zen-code 4.10.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/app.js +149 -239
  2. package/dist/{chunk-vbb3m0vz.js → chunk-069q9hkz.js} +1 -1
  3. package/dist/chunk-06trk066.js +1 -0
  4. package/dist/chunk-0kfw8bwn.js +2 -0
  5. package/dist/chunk-0mq8786q.js +281 -0
  6. package/dist/{chunk-mmx0k2yq.js → chunk-0qz8rr2k.js} +1 -1
  7. package/dist/chunk-1d47g6nc.js +2 -0
  8. package/dist/{chunk-nqh1pptf.js → chunk-1gssqf6g.js} +1 -1
  9. package/dist/{chunk-s5cqejr6.js → chunk-1rcc9xzn.js} +1 -1
  10. package/dist/{chunk-tjvhqr94.js → chunk-2bjeg40f.js} +1 -1
  11. package/dist/chunk-2gd8vzrf.js +2 -0
  12. package/dist/{chunk-spx7nn8t.js → chunk-2gprcgep.js} +2 -2
  13. package/dist/chunk-3k3c686f.js +1 -0
  14. package/dist/chunk-43h0n2td.js +1 -0
  15. package/dist/{chunk-8f19qk9r.js → chunk-492hjs9k.js} +1 -1
  16. package/dist/{chunk-pe8mzxwn.js → chunk-4eaqmt3c.js} +11 -11
  17. package/dist/{chunk-y8qhrx11.js → chunk-4fs853nh.js} +1 -1
  18. package/dist/chunk-5fe27s34.js +2 -0
  19. package/dist/{chunk-4wnmk2tj.js → chunk-5hqvapp1.js} +3 -3
  20. package/dist/chunk-6b3vfr39.js +2 -0
  21. package/dist/{chunk-t6440ajd.js → chunk-6j695pam.js} +2 -2
  22. package/dist/{chunk-pzb224c5.js → chunk-6saqxa3z.js} +2 -2
  23. package/dist/{chunk-tjg2e8v3.js → chunk-78ksrp8v.js} +2 -2
  24. package/dist/chunk-7cx9kda0.js +228 -0
  25. package/dist/chunk-7qba2raw.js +2 -0
  26. package/dist/chunk-81b2s97q.js +1 -0
  27. package/dist/chunk-88w3txtb.js +160 -0
  28. package/dist/chunk-8ygdre0g.js +1 -0
  29. package/dist/{chunk-fzh0v6r0.js → chunk-9011y634.js} +2 -2
  30. package/dist/chunk-9zcr1qh6.js +1 -0
  31. package/dist/chunk-a0nr8jva.js +2 -0
  32. package/dist/{chunk-5c3bpcpm.js → chunk-agevsn2e.js} +1 -1
  33. package/dist/{chunk-8tbtavry.js → chunk-akc3s5aw.js} +2 -2
  34. package/dist/{chunk-spa69h7p.js → chunk-b0beqmg2.js} +2 -2
  35. package/dist/{chunk-zg54h6gy.js → chunk-b175s7dm.js} +1 -1
  36. package/dist/chunk-bk32cwxa.js +5 -0
  37. package/dist/{chunk-vrnj0659.js → chunk-bn077sjq.js} +15 -15
  38. package/dist/{chunk-qxebn3jw.js → chunk-c9yrpb3g.js} +3 -3
  39. package/dist/{chunk-hnnwbfqk.js → chunk-cb0f54ar.js} +2 -2
  40. package/dist/chunk-ctqtahz4.js +1 -0
  41. package/dist/{chunk-gt8c6dne.js → chunk-d2sr8fnm.js} +1 -1
  42. package/dist/chunk-d5gzkkgg.js +1 -0
  43. package/dist/{chunk-bzgznka5.js → chunk-dh2f4xyb.js} +1 -1
  44. package/dist/chunk-dr32dt9y.js +1 -0
  45. package/dist/chunk-dv1vt080.js +1 -0
  46. package/dist/{chunk-vfxjbdz4.js → chunk-dz9sqfph.js} +1 -1
  47. package/dist/chunk-e7mbewmw.js +1 -0
  48. package/dist/chunk-em03xqy9.js +1 -0
  49. package/dist/chunk-fkt5b511.js +1 -0
  50. package/dist/{chunk-k4q8j7pg.js → chunk-gphssgy6.js} +1 -1
  51. package/dist/chunk-h2hk7vx4.js +1 -0
  52. package/dist/{chunk-c7kd2qrp.js → chunk-h7ypcqp3.js} +112 -111
  53. package/dist/{chunk-nsw5168d.js → chunk-j8tq0e8m.js} +2 -2
  54. package/dist/{chunk-40ht9pe1.js → chunk-jd1razfg.js} +2 -2
  55. package/dist/chunk-jhxvctg5.js +8 -0
  56. package/dist/chunk-kada5fyh.js +1 -0
  57. package/dist/chunk-kgc6ws03.js +1 -0
  58. package/dist/chunk-mk8ggmt8.js +17 -0
  59. package/dist/{chunk-e8kxa5vj.js → chunk-mv5m8bf4.js} +2 -2
  60. package/dist/chunk-mv8a5svx.js +1 -0
  61. package/dist/chunk-n61yv4t5.js +2 -0
  62. package/dist/chunk-nt2yp4jh.js +1 -0
  63. package/dist/chunk-p7ew4trx.js +1 -0
  64. package/dist/{chunk-s1tbdcs8.js → chunk-pgnhcznr.js} +1 -1
  65. package/dist/chunk-q8cfxky4.js +8 -0
  66. package/dist/{chunk-g2zskge5.js → chunk-q8zsxwd8.js} +2 -2
  67. package/dist/{chunk-nmzx5nmt.js → chunk-qfa5v4n5.js} +1 -1
  68. package/dist/chunk-qhzztj83.js +1 -0
  69. package/dist/chunk-snmkgfbe.js +15 -0
  70. package/dist/chunk-ss4bh5wb.js +2 -0
  71. package/dist/chunk-sv0k2v66.js +1 -0
  72. package/dist/{chunk-wmyc17aa.js → chunk-tbav8trq.js} +1 -1
  73. package/dist/chunk-tmyzfvsy.js +1 -0
  74. package/dist/chunk-ts4jreym.js +7 -0
  75. package/dist/chunk-tws3wcnm.js +2 -0
  76. package/dist/chunk-v0e9bsvt.js +89 -0
  77. package/dist/{chunk-n9rpnke9.js → chunk-vwj4n000.js} +1 -1
  78. package/dist/{chunk-gfhmzpy7.js → chunk-wd6s7gg7.js} +2 -3
  79. package/dist/{chunk-f0m4532p.js → chunk-y524zd2h.js} +5 -5
  80. package/dist/{chunk-hve2a279.js → chunk-yb71zqvt.js} +2 -2
  81. package/dist/{chunk-n7s6my89.js → chunk-yejgw2hm.js} +32 -32
  82. package/dist/{chunk-g974hxbz.js → chunk-yfjs6pf8.js} +1 -1
  83. package/dist/chunk-zhqdp4ak.js +2 -0
  84. package/dist/chunk-zkd3m39v.js +1 -0
  85. package/dist/cli.js +1 -1
  86. package/dist/nonInteractive.js +80 -80
  87. package/dist/zen-core.js +644 -0
  88. package/dist/zen-keyboard.js +1 -1
  89. package/package.json +5 -3
  90. package/dist/chunk-0ddrb30y.js +0 -1
  91. package/dist/chunk-215an3fz.js +0 -1
  92. package/dist/chunk-4z0w0ng1.js +0 -2
  93. package/dist/chunk-57bj89e2.js +0 -1
  94. package/dist/chunk-5a5mepqj.js +0 -1
  95. package/dist/chunk-7kw7ss8d.js +0 -1
  96. package/dist/chunk-86m0rmtc.js +0 -1
  97. package/dist/chunk-9rayxazs.js +0 -8
  98. package/dist/chunk-a9gpb2tx.js +0 -2
  99. package/dist/chunk-a9tw6d68.js +0 -1
  100. package/dist/chunk-anbtppz1.js +0 -294
  101. package/dist/chunk-bca8tkkr.js +0 -1
  102. package/dist/chunk-bdqds8vh.js +0 -1
  103. package/dist/chunk-dvbb3dd1.js +0 -233
  104. package/dist/chunk-ehmmd8qc.js +0 -1
  105. package/dist/chunk-ejfa95sm.js +0 -1
  106. package/dist/chunk-f7cps5x1.js +0 -1
  107. package/dist/chunk-fbemqjck.js +0 -2
  108. package/dist/chunk-feeqtzv5.js +0 -1
  109. package/dist/chunk-g9911ymn.js +0 -1
  110. package/dist/chunk-h8fdexm4.js +0 -2
  111. package/dist/chunk-hp2jzn9x.js +0 -166
  112. package/dist/chunk-js4qp900.js +0 -2
  113. package/dist/chunk-m21hvv91.js +0 -2
  114. package/dist/chunk-mnnyjmgw.js +0 -224
  115. package/dist/chunk-mw7x6xqp.js +0 -1
  116. package/dist/chunk-nk62q95g.js +0 -93
  117. package/dist/chunk-pg1ppq4y.js +0 -1
  118. package/dist/chunk-q1cxrg0x.js +0 -2
  119. package/dist/chunk-swc7se71.js +0 -2
  120. package/dist/chunk-swyc15ym.js +0 -1
  121. package/dist/chunk-t2s3s6af.js +0 -1
  122. package/dist/chunk-vdmq9d9x.js +0 -4
  123. package/dist/chunk-wt3p1w1g.js +0 -1
  124. package/dist/chunk-y5ry5c7v.js +0 -1
  125. package/dist/chunk-yy8p9zph.js +0 -2
  126. package/dist/chunk-z61m3anh.js +0 -1
  127. package/dist/chunk-zr90qp47.js +0 -1
  128. package/dist/chunk-zsa62xr0.js +0 -2
@@ -1 +1 @@
1
- import{f as i,g as u}from"./chunk-swc7se71.js";import"./chunk-n9rpnke9.js";import"./chunk-y8qhrx11.js";function l(e,t){let r=t?"query":"prepare",a=(o,n)=>e[r](o,n);return{db:e,query:(o,n,s)=>{let c=a(n,s);if(c.columnNames.length>0)return{rows:c.all()};else{let{changes:m,lastInsertRowid:p}=c.run();return{numAffectedRows:i(m),insertId:i(p),rows:[]}}},close:()=>e.close(),iterator:(o,n,s)=>f(a(n),s)}}async function*f(e,t){if(!("iterate"in e))throw Error("Streaming not supported, please upgrade to Bun@1.1.31 or later");for(let r of e.iterate(...t||[]))yield r}import w from"bun:sqlite";var y=class extends u{constructor(e){let{url:t=":memory:",cacheStatment:r=!1,onCreateConnection:a,dbOptions:o={create:!0}}=e||{};super(()=>l(new w(t,o),r),a)}};export{y as BunSqliteDialect};
1
+ import{c as i,d as u}from"./chunk-a0nr8jva.js";import"./chunk-vwj4n000.js";import"./chunk-4fs853nh.js";function l(e,t){let r=t?"query":"prepare",a=(o,n)=>e[r](o,n);return{db:e,query:(o,n,s)=>{let c=a(n,s);if(c.columnNames.length>0)return{rows:c.all()};else{let{changes:m,lastInsertRowid:p}=c.run();return{numAffectedRows:i(m),insertId:i(p),rows:[]}}},close:()=>e.close(),iterator:(o,n,s)=>f(a(n),s)}}async function*f(e,t){if(!("iterate"in e))throw Error("Streaming not supported, please upgrade to Bun@1.1.31 or later");for(let r of e.iterate(...t||[]))yield r}import w from"bun:sqlite";var y=class extends u{constructor(e){let{url:t=":memory:",cacheStatment:r=!1,onCreateConnection:a,dbOptions:o={create:!0}}=e||{};super(()=>l(new w(t,o),r),a)}};export{y as BunSqliteDialect};
@@ -0,0 +1,2 @@
1
+ import{H as a}from"./chunk-5fe27s34.js";import{K as f,M as r,N as l,O as n}from"./chunk-5hqvapp1.js";import{U as x,fa as P}from"./chunk-h7ypcqp3.js";import{Wl as g}from"./chunk-4fs853nh.js";var t=g(x(),1);function _({enabled:o=!0}={}){let i=a();return r({queryKey:n.config.detail(),queryFn:()=>i.config.get.query(),enabled:o,staleTime:300000,gcTime:600000})}function v(){let o=a(),i=f();return l({mutationFn:(e)=>o.config.update.mutate(e),onSuccess:(e)=>{i.setQueryData(n.config.detail(),e),i.invalidateQueries({queryKey:n.providers.all}),i.invalidateQueries({queryKey:n.models.all})}})}var h=g(P(),1),C=t.createContext(void 0),B=()=>{let o=t.useContext(C);if(o===void 0)throw Error("useSettings must be used within a SettingsProvider");return o},N=({children:o})=>{let i=a(),{data:e}=_(),d=v(),s=e?.provider_id,{data:c=[]}=r({queryKey:n.models.available(s),queryFn:()=>i.models.list.query({providerId:s}),staleTime:1800000,retry:1,enabled:!!s}),u=t.useMemo(()=>{return{provider_id:e?.provider_id||"openai",provider_type:e?.provider_type||"openai",model_id:e?.model_id||c[0]?.id||"default",mcp_config:e?.mcp_config,enable_thinking:e?.enable_thinking??!0,streaming:e?.streaming??!1,active_agent:e?.active_agent||"",cwd:process.cwd()}},[e?.provider_id,e?.provider_type,e?.model_id,e?.mcp_config,e?.enable_thinking,e?.streaming,e?.active_agent,e?.providers,c]),p=t.useMemo(()=>e?.compact_mode??!1,[e?.compact_mode]),A=async()=>{await d.mutateAsync({compact_mode:!p})},m=t.useMemo(()=>e?.show_detailed_info??!1,[e?.show_detailed_info]),S=async()=>{await d.mutateAsync({show_detailed_info:!m})},M=async(w)=>{await d.mutateAsync(w)};return h.jsxDEV(C.Provider,{value:{config:e||null,updateConfig:M,extraParams:u,AVAILABLE_MODELS:c,compactMode:p,toggleCompactMode:A,showDetailedInfo:m,toggleDetailedInfo:S},children:o},void 0,!1,void 0,this)};
2
+ export{B as E,N as F};
@@ -1,4 +1,4 @@
1
- import{$g as s$,Fg as u,Yg as VO,_g as SO}from"./chunk-hp2jzn9x.js";import"./chunk-nk62q95g.js";import"./chunk-nmzx5nmt.js";import"./chunk-tjg2e8v3.js";import"./chunk-hve2a279.js";import{Dl as vG,Fl as R,Il as W}from"./chunk-y8qhrx11.js";var L$=R((wO)=>{wO.parse=function($,E){return new W$($,E).parse()};class W${constructor($,E){this.source=$,this.transform=E||kO,this.position=0,this.entries=[],this.recorded=[],this.dimension=0}isEof(){return this.position>=this.source.length}nextCharacter(){var $=this.source[this.position++];if($==="\\")return{value:this.source[this.position++],escaped:!0};return{value:$,escaped:!1}}record($){this.recorded.push($)}newEntry($){var E;if(this.recorded.length>0||$){if(E=this.recorded.join(""),E==="NULL"&&!$)E=null;if(E!==null)E=this.transform(E);this.entries.push(E),this.recorded=[]}}consumeDimensions(){if(this.source[0]==="[")while(!this.isEof()){var $=this.nextCharacter();if($.value==="=")break}}parse($){var E,_,O;this.consumeDimensions();while(!this.isEof())if(E=this.nextCharacter(),E.value==="{"&&!O){if(this.dimension++,this.dimension>1)_=new W$(this.source.substr(this.position-1),this.transform),this.entries.push(_.parse(!0)),this.position+=_.position-2}else if(E.value==="}"&&!O){if(this.dimension--,!this.dimension){if(this.newEntry(),$)return this.entries}}else if(E.value==='"'&&!E.escaped){if(O)this.newEntry(!0);O=!O}else if(E.value===","&&!O)this.newEntry();else this.record(E.value);if(this.dimension!==0)throw Error("array dimension not balanced");return this.entries}}function kO($){return $}});var Q$=R((nG,e$)=>{var hO=L$();e$.exports={create:function($,E){return{parse:function(){return hO.parse($,E)}}}}});var _E=R((iG,EE)=>{var bO=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,yO=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,vO=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,pO=/^-?infinity$/;EE.exports=function(E){if(pO.test(E))return Number(E.replace("i","I"));var _=bO.exec(E);if(!_)return mO(E)||null;var O=!!_[8],G=parseInt(_[1],10);if(O)G=$E(G);var X=parseInt(_[2],10)-1,U=_[3],J=parseInt(_[4],10),Z=parseInt(_[5],10),H=parseInt(_[6],10),Y=_[7];Y=Y?1000*parseFloat(Y):0;var T,K=fO(E);if(K!=null){if(T=new Date(Date.UTC(G,X,U,J,Z,H,Y)),j$(G))T.setUTCFullYear(G);if(K!==0)T.setTime(T.getTime()-K)}else if(T=new Date(G,X,U,J,Z,H,Y),j$(G))T.setFullYear(G);return T};function mO($){var E=yO.exec($);if(!E)return;var _=parseInt(E[1],10),O=!!E[4];if(O)_=$E(_);var G=parseInt(E[2],10)-1,X=E[3],U=new Date(_,G,X);if(j$(_))U.setFullYear(_);return U}function fO($){if($.endsWith("+00"))return 0;var E=vO.exec($.split(" ")[1]);if(!E)return;var _=E[1];if(_==="Z")return 0;var O=_==="-"?-1:1,G=parseInt(E[2],10)*3600+parseInt(E[3]||0,10)*60+parseInt(E[4]||0,10);return G*O*1000}function $E($){return-($-1)}function j$($){return $>=0&&$<100}});var GE=R((sG,OE)=>{OE.exports=uO;var dO=Object.prototype.hasOwnProperty;function uO($){for(var E=1;E<arguments.length;E++){var _=arguments[E];for(var O in _)if(dO.call(_,O))$[O]=_[O]}return $}});var JE=R((tG,UE)=>{var gO=GE();UE.exports=x;function x($){if(!(this instanceof x))return new x($);gO(this,E0($))}var cO=["seconds","minutes","hours","days","months","years"];x.prototype.toPostgres=function(){var $=cO.filter(this.hasOwnProperty,this);if(this.milliseconds&&$.indexOf("seconds")<0)$.push("seconds");if($.length===0)return"0";return $.map(function(E){var _=this[E]||0;if(E==="seconds"&&this.milliseconds)_=(_+this.milliseconds/1000).toFixed(6).replace(/\.?0+$/,"");return _+" "+E},this).join(" ")};var lO={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"S"},oO=["years","months","days"],nO=["hours","minutes","seconds"];x.prototype.toISOString=x.prototype.toISO=function(){var $=oO.map(_,this).join(""),E=nO.map(_,this).join("");return"P"+$+"T"+E;function _(O){var G=this[O]||0;if(O==="seconds"&&this.milliseconds)G=(G+this.milliseconds/1000).toFixed(6).replace(/0+$/,"");return G+lO[O]}};var N$="([+-]?\\d+)",iO=N$+"\\s+years?",sO=N$+"\\s+mons?",tO=N$+"\\s+days?",aO="([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",rO=new RegExp([iO,sO,tO,aO].map(function($){return"("+$+")?"}).join("\\s*")),XE={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},eO=["hours","minutes","seconds","milliseconds"];function $0($){var E=$+"000000".slice($.length);return parseInt(E,10)/1000}function E0($){if(!$)return{};var E=rO.exec($),_=E[8]==="-";return Object.keys(XE).reduce(function(O,G){var X=XE[G],U=E[X];if(!U)return O;if(U=G==="milliseconds"?$0(U):parseInt(U,10),!U)return O;if(_&&~eO.indexOf(G))U*=-1;return O[G]=U,O},{})}});var TE=R((aG,HE)=>{var ZE=Buffer.from||Buffer;HE.exports=function(E){if(/^\\x/.test(E))return ZE(E.substr(2),"hex");var _="",O=0;while(O<E.length)if(E[O]!=="\\")_+=E[O],++O;else if(/[0-7]{3}/.test(E.substr(O+1,3)))_+=String.fromCharCode(parseInt(E.substr(O+1,3),8)),O+=4;else{var G=1;while(O+G<E.length&&E[O+G]==="\\")G++;for(var X=0;X<Math.floor(G/2);++X)_+="\\";O+=Math.floor(G/2)*2}return ZE(_,"binary")}});var jE=R((rG,QE)=>{var c=L$(),l=Q$(),$$=_E(),RE=JE(),KE=TE();function E$($){return function(_){if(_===null)return _;return $(_)}}function WE($){if($===null)return $;return $==="TRUE"||$==="t"||$==="true"||$==="y"||$==="yes"||$==="on"||$==="1"}function _0($){if(!$)return null;return c.parse($,WE)}function O0($){return parseInt($,10)}function F$($){if(!$)return null;return c.parse($,E$(O0))}function G0($){if(!$)return null;return c.parse($,E$(function(E){return LE(E).trim()}))}var X0=function($){if(!$)return null;var E=l.create($,function(_){if(_!==null)_=D$(_);return _});return E.parse()},z$=function($){if(!$)return null;var E=l.create($,function(_){if(_!==null)_=parseFloat(_);return _});return E.parse()},V=function($){if(!$)return null;var E=l.create($);return E.parse()},P$=function($){if(!$)return null;var E=l.create($,function(_){if(_!==null)_=$$(_);return _});return E.parse()},U0=function($){if(!$)return null;var E=l.create($,function(_){if(_!==null)_=RE(_);return _});return E.parse()},J0=function($){if(!$)return null;return c.parse($,E$(KE))},A$=function($){return parseInt($,10)},LE=function($){var E=String($);if(/^\d+$/.test(E))return E;return $},YE=function($){if(!$)return null;return c.parse($,E$(JSON.parse))},D$=function($){if($[0]!=="(")return null;return $=$.substring(1,$.length-1).split(","),{x:parseFloat($[0]),y:parseFloat($[1])}},Z0=function($){if($[0]!=="<"&&$[1]!=="(")return null;var E="(",_="",O=!1;for(var G=2;G<$.length-1;G++){if(!O)E+=$[G];if($[G]===")"){O=!0;continue}else if(!O)continue;if($[G]===",")continue;_+=$[G]}var X=D$(E);return X.radius=parseFloat(_),X},H0=function($){$(20,LE),$(21,A$),$(23,A$),$(26,A$),$(700,parseFloat),$(701,parseFloat),$(16,WE),$(1082,$$),$(1114,$$),$(1184,$$),$(600,D$),$(651,V),$(718,Z0),$(1000,_0),$(1001,J0),$(1005,F$),$(1007,F$),$(1028,F$),$(1016,G0),$(1017,X0),$(1021,z$),$(1022,z$),$(1231,z$),$(1014,V),$(1015,V),$(1008,V),$(1009,V),$(1040,V),$(1041,V),$(1115,P$),$(1182,P$),$(1185,P$),$(1186,RE),$(1187,U0),$(17,KE),$(114,JSON.parse.bind(JSON)),$(3802,JSON.parse.bind(JSON)),$(199,YE),$(3807,YE),$(3907,V),$(2951,V),$(791,V),$(1183,V),$(1270,V)};QE.exports={init:H0}});var FE=R((eG,NE)=>{var P=1e6;function T0($){var E=$.readInt32BE(0),_=$.readUInt32BE(4),O="";if(E<0)E=~E+(_===0),_=~_+1>>>0,O="-";var G="",X,U,J,Z,H,Y;{if(X=E%P,E=E/P>>>0,U=4294967296*X+_,_=U/P>>>0,J=""+(U-P*_),_===0&&E===0)return O+J+G;Z="",H=6-J.length;for(Y=0;Y<H;Y++)Z+="0";G=Z+J+G}{if(X=E%P,E=E/P>>>0,U=4294967296*X+_,_=U/P>>>0,J=""+(U-P*_),_===0&&E===0)return O+J+G;Z="",H=6-J.length;for(Y=0;Y<H;Y++)Z+="0";G=Z+J+G}{if(X=E%P,E=E/P>>>0,U=4294967296*X+_,_=U/P>>>0,J=""+(U-P*_),_===0&&E===0)return O+J+G;Z="",H=6-J.length;for(Y=0;Y<H;Y++)Z+="0";G=Z+J+G}return X=E%P,U=4294967296*X+_,J=""+U%P,O+J+G}NE.exports=T0});var ME=R(($8,DE)=>{var Y0=FE(),j=function($,E,_,O,G){_=_||0,O=O||!1,G=G||function(Q,C,K$){return Q*Math.pow(2,K$)+C};var X=_>>3,U=function(Q){if(O)return~Q&255;return Q},J=255,Z=8-_%8;if(E<Z)J=255<<8-E&255,Z=E;if(_)J=J>>_%8;var H=0;if(_%8+E>=8)H=G(0,U($[X])&J,Z);var Y=E+_>>3;for(var T=X+1;T<Y;T++)H=G(H,U($[T]),8);var K=(E+_)%8;if(K>0)H=G(H,U($[Y])>>8-K,K);return H},AE=function($,E,_){var O=Math.pow(2,_-1)-1,G=j($,1),X=j($,_,1);if(X===0)return 0;var U=1,J=function(H,Y,T){if(H===0)H=1;for(var K=1;K<=T;K++)if(U/=2,(Y&1<<T-K)>0)H+=U;return H},Z=j($,E,_+1,!1,J);if(X==Math.pow(2,_+1)-1){if(Z===0)return G===0?1/0:-1/0;return NaN}return(G===0?1:-1)*Math.pow(2,X-O)*Z},R0=function($){if(j($,1)==1)return-1*(j($,15,1,!0)+1);return j($,15,1)},zE=function($){if(j($,1)==1)return-1*(j($,31,1,!0)+1);return j($,31,1)},K0=function($){return AE($,23,8)},W0=function($){return AE($,52,11)},L0=function($){var E=j($,16,32);if(E==49152)return NaN;var _=Math.pow(1e4,j($,16,16)),O=0,G=[],X=j($,16);for(var U=0;U<X;U++)O+=j($,16,64+16*U)*_,_/=1e4;var J=Math.pow(10,j($,16,48));return(E===0?1:-1)*Math.round(O*J)/J},PE=function($,E){var _=j(E,1),O=j(E,63,1),G=new Date((_===0?1:-1)*O/1000+946684800000);if(!$)G.setTime(G.getTime()+G.getTimezoneOffset()*60000);return G.usec=O%1000,G.getMicroSeconds=function(){return this.usec},G.setMicroSeconds=function(X){this.usec=X},G.getUTCMicroSeconds=function(){return this.usec},G},o=function($){var E=j($,32),_=j($,32,32),O=j($,32,64),G=96,X=[];for(var U=0;U<E;U++)X[U]=j($,32,G),G+=32,G+=32;var J=function(H){var Y=j($,32,G);if(G+=32,Y==4294967295)return null;var T;if(H==23||H==20)return T=j($,Y*8,G),G+=Y*8,T;else if(H==25)return T=$.toString(this.encoding,G>>3,(G+=Y<<3)>>3),T;else console.log("ERROR: ElementType not implemented: "+H)},Z=function(H,Y){var T=[],K;if(H.length>1){var Q=H.shift();for(K=0;K<Q;K++)T[K]=Z(H,Y);H.unshift(Q)}else for(K=0;K<H[0];K++)T[K]=J(Y);return T};return Z(X,O)},Q0=function($){return $.toString("utf8")},j0=function($){if($===null)return null;return j($,8)>0},N0=function($){$(20,Y0),$(21,R0),$(23,zE),$(26,zE),$(1700,L0),$(700,K0),$(701,W0),$(16,j0),$(1114,PE.bind(null,!1)),$(1184,PE.bind(null,!0)),$(1000,o),$(1007,o),$(1016,o),$(1008,o),$(1009,o),$(25,Q0)};DE.exports={init:N0}});var SE=R((E8,VE)=>{VE.exports={BOOL:16,BYTEA:17,CHAR:18,INT8:20,INT2:21,INT4:23,REGPROC:24,TEXT:25,OID:26,TID:27,XID:28,CID:29,JSON:114,XML:142,PG_NODE_TREE:194,SMGR:210,PATH:602,POLYGON:604,CIDR:650,FLOAT4:700,FLOAT8:701,ABSTIME:702,RELTIME:703,TINTERVAL:704,CIRCLE:718,MACADDR8:774,MONEY:790,MACADDR:829,INET:869,ACLITEM:1033,BPCHAR:1042,VARCHAR:1043,DATE:1082,TIME:1083,TIMESTAMP:1114,TIMESTAMPTZ:1184,INTERVAL:1186,TIMETZ:1266,BIT:1560,VARBIT:1562,NUMERIC:1700,REFCURSOR:1790,REGPROCEDURE:2202,REGOPER:2203,REGOPERATOR:2204,REGCLASS:2205,REGTYPE:2206,UUID:2950,TXID_SNAPSHOT:2970,PG_LSN:3220,PG_NDISTINCT:3361,PG_DEPENDENCIES:3402,TSVECTOR:3614,TSQUERY:3615,GTSVECTOR:3642,REGCONFIG:3734,REGDICTIONARY:3769,JSONB:3802,REGNAMESPACE:4089,REGROLE:4096}});var i=R((V0)=>{var F0=jE(),z0=ME(),P0=Q$(),A0=SE();V0.getTypeParser=D0;V0.setTypeParser=M0;V0.arrayParser=P0;V0.builtins=A0;var n={text:{},binary:{}};function CE($){return String($)}function D0($,E){if(E=E||"text",!n[E])return CE;return n[E][$]||CE}function M0($,E,_){if(typeof E=="function")_=E,E="text";n[E][$]=_}F0.init(function($,E){n.text[$]=E});z0.init(function($,E){n.binary[$]=E})});var s=R((O8,M$)=>{var IE;try{IE=process.platform==="win32"?process.env.USERNAME:process.env.USER}catch{}M$.exports={host:"localhost",user:IE,database:void 0,password:null,connectionString:void 0,port:5432,rows:0,binary:!1,max:10,idleTimeoutMillis:30000,client_encoding:"",ssl:!1,application_name:void 0,fallback_application_name:void 0,options:void 0,parseInputDatesAsUTC:!1,statement_timeout:!1,lock_timeout:!1,idle_in_transaction_session_timeout:!1,query_timeout:!1,connect_timeout:0,keepalives:1,keepalives_idle:0};var h=i(),B0=h.getTypeParser(20,"text"),k0=h.getTypeParser(1016,"text");M$.exports.__defineSetter__("parseInt8",function($){h.setTypeParser(20,"text",$?h.getTypeParser(23,"text"):B0),h.setTypeParser(1016,"text",$?h.getTypeParser(1007,"text"):k0)})});var b=R((G8,kE)=>{var w0=s(),qE=W("util"),{isDate:x0}=qE.types||qE;function h0($){return'"'+$.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")+'"'}function BE($){let E="{";for(let _=0;_<$.length;_++){if(_>0)E=E+",";if($[_]===null||typeof $[_]>"u")E=E+"NULL";else if(Array.isArray($[_]))E=E+BE($[_]);else if(ArrayBuffer.isView($[_])){let O=$[_];if(!(O instanceof Buffer)){let G=Buffer.from(O.buffer,O.byteOffset,O.byteLength);if(G.length===O.byteLength)O=G;else O=G.slice(O.byteOffset,O.byteOffset+O.byteLength)}E+="\\\\x"+O.toString("hex")}else E+=h0(_$($[_]))}return E=E+"}",E}var _$=function($,E){if($==null)return null;if(typeof $==="object"){if($ instanceof Buffer)return $;if(ArrayBuffer.isView($)){let _=Buffer.from($.buffer,$.byteOffset,$.byteLength);if(_.length===$.byteLength)return _;return _.slice($.byteOffset,$.byteOffset+$.byteLength)}if(x0($))if(w0.parseInputDatesAsUTC)return v0($);else return y0($);if(Array.isArray($))return BE($);return b0($,E)}return $.toString()};function b0($,E){if($&&typeof $.toPostgres==="function"){if(E=E||[],E.indexOf($)!==-1)throw Error('circular reference detected while preparing "'+$+'" for query');return E.push($),_$($.toPostgres(_$),E)}return JSON.stringify($)}function y0($){let E=-$.getTimezoneOffset(),_=$.getFullYear(),O=_<1;if(O)_=Math.abs(_)+1;let G=String(_).padStart(4,"0")+"-"+String($.getMonth()+1).padStart(2,"0")+"-"+String($.getDate()).padStart(2,"0")+"T"+String($.getHours()).padStart(2,"0")+":"+String($.getMinutes()).padStart(2,"0")+":"+String($.getSeconds()).padStart(2,"0")+"."+String($.getMilliseconds()).padStart(3,"0");if(E<0)G+="-",E*=-1;else G+="+";if(G+=String(Math.floor(E/60)).padStart(2,"0")+":"+String(E%60).padStart(2,"0"),O)G+=" BC";return G}function v0($){let E=$.getUTCFullYear(),_=E<1;if(_)E=Math.abs(E)+1;let O=String(E).padStart(4,"0")+"-"+String($.getUTCMonth()+1).padStart(2,"0")+"-"+String($.getUTCDate()).padStart(2,"0")+"T"+String($.getUTCHours()).padStart(2,"0")+":"+String($.getUTCMinutes()).padStart(2,"0")+":"+String($.getUTCSeconds()).padStart(2,"0")+"."+String($.getUTCMilliseconds()).padStart(3,"0");if(O+="+00:00",_)O+=" BC";return O}function p0($,E,_){if($=typeof $==="string"?{text:$}:$,E)if(typeof E==="function")$.callback=E;else $.values=E;if(_)$.callback=_;return $}var m0=function($){return'"'+$.replace(/"/g,'""')+'"'},f0=function($){let E=!1,_="'";if($==null)return"''";if(typeof $!=="string")return"''";for(let O=0;O<$.length;O++){let G=$[O];if(G==="'")_+=G+G;else if(G==="\\")_+=G+G,E=!0;else _+=G}if(_+="'",E===!0)_=" E"+_;return _};kE.exports={prepareValue:function(E){return _$(E)},normalizeQueryConfig:p0,escapeIdentifier:m0,escapeLiteral:f0}});var xE=R((X8,wE)=>{var y=W("crypto");function V$($){return y.createHash("md5").update($,"utf-8").digest("hex")}function d0($,E,_){let O=V$(E+$);return"md5"+V$(Buffer.concat([Buffer.from(O),_]))}function u0($){return y.createHash("sha256").update($).digest()}function g0($,E){return $=$.replace(/(\D)-/,"$1"),y.createHash($).update(E).digest()}function c0($,E){return y.createHmac("sha256",$).update(E).digest()}async function l0($,E,_){return y.pbkdf2Sync($,E,_,32,"sha256")}wE.exports={postgresMd5PasswordHash:d0,randomBytes:y.randomBytes,deriveKey:l0,sha256:u0,hashByName:g0,hmacSha256:c0,md5:V$}});var vE=R((U8,yE)=>{var hE=W("crypto");yE.exports={postgresMd5PasswordHash:n0,randomBytes:o0,deriveKey:a0,sha256:i0,hashByName:s0,hmacSha256:t0,md5:S$};var bE=hE.webcrypto||globalThis.crypto,k=bE.subtle,C$=new TextEncoder;function o0($){return bE.getRandomValues(Buffer.alloc($))}async function S$($){try{return hE.createHash("md5").update($,"utf-8").digest("hex")}catch(E){let _=typeof $==="string"?C$.encode($):$,O=await k.digest("MD5",_);return Array.from(new Uint8Array(O)).map((G)=>G.toString(16).padStart(2,"0")).join("")}}async function n0($,E,_){let O=await S$(E+$);return"md5"+await S$(Buffer.concat([Buffer.from(O),_]))}async function i0($){return await k.digest("SHA-256",$)}async function s0($,E){return await k.digest($,E)}async function t0($,E){let _=await k.importKey("raw",$,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return await k.sign("HMAC",_,C$.encode(E))}async function a0($,E,_){let O=await k.importKey("raw",C$.encode($),"PBKDF2",!1,["deriveBits"]),G={name:"PBKDF2",hash:"SHA-256",salt:E,iterations:_};return await k.deriveBits(G,O,256,["deriveBits"])}});var q$=R((J8,I$)=>{var r0=parseInt(process.versions&&process.versions.node&&process.versions.node.split(".")[0])<15;if(r0)I$.exports=xE();else I$.exports=vE()});var fE=R((Z8,mE)=>{function w($,E){return Error("SASL channel binding: "+$+" when parsing public certificate "+E.toString("base64"))}function B$($,E){let _=$[E++];if(_<128)return{length:_,index:E};let O=_&127;if(O>4)throw w("bad length",$);_=0;for(let G=0;G<O;G++)_=_<<8|$[E++];return{length:_,index:E}}function pE($,E){if($[E++]!==6)throw w("non-OID data",$);let{length:_,index:O}=B$($,E);E=O;let G=E+_,X=$[E++],U=(X/40>>0)+"."+X%40;while(E<G){let J=0;while(E<G){let Z=$[E++];if(J=J<<7|Z&127,Z<128)break}U+="."+J}return{oid:U,index:E}}function t($,E){if($[E++]!==48)throw w("non-sequence data",$);return B$($,E)}function e0($,E){if(E===void 0)E=0;E=t($,E).index;let{length:_,index:O}=t($,E);E=O+_,E=t($,E).index;let{oid:G,index:X}=pE($,E);switch(G){case"1.2.840.113549.1.1.4":return"MD5";case"1.2.840.113549.1.1.5":return"SHA-1";case"1.2.840.113549.1.1.11":return"SHA-256";case"1.2.840.113549.1.1.12":return"SHA-384";case"1.2.840.113549.1.1.13":return"SHA-512";case"1.2.840.113549.1.1.14":return"SHA-224";case"1.2.840.113549.1.1.15":return"SHA512-224";case"1.2.840.113549.1.1.16":return"SHA512-256";case"1.2.840.10045.4.1":return"SHA-1";case"1.2.840.10045.4.3.1":return"SHA-224";case"1.2.840.10045.4.3.2":return"SHA-256";case"1.2.840.10045.4.3.3":return"SHA-384";case"1.2.840.10045.4.3.4":return"SHA-512";case"1.2.840.113549.1.1.10":{if(E=X,E=t($,E).index,$[E++]!==160)throw w("non-tag data",$);E=B$($,E).index,E=t($,E).index;let{oid:U}=pE($,E);switch(U){case"1.2.840.113549.2.5":return"MD5";case"1.3.14.3.2.26":return"SHA-1";case"2.16.840.1.101.3.4.2.1":return"SHA-256";case"2.16.840.1.101.3.4.2.2":return"SHA-384";case"2.16.840.1.101.3.4.2.3":return"SHA-512"}throw w("unknown hash OID "+U,$)}case"1.3.101.110":case"1.3.101.112":return"SHA-512";case"1.3.101.111":case"1.3.101.113":throw w("Ed448 certificate channel binding is not currently supported by Postgres")}throw w("unknown OID "+G,$)}mE.exports={signatureAlgorithmHashFromCertificate:e0}});var cE=R((H8,gE)=>{var q=q$(),{signatureAlgorithmHashFromCertificate:$1}=fE();function E1($,E){let _=["SCRAM-SHA-256"];if(E)_.unshift("SCRAM-SHA-256-PLUS");let O=_.find((U)=>$.includes(U));if(!O)throw Error("SASL: Only mechanism(s) "+_.join(" and ")+" are supported");if(O==="SCRAM-SHA-256-PLUS"&&typeof E.getPeerCertificate!=="function")throw Error("SASL: Mechanism SCRAM-SHA-256-PLUS requires a certificate");let G=q.randomBytes(18).toString("base64");return{mechanism:O,clientNonce:G,response:(O==="SCRAM-SHA-256-PLUS"?"p=tls-server-end-point":E?"y":"n")+",,n=*,r="+G,message:"SASLInitialResponse"}}async function _1($,E,_,O){if($.message!=="SASLInitialResponse")throw Error("SASL: Last message was not SASLInitialResponse");if(typeof E!=="string")throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");if(E==="")throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string");if(typeof _!=="string")throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");let G=X1(_);if(!G.nonce.startsWith($.clientNonce))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");else if(G.nonce.length===$.clientNonce.length)throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short");let X="n=*,r="+$.clientNonce,U="r="+G.nonce+",s="+G.salt+",i="+G.iteration,J=O?"eSws":"biws";if($.mechanism==="SCRAM-SHA-256-PLUS"){let t$=O.getPeerCertificate().raw,e=$1(t$);if(e==="MD5"||e==="SHA-1")e="SHA-256";let BO=await q.hashByName(e,t$);J=Buffer.concat([Buffer.from("p=tls-server-end-point,,"),Buffer.from(BO)]).toString("base64")}let Z="c="+J+",r="+G.nonce,H=X+","+U+","+Z,Y=Buffer.from(G.salt,"base64"),T=await q.deriveKey(E,Y,G.iteration),K=await q.hmacSha256(T,"Client Key"),Q=await q.sha256(K),C=await q.hmacSha256(Q,H),K$=J1(Buffer.from(K),Buffer.from(C)).toString("base64"),IO=await q.hmacSha256(T,"Server Key"),qO=await q.hmacSha256(IO,H);$.message="SASLResponse",$.serverSignature=Buffer.from(qO).toString("base64"),$.response=Z+",p="+K$}function O1($,E){if($.message!=="SASLResponse")throw Error("SASL: Last message was not SASLResponse");if(typeof E!=="string")throw Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");let{serverSignature:_}=U1(E);if(_!==$.serverSignature)throw Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match")}function G1($){if(typeof $!=="string")throw TypeError("SASL: text must be a string");return $.split("").map((E,_)=>$.charCodeAt(_)).every((E)=>E>=33&&E<=43||E>=45&&E<=126)}function dE($){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test($)}function uE($){if(typeof $!=="string")throw TypeError("SASL: attribute pairs text must be a string");return new Map($.split(",").map((E)=>{if(!/^.=/.test(E))throw Error("SASL: Invalid attribute pair entry");let _=E[0],O=E.substring(2);return[_,O]}))}function X1($){let E=uE($),_=E.get("r");if(!_)throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");else if(!G1(_))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters");let O=E.get("s");if(!O)throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing");else if(!dE(O))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64");let G=E.get("i");if(!G)throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing");else if(!/^[1-9][0-9]*$/.test(G))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count");let X=parseInt(G,10);return{nonce:_,salt:O,iteration:X}}function U1($){let _=uE($).get("v");if(!_)throw Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");else if(!dE(_))throw Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64");return{serverSignature:_}}function J1($,E){if(!Buffer.isBuffer($))throw TypeError("first argument must be a Buffer");if(!Buffer.isBuffer(E))throw TypeError("second argument must be a Buffer");if($.length!==E.length)throw Error("Buffer lengths must match");if($.length===0)throw Error("Buffers cannot be empty");return Buffer.from($.map((_,O)=>$[O]^E[O]))}gE.exports={startSession:E1,continueSession:_1,finalizeSession:O1}});var G$=R((T8,lE)=>{var Z1=i();function O$($){this._types=$||Z1,this.text={},this.binary={}}O$.prototype.getOverrides=function($){switch($){case"text":return this.text;case"binary":return this.binary;default:return{}}};O$.prototype.setTypeParser=function($,E,_){if(typeof E==="function")_=E,E="text";this.getOverrides(E)[$]=_};O$.prototype.getTypeParser=function($,E){return E=E||"text",this.getOverrides(E)[$]||this._types.getTypeParser($,E)};lE.exports=O$});var iE=R((Y8,nE)=>{function v($,E={}){if($.charAt(0)==="/"){let Z=$.split(" ");return{host:Z[0],database:Z[1]}}let _={},O,G=!1;if(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test($))$=encodeURI($).replace(/%25(\d\d)/g,"%$1");try{try{O=new URL($,"postgres://base")}catch(Z){O=new URL($.replace("@/","@___DUMMY___/"),"postgres://base"),G=!0}}catch(Z){throw Z.input&&(Z.input="*****REDACTED*****"),Z}for(let Z of O.searchParams.entries())_[Z[0]]=Z[1];if(_.user=_.user||decodeURIComponent(O.username),_.password=_.password||decodeURIComponent(O.password),O.protocol=="socket:")return _.host=decodeURI(O.pathname),_.database=O.searchParams.get("db"),_.client_encoding=O.searchParams.get("encoding"),_;let X=G?"":O.hostname;if(!_.host)_.host=decodeURIComponent(X);else if(X&&/^%2f/i.test(X))O.pathname=X+O.pathname;if(!_.port)_.port=O.port;let U=O.pathname.slice(1)||null;if(_.database=U?decodeURI(U):null,_.ssl==="true"||_.ssl==="1")_.ssl=!0;if(_.ssl==="0")_.ssl=!1;if(_.sslcert||_.sslkey||_.sslrootcert||_.sslmode)_.ssl={};let J=_.sslcert||_.sslkey||_.sslrootcert?W("fs"):null;if(_.sslcert)_.ssl.cert=J.readFileSync(_.sslcert).toString();if(_.sslkey)_.ssl.key=J.readFileSync(_.sslkey).toString();if(_.sslrootcert)_.ssl.ca=J.readFileSync(_.sslrootcert).toString();if(E.useLibpqCompat&&_.uselibpqcompat)throw Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.");if(_.uselibpqcompat==="true"||E.useLibpqCompat)switch(_.sslmode){case"disable":{_.ssl=!1;break}case"prefer":{_.ssl.rejectUnauthorized=!1;break}case"require":{if(_.sslrootcert)_.ssl.checkServerIdentity=function(){};else _.ssl.rejectUnauthorized=!1;break}case"verify-ca":{if(!_.ssl.ca)throw Error("SECURITY WARNING: Using sslmode=verify-ca requires specifying a CA with sslrootcert. If a public CA is used, verify-ca allows connections to a server that somebody else may have registered with the CA, making you vulnerable to Man-in-the-Middle attacks. Either specify a custom CA certificate with sslrootcert parameter or use sslmode=verify-full for proper security.");_.ssl.checkServerIdentity=function(){};break}case"verify-full":break}else switch(_.sslmode){case"disable":{_.ssl=!1;break}case"prefer":case"require":case"verify-ca":case"verify-full":{if(_.sslmode!=="verify-full")k$(_.sslmode);break}case"no-verify":{_.ssl.rejectUnauthorized=!1;break}}return _}function H1($){return Object.entries($).reduce((_,[O,G])=>{if(G!==void 0&&G!==null)_[O]=G;return _},{})}function oE($){return Object.entries($).reduce((_,[O,G])=>{if(O==="ssl"){let X=G;if(typeof X==="boolean")_[O]=X;if(typeof X==="object")_[O]=H1(X)}else if(G!==void 0&&G!==null)if(O==="port"){if(G!==""){let X=parseInt(G,10);if(isNaN(X))throw Error(`Invalid ${O}: ${G}`);_[O]=X}}else _[O]=G;return _},{})}function T1($){return oE(v($))}function k$($){if(!k$.warned&&typeof process<"u"&&process.emitWarning)k$.warned=!0,process.emitWarning(`SECURITY WARNING: The SSL modes 'prefer', 'require', and 'verify-ca' are treated as aliases for 'verify-full'.
1
+ import{Ag as VO,Cg as SO,Dg as s$,ug as u}from"./chunk-88w3txtb.js";import"./chunk-v0e9bsvt.js";import"./chunk-jhxvctg5.js";import"./chunk-bk32cwxa.js";import"./chunk-qfa5v4n5.js";import"./chunk-78ksrp8v.js";import"./chunk-yb71zqvt.js";import{$l as W,Wl as vG,Yl as R}from"./chunk-4fs853nh.js";var L$=R((wO)=>{wO.parse=function($,E){return new W$($,E).parse()};class W${constructor($,E){this.source=$,this.transform=E||kO,this.position=0,this.entries=[],this.recorded=[],this.dimension=0}isEof(){return this.position>=this.source.length}nextCharacter(){var $=this.source[this.position++];if($==="\\")return{value:this.source[this.position++],escaped:!0};return{value:$,escaped:!1}}record($){this.recorded.push($)}newEntry($){var E;if(this.recorded.length>0||$){if(E=this.recorded.join(""),E==="NULL"&&!$)E=null;if(E!==null)E=this.transform(E);this.entries.push(E),this.recorded=[]}}consumeDimensions(){if(this.source[0]==="[")while(!this.isEof()){var $=this.nextCharacter();if($.value==="=")break}}parse($){var E,_,O;this.consumeDimensions();while(!this.isEof())if(E=this.nextCharacter(),E.value==="{"&&!O){if(this.dimension++,this.dimension>1)_=new W$(this.source.substr(this.position-1),this.transform),this.entries.push(_.parse(!0)),this.position+=_.position-2}else if(E.value==="}"&&!O){if(this.dimension--,!this.dimension){if(this.newEntry(),$)return this.entries}}else if(E.value==='"'&&!E.escaped){if(O)this.newEntry(!0);O=!O}else if(E.value===","&&!O)this.newEntry();else this.record(E.value);if(this.dimension!==0)throw Error("array dimension not balanced");return this.entries}}function kO($){return $}});var Q$=R((nG,e$)=>{var hO=L$();e$.exports={create:function($,E){return{parse:function(){return hO.parse($,E)}}}}});var _E=R((iG,EE)=>{var bO=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,yO=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,vO=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,pO=/^-?infinity$/;EE.exports=function(E){if(pO.test(E))return Number(E.replace("i","I"));var _=bO.exec(E);if(!_)return mO(E)||null;var O=!!_[8],G=parseInt(_[1],10);if(O)G=$E(G);var X=parseInt(_[2],10)-1,U=_[3],J=parseInt(_[4],10),Z=parseInt(_[5],10),H=parseInt(_[6],10),Y=_[7];Y=Y?1000*parseFloat(Y):0;var T,K=fO(E);if(K!=null){if(T=new Date(Date.UTC(G,X,U,J,Z,H,Y)),j$(G))T.setUTCFullYear(G);if(K!==0)T.setTime(T.getTime()-K)}else if(T=new Date(G,X,U,J,Z,H,Y),j$(G))T.setFullYear(G);return T};function mO($){var E=yO.exec($);if(!E)return;var _=parseInt(E[1],10),O=!!E[4];if(O)_=$E(_);var G=parseInt(E[2],10)-1,X=E[3],U=new Date(_,G,X);if(j$(_))U.setFullYear(_);return U}function fO($){if($.endsWith("+00"))return 0;var E=vO.exec($.split(" ")[1]);if(!E)return;var _=E[1];if(_==="Z")return 0;var O=_==="-"?-1:1,G=parseInt(E[2],10)*3600+parseInt(E[3]||0,10)*60+parseInt(E[4]||0,10);return G*O*1000}function $E($){return-($-1)}function j$($){return $>=0&&$<100}});var GE=R((sG,OE)=>{OE.exports=uO;var dO=Object.prototype.hasOwnProperty;function uO($){for(var E=1;E<arguments.length;E++){var _=arguments[E];for(var O in _)if(dO.call(_,O))$[O]=_[O]}return $}});var JE=R((tG,UE)=>{var gO=GE();UE.exports=x;function x($){if(!(this instanceof x))return new x($);gO(this,E0($))}var cO=["seconds","minutes","hours","days","months","years"];x.prototype.toPostgres=function(){var $=cO.filter(this.hasOwnProperty,this);if(this.milliseconds&&$.indexOf("seconds")<0)$.push("seconds");if($.length===0)return"0";return $.map(function(E){var _=this[E]||0;if(E==="seconds"&&this.milliseconds)_=(_+this.milliseconds/1000).toFixed(6).replace(/\.?0+$/,"");return _+" "+E},this).join(" ")};var lO={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"S"},oO=["years","months","days"],nO=["hours","minutes","seconds"];x.prototype.toISOString=x.prototype.toISO=function(){var $=oO.map(_,this).join(""),E=nO.map(_,this).join("");return"P"+$+"T"+E;function _(O){var G=this[O]||0;if(O==="seconds"&&this.milliseconds)G=(G+this.milliseconds/1000).toFixed(6).replace(/0+$/,"");return G+lO[O]}};var N$="([+-]?\\d+)",iO=N$+"\\s+years?",sO=N$+"\\s+mons?",tO=N$+"\\s+days?",aO="([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",rO=new RegExp([iO,sO,tO,aO].map(function($){return"("+$+")?"}).join("\\s*")),XE={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},eO=["hours","minutes","seconds","milliseconds"];function $0($){var E=$+"000000".slice($.length);return parseInt(E,10)/1000}function E0($){if(!$)return{};var E=rO.exec($),_=E[8]==="-";return Object.keys(XE).reduce(function(O,G){var X=XE[G],U=E[X];if(!U)return O;if(U=G==="milliseconds"?$0(U):parseInt(U,10),!U)return O;if(_&&~eO.indexOf(G))U*=-1;return O[G]=U,O},{})}});var TE=R((aG,HE)=>{var ZE=Buffer.from||Buffer;HE.exports=function(E){if(/^\\x/.test(E))return ZE(E.substr(2),"hex");var _="",O=0;while(O<E.length)if(E[O]!=="\\")_+=E[O],++O;else if(/[0-7]{3}/.test(E.substr(O+1,3)))_+=String.fromCharCode(parseInt(E.substr(O+1,3),8)),O+=4;else{var G=1;while(O+G<E.length&&E[O+G]==="\\")G++;for(var X=0;X<Math.floor(G/2);++X)_+="\\";O+=Math.floor(G/2)*2}return ZE(_,"binary")}});var jE=R((rG,QE)=>{var c=L$(),l=Q$(),$$=_E(),RE=JE(),KE=TE();function E$($){return function(_){if(_===null)return _;return $(_)}}function WE($){if($===null)return $;return $==="TRUE"||$==="t"||$==="true"||$==="y"||$==="yes"||$==="on"||$==="1"}function _0($){if(!$)return null;return c.parse($,WE)}function O0($){return parseInt($,10)}function F$($){if(!$)return null;return c.parse($,E$(O0))}function G0($){if(!$)return null;return c.parse($,E$(function(E){return LE(E).trim()}))}var X0=function($){if(!$)return null;var E=l.create($,function(_){if(_!==null)_=D$(_);return _});return E.parse()},z$=function($){if(!$)return null;var E=l.create($,function(_){if(_!==null)_=parseFloat(_);return _});return E.parse()},V=function($){if(!$)return null;var E=l.create($);return E.parse()},P$=function($){if(!$)return null;var E=l.create($,function(_){if(_!==null)_=$$(_);return _});return E.parse()},U0=function($){if(!$)return null;var E=l.create($,function(_){if(_!==null)_=RE(_);return _});return E.parse()},J0=function($){if(!$)return null;return c.parse($,E$(KE))},A$=function($){return parseInt($,10)},LE=function($){var E=String($);if(/^\d+$/.test(E))return E;return $},YE=function($){if(!$)return null;return c.parse($,E$(JSON.parse))},D$=function($){if($[0]!=="(")return null;return $=$.substring(1,$.length-1).split(","),{x:parseFloat($[0]),y:parseFloat($[1])}},Z0=function($){if($[0]!=="<"&&$[1]!=="(")return null;var E="(",_="",O=!1;for(var G=2;G<$.length-1;G++){if(!O)E+=$[G];if($[G]===")"){O=!0;continue}else if(!O)continue;if($[G]===",")continue;_+=$[G]}var X=D$(E);return X.radius=parseFloat(_),X},H0=function($){$(20,LE),$(21,A$),$(23,A$),$(26,A$),$(700,parseFloat),$(701,parseFloat),$(16,WE),$(1082,$$),$(1114,$$),$(1184,$$),$(600,D$),$(651,V),$(718,Z0),$(1000,_0),$(1001,J0),$(1005,F$),$(1007,F$),$(1028,F$),$(1016,G0),$(1017,X0),$(1021,z$),$(1022,z$),$(1231,z$),$(1014,V),$(1015,V),$(1008,V),$(1009,V),$(1040,V),$(1041,V),$(1115,P$),$(1182,P$),$(1185,P$),$(1186,RE),$(1187,U0),$(17,KE),$(114,JSON.parse.bind(JSON)),$(3802,JSON.parse.bind(JSON)),$(199,YE),$(3807,YE),$(3907,V),$(2951,V),$(791,V),$(1183,V),$(1270,V)};QE.exports={init:H0}});var FE=R((eG,NE)=>{var P=1e6;function T0($){var E=$.readInt32BE(0),_=$.readUInt32BE(4),O="";if(E<0)E=~E+(_===0),_=~_+1>>>0,O="-";var G="",X,U,J,Z,H,Y;{if(X=E%P,E=E/P>>>0,U=4294967296*X+_,_=U/P>>>0,J=""+(U-P*_),_===0&&E===0)return O+J+G;Z="",H=6-J.length;for(Y=0;Y<H;Y++)Z+="0";G=Z+J+G}{if(X=E%P,E=E/P>>>0,U=4294967296*X+_,_=U/P>>>0,J=""+(U-P*_),_===0&&E===0)return O+J+G;Z="",H=6-J.length;for(Y=0;Y<H;Y++)Z+="0";G=Z+J+G}{if(X=E%P,E=E/P>>>0,U=4294967296*X+_,_=U/P>>>0,J=""+(U-P*_),_===0&&E===0)return O+J+G;Z="",H=6-J.length;for(Y=0;Y<H;Y++)Z+="0";G=Z+J+G}return X=E%P,U=4294967296*X+_,J=""+U%P,O+J+G}NE.exports=T0});var ME=R(($8,DE)=>{var Y0=FE(),j=function($,E,_,O,G){_=_||0,O=O||!1,G=G||function(Q,C,K$){return Q*Math.pow(2,K$)+C};var X=_>>3,U=function(Q){if(O)return~Q&255;return Q},J=255,Z=8-_%8;if(E<Z)J=255<<8-E&255,Z=E;if(_)J=J>>_%8;var H=0;if(_%8+E>=8)H=G(0,U($[X])&J,Z);var Y=E+_>>3;for(var T=X+1;T<Y;T++)H=G(H,U($[T]),8);var K=(E+_)%8;if(K>0)H=G(H,U($[Y])>>8-K,K);return H},AE=function($,E,_){var O=Math.pow(2,_-1)-1,G=j($,1),X=j($,_,1);if(X===0)return 0;var U=1,J=function(H,Y,T){if(H===0)H=1;for(var K=1;K<=T;K++)if(U/=2,(Y&1<<T-K)>0)H+=U;return H},Z=j($,E,_+1,!1,J);if(X==Math.pow(2,_+1)-1){if(Z===0)return G===0?1/0:-1/0;return NaN}return(G===0?1:-1)*Math.pow(2,X-O)*Z},R0=function($){if(j($,1)==1)return-1*(j($,15,1,!0)+1);return j($,15,1)},zE=function($){if(j($,1)==1)return-1*(j($,31,1,!0)+1);return j($,31,1)},K0=function($){return AE($,23,8)},W0=function($){return AE($,52,11)},L0=function($){var E=j($,16,32);if(E==49152)return NaN;var _=Math.pow(1e4,j($,16,16)),O=0,G=[],X=j($,16);for(var U=0;U<X;U++)O+=j($,16,64+16*U)*_,_/=1e4;var J=Math.pow(10,j($,16,48));return(E===0?1:-1)*Math.round(O*J)/J},PE=function($,E){var _=j(E,1),O=j(E,63,1),G=new Date((_===0?1:-1)*O/1000+946684800000);if(!$)G.setTime(G.getTime()+G.getTimezoneOffset()*60000);return G.usec=O%1000,G.getMicroSeconds=function(){return this.usec},G.setMicroSeconds=function(X){this.usec=X},G.getUTCMicroSeconds=function(){return this.usec},G},o=function($){var E=j($,32),_=j($,32,32),O=j($,32,64),G=96,X=[];for(var U=0;U<E;U++)X[U]=j($,32,G),G+=32,G+=32;var J=function(H){var Y=j($,32,G);if(G+=32,Y==4294967295)return null;var T;if(H==23||H==20)return T=j($,Y*8,G),G+=Y*8,T;else if(H==25)return T=$.toString(this.encoding,G>>3,(G+=Y<<3)>>3),T;else console.log("ERROR: ElementType not implemented: "+H)},Z=function(H,Y){var T=[],K;if(H.length>1){var Q=H.shift();for(K=0;K<Q;K++)T[K]=Z(H,Y);H.unshift(Q)}else for(K=0;K<H[0];K++)T[K]=J(Y);return T};return Z(X,O)},Q0=function($){return $.toString("utf8")},j0=function($){if($===null)return null;return j($,8)>0},N0=function($){$(20,Y0),$(21,R0),$(23,zE),$(26,zE),$(1700,L0),$(700,K0),$(701,W0),$(16,j0),$(1114,PE.bind(null,!1)),$(1184,PE.bind(null,!0)),$(1000,o),$(1007,o),$(1016,o),$(1008,o),$(1009,o),$(25,Q0)};DE.exports={init:N0}});var SE=R((E8,VE)=>{VE.exports={BOOL:16,BYTEA:17,CHAR:18,INT8:20,INT2:21,INT4:23,REGPROC:24,TEXT:25,OID:26,TID:27,XID:28,CID:29,JSON:114,XML:142,PG_NODE_TREE:194,SMGR:210,PATH:602,POLYGON:604,CIDR:650,FLOAT4:700,FLOAT8:701,ABSTIME:702,RELTIME:703,TINTERVAL:704,CIRCLE:718,MACADDR8:774,MONEY:790,MACADDR:829,INET:869,ACLITEM:1033,BPCHAR:1042,VARCHAR:1043,DATE:1082,TIME:1083,TIMESTAMP:1114,TIMESTAMPTZ:1184,INTERVAL:1186,TIMETZ:1266,BIT:1560,VARBIT:1562,NUMERIC:1700,REFCURSOR:1790,REGPROCEDURE:2202,REGOPER:2203,REGOPERATOR:2204,REGCLASS:2205,REGTYPE:2206,UUID:2950,TXID_SNAPSHOT:2970,PG_LSN:3220,PG_NDISTINCT:3361,PG_DEPENDENCIES:3402,TSVECTOR:3614,TSQUERY:3615,GTSVECTOR:3642,REGCONFIG:3734,REGDICTIONARY:3769,JSONB:3802,REGNAMESPACE:4089,REGROLE:4096}});var i=R((V0)=>{var F0=jE(),z0=ME(),P0=Q$(),A0=SE();V0.getTypeParser=D0;V0.setTypeParser=M0;V0.arrayParser=P0;V0.builtins=A0;var n={text:{},binary:{}};function CE($){return String($)}function D0($,E){if(E=E||"text",!n[E])return CE;return n[E][$]||CE}function M0($,E,_){if(typeof E=="function")_=E,E="text";n[E][$]=_}F0.init(function($,E){n.text[$]=E});z0.init(function($,E){n.binary[$]=E})});var s=R((O8,M$)=>{var IE;try{IE=process.platform==="win32"?process.env.USERNAME:process.env.USER}catch{}M$.exports={host:"localhost",user:IE,database:void 0,password:null,connectionString:void 0,port:5432,rows:0,binary:!1,max:10,idleTimeoutMillis:30000,client_encoding:"",ssl:!1,application_name:void 0,fallback_application_name:void 0,options:void 0,parseInputDatesAsUTC:!1,statement_timeout:!1,lock_timeout:!1,idle_in_transaction_session_timeout:!1,query_timeout:!1,connect_timeout:0,keepalives:1,keepalives_idle:0};var h=i(),B0=h.getTypeParser(20,"text"),k0=h.getTypeParser(1016,"text");M$.exports.__defineSetter__("parseInt8",function($){h.setTypeParser(20,"text",$?h.getTypeParser(23,"text"):B0),h.setTypeParser(1016,"text",$?h.getTypeParser(1007,"text"):k0)})});var b=R((G8,kE)=>{var w0=s(),qE=W("util"),{isDate:x0}=qE.types||qE;function h0($){return'"'+$.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")+'"'}function BE($){let E="{";for(let _=0;_<$.length;_++){if(_>0)E=E+",";if($[_]===null||typeof $[_]>"u")E=E+"NULL";else if(Array.isArray($[_]))E=E+BE($[_]);else if(ArrayBuffer.isView($[_])){let O=$[_];if(!(O instanceof Buffer)){let G=Buffer.from(O.buffer,O.byteOffset,O.byteLength);if(G.length===O.byteLength)O=G;else O=G.slice(O.byteOffset,O.byteOffset+O.byteLength)}E+="\\\\x"+O.toString("hex")}else E+=h0(_$($[_]))}return E=E+"}",E}var _$=function($,E){if($==null)return null;if(typeof $==="object"){if($ instanceof Buffer)return $;if(ArrayBuffer.isView($)){let _=Buffer.from($.buffer,$.byteOffset,$.byteLength);if(_.length===$.byteLength)return _;return _.slice($.byteOffset,$.byteOffset+$.byteLength)}if(x0($))if(w0.parseInputDatesAsUTC)return v0($);else return y0($);if(Array.isArray($))return BE($);return b0($,E)}return $.toString()};function b0($,E){if($&&typeof $.toPostgres==="function"){if(E=E||[],E.indexOf($)!==-1)throw Error('circular reference detected while preparing "'+$+'" for query');return E.push($),_$($.toPostgres(_$),E)}return JSON.stringify($)}function y0($){let E=-$.getTimezoneOffset(),_=$.getFullYear(),O=_<1;if(O)_=Math.abs(_)+1;let G=String(_).padStart(4,"0")+"-"+String($.getMonth()+1).padStart(2,"0")+"-"+String($.getDate()).padStart(2,"0")+"T"+String($.getHours()).padStart(2,"0")+":"+String($.getMinutes()).padStart(2,"0")+":"+String($.getSeconds()).padStart(2,"0")+"."+String($.getMilliseconds()).padStart(3,"0");if(E<0)G+="-",E*=-1;else G+="+";if(G+=String(Math.floor(E/60)).padStart(2,"0")+":"+String(E%60).padStart(2,"0"),O)G+=" BC";return G}function v0($){let E=$.getUTCFullYear(),_=E<1;if(_)E=Math.abs(E)+1;let O=String(E).padStart(4,"0")+"-"+String($.getUTCMonth()+1).padStart(2,"0")+"-"+String($.getUTCDate()).padStart(2,"0")+"T"+String($.getUTCHours()).padStart(2,"0")+":"+String($.getUTCMinutes()).padStart(2,"0")+":"+String($.getUTCSeconds()).padStart(2,"0")+"."+String($.getUTCMilliseconds()).padStart(3,"0");if(O+="+00:00",_)O+=" BC";return O}function p0($,E,_){if($=typeof $==="string"?{text:$}:$,E)if(typeof E==="function")$.callback=E;else $.values=E;if(_)$.callback=_;return $}var m0=function($){return'"'+$.replace(/"/g,'""')+'"'},f0=function($){let E=!1,_="'";if($==null)return"''";if(typeof $!=="string")return"''";for(let O=0;O<$.length;O++){let G=$[O];if(G==="'")_+=G+G;else if(G==="\\")_+=G+G,E=!0;else _+=G}if(_+="'",E===!0)_=" E"+_;return _};kE.exports={prepareValue:function(E){return _$(E)},normalizeQueryConfig:p0,escapeIdentifier:m0,escapeLiteral:f0}});var xE=R((X8,wE)=>{var y=W("crypto");function V$($){return y.createHash("md5").update($,"utf-8").digest("hex")}function d0($,E,_){let O=V$(E+$);return"md5"+V$(Buffer.concat([Buffer.from(O),_]))}function u0($){return y.createHash("sha256").update($).digest()}function g0($,E){return $=$.replace(/(\D)-/,"$1"),y.createHash($).update(E).digest()}function c0($,E){return y.createHmac("sha256",$).update(E).digest()}async function l0($,E,_){return y.pbkdf2Sync($,E,_,32,"sha256")}wE.exports={postgresMd5PasswordHash:d0,randomBytes:y.randomBytes,deriveKey:l0,sha256:u0,hashByName:g0,hmacSha256:c0,md5:V$}});var vE=R((U8,yE)=>{var hE=W("crypto");yE.exports={postgresMd5PasswordHash:n0,randomBytes:o0,deriveKey:a0,sha256:i0,hashByName:s0,hmacSha256:t0,md5:S$};var bE=hE.webcrypto||globalThis.crypto,k=bE.subtle,C$=new TextEncoder;function o0($){return bE.getRandomValues(Buffer.alloc($))}async function S$($){try{return hE.createHash("md5").update($,"utf-8").digest("hex")}catch(E){let _=typeof $==="string"?C$.encode($):$,O=await k.digest("MD5",_);return Array.from(new Uint8Array(O)).map((G)=>G.toString(16).padStart(2,"0")).join("")}}async function n0($,E,_){let O=await S$(E+$);return"md5"+await S$(Buffer.concat([Buffer.from(O),_]))}async function i0($){return await k.digest("SHA-256",$)}async function s0($,E){return await k.digest($,E)}async function t0($,E){let _=await k.importKey("raw",$,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return await k.sign("HMAC",_,C$.encode(E))}async function a0($,E,_){let O=await k.importKey("raw",C$.encode($),"PBKDF2",!1,["deriveBits"]),G={name:"PBKDF2",hash:"SHA-256",salt:E,iterations:_};return await k.deriveBits(G,O,256,["deriveBits"])}});var q$=R((J8,I$)=>{var r0=parseInt(process.versions&&process.versions.node&&process.versions.node.split(".")[0])<15;if(r0)I$.exports=xE();else I$.exports=vE()});var fE=R((Z8,mE)=>{function w($,E){return Error("SASL channel binding: "+$+" when parsing public certificate "+E.toString("base64"))}function B$($,E){let _=$[E++];if(_<128)return{length:_,index:E};let O=_&127;if(O>4)throw w("bad length",$);_=0;for(let G=0;G<O;G++)_=_<<8|$[E++];return{length:_,index:E}}function pE($,E){if($[E++]!==6)throw w("non-OID data",$);let{length:_,index:O}=B$($,E);E=O;let G=E+_,X=$[E++],U=(X/40>>0)+"."+X%40;while(E<G){let J=0;while(E<G){let Z=$[E++];if(J=J<<7|Z&127,Z<128)break}U+="."+J}return{oid:U,index:E}}function t($,E){if($[E++]!==48)throw w("non-sequence data",$);return B$($,E)}function e0($,E){if(E===void 0)E=0;E=t($,E).index;let{length:_,index:O}=t($,E);E=O+_,E=t($,E).index;let{oid:G,index:X}=pE($,E);switch(G){case"1.2.840.113549.1.1.4":return"MD5";case"1.2.840.113549.1.1.5":return"SHA-1";case"1.2.840.113549.1.1.11":return"SHA-256";case"1.2.840.113549.1.1.12":return"SHA-384";case"1.2.840.113549.1.1.13":return"SHA-512";case"1.2.840.113549.1.1.14":return"SHA-224";case"1.2.840.113549.1.1.15":return"SHA512-224";case"1.2.840.113549.1.1.16":return"SHA512-256";case"1.2.840.10045.4.1":return"SHA-1";case"1.2.840.10045.4.3.1":return"SHA-224";case"1.2.840.10045.4.3.2":return"SHA-256";case"1.2.840.10045.4.3.3":return"SHA-384";case"1.2.840.10045.4.3.4":return"SHA-512";case"1.2.840.113549.1.1.10":{if(E=X,E=t($,E).index,$[E++]!==160)throw w("non-tag data",$);E=B$($,E).index,E=t($,E).index;let{oid:U}=pE($,E);switch(U){case"1.2.840.113549.2.5":return"MD5";case"1.3.14.3.2.26":return"SHA-1";case"2.16.840.1.101.3.4.2.1":return"SHA-256";case"2.16.840.1.101.3.4.2.2":return"SHA-384";case"2.16.840.1.101.3.4.2.3":return"SHA-512"}throw w("unknown hash OID "+U,$)}case"1.3.101.110":case"1.3.101.112":return"SHA-512";case"1.3.101.111":case"1.3.101.113":throw w("Ed448 certificate channel binding is not currently supported by Postgres")}throw w("unknown OID "+G,$)}mE.exports={signatureAlgorithmHashFromCertificate:e0}});var cE=R((H8,gE)=>{var q=q$(),{signatureAlgorithmHashFromCertificate:$1}=fE();function E1($,E){let _=["SCRAM-SHA-256"];if(E)_.unshift("SCRAM-SHA-256-PLUS");let O=_.find((U)=>$.includes(U));if(!O)throw Error("SASL: Only mechanism(s) "+_.join(" and ")+" are supported");if(O==="SCRAM-SHA-256-PLUS"&&typeof E.getPeerCertificate!=="function")throw Error("SASL: Mechanism SCRAM-SHA-256-PLUS requires a certificate");let G=q.randomBytes(18).toString("base64");return{mechanism:O,clientNonce:G,response:(O==="SCRAM-SHA-256-PLUS"?"p=tls-server-end-point":E?"y":"n")+",,n=*,r="+G,message:"SASLInitialResponse"}}async function _1($,E,_,O){if($.message!=="SASLInitialResponse")throw Error("SASL: Last message was not SASLInitialResponse");if(typeof E!=="string")throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");if(E==="")throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string");if(typeof _!=="string")throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");let G=X1(_);if(!G.nonce.startsWith($.clientNonce))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");else if(G.nonce.length===$.clientNonce.length)throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short");let X="n=*,r="+$.clientNonce,U="r="+G.nonce+",s="+G.salt+",i="+G.iteration,J=O?"eSws":"biws";if($.mechanism==="SCRAM-SHA-256-PLUS"){let t$=O.getPeerCertificate().raw,e=$1(t$);if(e==="MD5"||e==="SHA-1")e="SHA-256";let BO=await q.hashByName(e,t$);J=Buffer.concat([Buffer.from("p=tls-server-end-point,,"),Buffer.from(BO)]).toString("base64")}let Z="c="+J+",r="+G.nonce,H=X+","+U+","+Z,Y=Buffer.from(G.salt,"base64"),T=await q.deriveKey(E,Y,G.iteration),K=await q.hmacSha256(T,"Client Key"),Q=await q.sha256(K),C=await q.hmacSha256(Q,H),K$=J1(Buffer.from(K),Buffer.from(C)).toString("base64"),IO=await q.hmacSha256(T,"Server Key"),qO=await q.hmacSha256(IO,H);$.message="SASLResponse",$.serverSignature=Buffer.from(qO).toString("base64"),$.response=Z+",p="+K$}function O1($,E){if($.message!=="SASLResponse")throw Error("SASL: Last message was not SASLResponse");if(typeof E!=="string")throw Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");let{serverSignature:_}=U1(E);if(_!==$.serverSignature)throw Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match")}function G1($){if(typeof $!=="string")throw TypeError("SASL: text must be a string");return $.split("").map((E,_)=>$.charCodeAt(_)).every((E)=>E>=33&&E<=43||E>=45&&E<=126)}function dE($){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test($)}function uE($){if(typeof $!=="string")throw TypeError("SASL: attribute pairs text must be a string");return new Map($.split(",").map((E)=>{if(!/^.=/.test(E))throw Error("SASL: Invalid attribute pair entry");let _=E[0],O=E.substring(2);return[_,O]}))}function X1($){let E=uE($),_=E.get("r");if(!_)throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");else if(!G1(_))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters");let O=E.get("s");if(!O)throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing");else if(!dE(O))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64");let G=E.get("i");if(!G)throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing");else if(!/^[1-9][0-9]*$/.test(G))throw Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count");let X=parseInt(G,10);return{nonce:_,salt:O,iteration:X}}function U1($){let _=uE($).get("v");if(!_)throw Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");else if(!dE(_))throw Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64");return{serverSignature:_}}function J1($,E){if(!Buffer.isBuffer($))throw TypeError("first argument must be a Buffer");if(!Buffer.isBuffer(E))throw TypeError("second argument must be a Buffer");if($.length!==E.length)throw Error("Buffer lengths must match");if($.length===0)throw Error("Buffers cannot be empty");return Buffer.from($.map((_,O)=>$[O]^E[O]))}gE.exports={startSession:E1,continueSession:_1,finalizeSession:O1}});var G$=R((T8,lE)=>{var Z1=i();function O$($){this._types=$||Z1,this.text={},this.binary={}}O$.prototype.getOverrides=function($){switch($){case"text":return this.text;case"binary":return this.binary;default:return{}}};O$.prototype.setTypeParser=function($,E,_){if(typeof E==="function")_=E,E="text";this.getOverrides(E)[$]=_};O$.prototype.getTypeParser=function($,E){return E=E||"text",this.getOverrides(E)[$]||this._types.getTypeParser($,E)};lE.exports=O$});var iE=R((Y8,nE)=>{function v($,E={}){if($.charAt(0)==="/"){let Z=$.split(" ");return{host:Z[0],database:Z[1]}}let _={},O,G=!1;if(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test($))$=encodeURI($).replace(/%25(\d\d)/g,"%$1");try{try{O=new URL($,"postgres://base")}catch(Z){O=new URL($.replace("@/","@___DUMMY___/"),"postgres://base"),G=!0}}catch(Z){throw Z.input&&(Z.input="*****REDACTED*****"),Z}for(let Z of O.searchParams.entries())_[Z[0]]=Z[1];if(_.user=_.user||decodeURIComponent(O.username),_.password=_.password||decodeURIComponent(O.password),O.protocol=="socket:")return _.host=decodeURI(O.pathname),_.database=O.searchParams.get("db"),_.client_encoding=O.searchParams.get("encoding"),_;let X=G?"":O.hostname;if(!_.host)_.host=decodeURIComponent(X);else if(X&&/^%2f/i.test(X))O.pathname=X+O.pathname;if(!_.port)_.port=O.port;let U=O.pathname.slice(1)||null;if(_.database=U?decodeURI(U):null,_.ssl==="true"||_.ssl==="1")_.ssl=!0;if(_.ssl==="0")_.ssl=!1;if(_.sslcert||_.sslkey||_.sslrootcert||_.sslmode)_.ssl={};let J=_.sslcert||_.sslkey||_.sslrootcert?W("fs"):null;if(_.sslcert)_.ssl.cert=J.readFileSync(_.sslcert).toString();if(_.sslkey)_.ssl.key=J.readFileSync(_.sslkey).toString();if(_.sslrootcert)_.ssl.ca=J.readFileSync(_.sslrootcert).toString();if(E.useLibpqCompat&&_.uselibpqcompat)throw Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.");if(_.uselibpqcompat==="true"||E.useLibpqCompat)switch(_.sslmode){case"disable":{_.ssl=!1;break}case"prefer":{_.ssl.rejectUnauthorized=!1;break}case"require":{if(_.sslrootcert)_.ssl.checkServerIdentity=function(){};else _.ssl.rejectUnauthorized=!1;break}case"verify-ca":{if(!_.ssl.ca)throw Error("SECURITY WARNING: Using sslmode=verify-ca requires specifying a CA with sslrootcert. If a public CA is used, verify-ca allows connections to a server that somebody else may have registered with the CA, making you vulnerable to Man-in-the-Middle attacks. Either specify a custom CA certificate with sslrootcert parameter or use sslmode=verify-full for proper security.");_.ssl.checkServerIdentity=function(){};break}case"verify-full":break}else switch(_.sslmode){case"disable":{_.ssl=!1;break}case"prefer":case"require":case"verify-ca":case"verify-full":{if(_.sslmode!=="verify-full")k$(_.sslmode);break}case"no-verify":{_.ssl.rejectUnauthorized=!1;break}}return _}function H1($){return Object.entries($).reduce((_,[O,G])=>{if(G!==void 0&&G!==null)_[O]=G;return _},{})}function oE($){return Object.entries($).reduce((_,[O,G])=>{if(O==="ssl"){let X=G;if(typeof X==="boolean")_[O]=X;if(typeof X==="object")_[O]=H1(X)}else if(G!==void 0&&G!==null)if(O==="port"){if(G!==""){let X=parseInt(G,10);if(isNaN(X))throw Error(`Invalid ${O}: ${G}`);_[O]=X}}else _[O]=G;return _},{})}function T1($){return oE(v($))}function k$($){if(!k$.warned&&typeof process<"u"&&process.emitWarning)k$.warned=!0,process.emitWarning(`SECURITY WARNING: The SSL modes 'prefer', 'require', and 'verify-ca' are treated as aliases for 'verify-full'.
2
2
  In the next major version (pg-connection-string v3.0.0 and pg v9.0.0), these modes will adopt standard libpq semantics, which have weaker security guarantees.
3
3
 
4
4
  To prepare for this change:
@@ -1,4 +1,4 @@
1
- import{Dl as W8,Fl as E1,Il as o5}from"./chunk-y8qhrx11.js";var Y4=E1((sY,X6)=>{var J6=["nodebuffer","arraybuffer","fragments"],K6=typeof Blob<"u";if(K6)J6.push("blob");X6.exports={BINARY_TYPES:J6,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:K6,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var _3=E1((oY,$7)=>{var{EMPTY_BUFFER:qI}=Y4(),gJ=Buffer[Symbol.species];function UI(G,H){if(G.length===0)return qI;if(G.length===1)return G[0];let R=Buffer.allocUnsafe(H),P=0;for(let D=0;D<G.length;D++){let M=G[D];R.set(M,P),P+=M.length}if(P<H)return new gJ(R.buffer,R.byteOffset,P);return R}function Z6(G,H,R,P,D){for(let M=0;M<D;M++)R[P+M]=G[M]^H[M&3]}function $6(G,H){for(let R=0;R<G.length;R++)G[R]^=H[R&3]}function LI(G){if(G.length===G.buffer.byteLength)return G.buffer;return G.buffer.slice(G.byteOffset,G.byteOffset+G.length)}function hJ(G){if(hJ.readOnly=!0,Buffer.isBuffer(G))return G;let H;if(G instanceof ArrayBuffer)H=new gJ(G);else if(ArrayBuffer.isView(G))H=new gJ(G.buffer,G.byteOffset,G.byteLength);else H=Buffer.from(G),hJ.readOnly=!1;return H}$7.exports={concat:UI,mask:Z6,toArrayBuffer:LI,toBuffer:hJ,unmask:$6};if(!process.env.WS_NO_BUFFER_UTIL)try{let G=(()=>{throw new Error("Cannot require module "+"bufferutil");})();$7.exports.mask=function(H,R,P,D,M){if(M<48)Z6(H,R,P,D,M);else G.mask(H,R,P,D,M)},$7.exports.unmask=function(H,R){if(H.length<32)$6(H,R);else G.unmask(H,R)}}catch(G){}});var z6=E1((tY,I6)=>{var Q6=Symbol("kDone"),mJ=Symbol("kRun");class G6{constructor(G){this[Q6]=()=>{this.pending--,this[mJ]()},this.concurrency=G||1/0,this.jobs=[],this.pending=0}add(G){this.jobs.push(G),this[mJ]()}[mJ](){if(this.pending===this.concurrency)return;if(this.jobs.length){let G=this.jobs.shift();this.pending++,G(this[Q6])}}}I6.exports=G6});var N3=E1((eY,H6)=>{var H3=o5("zlib"),j6=_3(),WI=z6(),{kStatusCode:Y6}=Y4(),EI=Buffer[Symbol.species],yI=Buffer.from([0,0,255,255]),G7=Symbol("permessage-deflate"),V4=Symbol("total-length"),T8=Symbol("callback"),U4=Symbol("buffers"),x8=Symbol("error"),Q7;class V6{constructor(G,H,R){if(this._maxPayload=R|0,this._options=G||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!H,this._deflate=null,this._inflate=null,this.params=null,!Q7){let P=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Q7=new WI(P)}}static get extensionName(){return"permessage-deflate"}offer(){let G={};if(this._options.serverNoContextTakeover)G.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)G.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)G.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)G.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)G.client_max_window_bits=!0;return G}accept(G){return G=this.normalizeParams(G),this.params=this._isServer?this.acceptAsServer(G):this.acceptAsClient(G),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let G=this._deflate[T8];if(this._deflate.close(),this._deflate=null,G)G(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(G){let H=this._options,R=G.find((P)=>{if(H.serverNoContextTakeover===!1&&P.server_no_context_takeover||P.server_max_window_bits&&(H.serverMaxWindowBits===!1||typeof H.serverMaxWindowBits==="number"&&H.serverMaxWindowBits>P.server_max_window_bits)||typeof H.clientMaxWindowBits==="number"&&!P.client_max_window_bits)return!1;return!0});if(!R)throw Error("None of the extension offers can be accepted");if(H.serverNoContextTakeover)R.server_no_context_takeover=!0;if(H.clientNoContextTakeover)R.client_no_context_takeover=!0;if(typeof H.serverMaxWindowBits==="number")R.server_max_window_bits=H.serverMaxWindowBits;if(typeof H.clientMaxWindowBits==="number")R.client_max_window_bits=H.clientMaxWindowBits;else if(R.client_max_window_bits===!0||H.clientMaxWindowBits===!1)delete R.client_max_window_bits;return R}acceptAsClient(G){let H=G[0];if(this._options.clientNoContextTakeover===!1&&H.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!H.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")H.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&H.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return H}normalizeParams(G){return G.forEach((H)=>{Object.keys(H).forEach((R)=>{let P=H[R];if(P.length>1)throw Error(`Parameter "${R}" must have only a single value`);if(P=P[0],R==="client_max_window_bits"){if(P!==!0){let D=+P;if(!Number.isInteger(D)||D<8||D>15)throw TypeError(`Invalid value for parameter "${R}": ${P}`);P=D}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${R}": ${P}`)}else if(R==="server_max_window_bits"){let D=+P;if(!Number.isInteger(D)||D<8||D>15)throw TypeError(`Invalid value for parameter "${R}": ${P}`);P=D}else if(R==="client_no_context_takeover"||R==="server_no_context_takeover"){if(P!==!0)throw TypeError(`Invalid value for parameter "${R}": ${P}`)}else throw Error(`Unknown parameter "${R}"`);H[R]=P})}),G}decompress(G,H,R){Q7.add((P)=>{this._decompress(G,H,(D,M)=>{P(),R(D,M)})})}compress(G,H,R){Q7.add((P)=>{this._compress(G,H,(D,M)=>{P(),R(D,M)})})}_decompress(G,H,R){let P=this._isServer?"client":"server";if(!this._inflate){let D=`${P}_max_window_bits`,M=typeof this.params[D]!=="number"?H3.Z_DEFAULT_WINDOWBITS:this.params[D];this._inflate=H3.createInflateRaw({...this._options.zlibInflateOptions,windowBits:M}),this._inflate[G7]=this,this._inflate[V4]=0,this._inflate[U4]=[],this._inflate.on("error",vI),this._inflate.on("data",_6)}if(this._inflate[T8]=R,this._inflate.write(G),H)this._inflate.write(yI);this._inflate.flush(()=>{let D=this._inflate[x8];if(D){this._inflate.close(),this._inflate=null,R(D);return}let M=j6.concat(this._inflate[U4],this._inflate[V4]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[V4]=0,this._inflate[U4]=[],H&&this.params[`${P}_no_context_takeover`])this._inflate.reset();R(null,M)})}_compress(G,H,R){let P=this._isServer?"server":"client";if(!this._deflate){let D=`${P}_max_window_bits`,M=typeof this.params[D]!=="number"?H3.Z_DEFAULT_WINDOWBITS:this.params[D];this._deflate=H3.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:M}),this._deflate[V4]=0,this._deflate[U4]=[],this._deflate.on("data",SI)}this._deflate[T8]=R,this._deflate.write(G),this._deflate.flush(H3.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let D=j6.concat(this._deflate[U4],this._deflate[V4]);if(H)D=new EI(D.buffer,D.byteOffset,D.length-4);if(this._deflate[T8]=null,this._deflate[V4]=0,this._deflate[U4]=[],H&&this.params[`${P}_no_context_takeover`])this._deflate.reset();R(null,D)})}}H6.exports=V6;function SI(G){this[U4].push(G),this[V4]+=G.length}function _6(G){if(this[V4]+=G.length,this[G7]._maxPayload<1||this[V4]<=this[G7]._maxPayload){this[U4].push(G);return}this[x8]=RangeError("Max payload size exceeded"),this[x8].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[x8][Y6]=1009,this.removeListener("data",_6),this.reset()}function vI(G){if(this[G7]._inflate=null,this[x8]){this[T8](this[x8]);return}G[Y6]=1007,this[T8](G)}});var B8=E1((JV,I7)=>{var{isUtf8:N6}=o5("buffer"),{hasBlob:wI}=Y4(),gI=[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 hI(G){return G>=1000&&G<=1014&&G!==1004&&G!==1005&&G!==1006||G>=3000&&G<=4999}function fJ(G){let H=G.length,R=0;while(R<H)if((G[R]&128)===0)R++;else if((G[R]&224)===192){if(R+1===H||(G[R+1]&192)!==128||(G[R]&254)===192)return!1;R+=2}else if((G[R]&240)===224){if(R+2>=H||(G[R+1]&192)!==128||(G[R+2]&192)!==128||G[R]===224&&(G[R+1]&224)===128||G[R]===237&&(G[R+1]&224)===160)return!1;R+=3}else if((G[R]&248)===240){if(R+3>=H||(G[R+1]&192)!==128||(G[R+2]&192)!==128||(G[R+3]&192)!==128||G[R]===240&&(G[R+1]&240)===128||G[R]===244&&G[R+1]>143||G[R]>244)return!1;R+=4}else return!1;return!0}function mI(G){return wI&&typeof G==="object"&&typeof G.arrayBuffer==="function"&&typeof G.type==="string"&&typeof G.stream==="function"&&(G[Symbol.toStringTag]==="Blob"||G[Symbol.toStringTag]==="File")}I7.exports={isBlob:mI,isValidStatusCode:hI,isValidUTF8:fJ,tokenChars:gI};if(N6)I7.exports.isValidUTF8=function(G){return G.length<24?fJ(G):N6(G)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let G=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();I7.exports.isValidUTF8=function(H){return H.length<32?fJ(H):G(H)}}catch(G){}});var lJ=E1((KV,O6)=>{var{Writable:fI}=o5("stream"),R6=N3(),{BINARY_TYPES:uI,EMPTY_BUFFER:A6,kStatusCode:lI,kWebSocket:pI}=Y4(),{concat:uJ,toArrayBuffer:kI,unmask:bI}=_3(),{isValidStatusCode:iI,isValidUTF8:F6}=B8(),z7=Buffer[Symbol.species];class D6 extends fI{constructor(G={}){super();this._allowSynchronousEvents=G.allowSynchronousEvents!==void 0?G.allowSynchronousEvents:!0,this._binaryType=G.binaryType||uI[0],this._extensions=G.extensions||{},this._isServer=!!G.isServer,this._maxPayload=G.maxPayload|0,this._skipUTF8Validation=!!G.skipUTF8Validation,this[pI]=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=0}_write(G,H,R){if(this._opcode===8&&this._state==0)return R();this._bufferedBytes+=G.length,this._buffers.push(G),this.startLoop(R)}consume(G){if(this._bufferedBytes-=G,G===this._buffers[0].length)return this._buffers.shift();if(G<this._buffers[0].length){let R=this._buffers[0];return this._buffers[0]=new z7(R.buffer,R.byteOffset+G,R.length-G),new z7(R.buffer,R.byteOffset,G)}let H=Buffer.allocUnsafe(G);do{let R=this._buffers[0],P=H.length-G;if(G>=R.length)H.set(this._buffers.shift(),P);else H.set(new Uint8Array(R.buffer,R.byteOffset,G),P),this._buffers[0]=new z7(R.buffer,R.byteOffset+G,R.length-G);G-=R.length}while(G>0);return H}startLoop(G){this._loop=!0;do switch(this._state){case 0:this.getInfo(G);break;case 1:this.getPayloadLength16(G);break;case 2:this.getPayloadLength64(G);break;case 3:this.getMask();break;case 4:this.getData(G);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)G()}getInfo(G){if(this._bufferedBytes<2){this._loop=!1;return}let H=this.consume(2);if((H[0]&48)!==0){let P=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");G(P);return}let R=(H[0]&64)===64;if(R&&!this._extensions[R6.extensionName]){let P=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");G(P);return}if(this._fin=(H[0]&128)===128,this._opcode=H[0]&15,this._payloadLength=H[1]&127,this._opcode===0){if(R){let P=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");G(P);return}if(!this._fragmented){let P=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");G(P);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let P=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");G(P);return}this._compressed=R}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let P=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");G(P);return}if(R){let P=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");G(P);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let P=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");G(P);return}}else{let P=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");G(P);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(H[1]&128)===128,this._isServer){if(!this._masked){let P=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");G(P);return}}else if(this._masked){let P=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");G(P);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength(G)}getPayloadLength16(G){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(G)}getPayloadLength64(G){if(this._bufferedBytes<8){this._loop=!1;return}let H=this.consume(8),R=H.readUInt32BE(0);if(R>Math.pow(2,21)-1){let P=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");G(P);return}this._payloadLength=R*Math.pow(2,32)+H.readUInt32BE(4),this.haveLength(G)}haveLength(G){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let H=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");G(H);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(G){let H=A6;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(H=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)bI(H,this._mask)}if(this._opcode>7){this.controlMessage(H,G);return}if(this._compressed){this._state=5,this.decompress(H,G);return}if(H.length)this._messageLength=this._totalPayloadLength,this._fragments.push(H);this.dataMessage(G)}decompress(G,H){this._extensions[R6.extensionName].decompress(G,this._fin,(P,D)=>{if(P)return H(P);if(D.length){if(this._messageLength+=D.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let M=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");H(M);return}this._fragments.push(D)}if(this.dataMessage(H),this._state===0)this.startLoop(H)})}dataMessage(G){if(!this._fin){this._state=0;return}let H=this._messageLength,R=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let P;if(this._binaryType==="nodebuffer")P=uJ(R,H);else if(this._binaryType==="arraybuffer")P=kI(uJ(R,H));else if(this._binaryType==="blob")P=new Blob(R);else P=R;if(this._allowSynchronousEvents)this.emit("message",P,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",P,!0),this._state=0,this.startLoop(G)})}else{let P=uJ(R,H);if(!this._skipUTF8Validation&&!F6(P)){let D=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");G(D);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",P,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",P,!1),this._state=0,this.startLoop(G)})}}controlMessage(G,H){if(this._opcode===8){if(G.length===0)this._loop=!1,this.emit("conclude",1005,A6),this.end();else{let R=G.readUInt16BE(0);if(!iI(R)){let D=this.createError(RangeError,`invalid status code ${R}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");H(D);return}let P=new z7(G.buffer,G.byteOffset+2,G.length-2);if(!this._skipUTF8Validation&&!F6(P)){let D=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");H(D);return}this._loop=!1,this.emit("conclude",R,P),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",G),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",G),this._state=0,this.startLoop(H)})}createError(G,H,R,P,D){this._loop=!1,this._errored=!0;let M=new G(R?`Invalid WebSocket frame: ${H}`:H);return Error.captureStackTrace(M,this.createError),M.code=D,M[lI]=P,M}}O6.exports=D6});var kJ=E1((ZV,T6)=>{var{Duplex:XV}=o5("stream"),{randomFillSync:dI}=o5("crypto"),M6=N3(),{EMPTY_BUFFER:cI,kWebSocket:nI,NOOP:rI}=Y4(),{isBlob:C8,isValidStatusCode:aI}=B8(),{mask:P6,toBuffer:n4}=_3(),k1=Symbol("kByteLength"),sI=Buffer.alloc(4),r4,q8=8192,c1=0,oI=1,tI=2;class L4{constructor(G,H,R){if(this._extensions=H||{},R)this._generateMask=R,this._maskBuffer=Buffer.alloc(4);this._socket=G,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=c1,this.onerror=rI,this[nI]=void 0}static frame(G,H){let R,P=!1,D=2,M=!1;if(H.mask){if(R=H.maskBuffer||sI,H.generateMask)H.generateMask(R);else{if(q8===8192){if(r4===void 0)r4=Buffer.alloc(8192);dI(r4,0,8192),q8=0}R[0]=r4[q8++],R[1]=r4[q8++],R[2]=r4[q8++],R[3]=r4[q8++]}M=(R[0]|R[1]|R[2]|R[3])===0,D=6}let p;if(typeof G==="string")if((!H.mask||M)&&H[k1]!==void 0)p=H[k1];else G=Buffer.from(G),p=G.length;else p=G.length,P=H.mask&&H.readOnly&&!M;let f=p;if(p>=65536)D+=8,f=127;else if(p>125)D+=2,f=126;let u=Buffer.allocUnsafe(P?p+D:D);if(u[0]=H.fin?H.opcode|128:H.opcode,H.rsv1)u[0]|=64;if(u[1]=f,f===126)u.writeUInt16BE(p,2);else if(f===127)u[2]=u[3]=0,u.writeUIntBE(p,4,6);if(!H.mask)return[u,G];if(u[1]|=128,u[D-4]=R[0],u[D-3]=R[1],u[D-2]=R[2],u[D-1]=R[3],M)return[u,G];if(P)return P6(G,R,u,D,p),[u];return P6(G,R,G,0,p),[u,G]}close(G,H,R,P){let D;if(G===void 0)D=cI;else if(typeof G!=="number"||!aI(G))throw TypeError("First argument must be a valid error code number");else if(H===void 0||!H.length)D=Buffer.allocUnsafe(2),D.writeUInt16BE(G,0);else{let p=Buffer.byteLength(H);if(p>123)throw RangeError("The message must not be greater than 123 bytes");if(D=Buffer.allocUnsafe(2+p),D.writeUInt16BE(G,0),typeof H==="string")D.write(H,2);else D.set(H,2)}let M={[k1]:D.length,fin:!0,generateMask:this._generateMask,mask:R,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==c1)this.enqueue([this.dispatch,D,!1,M,P]);else this.sendFrame(L4.frame(D,M),P)}ping(G,H,R){let P,D;if(typeof G==="string")P=Buffer.byteLength(G),D=!1;else if(C8(G))P=G.size,D=!1;else G=n4(G),P=G.length,D=n4.readOnly;if(P>125)throw RangeError("The data size must not be greater than 125 bytes");let M={[k1]:P,fin:!0,generateMask:this._generateMask,mask:H,maskBuffer:this._maskBuffer,opcode:9,readOnly:D,rsv1:!1};if(C8(G))if(this._state!==c1)this.enqueue([this.getBlobData,G,!1,M,R]);else this.getBlobData(G,!1,M,R);else if(this._state!==c1)this.enqueue([this.dispatch,G,!1,M,R]);else this.sendFrame(L4.frame(G,M),R)}pong(G,H,R){let P,D;if(typeof G==="string")P=Buffer.byteLength(G),D=!1;else if(C8(G))P=G.size,D=!1;else G=n4(G),P=G.length,D=n4.readOnly;if(P>125)throw RangeError("The data size must not be greater than 125 bytes");let M={[k1]:P,fin:!0,generateMask:this._generateMask,mask:H,maskBuffer:this._maskBuffer,opcode:10,readOnly:D,rsv1:!1};if(C8(G))if(this._state!==c1)this.enqueue([this.getBlobData,G,!1,M,R]);else this.getBlobData(G,!1,M,R);else if(this._state!==c1)this.enqueue([this.dispatch,G,!1,M,R]);else this.sendFrame(L4.frame(G,M),R)}send(G,H,R){let P=this._extensions[M6.extensionName],D=H.binary?2:1,M=H.compress,p,f;if(typeof G==="string")p=Buffer.byteLength(G),f=!1;else if(C8(G))p=G.size,f=!1;else G=n4(G),p=G.length,f=n4.readOnly;if(this._firstFragment){if(this._firstFragment=!1,M&&P&&P.params[P._isServer?"server_no_context_takeover":"client_no_context_takeover"])M=p>=P._threshold;this._compress=M}else M=!1,D=0;if(H.fin)this._firstFragment=!0;let u={[k1]:p,fin:H.fin,generateMask:this._generateMask,mask:H.mask,maskBuffer:this._maskBuffer,opcode:D,readOnly:f,rsv1:M};if(C8(G))if(this._state!==c1)this.enqueue([this.getBlobData,G,this._compress,u,R]);else this.getBlobData(G,this._compress,u,R);else if(this._state!==c1)this.enqueue([this.dispatch,G,this._compress,u,R]);else this.dispatch(G,this._compress,u,R)}getBlobData(G,H,R,P){this._bufferedBytes+=R[k1],this._state=tI,G.arrayBuffer().then((D)=>{if(this._socket.destroyed){let p=Error("The socket was closed while the blob was being read");process.nextTick(pJ,this,p,P);return}this._bufferedBytes-=R[k1];let M=n4(D);if(!H)this._state=c1,this.sendFrame(L4.frame(M,R),P),this.dequeue();else this.dispatch(M,H,R,P)}).catch((D)=>{process.nextTick(eI,this,D,P)})}dispatch(G,H,R,P){if(!H){this.sendFrame(L4.frame(G,R),P);return}let D=this._extensions[M6.extensionName];this._bufferedBytes+=R[k1],this._state=oI,D.compress(G,R.fin,(M,p)=>{if(this._socket.destroyed){let f=Error("The socket was closed while data was being compressed");pJ(this,f,P);return}this._bufferedBytes-=R[k1],this._state=c1,R.readOnly=!1,this.sendFrame(L4.frame(p,R),P),this.dequeue()})}dequeue(){while(this._state===c1&&this._queue.length){let G=this._queue.shift();this._bufferedBytes-=G[3][k1],Reflect.apply(G[0],this,G.slice(1))}}enqueue(G){this._bufferedBytes+=G[3][k1],this._queue.push(G)}sendFrame(G,H){if(G.length===2)this._socket.cork(),this._socket.write(G[0]),this._socket.write(G[1],H),this._socket.uncork();else this._socket.write(G[0],H)}}T6.exports=L4;function pJ(G,H,R){if(typeof R==="function")R(H);for(let P=0;P<G._queue.length;P++){let D=G._queue[P],M=D[D.length-1];if(typeof M==="function")M(H)}}function eI(G,H,R){pJ(G,H,R),G.onerror(H)}});var y6=E1(($V,E6)=>{var{kForOnEventAttribute:R3,kListener:bJ}=Y4(),x6=Symbol("kCode"),B6=Symbol("kData"),C6=Symbol("kError"),q6=Symbol("kMessage"),U6=Symbol("kReason"),U8=Symbol("kTarget"),L6=Symbol("kType"),W6=Symbol("kWasClean");class W4{constructor(G){this[U8]=null,this[L6]=G}get target(){return this[U8]}get type(){return this[L6]}}Object.defineProperty(W4.prototype,"target",{enumerable:!0});Object.defineProperty(W4.prototype,"type",{enumerable:!0});class L8 extends W4{constructor(G,H={}){super(G);this[x6]=H.code===void 0?0:H.code,this[U6]=H.reason===void 0?"":H.reason,this[W6]=H.wasClean===void 0?!1:H.wasClean}get code(){return this[x6]}get reason(){return this[U6]}get wasClean(){return this[W6]}}Object.defineProperty(L8.prototype,"code",{enumerable:!0});Object.defineProperty(L8.prototype,"reason",{enumerable:!0});Object.defineProperty(L8.prototype,"wasClean",{enumerable:!0});class A3 extends W4{constructor(G,H={}){super(G);this[C6]=H.error===void 0?null:H.error,this[q6]=H.message===void 0?"":H.message}get error(){return this[C6]}get message(){return this[q6]}}Object.defineProperty(A3.prototype,"error",{enumerable:!0});Object.defineProperty(A3.prototype,"message",{enumerable:!0});class Y7 extends W4{constructor(G,H={}){super(G);this[B6]=H.data===void 0?null:H.data}get data(){return this[B6]}}Object.defineProperty(Y7.prototype,"data",{enumerable:!0});var Jz={addEventListener(G,H,R={}){for(let D of this.listeners(G))if(!R[R3]&&D[bJ]===H&&!D[R3])return;let P;if(G==="message")P=function(M,p){let f=new Y7("message",{data:p?M:M.toString()});f[U8]=this,j7(H,this,f)};else if(G==="close")P=function(M,p){let f=new L8("close",{code:M,reason:p.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[U8]=this,j7(H,this,f)};else if(G==="error")P=function(M){let p=new A3("error",{error:M,message:M.message});p[U8]=this,j7(H,this,p)};else if(G==="open")P=function(){let M=new W4("open");M[U8]=this,j7(H,this,M)};else return;if(P[R3]=!!R[R3],P[bJ]=H,R.once)this.once(G,P);else this.on(G,P)},removeEventListener(G,H){for(let R of this.listeners(G))if(R[bJ]===H&&!R[R3]){this.removeListener(G,R);break}}};E6.exports={CloseEvent:L8,ErrorEvent:A3,Event:W4,EventTarget:Jz,MessageEvent:Y7};function j7(G,H,R){if(typeof G==="object"&&G.handleEvent)G.handleEvent.call(G,R);else G.call(H,R)}});var iJ=E1((QV,S6)=>{var{tokenChars:F3}=B8();function X4(G,H,R){if(G[H]===void 0)G[H]=[R];else G[H].push(R)}function Kz(G){let H=Object.create(null),R=Object.create(null),P=!1,D=!1,M=!1,p,f,u=-1,V0=-1,R0=-1,Z0=0;for(;Z0<G.length;Z0++)if(V0=G.charCodeAt(Z0),p===void 0)if(R0===-1&&F3[V0]===1){if(u===-1)u=Z0}else if(Z0!==0&&(V0===32||V0===9)){if(R0===-1&&u!==-1)R0=Z0}else if(V0===59||V0===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(R0===-1)R0=Z0;let h=G.slice(u,R0);if(V0===44)X4(H,h,R),R=Object.create(null);else p=h;u=R0=-1}else throw SyntaxError(`Unexpected character at index ${Z0}`);else if(f===void 0)if(R0===-1&&F3[V0]===1){if(u===-1)u=Z0}else if(V0===32||V0===9){if(R0===-1&&u!==-1)R0=Z0}else if(V0===59||V0===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(R0===-1)R0=Z0;if(X4(R,G.slice(u,R0),!0),V0===44)X4(H,p,R),R=Object.create(null),p=void 0;u=R0=-1}else if(V0===61&&u!==-1&&R0===-1)f=G.slice(u,Z0),u=R0=-1;else throw SyntaxError(`Unexpected character at index ${Z0}`);else if(D){if(F3[V0]!==1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(u===-1)u=Z0;else if(!P)P=!0;D=!1}else if(M)if(F3[V0]===1){if(u===-1)u=Z0}else if(V0===34&&u!==-1)M=!1,R0=Z0;else if(V0===92)D=!0;else throw SyntaxError(`Unexpected character at index ${Z0}`);else if(V0===34&&G.charCodeAt(Z0-1)===61)M=!0;else if(R0===-1&&F3[V0]===1){if(u===-1)u=Z0}else if(u!==-1&&(V0===32||V0===9)){if(R0===-1)R0=Z0}else if(V0===59||V0===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(R0===-1)R0=Z0;let h=G.slice(u,R0);if(P)h=h.replace(/\\/g,""),P=!1;if(X4(R,f,h),V0===44)X4(H,p,R),R=Object.create(null),p=void 0;f=void 0,u=R0=-1}else throw SyntaxError(`Unexpected character at index ${Z0}`);if(u===-1||M||V0===32||V0===9)throw SyntaxError("Unexpected end of input");if(R0===-1)R0=Z0;let U=G.slice(u,R0);if(p===void 0)X4(H,U,R);else{if(f===void 0)X4(R,U,!0);else if(P)X4(R,f,U.replace(/\\/g,""));else X4(R,f,U);X4(H,p,R)}return H}function Xz(G){return Object.keys(G).map((H)=>{let R=G[H];if(!Array.isArray(R))R=[R];return R.map((P)=>{return[H].concat(Object.keys(P).map((D)=>{let M=P[D];if(!Array.isArray(M))M=[M];return M.map((p)=>p===!0?D:`${D}=${p}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}S6.exports={format:Xz,parse:Kz}});var N7=E1((zV,i6)=>{var Zz=o5("events"),$z=o5("https"),Qz=o5("http"),g6=o5("net"),Gz=o5("tls"),{randomBytes:Iz,createHash:zz}=o5("crypto"),{Duplex:GV,Readable:IV}=o5("stream"),{URL:dJ}=o5("url"),E4=N3(),jz=lJ(),Yz=kJ(),{isBlob:Vz}=B8(),{BINARY_TYPES:v6,CLOSE_TIMEOUT:_z,EMPTY_BUFFER:V7,GUID:Hz,kForOnEventAttribute:cJ,kListener:Nz,kStatusCode:Rz,kWebSocket:Y1,NOOP:h6}=Y4(),{EventTarget:{addEventListener:Az,removeEventListener:Fz}}=y6(),{format:Dz,parse:Oz}=iJ(),{toBuffer:Mz}=_3(),m6=Symbol("kAborted"),nJ=[8,13],_4=["CONNECTING","OPEN","CLOSING","CLOSED"],Pz=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class a0 extends Zz{constructor(G,H,R){super();if(this._binaryType=v6[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=V7,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=a0.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,G!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,H===void 0)H=[];else if(!Array.isArray(H))if(typeof H==="object"&&H!==null)R=H,H=[];else H=[H];f6(this,G,H,R)}else this._autoPong=R.autoPong,this._closeTimeout=R.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(G){if(!v6.includes(G))return;if(this._binaryType=G,this._receiver)this._receiver._binaryType=G}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}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(G,H,R){let P=new jz({allowSynchronousEvents:R.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:R.maxPayload,skipUTF8Validation:R.skipUTF8Validation}),D=new Yz(G,this._extensions,R.generateMask);if(this._receiver=P,this._sender=D,this._socket=G,P[Y1]=this,D[Y1]=this,G[Y1]=this,P.on("conclude",Bz),P.on("drain",Cz),P.on("error",qz),P.on("message",Uz),P.on("ping",Lz),P.on("pong",Wz),D.onerror=Ez,G.setTimeout)G.setTimeout(0);if(G.setNoDelay)G.setNoDelay();if(H.length>0)G.unshift(H);G.on("close",p6),G.on("data",H7),G.on("end",k6),G.on("error",b6),this._readyState=a0.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=a0.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[E4.extensionName])this._extensions[E4.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=a0.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(G,H){if(this.readyState===a0.CLOSED)return;if(this.readyState===a0.CONNECTING){v1(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===a0.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=a0.CLOSING,this._sender.close(G,H,!this._isServer,(R)=>{if(R)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),l6(this)}pause(){if(this.readyState===a0.CONNECTING||this.readyState===a0.CLOSED)return;this._paused=!0,this._socket.pause()}ping(G,H,R){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof G==="function")R=G,G=H=void 0;else if(typeof H==="function")R=H,H=void 0;if(typeof G==="number")G=G.toString();if(this.readyState!==a0.OPEN){rJ(this,G,R);return}if(H===void 0)H=!this._isServer;this._sender.ping(G||V7,H,R)}pong(G,H,R){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof G==="function")R=G,G=H=void 0;else if(typeof H==="function")R=H,H=void 0;if(typeof G==="number")G=G.toString();if(this.readyState!==a0.OPEN){rJ(this,G,R);return}if(H===void 0)H=!this._isServer;this._sender.pong(G||V7,H,R)}resume(){if(this.readyState===a0.CONNECTING||this.readyState===a0.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send(G,H,R){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof H==="function")R=H,H={};if(typeof G==="number")G=G.toString();if(this.readyState!==a0.OPEN){rJ(this,G,R);return}let P={binary:typeof G!=="string",mask:!this._isServer,compress:!0,fin:!0,...H};if(!this._extensions[E4.extensionName])P.compress=!1;this._sender.send(G||V7,P,R)}terminate(){if(this.readyState===a0.CLOSED)return;if(this.readyState===a0.CONNECTING){v1(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=a0.CLOSING,this._socket.destroy()}}Object.defineProperty(a0,"CONNECTING",{enumerable:!0,value:_4.indexOf("CONNECTING")});Object.defineProperty(a0.prototype,"CONNECTING",{enumerable:!0,value:_4.indexOf("CONNECTING")});Object.defineProperty(a0,"OPEN",{enumerable:!0,value:_4.indexOf("OPEN")});Object.defineProperty(a0.prototype,"OPEN",{enumerable:!0,value:_4.indexOf("OPEN")});Object.defineProperty(a0,"CLOSING",{enumerable:!0,value:_4.indexOf("CLOSING")});Object.defineProperty(a0.prototype,"CLOSING",{enumerable:!0,value:_4.indexOf("CLOSING")});Object.defineProperty(a0,"CLOSED",{enumerable:!0,value:_4.indexOf("CLOSED")});Object.defineProperty(a0.prototype,"CLOSED",{enumerable:!0,value:_4.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((G)=>{Object.defineProperty(a0.prototype,G,{enumerable:!0})});["open","error","close","message"].forEach((G)=>{Object.defineProperty(a0.prototype,`on${G}`,{enumerable:!0,get(){for(let H of this.listeners(G))if(H[cJ])return H[Nz];return null},set(H){for(let R of this.listeners(G))if(R[cJ]){this.removeListener(G,R);break}if(typeof H!=="function")return;this.addEventListener(G,H,{[cJ]:!0})}})});a0.prototype.addEventListener=Az;a0.prototype.removeEventListener=Fz;i6.exports=a0;function f6(G,H,R,P){let D={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:_z,protocolVersion:nJ[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...P,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(G._autoPong=D.autoPong,G._closeTimeout=D.closeTimeout,!nJ.includes(D.protocolVersion))throw RangeError(`Unsupported protocol version: ${D.protocolVersion} (supported versions: ${nJ.join(", ")})`);let M;if(H instanceof dJ)M=H;else try{M=new dJ(H)}catch(y){throw SyntaxError(`Invalid URL: ${H}`)}if(M.protocol==="http:")M.protocol="ws:";else if(M.protocol==="https:")M.protocol="wss:";G._url=M.href;let p=M.protocol==="wss:",f=M.protocol==="ws+unix:",u;if(M.protocol!=="ws:"&&!p&&!f)u=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(f&&!M.pathname)u="The URL's pathname is empty";else if(M.hash)u="The URL contains a fragment identifier";if(u){let y=SyntaxError(u);if(G._redirects===0)throw y;else{_7(G,y);return}}let V0=p?443:80,R0=Iz(16).toString("base64"),Z0=p?$z.request:Qz.request,U=new Set,h;if(D.createConnection=D.createConnection||(p?xz:Tz),D.defaultPort=D.defaultPort||V0,D.port=M.port||V0,D.host=M.hostname.startsWith("[")?M.hostname.slice(1,-1):M.hostname,D.headers={...D.headers,"Sec-WebSocket-Version":D.protocolVersion,"Sec-WebSocket-Key":R0,Connection:"Upgrade",Upgrade:"websocket"},D.path=M.pathname+M.search,D.timeout=D.handshakeTimeout,D.perMessageDeflate)h=new E4(D.perMessageDeflate!==!0?D.perMessageDeflate:{},!1,D.maxPayload),D.headers["Sec-WebSocket-Extensions"]=Dz({[E4.extensionName]:h.offer()});if(R.length){for(let y of R){if(typeof y!=="string"||!Pz.test(y)||U.has(y))throw SyntaxError("An invalid or duplicated subprotocol was specified");U.add(y)}D.headers["Sec-WebSocket-Protocol"]=R.join(",")}if(D.origin)if(D.protocolVersion<13)D.headers["Sec-WebSocket-Origin"]=D.origin;else D.headers.Origin=D.origin;if(M.username||M.password)D.auth=`${M.username}:${M.password}`;if(f){let y=D.path.split(":");D.socketPath=y[0],D.path=y[1]}let g;if(D.followRedirects){if(G._redirects===0){G._originalIpc=f,G._originalSecure=p,G._originalHostOrSocketPath=f?D.socketPath:M.host;let y=P&&P.headers;if(P={...P,headers:{}},y)for(let[r,F0]of Object.entries(y))P.headers[r.toLowerCase()]=F0}else if(G.listenerCount("redirect")===0){let y=f?G._originalIpc?D.socketPath===G._originalHostOrSocketPath:!1:G._originalIpc?!1:M.host===G._originalHostOrSocketPath;if(!y||G._originalSecure&&!p){if(delete D.headers.authorization,delete D.headers.cookie,!y)delete D.headers.host;D.auth=void 0}}if(D.auth&&!P.headers.authorization)P.headers.authorization="Basic "+Buffer.from(D.auth).toString("base64");if(g=G._req=Z0(D),G._redirects)G.emit("redirect",G.url,g)}else g=G._req=Z0(D);if(D.timeout)g.on("timeout",()=>{v1(G,g,"Opening handshake has timed out")});if(g.on("error",(y)=>{if(g===null||g[m6])return;g=G._req=null,_7(G,y)}),g.on("response",(y)=>{let r=y.headers.location,F0=y.statusCode;if(r&&D.followRedirects&&F0>=300&&F0<400){if(++G._redirects>D.maxRedirects){v1(G,g,"Maximum redirects exceeded");return}g.abort();let v0;try{v0=new dJ(r,H)}catch($0){let A0=SyntaxError(`Invalid URL: ${r}`);_7(G,A0);return}f6(G,v0,R,P)}else if(!G.emit("unexpected-response",g,y))v1(G,g,`Unexpected server response: ${y.statusCode}`)}),g.on("upgrade",(y,r,F0)=>{if(G.emit("upgrade",y),G.readyState!==a0.CONNECTING)return;g=G._req=null;let v0=y.headers.upgrade;if(v0===void 0||v0.toLowerCase()!=="websocket"){v1(G,r,"Invalid Upgrade header");return}let $0=zz("sha1").update(R0+Hz).digest("base64");if(y.headers["sec-websocket-accept"]!==$0){v1(G,r,"Invalid Sec-WebSocket-Accept header");return}let A0=y.headers["sec-websocket-protocol"],Q0;if(A0!==void 0){if(!U.size)Q0="Server sent a subprotocol but none was requested";else if(!U.has(A0))Q0="Server sent an invalid subprotocol"}else if(U.size)Q0="Server sent no subprotocol";if(Q0){v1(G,r,Q0);return}if(A0)G._protocol=A0;let H0=y.headers["sec-websocket-extensions"];if(H0!==void 0){if(!h){v1(G,r,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let I0;try{I0=Oz(H0)}catch(F5){v1(G,r,"Invalid Sec-WebSocket-Extensions header");return}let L0=Object.keys(I0);if(L0.length!==1||L0[0]!==E4.extensionName){v1(G,r,"Server indicated an extension that was not requested");return}try{h.accept(I0[E4.extensionName])}catch(F5){v1(G,r,"Invalid Sec-WebSocket-Extensions header");return}G._extensions[E4.extensionName]=h}G.setSocket(r,F0,{allowSynchronousEvents:D.allowSynchronousEvents,generateMask:D.generateMask,maxPayload:D.maxPayload,skipUTF8Validation:D.skipUTF8Validation})}),D.finishRequest)D.finishRequest(g,G);else g.end()}function _7(G,H){G._readyState=a0.CLOSING,G._errorEmitted=!0,G.emit("error",H),G.emitClose()}function Tz(G){return G.path=G.socketPath,g6.connect(G)}function xz(G){if(G.path=void 0,!G.servername&&G.servername!=="")G.servername=g6.isIP(G.host)?"":G.host;return Gz.connect(G)}function v1(G,H,R){G._readyState=a0.CLOSING;let P=Error(R);if(Error.captureStackTrace(P,v1),H.setHeader){if(H[m6]=!0,H.abort(),H.socket&&!H.socket.destroyed)H.socket.destroy();process.nextTick(_7,G,P)}else H.destroy(P),H.once("error",G.emit.bind(G,"error")),H.once("close",G.emitClose.bind(G))}function rJ(G,H,R){if(H){let P=Vz(H)?H.size:Mz(H).length;if(G._socket)G._sender._bufferedBytes+=P;else G._bufferedAmount+=P}if(R){let P=Error(`WebSocket is not open: readyState ${G.readyState} (${_4[G.readyState]})`);process.nextTick(R,P)}}function Bz(G,H){let R=this[Y1];if(R._closeFrameReceived=!0,R._closeMessage=H,R._closeCode=G,R._socket[Y1]===void 0)return;if(R._socket.removeListener("data",H7),process.nextTick(u6,R._socket),G===1005)R.close();else R.close(G,H)}function Cz(){let G=this[Y1];if(!G.isPaused)G._socket.resume()}function qz(G){let H=this[Y1];if(H._socket[Y1]!==void 0)H._socket.removeListener("data",H7),process.nextTick(u6,H._socket),H.close(G[Rz]);if(!H._errorEmitted)H._errorEmitted=!0,H.emit("error",G)}function w6(){this[Y1].emitClose()}function Uz(G,H){this[Y1].emit("message",G,H)}function Lz(G){let H=this[Y1];if(H._autoPong)H.pong(G,!this._isServer,h6);H.emit("ping",G)}function Wz(G){this[Y1].emit("pong",G)}function u6(G){G.resume()}function Ez(G){let H=this[Y1];if(H.readyState===a0.CLOSED)return;if(H.readyState===a0.OPEN)H._readyState=a0.CLOSING,l6(H);if(this._socket.end(),!H._errorEmitted)H._errorEmitted=!0,H.emit("error",G)}function l6(G){G._closeTimer=setTimeout(G._socket.destroy.bind(G._socket),G._closeTimeout)}function p6(){let G=this[Y1];if(this.removeListener("close",p6),this.removeListener("data",H7),this.removeListener("end",k6),G._readyState=a0.CLOSING,!this._readableState.endEmitted&&!G._closeFrameReceived&&!G._receiver._writableState.errorEmitted&&this._readableState.length!==0){let H=this.read(this._readableState.length);G._receiver.write(H)}if(G._receiver.end(),this[Y1]=void 0,clearTimeout(G._closeTimer),G._receiver._writableState.finished||G._receiver._writableState.errorEmitted)G.emitClose();else G._receiver.on("error",w6),G._receiver.on("finish",w6)}function H7(G){if(!this[Y1]._receiver.write(G))this.pause()}function k6(){let G=this[Y1];G._readyState=a0.CLOSING,G._receiver.end(),this.end()}function b6(){let G=this[Y1];if(this.removeListener("error",b6),this.on("error",h6),G)G._readyState=a0.CLOSING,this.destroy()}});var r6=E1((YV,n6)=>{var jV=N7(),{Duplex:yz}=o5("stream");function d6(G){G.emit("close")}function Sz(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function c6(G){if(this.removeListener("error",c6),this.destroy(),this.listenerCount("error")===0)this.emit("error",G)}function vz(G,H){let R=!0,P=new yz({...H,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return G.on("message",function(M,p){let f=!p&&P._readableState.objectMode?M.toString():M;if(!P.push(f))G.pause()}),G.once("error",function(M){if(P.destroyed)return;R=!1,P.destroy(M)}),G.once("close",function(){if(P.destroyed)return;P.push(null)}),P._destroy=function(D,M){if(G.readyState===G.CLOSED){M(D),process.nextTick(d6,P);return}let p=!1;if(G.once("error",function(u){p=!0,M(u)}),G.once("close",function(){if(!p)M(D);process.nextTick(d6,P)}),R)G.terminate()},P._final=function(D){if(G.readyState===G.CONNECTING){G.once("open",function(){P._final(D)});return}if(G._socket===null)return;if(G._socket._writableState.finished){if(D(),P._readableState.endEmitted)P.destroy()}else G._socket.once("finish",function(){D()}),G.close()},P._read=function(){if(G.isPaused)G.resume()},P._write=function(D,M,p){if(G.readyState===G.CONNECTING){G.once("open",function(){P._write(D,M,p)});return}G.send(D,p)},P.on("end",Sz),P.on("error",c6),P}n6.exports=vz});var s6=E1((VV,a6)=>{var{tokenChars:wz}=B8();function gz(G){let H=new Set,R=-1,P=-1,D=0;for(D;D<G.length;D++){let p=G.charCodeAt(D);if(P===-1&&wz[p]===1){if(R===-1)R=D}else if(D!==0&&(p===32||p===9)){if(P===-1&&R!==-1)P=D}else if(p===44){if(R===-1)throw SyntaxError(`Unexpected character at index ${D}`);if(P===-1)P=D;let f=G.slice(R,P);if(H.has(f))throw SyntaxError(`The "${f}" subprotocol is duplicated`);H.add(f),R=P=-1}else throw SyntaxError(`Unexpected character at index ${D}`)}if(R===-1||P!==-1)throw SyntaxError("Unexpected end of input");let M=G.slice(R,D);if(H.has(M))throw SyntaxError(`The "${M}" subprotocol is duplicated`);return H.add(M),H}a6.exports={parse:gz}});var K$=E1((HV,J$)=>{var hz=o5("events"),R7=o5("http"),{Duplex:_V}=o5("stream"),{createHash:mz}=o5("crypto"),o6=iJ(),a4=N3(),fz=s6(),uz=N7(),{CLOSE_TIMEOUT:lz,GUID:pz,kWebSocket:kz}=Y4(),bz=/^[+/0-9A-Za-z]{22}==$/;class e6 extends hz{constructor(G,H){super();if(G={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:lz,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:uz,...G},G.port==null&&!G.server&&!G.noServer||G.port!=null&&(G.server||G.noServer)||G.server&&G.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(G.port!=null)this._server=R7.createServer((R,P)=>{let D=R7.STATUS_CODES[426];P.writeHead(426,{"Content-Length":D.length,"Content-Type":"text/plain"}),P.end(D)}),this._server.listen(G.port,G.host,G.backlog,H);else if(G.server)this._server=G.server;if(this._server){let R=this.emit.bind(this,"connection");this._removeListeners=iz(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(P,D,M)=>{this.handleUpgrade(P,D,M,R)}})}if(G.perMessageDeflate===!0)G.perMessageDeflate={};if(G.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=G,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close(G){if(this._state===2){if(G)this.once("close",()=>{G(Error("The server is not running"))});process.nextTick(D3,this);return}if(G)this.once("close",G);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(D3,this);else this._shouldEmitClose=!0;else process.nextTick(D3,this)}else{let H=this._server;this._removeListeners(),this._removeListeners=this._server=null,H.close(()=>{D3(this)})}}shouldHandle(G){if(this.options.path){let H=G.url.indexOf("?");if((H!==-1?G.url.slice(0,H):G.url)!==this.options.path)return!1}return!0}handleUpgrade(G,H,R,P){H.on("error",t6);let D=G.headers["sec-websocket-key"],M=G.headers.upgrade,p=+G.headers["sec-websocket-version"];if(G.method!=="GET"){s4(this,G,H,405,"Invalid HTTP method");return}if(M===void 0||M.toLowerCase()!=="websocket"){s4(this,G,H,400,"Invalid Upgrade header");return}if(D===void 0||!bz.test(D)){s4(this,G,H,400,"Missing or invalid Sec-WebSocket-Key header");return}if(p!==13&&p!==8){s4(this,G,H,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(G)){O3(H,400);return}let f=G.headers["sec-websocket-protocol"],u=new Set;if(f!==void 0)try{u=fz.parse(f)}catch(Z0){s4(this,G,H,400,"Invalid Sec-WebSocket-Protocol header");return}let V0=G.headers["sec-websocket-extensions"],R0={};if(this.options.perMessageDeflate&&V0!==void 0){let Z0=new a4(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let U=o6.parse(V0);if(U[a4.extensionName])Z0.accept(U[a4.extensionName]),R0[a4.extensionName]=Z0}catch(U){s4(this,G,H,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let Z0={origin:G.headers[`${p===8?"sec-websocket-origin":"origin"}`],secure:!!(G.socket.authorized||G.socket.encrypted),req:G};if(this.options.verifyClient.length===2){this.options.verifyClient(Z0,(U,h,g,y)=>{if(!U)return O3(H,h||401,g,y);this.completeUpgrade(R0,D,u,G,H,R,P)});return}if(!this.options.verifyClient(Z0))return O3(H,401)}this.completeUpgrade(R0,D,u,G,H,R,P)}completeUpgrade(G,H,R,P,D,M,p){if(!D.readable||!D.writable)return D.destroy();if(D[kz])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return O3(D,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${mz("sha1").update(H+pz).digest("base64")}`],V0=new this.options.WebSocket(null,void 0,this.options);if(R.size){let R0=this.options.handleProtocols?this.options.handleProtocols(R,P):R.values().next().value;if(R0)u.push(`Sec-WebSocket-Protocol: ${R0}`),V0._protocol=R0}if(G[a4.extensionName]){let R0=G[a4.extensionName].params,Z0=o6.format({[a4.extensionName]:[R0]});u.push(`Sec-WebSocket-Extensions: ${Z0}`),V0._extensions=G}if(this.emit("headers",u,P),D.write(u.concat(`\r
1
+ import{$l as o5,Wl as W8,Yl as E1}from"./chunk-4fs853nh.js";var Y4=E1((sY,X6)=>{var J6=["nodebuffer","arraybuffer","fragments"],K6=typeof Blob<"u";if(K6)J6.push("blob");X6.exports={BINARY_TYPES:J6,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:K6,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var _3=E1((oY,$7)=>{var{EMPTY_BUFFER:qI}=Y4(),gJ=Buffer[Symbol.species];function UI(G,H){if(G.length===0)return qI;if(G.length===1)return G[0];let R=Buffer.allocUnsafe(H),P=0;for(let D=0;D<G.length;D++){let M=G[D];R.set(M,P),P+=M.length}if(P<H)return new gJ(R.buffer,R.byteOffset,P);return R}function Z6(G,H,R,P,D){for(let M=0;M<D;M++)R[P+M]=G[M]^H[M&3]}function $6(G,H){for(let R=0;R<G.length;R++)G[R]^=H[R&3]}function LI(G){if(G.length===G.buffer.byteLength)return G.buffer;return G.buffer.slice(G.byteOffset,G.byteOffset+G.length)}function hJ(G){if(hJ.readOnly=!0,Buffer.isBuffer(G))return G;let H;if(G instanceof ArrayBuffer)H=new gJ(G);else if(ArrayBuffer.isView(G))H=new gJ(G.buffer,G.byteOffset,G.byteLength);else H=Buffer.from(G),hJ.readOnly=!1;return H}$7.exports={concat:UI,mask:Z6,toArrayBuffer:LI,toBuffer:hJ,unmask:$6};if(!process.env.WS_NO_BUFFER_UTIL)try{let G=(()=>{throw new Error("Cannot require module "+"bufferutil");})();$7.exports.mask=function(H,R,P,D,M){if(M<48)Z6(H,R,P,D,M);else G.mask(H,R,P,D,M)},$7.exports.unmask=function(H,R){if(H.length<32)$6(H,R);else G.unmask(H,R)}}catch(G){}});var z6=E1((tY,I6)=>{var Q6=Symbol("kDone"),mJ=Symbol("kRun");class G6{constructor(G){this[Q6]=()=>{this.pending--,this[mJ]()},this.concurrency=G||1/0,this.jobs=[],this.pending=0}add(G){this.jobs.push(G),this[mJ]()}[mJ](){if(this.pending===this.concurrency)return;if(this.jobs.length){let G=this.jobs.shift();this.pending++,G(this[Q6])}}}I6.exports=G6});var N3=E1((eY,H6)=>{var H3=o5("zlib"),j6=_3(),WI=z6(),{kStatusCode:Y6}=Y4(),EI=Buffer[Symbol.species],yI=Buffer.from([0,0,255,255]),G7=Symbol("permessage-deflate"),V4=Symbol("total-length"),T8=Symbol("callback"),U4=Symbol("buffers"),x8=Symbol("error"),Q7;class V6{constructor(G,H,R){if(this._maxPayload=R|0,this._options=G||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!H,this._deflate=null,this._inflate=null,this.params=null,!Q7){let P=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Q7=new WI(P)}}static get extensionName(){return"permessage-deflate"}offer(){let G={};if(this._options.serverNoContextTakeover)G.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)G.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)G.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)G.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)G.client_max_window_bits=!0;return G}accept(G){return G=this.normalizeParams(G),this.params=this._isServer?this.acceptAsServer(G):this.acceptAsClient(G),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let G=this._deflate[T8];if(this._deflate.close(),this._deflate=null,G)G(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(G){let H=this._options,R=G.find((P)=>{if(H.serverNoContextTakeover===!1&&P.server_no_context_takeover||P.server_max_window_bits&&(H.serverMaxWindowBits===!1||typeof H.serverMaxWindowBits==="number"&&H.serverMaxWindowBits>P.server_max_window_bits)||typeof H.clientMaxWindowBits==="number"&&!P.client_max_window_bits)return!1;return!0});if(!R)throw Error("None of the extension offers can be accepted");if(H.serverNoContextTakeover)R.server_no_context_takeover=!0;if(H.clientNoContextTakeover)R.client_no_context_takeover=!0;if(typeof H.serverMaxWindowBits==="number")R.server_max_window_bits=H.serverMaxWindowBits;if(typeof H.clientMaxWindowBits==="number")R.client_max_window_bits=H.clientMaxWindowBits;else if(R.client_max_window_bits===!0||H.clientMaxWindowBits===!1)delete R.client_max_window_bits;return R}acceptAsClient(G){let H=G[0];if(this._options.clientNoContextTakeover===!1&&H.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!H.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")H.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&H.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return H}normalizeParams(G){return G.forEach((H)=>{Object.keys(H).forEach((R)=>{let P=H[R];if(P.length>1)throw Error(`Parameter "${R}" must have only a single value`);if(P=P[0],R==="client_max_window_bits"){if(P!==!0){let D=+P;if(!Number.isInteger(D)||D<8||D>15)throw TypeError(`Invalid value for parameter "${R}": ${P}`);P=D}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${R}": ${P}`)}else if(R==="server_max_window_bits"){let D=+P;if(!Number.isInteger(D)||D<8||D>15)throw TypeError(`Invalid value for parameter "${R}": ${P}`);P=D}else if(R==="client_no_context_takeover"||R==="server_no_context_takeover"){if(P!==!0)throw TypeError(`Invalid value for parameter "${R}": ${P}`)}else throw Error(`Unknown parameter "${R}"`);H[R]=P})}),G}decompress(G,H,R){Q7.add((P)=>{this._decompress(G,H,(D,M)=>{P(),R(D,M)})})}compress(G,H,R){Q7.add((P)=>{this._compress(G,H,(D,M)=>{P(),R(D,M)})})}_decompress(G,H,R){let P=this._isServer?"client":"server";if(!this._inflate){let D=`${P}_max_window_bits`,M=typeof this.params[D]!=="number"?H3.Z_DEFAULT_WINDOWBITS:this.params[D];this._inflate=H3.createInflateRaw({...this._options.zlibInflateOptions,windowBits:M}),this._inflate[G7]=this,this._inflate[V4]=0,this._inflate[U4]=[],this._inflate.on("error",vI),this._inflate.on("data",_6)}if(this._inflate[T8]=R,this._inflate.write(G),H)this._inflate.write(yI);this._inflate.flush(()=>{let D=this._inflate[x8];if(D){this._inflate.close(),this._inflate=null,R(D);return}let M=j6.concat(this._inflate[U4],this._inflate[V4]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[V4]=0,this._inflate[U4]=[],H&&this.params[`${P}_no_context_takeover`])this._inflate.reset();R(null,M)})}_compress(G,H,R){let P=this._isServer?"server":"client";if(!this._deflate){let D=`${P}_max_window_bits`,M=typeof this.params[D]!=="number"?H3.Z_DEFAULT_WINDOWBITS:this.params[D];this._deflate=H3.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:M}),this._deflate[V4]=0,this._deflate[U4]=[],this._deflate.on("data",SI)}this._deflate[T8]=R,this._deflate.write(G),this._deflate.flush(H3.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let D=j6.concat(this._deflate[U4],this._deflate[V4]);if(H)D=new EI(D.buffer,D.byteOffset,D.length-4);if(this._deflate[T8]=null,this._deflate[V4]=0,this._deflate[U4]=[],H&&this.params[`${P}_no_context_takeover`])this._deflate.reset();R(null,D)})}}H6.exports=V6;function SI(G){this[U4].push(G),this[V4]+=G.length}function _6(G){if(this[V4]+=G.length,this[G7]._maxPayload<1||this[V4]<=this[G7]._maxPayload){this[U4].push(G);return}this[x8]=RangeError("Max payload size exceeded"),this[x8].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[x8][Y6]=1009,this.removeListener("data",_6),this.reset()}function vI(G){if(this[G7]._inflate=null,this[x8]){this[T8](this[x8]);return}G[Y6]=1007,this[T8](G)}});var B8=E1((JV,I7)=>{var{isUtf8:N6}=o5("buffer"),{hasBlob:wI}=Y4(),gI=[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 hI(G){return G>=1000&&G<=1014&&G!==1004&&G!==1005&&G!==1006||G>=3000&&G<=4999}function fJ(G){let H=G.length,R=0;while(R<H)if((G[R]&128)===0)R++;else if((G[R]&224)===192){if(R+1===H||(G[R+1]&192)!==128||(G[R]&254)===192)return!1;R+=2}else if((G[R]&240)===224){if(R+2>=H||(G[R+1]&192)!==128||(G[R+2]&192)!==128||G[R]===224&&(G[R+1]&224)===128||G[R]===237&&(G[R+1]&224)===160)return!1;R+=3}else if((G[R]&248)===240){if(R+3>=H||(G[R+1]&192)!==128||(G[R+2]&192)!==128||(G[R+3]&192)!==128||G[R]===240&&(G[R+1]&240)===128||G[R]===244&&G[R+1]>143||G[R]>244)return!1;R+=4}else return!1;return!0}function mI(G){return wI&&typeof G==="object"&&typeof G.arrayBuffer==="function"&&typeof G.type==="string"&&typeof G.stream==="function"&&(G[Symbol.toStringTag]==="Blob"||G[Symbol.toStringTag]==="File")}I7.exports={isBlob:mI,isValidStatusCode:hI,isValidUTF8:fJ,tokenChars:gI};if(N6)I7.exports.isValidUTF8=function(G){return G.length<24?fJ(G):N6(G)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let G=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();I7.exports.isValidUTF8=function(H){return H.length<32?fJ(H):G(H)}}catch(G){}});var lJ=E1((KV,O6)=>{var{Writable:fI}=o5("stream"),R6=N3(),{BINARY_TYPES:uI,EMPTY_BUFFER:A6,kStatusCode:lI,kWebSocket:pI}=Y4(),{concat:uJ,toArrayBuffer:kI,unmask:bI}=_3(),{isValidStatusCode:iI,isValidUTF8:F6}=B8(),z7=Buffer[Symbol.species];class D6 extends fI{constructor(G={}){super();this._allowSynchronousEvents=G.allowSynchronousEvents!==void 0?G.allowSynchronousEvents:!0,this._binaryType=G.binaryType||uI[0],this._extensions=G.extensions||{},this._isServer=!!G.isServer,this._maxPayload=G.maxPayload|0,this._skipUTF8Validation=!!G.skipUTF8Validation,this[pI]=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=0}_write(G,H,R){if(this._opcode===8&&this._state==0)return R();this._bufferedBytes+=G.length,this._buffers.push(G),this.startLoop(R)}consume(G){if(this._bufferedBytes-=G,G===this._buffers[0].length)return this._buffers.shift();if(G<this._buffers[0].length){let R=this._buffers[0];return this._buffers[0]=new z7(R.buffer,R.byteOffset+G,R.length-G),new z7(R.buffer,R.byteOffset,G)}let H=Buffer.allocUnsafe(G);do{let R=this._buffers[0],P=H.length-G;if(G>=R.length)H.set(this._buffers.shift(),P);else H.set(new Uint8Array(R.buffer,R.byteOffset,G),P),this._buffers[0]=new z7(R.buffer,R.byteOffset+G,R.length-G);G-=R.length}while(G>0);return H}startLoop(G){this._loop=!0;do switch(this._state){case 0:this.getInfo(G);break;case 1:this.getPayloadLength16(G);break;case 2:this.getPayloadLength64(G);break;case 3:this.getMask();break;case 4:this.getData(G);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)G()}getInfo(G){if(this._bufferedBytes<2){this._loop=!1;return}let H=this.consume(2);if((H[0]&48)!==0){let P=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");G(P);return}let R=(H[0]&64)===64;if(R&&!this._extensions[R6.extensionName]){let P=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");G(P);return}if(this._fin=(H[0]&128)===128,this._opcode=H[0]&15,this._payloadLength=H[1]&127,this._opcode===0){if(R){let P=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");G(P);return}if(!this._fragmented){let P=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");G(P);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let P=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");G(P);return}this._compressed=R}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let P=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");G(P);return}if(R){let P=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");G(P);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let P=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");G(P);return}}else{let P=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");G(P);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(H[1]&128)===128,this._isServer){if(!this._masked){let P=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");G(P);return}}else if(this._masked){let P=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");G(P);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength(G)}getPayloadLength16(G){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(G)}getPayloadLength64(G){if(this._bufferedBytes<8){this._loop=!1;return}let H=this.consume(8),R=H.readUInt32BE(0);if(R>Math.pow(2,21)-1){let P=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");G(P);return}this._payloadLength=R*Math.pow(2,32)+H.readUInt32BE(4),this.haveLength(G)}haveLength(G){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let H=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");G(H);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(G){let H=A6;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(H=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)bI(H,this._mask)}if(this._opcode>7){this.controlMessage(H,G);return}if(this._compressed){this._state=5,this.decompress(H,G);return}if(H.length)this._messageLength=this._totalPayloadLength,this._fragments.push(H);this.dataMessage(G)}decompress(G,H){this._extensions[R6.extensionName].decompress(G,this._fin,(P,D)=>{if(P)return H(P);if(D.length){if(this._messageLength+=D.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let M=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");H(M);return}this._fragments.push(D)}if(this.dataMessage(H),this._state===0)this.startLoop(H)})}dataMessage(G){if(!this._fin){this._state=0;return}let H=this._messageLength,R=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let P;if(this._binaryType==="nodebuffer")P=uJ(R,H);else if(this._binaryType==="arraybuffer")P=kI(uJ(R,H));else if(this._binaryType==="blob")P=new Blob(R);else P=R;if(this._allowSynchronousEvents)this.emit("message",P,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",P,!0),this._state=0,this.startLoop(G)})}else{let P=uJ(R,H);if(!this._skipUTF8Validation&&!F6(P)){let D=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");G(D);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",P,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",P,!1),this._state=0,this.startLoop(G)})}}controlMessage(G,H){if(this._opcode===8){if(G.length===0)this._loop=!1,this.emit("conclude",1005,A6),this.end();else{let R=G.readUInt16BE(0);if(!iI(R)){let D=this.createError(RangeError,`invalid status code ${R}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");H(D);return}let P=new z7(G.buffer,G.byteOffset+2,G.length-2);if(!this._skipUTF8Validation&&!F6(P)){let D=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");H(D);return}this._loop=!1,this.emit("conclude",R,P),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",G),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",G),this._state=0,this.startLoop(H)})}createError(G,H,R,P,D){this._loop=!1,this._errored=!0;let M=new G(R?`Invalid WebSocket frame: ${H}`:H);return Error.captureStackTrace(M,this.createError),M.code=D,M[lI]=P,M}}O6.exports=D6});var kJ=E1((ZV,T6)=>{var{Duplex:XV}=o5("stream"),{randomFillSync:dI}=o5("crypto"),M6=N3(),{EMPTY_BUFFER:cI,kWebSocket:nI,NOOP:rI}=Y4(),{isBlob:C8,isValidStatusCode:aI}=B8(),{mask:P6,toBuffer:n4}=_3(),k1=Symbol("kByteLength"),sI=Buffer.alloc(4),r4,q8=8192,c1=0,oI=1,tI=2;class L4{constructor(G,H,R){if(this._extensions=H||{},R)this._generateMask=R,this._maskBuffer=Buffer.alloc(4);this._socket=G,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=c1,this.onerror=rI,this[nI]=void 0}static frame(G,H){let R,P=!1,D=2,M=!1;if(H.mask){if(R=H.maskBuffer||sI,H.generateMask)H.generateMask(R);else{if(q8===8192){if(r4===void 0)r4=Buffer.alloc(8192);dI(r4,0,8192),q8=0}R[0]=r4[q8++],R[1]=r4[q8++],R[2]=r4[q8++],R[3]=r4[q8++]}M=(R[0]|R[1]|R[2]|R[3])===0,D=6}let p;if(typeof G==="string")if((!H.mask||M)&&H[k1]!==void 0)p=H[k1];else G=Buffer.from(G),p=G.length;else p=G.length,P=H.mask&&H.readOnly&&!M;let f=p;if(p>=65536)D+=8,f=127;else if(p>125)D+=2,f=126;let u=Buffer.allocUnsafe(P?p+D:D);if(u[0]=H.fin?H.opcode|128:H.opcode,H.rsv1)u[0]|=64;if(u[1]=f,f===126)u.writeUInt16BE(p,2);else if(f===127)u[2]=u[3]=0,u.writeUIntBE(p,4,6);if(!H.mask)return[u,G];if(u[1]|=128,u[D-4]=R[0],u[D-3]=R[1],u[D-2]=R[2],u[D-1]=R[3],M)return[u,G];if(P)return P6(G,R,u,D,p),[u];return P6(G,R,G,0,p),[u,G]}close(G,H,R,P){let D;if(G===void 0)D=cI;else if(typeof G!=="number"||!aI(G))throw TypeError("First argument must be a valid error code number");else if(H===void 0||!H.length)D=Buffer.allocUnsafe(2),D.writeUInt16BE(G,0);else{let p=Buffer.byteLength(H);if(p>123)throw RangeError("The message must not be greater than 123 bytes");if(D=Buffer.allocUnsafe(2+p),D.writeUInt16BE(G,0),typeof H==="string")D.write(H,2);else D.set(H,2)}let M={[k1]:D.length,fin:!0,generateMask:this._generateMask,mask:R,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==c1)this.enqueue([this.dispatch,D,!1,M,P]);else this.sendFrame(L4.frame(D,M),P)}ping(G,H,R){let P,D;if(typeof G==="string")P=Buffer.byteLength(G),D=!1;else if(C8(G))P=G.size,D=!1;else G=n4(G),P=G.length,D=n4.readOnly;if(P>125)throw RangeError("The data size must not be greater than 125 bytes");let M={[k1]:P,fin:!0,generateMask:this._generateMask,mask:H,maskBuffer:this._maskBuffer,opcode:9,readOnly:D,rsv1:!1};if(C8(G))if(this._state!==c1)this.enqueue([this.getBlobData,G,!1,M,R]);else this.getBlobData(G,!1,M,R);else if(this._state!==c1)this.enqueue([this.dispatch,G,!1,M,R]);else this.sendFrame(L4.frame(G,M),R)}pong(G,H,R){let P,D;if(typeof G==="string")P=Buffer.byteLength(G),D=!1;else if(C8(G))P=G.size,D=!1;else G=n4(G),P=G.length,D=n4.readOnly;if(P>125)throw RangeError("The data size must not be greater than 125 bytes");let M={[k1]:P,fin:!0,generateMask:this._generateMask,mask:H,maskBuffer:this._maskBuffer,opcode:10,readOnly:D,rsv1:!1};if(C8(G))if(this._state!==c1)this.enqueue([this.getBlobData,G,!1,M,R]);else this.getBlobData(G,!1,M,R);else if(this._state!==c1)this.enqueue([this.dispatch,G,!1,M,R]);else this.sendFrame(L4.frame(G,M),R)}send(G,H,R){let P=this._extensions[M6.extensionName],D=H.binary?2:1,M=H.compress,p,f;if(typeof G==="string")p=Buffer.byteLength(G),f=!1;else if(C8(G))p=G.size,f=!1;else G=n4(G),p=G.length,f=n4.readOnly;if(this._firstFragment){if(this._firstFragment=!1,M&&P&&P.params[P._isServer?"server_no_context_takeover":"client_no_context_takeover"])M=p>=P._threshold;this._compress=M}else M=!1,D=0;if(H.fin)this._firstFragment=!0;let u={[k1]:p,fin:H.fin,generateMask:this._generateMask,mask:H.mask,maskBuffer:this._maskBuffer,opcode:D,readOnly:f,rsv1:M};if(C8(G))if(this._state!==c1)this.enqueue([this.getBlobData,G,this._compress,u,R]);else this.getBlobData(G,this._compress,u,R);else if(this._state!==c1)this.enqueue([this.dispatch,G,this._compress,u,R]);else this.dispatch(G,this._compress,u,R)}getBlobData(G,H,R,P){this._bufferedBytes+=R[k1],this._state=tI,G.arrayBuffer().then((D)=>{if(this._socket.destroyed){let p=Error("The socket was closed while the blob was being read");process.nextTick(pJ,this,p,P);return}this._bufferedBytes-=R[k1];let M=n4(D);if(!H)this._state=c1,this.sendFrame(L4.frame(M,R),P),this.dequeue();else this.dispatch(M,H,R,P)}).catch((D)=>{process.nextTick(eI,this,D,P)})}dispatch(G,H,R,P){if(!H){this.sendFrame(L4.frame(G,R),P);return}let D=this._extensions[M6.extensionName];this._bufferedBytes+=R[k1],this._state=oI,D.compress(G,R.fin,(M,p)=>{if(this._socket.destroyed){let f=Error("The socket was closed while data was being compressed");pJ(this,f,P);return}this._bufferedBytes-=R[k1],this._state=c1,R.readOnly=!1,this.sendFrame(L4.frame(p,R),P),this.dequeue()})}dequeue(){while(this._state===c1&&this._queue.length){let G=this._queue.shift();this._bufferedBytes-=G[3][k1],Reflect.apply(G[0],this,G.slice(1))}}enqueue(G){this._bufferedBytes+=G[3][k1],this._queue.push(G)}sendFrame(G,H){if(G.length===2)this._socket.cork(),this._socket.write(G[0]),this._socket.write(G[1],H),this._socket.uncork();else this._socket.write(G[0],H)}}T6.exports=L4;function pJ(G,H,R){if(typeof R==="function")R(H);for(let P=0;P<G._queue.length;P++){let D=G._queue[P],M=D[D.length-1];if(typeof M==="function")M(H)}}function eI(G,H,R){pJ(G,H,R),G.onerror(H)}});var y6=E1(($V,E6)=>{var{kForOnEventAttribute:R3,kListener:bJ}=Y4(),x6=Symbol("kCode"),B6=Symbol("kData"),C6=Symbol("kError"),q6=Symbol("kMessage"),U6=Symbol("kReason"),U8=Symbol("kTarget"),L6=Symbol("kType"),W6=Symbol("kWasClean");class W4{constructor(G){this[U8]=null,this[L6]=G}get target(){return this[U8]}get type(){return this[L6]}}Object.defineProperty(W4.prototype,"target",{enumerable:!0});Object.defineProperty(W4.prototype,"type",{enumerable:!0});class L8 extends W4{constructor(G,H={}){super(G);this[x6]=H.code===void 0?0:H.code,this[U6]=H.reason===void 0?"":H.reason,this[W6]=H.wasClean===void 0?!1:H.wasClean}get code(){return this[x6]}get reason(){return this[U6]}get wasClean(){return this[W6]}}Object.defineProperty(L8.prototype,"code",{enumerable:!0});Object.defineProperty(L8.prototype,"reason",{enumerable:!0});Object.defineProperty(L8.prototype,"wasClean",{enumerable:!0});class A3 extends W4{constructor(G,H={}){super(G);this[C6]=H.error===void 0?null:H.error,this[q6]=H.message===void 0?"":H.message}get error(){return this[C6]}get message(){return this[q6]}}Object.defineProperty(A3.prototype,"error",{enumerable:!0});Object.defineProperty(A3.prototype,"message",{enumerable:!0});class Y7 extends W4{constructor(G,H={}){super(G);this[B6]=H.data===void 0?null:H.data}get data(){return this[B6]}}Object.defineProperty(Y7.prototype,"data",{enumerable:!0});var Jz={addEventListener(G,H,R={}){for(let D of this.listeners(G))if(!R[R3]&&D[bJ]===H&&!D[R3])return;let P;if(G==="message")P=function(M,p){let f=new Y7("message",{data:p?M:M.toString()});f[U8]=this,j7(H,this,f)};else if(G==="close")P=function(M,p){let f=new L8("close",{code:M,reason:p.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[U8]=this,j7(H,this,f)};else if(G==="error")P=function(M){let p=new A3("error",{error:M,message:M.message});p[U8]=this,j7(H,this,p)};else if(G==="open")P=function(){let M=new W4("open");M[U8]=this,j7(H,this,M)};else return;if(P[R3]=!!R[R3],P[bJ]=H,R.once)this.once(G,P);else this.on(G,P)},removeEventListener(G,H){for(let R of this.listeners(G))if(R[bJ]===H&&!R[R3]){this.removeListener(G,R);break}}};E6.exports={CloseEvent:L8,ErrorEvent:A3,Event:W4,EventTarget:Jz,MessageEvent:Y7};function j7(G,H,R){if(typeof G==="object"&&G.handleEvent)G.handleEvent.call(G,R);else G.call(H,R)}});var iJ=E1((QV,S6)=>{var{tokenChars:F3}=B8();function X4(G,H,R){if(G[H]===void 0)G[H]=[R];else G[H].push(R)}function Kz(G){let H=Object.create(null),R=Object.create(null),P=!1,D=!1,M=!1,p,f,u=-1,V0=-1,R0=-1,Z0=0;for(;Z0<G.length;Z0++)if(V0=G.charCodeAt(Z0),p===void 0)if(R0===-1&&F3[V0]===1){if(u===-1)u=Z0}else if(Z0!==0&&(V0===32||V0===9)){if(R0===-1&&u!==-1)R0=Z0}else if(V0===59||V0===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(R0===-1)R0=Z0;let h=G.slice(u,R0);if(V0===44)X4(H,h,R),R=Object.create(null);else p=h;u=R0=-1}else throw SyntaxError(`Unexpected character at index ${Z0}`);else if(f===void 0)if(R0===-1&&F3[V0]===1){if(u===-1)u=Z0}else if(V0===32||V0===9){if(R0===-1&&u!==-1)R0=Z0}else if(V0===59||V0===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(R0===-1)R0=Z0;if(X4(R,G.slice(u,R0),!0),V0===44)X4(H,p,R),R=Object.create(null),p=void 0;u=R0=-1}else if(V0===61&&u!==-1&&R0===-1)f=G.slice(u,Z0),u=R0=-1;else throw SyntaxError(`Unexpected character at index ${Z0}`);else if(D){if(F3[V0]!==1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(u===-1)u=Z0;else if(!P)P=!0;D=!1}else if(M)if(F3[V0]===1){if(u===-1)u=Z0}else if(V0===34&&u!==-1)M=!1,R0=Z0;else if(V0===92)D=!0;else throw SyntaxError(`Unexpected character at index ${Z0}`);else if(V0===34&&G.charCodeAt(Z0-1)===61)M=!0;else if(R0===-1&&F3[V0]===1){if(u===-1)u=Z0}else if(u!==-1&&(V0===32||V0===9)){if(R0===-1)R0=Z0}else if(V0===59||V0===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(R0===-1)R0=Z0;let h=G.slice(u,R0);if(P)h=h.replace(/\\/g,""),P=!1;if(X4(R,f,h),V0===44)X4(H,p,R),R=Object.create(null),p=void 0;f=void 0,u=R0=-1}else throw SyntaxError(`Unexpected character at index ${Z0}`);if(u===-1||M||V0===32||V0===9)throw SyntaxError("Unexpected end of input");if(R0===-1)R0=Z0;let U=G.slice(u,R0);if(p===void 0)X4(H,U,R);else{if(f===void 0)X4(R,U,!0);else if(P)X4(R,f,U.replace(/\\/g,""));else X4(R,f,U);X4(H,p,R)}return H}function Xz(G){return Object.keys(G).map((H)=>{let R=G[H];if(!Array.isArray(R))R=[R];return R.map((P)=>{return[H].concat(Object.keys(P).map((D)=>{let M=P[D];if(!Array.isArray(M))M=[M];return M.map((p)=>p===!0?D:`${D}=${p}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}S6.exports={format:Xz,parse:Kz}});var N7=E1((zV,i6)=>{var Zz=o5("events"),$z=o5("https"),Qz=o5("http"),g6=o5("net"),Gz=o5("tls"),{randomBytes:Iz,createHash:zz}=o5("crypto"),{Duplex:GV,Readable:IV}=o5("stream"),{URL:dJ}=o5("url"),E4=N3(),jz=lJ(),Yz=kJ(),{isBlob:Vz}=B8(),{BINARY_TYPES:v6,CLOSE_TIMEOUT:_z,EMPTY_BUFFER:V7,GUID:Hz,kForOnEventAttribute:cJ,kListener:Nz,kStatusCode:Rz,kWebSocket:Y1,NOOP:h6}=Y4(),{EventTarget:{addEventListener:Az,removeEventListener:Fz}}=y6(),{format:Dz,parse:Oz}=iJ(),{toBuffer:Mz}=_3(),m6=Symbol("kAborted"),nJ=[8,13],_4=["CONNECTING","OPEN","CLOSING","CLOSED"],Pz=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class a0 extends Zz{constructor(G,H,R){super();if(this._binaryType=v6[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=V7,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=a0.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,G!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,H===void 0)H=[];else if(!Array.isArray(H))if(typeof H==="object"&&H!==null)R=H,H=[];else H=[H];f6(this,G,H,R)}else this._autoPong=R.autoPong,this._closeTimeout=R.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(G){if(!v6.includes(G))return;if(this._binaryType=G,this._receiver)this._receiver._binaryType=G}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}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(G,H,R){let P=new jz({allowSynchronousEvents:R.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:R.maxPayload,skipUTF8Validation:R.skipUTF8Validation}),D=new Yz(G,this._extensions,R.generateMask);if(this._receiver=P,this._sender=D,this._socket=G,P[Y1]=this,D[Y1]=this,G[Y1]=this,P.on("conclude",Bz),P.on("drain",Cz),P.on("error",qz),P.on("message",Uz),P.on("ping",Lz),P.on("pong",Wz),D.onerror=Ez,G.setTimeout)G.setTimeout(0);if(G.setNoDelay)G.setNoDelay();if(H.length>0)G.unshift(H);G.on("close",p6),G.on("data",H7),G.on("end",k6),G.on("error",b6),this._readyState=a0.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=a0.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[E4.extensionName])this._extensions[E4.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=a0.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(G,H){if(this.readyState===a0.CLOSED)return;if(this.readyState===a0.CONNECTING){v1(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===a0.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=a0.CLOSING,this._sender.close(G,H,!this._isServer,(R)=>{if(R)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),l6(this)}pause(){if(this.readyState===a0.CONNECTING||this.readyState===a0.CLOSED)return;this._paused=!0,this._socket.pause()}ping(G,H,R){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof G==="function")R=G,G=H=void 0;else if(typeof H==="function")R=H,H=void 0;if(typeof G==="number")G=G.toString();if(this.readyState!==a0.OPEN){rJ(this,G,R);return}if(H===void 0)H=!this._isServer;this._sender.ping(G||V7,H,R)}pong(G,H,R){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof G==="function")R=G,G=H=void 0;else if(typeof H==="function")R=H,H=void 0;if(typeof G==="number")G=G.toString();if(this.readyState!==a0.OPEN){rJ(this,G,R);return}if(H===void 0)H=!this._isServer;this._sender.pong(G||V7,H,R)}resume(){if(this.readyState===a0.CONNECTING||this.readyState===a0.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send(G,H,R){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof H==="function")R=H,H={};if(typeof G==="number")G=G.toString();if(this.readyState!==a0.OPEN){rJ(this,G,R);return}let P={binary:typeof G!=="string",mask:!this._isServer,compress:!0,fin:!0,...H};if(!this._extensions[E4.extensionName])P.compress=!1;this._sender.send(G||V7,P,R)}terminate(){if(this.readyState===a0.CLOSED)return;if(this.readyState===a0.CONNECTING){v1(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=a0.CLOSING,this._socket.destroy()}}Object.defineProperty(a0,"CONNECTING",{enumerable:!0,value:_4.indexOf("CONNECTING")});Object.defineProperty(a0.prototype,"CONNECTING",{enumerable:!0,value:_4.indexOf("CONNECTING")});Object.defineProperty(a0,"OPEN",{enumerable:!0,value:_4.indexOf("OPEN")});Object.defineProperty(a0.prototype,"OPEN",{enumerable:!0,value:_4.indexOf("OPEN")});Object.defineProperty(a0,"CLOSING",{enumerable:!0,value:_4.indexOf("CLOSING")});Object.defineProperty(a0.prototype,"CLOSING",{enumerable:!0,value:_4.indexOf("CLOSING")});Object.defineProperty(a0,"CLOSED",{enumerable:!0,value:_4.indexOf("CLOSED")});Object.defineProperty(a0.prototype,"CLOSED",{enumerable:!0,value:_4.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((G)=>{Object.defineProperty(a0.prototype,G,{enumerable:!0})});["open","error","close","message"].forEach((G)=>{Object.defineProperty(a0.prototype,`on${G}`,{enumerable:!0,get(){for(let H of this.listeners(G))if(H[cJ])return H[Nz];return null},set(H){for(let R of this.listeners(G))if(R[cJ]){this.removeListener(G,R);break}if(typeof H!=="function")return;this.addEventListener(G,H,{[cJ]:!0})}})});a0.prototype.addEventListener=Az;a0.prototype.removeEventListener=Fz;i6.exports=a0;function f6(G,H,R,P){let D={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:_z,protocolVersion:nJ[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...P,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(G._autoPong=D.autoPong,G._closeTimeout=D.closeTimeout,!nJ.includes(D.protocolVersion))throw RangeError(`Unsupported protocol version: ${D.protocolVersion} (supported versions: ${nJ.join(", ")})`);let M;if(H instanceof dJ)M=H;else try{M=new dJ(H)}catch(y){throw SyntaxError(`Invalid URL: ${H}`)}if(M.protocol==="http:")M.protocol="ws:";else if(M.protocol==="https:")M.protocol="wss:";G._url=M.href;let p=M.protocol==="wss:",f=M.protocol==="ws+unix:",u;if(M.protocol!=="ws:"&&!p&&!f)u=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(f&&!M.pathname)u="The URL's pathname is empty";else if(M.hash)u="The URL contains a fragment identifier";if(u){let y=SyntaxError(u);if(G._redirects===0)throw y;else{_7(G,y);return}}let V0=p?443:80,R0=Iz(16).toString("base64"),Z0=p?$z.request:Qz.request,U=new Set,h;if(D.createConnection=D.createConnection||(p?xz:Tz),D.defaultPort=D.defaultPort||V0,D.port=M.port||V0,D.host=M.hostname.startsWith("[")?M.hostname.slice(1,-1):M.hostname,D.headers={...D.headers,"Sec-WebSocket-Version":D.protocolVersion,"Sec-WebSocket-Key":R0,Connection:"Upgrade",Upgrade:"websocket"},D.path=M.pathname+M.search,D.timeout=D.handshakeTimeout,D.perMessageDeflate)h=new E4(D.perMessageDeflate!==!0?D.perMessageDeflate:{},!1,D.maxPayload),D.headers["Sec-WebSocket-Extensions"]=Dz({[E4.extensionName]:h.offer()});if(R.length){for(let y of R){if(typeof y!=="string"||!Pz.test(y)||U.has(y))throw SyntaxError("An invalid or duplicated subprotocol was specified");U.add(y)}D.headers["Sec-WebSocket-Protocol"]=R.join(",")}if(D.origin)if(D.protocolVersion<13)D.headers["Sec-WebSocket-Origin"]=D.origin;else D.headers.Origin=D.origin;if(M.username||M.password)D.auth=`${M.username}:${M.password}`;if(f){let y=D.path.split(":");D.socketPath=y[0],D.path=y[1]}let g;if(D.followRedirects){if(G._redirects===0){G._originalIpc=f,G._originalSecure=p,G._originalHostOrSocketPath=f?D.socketPath:M.host;let y=P&&P.headers;if(P={...P,headers:{}},y)for(let[r,F0]of Object.entries(y))P.headers[r.toLowerCase()]=F0}else if(G.listenerCount("redirect")===0){let y=f?G._originalIpc?D.socketPath===G._originalHostOrSocketPath:!1:G._originalIpc?!1:M.host===G._originalHostOrSocketPath;if(!y||G._originalSecure&&!p){if(delete D.headers.authorization,delete D.headers.cookie,!y)delete D.headers.host;D.auth=void 0}}if(D.auth&&!P.headers.authorization)P.headers.authorization="Basic "+Buffer.from(D.auth).toString("base64");if(g=G._req=Z0(D),G._redirects)G.emit("redirect",G.url,g)}else g=G._req=Z0(D);if(D.timeout)g.on("timeout",()=>{v1(G,g,"Opening handshake has timed out")});if(g.on("error",(y)=>{if(g===null||g[m6])return;g=G._req=null,_7(G,y)}),g.on("response",(y)=>{let r=y.headers.location,F0=y.statusCode;if(r&&D.followRedirects&&F0>=300&&F0<400){if(++G._redirects>D.maxRedirects){v1(G,g,"Maximum redirects exceeded");return}g.abort();let v0;try{v0=new dJ(r,H)}catch($0){let A0=SyntaxError(`Invalid URL: ${r}`);_7(G,A0);return}f6(G,v0,R,P)}else if(!G.emit("unexpected-response",g,y))v1(G,g,`Unexpected server response: ${y.statusCode}`)}),g.on("upgrade",(y,r,F0)=>{if(G.emit("upgrade",y),G.readyState!==a0.CONNECTING)return;g=G._req=null;let v0=y.headers.upgrade;if(v0===void 0||v0.toLowerCase()!=="websocket"){v1(G,r,"Invalid Upgrade header");return}let $0=zz("sha1").update(R0+Hz).digest("base64");if(y.headers["sec-websocket-accept"]!==$0){v1(G,r,"Invalid Sec-WebSocket-Accept header");return}let A0=y.headers["sec-websocket-protocol"],Q0;if(A0!==void 0){if(!U.size)Q0="Server sent a subprotocol but none was requested";else if(!U.has(A0))Q0="Server sent an invalid subprotocol"}else if(U.size)Q0="Server sent no subprotocol";if(Q0){v1(G,r,Q0);return}if(A0)G._protocol=A0;let H0=y.headers["sec-websocket-extensions"];if(H0!==void 0){if(!h){v1(G,r,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let I0;try{I0=Oz(H0)}catch(F5){v1(G,r,"Invalid Sec-WebSocket-Extensions header");return}let L0=Object.keys(I0);if(L0.length!==1||L0[0]!==E4.extensionName){v1(G,r,"Server indicated an extension that was not requested");return}try{h.accept(I0[E4.extensionName])}catch(F5){v1(G,r,"Invalid Sec-WebSocket-Extensions header");return}G._extensions[E4.extensionName]=h}G.setSocket(r,F0,{allowSynchronousEvents:D.allowSynchronousEvents,generateMask:D.generateMask,maxPayload:D.maxPayload,skipUTF8Validation:D.skipUTF8Validation})}),D.finishRequest)D.finishRequest(g,G);else g.end()}function _7(G,H){G._readyState=a0.CLOSING,G._errorEmitted=!0,G.emit("error",H),G.emitClose()}function Tz(G){return G.path=G.socketPath,g6.connect(G)}function xz(G){if(G.path=void 0,!G.servername&&G.servername!=="")G.servername=g6.isIP(G.host)?"":G.host;return Gz.connect(G)}function v1(G,H,R){G._readyState=a0.CLOSING;let P=Error(R);if(Error.captureStackTrace(P,v1),H.setHeader){if(H[m6]=!0,H.abort(),H.socket&&!H.socket.destroyed)H.socket.destroy();process.nextTick(_7,G,P)}else H.destroy(P),H.once("error",G.emit.bind(G,"error")),H.once("close",G.emitClose.bind(G))}function rJ(G,H,R){if(H){let P=Vz(H)?H.size:Mz(H).length;if(G._socket)G._sender._bufferedBytes+=P;else G._bufferedAmount+=P}if(R){let P=Error(`WebSocket is not open: readyState ${G.readyState} (${_4[G.readyState]})`);process.nextTick(R,P)}}function Bz(G,H){let R=this[Y1];if(R._closeFrameReceived=!0,R._closeMessage=H,R._closeCode=G,R._socket[Y1]===void 0)return;if(R._socket.removeListener("data",H7),process.nextTick(u6,R._socket),G===1005)R.close();else R.close(G,H)}function Cz(){let G=this[Y1];if(!G.isPaused)G._socket.resume()}function qz(G){let H=this[Y1];if(H._socket[Y1]!==void 0)H._socket.removeListener("data",H7),process.nextTick(u6,H._socket),H.close(G[Rz]);if(!H._errorEmitted)H._errorEmitted=!0,H.emit("error",G)}function w6(){this[Y1].emitClose()}function Uz(G,H){this[Y1].emit("message",G,H)}function Lz(G){let H=this[Y1];if(H._autoPong)H.pong(G,!this._isServer,h6);H.emit("ping",G)}function Wz(G){this[Y1].emit("pong",G)}function u6(G){G.resume()}function Ez(G){let H=this[Y1];if(H.readyState===a0.CLOSED)return;if(H.readyState===a0.OPEN)H._readyState=a0.CLOSING,l6(H);if(this._socket.end(),!H._errorEmitted)H._errorEmitted=!0,H.emit("error",G)}function l6(G){G._closeTimer=setTimeout(G._socket.destroy.bind(G._socket),G._closeTimeout)}function p6(){let G=this[Y1];if(this.removeListener("close",p6),this.removeListener("data",H7),this.removeListener("end",k6),G._readyState=a0.CLOSING,!this._readableState.endEmitted&&!G._closeFrameReceived&&!G._receiver._writableState.errorEmitted&&this._readableState.length!==0){let H=this.read(this._readableState.length);G._receiver.write(H)}if(G._receiver.end(),this[Y1]=void 0,clearTimeout(G._closeTimer),G._receiver._writableState.finished||G._receiver._writableState.errorEmitted)G.emitClose();else G._receiver.on("error",w6),G._receiver.on("finish",w6)}function H7(G){if(!this[Y1]._receiver.write(G))this.pause()}function k6(){let G=this[Y1];G._readyState=a0.CLOSING,G._receiver.end(),this.end()}function b6(){let G=this[Y1];if(this.removeListener("error",b6),this.on("error",h6),G)G._readyState=a0.CLOSING,this.destroy()}});var r6=E1((YV,n6)=>{var jV=N7(),{Duplex:yz}=o5("stream");function d6(G){G.emit("close")}function Sz(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function c6(G){if(this.removeListener("error",c6),this.destroy(),this.listenerCount("error")===0)this.emit("error",G)}function vz(G,H){let R=!0,P=new yz({...H,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return G.on("message",function(M,p){let f=!p&&P._readableState.objectMode?M.toString():M;if(!P.push(f))G.pause()}),G.once("error",function(M){if(P.destroyed)return;R=!1,P.destroy(M)}),G.once("close",function(){if(P.destroyed)return;P.push(null)}),P._destroy=function(D,M){if(G.readyState===G.CLOSED){M(D),process.nextTick(d6,P);return}let p=!1;if(G.once("error",function(u){p=!0,M(u)}),G.once("close",function(){if(!p)M(D);process.nextTick(d6,P)}),R)G.terminate()},P._final=function(D){if(G.readyState===G.CONNECTING){G.once("open",function(){P._final(D)});return}if(G._socket===null)return;if(G._socket._writableState.finished){if(D(),P._readableState.endEmitted)P.destroy()}else G._socket.once("finish",function(){D()}),G.close()},P._read=function(){if(G.isPaused)G.resume()},P._write=function(D,M,p){if(G.readyState===G.CONNECTING){G.once("open",function(){P._write(D,M,p)});return}G.send(D,p)},P.on("end",Sz),P.on("error",c6),P}n6.exports=vz});var s6=E1((VV,a6)=>{var{tokenChars:wz}=B8();function gz(G){let H=new Set,R=-1,P=-1,D=0;for(D;D<G.length;D++){let p=G.charCodeAt(D);if(P===-1&&wz[p]===1){if(R===-1)R=D}else if(D!==0&&(p===32||p===9)){if(P===-1&&R!==-1)P=D}else if(p===44){if(R===-1)throw SyntaxError(`Unexpected character at index ${D}`);if(P===-1)P=D;let f=G.slice(R,P);if(H.has(f))throw SyntaxError(`The "${f}" subprotocol is duplicated`);H.add(f),R=P=-1}else throw SyntaxError(`Unexpected character at index ${D}`)}if(R===-1||P!==-1)throw SyntaxError("Unexpected end of input");let M=G.slice(R,D);if(H.has(M))throw SyntaxError(`The "${M}" subprotocol is duplicated`);return H.add(M),H}a6.exports={parse:gz}});var K$=E1((HV,J$)=>{var hz=o5("events"),R7=o5("http"),{Duplex:_V}=o5("stream"),{createHash:mz}=o5("crypto"),o6=iJ(),a4=N3(),fz=s6(),uz=N7(),{CLOSE_TIMEOUT:lz,GUID:pz,kWebSocket:kz}=Y4(),bz=/^[+/0-9A-Za-z]{22}==$/;class e6 extends hz{constructor(G,H){super();if(G={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:lz,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:uz,...G},G.port==null&&!G.server&&!G.noServer||G.port!=null&&(G.server||G.noServer)||G.server&&G.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(G.port!=null)this._server=R7.createServer((R,P)=>{let D=R7.STATUS_CODES[426];P.writeHead(426,{"Content-Length":D.length,"Content-Type":"text/plain"}),P.end(D)}),this._server.listen(G.port,G.host,G.backlog,H);else if(G.server)this._server=G.server;if(this._server){let R=this.emit.bind(this,"connection");this._removeListeners=iz(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(P,D,M)=>{this.handleUpgrade(P,D,M,R)}})}if(G.perMessageDeflate===!0)G.perMessageDeflate={};if(G.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=G,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close(G){if(this._state===2){if(G)this.once("close",()=>{G(Error("The server is not running"))});process.nextTick(D3,this);return}if(G)this.once("close",G);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(D3,this);else this._shouldEmitClose=!0;else process.nextTick(D3,this)}else{let H=this._server;this._removeListeners(),this._removeListeners=this._server=null,H.close(()=>{D3(this)})}}shouldHandle(G){if(this.options.path){let H=G.url.indexOf("?");if((H!==-1?G.url.slice(0,H):G.url)!==this.options.path)return!1}return!0}handleUpgrade(G,H,R,P){H.on("error",t6);let D=G.headers["sec-websocket-key"],M=G.headers.upgrade,p=+G.headers["sec-websocket-version"];if(G.method!=="GET"){s4(this,G,H,405,"Invalid HTTP method");return}if(M===void 0||M.toLowerCase()!=="websocket"){s4(this,G,H,400,"Invalid Upgrade header");return}if(D===void 0||!bz.test(D)){s4(this,G,H,400,"Missing or invalid Sec-WebSocket-Key header");return}if(p!==13&&p!==8){s4(this,G,H,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(G)){O3(H,400);return}let f=G.headers["sec-websocket-protocol"],u=new Set;if(f!==void 0)try{u=fz.parse(f)}catch(Z0){s4(this,G,H,400,"Invalid Sec-WebSocket-Protocol header");return}let V0=G.headers["sec-websocket-extensions"],R0={};if(this.options.perMessageDeflate&&V0!==void 0){let Z0=new a4(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let U=o6.parse(V0);if(U[a4.extensionName])Z0.accept(U[a4.extensionName]),R0[a4.extensionName]=Z0}catch(U){s4(this,G,H,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let Z0={origin:G.headers[`${p===8?"sec-websocket-origin":"origin"}`],secure:!!(G.socket.authorized||G.socket.encrypted),req:G};if(this.options.verifyClient.length===2){this.options.verifyClient(Z0,(U,h,g,y)=>{if(!U)return O3(H,h||401,g,y);this.completeUpgrade(R0,D,u,G,H,R,P)});return}if(!this.options.verifyClient(Z0))return O3(H,401)}this.completeUpgrade(R0,D,u,G,H,R,P)}completeUpgrade(G,H,R,P,D,M,p){if(!D.readable||!D.writable)return D.destroy();if(D[kz])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return O3(D,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${mz("sha1").update(H+pz).digest("base64")}`],V0=new this.options.WebSocket(null,void 0,this.options);if(R.size){let R0=this.options.handleProtocols?this.options.handleProtocols(R,P):R.values().next().value;if(R0)u.push(`Sec-WebSocket-Protocol: ${R0}`),V0._protocol=R0}if(G[a4.extensionName]){let R0=G[a4.extensionName].params,Z0=o6.format({[a4.extensionName]:[R0]});u.push(`Sec-WebSocket-Extensions: ${Z0}`),V0._extensions=G}if(this.emit("headers",u,P),D.write(u.concat(`\r
2
2
  `).join(`\r
3
3
  `)),D.removeListener("error",t6),V0.setSocket(D,M,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(V0),V0.on("close",()=>{if(this.clients.delete(V0),this._shouldEmitClose&&!this.clients.size)process.nextTick(D3,this)});p(V0,P)}}J$.exports=e6;function iz(G,H){for(let R of Object.keys(H))G.on(R,H[R]);return function(){for(let P of Object.keys(H))G.removeListener(P,H[P])}}function D3(G){G._state=2,G.emit("close")}function t6(){this.destroy()}function O3(G,H,R,P){R=R||R7.STATUS_CODES[H],P={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(R),...P},G.once("finish",G.destroy),G.end(`HTTP/1.1 ${H} ${R7.STATUS_CODES[H]}\r
4
4
  `+Object.keys(P).map((D)=>`${D}: ${P[D]}`).join(`\r
@@ -1 +1 @@
1
- import"./chunk-y8qhrx11.js";var V=((f)=>{return f.NETWORK_ERROR="NETWORK_ERROR",f.CONNECTION_TIMEOUT="CONNECTION_TIMEOUT",f.INTERNAL_ERROR="INTERNAL_ERROR",f.THREAD_NOT_FOUND="THREAD_NOT_FOUND",f.THREAD_BUSY="THREAD_BUSY",f.RUN_NOT_FOUND="RUN_NOT_FOUND",f.GRAPH_NOT_FOUND="GRAPH_NOT_FOUND",f.INVALID_REQUEST="INVALID_REQUEST",f})(V||{});class N extends Error{constructor(f,w,x){super(w);this.code=f,this.statusCode=x,this.name="RemoteApiError"}}async function O(f,w,x){try{let z=f;if(x?.query){let W=new URLSearchParams;Object.entries(x.query).forEach(([Z,_])=>{W.append(Z,String(_))}),z+=`?${W.toString()}`}let Q=await fetch(z,{method:w,headers:{"Content-Type":"application/json"},body:x?.body?JSON.stringify(x.body):void 0}),H=await Q.json();if(!Q.ok||!H.success)throw new N(H.error?.code||V.INTERNAL_ERROR,H.error?.message||"Unknown error",Q.status);return H}catch(z){if(z instanceof N)throw z;throw new N(V.NETWORK_ERROR,`Network error: ${z instanceof Error?z.message:"Unknown error"}`)}}async function J(f,w){return O(f,"GET",{query:w})}async function F(f,w,x){return O(f,"POST",{body:w,query:x})}async function Y(f,w,x){return O(f,"PUT",{body:w,query:x})}async function $(f,w){return O(f,"DELETE",{query:w})}class j{constructor(f,w){this.serverUrl=f,this.httpClient=w,this.serverUrl=f.replace(/\/$/,""),this.httpClient=w||fetch}async setup(){await F(`${this.serverUrl}/setup`)}async create(f){return(await F(`${this.serverUrl}/threads`,f)).data}async search(f){let w={};if(f?.ids!==void 0&&f.ids.length>0)w.ids=JSON.stringify(f.ids);if(f?.metadata!==void 0)w.metadata=JSON.stringify(f.metadata);if(f?.limit!==void 0)w.limit=f.limit;if(f?.offset!==void 0)w.offset=f.offset;if(f?.status!==void 0)w.status=f.status;if(f?.sortBy!==void 0)w.sortBy=f.sortBy;if(f?.sortOrder!==void 0)w.sortOrder=f.sortOrder;if(f?.values!==void 0)w.values=JSON.stringify(f.values);if(f?.select!==void 0)w.select=JSON.stringify(f.select);if(f?.withoutDetails!==void 0)w.withoutDetails=f.withoutDetails;return(await J(`${this.serverUrl}/threads`,w)).data}async get(f){return(await J(`${this.serverUrl}/threads/${f}`)).data}async set(f,w){await Y(`${this.serverUrl}/threads/${f}`,w)}async delete(f){await $(`${this.serverUrl}/threads/${f}`)}async updateState(f,w){return(await F(`${this.serverUrl}/threads/${f}/state`,w)).data}async createRun(f,w,x){return(await F(`${this.serverUrl}/threads/${f}/runs`,x||{},{assistantId:w})).data}async listRuns(f,w){let x={};if(w?.limit!==void 0)x.limit=w.limit;if(w?.offset!==void 0)x.offset=w.offset;if(w?.status!==void 0)x.status=w.status;return(await J(`${this.serverUrl}/threads/${f}/runs`,x)).data}async updateRun(f,w){await Y(`${this.serverUrl}/runs/${f}`,w)}async count(f){let w={};if(f?.ids!==void 0&&f.ids.length>0)w.ids=JSON.stringify(f.ids);if(f?.metadata!==void 0)w.metadata=JSON.stringify(f.metadata);if(f?.status!==void 0)w.status=f.status;if(f?.values!==void 0)w.values=JSON.stringify(f.values);return(await J(`${this.serverUrl}/threads/count`,w)).data}async patch(f,w){return(await F(`${this.serverUrl}/threads/${f}`,w)).data}async getState(f,w){let x={};if(w?.subgraphs!==void 0)x.subgraphs=w.subgraphs;if(w?.checkpointId!==void 0)x.checkpointId=w.checkpointId;return(await F(`${this.serverUrl}/threads/${f}/state`,x)).data}async getStateHistory(f,w){let x={};if(w?.limit!==void 0)x.limit=w.limit;if(w?.before!==void 0)x.before=w.before;return(await F(`${this.serverUrl}/threads/${f}/history`,x)).data}async copy(f){return(await F(`${this.serverUrl}/threads/${f}/copy`)).data}async setTitleIfNull(f,w){try{return(await F(`${this.serverUrl}/threads/${f}/title`,{title:w})).data.success}catch(x){let z=await this.get(f);if(z?.title===null||z?.title===void 0)return await this.set(f,{title:w}),!0;return!1}}}export{j as RemoteKyselyThreadsManager};
1
+ import"./chunk-4fs853nh.js";var V=((f)=>{return f.NETWORK_ERROR="NETWORK_ERROR",f.CONNECTION_TIMEOUT="CONNECTION_TIMEOUT",f.INTERNAL_ERROR="INTERNAL_ERROR",f.THREAD_NOT_FOUND="THREAD_NOT_FOUND",f.THREAD_BUSY="THREAD_BUSY",f.RUN_NOT_FOUND="RUN_NOT_FOUND",f.GRAPH_NOT_FOUND="GRAPH_NOT_FOUND",f.INVALID_REQUEST="INVALID_REQUEST",f})(V||{});class N extends Error{constructor(f,w,x){super(w);this.code=f,this.statusCode=x,this.name="RemoteApiError"}}async function O(f,w,x){try{let z=f;if(x?.query){let W=new URLSearchParams;Object.entries(x.query).forEach(([Z,_])=>{W.append(Z,String(_))}),z+=`?${W.toString()}`}let Q=await fetch(z,{method:w,headers:{"Content-Type":"application/json"},body:x?.body?JSON.stringify(x.body):void 0}),H=await Q.json();if(!Q.ok||!H.success)throw new N(H.error?.code||V.INTERNAL_ERROR,H.error?.message||"Unknown error",Q.status);return H}catch(z){if(z instanceof N)throw z;throw new N(V.NETWORK_ERROR,`Network error: ${z instanceof Error?z.message:"Unknown error"}`)}}async function J(f,w){return O(f,"GET",{query:w})}async function F(f,w,x){return O(f,"POST",{body:w,query:x})}async function Y(f,w,x){return O(f,"PUT",{body:w,query:x})}async function $(f,w){return O(f,"DELETE",{query:w})}class j{constructor(f,w){this.serverUrl=f,this.httpClient=w,this.serverUrl=f.replace(/\/$/,""),this.httpClient=w||fetch}async setup(){await F(`${this.serverUrl}/setup`)}async create(f){return(await F(`${this.serverUrl}/threads`,f)).data}async search(f){let w={};if(f?.ids!==void 0&&f.ids.length>0)w.ids=JSON.stringify(f.ids);if(f?.metadata!==void 0)w.metadata=JSON.stringify(f.metadata);if(f?.limit!==void 0)w.limit=f.limit;if(f?.offset!==void 0)w.offset=f.offset;if(f?.status!==void 0)w.status=f.status;if(f?.sortBy!==void 0)w.sortBy=f.sortBy;if(f?.sortOrder!==void 0)w.sortOrder=f.sortOrder;if(f?.values!==void 0)w.values=JSON.stringify(f.values);if(f?.select!==void 0)w.select=JSON.stringify(f.select);if(f?.withoutDetails!==void 0)w.withoutDetails=f.withoutDetails;return(await J(`${this.serverUrl}/threads`,w)).data}async get(f){return(await J(`${this.serverUrl}/threads/${f}`)).data}async set(f,w){await Y(`${this.serverUrl}/threads/${f}`,w)}async delete(f){await $(`${this.serverUrl}/threads/${f}`)}async updateState(f,w){return(await F(`${this.serverUrl}/threads/${f}/state`,w)).data}async createRun(f,w,x){return(await F(`${this.serverUrl}/threads/${f}/runs`,x||{},{assistantId:w})).data}async listRuns(f,w){let x={};if(w?.limit!==void 0)x.limit=w.limit;if(w?.offset!==void 0)x.offset=w.offset;if(w?.status!==void 0)x.status=w.status;return(await J(`${this.serverUrl}/threads/${f}/runs`,x)).data}async updateRun(f,w){await Y(`${this.serverUrl}/runs/${f}`,w)}async count(f){let w={};if(f?.ids!==void 0&&f.ids.length>0)w.ids=JSON.stringify(f.ids);if(f?.metadata!==void 0)w.metadata=JSON.stringify(f.metadata);if(f?.status!==void 0)w.status=f.status;if(f?.values!==void 0)w.values=JSON.stringify(f.values);return(await J(`${this.serverUrl}/threads/count`,w)).data}async patch(f,w){return(await F(`${this.serverUrl}/threads/${f}`,w)).data}async getState(f,w){let x={};if(w?.subgraphs!==void 0)x.subgraphs=w.subgraphs;if(w?.checkpointId!==void 0)x.checkpointId=w.checkpointId;return(await F(`${this.serverUrl}/threads/${f}/state`,x)).data}async getStateHistory(f,w){let x={};if(w?.limit!==void 0)x.limit=w.limit;if(w?.before!==void 0)x.before=w.before;return(await F(`${this.serverUrl}/threads/${f}/history`,x)).data}async copy(f){return(await F(`${this.serverUrl}/threads/${f}/copy`)).data}async setTitleIfNull(f,w){try{return(await F(`${this.serverUrl}/threads/${f}/title`,{title:w})).data.success}catch(x){let z=await this.get(f);if(z?.title===null||z?.title===void 0)return await this.set(f,{title:w}),!0;return!1}}}export{j as RemoteKyselyThreadsManager};
@@ -0,0 +1,2 @@
1
+ var O=(h)=>typeof h==="object"&&h!==null,A=(h)=>{if(!O(h))return!1;if(h instanceof RegExp||h instanceof Error||h instanceof Date||h instanceof Map||h instanceof Set||h instanceof WeakMap||h instanceof WeakSet||h instanceof Promise||h instanceof ArrayBuffer||h instanceof DataView||ArrayBuffer.isView(h)||globalThis.Blob&&h instanceof globalThis.Blob)return!1;if(typeof h.$$typeof==="symbol"||typeof h.asymmetricMatch==="function")return!1;return!0},S=Symbol("mapObjectSkip"),P=(h,f)=>{if(f){let d=Object.keys(h),M=Object.getOwnPropertySymbols(h).filter((z)=>Object.getOwnPropertyDescriptor(h,z)?.enumerable);return[...d,...M]}return Object.keys(h)},N=(h,f,d,M=new WeakMap)=>{let{target:z={},...Y}={deep:!1,includeSymbols:!1,...d};if(M.has(h))return M.get(h);M.set(h,z);let $=(q)=>q.map((Q)=>A(Q)?N(Q,f,Y,M):Q);if(Array.isArray(h))return $(h);for(let q of P(h,Y.includeSymbols)){let Q=h[q],I=f(q,Q);if(I===S)continue;if(!Array.isArray(I))throw TypeError(`Mapper must return an array or mapObjectSkip, got ${I===null?"null":typeof I}`);if(I.length<2)throw TypeError(`Mapper must return an array with at least 2 elements [key, value], got ${I.length} elements`);let[J,X,{shouldRecurse:_=!0}={}]=I;if(J==="__proto__")continue;if(Y.deep&&_&&A(X))X=Array.isArray(X)?$(X):N(X,f,Y,M);try{z[J]=X}catch(G){if(G.name==="TypeError"&&G.message.includes("read only"))continue;throw G}}return z};function K(h,f,d){if(!O(h))throw TypeError(`Expected an object, got \`${h}\` (${typeof h})`);if(Array.isArray(h))throw TypeError("Expected an object, got an array");return N(h,(z,Y)=>f(z,Y,h),d)}var w=/[\p{Lu}]/u,U=/[\p{Ll}]/u,L=/^[\p{Lu}](?![\p{Lu}])/u,V=/[_.\- ]+/,R=/([\p{Alpha}\p{N}_]|$)/u,k=new RegExp("^"+V.source),j=new RegExp(V.source+R.source,"gu"),y=new RegExp(String.raw`\d+`+R.source,"gu"),b=(h,f,d,M)=>{let z=!1,Y=!1,$=!1,q=!1;for(let Q=0;Q<h.length;Q++){let I=h[Q];if(q=Q>2?h[Q-3]==="-":!0,z&&w.test(I))h=h.slice(0,Q)+"-"+h.slice(Q),z=!1,$=Y,Y=!0,Q++;else if(Y&&$&&U.test(I)&&(!q||M))h=h.slice(0,Q-1)+"-"+h.slice(Q-1),$=Y,Y=!1,z=!0;else z=f(I)===I&&d(I)!==I,$=Y,Y=d(I)===I&&f(I)!==I}return h},m=(h,f)=>h.replace(L,(d)=>f(d)),C=(h,f,d)=>{let M="",z=!1,Y=!1,$=[...h];for(let q=0;q<$.length;q++){let Q=$[q],I=w.test(Q),J=q+1<$.length&&w.test($[q+1]);if(z&&/[\p{Alpha}]/u.test(Q))M+=Q,z=!1,Y=I;else if(d&&I&&(Y||J))M+=Q,Y=!0;else if(/\d/.test(Q))M+=Q,z=!0,Y=!1;else if(V.test(Q))M+=Q,Y=!1;else M+=f(Q),z=!1,Y=!1}return M},l=(h,f,{capitalizeAfterNumber:d})=>{let M=d?(z,Y,$,q)=>{let Q=q.charAt($+z.length);if(V.test(Q))return z;return Y?z.slice(0,-Y.length)+f(Y):z}:(z)=>z;return h.replaceAll(y,M).replaceAll(j,(z,Y)=>f(Y))};function W(h,f){if(!(typeof h==="string"||Array.isArray(h)))throw TypeError("Expected the input to be `string | string[]`");if(f={pascalCase:!1,preserveConsecutiveUppercase:!1,capitalizeAfterNumber:!0,...f},Array.isArray(h))h=h.map(($)=>$.trim()).filter(($)=>$.length>0).join("-");else h=h.trim();if(h.length===0)return"";let d=h.match(/^[_$]*/)[0];if(h=h.slice(d.length),h.length===0)return d;let M=f.locale===!1?($)=>$.toLowerCase():($)=>$.toLocaleLowerCase(f.locale),z=f.locale===!1?($)=>$.toUpperCase():($)=>$.toLocaleUpperCase(f.locale);if(h.length===1){if(V.test(h))return d;return d+(f.pascalCase?z(h):M(h))}if(h!==M(h))h=b(h,M,z,f.preserveConsecutiveUppercase);if(h=h.replace(k,""),f.capitalizeAfterNumber)h=f.preserveConsecutiveUppercase?m(h,M):M(h);else h=C(h,M,f.preserveConsecutiveUppercase);if(f.pascalCase&&h.length>0)h=z(h[0])+h.slice(1);return d+l(h,z,f)}class D extends Map{#d=0;#h=new Map;#f=new Map;#z;#Q;#Y;constructor(h={}){super();if(!(h.maxSize&&h.maxSize>0))throw TypeError("`maxSize` must be a number greater than 0");if(typeof h.maxAge==="number"&&h.maxAge===0)throw TypeError("`maxAge` must be a number greater than 0");this.#z=h.maxSize,this.#Q=h.maxAge||Number.POSITIVE_INFINITY,this.#Y=h.onEviction}get __oldCache(){return this.#f}#$(h){if(typeof this.#Y!=="function")return;for(let[f,d]of h)this.#Y(f,d.value)}#M(h,f){if(typeof f.expiry==="number"&&f.expiry<=Date.now()){if(typeof this.#Y==="function")this.#Y(h,f.value);return this.delete(h)}return!1}#J(h,f){if(this.#M(h,f)===!1)return f.value}#q(h,f){return f.expiry?this.#J(h,f):f.value}#x(h,f){let d=f.get(h);return this.#q(h,d)}#H(h,f){if(this.#h.set(h,f),this.#d++,this.#d>=this.#z)this.#d=0,this.#$(this.#f),this.#f=this.#h,this.#h=new Map}#X(h,f){this.#f.delete(h),this.#H(h,f)}*#I(){for(let h of this.#f){let[f,d]=h;if(!this.#h.has(f)){if(this.#M(f,d)===!1)yield h}}for(let h of this.#h){let[f,d]=h;if(this.#M(f,d)===!1)yield h}}get(h){if(this.#h.has(h)){let f=this.#h.get(h);return this.#q(h,f)}if(this.#f.has(h)){let f=this.#f.get(h);if(this.#M(h,f)===!1)return this.#X(h,f),f.value}}set(h,f,{maxAge:d=this.#Q}={}){let M=typeof d==="number"&&d!==Number.POSITIVE_INFINITY?Date.now()+d:void 0;if(this.#h.has(h))this.#h.set(h,{value:f,expiry:M});else this.#H(h,{value:f,expiry:M});return this}has(h){if(this.#h.has(h))return!this.#M(h,this.#h.get(h));if(this.#f.has(h))return!this.#M(h,this.#f.get(h));return!1}peek(h){if(this.#h.has(h))return this.#x(h,this.#h);if(this.#f.has(h))return this.#x(h,this.#f)}expiresIn(h){let f=this.#h.get(h)??this.#f.get(h);if(f)return f.expiry?f.expiry-Date.now():Number.POSITIVE_INFINITY}delete(h){let f=this.#h.delete(h);if(f)this.#d--;return this.#f.delete(h)||f}clear(){this.#h.clear(),this.#f.clear(),this.#d=0}resize(h){if(!(h&&h>0))throw TypeError("`maxSize` must be a number greater than 0");let f=[...this.#I()],d=f.length-h;if(d<0)this.#h=new Map(f),this.#f=new Map,this.#d=f.length;else{if(d>0)this.#$(f.slice(0,d));this.#f=new Map(f.slice(d)),this.#h=new Map,this.#d=0}this.#z=h}evict(h=1){let f=Number(h);if(!f||f<=0)return;let d=[...this.#I()],M=Math.trunc(Math.min(f,Math.max(d.length-1,0)));if(M<=0)return;this.#$(d.slice(0,M)),this.#f=new Map(d.slice(M)),this.#h=new Map,this.#d=0}*keys(){for(let[h]of this)yield h}*values(){for(let[,h]of this)yield h}*[Symbol.iterator](){for(let h of this.#h){let[f,d]=h;if(this.#M(f,d)===!1)yield[f,d.value]}for(let h of this.#f){let[f,d]=h;if(!this.#h.has(f)){if(this.#M(f,d)===!1)yield[f,d.value]}}}*entriesDescending(){let h=[...this.#h];for(let f=h.length-1;f>=0;--f){let d=h[f],[M,z]=d;if(this.#M(M,z)===!1)yield[M,z.value]}h=[...this.#f];for(let f=h.length-1;f>=0;--f){let d=h[f],[M,z]=d;if(!this.#h.has(M)){if(this.#M(M,z)===!1)yield[M,z.value]}}}*entriesAscending(){for(let[h,f]of this.#I())yield[h,f.value]}get size(){if(!this.#d)return this.#f.size;let h=0;for(let f of this.#f.keys())if(!this.#h.has(f))h++;return Math.min(this.#d+h,this.#z)}get maxSize(){return this.#z}get maxAge(){return this.#Q}entries(){return this.entriesAscending()}forEach(h,f=this){for(let[d,M]of this.entriesAscending())h.call(f,M,d,this)}get[Symbol.toStringTag](){return"QuickLRU"}toString(){return`QuickLRU(${this.size}/${this.maxSize})`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}var v=(h,f)=>h.some((d)=>{if(typeof d==="string")return d===f;return d.lastIndex=0,d.test(f)}),c=(h)=>h.trim()!==""&&!Number.isNaN(Number(h)),E=new D({maxSize:1e5}),s=(h)=>ArrayBuffer.isView(h)||h instanceof Date||h instanceof RegExp||h instanceof Error||h instanceof Map||h instanceof Set||h instanceof WeakMap||h instanceof WeakSet||h instanceof Promise,T=(h)=>typeof h==="object"&&h!==null&&!s(h),B=(h,f={},d=new WeakMap,M)=>{if(!T(h))return h;if(d.has(h))return d.get(h);let{exclude:z,pascalCase:Y=!1,stopPaths:$,deep:q=!1,preserveConsecutiveUppercase:Q=!1}=f,I=new Set($);if(Array.isArray(h)){let H=[];d.set(h,H);for(let x of h)H.push(T(x)?B(x,f,d,M):x);return H}let J={};d.set(h,J);let _=K(h,((H)=>(x,F)=>{if(q&&T(F)){let Z=H===void 0?x:`${H}.${x}`;if(!I.has(Z))F=Array.isArray(F)?F.map((g)=>T(g)?B(g,f,d,Z):g):B(F,f,d,Z)}if(typeof x==="string"&&!c(x)&&!(z&&v(z,x))){let Z=Y?`${x}_`:x;if(E.has(Z))x=E.get(Z);else if(x=W(x,{pascalCase:Y,locale:!1,preserveConsecutiveUppercase:Q}),x.length<100)E.set(Z,x)}return[x,F]})(M),{deep:!1});Object.assign(J,_);let G=Object.getOwnPropertySymbols(h);for(let H of G)J[H]=q&&T(h[H])?B(h[H],f,d,M):h[H];return J};function o(h,f){let d=new WeakMap;if(Array.isArray(h))return h.map((M)=>T(M)?B(M,f,d,void 0):M);return B(h,f,d)}
2
+ export{o as n};
@@ -1,6 +1,6 @@
1
- import{Ik as T}from"./chunk-e8kxa5vj.js";import{Dl as R}from"./chunk-y8qhrx11.js";var I=R(T(),1);import A from"fs/promises";import z from"path";import O from"os";class U{skillsDir;projectSkillsDir;constructor(){let b=O.homedir();this.skillsDir=z.join(b,".claude","skills"),this.projectSkillsDir=z.join(process.cwd(),".claude","skills")}async listSkills(){let b=new Map,g=await this.listSkillsInDir(this.skillsDir);for(let q of g)b.set(q.name,q);let x=await this.listSkillsInDir(this.projectSkillsDir);for(let q of x)b.set(q.name,q);return Array.from(b.values())}async listSkillsInDir(b){try{let g=await A.readdir(b,{withFileTypes:!0}),x=[];for(let q of g){let F=z.join(b,q.name),J=await A.lstat(F).catch(()=>null);if(!J)continue;let K=await A.stat(F).catch(()=>null);if(!K||!K.isDirectory())continue;if(J.isSymbolicLink()){let C=z.resolve(F),G=z.resolve(b),N=C.substring(G.length);if(!(C===G||N.startsWith("/")||N==="")){let Q=O.homedir();if(!C.startsWith(Q))continue}}let L=z.join(F,"SKILL.md");try{let C=await A.readFile(L,"utf-8"),G=this.parseFrontmatter(C);x.push({name:q.name,description:G.description||"",path:L})}catch{}}return x}catch{return[]}}async getSkill(b){let g=z.join(this.projectSkillsDir,b,"SKILL.md");try{let q=await A.readFile(g,"utf-8");return this.parseSkillContent(q)}catch{}let x=z.join(this.skillsDir,b,"SKILL.md");try{let q=await A.readFile(x,"utf-8");return this.parseSkillContent(q)}catch{return null}}async saveSkill(b,g){let x=z.join(this.skillsDir,b);await A.mkdir(x,{recursive:!0});let q=this.formatSkillContent(g);await A.writeFile(z.join(x,"SKILL.md"),q,"utf-8")}async deleteSkill(b){let g=z.join(this.skillsDir,b);await A.rm(g,{recursive:!0,force:!0})}async syncFromRemote(b){let g=await b.listRemoteSkills();for(let x of g){let q=await b.fetchSkill(x.name);if(q)await this.saveSkill(x.name,q)}}parseFrontmatter(b){let g=b.match(/^---\n(.+?)\n---/s);if(!g)return{};try{return I.default.parse(g[1])}catch{return{}}}parseSkillContent(b){let g=this.parseFrontmatter(b),x=b.replace(/^---\n.+?\n---\n*/s,"");return{frontmatter:g,markdown:x}}formatSkillContent(b){return`---
1
+ import{Dk as T}from"./chunk-mv5m8bf4.js";import{Wl as R}from"./chunk-4fs853nh.js";var I=R(T(),1);import A from"fs/promises";import z from"path";import O from"os";class U{skillsDir;projectSkillsDir;constructor(){let b=O.homedir();this.skillsDir=z.join(b,".claude","skills"),this.projectSkillsDir=z.join(process.cwd(),".claude","skills")}async listSkills(){let b=new Map,g=await this.listSkillsInDir(this.skillsDir);for(let q of g)b.set(q.name,q);let x=await this.listSkillsInDir(this.projectSkillsDir);for(let q of x)b.set(q.name,q);return Array.from(b.values())}async listSkillsInDir(b){try{let g=await A.readdir(b,{withFileTypes:!0}),x=[];for(let q of g){let F=z.join(b,q.name),J=await A.lstat(F).catch(()=>null);if(!J)continue;let K=await A.stat(F).catch(()=>null);if(!K||!K.isDirectory())continue;if(J.isSymbolicLink()){let C=z.resolve(F),G=z.resolve(b),N=C.substring(G.length);if(!(C===G||N.startsWith("/")||N==="")){let Q=O.homedir();if(!C.startsWith(Q))continue}}let L=z.join(F,"SKILL.md");try{let C=await A.readFile(L,"utf-8"),G=this.parseFrontmatter(C);x.push({name:q.name,description:G.description||"",path:L})}catch{}}return x}catch{return[]}}async getSkill(b){let g=z.join(this.projectSkillsDir,b,"SKILL.md");try{let q=await A.readFile(g,"utf-8");return this.parseSkillContent(q)}catch{}let x=z.join(this.skillsDir,b,"SKILL.md");try{let q=await A.readFile(x,"utf-8");return this.parseSkillContent(q)}catch{return null}}async saveSkill(b,g){let x=z.join(this.skillsDir,b);await A.mkdir(x,{recursive:!0});let q=this.formatSkillContent(g);await A.writeFile(z.join(x,"SKILL.md"),q,"utf-8")}async deleteSkill(b){let g=z.join(this.skillsDir,b);await A.rm(g,{recursive:!0,force:!0})}async syncFromRemote(b){let g=await b.listRemoteSkills();for(let x of g){let q=await b.fetchSkill(x.name);if(q)await this.saveSkill(x.name,q)}}parseFrontmatter(b){let g=b.match(/^---\n(.+?)\n---/s);if(!g)return{};try{return I.default.parse(g[1])}catch{return{}}}parseSkillContent(b){let g=this.parseFrontmatter(b),x=b.replace(/^---\n.+?\n---\n*/s,"");return{frontmatter:g,markdown:x}}formatSkillContent(b){return`---
2
2
  ${I.default.stringify(b.frontmatter).trim()}
3
3
  ---
4
4
 
5
5
  ${b.markdown}`}}
6
- export{U as gf};
6
+ export{U as yk};
@@ -0,0 +1 @@
1
+ import{E as w}from"./chunk-1d47g6nc.js";import{H as $}from"./chunk-5fe27s34.js";import"./chunk-5hqvapp1.js";import{$ as _,U as h,Y as G,fa as Y,ia as U,ka as Z}from"./chunk-h7ypcqp3.js";import{Wl as K}from"./chunk-4fs853nh.js";var z=K(h(),1);var y=K(Y(),1),b=({onClose:H})=>{let{config:v,updateConfig:L}=w(),N=$(),B=v?.active_agent||"default",O=z.useCallback(async()=>{return await N.agents.list.query()},[N]),Q=z.useCallback((q,F,J)=>{let P=q.id===B;return y.jsxDEV(U,{isSelected:J,isCurrent:P,children:[y.jsxDEV(G,{bold:!0,children:[F+1,". ",q.id]},void 0,!0,void 0,this),y.jsxDEV(_,{},void 0,!1,void 0,this),y.jsxDEV(G,{dimColor:!0,children:q.description.slice(0,20)},void 0,!1,void 0,this)]},`agent-${q.id}`,!0,void 0,this)},[B]),R=z.useCallback((q)=>{return q.id===B},[B]),W=z.useCallback(async(q)=>{let F=q.id==="default"?"":q.id;L({active_agent:F}),H()},[L,H]),X=z.useCallback((q)=>{let F=q.find((J)=>J.id===B);return F?y.jsxDEV(G,{color:"gray",dimColor:!0,children:["当前 Agent: ",y.jsxDEV(G,{color:"green",children:F.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null},[B]),M=z.useMemo(()=>({id:"agent",title:"Agent 选择",icon:"\uD83E\uDD16",dataSource:O,searchable:!0,searchFields:["id","name","description"],searchPlaceholder:"搜索 agent (名称/描述)...",filterable:!0,filters:[{id:"default",label:"默认",predicate:(q)=>q.id==="default"},{id:"custom",label:"自定义",predicate:(q)=>q.id!=="default"}],defaultFilter:"all",itemHeight:1,visibleCount:15,renderItem:Q,isSelected:R,onSelect:W,showCount:!0,statusInfo:X}),[O,Q,R,W,X]);return y.jsxDEV(Z,{config:M,onClose:H},void 0,!1,void 0,this)},k=b;export{k as default};
@@ -0,0 +1 @@
1
+ import{K as R,M as v,N as _,O as b}from"./chunk-5hqvapp1.js";import{U as S,X as J,Y as W,fa as h,ga as q}from"./chunk-h7ypcqp3.js";import{Kl as U}from"./chunk-dh2f4xyb.js";import{Wl as w}from"./chunk-4fs853nh.js";var G=w(S(),1);function M({limit:X=100,enabled:H=!0}={}){return v({queryKey:b.errors.list(),queryFn:async()=>{return U.getRecentErrors(X)},enabled:H,staleTime:5000,refetchInterval:5000})}function O(){let X=R();return _({mutationFn:async(H)=>{return U.deleteError(H)},onSuccess:()=>{X.invalidateQueries({queryKey:b.errors.all})}})}function Q(){let X=R();return _({mutationFn:async()=>{U.clearAll()},onSuccess:()=>{X.invalidateQueries({queryKey:b.errors.all})}})}var z=w(h(),1);import{join as B}from"node:path";var T={error:{emoji:"❌",color:"red",label:"错误"},warning:{emoji:"⚠️",color:"yellow",label:"警告"}},p={Agent:{emoji:"\uD83E\uDD16",label:"Agent"},Tool:{emoji:"\uD83D\uDD27",label:"Tool"},Terminal:{emoji:"\uD83D\uDCBB",label:"Terminal"},System:{emoji:"⚙️",label:"System"},Unknown:{emoji:"❓",label:"Unknown"}};function g(X){let H=new Date(X),Z=new Date,P=Z.getTime()-H.getTime();if(P<60000)return"刚刚";if(P<3600000)return`${Math.floor(P/60000)}分钟前`;if(H.toDateString()===Z.toDateString())return H.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return H.toLocaleDateString("zh-CN",{month:"short",day:"numeric"})}function c(X,H=80){if(X.length<=H)return X;return X.slice(0,H-3)+"..."}var d=({onClose:X})=>{let{data:H=[],isLoading:Z}=M({limit:50}),P=O(),N=Q(),L=G.useCallback(async()=>{await N.mutateAsync()},[N]);q((Y,A)=>{if(A.escape)X();if(A.ctrl&&Y==="l")L()},{isActive:!0});let f=B(process.cwd(),".zen-code","errors.json"),F=G.default.useMemo(()=>{let Y=H.filter(($)=>$.level==="error").length,A=H.filter(($)=>$.level==="warning").length;return{errorCount:Y,warningCount:A}},[H]);return z.jsxDEV(J,{flexDirection:"column",paddingX:1,paddingY:1,children:[z.jsxDEV(J,{marginBottom:1,children:[z.jsxDEV(W,{bold:!0,color:"cyan",children:"\uD83D\uDCCB 错误日志"},void 0,!1,void 0,this),z.jsxDEV(J,{marginLeft:2,children:[z.jsxDEV(W,{color:"red",children:["❌ ",F.errorCount]},void 0,!0,void 0,this),z.jsxDEV(W,{children:" "},void 0,!1,void 0,this),z.jsxDEV(W,{color:"yellow",children:["⚠️ ",F.warningCount]},void 0,!0,void 0,this),z.jsxDEV(W,{dimColor:!0,children:["| Total: ",H.length]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Z&&z.jsxDEV(J,{marginBottom:1,children:z.jsxDEV(W,{dimColor:!0,children:"加载中..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),!Z&&H.length>0&&z.jsxDEV(J,{flexDirection:"column",children:H.slice(0,20).map((Y,A)=>{let $=T[Y.level],K=p[Y.source]||p.Unknown,k=g(Y.timestamp),I=c(Y.message);return z.jsxDEV(J,{flexDirection:"column",marginBottom:1,children:[z.jsxDEV(J,{children:z.jsxDEV(W,{color:$.color,children:[$.emoji," ",I]},void 0,!0,void 0,this)},void 0,!1,void 0,this),z.jsxDEV(J,{marginLeft:2,children:[z.jsxDEV(W,{dimColor:!0,children:[K.emoji," ",K.label," | ",k]},void 0,!0,void 0,this),Y.file&&z.jsxDEV(W,{dimColor:!0,color:"gray",children:[" ","| \uD83D\uDCC4 ",Y.file,Y.line&&`:${Y.line}`]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},Y.id,!0,void 0,this)})},void 0,!1,void 0,this),!Z&&H.length===0&&z.jsxDEV(J,{flexDirection:"column",marginBottom:1,children:[z.jsxDEV(J,{marginBottom:1,children:z.jsxDEV(W,{dimColor:!0,children:"暂无错误记录"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV(J,{marginBottom:1,children:z.jsxDEV(W,{dimColor:!0,children:"错误将自动收集到:"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV(J,{marginBottom:1,children:z.jsxDEV(W,{color:"yellow",children:f},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV(J,{marginTop:1,children:z.jsxDEV(W,{dimColor:!0,children:"按 ESC 返回 | Ctrl+L 清空所有"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},E=d;export{E as default};
@@ -1,4 +1,4 @@
1
- import{Gd as z}from"./chunk-n9rpnke9.js";import"./chunk-y8qhrx11.js";class I{db;pragmaPromise=null;constructor(x){this.db=x}ensurePragma(){if(!this.pragmaPromise)this.pragmaPromise=this.doEnsurePragma();return this.pragmaPromise}async doEnsurePragma(){await z`PRAGMA busy_timeout = 5000`.execute(this.db),await z`PRAGMA journal_mode = WAL`.execute(this.db),await z`PRAGMA synchronous = NORMAL`.execute(this.db),await z`PRAGMA wal_autocheckpoint = 1000`.execute(this.db)}dateToDb(x){return x.toISOString()}dbToDate(x){return new Date(x)}jsonToDb(x){return JSON.stringify(x)}dbToJson(x){if(typeof x==="string")try{return JSON.parse(x)}catch{return x}return x}buildJsonQuery(x,E,F,B){let G=`$.${JSON.stringify(F)}`;if(B===null)return z`
1
+ import{fe as z}from"./chunk-vwj4n000.js";import"./chunk-4fs853nh.js";class I{db;pragmaPromise=null;constructor(x){this.db=x}ensurePragma(){if(!this.pragmaPromise)this.pragmaPromise=this.doEnsurePragma();return this.pragmaPromise}async doEnsurePragma(){await z`PRAGMA busy_timeout = 5000`.execute(this.db),await z`PRAGMA journal_mode = WAL`.execute(this.db),await z`PRAGMA synchronous = NORMAL`.execute(this.db),await z`PRAGMA wal_autocheckpoint = 1000`.execute(this.db)}dateToDb(x){return x.toISOString()}dbToDate(x){return new Date(x)}jsonToDb(x){return JSON.stringify(x)}dbToJson(x){if(typeof x==="string")try{return JSON.parse(x)}catch{return x}return x}buildJsonQuery(x,E,F,B){let G=`$.${JSON.stringify(F)}`;if(B===null)return z`
2
2
  json_type(${z.ref(E)}, ${z.lit(G)}) = 'null'
3
3
  `;let C;if(typeof B==="string")C=B;else if(typeof B==="number")C=B;else if(typeof B==="boolean")C=B?1:0;else C=JSON.stringify(B);return z`json_extract(${z.ref(E)}, ${z.lit(G)}) = ${z.lit(C)}`}now(){return new Date().toISOString()}async createTables(x){await this.ensurePragma(),await z`
4
4
  CREATE TABLE IF NOT EXISTS threads (