zen-code 4.7.4 → 4.8.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.
- package/dist/app.js +271 -0
- package/dist/chunk-0fhpz98a.js +2 -0
- package/dist/chunk-15smn69q.js +31 -0
- package/dist/chunk-3ep2tag7.js +2 -0
- package/dist/chunk-3jek9sxm.js +2 -0
- package/dist/chunk-3n2b4eb4.js +2 -0
- package/dist/chunk-3znrwnd8.js +1 -0
- package/dist/chunk-4b8yaknt.js +1 -0
- package/dist/chunk-5fqt5yg1.js +81 -0
- package/dist/chunk-5nzs0q25.js +1 -0
- package/dist/chunk-5wn1nfqy.js +6 -0
- package/dist/chunk-6ty22kkt.js +4 -0
- package/dist/chunk-70a0e941.js +1 -0
- package/dist/chunk-7dp8kq2f.js +2 -0
- package/dist/chunk-8nhayyat.js +1 -0
- package/dist/chunk-9k57afdm.js +2 -0
- package/dist/chunk-9kc9cea3.js +7 -0
- package/dist/chunk-bgpcx3bm.js +2 -0
- package/dist/chunk-bjywwcgn.js +26 -0
- package/dist/chunk-c9q11tk2.js +88 -0
- package/dist/chunk-cga0m5sy.js +1 -0
- package/dist/chunk-cze71w02.js +2 -0
- package/dist/chunk-czz2fs2w.js +7 -0
- package/dist/chunk-dh3jz71n.js +1 -0
- package/dist/chunk-e0sqjq2h.js +1 -0
- package/dist/chunk-efhkdw2z.js +1 -0
- package/dist/chunk-ew7249h9.js +1 -0
- package/dist/chunk-h5nnz4dy.js +1 -0
- package/dist/chunk-hww94vjn.js +1 -0
- package/dist/chunk-j1n8jp1w.js +253 -0
- package/dist/chunk-j204fejq.js +1 -0
- package/dist/chunk-jkbtx9va.js +2 -0
- package/dist/chunk-k67epfhc.js +1 -0
- package/dist/chunk-kbs4px1b.js +6 -0
- package/dist/chunk-keqk70wm.js +2 -0
- package/dist/chunk-kxk71nn0.js +1 -0
- package/dist/chunk-mg8zpgaz.js +1 -0
- package/dist/chunk-n1d8xx5k.js +2 -0
- package/dist/chunk-ndtwq2zx.js +2 -0
- package/dist/chunk-pdkbrds7.js +1 -0
- package/dist/chunk-q8arjxg1.js +23 -0
- package/dist/chunk-rdc9pxf6.js +1 -0
- package/dist/chunk-rrkzfahh.js +91 -0
- package/dist/chunk-s3fyfrka.js +2 -0
- package/dist/chunk-sft6ep0c.js +310 -0
- package/dist/chunk-vc384abg.js +3 -0
- package/dist/chunk-vjj00e3e.js +6 -0
- package/dist/chunk-vkng13p1.js +424 -0
- package/dist/chunk-wbn1hbxf.js +1 -0
- package/dist/chunk-wwn7gw8g.js +274 -0
- package/dist/chunk-yaa4eesd.js +2 -0
- package/dist/chunk-yvhq458c.js +25 -0
- package/dist/cli.js +2 -0
- package/dist/nonInteractive.js +4 -0
- package/dist/zen-keyboard.js +3 -0
- package/package.json +88 -87
- package/LICENSE +0 -201
- package/dist/FileSystemPluginStore-ChortK7z.mjs +0 -64
- package/dist/FileSystemSkillStore-Dl5briBv.mjs +0 -108
- package/dist/MultiLineTextInput-CL8nm9nv.mjs +0 -24492
- package/dist/_commonjsHelpers-DQNKXVTB.mjs +0 -33
- package/dist/app-CK3nD8Gj.mjs +0 -22428
- package/dist/checkpoint-C5AFBYE--CczNxXBB.mjs +0 -355
- package/dist/checkpoint-DxiUsHMy-B5iaccT2.mjs +0 -394
- package/dist/cli.mjs +0 -57
- package/dist/devtools-CzaVuYnh.mjs +0 -2667
- package/dist/graphBuilder-DJoMXf6J.mjs +0 -28909
- package/dist/index-BPG5Np-8.mjs +0 -144
- package/dist/index-Dxfhvdx8.mjs +0 -23
- package/dist/index-F6_SKYUd.mjs +0 -463
- package/dist/load-iYJqYrjn.mjs +0 -119
- package/dist/memories-CaHDnBK1.mjs +0 -115
- package/dist/metadata-XVTVXthy.mjs +0 -6
- package/dist/nonInteractive.mjs +0 -55
- package/dist/pg-adapter-BFtir1GE-BbUXBpaX.mjs +0 -60
- package/dist/queue-DySatFkr-CG2GdO4P.mjs +0 -106
- package/dist/remote-threads-CrG03ZS7-C9duTCnB.mjs +0 -157
- package/dist/shallow-G4eKoZ7M.mjs +0 -331
- package/dist/shallow-checkpoint-BEhTdp7z-DfHxnfoU.mjs +0 -383
- package/dist/sqlite-adapter-oBA95xba-BrBWorSV.mjs +0 -82
- package/dist/subTasks-DNjIN4eU.mjs +0 -18
- package/dist/zen-code.mjs +0 -3
- package/dist/zen-keyboard.mjs +0 -13
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import{V as u,X as VO,Y as SO,Z as s$}from"./chunk-bgpcx3bm.js";import{nb as vG,ob as R,rb as W}from"./chunk-cze71w02.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
|
+
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
|
+
|
|
4
|
+
To prepare for this change:
|
|
5
|
+
- If you want the current behavior, explicitly use 'sslmode=verify-full'
|
|
6
|
+
- If you want libpq compatibility now, use 'uselibpqcompat=true&sslmode=${$}'
|
|
7
|
+
|
|
8
|
+
See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode definitions.`)}nE.exports=v;v.parse=v;v.toClientConfig=oE;v.parseIntoClientConfig=T1});var w$=R((R8,rE)=>{var Y1=W("dns"),tE=s(),sE=iE().parse,z=function($,E,_){if(E[$])return E[$];if(_===void 0)_=process.env["PG"+$.toUpperCase()];else if(_===!1);else _=process.env[_];return _||tE[$]},R1=function(){switch(process.env.PGSSLMODE){case"disable":return!1;case"prefer":case"require":case"verify-ca":case"verify-full":return!0;case"no-verify":return{rejectUnauthorized:!1}}return tE.ssl},p=function($){return"'"+(""+$).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},S=function($,E,_){let O=E[_];if(O!==void 0&&O!==null)$.push(_+"="+p(O))};class aE{constructor($){if($=typeof $==="string"?sE($):$||{},$.connectionString)$=Object.assign({},$,sE($.connectionString));if(this.user=z("user",$),this.database=z("database",$),this.database===void 0)this.database=this.user;if(this.port=parseInt(z("port",$),10),this.host=z("host",$),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:z("password",$)}),this.binary=z("binary",$),this.options=z("options",$),this.ssl=typeof $.ssl>"u"?R1():$.ssl,typeof this.ssl==="string"){if(this.ssl==="true")this.ssl=!0}if(this.ssl==="no-verify")this.ssl={rejectUnauthorized:!1};if(this.ssl&&this.ssl.key)Object.defineProperty(this.ssl,"key",{enumerable:!1});if(this.client_encoding=z("client_encoding",$),this.replication=z("replication",$),this.isDomainSocket=!(this.host||"").indexOf("/"),this.application_name=z("application_name",$,"PGAPPNAME"),this.fallback_application_name=z("fallback_application_name",$,!1),this.statement_timeout=z("statement_timeout",$,!1),this.lock_timeout=z("lock_timeout",$,!1),this.idle_in_transaction_session_timeout=z("idle_in_transaction_session_timeout",$,!1),this.query_timeout=z("query_timeout",$,!1),$.connectionTimeoutMillis===void 0)this.connect_timeout=process.env.PGCONNECT_TIMEOUT||0;else this.connect_timeout=Math.floor($.connectionTimeoutMillis/1000);if($.keepAlive===!1)this.keepalives=0;else if($.keepAlive===!0)this.keepalives=1;if(typeof $.keepAliveInitialDelayMillis==="number")this.keepalives_idle=Math.floor($.keepAliveInitialDelayMillis/1000)}getLibpqConnectionString($){let E=[];S(E,this,"user"),S(E,this,"password"),S(E,this,"port"),S(E,this,"application_name"),S(E,this,"fallback_application_name"),S(E,this,"connect_timeout"),S(E,this,"options");let _=typeof this.ssl==="object"?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(S(E,_,"sslmode"),S(E,_,"sslca"),S(E,_,"sslkey"),S(E,_,"sslcert"),S(E,_,"sslrootcert"),this.database)E.push("dbname="+p(this.database));if(this.replication)E.push("replication="+p(this.replication));if(this.host)E.push("host="+p(this.host));if(this.isDomainSocket)return $(null,E.join(" "));if(this.client_encoding)E.push("client_encoding="+p(this.client_encoding));Y1.lookup(this.host,function(O,G){if(O)return $(O,null);return E.push("hostaddr="+p(G)),$(null,E.join(" "))})}}rE.exports=aE});var x$=R((K8,E_)=>{var K1=i(),eE=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/;class $_{constructor($,E){if(this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0,this._types=E,this.RowCtor=null,this.rowAsArray=$==="array",this.rowAsArray)this.parseRow=this._parseRowAsArray;this._prebuiltEmptyResultObject=null}addCommandComplete($){let E;if($.text)E=eE.exec($.text);else E=eE.exec($.command);if(E){if(this.command=E[1],E[3])this.oid=parseInt(E[2],10),this.rowCount=parseInt(E[3],10);else if(E[2])this.rowCount=parseInt(E[2],10)}}_parseRowAsArray($){let E=Array($.length);for(let _=0,O=$.length;_<O;_++){let G=$[_];if(G!==null)E[_]=this._parsers[_](G);else E[_]=null}return E}parseRow($){let E={...this._prebuiltEmptyResultObject};for(let _=0,O=$.length;_<O;_++){let G=$[_],X=this.fields[_].name;if(G!==null){let U=this.fields[_].format==="binary"?Buffer.from(G):G;E[X]=this._parsers[_](U)}else E[X]=null}return E}addRow($){this.rows.push($)}addFields($){if(this.fields=$,this.fields.length)this._parsers=Array($.length);let E={};for(let _=0;_<$.length;_++){let O=$[_];if(E[O.name]=null,this._types)this._parsers[_]=this._types.getTypeParser(O.dataTypeID,O.format||"text");else this._parsers[_]=K1.getTypeParser(O.dataTypeID,O.format||"text")}this._prebuiltEmptyResultObject={...E}}}E_.exports=$_});var U_=R((W8,X_)=>{var{EventEmitter:W1}=W("events"),__=x$(),O_=b();class G_ extends W1{constructor($,E,_){super();if($=O_.normalizeQueryConfig($,E,_),this.text=$.text,this.values=$.values,this.rows=$.rows,this.types=$.types,this.name=$.name,this.queryMode=$.queryMode,this.binary=$.binary,this.portal=$.portal||"",this.callback=$.callback,this._rowMode=$.rowMode,process.domain&&$.callback)this.callback=process.domain.bind($.callback);this._result=new __(this._rowMode,this.types),this._results=this._result,this._canceledDueToError=!1}requiresPreparation(){if(this.queryMode==="extended")return!0;if(this.name)return!0;if(this.rows)return!0;if(!this.text)return!1;if(!this.values)return!1;return this.values.length>0}_checkForMultirow(){if(this._result.command){if(!Array.isArray(this._results))this._results=[this._result];this._result=new __(this._rowMode,this._result._types),this._results.push(this._result)}}handleRowDescription($){this._checkForMultirow(),this._result.addFields($.fields),this._accumulateRows=this.callback||!this.listeners("row").length}handleDataRow($){let E;if(this._canceledDueToError)return;try{E=this._result.parseRow($.fields)}catch(_){this._canceledDueToError=_;return}if(this.emit("row",E,this._result),this._accumulateRows)this._result.addRow(E)}handleCommandComplete($,E){if(this._checkForMultirow(),this._result.addCommandComplete($),this.rows)E.sync()}handleEmptyQuery($){if(this.rows)$.sync()}handleError($,E){if(this._canceledDueToError)$=this._canceledDueToError,this._canceledDueToError=!1;if(this.callback)return this.callback($);this.emit("error",$)}handleReadyForQuery($){if(this._canceledDueToError)return this.handleError(this._canceledDueToError,$);if(this.callback)try{this.callback(null,this._results)}catch(E){process.nextTick(()=>{throw E})}this.emit("end",this._results)}submit($){if(typeof this.text!=="string"&&typeof this.name!=="string")return Error("A query must have either text or a name. Supplying neither is unsupported.");let E=$.parsedStatements[this.name];if(this.text&&E&&this.text!==E)return Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);if(this.values&&!Array.isArray(this.values))return Error("Query values must be an array");if(this.requiresPreparation()){$.stream.cork&&$.stream.cork();try{this.prepare($)}finally{$.stream.uncork&&$.stream.uncork()}}else $.query(this.text);return null}hasBeenParsed($){return this.name&&$.parsedStatements[this.name]}handlePortalSuspended($){this._getRows($,this.rows)}_getRows($,E){if($.execute({portal:this.portal,rows:E}),!E)$.sync();else $.flush()}prepare($){if(!this.hasBeenParsed($))$.parse({text:this.text,name:this.name,types:this.types});try{$.bind({portal:this.portal,statement:this.name,values:this.values,binary:this.binary,valueMapper:O_.prepareValue})}catch(E){this.handleError(E,$);return}$.describe({type:"P",name:this.portal||""}),this._getRows($,this.rows)}handleCopyInResponse($){$.sendCopyFail("No source stream defined")}handleCopyData($,E){}}X_.exports=G_});var h$=R((P_)=>{Object.defineProperty(P_,"__esModule",{value:!0});P_.NoticeMessage=P_.DataRowMessage=P_.CommandCompleteMessage=P_.ReadyForQueryMessage=P_.NotificationResponseMessage=P_.BackendKeyDataMessage=P_.AuthenticationMD5Password=P_.ParameterStatusMessage=P_.ParameterDescriptionMessage=P_.RowDescriptionMessage=P_.Field=P_.CopyResponse=P_.CopyDataMessage=P_.DatabaseError=P_.copyDone=P_.emptyQuery=P_.replicationStart=P_.portalSuspended=P_.noData=P_.closeComplete=P_.bindComplete=P_.parseComplete=void 0;P_.parseComplete={name:"parseComplete",length:5};P_.bindComplete={name:"bindComplete",length:5};P_.closeComplete={name:"closeComplete",length:5};P_.noData={name:"noData",length:5};P_.portalSuspended={name:"portalSuspended",length:5};P_.replicationStart={name:"replicationStart",length:4};P_.emptyQuery={name:"emptyQuery",length:4};P_.copyDone={name:"copyDone",length:4};class J_ extends Error{constructor($,E,_){super($);this.length=E,this.name=_}}P_.DatabaseError=J_;class Z_{constructor($,E){this.length=$,this.chunk=E,this.name="copyData"}}P_.CopyDataMessage=Z_;class H_{constructor($,E,_,O){this.length=$,this.name=E,this.binary=_,this.columnTypes=Array(O)}}P_.CopyResponse=H_;class T_{constructor($,E,_,O,G,X,U){this.name=$,this.tableID=E,this.columnID=_,this.dataTypeID=O,this.dataTypeSize=G,this.dataTypeModifier=X,this.format=U}}P_.Field=T_;class Y_{constructor($,E){this.length=$,this.fieldCount=E,this.name="rowDescription",this.fields=Array(this.fieldCount)}}P_.RowDescriptionMessage=Y_;class R_{constructor($,E){this.length=$,this.parameterCount=E,this.name="parameterDescription",this.dataTypeIDs=Array(this.parameterCount)}}P_.ParameterDescriptionMessage=R_;class K_{constructor($,E,_){this.length=$,this.parameterName=E,this.parameterValue=_,this.name="parameterStatus"}}P_.ParameterStatusMessage=K_;class W_{constructor($,E){this.length=$,this.salt=E,this.name="authenticationMD5Password"}}P_.AuthenticationMD5Password=W_;class L_{constructor($,E,_){this.length=$,this.processID=E,this.secretKey=_,this.name="backendKeyData"}}P_.BackendKeyDataMessage=L_;class Q_{constructor($,E,_,O){this.length=$,this.processId=E,this.channel=_,this.payload=O,this.name="notification"}}P_.NotificationResponseMessage=Q_;class j_{constructor($,E){this.length=$,this.status=E,this.name="readyForQuery"}}P_.ReadyForQueryMessage=j_;class N_{constructor($,E){this.length=$,this.text=E,this.name="commandComplete"}}P_.CommandCompleteMessage=N_;class F_{constructor($,E){this.length=$,this.fields=E,this.name="dataRow",this.fieldCount=E.length}}P_.DataRowMessage=F_;class z_{constructor($,E){this.length=$,this.message=E,this.name="notice"}}P_.NoticeMessage=z_});var S_=R((M_)=>{Object.defineProperty(M_,"__esModule",{value:!0});M_.Writer=void 0;class D_{constructor($=256){this.size=$,this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe($)}ensure($){if(this.buffer.length-this.offset<$){let _=this.buffer,O=_.length+(_.length>>1)+$;this.buffer=Buffer.allocUnsafe(O),_.copy(this.buffer)}}addInt32($){return this.ensure(4),this.buffer[this.offset++]=$>>>24&255,this.buffer[this.offset++]=$>>>16&255,this.buffer[this.offset++]=$>>>8&255,this.buffer[this.offset++]=$>>>0&255,this}addInt16($){return this.ensure(2),this.buffer[this.offset++]=$>>>8&255,this.buffer[this.offset++]=$>>>0&255,this}addCString($){if(!$)this.ensure(1);else{let E=Buffer.byteLength($);this.ensure(E+1),this.buffer.write($,this.offset,"utf-8"),this.offset+=E}return this.buffer[this.offset++]=0,this}addString($=""){let E=Buffer.byteLength($);return this.ensure(E),this.buffer.write($,this.offset),this.offset+=E,this}add($){return this.ensure($.length),$.copy(this.buffer,this.offset),this.offset+=$.length,this}join($){if($){this.buffer[this.headerPosition]=$;let E=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(E,this.headerPosition+1)}return this.buffer.slice($?0:5,this.offset)}flush($){let E=this.join($);return this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(this.size),E}}M_.Writer=D_});var B_=R((I_)=>{Object.defineProperty(I_,"__esModule",{value:!0});I_.serialize=void 0;var b$=S_(),L=new b$.Writer,y1=($)=>{L.addInt16(3).addInt16(0);for(let O of Object.keys($))L.addCString(O).addCString($[O]);L.addCString("client_encoding").addCString("UTF8");let E=L.addCString("").flush(),_=E.length+4;return new b$.Writer().addInt32(_).add(E).flush()},v1=()=>{let $=Buffer.allocUnsafe(8);return $.writeInt32BE(8,0),$.writeInt32BE(80877103,4),$},p1=($)=>{return L.addCString($).flush(112)},m1=function($,E){return L.addCString($).addInt32(Buffer.byteLength(E)).addString(E),L.flush(112)},f1=function($){return L.addString($).flush(112)},d1=($)=>{return L.addCString($).flush(81)},C_=[],u1=($)=>{let E=$.name||"";if(E.length>63)console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",E,E.length),console.error("This can cause conflicts and silent errors executing queries");let _=$.types||C_,O=_.length,G=L.addCString(E).addCString($.text).addInt16(O);for(let X=0;X<O;X++)G.addInt32(_[X]);return L.flush(80)},m=new b$.Writer,g1=function($,E){for(let _=0;_<$.length;_++){let O=E?E($[_],_):$[_];if(O==null)L.addInt16(0),m.addInt32(-1);else if(O instanceof Buffer)L.addInt16(1),m.addInt32(O.length),m.add(O);else L.addInt16(0),m.addInt32(Buffer.byteLength(O)),m.addString(O)}},c1=($={})=>{let E=$.portal||"",_=$.statement||"",O=$.binary||!1,G=$.values||C_,X=G.length;return L.addCString(E).addCString(_),L.addInt16(X),g1(G,$.valueMapper),L.addInt16(X),L.add(m.flush()),L.addInt16(1),L.addInt16(O?1:0),L.flush(66)},l1=Buffer.from([69,0,0,0,9,0,0,0,0,0]),o1=($)=>{if(!$||!$.portal&&!$.rows)return l1;let E=$.portal||"",_=$.rows||0,O=Buffer.byteLength(E),G=4+O+1+4,X=Buffer.allocUnsafe(1+G);return X[0]=69,X.writeInt32BE(G,1),X.write(E,5,"utf-8"),X[O+5]=0,X.writeUInt32BE(_,X.length-4),X},n1=($,E)=>{let _=Buffer.allocUnsafe(16);return _.writeInt32BE(16,0),_.writeInt16BE(1234,4),_.writeInt16BE(5678,6),_.writeInt32BE($,8),_.writeInt32BE(E,12),_},y$=($,E)=>{let O=4+Buffer.byteLength(E)+1,G=Buffer.allocUnsafe(1+O);return G[0]=$,G.writeInt32BE(O,1),G.write(E,5,"utf-8"),G[O]=0,G},i1=L.addCString("P").flush(68),s1=L.addCString("S").flush(68),t1=($)=>{return $.name?y$(68,`${$.type}${$.name||""}`):$.type==="P"?i1:s1},a1=($)=>{let E=`${$.type}${$.name||""}`;return y$(67,E)},r1=($)=>{return L.add($).flush(100)},e1=($)=>{return y$(102,$)},X$=($)=>Buffer.from([$,0,0,0,4]),$4=X$(72),E4=X$(83),_4=X$(88),O4=X$(99),G4={startup:y1,password:p1,requestSsl:v1,sendSASLInitialResponseMessage:m1,sendSCRAMClientFinalMessage:f1,query:d1,parse:u1,bind:c1,execute:o1,describe:t1,close:a1,flush:()=>$4,sync:()=>E4,end:()=>_4,copyData:r1,copyDone:()=>O4,copyFail:e1,cancel:n1};I_.serialize=G4});var h_=R((w_)=>{Object.defineProperty(w_,"__esModule",{value:!0});w_.BufferReader=void 0;var X4=Buffer.allocUnsafe(0);class k_{constructor($=0){this.offset=$,this.buffer=X4,this.encoding="utf-8"}setBuffer($,E){this.offset=$,this.buffer=E}int16(){let $=this.buffer.readInt16BE(this.offset);return this.offset+=2,$}byte(){let $=this.buffer[this.offset];return this.offset++,$}int32(){let $=this.buffer.readInt32BE(this.offset);return this.offset+=4,$}uint32(){let $=this.buffer.readUInt32BE(this.offset);return this.offset+=4,$}string($){let E=this.buffer.toString(this.encoding,this.offset,this.offset+$);return this.offset+=$,E}cstring(){let $=this.offset,E=$;while(this.buffer[E++]!==0);return this.offset=E,this.buffer.toString(this.encoding,$,E-1)}bytes($){let E=this.buffer.slice(this.offset,this.offset+$);return this.offset+=$,E}}w_.BufferReader=k_});var d_=R((m_)=>{Object.defineProperty(m_,"__esModule",{value:!0});m_.Parser=void 0;var N=h$(),U4=h_(),p$=1,J4=4,b_=p$+J4,D=-1,v$=Buffer.allocUnsafe(0);class v_{constructor($){if(this.buffer=v$,this.bufferLength=0,this.bufferOffset=0,this.reader=new U4.BufferReader,($===null||$===void 0?void 0:$.mode)==="binary")throw Error("Binary mode not supported yet");this.mode=($===null||$===void 0?void 0:$.mode)||"text"}parse($,E){this.mergeBuffer($);let _=this.bufferOffset+this.bufferLength,O=this.bufferOffset;while(O+b_<=_){let G=this.buffer[O],X=this.buffer.readUInt32BE(O+p$),U=p$+X;if(U+O<=_){let J=this.handlePacket(O+b_,G,X,this.buffer);E(J),O+=U}else break}if(O===_)this.buffer=v$,this.bufferLength=0,this.bufferOffset=0;else this.bufferLength=_-O,this.bufferOffset=O}mergeBuffer($){if(this.bufferLength>0){let E=this.bufferLength+$.byteLength;if(E+this.bufferOffset>this.buffer.byteLength){let O;if(E<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)O=this.buffer;else{let G=this.buffer.byteLength*2;while(E>=G)G*=2;O=Buffer.allocUnsafe(G)}this.buffer.copy(O,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=O,this.bufferOffset=0}$.copy(this.buffer,this.bufferOffset+this.bufferLength),this.bufferLength=E}else this.buffer=$,this.bufferOffset=0,this.bufferLength=$.byteLength}handlePacket($,E,_,O){let{reader:G}=this;G.setBuffer($,O);let X;switch(E){case 50:X=N.bindComplete;break;case 49:X=N.parseComplete;break;case 51:X=N.closeComplete;break;case 110:X=N.noData;break;case 115:X=N.portalSuspended;break;case 99:X=N.copyDone;break;case 87:X=N.replicationStart;break;case 73:X=N.emptyQuery;break;case 68:X=j4(G);break;case 67:X=H4(G);break;case 90:X=Z4(G);break;case 65:X=K4(G);break;case 82:X=z4(G,_);break;case 83:X=N4(G);break;case 75:X=F4(G);break;case 69:X=y_(G,"error");break;case 78:X=y_(G,"notice");break;case 84:X=W4(G);break;case 116:X=Q4(G);break;case 71:X=Y4(G);break;case 72:X=R4(G);break;case 100:X=T4(G,_);break;default:return new N.DatabaseError("received invalid response: "+E.toString(16),_,"error")}return G.setBuffer(0,v$),X.length=_,X}}m_.Parser=v_;var Z4=($)=>{let E=$.string(1);return new N.ReadyForQueryMessage(D,E)},H4=($)=>{let E=$.cstring();return new N.CommandCompleteMessage(D,E)},T4=($,E)=>{let _=$.bytes(E-4);return new N.CopyDataMessage(D,_)},Y4=($)=>p_($,"copyInResponse"),R4=($)=>p_($,"copyOutResponse"),p_=($,E)=>{let _=$.byte()!==0,O=$.int16(),G=new N.CopyResponse(D,E,_,O);for(let X=0;X<O;X++)G.columnTypes[X]=$.int16();return G},K4=($)=>{let E=$.int32(),_=$.cstring(),O=$.cstring();return new N.NotificationResponseMessage(D,E,_,O)},W4=($)=>{let E=$.int16(),_=new N.RowDescriptionMessage(D,E);for(let O=0;O<E;O++)_.fields[O]=L4($);return _},L4=($)=>{let E=$.cstring(),_=$.uint32(),O=$.int16(),G=$.uint32(),X=$.int16(),U=$.int32(),J=$.int16()===0?"text":"binary";return new N.Field(E,_,O,G,X,U,J)},Q4=($)=>{let E=$.int16(),_=new N.ParameterDescriptionMessage(D,E);for(let O=0;O<E;O++)_.dataTypeIDs[O]=$.int32();return _},j4=($)=>{let E=$.int16(),_=Array(E);for(let O=0;O<E;O++){let G=$.int32();_[O]=G===-1?null:$.string(G)}return new N.DataRowMessage(D,_)},N4=($)=>{let E=$.cstring(),_=$.cstring();return new N.ParameterStatusMessage(D,E,_)},F4=($)=>{let E=$.int32(),_=$.int32();return new N.BackendKeyDataMessage(D,E,_)},z4=($,E)=>{let _=$.int32(),O={name:"authenticationOk",length:E};switch(_){case 0:break;case 3:if(O.length===8)O.name="authenticationCleartextPassword";break;case 5:if(O.length===12){O.name="authenticationMD5Password";let G=$.bytes(4);return new N.AuthenticationMD5Password(D,G)}break;case 10:{O.name="authenticationSASL",O.mechanisms=[];let G;do if(G=$.cstring(),G)O.mechanisms.push(G);while(G)}break;case 11:O.name="authenticationSASLContinue",O.data=$.string(E-8);break;case 12:O.name="authenticationSASLFinal",O.data=$.string(E-8);break;default:throw Error("Unknown authenticationOk message type "+_)}return O},y_=($,E)=>{let _={},O=$.string(1);while(O!=="\x00")_[O]=$.cstring(),O=$.string(1);let G=_.M,X=E==="notice"?new N.NoticeMessage(D,G):new N.DatabaseError(G,D,E);return X.severity=_.S,X.code=_.C,X.detail=_.D,X.hint=_.H,X.position=_.P,X.internalPosition=_.p,X.internalQuery=_.q,X.where=_.W,X.schema=_.s,X.table=_.t,X.column=_.c,X.dataType=_.d,X.constraint=_.n,X.file=_.F,X.line=_.L,X.routine=_.R,X}});var m$=R((U$)=>{Object.defineProperty(U$,"__esModule",{value:!0});U$.DatabaseError=U$.serialize=U$.parse=void 0;var P4=h$();Object.defineProperty(U$,"DatabaseError",{enumerable:!0,get:function(){return P4.DatabaseError}});var A4=B_();Object.defineProperty(U$,"serialize",{enumerable:!0,get:function(){return A4.serialize}});var D4=d_();function M4($,E){let _=new D4.Parser;return $.on("data",(O)=>_.parse(O,E)),new Promise((O)=>$.on("end",()=>O()))}U$.parse=M4});var g_=R((u_)=>{Object.defineProperty(u_,"__esModule",{value:!0});u_.default={}});var l_=R((D8,c_)=>{var{getStream:I4,getSecureStream:q4}=x4();c_.exports={getStream:I4,getSecureStream:q4};function B4(){function $(_){return new(W("net")).Socket}function E(_){return W("tls").connect(_)}return{getStream:$,getSecureStream:E}}function k4(){function $(_){let{CloudflareSocket:O}=g_();return new O(_)}function E(_){return _.socket.startTls(_),_.socket}return{getStream:$,getSecureStream:E}}function w4(){if(typeof navigator==="object"&&navigator!==null&&typeof navigator.userAgent==="string")return navigator.userAgent==="Cloudflare-Workers";if(typeof Response==="function"){let $=new Response(null,{cf:{thing:!0}});if(typeof $.cf==="object"&&$.cf!==null&&$.cf.thing)return!0}return!1}function x4(){if(w4())return k4();return B4()}});var f$=R((M8,n_)=>{var h4=W("events").EventEmitter,{parse:b4,serialize:F}=m$(),{getStream:y4,getSecureStream:v4}=l_(),p4=F.flush(),m4=F.sync(),f4=F.end();class o_ extends h4{constructor($){super();if($=$||{},this.stream=$.stream||y4($.ssl),typeof this.stream==="function")this.stream=this.stream($);this._keepAlive=$.keepAlive,this._keepAliveInitialDelayMillis=$.keepAliveInitialDelayMillis,this.parsedStatements={},this.ssl=$.ssl||!1,this._ending=!1,this._emitMessage=!1;let E=this;this.on("newListener",function(_){if(_==="message")E._emitMessage=!0})}connect($,E){let _=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect($,E),this.stream.once("connect",function(){if(_._keepAlive)_.stream.setKeepAlive(!0,_._keepAliveInitialDelayMillis);_.emit("connect")});let O=function(G){if(_._ending&&(G.code==="ECONNRESET"||G.code==="EPIPE"))return;_.emit("error",G)};if(this.stream.on("error",O),this.stream.on("close",function(){_.emit("end")}),!this.ssl)return this.attachListeners(this.stream);this.stream.once("data",function(G){switch(G.toString("utf8")){case"S":break;case"N":return _.stream.end(),_.emit("error",Error("The server does not support SSL connections"));default:return _.stream.end(),_.emit("error",Error("There was an error establishing an SSL connection"))}let U={socket:_.stream};if(_.ssl!==!0){if(Object.assign(U,_.ssl),"key"in _.ssl)U.key=_.ssl.key}let J=W("net");if(J.isIP&&J.isIP(E)===0)U.servername=E;try{_.stream=v4(U)}catch(Z){return _.emit("error",Z)}_.attachListeners(_.stream),_.stream.on("error",O),_.emit("sslconnect")})}attachListeners($){b4($,(E)=>{let _=E.name==="error"?"errorMessage":E.name;if(this._emitMessage)this.emit("message",E);this.emit(_,E)})}requestSsl(){this.stream.write(F.requestSsl())}startup($){this.stream.write(F.startup($))}cancel($,E){this._send(F.cancel($,E))}password($){this._send(F.password($))}sendSASLInitialResponseMessage($,E){this._send(F.sendSASLInitialResponseMessage($,E))}sendSCRAMClientFinalMessage($){this._send(F.sendSCRAMClientFinalMessage($))}_send($){if(!this.stream.writable)return!1;return this.stream.write($)}query($){this._send(F.query($))}parse($){this._send(F.parse($))}bind($){this._send(F.bind($))}execute($){this._send(F.execute($))}flush(){if(this.stream.writable)this.stream.write(p4)}sync(){this._ending=!0,this._send(m4)}ref(){this.stream.ref()}unref(){this.stream.unref()}end(){if(this._ending=!0,!this._connecting||!this.stream.writable){this.stream.end();return}return this.stream.write(f4,()=>{this.stream.end()})}close($){this._send(F.close($))}describe($){this._send(F.describe($))}sendCopyFromChunk($){this._send(F.copyData($))}endCopyFrom(){this._send(F.copyDone())}sendCopyFail($){this._send(F.copyFail($))}}n_.exports=o_});var a_=R((V8,t_)=>{var{Transform:d4}=W("stream"),{StringDecoder:u4}=W("string_decoder"),B=Symbol("last"),J$=Symbol("decoder");function g4($,E,_){let O;if(this.overflow){if(O=this[J$].write($).split(this.matcher),O.length===1)return _();O.shift(),this.overflow=!1}else this[B]+=this[J$].write($),O=this[B].split(this.matcher);this[B]=O.pop();for(let G=0;G<O.length;G++)try{s_(this,this.mapper(O[G]))}catch(X){return _(X)}if(this.overflow=this[B].length>this.maxLength,this.overflow&&!this.skipOverflow){_(Error("maximum buffer reached"));return}_()}function c4($){if(this[B]+=this[J$].end(),this[B])try{s_(this,this.mapper(this[B]))}catch(E){return $(E)}$()}function s_($,E){if(E!==void 0)$.push(E)}function i_($){return $}function l4($,E,_){switch($=$||/\r?\n/,E=E||i_,_=_||{},arguments.length){case 1:if(typeof $==="function")E=$,$=/\r?\n/;else if(typeof $==="object"&&!($ instanceof RegExp)&&!$[Symbol.split])_=$,$=/\r?\n/;break;case 2:if(typeof $==="function")_=E,E=$,$=/\r?\n/;else if(typeof E==="object")_=E,E=i_}_=Object.assign({},_),_.autoDestroy=!0,_.transform=g4,_.flush=c4,_.readableObjectMode=!0;let O=new d4(_);return O[B]="",O[J$]=new u4("utf8"),O.matcher=$,O.mapper=E,O.maxLength=_.maxLength,O.skipOverflow=_.skipOverflow||!1,O.overflow=!1,O._destroy=function(G,X){this._writableState.errorEmitted=!1,X(G)},O}t_.exports=l4});var $O=R((GG,I)=>{var r_=W("path"),o4=W("stream").Stream,n4=a_(),e_=W("util"),i4=5432,Z$=process.platform==="win32",a=process.stderr,s4=56,t4=7,a4=61440,r4=32768;function e4($){return($&a4)==r4}var f=["host","port","database","user","password"],d$=f.length,$G=f[d$-1];function u$(){var $=a instanceof o4&&a.writable===!0;if($){var E=Array.prototype.slice.call(arguments).concat(`
|
|
9
|
+
`);a.write(e_.format.apply(e_,E))}}Object.defineProperty(GG,"isWin",{get:function(){return Z$},set:function($){Z$=$}});GG.warnTo=function($){var E=a;return a=$,E};GG.getFileName=function($){var E=$||process.env,_=E.PGPASSFILE||(Z$?r_.join(E.APPDATA||"./","postgresql","pgpass.conf"):r_.join(E.HOME||"./",".pgpass"));return _};GG.usePgPass=function($,E){if(Object.prototype.hasOwnProperty.call(process.env,"PGPASSWORD"))return!1;if(Z$)return!0;if(E=E||"<unkn>",!e4($.mode))return u$('WARNING: password file "%s" is not a plain file',E),!1;if($.mode&(s4|t4))return u$('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less',E),!1;return!0};var EG=GG.match=function($,E){return f.slice(0,-1).reduce(function(_,O,G){if(G==1){if(Number($[O]||i4)===Number(E[O]))return _&&!0}return _&&(E[O]==="*"||E[O]===$[O])},!0)};GG.getPassword=function($,E,_){var O,G=E.pipe(n4());function X(Z){var H=_G(Z);if(H&&OG(H)&&EG($,H))O=H[$G],G.end()}var U=function(){E.destroy(),_(O)},J=function(Z){E.destroy(),u$("WARNING: error on reading file: %s",Z),_(void 0)};E.on("error",J),G.on("data",X).on("end",U).on("error",J)};var _G=GG.parseLine=function($){if($.length<11||$.match(/^\s+#/))return null;var E="",_="",O=0,G=0,X=0,U={},J=!1,Z=function(Y,T,K){var Q=$.substring(T,K);if(!Object.hasOwnProperty.call(process.env,"PGPASS_NO_DEESCAPE"))Q=Q.replace(/\\([:\\])/g,"$1");U[f[Y]]=Q};for(var H=0;H<$.length-1;H+=1){if(E=$.charAt(H+1),_=$.charAt(H),J=O==d$-1,J){Z(O,G);break}if(H>=0&&E==":"&&_!=="\\")Z(O,G,H+1),G=H+2,O+=1}return U=Object.keys(U).length===d$?U:null,U},OG=GG.isValidEntry=function($){var E={0:function(U){return U.length>0},1:function(U){if(U==="*")return!0;return U=Number(U),isFinite(U)&&U>0&&U<9007199254740992&&Math.floor(U)===U},2:function(U){return U.length>0},3:function(U){return U.length>0},4:function(U){return U.length>0}};for(var _=0;_<f.length;_+=1){var O=E[_],G=$[f[_]]||"",X=O(G);if(!X)return!1}return!0}});var _O=R((B8,g$)=>{var q8=W("path"),EO=W("fs"),H$=$O();g$.exports=function($,E){var _=H$.getFileName();EO.stat(_,function(O,G){if(O||!H$.usePgPass(G,_))return E(void 0);var X=EO.createReadStream(_);H$.getPassword($,X,E)})};g$.exports.warnTo=H$.warnTo});var JO=R((k8,UO)=>{var HG=W("events").EventEmitter,OO=b(),T$=W("util"),c$=cE(),TG=G$(),YG=w$(),XO=U_(),RG=s(),KG=f$(),WG=q$(),GO=T$.deprecate(()=>{},"Client.activeQuery is deprecated and will be removed in a future version."),LG=T$.deprecate(()=>{},"Client.queryQueue is deprecated and will be removed in a future version."),QG=T$.deprecate(()=>{},"pgpass support is deprecated and will be removed in a future version. You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this funciton you can call the pgpass module in your own code."),jG=T$.deprecate(()=>{},"Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in a future version.");class l$ extends HG{constructor($){super();this.connectionParameters=new YG($),this.user=this.connectionParameters.user,this.database=this.connectionParameters.database,this.port=this.connectionParameters.port,this.host=this.connectionParameters.host,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:this.connectionParameters.password}),this.replication=this.connectionParameters.replication;let E=$||{};if(E.Promise)jG();if(this._Promise=E.Promise||global.Promise,this._types=new TG(E.types),this._ending=!1,this._ended=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this._activeQuery=null,this.enableChannelBinding=Boolean(E.enableChannelBinding),this.connection=E.connection||new KG({stream:E.stream,ssl:this.connectionParameters.ssl,keepAlive:E.keepAlive||!1,keepAliveInitialDelayMillis:E.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||"utf8"}),this._queryQueue=[],this.binary=E.binary||RG.binary,this.processID=null,this.secretKey=null,this.ssl=this.connectionParameters.ssl||!1,this.ssl&&this.ssl.key)Object.defineProperty(this.ssl,"key",{enumerable:!1});this._connectionTimeoutMillis=E.connectionTimeoutMillis||0}get activeQuery(){return GO(),this._activeQuery}set activeQuery($){GO(),this._activeQuery=$}_getActiveQuery(){return this._activeQuery}_errorAllQueries($){let E=(O)=>{process.nextTick(()=>{O.handleError($,this.connection)})},_=this._getActiveQuery();if(_)E(_),this._activeQuery=null;this._queryQueue.forEach(E),this._queryQueue.length=0}_connect($){let E=this,_=this.connection;if(this._connectionCallback=$,this._connecting||this._connected){let O=Error("Client has already been connected. You cannot reuse a client.");process.nextTick(()=>{$(O)});return}if(this._connecting=!0,this._connectionTimeoutMillis>0){if(this.connectionTimeoutHandle=setTimeout(()=>{_._ending=!0,_.stream.destroy(Error("timeout expired"))},this._connectionTimeoutMillis),this.connectionTimeoutHandle.unref)this.connectionTimeoutHandle.unref()}if(this.host&&this.host.indexOf("/")===0)_.connect(this.host+"/.s.PGSQL."+this.port);else _.connect(this.port,this.host);_.on("connect",function(){if(E.ssl)_.requestSsl();else _.startup(E.getStartupConf())}),_.on("sslconnect",function(){_.startup(E.getStartupConf())}),this._attachListeners(_),_.once("end",()=>{let O=this._ending?Error("Connection terminated"):Error("Connection terminated unexpectedly");if(clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(O),this._ended=!0,!this._ending){if(this._connecting&&!this._connectionError)if(this._connectionCallback)this._connectionCallback(O);else this._handleErrorEvent(O);else if(!this._connectionError)this._handleErrorEvent(O)}process.nextTick(()=>{this.emit("end")})})}connect($){if($){this._connect($);return}return new this._Promise((E,_)=>{this._connect((O)=>{if(O)_(O);else E(this)})})}_attachListeners($){$.on("authenticationCleartextPassword",this._handleAuthCleartextPassword.bind(this)),$.on("authenticationMD5Password",this._handleAuthMD5Password.bind(this)),$.on("authenticationSASL",this._handleAuthSASL.bind(this)),$.on("authenticationSASLContinue",this._handleAuthSASLContinue.bind(this)),$.on("authenticationSASLFinal",this._handleAuthSASLFinal.bind(this)),$.on("backendKeyData",this._handleBackendKeyData.bind(this)),$.on("error",this._handleErrorEvent.bind(this)),$.on("errorMessage",this._handleErrorMessage.bind(this)),$.on("readyForQuery",this._handleReadyForQuery.bind(this)),$.on("notice",this._handleNotice.bind(this)),$.on("rowDescription",this._handleRowDescription.bind(this)),$.on("dataRow",this._handleDataRow.bind(this)),$.on("portalSuspended",this._handlePortalSuspended.bind(this)),$.on("emptyQuery",this._handleEmptyQuery.bind(this)),$.on("commandComplete",this._handleCommandComplete.bind(this)),$.on("parseComplete",this._handleParseComplete.bind(this)),$.on("copyInResponse",this._handleCopyInResponse.bind(this)),$.on("copyData",this._handleCopyData.bind(this)),$.on("notification",this._handleNotification.bind(this))}_getPassword($){let E=this.connection;if(typeof this.password==="function")this._Promise.resolve().then(()=>this.password()).then((_)=>{if(_!==void 0){if(typeof _!=="string"){E.emit("error",TypeError("Password must be a string"));return}this.connectionParameters.password=this.password=_}else this.connectionParameters.password=this.password=null;$()}).catch((_)=>{E.emit("error",_)});else if(this.password!==null)$();else try{_O()(this.connectionParameters,(O)=>{if(O!==void 0)QG(),this.connectionParameters.password=this.password=O;$()})}catch(_){this.emit("error",_)}}_handleAuthCleartextPassword($){this._getPassword(()=>{this.connection.password(this.password)})}_handleAuthMD5Password($){this._getPassword(async()=>{try{let E=await WG.postgresMd5PasswordHash(this.user,this.password,$.salt);this.connection.password(E)}catch(E){this.emit("error",E)}})}_handleAuthSASL($){this._getPassword(()=>{try{this.saslSession=c$.startSession($.mechanisms,this.enableChannelBinding&&this.connection.stream),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)}catch(E){this.connection.emit("error",E)}})}async _handleAuthSASLContinue($){try{await c$.continueSession(this.saslSession,this.password,$.data,this.enableChannelBinding&&this.connection.stream),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}catch(E){this.connection.emit("error",E)}}_handleAuthSASLFinal($){try{c$.finalizeSession(this.saslSession,$.data),this.saslSession=null}catch(E){this.connection.emit("error",E)}}_handleBackendKeyData($){this.processID=$.processID,this.secretKey=$.secretKey}_handleReadyForQuery($){if(this._connecting){if(this._connecting=!1,this._connected=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback)this._connectionCallback(null,this),this._connectionCallback=null;this.emit("connect")}let E=this._getActiveQuery();if(this._activeQuery=null,this.readyForQuery=!0,E)E.handleReadyForQuery(this.connection);this._pulseQueryQueue()}_handleErrorWhileConnecting($){if(this._connectionError)return;if(this._connectionError=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback)return this._connectionCallback($);this.emit("error",$)}_handleErrorEvent($){if(this._connecting)return this._handleErrorWhileConnecting($);this._queryable=!1,this._errorAllQueries($),this.emit("error",$)}_handleErrorMessage($){if(this._connecting)return this._handleErrorWhileConnecting($);let E=this._getActiveQuery();if(!E){this._handleErrorEvent($);return}this._activeQuery=null,E.handleError($,this.connection)}_handleRowDescription($){let E=this._getActiveQuery();if(E==null){let _=Error("Received unexpected rowDescription message from backend.");this._handleErrorEvent(_);return}E.handleRowDescription($)}_handleDataRow($){let E=this._getActiveQuery();if(E==null){let _=Error("Received unexpected dataRow message from backend.");this._handleErrorEvent(_);return}E.handleDataRow($)}_handlePortalSuspended($){let E=this._getActiveQuery();if(E==null){let _=Error("Received unexpected portalSuspended message from backend.");this._handleErrorEvent(_);return}E.handlePortalSuspended(this.connection)}_handleEmptyQuery($){let E=this._getActiveQuery();if(E==null){let _=Error("Received unexpected emptyQuery message from backend.");this._handleErrorEvent(_);return}E.handleEmptyQuery(this.connection)}_handleCommandComplete($){let E=this._getActiveQuery();if(E==null){let _=Error("Received unexpected commandComplete message from backend.");this._handleErrorEvent(_);return}E.handleCommandComplete($,this.connection)}_handleParseComplete(){let $=this._getActiveQuery();if($==null){let E=Error("Received unexpected parseComplete message from backend.");this._handleErrorEvent(E);return}if($.name)this.connection.parsedStatements[$.name]=$.text}_handleCopyInResponse($){let E=this._getActiveQuery();if(E==null){let _=Error("Received unexpected copyInResponse message from backend.");this._handleErrorEvent(_);return}E.handleCopyInResponse(this.connection)}_handleCopyData($){let E=this._getActiveQuery();if(E==null){let _=Error("Received unexpected copyData message from backend.");this._handleErrorEvent(_);return}E.handleCopyData($,this.connection)}_handleNotification($){this.emit("notification",$)}_handleNotice($){this.emit("notice",$)}getStartupConf(){let $=this.connectionParameters,E={user:$.user,database:$.database},_=$.application_name||$.fallback_application_name;if(_)E.application_name=_;if($.replication)E.replication=""+$.replication;if($.statement_timeout)E.statement_timeout=String(parseInt($.statement_timeout,10));if($.lock_timeout)E.lock_timeout=String(parseInt($.lock_timeout,10));if($.idle_in_transaction_session_timeout)E.idle_in_transaction_session_timeout=String(parseInt($.idle_in_transaction_session_timeout,10));if($.options)E.options=$.options;return E}cancel($,E){if($.activeQuery===E){let _=this.connection;if(this.host&&this.host.indexOf("/")===0)_.connect(this.host+"/.s.PGSQL."+this.port);else _.connect(this.port,this.host);_.on("connect",function(){_.cancel($.processID,$.secretKey)})}else if($._queryQueue.indexOf(E)!==-1)$._queryQueue.splice($._queryQueue.indexOf(E),1)}setTypeParser($,E,_){return this._types.setTypeParser($,E,_)}getTypeParser($,E){return this._types.getTypeParser($,E)}escapeIdentifier($){return OO.escapeIdentifier($)}escapeLiteral($){return OO.escapeLiteral($)}_pulseQueryQueue(){if(this.readyForQuery===!0){this._activeQuery=this._queryQueue.shift();let $=this._getActiveQuery();if($){this.readyForQuery=!1,this.hasExecuted=!0;let E=$.submit(this.connection);if(E)process.nextTick(()=>{$.handleError(E,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else if(this.hasExecuted)this._activeQuery=null,this.emit("drain")}}query($,E,_){let O,G,X,U,J;if($===null||$===void 0)throw TypeError("Client was passed a null or undefined query");else if(typeof $.submit==="function"){if(X=$.query_timeout||this.connectionParameters.query_timeout,G=O=$,typeof E==="function")O.callback=O.callback||E}else if(X=$.query_timeout||this.connectionParameters.query_timeout,O=new XO($,E,_),!O.callback)G=new this._Promise((Z,H)=>{O.callback=(Y,T)=>Y?H(Y):Z(T)}).catch((Z)=>{throw Error.captureStackTrace(Z),Z});if(X)J=O.callback,U=setTimeout(()=>{let Z=Error("Query read timeout");process.nextTick(()=>{O.handleError(Z,this.connection)}),J(Z),O.callback=()=>{};let H=this._queryQueue.indexOf(O);if(H>-1)this._queryQueue.splice(H,1);this._pulseQueryQueue()},X),O.callback=(Z,H)=>{clearTimeout(U),J(Z,H)};if(this.binary&&!O.binary)O.binary=!0;if(O._result&&!O._result._types)O._result._types=this._types;if(!this._queryable)return process.nextTick(()=>{O.handleError(Error("Client has encountered a connection error and is not queryable"),this.connection)}),G;if(this._ending)return process.nextTick(()=>{O.handleError(Error("Client was closed and is not queryable"),this.connection)}),G;return this._queryQueue.push(O),this._pulseQueryQueue(),G}ref(){this.connection.ref()}unref(){this.connection.unref()}end($){if(this._ending=!0,!this.connection._connecting||this._ended)if($)$();else return this._Promise.resolve();if(this._getActiveQuery()||!this._queryable)this.connection.stream.destroy();else this.connection.end();if($)this.connection.once("end",$);else return new this._Promise((E)=>{this.connection.once("end",E)})}get queryQueue(){return LG(),this._queryQueue}}l$.Query=XO;UO.exports=l$});var KO=R((w8,RO)=>{var NG=W("events").EventEmitter,ZO=function(){},HO=($,E)=>{let _=$.findIndex(E);return _===-1?void 0:$.splice(_,1)[0]};class TO{constructor($,E,_){this.client=$,this.idleListener=E,this.timeoutId=_}}class r{constructor($){this.callback=$}}function FG(){throw Error("Release called on client which has already been released to the pool.")}function Y$($,E){if(E)return{callback:E,result:void 0};let _,O,G=function(U,J){U?_(U):O(J)},X=new $(function(U,J){O=U,_=J}).catch((U)=>{throw Error.captureStackTrace(U),U});return{callback:G,result:X}}function zG($,E){return function _(O){O.client=E,E.removeListener("error",_),E.on("error",()=>{$.log("additional client error after disconnection due to error",O)}),$._remove(E),$.emit("error",O,E)}}class YO extends NG{constructor($,E){super();if(this.options=Object.assign({},$),$!=null&&"password"in $)Object.defineProperty(this.options,"password",{configurable:!0,enumerable:!1,writable:!0,value:$.password});if($!=null&&$.ssl&&$.ssl.key)Object.defineProperty(this.options.ssl,"key",{enumerable:!1});if(this.options.max=this.options.max||this.options.poolSize||10,this.options.min=this.options.min||0,this.options.maxUses=this.options.maxUses||1/0,this.options.allowExitOnIdle=this.options.allowExitOnIdle||!1,this.options.maxLifetimeSeconds=this.options.maxLifetimeSeconds||0,this.log=this.options.log||function(){},this.Client=this.options.Client||E||o$().Client,this.Promise=this.options.Promise||global.Promise,typeof this.options.idleTimeoutMillis>"u")this.options.idleTimeoutMillis=1e4;this._clients=[],this._idle=[],this._expired=new WeakSet,this._pendingQueue=[],this._endCallback=void 0,this.ending=!1,this.ended=!1}_isFull(){return this._clients.length>=this.options.max}_isAboveMin(){return this._clients.length>this.options.min}_pulseQueue(){if(this.log("pulse queue"),this.ended){this.log("pulse queue ended");return}if(this.ending){if(this.log("pulse queue on ending"),this._idle.length)this._idle.slice().map((E)=>{this._remove(E.client)});if(!this._clients.length)this.ended=!0,this._endCallback();return}if(!this._pendingQueue.length){this.log("no queued requests");return}if(!this._idle.length&&this._isFull())return;let $=this._pendingQueue.shift();if(this._idle.length){let E=this._idle.pop();clearTimeout(E.timeoutId);let _=E.client;_.ref&&_.ref();let O=E.idleListener;return this._acquireClient(_,$,O,!1)}if(!this._isFull())return this.newClient($);throw Error("unexpected condition")}_remove($,E){let _=HO(this._idle,(G)=>G.client===$);if(_!==void 0)clearTimeout(_.timeoutId);this._clients=this._clients.filter((G)=>G!==$);let O=this;$.end(()=>{if(O.emit("remove",$),typeof E==="function")E()})}connect($){if(this.ending){let O=Error("Cannot use a pool after calling end on the pool");return $?$(O):this.Promise.reject(O)}let E=Y$(this.Promise,$),_=E.result;if(this._isFull()||this._idle.length){if(this._idle.length)process.nextTick(()=>this._pulseQueue());if(!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new r(E.callback)),_;let O=(U,J,Z)=>{clearTimeout(X),E.callback(U,J,Z)},G=new r(O),X=setTimeout(()=>{HO(this._pendingQueue,(U)=>U.callback===O),G.timedOut=!0,E.callback(Error("timeout exceeded when trying to connect"))},this.options.connectionTimeoutMillis);if(X.unref)X.unref();return this._pendingQueue.push(G),_}return this.newClient(new r(E.callback)),_}newClient($){let E=new this.Client(this.options);this._clients.push(E);let _=zG(this,E);this.log("checking client timeout");let O,G=!1;if(this.options.connectionTimeoutMillis)O=setTimeout(()=>{this.log("ending client due to timeout"),G=!0,E.connection?E.connection.stream.destroy():E.end()},this.options.connectionTimeoutMillis);this.log("connecting new client"),E.connect((X)=>{if(O)clearTimeout(O);if(E.on("error",_),X){if(this.log("client failed to connect",X),this._clients=this._clients.filter((U)=>U!==E),G)X=Error("Connection terminated due to connection timeout",{cause:X});if(this._pulseQueue(),!$.timedOut)$.callback(X,void 0,ZO)}else{if(this.log("new client connected"),this.options.maxLifetimeSeconds!==0){let U=setTimeout(()=>{if(this.log("ending client due to expired lifetime"),this._expired.add(E),this._idle.findIndex((Z)=>Z.client===E)!==-1)this._acquireClient(E,new r((Z,H,Y)=>Y()),_,!1)},this.options.maxLifetimeSeconds*1000);U.unref(),E.once("end",()=>clearTimeout(U))}return this._acquireClient(E,$,_,!0)}})}_acquireClient($,E,_,O){if(O)this.emit("connect",$);if(this.emit("acquire",$),$.release=this._releaseOnce($,_),$.removeListener("error",_),!E.timedOut)if(O&&this.options.verify)this.options.verify($,(G)=>{if(G)return $.release(G),E.callback(G,void 0,ZO);E.callback(void 0,$,$.release)});else E.callback(void 0,$,$.release);else if(O&&this.options.verify)this.options.verify($,$.release);else $.release()}_releaseOnce($,E){let _=!1;return(O)=>{if(_)FG();_=!0,this._release($,E,O)}}_release($,E,_){if($.on("error",E),$._poolUseCount=($._poolUseCount||0)+1,this.emit("release",_,$),_||this.ending||!$._queryable||$._ending||$._poolUseCount>=this.options.maxUses){if($._poolUseCount>=this.options.maxUses)this.log("remove expended client");return this._remove($,this._pulseQueue.bind(this))}if(this._expired.has($))return this.log("remove expired client"),this._expired.delete($),this._remove($,this._pulseQueue.bind(this));let G;if(this.options.idleTimeoutMillis&&this._isAboveMin()){if(G=setTimeout(()=>{if(this._isAboveMin())this.log("remove idle client"),this._remove($,this._pulseQueue.bind(this))},this.options.idleTimeoutMillis),this.options.allowExitOnIdle)G.unref()}if(this.options.allowExitOnIdle)$.unref();this._idle.push(new TO($,E,G)),this._pulseQueue()}query($,E,_){if(typeof $==="function"){let G=Y$(this.Promise,$);return setImmediate(function(){return G.callback(Error("Passing a function as the first parameter to pool.query is not supported"))}),G.result}if(typeof E==="function")_=E,E=void 0;let O=Y$(this.Promise,_);return _=O.callback,this.connect((G,X)=>{if(G)return _(G);let U=!1,J=(Z)=>{if(U)return;U=!0,X.release(Z),_(Z)};X.once("error",J),this.log("dispatching query");try{X.query($,E,(Z,H)=>{if(this.log("query dispatched"),X.removeListener("error",J),U)return;if(U=!0,X.release(Z),Z)return _(Z);return _(void 0,H)})}catch(Z){return X.release(Z),_(Z)}}),O.result}end($){if(this.log("ending"),this.ending){let _=Error("Called end on pool more than once");return $?$(_):this.Promise.reject(_)}this.ending=!0;let E=Y$(this.Promise,$);return this._endCallback=E.callback,this._pulseQueue(),E.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce(($,E)=>$+(this._expired.has(E)?1:0),0)}get totalCount(){return this._clients.length}}RO.exports=YO});var QO=R((x8,LO)=>{var WO=W("events").EventEmitter,PG=W("util"),n$=b(),d=LO.exports=function($,E,_){WO.call(this),$=n$.normalizeQueryConfig($,E,_),this.text=$.text,this.values=$.values,this.name=$.name,this.queryMode=$.queryMode,this.callback=$.callback,this.state="new",this._arrayMode=$.rowMode==="array",this._emitRowEvents=!1,this.on("newListener",function(O){if(O==="row")this._emitRowEvents=!0}.bind(this))};PG.inherits(d,WO);var AG={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"file",sourceLine:"line",sourceFunction:"routine"};d.prototype.handleError=function($){let E=this.native.pq.resultErrorFields();if(E)for(let _ in E){let O=AG[_]||_;$[O]=E[_]}if(this.callback)this.callback($);else this.emit("error",$);this.state="error"};d.prototype.then=function($,E){return this._getPromise().then($,E)};d.prototype.catch=function($){return this._getPromise().catch($)};d.prototype._getPromise=function(){if(this._promise)return this._promise;return this._promise=new Promise(function($,E){this._once("end",$),this._once("error",E)}.bind(this)),this._promise};d.prototype.submit=function($){this.state="running";let E=this;this.native=$.native,$.native.arrayMode=this._arrayMode;let _=function(O,G,X){if($.native.arrayMode=!1,setImmediate(function(){E.emit("_done")}),O)return E.handleError(O);if(E._emitRowEvents)if(X.length>1)G.forEach((U,J)=>{U.forEach((Z)=>{E.emit("row",Z,X[J])})});else G.forEach(function(U){E.emit("row",U,X)});if(E.state="end",E.emit("end",X),E.callback)E.callback(null,X)};if(process.domain)_=process.domain.bind(_);if(this.name){if(this.name.length>63)console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",this.name,this.name.length),console.error("This can cause conflicts and silent errors executing queries");let O=(this.values||[]).map(n$.prepareValue);if($.namedQueries[this.name]){if(this.text&&$.namedQueries[this.name]!==this.text){let G=Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return _(G)}return $.native.execute(this.name,O,_)}return $.native.prepare(this.name,this.text,O.length,function(G){if(G)return _(G);return $.namedQueries[E.name]=E.text,E.native.execute(E.name,O,_)})}else if(this.values){if(!Array.isArray(this.values)){let G=Error("Query values must be an array");return _(G)}let O=this.values.map(n$.prepareValue);$.native.query(this.text,O,_)}else if(this.queryMode==="extended")$.native.query(this.text,[],_);else $.native.query(this.text,_)}});var i$=R((h8,zO)=>{var jO;try{jO=(()=>{throw new Error("Cannot require module "+"pg-native");})()}catch($){throw $}var DG=G$(),NO=W("events").EventEmitter,MG=W("util"),VG=w$(),FO=QO(),A=zO.exports=function($){NO.call(this),$=$||{},this._Promise=$.Promise||global.Promise,this._types=new DG($.types),this.native=new jO({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;let E=this.connectionParameters=new VG($);if($.nativeConnectionString)E.nativeConnectionString=$.nativeConnectionString;this.user=E.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:E.password}),this.database=E.database,this.host=E.host,this.port=E.port,this.namedQueries={}};A.Query=FO;MG.inherits(A,NO);A.prototype._errorAllQueries=function($){let E=(_)=>{process.nextTick(()=>{_.native=this.native,_.handleError($)})};if(this._hasActiveQuery())E(this._activeQuery),this._activeQuery=null;this._queryQueue.forEach(E),this._queryQueue.length=0};A.prototype._connect=function($){let E=this;if(this._connecting){process.nextTick(()=>$(Error("Client has already been connected. You cannot reuse a client.")));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(_,O){if(E.connectionParameters.nativeConnectionString)O=E.connectionParameters.nativeConnectionString;if(_)return $(_);E.native.connect(O,function(G){if(G)return E.native.end(),$(G);E._connected=!0,E.native.on("error",function(X){E._queryable=!1,E._errorAllQueries(X),E.emit("error",X)}),E.native.on("notification",function(X){E.emit("notification",{channel:X.relname,payload:X.extra})}),E.emit("connect"),E._pulseQueryQueue(!0),$(null,this)})})};A.prototype.connect=function($){if($){this._connect($);return}return new this._Promise((E,_)=>{this._connect((O)=>{if(O)_(O);else E(this)})})};A.prototype.query=function($,E,_){let O,G,X,U,J;if($===null||$===void 0)throw TypeError("Client was passed a null or undefined query");else if(typeof $.submit==="function"){if(X=$.query_timeout||this.connectionParameters.query_timeout,G=O=$,typeof E==="function")$.callback=E}else if(X=$.query_timeout||this.connectionParameters.query_timeout,O=new FO($,E,_),!O.callback){let Z,H;G=new this._Promise((Y,T)=>{Z=Y,H=T}).catch((Y)=>{throw Error.captureStackTrace(Y),Y}),O.callback=(Y,T)=>Y?H(Y):Z(T)}if(X)J=O.callback,U=setTimeout(()=>{let Z=Error("Query read timeout");process.nextTick(()=>{O.handleError(Z,this.connection)}),J(Z),O.callback=()=>{};let H=this._queryQueue.indexOf(O);if(H>-1)this._queryQueue.splice(H,1);this._pulseQueryQueue()},X),O.callback=(Z,H)=>{clearTimeout(U),J(Z,H)};if(!this._queryable)return O.native=this.native,process.nextTick(()=>{O.handleError(Error("Client has encountered a connection error and is not queryable"))}),G;if(this._ending)return O.native=this.native,process.nextTick(()=>{O.handleError(Error("Client was closed and is not queryable"))}),G;return this._queryQueue.push(O),this._pulseQueryQueue(),G};A.prototype.end=function($){let E=this;if(this._ending=!0,!this._connected)this.once("connect",this.end.bind(this,$));let _;if(!$)_=new this._Promise(function(O,G){$=(X)=>X?G(X):O()});return this.native.end(function(){E._errorAllQueries(Error("Connection terminated")),process.nextTick(()=>{if(E.emit("end"),$)$()})}),_};A.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!=="error"&&this._activeQuery.state!=="end"};A.prototype._pulseQueryQueue=function($){if(!this._connected)return;if(this._hasActiveQuery())return;let E=this._queryQueue.shift();if(!E){if(!$)this.emit("drain");return}this._activeQuery=E,E.submit(this);let _=this;E.once("_done",function(){_._pulseQueryQueue()})};A.prototype.cancel=function($){if(this._activeQuery===$)this.native.cancel(function(){});else if(this._queryQueue.indexOf($)!==-1)this._queryQueue.splice(this._queryQueue.indexOf($),1)};A.prototype.ref=function(){};A.prototype.unref=function(){};A.prototype.setTypeParser=function($,E,_){return this._types.setTypeParser($,E,_)};A.prototype.getTypeParser=function($,E){return this._types.getTypeParser($,E)}});var o$=R((b8,R$)=>{var SG=JO(),CG=s(),IG=f$(),qG=x$(),BG=b(),kG=KO(),wG=G$(),{DatabaseError:xG}=m$(),{escapeIdentifier:hG,escapeLiteral:bG}=b(),yG=($)=>{return class extends kG{constructor(_){super(_,$)}}},PO=function($){this.defaults=CG,this.Client=$,this.Query=this.Client.Query,this.Pool=yG(this.Client),this._pools=[],this.Connection=IG,this.types=i(),this.DatabaseError=xG,this.TypeOverrides=wG,this.escapeIdentifier=hG,this.escapeLiteral=bG,this.Result=qG,this.utils=BG},AO=SG,DO=!1;try{DO=!!process.env.NODE_PG_FORCE_NATIVE}catch{}if(DO)AO=i$();R$.exports=new PO(AO);Object.defineProperty(R$.exports,"native",{configurable:!0,enumerable:!1,get(){let $=null;try{$=new PO(i$())}catch(E){if(E.code!=="MODULE_NOT_FOUND")throw E}return Object.defineProperty(R$.exports,"native",{value:$}),$}})});var g=($)=>{return["checkpoints","checkpoint_blobs","checkpoint_migrations","checkpoint_writes"].reduce((E,_)=>{return E[_]=`"${$}".${_}`,E},{})},a$=($)=>{let E=g($);return{SELECT_SQL:`select
|
|
10
|
+
thread_id,
|
|
11
|
+
checkpoint,
|
|
12
|
+
checkpoint_ns,
|
|
13
|
+
checkpoint_id,
|
|
14
|
+
parent_checkpoint_id,
|
|
15
|
+
metadata,
|
|
16
|
+
(
|
|
17
|
+
select array_agg(array[bl.channel::bytea, bl.type::bytea, bl.blob])
|
|
18
|
+
from jsonb_each_text(checkpoint -> 'channel_versions')
|
|
19
|
+
inner join ${E.checkpoint_blobs} bl
|
|
20
|
+
on bl.thread_id = cp.thread_id
|
|
21
|
+
and bl.checkpoint_ns = cp.checkpoint_ns
|
|
22
|
+
and bl.channel = jsonb_each_text.key
|
|
23
|
+
and bl.version = jsonb_each_text.value
|
|
24
|
+
) as channel_values,
|
|
25
|
+
(
|
|
26
|
+
select
|
|
27
|
+
array_agg(array[cw.task_id::text::bytea, cw.channel::bytea, cw.type::bytea, cw.blob] order by cw.task_id, cw.idx)
|
|
28
|
+
from ${E.checkpoint_writes} cw
|
|
29
|
+
where cw.thread_id = cp.thread_id
|
|
30
|
+
and cw.checkpoint_ns = cp.checkpoint_ns
|
|
31
|
+
and cw.checkpoint_id = cp.checkpoint_id
|
|
32
|
+
) as pending_writes
|
|
33
|
+
from ${E.checkpoints} cp `,SELECT_PENDING_SENDS_SQL:`select
|
|
34
|
+
checkpoint_id,
|
|
35
|
+
array_agg(array[cw.type::bytea, cw.blob] order by cw.task_id, cw.idx) as pending_sends
|
|
36
|
+
from ${E.checkpoint_writes} cw
|
|
37
|
+
where cw.thread_id = $1
|
|
38
|
+
and cw.checkpoint_id = any($2)
|
|
39
|
+
and cw.channel = '${u}'
|
|
40
|
+
group by cw.checkpoint_id
|
|
41
|
+
`,UPSERT_CHECKPOINT_BLOBS_SQL:`INSERT INTO ${E.checkpoint_blobs} (thread_id, checkpoint_ns, channel, version, type, blob)
|
|
42
|
+
VALUES ($1, $2, $3, $4, $5, $6)
|
|
43
|
+
ON CONFLICT (thread_id, checkpoint_ns, channel, version) DO NOTHING
|
|
44
|
+
`,UPSERT_CHECKPOINTS_SQL:`INSERT INTO ${E.checkpoints} (thread_id, checkpoint_ns, checkpoint_id, parent_checkpoint_id, checkpoint, metadata)
|
|
45
|
+
VALUES ($1, $2, $3, $4, $5, $6)
|
|
46
|
+
ON CONFLICT (thread_id, checkpoint_ns, checkpoint_id)
|
|
47
|
+
DO UPDATE SET
|
|
48
|
+
checkpoint = EXCLUDED.checkpoint,
|
|
49
|
+
metadata = EXCLUDED.metadata;
|
|
50
|
+
`,UPSERT_CHECKPOINT_WRITES_SQL:`INSERT INTO ${E.checkpoint_writes} (thread_id, checkpoint_ns, checkpoint_id, task_id, idx, channel, type, blob)
|
|
51
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
52
|
+
ON CONFLICT (thread_id, checkpoint_ns, checkpoint_id, task_id, idx) DO UPDATE SET
|
|
53
|
+
channel = EXCLUDED.channel,
|
|
54
|
+
type = EXCLUDED.type,
|
|
55
|
+
blob = EXCLUDED.blob;
|
|
56
|
+
`,INSERT_CHECKPOINT_WRITES_SQL:`INSERT INTO ${E.checkpoint_writes} (thread_id, checkpoint_ns, checkpoint_id, task_id, idx, channel, type, blob)
|
|
57
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
58
|
+
ON CONFLICT (thread_id, checkpoint_ns, checkpoint_id, task_id, idx) DO NOTHING
|
|
59
|
+
`,DELETE_CHECKPOINTS_SQL:`DELETE FROM ${E.checkpoints} WHERE thread_id = $1`,DELETE_CHECKPOINT_BLOBS_SQL:`DELETE FROM ${E.checkpoint_blobs} WHERE thread_id = $1`,DELETE_CHECKPOINT_WRITES_SQL:`DELETE FROM ${E.checkpoint_writes} WHERE thread_id = $1`}};var r$=($)=>{let E=g($);return[`CREATE TABLE IF NOT EXISTS ${E.checkpoint_migrations} (
|
|
60
|
+
v INTEGER PRIMARY KEY
|
|
61
|
+
);`,`CREATE TABLE IF NOT EXISTS ${E.checkpoints} (
|
|
62
|
+
thread_id TEXT NOT NULL,
|
|
63
|
+
checkpoint_ns TEXT NOT NULL DEFAULT '',
|
|
64
|
+
checkpoint_id TEXT NOT NULL,
|
|
65
|
+
parent_checkpoint_id TEXT,
|
|
66
|
+
type TEXT,
|
|
67
|
+
checkpoint JSONB NOT NULL,
|
|
68
|
+
metadata JSONB NOT NULL DEFAULT '{}',
|
|
69
|
+
PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id)
|
|
70
|
+
);`,`CREATE TABLE IF NOT EXISTS ${E.checkpoint_blobs} (
|
|
71
|
+
thread_id TEXT NOT NULL,
|
|
72
|
+
checkpoint_ns TEXT NOT NULL DEFAULT '',
|
|
73
|
+
channel TEXT NOT NULL,
|
|
74
|
+
version TEXT NOT NULL,
|
|
75
|
+
type TEXT NOT NULL,
|
|
76
|
+
blob BYTEA,
|
|
77
|
+
PRIMARY KEY (thread_id, checkpoint_ns, channel, version)
|
|
78
|
+
);`,`CREATE TABLE IF NOT EXISTS ${E.checkpoint_writes} (
|
|
79
|
+
thread_id TEXT NOT NULL,
|
|
80
|
+
checkpoint_ns TEXT NOT NULL DEFAULT '',
|
|
81
|
+
checkpoint_id TEXT NOT NULL,
|
|
82
|
+
task_id TEXT NOT NULL,
|
|
83
|
+
idx INTEGER NOT NULL,
|
|
84
|
+
channel TEXT NOT NULL,
|
|
85
|
+
type TEXT,
|
|
86
|
+
blob BYTEA NOT NULL,
|
|
87
|
+
PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id, task_id, idx)
|
|
88
|
+
);`,`ALTER TABLE ${E.checkpoint_blobs} ALTER COLUMN blob DROP not null;`]};var M=vG(o$(),1),y8=M.default.Client,v8=M.default.Pool,p8=M.default.Connection,m8=M.default.types,f8=M.default.Query,d8=M.default.DatabaseError,u8=M.default.escapeIdentifier,g8=M.default.escapeLiteral,c8=M.default.Result,l8=M.default.TypeOverrides,o8=M.default.defaults,MO=M.default;var pG={schema:"public"},mG=($)=>{return{...$,schema:$?.schema??pG.schema}},{Pool:fG}=MO,CO=class $ extends VO{pool;options;SQL_STATEMENTS;isSetup;constructor(E,_,O){super(_);this.pool=E,this.isSetup=!1,this.options=mG(O),this.SQL_STATEMENTS=a$(this.options.schema)}static fromConnString(E,_){return new $(new fG({connectionString:E}),void 0,_)}async setup(){let E=await this.pool.connect(),_=g(this.options.schema);try{await E.query(`CREATE SCHEMA IF NOT EXISTS "${this.options.schema}"`);let O=-1,G=r$(this.options.schema);try{let X=await E.query(`SELECT v FROM ${_.checkpoint_migrations} ORDER BY v DESC LIMIT 1`);if(X.rows.length>0)O=X.rows[0].v}catch(X){if(typeof X==="object"&&X!==null&&"code"in X&&typeof X.code==="string"&&X.code==="42P01")O=-1;else throw X}for(let X=O+1;X<G.length;X+=1)await E.query(G[X]),await E.query(`INSERT INTO ${_.checkpoint_migrations} (v) VALUES ($1)`,[X])}finally{E.release()}}async _loadCheckpoint(E,_){return{...E,channel_values:await this._loadBlobs(_)}}async _loadBlobs(E){if(!E||E.length===0)return{};let _=new TextDecoder,O=await Promise.all(E.filter(([,G])=>_.decode(G)!=="empty").map(async([G,X,U])=>[_.decode(G),await this.serde.loadsTyped(_.decode(X),U)]));return Object.fromEntries(O)}async _loadMetadata(E){let[_,O]=await this.serde.dumpsTyped(E);return this.serde.loadsTyped(_,O)}async _loadWrites(E){let _=new TextDecoder;return E?await Promise.all(E.map(async([O,G,X,U])=>[_.decode(O),_.decode(G),await this.serde.loadsTyped(_.decode(X),U)])):[]}async _dumpBlobs(E,_,O,G){if(Object.keys(G).length===0)return[];return Promise.all(Object.entries(G).map(async([X,U])=>{let[J,Z]=X in O?await this.serde.dumpsTyped(O[X]):["empty",null];return[E,_,X,U.toString(),J,Z?new Uint8Array(Z):void 0]}))}_dumpCheckpoint(E){let _={...E};if("channel_values"in _)delete _.channel_values;return _}async _dumpMetadata(E){let[,_]=await this.serde.dumpsTyped(E);return JSON.parse(new TextDecoder().decode(_).replace(/\0/g,""))}async _dumpWrites(E,_,O,G,X){return Promise.all(X.map(async([U,J],Z)=>{let[H,Y]=await this.serde.dumpsTyped(J);return[E,_,O,G,s$[U]??Z,U,H,new Uint8Array(Y)]}))}_searchWhere(E,_,O){let G=[],X=[];if(E?.configurable?.thread_id)G.push(`thread_id = $${X.length+1}`),X.push(E.configurable.thread_id);if(E?.configurable?.checkpoint_ns!==void 0&&E?.configurable?.checkpoint_ns!==null)G.push(`checkpoint_ns = $${X.length+1}`),X.push(E.configurable.checkpoint_ns);if(E?.configurable?.checkpoint_id)G.push(`checkpoint_id = $${X.length+1}`),X.push(E.configurable.checkpoint_id);if(_&&Object.keys(_).length>0)G.push(`metadata @> $${X.length+1}`),X.push(JSON.stringify(_));if(O?.configurable?.checkpoint_id!==void 0)G.push(`checkpoint_id < $${X.length+1}`),X.push(O.configurable.checkpoint_id);return[G.length>0?`WHERE ${G.join(" AND ")}`:"",X]}async getTuple(E){let{thread_id:_,checkpoint_ns:O="",checkpoint_id:G}=E.configurable??{},X,U;if(G)U="WHERE thread_id = $1 AND checkpoint_ns = $2 AND checkpoint_id = $3",X=[_,O,G];else U="WHERE thread_id = $1 AND checkpoint_ns = $2 ORDER BY checkpoint_id DESC LIMIT 1",X=[_,O];let[J]=(await this.pool.query(this.SQL_STATEMENTS.SELECT_SQL+U,X)).rows;if(J===void 0)return;if(J.checkpoint.v<4&&J.parent_checkpoint_id!=null){let[H]=(await this.pool.query(this.SQL_STATEMENTS.SELECT_PENDING_SENDS_SQL,[_,[J.parent_checkpoint_id]])).rows;if(H!=null)await this._migratePendingSends(H.pending_sends,J)}let Z=await this._loadCheckpoint(J.checkpoint,J.channel_values);return{config:{configurable:{thread_id:_,checkpoint_ns:O,checkpoint_id:J.checkpoint_id}},checkpoint:Z,metadata:await this._loadMetadata(J.metadata),parentConfig:J.parent_checkpoint_id?{configurable:{thread_id:_,checkpoint_ns:O,checkpoint_id:J.parent_checkpoint_id}}:void 0,pendingWrites:await this._loadWrites(J.pending_writes)}}async*list(E,_){let{filter:O,before:G,limit:X}=_??{},[U,J]=this._searchWhere(E,O,G),Z=`${this.SQL_STATEMENTS.SELECT_SQL}${U} ORDER BY checkpoint_id DESC`;if(X!==void 0)Z+=` LIMIT ${Number.parseInt(X.toString(),10)}`;let H=await this.pool.query(Z,J),Y=H.rows.filter((T)=>T.checkpoint.v<4&&T.parent_checkpoint_id!=null);if(Y.length>0){let T=await this.pool.query(this.SQL_STATEMENTS.SELECT_PENDING_SENDS_SQL,[Y[0].thread_id,Y.map((Q)=>Q.parent_checkpoint_id)]),K=Y.reduce((Q,C)=>{if(!C.parent_checkpoint_id)return Q;return Q[C.parent_checkpoint_id]??=[],Q[C.parent_checkpoint_id].push(C),Q},{});for(let Q of T.rows)for(let C of K[Q.checkpoint_id])await this._migratePendingSends(Q.pending_sends,C)}for(let T of H.rows)yield{config:{configurable:{thread_id:T.thread_id,checkpoint_ns:T.checkpoint_ns,checkpoint_id:T.checkpoint_id}},checkpoint:await this._loadCheckpoint(T.checkpoint,T.channel_values),metadata:await this._loadMetadata(T.metadata),parentConfig:T.parent_checkpoint_id?{configurable:{thread_id:T.thread_id,checkpoint_ns:T.checkpoint_ns,checkpoint_id:T.parent_checkpoint_id}}:void 0,pendingWrites:await this._loadWrites(T.pending_writes)}}async _migratePendingSends(E,_){let O=new TextEncoder,G=new TextDecoder,X=_,[U,J]=await this.serde.dumpsTyped(await Promise.all(E.map(([Z,H])=>this.serde.loadsTyped(G.decode(Z),H))));X.channel_values??=[],X.channel_values.push([O.encode(u),O.encode(U),J]),X.checkpoint.channel_versions[u]=Object.keys(_.checkpoint.channel_versions).length>0?SO(...Object.values(_.checkpoint.channel_versions)):this.getNextVersion(void 0)}async put(E,_,O,G){if(E.configurable===void 0)throw Error('Missing "configurable" field in "config" param');let{thread_id:X,checkpoint_ns:U="",checkpoint_id:J}=E.configurable,Z={configurable:{thread_id:X,checkpoint_ns:U,checkpoint_id:_.id}},H=await this.pool.connect(),Y=this._dumpCheckpoint(_);try{await H.query("BEGIN");let T=await this._dumpBlobs(X,U,_.channel_values,G);for(let K of T)await H.query(this.SQL_STATEMENTS.UPSERT_CHECKPOINT_BLOBS_SQL,K);await H.query(this.SQL_STATEMENTS.UPSERT_CHECKPOINTS_SQL,[X,U,_.id,J,Y,await this._dumpMetadata(O)]),await H.query("COMMIT")}catch(T){throw await H.query("ROLLBACK"),T}finally{H.release()}return Z}async putWrites(E,_,O){let G=_.every((J)=>(J[0]in s$))?this.SQL_STATEMENTS.UPSERT_CHECKPOINT_WRITES_SQL:this.SQL_STATEMENTS.INSERT_CHECKPOINT_WRITES_SQL,X=await this._dumpWrites(E.configurable?.thread_id,E.configurable?.checkpoint_ns,E.configurable?.checkpoint_id,O,_),U=await this.pool.connect();try{await U.query("BEGIN");for await(let J of X)await U.query(G,J);await U.query("COMMIT")}catch(J){throw await U.query("ROLLBACK"),J}finally{U.release()}}async end(){return this.pool.end()}async deleteThread(E){let _=await this.pool.connect();try{await _.query("BEGIN"),await _.query(this.SQL_STATEMENTS.DELETE_CHECKPOINT_BLOBS_SQL,[E]),await _.query(this.SQL_STATEMENTS.DELETE_CHECKPOINTS_SQL,[E]),await _.query(this.SQL_STATEMENTS.DELETE_CHECKPOINT_WRITES_SQL,[E]),await _.query("COMMIT")}catch(O){throw await _.query("ROLLBACK"),O}finally{_.release()}}};var $3=async()=>{let $=CO.fromConnString(process.env.DATABASE_URL);if(process.env.DATABASE_INIT==="true")console.debug("LG | Initializing postgres checkpoint"),await $.setup();return $};export{$3 as createPGCheckpoint};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mb as a}from"./chunk-9k57afdm.js";import"./chunk-cze71w02.js";export{a as FileSystemPluginStore};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createRequire as k}from"node:module";var g=Object.create;var{getPrototypeOf:h,defineProperty:f,getOwnPropertyNames:i}=Object;var j=Object.prototype.hasOwnProperty;var l=(a,b,c)=>{c=a!=null?g(h(a)):{};let d=b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c;for(let e of i(a))if(!j.call(d,e))f(d,e,{get:()=>a[e],enumerable:!0});return d};var m=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var n=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0,configurable:!0,set:(d)=>b[c]=()=>d})};var o=(a,b)=>()=>(a&&(b=a(a=0)),b);var q=k(import.meta.url);
|
|
2
|
+
export{l as nb,m as ob,n as pb,o as qb,q as rb};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{nb as K0,ob as P,rb as R}from"./chunk-cze71w02.js";var C=P((j4,h0)=>{var g0=["nodebuffer","arraybuffer","fragments"],w0=typeof Blob<"u";if(w0)g0.push("blob");h0.exports={BINARY_TYPES:g0,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:w0,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var n=P((Y4,X0)=>{var{EMPTY_BUFFER:l5}=C(),F0=Buffer[Symbol.species];function p5(J,K){if(J.length===0)return l5;if(J.length===1)return J[0];let X=Buffer.allocUnsafe(K),Z=0;for(let $=0;$<J.length;$++){let Q=J[$];X.set(Q,Z),Z+=Q.length}if(Z<K)return new F0(X.buffer,X.byteOffset,Z);return X}function m0(J,K,X,Z,$){for(let Q=0;Q<$;Q++)X[Z+Q]=J[Q]^K[Q&3]}function f0(J,K){for(let X=0;X<J.length;X++)J[X]^=K[X&3]}function b5(J){if(J.length===J.buffer.byteLength)return J.buffer;return J.buffer.slice(J.byteOffset,J.byteOffset+J.length)}function D0(J){if(D0.readOnly=!0,Buffer.isBuffer(J))return J;let K;if(J instanceof ArrayBuffer)K=new F0(J);else if(ArrayBuffer.isView(J))K=new F0(J.buffer,J.byteOffset,J.byteLength);else K=Buffer.from(J),D0.readOnly=!1;return K}X0.exports={concat:p5,mask:m0,toArrayBuffer:b5,toBuffer:D0,unmask:f0};if(!process.env.WS_NO_BUFFER_UTIL)try{let J=(()=>{throw new Error("Cannot require module "+"bufferutil");})();X0.exports.mask=function(K,X,Z,$,Q){if(Q<48)m0(K,X,Z,$,Q);else J.mask(K,X,Z,$,Q)},X0.exports.unmask=function(K,X){if(K.length<32)f0(K,X);else J.unmask(K,X)}}catch(J){}});var b0=P((V4,p0)=>{var u0=Symbol("kDone"),O0=Symbol("kRun");class l0{constructor(J){this[u0]=()=>{this.pending--,this[O0]()},this.concurrency=J||1/0,this.jobs=[],this.pending=0}add(J){this.jobs.push(J),this[O0]()}[O0](){if(this.pending===this.concurrency)return;if(this.jobs.length){let J=this.jobs.shift();this.pending++,J(this[u0])}}}p0.exports=l0});var a=P((_4,n0)=>{var r=R("zlib"),k0=n(),k5=b0(),{kStatusCode:i0}=C(),i5=Buffer[Symbol.species],d5=Buffer.from([0,0,255,255]),$0=Symbol("permessage-deflate"),q=Symbol("total-length"),f=Symbol("callback"),L=Symbol("buffers"),u=Symbol("error"),Z0;class d0{constructor(J,K,X){if(this._maxPayload=X|0,this._options=J||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!K,this._deflate=null,this._inflate=null,this.params=null,!Z0){let Z=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Z0=new k5(Z)}}static get extensionName(){return"permessage-deflate"}offer(){let J={};if(this._options.serverNoContextTakeover)J.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)J.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)J.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)J.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)J.client_max_window_bits=!0;return J}accept(J){return J=this.normalizeParams(J),this.params=this._isServer?this.acceptAsServer(J):this.acceptAsClient(J),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let J=this._deflate[f];if(this._deflate.close(),this._deflate=null,J)J(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(J){let K=this._options,X=J.find((Z)=>{if(K.serverNoContextTakeover===!1&&Z.server_no_context_takeover||Z.server_max_window_bits&&(K.serverMaxWindowBits===!1||typeof K.serverMaxWindowBits==="number"&&K.serverMaxWindowBits>Z.server_max_window_bits)||typeof K.clientMaxWindowBits==="number"&&!Z.client_max_window_bits)return!1;return!0});if(!X)throw Error("None of the extension offers can be accepted");if(K.serverNoContextTakeover)X.server_no_context_takeover=!0;if(K.clientNoContextTakeover)X.client_no_context_takeover=!0;if(typeof K.serverMaxWindowBits==="number")X.server_max_window_bits=K.serverMaxWindowBits;if(typeof K.clientMaxWindowBits==="number")X.client_max_window_bits=K.clientMaxWindowBits;else if(X.client_max_window_bits===!0||K.clientMaxWindowBits===!1)delete X.client_max_window_bits;return X}acceptAsClient(J){let K=J[0];if(this._options.clientNoContextTakeover===!1&&K.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!K.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")K.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&K.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return K}normalizeParams(J){return J.forEach((K)=>{Object.keys(K).forEach((X)=>{let Z=K[X];if(Z.length>1)throw Error(`Parameter "${X}" must have only a single value`);if(Z=Z[0],X==="client_max_window_bits"){if(Z!==!0){let $=+Z;if(!Number.isInteger($)||$<8||$>15)throw TypeError(`Invalid value for parameter "${X}": ${Z}`);Z=$}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${X}": ${Z}`)}else if(X==="server_max_window_bits"){let $=+Z;if(!Number.isInteger($)||$<8||$>15)throw TypeError(`Invalid value for parameter "${X}": ${Z}`);Z=$}else if(X==="client_no_context_takeover"||X==="server_no_context_takeover"){if(Z!==!0)throw TypeError(`Invalid value for parameter "${X}": ${Z}`)}else throw Error(`Unknown parameter "${X}"`);K[X]=Z})}),J}decompress(J,K,X){Z0.add((Z)=>{this._decompress(J,K,($,Q)=>{Z(),X($,Q)})})}compress(J,K,X){Z0.add((Z)=>{this._compress(J,K,($,Q)=>{Z(),X($,Q)})})}_decompress(J,K,X){let Z=this._isServer?"client":"server";if(!this._inflate){let $=`${Z}_max_window_bits`,Q=typeof this.params[$]!=="number"?r.Z_DEFAULT_WINDOWBITS:this.params[$];this._inflate=r.createInflateRaw({...this._options.zlibInflateOptions,windowBits:Q}),this._inflate[$0]=this,this._inflate[q]=0,this._inflate[L]=[],this._inflate.on("error",n5),this._inflate.on("data",c0)}if(this._inflate[f]=X,this._inflate.write(J),K)this._inflate.write(d5);this._inflate.flush(()=>{let $=this._inflate[u];if($){this._inflate.close(),this._inflate=null,X($);return}let Q=k0.concat(this._inflate[L],this._inflate[q]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[q]=0,this._inflate[L]=[],K&&this.params[`${Z}_no_context_takeover`])this._inflate.reset();X(null,Q)})}_compress(J,K,X){let Z=this._isServer?"server":"client";if(!this._deflate){let $=`${Z}_max_window_bits`,Q=typeof this.params[$]!=="number"?r.Z_DEFAULT_WINDOWBITS:this.params[$];this._deflate=r.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:Q}),this._deflate[q]=0,this._deflate[L]=[],this._deflate.on("data",c5)}this._deflate[f]=X,this._deflate.write(J),this._deflate.flush(r.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let $=k0.concat(this._deflate[L],this._deflate[q]);if(K)$=new i5($.buffer,$.byteOffset,$.length-4);if(this._deflate[f]=null,this._deflate[q]=0,this._deflate[L]=[],K&&this.params[`${Z}_no_context_takeover`])this._deflate.reset();X(null,$)})}}n0.exports=d0;function c5(J){this[L].push(J),this[q]+=J.length}function c0(J){if(this[q]+=J.length,this[$0]._maxPayload<1||this[q]<=this[$0]._maxPayload){this[L].push(J);return}this[u]=RangeError("Max payload size exceeded"),this[u].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[u][i0]=1009,this.removeListener("data",c0),this.reset()}function n5(J){if(this[$0]._inflate=null,this[u]){this[f](this[u]);return}J[i0]=1007,this[f](J)}});var l=P((N4,Q0)=>{var{isUtf8:r0}=R("buffer"),{hasBlob:r5}=C(),a5=[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 s5(J){return J>=1000&&J<=1014&&J!==1004&&J!==1005&&J!==1006||J>=3000&&J<=4999}function P0(J){let K=J.length,X=0;while(X<K)if((J[X]&128)===0)X++;else if((J[X]&224)===192){if(X+1===K||(J[X+1]&192)!==128||(J[X]&254)===192)return!1;X+=2}else if((J[X]&240)===224){if(X+2>=K||(J[X+1]&192)!==128||(J[X+2]&192)!==128||J[X]===224&&(J[X+1]&224)===128||J[X]===237&&(J[X+1]&224)===160)return!1;X+=3}else if((J[X]&248)===240){if(X+3>=K||(J[X+1]&192)!==128||(J[X+2]&192)!==128||(J[X+3]&192)!==128||J[X]===240&&(J[X+1]&240)===128||J[X]===244&&J[X+1]>143||J[X]>244)return!1;X+=4}else return!1;return!0}function o5(J){return r5&&typeof J==="object"&&typeof J.arrayBuffer==="function"&&typeof J.type==="string"&&typeof J.stream==="function"&&(J[Symbol.toStringTag]==="Blob"||J[Symbol.toStringTag]==="File")}Q0.exports={isBlob:o5,isValidStatusCode:s5,isValidUTF8:P0,tokenChars:a5};if(r0)Q0.exports.isValidUTF8=function(J){return J.length<24?P0(J):r0(J)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let J=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();Q0.exports.isValidUTF8=function(K){return K.length<32?P0(K):J(K)}}catch(J){}});var T0=P((H4,e0)=>{var{Writable:t5}=R("stream"),a0=a(),{BINARY_TYPES:e5,EMPTY_BUFFER:s0,kStatusCode:J1,kWebSocket:K1}=C(),{concat:M0,toArrayBuffer:X1,unmask:Z1}=n(),{isValidStatusCode:$1,isValidUTF8:o0}=l(),G0=Buffer[Symbol.species];class t0 extends t5{constructor(J={}){super();this._allowSynchronousEvents=J.allowSynchronousEvents!==void 0?J.allowSynchronousEvents:!0,this._binaryType=J.binaryType||e5[0],this._extensions=J.extensions||{},this._isServer=!!J.isServer,this._maxPayload=J.maxPayload|0,this._skipUTF8Validation=!!J.skipUTF8Validation,this[K1]=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(J,K,X){if(this._opcode===8&&this._state==0)return X();this._bufferedBytes+=J.length,this._buffers.push(J),this.startLoop(X)}consume(J){if(this._bufferedBytes-=J,J===this._buffers[0].length)return this._buffers.shift();if(J<this._buffers[0].length){let X=this._buffers[0];return this._buffers[0]=new G0(X.buffer,X.byteOffset+J,X.length-J),new G0(X.buffer,X.byteOffset,J)}let K=Buffer.allocUnsafe(J);do{let X=this._buffers[0],Z=K.length-J;if(J>=X.length)K.set(this._buffers.shift(),Z);else K.set(new Uint8Array(X.buffer,X.byteOffset,J),Z),this._buffers[0]=new G0(X.buffer,X.byteOffset+J,X.length-J);J-=X.length}while(J>0);return K}startLoop(J){this._loop=!0;do switch(this._state){case 0:this.getInfo(J);break;case 1:this.getPayloadLength16(J);break;case 2:this.getPayloadLength64(J);break;case 3:this.getMask();break;case 4:this.getData(J);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)J()}getInfo(J){if(this._bufferedBytes<2){this._loop=!1;return}let K=this.consume(2);if((K[0]&48)!==0){let Z=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");J(Z);return}let X=(K[0]&64)===64;if(X&&!this._extensions[a0.extensionName]){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");J(Z);return}if(this._fin=(K[0]&128)===128,this._opcode=K[0]&15,this._payloadLength=K[1]&127,this._opcode===0){if(X){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");J(Z);return}if(!this._fragmented){let Z=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");J(Z);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let Z=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");J(Z);return}this._compressed=X}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let Z=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");J(Z);return}if(X){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");J(Z);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let Z=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");J(Z);return}}else{let Z=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");J(Z);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(K[1]&128)===128,this._isServer){if(!this._masked){let Z=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");J(Z);return}}else if(this._masked){let Z=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");J(Z);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength(J)}getPayloadLength16(J){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(J)}getPayloadLength64(J){if(this._bufferedBytes<8){this._loop=!1;return}let K=this.consume(8),X=K.readUInt32BE(0);if(X>Math.pow(2,21)-1){let Z=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");J(Z);return}this._payloadLength=X*Math.pow(2,32)+K.readUInt32BE(4),this.haveLength(J)}haveLength(J){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let K=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");J(K);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(J){let K=s0;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(K=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)Z1(K,this._mask)}if(this._opcode>7){this.controlMessage(K,J);return}if(this._compressed){this._state=5,this.decompress(K,J);return}if(K.length)this._messageLength=this._totalPayloadLength,this._fragments.push(K);this.dataMessage(J)}decompress(J,K){this._extensions[a0.extensionName].decompress(J,this._fin,(Z,$)=>{if(Z)return K(Z);if($.length){if(this._messageLength+=$.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let Q=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");K(Q);return}this._fragments.push($)}if(this.dataMessage(K),this._state===0)this.startLoop(K)})}dataMessage(J){if(!this._fin){this._state=0;return}let K=this._messageLength,X=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let Z;if(this._binaryType==="nodebuffer")Z=M0(X,K);else if(this._binaryType==="arraybuffer")Z=X1(M0(X,K));else if(this._binaryType==="blob")Z=new Blob(X);else Z=X;if(this._allowSynchronousEvents)this.emit("message",Z,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Z,!0),this._state=0,this.startLoop(J)})}else{let Z=M0(X,K);if(!this._skipUTF8Validation&&!o0(Z)){let $=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");J($);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",Z,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Z,!1),this._state=0,this.startLoop(J)})}}controlMessage(J,K){if(this._opcode===8){if(J.length===0)this._loop=!1,this.emit("conclude",1005,s0),this.end();else{let X=J.readUInt16BE(0);if(!$1(X)){let $=this.createError(RangeError,`invalid status code ${X}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");K($);return}let Z=new G0(J.buffer,J.byteOffset+2,J.length-2);if(!this._skipUTF8Validation&&!o0(Z)){let $=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");K($);return}this._loop=!1,this.emit("conclude",X,Z),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",J),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",J),this._state=0,this.startLoop(K)})}createError(J,K,X,Z,$){this._loop=!1,this._errored=!0;let Q=new J(X?`Invalid WebSocket frame: ${K}`:K);return Error.captureStackTrace(Q,this.createError),Q.code=$,Q[J1]=Z,Q}}e0.exports=t0});var B0=P((A4,X5)=>{var{Duplex:R4}=R("stream"),{randomFillSync:Q1}=R("crypto"),J5=a(),{EMPTY_BUFFER:G1,kWebSocket:I1,NOOP:z1}=C(),{isBlob:p,isValidStatusCode:j1}=l(),{mask:K5,toBuffer:S}=n(),T=Symbol("kByteLength"),Y1=Buffer.alloc(4),v,b=8192,x=0,V1=1,_1=2;class W{constructor(J,K,X){if(this._extensions=K||{},X)this._generateMask=X,this._maskBuffer=Buffer.alloc(4);this._socket=J,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=x,this.onerror=z1,this[I1]=void 0}static frame(J,K){let X,Z=!1,$=2,Q=!1;if(K.mask){if(X=K.maskBuffer||Y1,K.generateMask)K.generateMask(X);else{if(b===8192){if(v===void 0)v=Buffer.alloc(8192);Q1(v,0,8192),b=0}X[0]=v[b++],X[1]=v[b++],X[2]=v[b++],X[3]=v[b++]}Q=(X[0]|X[1]|X[2]|X[3])===0,$=6}let G;if(typeof J==="string")if((!K.mask||Q)&&K[T]!==void 0)G=K[T];else J=Buffer.from(J),G=J.length;else G=J.length,Z=K.mask&&K.readOnly&&!Q;let z=G;if(G>=65536)$+=8,z=127;else if(G>125)$+=2,z=126;let I=Buffer.allocUnsafe(Z?G+$:$);if(I[0]=K.fin?K.opcode|128:K.opcode,K.rsv1)I[0]|=64;if(I[1]=z,z===126)I.writeUInt16BE(G,2);else if(z===127)I[2]=I[3]=0,I.writeUIntBE(G,4,6);if(!K.mask)return[I,J];if(I[1]|=128,I[$-4]=X[0],I[$-3]=X[1],I[$-2]=X[2],I[$-1]=X[3],Q)return[I,J];if(Z)return K5(J,X,I,$,G),[I];return K5(J,X,J,0,G),[I,J]}close(J,K,X,Z){let $;if(J===void 0)$=G1;else if(typeof J!=="number"||!j1(J))throw TypeError("First argument must be a valid error code number");else if(K===void 0||!K.length)$=Buffer.allocUnsafe(2),$.writeUInt16BE(J,0);else{let G=Buffer.byteLength(K);if(G>123)throw RangeError("The message must not be greater than 123 bytes");if($=Buffer.allocUnsafe(2+G),$.writeUInt16BE(J,0),typeof K==="string")$.write(K,2);else $.set(K,2)}let Q={[T]:$.length,fin:!0,generateMask:this._generateMask,mask:X,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==x)this.enqueue([this.dispatch,$,!1,Q,Z]);else this.sendFrame(W.frame($,Q),Z)}ping(J,K,X){let Z,$;if(typeof J==="string")Z=Buffer.byteLength(J),$=!1;else if(p(J))Z=J.size,$=!1;else J=S(J),Z=J.length,$=S.readOnly;if(Z>125)throw RangeError("The data size must not be greater than 125 bytes");let Q={[T]:Z,fin:!0,generateMask:this._generateMask,mask:K,maskBuffer:this._maskBuffer,opcode:9,readOnly:$,rsv1:!1};if(p(J))if(this._state!==x)this.enqueue([this.getBlobData,J,!1,Q,X]);else this.getBlobData(J,!1,Q,X);else if(this._state!==x)this.enqueue([this.dispatch,J,!1,Q,X]);else this.sendFrame(W.frame(J,Q),X)}pong(J,K,X){let Z,$;if(typeof J==="string")Z=Buffer.byteLength(J),$=!1;else if(p(J))Z=J.size,$=!1;else J=S(J),Z=J.length,$=S.readOnly;if(Z>125)throw RangeError("The data size must not be greater than 125 bytes");let Q={[T]:Z,fin:!0,generateMask:this._generateMask,mask:K,maskBuffer:this._maskBuffer,opcode:10,readOnly:$,rsv1:!1};if(p(J))if(this._state!==x)this.enqueue([this.getBlobData,J,!1,Q,X]);else this.getBlobData(J,!1,Q,X);else if(this._state!==x)this.enqueue([this.dispatch,J,!1,Q,X]);else this.sendFrame(W.frame(J,Q),X)}send(J,K,X){let Z=this._extensions[J5.extensionName],$=K.binary?2:1,Q=K.compress,G,z;if(typeof J==="string")G=Buffer.byteLength(J),z=!1;else if(p(J))G=J.size,z=!1;else J=S(J),G=J.length,z=S.readOnly;if(this._firstFragment){if(this._firstFragment=!1,Q&&Z&&Z.params[Z._isServer?"server_no_context_takeover":"client_no_context_takeover"])Q=G>=Z._threshold;this._compress=Q}else Q=!1,$=0;if(K.fin)this._firstFragment=!0;let I={[T]:G,fin:K.fin,generateMask:this._generateMask,mask:K.mask,maskBuffer:this._maskBuffer,opcode:$,readOnly:z,rsv1:Q};if(p(J))if(this._state!==x)this.enqueue([this.getBlobData,J,this._compress,I,X]);else this.getBlobData(J,this._compress,I,X);else if(this._state!==x)this.enqueue([this.dispatch,J,this._compress,I,X]);else this.dispatch(J,this._compress,I,X)}getBlobData(J,K,X,Z){this._bufferedBytes+=X[T],this._state=_1,J.arrayBuffer().then(($)=>{if(this._socket.destroyed){let G=Error("The socket was closed while the blob was being read");process.nextTick(x0,this,G,Z);return}this._bufferedBytes-=X[T];let Q=S($);if(!K)this._state=x,this.sendFrame(W.frame(Q,X),Z),this.dequeue();else this.dispatch(Q,K,X,Z)}).catch(($)=>{process.nextTick(N1,this,$,Z)})}dispatch(J,K,X,Z){if(!K){this.sendFrame(W.frame(J,X),Z);return}let $=this._extensions[J5.extensionName];this._bufferedBytes+=X[T],this._state=V1,$.compress(J,X.fin,(Q,G)=>{if(this._socket.destroyed){let z=Error("The socket was closed while data was being compressed");x0(this,z,Z);return}this._bufferedBytes-=X[T],this._state=x,X.readOnly=!1,this.sendFrame(W.frame(G,X),Z),this.dequeue()})}dequeue(){while(this._state===x&&this._queue.length){let J=this._queue.shift();this._bufferedBytes-=J[3][T],Reflect.apply(J[0],this,J.slice(1))}}enqueue(J){this._bufferedBytes+=J[3][T],this._queue.push(J)}sendFrame(J,K){if(J.length===2)this._socket.cork(),this._socket.write(J[0]),this._socket.write(J[1],K),this._socket.uncork();else this._socket.write(J[0],K)}}X5.exports=W;function x0(J,K,X){if(typeof X==="function")X(K);for(let Z=0;Z<J._queue.length;Z++){let $=J._queue[Z],Q=$[$.length-1];if(typeof Q==="function")Q(K)}}function N1(J,K,X){x0(J,K,X),J.onerror(K)}});var V5=P((F4,Y5)=>{var{kForOnEventAttribute:s,kListener:C0}=C(),Z5=Symbol("kCode"),$5=Symbol("kData"),Q5=Symbol("kError"),G5=Symbol("kMessage"),I5=Symbol("kReason"),k=Symbol("kTarget"),z5=Symbol("kType"),j5=Symbol("kWasClean");class E{constructor(J){this[k]=null,this[z5]=J}get target(){return this[k]}get type(){return this[z5]}}Object.defineProperty(E.prototype,"target",{enumerable:!0});Object.defineProperty(E.prototype,"type",{enumerable:!0});class i extends E{constructor(J,K={}){super(J);this[Z5]=K.code===void 0?0:K.code,this[I5]=K.reason===void 0?"":K.reason,this[j5]=K.wasClean===void 0?!1:K.wasClean}get code(){return this[Z5]}get reason(){return this[I5]}get wasClean(){return this[j5]}}Object.defineProperty(i.prototype,"code",{enumerable:!0});Object.defineProperty(i.prototype,"reason",{enumerable:!0});Object.defineProperty(i.prototype,"wasClean",{enumerable:!0});class o extends E{constructor(J,K={}){super(J);this[Q5]=K.error===void 0?null:K.error,this[G5]=K.message===void 0?"":K.message}get error(){return this[Q5]}get message(){return this[G5]}}Object.defineProperty(o.prototype,"error",{enumerable:!0});Object.defineProperty(o.prototype,"message",{enumerable:!0});class z0 extends E{constructor(J,K={}){super(J);this[$5]=K.data===void 0?null:K.data}get data(){return this[$5]}}Object.defineProperty(z0.prototype,"data",{enumerable:!0});var H1={addEventListener(J,K,X={}){for(let $ of this.listeners(J))if(!X[s]&&$[C0]===K&&!$[s])return;let Z;if(J==="message")Z=function(Q,G){let z=new z0("message",{data:G?Q:Q.toString()});z[k]=this,I0(K,this,z)};else if(J==="close")Z=function(Q,G){let z=new i("close",{code:Q,reason:G.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});z[k]=this,I0(K,this,z)};else if(J==="error")Z=function(Q){let G=new o("error",{error:Q,message:Q.message});G[k]=this,I0(K,this,G)};else if(J==="open")Z=function(){let Q=new E("open");Q[k]=this,I0(K,this,Q)};else return;if(Z[s]=!!X[s],Z[C0]=K,X.once)this.once(J,Z);else this.on(J,Z)},removeEventListener(J,K){for(let X of this.listeners(J))if(X[C0]===K&&!X[s]){this.removeListener(J,X);break}}};Y5.exports={CloseEvent:i,ErrorEvent:o,Event:E,EventTarget:H1,MessageEvent:z0};function I0(J,K,X){if(typeof J==="object"&&J.handleEvent)J.handleEvent.call(J,X);else J.call(K,X)}});var q0=P((D4,_5)=>{var{tokenChars:t}=l();function B(J,K,X){if(J[K]===void 0)J[K]=[X];else J[K].push(X)}function R1(J){let K=Object.create(null),X=Object.create(null),Z=!1,$=!1,Q=!1,G,z,I=-1,V=-1,_=-1,Y=0;for(;Y<J.length;Y++)if(V=J.charCodeAt(Y),G===void 0)if(_===-1&&t[V]===1){if(I===-1)I=Y}else if(Y!==0&&(V===32||V===9)){if(_===-1&&I!==-1)_=Y}else if(V===59||V===44){if(I===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(_===-1)_=Y;let D=J.slice(I,_);if(V===44)B(K,D,X),X=Object.create(null);else G=D;I=_=-1}else throw SyntaxError(`Unexpected character at index ${Y}`);else if(z===void 0)if(_===-1&&t[V]===1){if(I===-1)I=Y}else if(V===32||V===9){if(_===-1&&I!==-1)_=Y}else if(V===59||V===44){if(I===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(_===-1)_=Y;if(B(X,J.slice(I,_),!0),V===44)B(K,G,X),X=Object.create(null),G=void 0;I=_=-1}else if(V===61&&I!==-1&&_===-1)z=J.slice(I,Y),I=_=-1;else throw SyntaxError(`Unexpected character at index ${Y}`);else if($){if(t[V]!==1)throw SyntaxError(`Unexpected character at index ${Y}`);if(I===-1)I=Y;else if(!Z)Z=!0;$=!1}else if(Q)if(t[V]===1){if(I===-1)I=Y}else if(V===34&&I!==-1)Q=!1,_=Y;else if(V===92)$=!0;else throw SyntaxError(`Unexpected character at index ${Y}`);else if(V===34&&J.charCodeAt(Y-1)===61)Q=!0;else if(_===-1&&t[V]===1){if(I===-1)I=Y}else if(I!==-1&&(V===32||V===9)){if(_===-1)_=Y}else if(V===59||V===44){if(I===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(_===-1)_=Y;let D=J.slice(I,_);if(Z)D=D.replace(/\\/g,""),Z=!1;if(B(X,z,D),V===44)B(K,G,X),X=Object.create(null),G=void 0;z=void 0,I=_=-1}else throw SyntaxError(`Unexpected character at index ${Y}`);if(I===-1||Q||V===32||V===9)throw SyntaxError("Unexpected end of input");if(_===-1)_=Y;let F=J.slice(I,_);if(G===void 0)B(K,F,X);else{if(z===void 0)B(X,F,!0);else if(Z)B(X,z,F.replace(/\\/g,""));else B(X,z,F);B(K,G,X)}return K}function A1(J){return Object.keys(J).map((K)=>{let X=J[K];if(!Array.isArray(X))X=[X];return X.map((Z)=>{return[K].concat(Object.keys(Z).map(($)=>{let Q=Z[$];if(!Array.isArray(Q))Q=[Q];return Q.map((G)=>G===!0?$:`${$}=${G}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}_5.exports={format:A1,parse:R1}});var _0=P((M4,B5)=>{var F1=R("events"),D1=R("https"),O1=R("http"),R5=R("net"),P1=R("tls"),{randomBytes:M1,createHash:T1}=R("crypto"),{Duplex:O4,Readable:P4}=R("stream"),{URL:U0}=R("url"),y=a(),x1=T0(),B1=B0(),{isBlob:C1}=l(),{BINARY_TYPES:N5,CLOSE_TIMEOUT:q1,EMPTY_BUFFER:j0,GUID:U1,kForOnEventAttribute:L0,kListener:L1,kStatusCode:W1,kWebSocket:A,NOOP:A5}=C(),{EventTarget:{addEventListener:E1,removeEventListener:y1}}=V5(),{format:S1,parse:v1}=q0(),{toBuffer:g1}=n(),F5=Symbol("kAborted"),W0=[8,13],U=["CONNECTING","OPEN","CLOSING","CLOSED"],w1=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class j extends F1{constructor(J,K,X){super();if(this._binaryType=N5[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=j0,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=j.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,J!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,K===void 0)K=[];else if(!Array.isArray(K))if(typeof K==="object"&&K!==null)X=K,K=[];else K=[K];D5(this,J,K,X)}else this._autoPong=X.autoPong,this._closeTimeout=X.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(J){if(!N5.includes(J))return;if(this._binaryType=J,this._receiver)this._receiver._binaryType=J}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(J,K,X){let Z=new x1({allowSynchronousEvents:X.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:X.maxPayload,skipUTF8Validation:X.skipUTF8Validation}),$=new B1(J,this._extensions,X.generateMask);if(this._receiver=Z,this._sender=$,this._socket=J,Z[A]=this,$[A]=this,J[A]=this,Z.on("conclude",f1),Z.on("drain",u1),Z.on("error",l1),Z.on("message",p1),Z.on("ping",b1),Z.on("pong",k1),$.onerror=i1,J.setTimeout)J.setTimeout(0);if(J.setNoDelay)J.setNoDelay();if(K.length>0)J.unshift(K);J.on("close",M5),J.on("data",V0),J.on("end",T5),J.on("error",x5),this._readyState=j.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=j.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[y.extensionName])this._extensions[y.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=j.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(J,K){if(this.readyState===j.CLOSED)return;if(this.readyState===j.CONNECTING){M(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===j.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=j.CLOSING,this._sender.close(J,K,!this._isServer,(X)=>{if(X)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),P5(this)}pause(){if(this.readyState===j.CONNECTING||this.readyState===j.CLOSED)return;this._paused=!0,this._socket.pause()}ping(J,K,X){if(this.readyState===j.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof J==="function")X=J,J=K=void 0;else if(typeof K==="function")X=K,K=void 0;if(typeof J==="number")J=J.toString();if(this.readyState!==j.OPEN){E0(this,J,X);return}if(K===void 0)K=!this._isServer;this._sender.ping(J||j0,K,X)}pong(J,K,X){if(this.readyState===j.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof J==="function")X=J,J=K=void 0;else if(typeof K==="function")X=K,K=void 0;if(typeof J==="number")J=J.toString();if(this.readyState!==j.OPEN){E0(this,J,X);return}if(K===void 0)K=!this._isServer;this._sender.pong(J||j0,K,X)}resume(){if(this.readyState===j.CONNECTING||this.readyState===j.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send(J,K,X){if(this.readyState===j.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof K==="function")X=K,K={};if(typeof J==="number")J=J.toString();if(this.readyState!==j.OPEN){E0(this,J,X);return}let Z={binary:typeof J!=="string",mask:!this._isServer,compress:!0,fin:!0,...K};if(!this._extensions[y.extensionName])Z.compress=!1;this._sender.send(J||j0,Z,X)}terminate(){if(this.readyState===j.CLOSED)return;if(this.readyState===j.CONNECTING){M(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=j.CLOSING,this._socket.destroy()}}Object.defineProperty(j,"CONNECTING",{enumerable:!0,value:U.indexOf("CONNECTING")});Object.defineProperty(j.prototype,"CONNECTING",{enumerable:!0,value:U.indexOf("CONNECTING")});Object.defineProperty(j,"OPEN",{enumerable:!0,value:U.indexOf("OPEN")});Object.defineProperty(j.prototype,"OPEN",{enumerable:!0,value:U.indexOf("OPEN")});Object.defineProperty(j,"CLOSING",{enumerable:!0,value:U.indexOf("CLOSING")});Object.defineProperty(j.prototype,"CLOSING",{enumerable:!0,value:U.indexOf("CLOSING")});Object.defineProperty(j,"CLOSED",{enumerable:!0,value:U.indexOf("CLOSED")});Object.defineProperty(j.prototype,"CLOSED",{enumerable:!0,value:U.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((J)=>{Object.defineProperty(j.prototype,J,{enumerable:!0})});["open","error","close","message"].forEach((J)=>{Object.defineProperty(j.prototype,`on${J}`,{enumerable:!0,get(){for(let K of this.listeners(J))if(K[L0])return K[L1];return null},set(K){for(let X of this.listeners(J))if(X[L0]){this.removeListener(J,X);break}if(typeof K!=="function")return;this.addEventListener(J,K,{[L0]:!0})}})});j.prototype.addEventListener=E1;j.prototype.removeEventListener=y1;B5.exports=j;function D5(J,K,X,Z){let $={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:q1,protocolVersion:W0[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...Z,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(J._autoPong=$.autoPong,J._closeTimeout=$.closeTimeout,!W0.includes($.protocolVersion))throw RangeError(`Unsupported protocol version: ${$.protocolVersion} (supported versions: ${W0.join(", ")})`);let Q;if(K instanceof U0)Q=K;else try{Q=new U0(K)}catch(N){throw SyntaxError(`Invalid URL: ${K}`)}if(Q.protocol==="http:")Q.protocol="ws:";else if(Q.protocol==="https:")Q.protocol="wss:";J._url=Q.href;let G=Q.protocol==="wss:",z=Q.protocol==="ws+unix:",I;if(Q.protocol!=="ws:"&&!G&&!z)I=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(z&&!Q.pathname)I="The URL's pathname is empty";else if(Q.hash)I="The URL contains a fragment identifier";if(I){let N=SyntaxError(I);if(J._redirects===0)throw N;else{Y0(J,N);return}}let V=G?443:80,_=M1(16).toString("base64"),Y=G?D1.request:O1.request,F=new Set,D;if($.createConnection=$.createConnection||(G?m1:h1),$.defaultPort=$.defaultPort||V,$.port=Q.port||V,$.host=Q.hostname.startsWith("[")?Q.hostname.slice(1,-1):Q.hostname,$.headers={...$.headers,"Sec-WebSocket-Version":$.protocolVersion,"Sec-WebSocket-Key":_,Connection:"Upgrade",Upgrade:"websocket"},$.path=Q.pathname+Q.search,$.timeout=$.handshakeTimeout,$.perMessageDeflate)D=new y($.perMessageDeflate!==!0?$.perMessageDeflate:{},!1,$.maxPayload),$.headers["Sec-WebSocket-Extensions"]=S1({[y.extensionName]:D.offer()});if(X.length){for(let N of X){if(typeof N!=="string"||!w1.test(N)||F.has(N))throw SyntaxError("An invalid or duplicated subprotocol was specified");F.add(N)}$.headers["Sec-WebSocket-Protocol"]=X.join(",")}if($.origin)if($.protocolVersion<13)$.headers["Sec-WebSocket-Origin"]=$.origin;else $.headers.Origin=$.origin;if(Q.username||Q.password)$.auth=`${Q.username}:${Q.password}`;if(z){let N=$.path.split(":");$.socketPath=N[0],$.path=N[1]}let H;if($.followRedirects){if(J._redirects===0){J._originalIpc=z,J._originalSecure=G,J._originalHostOrSocketPath=z?$.socketPath:Q.host;let N=Z&&Z.headers;if(Z={...Z,headers:{}},N)for(let[O,h]of Object.entries(N))Z.headers[O.toLowerCase()]=h}else if(J.listenerCount("redirect")===0){let N=z?J._originalIpc?$.socketPath===J._originalHostOrSocketPath:!1:J._originalIpc?!1:Q.host===J._originalHostOrSocketPath;if(!N||J._originalSecure&&!G){if(delete $.headers.authorization,delete $.headers.cookie,!N)delete $.headers.host;$.auth=void 0}}if($.auth&&!Z.headers.authorization)Z.headers.authorization="Basic "+Buffer.from($.auth).toString("base64");if(H=J._req=Y($),J._redirects)J.emit("redirect",J.url,H)}else H=J._req=Y($);if($.timeout)H.on("timeout",()=>{M(J,H,"Opening handshake has timed out")});if(H.on("error",(N)=>{if(H===null||H[F5])return;H=J._req=null,Y0(J,N)}),H.on("response",(N)=>{let O=N.headers.location,h=N.statusCode;if(O&&$.followRedirects&&h>=300&&h<400){if(++J._redirects>$.maxRedirects){M(J,H,"Maximum redirects exceeded");return}H.abort();let d;try{d=new U0(O,K)}catch(y0){let m=SyntaxError(`Invalid URL: ${O}`);Y0(J,m);return}D5(J,d,X,Z)}else if(!J.emit("unexpected-response",H,N))M(J,H,`Unexpected server response: ${N.statusCode}`)}),H.on("upgrade",(N,O,h)=>{if(J.emit("upgrade",N),J.readyState!==j.CONNECTING)return;H=J._req=null;let d=N.headers.upgrade;if(d===void 0||d.toLowerCase()!=="websocket"){M(J,O,"Invalid Upgrade header");return}let y0=T1("sha1").update(_+U1).digest("base64");if(N.headers["sec-websocket-accept"]!==y0){M(J,O,"Invalid Sec-WebSocket-Accept header");return}let m=N.headers["sec-websocket-protocol"],c;if(m!==void 0){if(!F.size)c="Server sent a subprotocol but none was requested";else if(!F.has(m))c="Server sent an invalid subprotocol"}else if(F.size)c="Server sent no subprotocol";if(c){M(J,O,c);return}if(m)J._protocol=m;let S0=N.headers["sec-websocket-extensions"];if(S0!==void 0){if(!D){M(J,O,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let R0;try{R0=v1(S0)}catch(A0){M(J,O,"Invalid Sec-WebSocket-Extensions header");return}let v0=Object.keys(R0);if(v0.length!==1||v0[0]!==y.extensionName){M(J,O,"Server indicated an extension that was not requested");return}try{D.accept(R0[y.extensionName])}catch(A0){M(J,O,"Invalid Sec-WebSocket-Extensions header");return}J._extensions[y.extensionName]=D}J.setSocket(O,h,{allowSynchronousEvents:$.allowSynchronousEvents,generateMask:$.generateMask,maxPayload:$.maxPayload,skipUTF8Validation:$.skipUTF8Validation})}),$.finishRequest)$.finishRequest(H,J);else H.end()}function Y0(J,K){J._readyState=j.CLOSING,J._errorEmitted=!0,J.emit("error",K),J.emitClose()}function h1(J){return J.path=J.socketPath,R5.connect(J)}function m1(J){if(J.path=void 0,!J.servername&&J.servername!=="")J.servername=R5.isIP(J.host)?"":J.host;return P1.connect(J)}function M(J,K,X){J._readyState=j.CLOSING;let Z=Error(X);if(Error.captureStackTrace(Z,M),K.setHeader){if(K[F5]=!0,K.abort(),K.socket&&!K.socket.destroyed)K.socket.destroy();process.nextTick(Y0,J,Z)}else K.destroy(Z),K.once("error",J.emit.bind(J,"error")),K.once("close",J.emitClose.bind(J))}function E0(J,K,X){if(K){let Z=C1(K)?K.size:g1(K).length;if(J._socket)J._sender._bufferedBytes+=Z;else J._bufferedAmount+=Z}if(X){let Z=Error(`WebSocket is not open: readyState ${J.readyState} (${U[J.readyState]})`);process.nextTick(X,Z)}}function f1(J,K){let X=this[A];if(X._closeFrameReceived=!0,X._closeMessage=K,X._closeCode=J,X._socket[A]===void 0)return;if(X._socket.removeListener("data",V0),process.nextTick(O5,X._socket),J===1005)X.close();else X.close(J,K)}function u1(){let J=this[A];if(!J.isPaused)J._socket.resume()}function l1(J){let K=this[A];if(K._socket[A]!==void 0)K._socket.removeListener("data",V0),process.nextTick(O5,K._socket),K.close(J[W1]);if(!K._errorEmitted)K._errorEmitted=!0,K.emit("error",J)}function H5(){this[A].emitClose()}function p1(J,K){this[A].emit("message",J,K)}function b1(J){let K=this[A];if(K._autoPong)K.pong(J,!this._isServer,A5);K.emit("ping",J)}function k1(J){this[A].emit("pong",J)}function O5(J){J.resume()}function i1(J){let K=this[A];if(K.readyState===j.CLOSED)return;if(K.readyState===j.OPEN)K._readyState=j.CLOSING,P5(K);if(this._socket.end(),!K._errorEmitted)K._errorEmitted=!0,K.emit("error",J)}function P5(J){J._closeTimer=setTimeout(J._socket.destroy.bind(J._socket),J._closeTimeout)}function M5(){let J=this[A];if(this.removeListener("close",M5),this.removeListener("data",V0),this.removeListener("end",T5),J._readyState=j.CLOSING,!this._readableState.endEmitted&&!J._closeFrameReceived&&!J._receiver._writableState.errorEmitted&&this._readableState.length!==0){let K=this.read(this._readableState.length);J._receiver.write(K)}if(J._receiver.end(),this[A]=void 0,clearTimeout(J._closeTimer),J._receiver._writableState.finished||J._receiver._writableState.errorEmitted)J.emitClose();else J._receiver.on("error",H5),J._receiver.on("finish",H5)}function V0(J){if(!this[A]._receiver.write(J))this.pause()}function T5(){let J=this[A];J._readyState=j.CLOSING,J._receiver.end(),this.end()}function x5(){let J=this[A];if(this.removeListener("error",x5),this.on("error",A5),J)J._readyState=j.CLOSING,this.destroy()}});var L5=P((x4,U5)=>{var T4=_0(),{Duplex:d1}=R("stream");function C5(J){J.emit("close")}function c1(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function q5(J){if(this.removeListener("error",q5),this.destroy(),this.listenerCount("error")===0)this.emit("error",J)}function n1(J,K){let X=!0,Z=new d1({...K,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return J.on("message",function(Q,G){let z=!G&&Z._readableState.objectMode?Q.toString():Q;if(!Z.push(z))J.pause()}),J.once("error",function(Q){if(Z.destroyed)return;X=!1,Z.destroy(Q)}),J.once("close",function(){if(Z.destroyed)return;Z.push(null)}),Z._destroy=function($,Q){if(J.readyState===J.CLOSED){Q($),process.nextTick(C5,Z);return}let G=!1;if(J.once("error",function(I){G=!0,Q(I)}),J.once("close",function(){if(!G)Q($);process.nextTick(C5,Z)}),X)J.terminate()},Z._final=function($){if(J.readyState===J.CONNECTING){J.once("open",function(){Z._final($)});return}if(J._socket===null)return;if(J._socket._writableState.finished){if($(),Z._readableState.endEmitted)Z.destroy()}else J._socket.once("finish",function(){$()}),J.close()},Z._read=function(){if(J.isPaused)J.resume()},Z._write=function($,Q,G){if(J.readyState===J.CONNECTING){J.once("open",function(){Z._write($,Q,G)});return}J.send($,G)},Z.on("end",c1),Z.on("error",q5),Z}U5.exports=n1});var E5=P((B4,W5)=>{var{tokenChars:r1}=l();function a1(J){let K=new Set,X=-1,Z=-1,$=0;for($;$<J.length;$++){let G=J.charCodeAt($);if(Z===-1&&r1[G]===1){if(X===-1)X=$}else if($!==0&&(G===32||G===9)){if(Z===-1&&X!==-1)Z=$}else if(G===44){if(X===-1)throw SyntaxError(`Unexpected character at index ${$}`);if(Z===-1)Z=$;let z=J.slice(X,Z);if(K.has(z))throw SyntaxError(`The "${z}" subprotocol is duplicated`);K.add(z),X=Z=-1}else throw SyntaxError(`Unexpected character at index ${$}`)}if(X===-1||Z!==-1)throw SyntaxError("Unexpected end of input");let Q=J.slice(X,$);if(K.has(Q))throw SyntaxError(`The "${Q}" subprotocol is duplicated`);return K.add(Q),K}W5.exports={parse:a1}});var w5=P((q4,g5)=>{var s1=R("events"),N0=R("http"),{Duplex:C4}=R("stream"),{createHash:o1}=R("crypto"),y5=q0(),g=a(),t1=E5(),e1=_0(),{CLOSE_TIMEOUT:J4,GUID:K4,kWebSocket:X4}=C(),Z4=/^[+/0-9A-Za-z]{22}==$/;class v5 extends s1{constructor(J,K){super();if(J={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:J4,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:e1,...J},J.port==null&&!J.server&&!J.noServer||J.port!=null&&(J.server||J.noServer)||J.server&&J.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(J.port!=null)this._server=N0.createServer((X,Z)=>{let $=N0.STATUS_CODES[426];Z.writeHead(426,{"Content-Length":$.length,"Content-Type":"text/plain"}),Z.end($)}),this._server.listen(J.port,J.host,J.backlog,K);else if(J.server)this._server=J.server;if(this._server){let X=this.emit.bind(this,"connection");this._removeListeners=$4(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(Z,$,Q)=>{this.handleUpgrade(Z,$,Q,X)}})}if(J.perMessageDeflate===!0)J.perMessageDeflate={};if(J.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=J,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(J){if(this._state===2){if(J)this.once("close",()=>{J(Error("The server is not running"))});process.nextTick(e,this);return}if(J)this.once("close",J);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(e,this);else this._shouldEmitClose=!0;else process.nextTick(e,this)}else{let K=this._server;this._removeListeners(),this._removeListeners=this._server=null,K.close(()=>{e(this)})}}shouldHandle(J){if(this.options.path){let K=J.url.indexOf("?");if((K!==-1?J.url.slice(0,K):J.url)!==this.options.path)return!1}return!0}handleUpgrade(J,K,X,Z){K.on("error",S5);let $=J.headers["sec-websocket-key"],Q=J.headers.upgrade,G=+J.headers["sec-websocket-version"];if(J.method!=="GET"){w(this,J,K,405,"Invalid HTTP method");return}if(Q===void 0||Q.toLowerCase()!=="websocket"){w(this,J,K,400,"Invalid Upgrade header");return}if($===void 0||!Z4.test($)){w(this,J,K,400,"Missing or invalid Sec-WebSocket-Key header");return}if(G!==13&&G!==8){w(this,J,K,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(J)){J0(K,400);return}let z=J.headers["sec-websocket-protocol"],I=new Set;if(z!==void 0)try{I=t1.parse(z)}catch(Y){w(this,J,K,400,"Invalid Sec-WebSocket-Protocol header");return}let V=J.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&V!==void 0){let Y=new g(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let F=y5.parse(V);if(F[g.extensionName])Y.accept(F[g.extensionName]),_[g.extensionName]=Y}catch(F){w(this,J,K,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let Y={origin:J.headers[`${G===8?"sec-websocket-origin":"origin"}`],secure:!!(J.socket.authorized||J.socket.encrypted),req:J};if(this.options.verifyClient.length===2){this.options.verifyClient(Y,(F,D,H,N)=>{if(!F)return J0(K,D||401,H,N);this.completeUpgrade(_,$,I,J,K,X,Z)});return}if(!this.options.verifyClient(Y))return J0(K,401)}this.completeUpgrade(_,$,I,J,K,X,Z)}completeUpgrade(J,K,X,Z,$,Q,G){if(!$.readable||!$.writable)return $.destroy();if($[X4])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return J0($,503);let I=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${o1("sha1").update(K+K4).digest("base64")}`],V=new this.options.WebSocket(null,void 0,this.options);if(X.size){let _=this.options.handleProtocols?this.options.handleProtocols(X,Z):X.values().next().value;if(_)I.push(`Sec-WebSocket-Protocol: ${_}`),V._protocol=_}if(J[g.extensionName]){let _=J[g.extensionName].params,Y=y5.format({[g.extensionName]:[_]});I.push(`Sec-WebSocket-Extensions: ${Y}`),V._extensions=J}if(this.emit("headers",I,Z),$.write(I.concat(`\r
|
|
2
|
+
`).join(`\r
|
|
3
|
+
`)),$.removeListener("error",S5),V.setSocket($,Q,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(V),V.on("close",()=>{if(this.clients.delete(V),this._shouldEmitClose&&!this.clients.size)process.nextTick(e,this)});G(V,Z)}}g5.exports=v5;function $4(J,K){for(let X of Object.keys(K))J.on(X,K[X]);return function(){for(let Z of Object.keys(K))J.removeListener(Z,K[Z])}}function e(J){J._state=2,J.emit("close")}function S5(){this.destroy()}function J0(J,K,X,Z){X=X||N0.STATUS_CODES[K],Z={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(X),...Z},J.once("finish",J.destroy),J.end(`HTTP/1.1 ${K} ${N0.STATUS_CODES[K]}\r
|
|
4
|
+
`+Object.keys(Z).map(($)=>`${$}: ${Z[$]}`).join(`\r
|
|
5
|
+
`)+`\r
|
|
6
|
+
\r
|
|
7
|
+
`+X)}function w(J,K,X,Z,$,Q){if(J.listenerCount("wsClientError")){let G=Error($);Error.captureStackTrace(G,w),J.emit("wsClientError",G,X,K)}else J0(X,Z,$,Q)}});var Q4=K0(L5(),1),G4=K0(T0(),1),I4=K0(B0(),1),h5=K0(_0(),1),z4=K0(w5(),1);var m5=h5.default;var H0=global;H0.WebSocket||=m5;H0.window||=global;H0.self||=global;H0.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__=[{type:1,value:7,isEnabled:!0},{type:2,value:"InternalApp",isEnabled:!0,isValid:!0},{type:2,value:"InternalAppContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalStdoutContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalStderrContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalStdinContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalFocusContext",isEnabled:!0,isValid:!0}];import f5 from"react-devtools-core";f5.initialize();f5.connectToDevTools();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hb as D}from"./chunk-yaa4eesd.js";import{rb as $}from"./chunk-cze71w02.js";class X{manager;routes=[];constructor(B){this.manager=B,this.registerRoutes()}registerRoutes(){this.addRoute("GET","/api/config",this.getConfig.bind(this)),this.addRoute("POST","/api/config",this.updateConfig.bind(this)),this.addRoute("GET","/api/skills",this.listSkills.bind(this)),this.addRoute("GET","/api/skill",this.getSkill.bind(this)),this.addRoute("PUT","/api/skill",this.saveSkill.bind(this)),this.addRoute("DELETE","/api/skill",this.deleteSkill.bind(this)),this.addRoute("POST","/api/skills/sync",this.syncSkills.bind(this)),this.addRoute("GET","/api/plugins",this.listPlugins.bind(this)),this.addRoute("GET","/api/plugin/config",this.getPluginConfig.bind(this)),this.addRoute("PUT","/api/plugin/config",this.updatePluginConfig.bind(this)),this.addRoute("POST","/api/plugin/install",this.installPlugin.bind(this)),this.addRoute("DELETE","/api/plugin",this.uninstallPlugin.bind(this)),this.addRoute("GET","/api/health",this.healthCheck.bind(this))}addRoute(B,G,Q){this.routes.push({method:B,pathname:G,handler:Q})}matchRoute(B,G){return B===G}async fetch(B){let G=new URL(B.url),Q=B.method,V=G.pathname;for(let W of this.routes){if(W.method!==Q)continue;if(!this.matchRoute(W.pathname,V))continue;try{return await W.handler(B)}catch(N){return this.errorResponse(N)}}return this.notFoundResponse()}jsonResponse(B,G=200){return new Response(JSON.stringify(B),{status:G,headers:{"Content-Type":"application/json"}})}errorResponse(B){console.error("Request error:",B);let G=B instanceof Error?B.message:"Internal server error";return this.jsonResponse({error:G},500)}notFoundResponse(){return this.jsonResponse({error:"Not found"},404)}async parseJson(B){let G=await B.text();if(!G)throw Error("Request body is empty");return JSON.parse(G)}getQueryParam(B,G){return new URL(B.url).searchParams.get(G)}requireQueryParam(B,G){let Q=this.getQueryParam(B,G);if(!Q)throw Error(`Missing required query parameter: ${G}`);return Q}async healthCheck(){return this.jsonResponse({status:"ok",timestamp:Date.now()})}async getConfig(){let B=await this.manager.getConfig();return this.jsonResponse(B)}async updateConfig(B){let G=await this.parseJson(B);return await this.manager.updateConfig(G),this.jsonResponse({success:!0})}async listSkills(){let B=await this.manager.listSkills();return this.jsonResponse(B)}async getSkill(B){let G=this.requireQueryParam(B,"name"),Q=await this.manager.getSkill(G);if(!Q)return this.jsonResponse({error:"Skill not found"},404);return this.jsonResponse(Q)}async saveSkill(B){let G=await this.parseJson(B);return await this.manager.saveSkill(G.name,G.content),this.jsonResponse({success:!0})}async deleteSkill(B){let G=await this.parseJson(B);return await this.manager.deleteSkill(G.name),this.jsonResponse({success:!0})}async syncSkills(){return await this.manager.syncSkillsFromRemote(),this.jsonResponse({success:!0})}async listPlugins(){let B=await this.manager.listPlugins();return this.jsonResponse(B)}async getPluginConfig(B){let G=this.requireQueryParam(B,"name"),Q=await this.manager.getPluginConfig(G);if(!Q)return this.jsonResponse({error:"Plugin config not found"},404);return this.jsonResponse(Q)}async updatePluginConfig(B){let G=await this.parseJson(B);return await this.manager.updatePluginConfig(G.name,G.config),this.jsonResponse({success:!0})}async installPlugin(B){let G=await this.parseJson(B);return await this.manager.installPlugin(G.name,G.source),this.jsonResponse({success:!0})}async uninstallPlugin(B){let G=await this.parseJson(B);return await this.manager.uninstallPlugin(G.name),this.jsonResponse({success:!0})}}async function x(){let{createFSManager:B}=await import("./chunk-wbn1hbxf.js"),G=await B();return new X(G)}function F(B){return new X(B)}class Y{baseUrl;constructor(B="http://localhost:3000"){this.baseUrl=B}async request(B,G){let Q=`${this.baseUrl}${B}`,V=await fetch(Q,G);if(!V.ok){let W=await V.json().catch(()=>({error:"Unknown error"}));throw Error(W.error||`HTTP ${V.status}`)}return V.json()}async initialize(){}async getConfig(){return this.request("/api/config")}async updateConfig(B){await this.request("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(B)})}}class Z{baseUrl;constructor(B="http://localhost:3000"){this.baseUrl=B}async request(B,G){let Q=`${this.baseUrl}${B}`,V=await fetch(Q,G);if(!V.ok){let W=await V.json().catch(()=>({error:"Unknown error"}));throw Error(W.error||`HTTP ${V.status}`)}return V.json()}async initialize(){}async listSkills(){return this.request("/api/skills")}async getSkill(B){let G=`/api/skill?name=${encodeURIComponent(B)}`;return this.request(G)}async saveSkill(B,G){await this.request("/api/skill",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B,content:G})})}async deleteSkill(B){await this.request("/api/skill",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B})})}async syncFromRemote(B){await this.request("/api/skills/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({remote:B})})}}class _{baseUrl;constructor(B="http://localhost:3000"){this.baseUrl=B}async request(B,G){let Q=`${this.baseUrl}${B}`,V=await fetch(Q,G);if(!V.ok){let W=await V.json().catch(()=>({error:"Unknown error"}));throw Error(W.error||`HTTP ${V.status}`)}return V.json()}async initialize(){}async listPlugins(){return this.request("/api/plugins")}async getPluginConfig(B){let G=`/api/plugin/config?name=${encodeURIComponent(B)}`;return this.request(G)}async updatePluginConfig(B,G){await this.request("/api/plugin/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B,config:G})})}async installPlugin(B,G){await this.request("/api/plugin/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B,source:G})})}async uninstallPlugin(B){await this.request("/api/plugin",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B})})}}async function w(B="http://localhost:3000"){let G=new Y(B),Q=new Z(B),V=new _(B),W=new D(G,Q,V);return await W.initialize(),W}import{z as K}from"zod";var v=K.enum(["idea","bug_report","feature","refactor"]),C=K.enum(["low","medium","high","critical"]),U=K.enum(["pending","planned","archived"]),R=K.enum(["user_input","ai_suggestion","conversation_derived"]),P=K.object({id:K.string().uuid(),type:v,title:K.string().min(1).max(200),description:K.string(),priority:C.default("medium"),source:R,status:U.default("pending"),createdAt:K.string().datetime(),tags:K.array(K.string()).default([]),metadata:K.object({relatedFiles:K.array(K.string()).optional(),conversationContext:K.string().optional(),estimatedComplexity:K.enum(["simple","medium","complex"]).optional()}).optional()}),a=K.object({version:K.literal("1.0"),sparks:K.array(P),lastUpdated:K.string().datetime()}),O=K.enum(["pickup","running","complete","error","review","feedback"]),E=K.enum(["default","planner","reviewer","refactor","finder","debugger","architect"]),T=K.enum(["serial","parallel"]),H=K.lazy(()=>K.object({id:K.string(),title:K.string().min(1).max(200),description:K.string(),execution:T.optional(),children:K.array(K.lazy(()=>H)).optional(),agentType:E.optional(),threadId:K.string().optional(),estimatedTime:K.string().optional(),complexity:K.enum(["simple","medium","complex"]).optional(),dependencies:K.array(K.string()).optional(),acceptanceCriteria:K.array(K.string()).optional(),status:O.optional(),startedAt:K.string().datetime().optional(),completedAt:K.string().datetime().optional(),assignedTo:E.optional(),error:K.object({message:K.string(),stack:K.string().optional(),retryCount:K.number().optional()}).optional()})),j=K.object({taskId:K.string(),planId:K.string(),threadId:K.string(),agentType:E,status:O,startedAt:K.string().datetime(),completedAt:K.string().datetime().optional(),output:K.string().optional(),error:K.string().optional(),changedFiles:K.array(K.string()).optional()}),r=K.object({version:K.literal("1.0"),lastUpdated:K.string().datetime(),activePlanId:K.string().optional(),tasks:K.record(K.string(),H),history:K.array(j),config:K.object({maxConcurrentAgents:K.number().min(1).max(10).default(3),retryLimit:K.number().min(0).max(10).default(3),autoResume:K.boolean().default(!1)})});import{Low as b}from"lowdb";import{JSONFile as I}from"lowdb/node";import A from"path";class J{db;dbPath;constructor(B){this.dbPath=A.join(B,".claude","spark.json");let G=new I(this.dbPath);this.db=new b(G,this.getDefaultData())}getDefaultData(){return{version:"1.0",sparks:[],lastUpdated:new Date().toISOString()}}async initialize(){let B=await import("fs"),G=A.dirname(this.dbPath);if(!B.existsSync(G))B.mkdirSync(G,{recursive:!0});if(await this.db.read(),!this.db.data)this.db.data=this.getDefaultData(),await this.db.write()}generateId(){return crypto.randomUUID()}async addSpark(B){await this.db.read();let G={id:this.generateId(),type:B.type,title:B.title,description:B.description,priority:B.priority||"medium",source:"user_input",status:"pending",createdAt:new Date().toISOString(),tags:B.tags||[]};return this.db.data.sparks.push(G),this.db.data.lastUpdated=new Date().toISOString(),await this.db.write(),G}async getAllSparks(){return await this.db.read(),this.db.data.sparks}async getSparksByStatus(B){return await this.db.read(),this.db.data.sparks.filter((G)=>G.status===B)}async getSparksByType(B){return await this.db.read(),this.db.data.sparks.filter((G)=>G.type===B)}async updateSparkStatus(B,G){await this.db.read();let Q=this.db.data.sparks.find((V)=>V.id===B);if(!Q)return!1;return Q.status=G,this.db.data.lastUpdated=new Date().toISOString(),await this.db.write(),!0}async deleteSpark(B){await this.db.read();let G=this.db.data.sparks.findIndex((Q)=>Q.id===B);if(G===-1)return!1;return this.db.data.sparks.splice(G,1),this.db.data.lastUpdated=new Date().toISOString(),await this.db.write(),!0}getDbPath(){return this.dbPath}}import{Low as f}from"lowdb";import{JSONFile as q}from"lowdb/node";import M from"path";class L{db;dbPath;constructor(B){this.dbPath=M.join(B,".claude","task.json");let G=new q(this.dbPath);this.db=new f(G,this.getDefaultData())}getDefaultData(){return{version:"1.0",lastUpdated:new Date().toISOString(),tasks:{},history:[],config:{maxConcurrentAgents:3,retryLimit:3,autoResume:!1}}}async initialize(){let B=await import("fs"),G=M.dirname(this.dbPath);if(!B.existsSync(G))B.mkdirSync(G,{recursive:!0});if(await this.db.read(),!this.db.data)this.db.data=this.getDefaultData(),await this.db.write()}async getTask(B){return await this.db.read(),this.db.data.tasks[B]}async updateTask(B,G){await this.db.read();let Q=this.db.data.tasks[B];if(!Q)return!1;if(this.db.data.tasks[B]={...Q,...G},G.status){if(G.status==="running"&&!Q.startedAt)this.db.data.tasks[B].startedAt=new Date().toISOString();else if(["complete","error","review"].includes(G.status)&&!Q.completedAt)this.db.data.tasks[B].completedAt=new Date().toISOString()}return this.db.data.lastUpdated=new Date().toISOString(),await this.db.write(),!0}async addTasks(B){await this.db.read();for(let G of B)this.db.data.tasks[G.id]=G;this.db.data.lastUpdated=new Date().toISOString(),await this.db.write()}async getTasksByStatus(B){return await this.db.read(),Object.values(this.db.data.tasks).filter((G)=>G.status===B)}async getAllTasks(){return await this.db.read(),Object.values(this.db.data.tasks)}async addHistory(B){await this.db.read(),this.db.data.history.push(B),await this.db.write()}async getHistory(B){if(await this.db.read(),B)return this.db.data.history.filter((G)=>G.planId===B);return this.db.data.history}async setActivePlan(B){await this.db.read(),this.db.data.activePlanId=B,this.db.data.lastUpdated=new Date().toISOString(),await this.db.write()}async getActivePlan(){return await this.db.read(),this.db.data.activePlanId}async updateConfig(B){await this.db.read(),this.db.data.config={...this.db.data.config,...B},this.db.data.lastUpdated=new Date().toISOString(),await this.db.write()}async getConfig(){return await this.db.read(),this.db.data.config}async clearAllTasks(){await this.db.read(),this.db.data.tasks={},this.db.data.activePlanId=void 0,this.db.data.lastUpdated=new Date().toISOString(),await this.db.write()}async deleteTask(B){if(await this.db.read(),!this.db.data.tasks[B])return!1;return delete this.db.data.tasks[B],this.db.data.lastUpdated=new Date().toISOString(),await this.db.write(),!0}getDbPath(){return this.dbPath}}export{X as Oa,x as Pa,F as Qa,Y as Ra,Z as Sa,_ as Ta,w as Ua,v as Va,C as Wa,U as Xa,R as Ya,P as Za,a as _a,O as $a,E as ab,T as bb,H as cb,j as db,r as eb,J as fb,L as gb};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{P as C,R as S,S as y,T as w}from"./chunk-9kc9cea3.js";import{ca as l,da as Z,ea as J,ha as j,ka as d,la as m,na as D,pa as u}from"./chunk-wwn7gw8g.js";import{nb as q,rb as p}from"./chunk-cze71w02.js";var L=q(l(),1);function f({filter:H,enabled:Q=!0}){return S({queryKey:w.tasks.list(H),queryFn:async()=>{let{getTasksStore:X}=await import("./chunk-h5nnz4dy.js"),Y=X(process.cwd());if(await Y.initialize(),H)return await Y.getTasksByStatus(H);return await Y.getAllTasks()},enabled:Q,staleTime:30000})}function I(){let H=C();return y({mutationFn:async(Q)=>{let{getTasksStore:X}=await import("./chunk-h5nnz4dy.js"),Y=X(process.cwd());return await Y.initialize(),await Y.deleteTask(Q)},onSuccess:(Q,X)=>{H.invalidateQueries({queryKey:w.tasks.all}),H.removeQueries({queryKey:w.tasks.detail(X)})}})}var z=q(m(),1),F={pickup:{emoji:"\uD83D\uDCE5",color:"cyan",label:"待领取"},running:{emoji:"\uD83D\uDD04",color:"yellow",label:"运行中"},complete:{emoji:"✅",color:"green",label:"已完成"},error:{emoji:"❌",color:"red",label:"失败"},review:{emoji:"\uD83D\uDC40",color:"blue",label:"待审核"},feedback:{emoji:"\uD83D\uDCAC",color:"magenta",label:"待反馈"}},i={simple:{emoji:"\uD83D\uDFE2",label:"简单"},medium:{emoji:"\uD83D\uDFE1",label:"中等"},complex:{emoji:"\uD83D\uDD34",label:"复杂"}},E=({task:H,onClose:Q,onExecuteTask:X,onDelete:Y})=>{d((K,M)=>{if(M.escape)Q();else if(M.return&&X){if(H.status==="pickup"||H.status==="error"||H.status==="feedback")X(H)}else if((M.backspace||M.delete)&&Y)Y(H)});let R=H.status?F[H.status]:F.pickup,A=H.status==="pickup"||H.status==="error"||H.status==="feedback",G=H.complexity?i[H.complexity]:null;return z.jsxDEV(Z,{flexDirection:"column",paddingX:1,children:[z.jsxDEV(Z,{borderStyle:"single",paddingX:1,marginBottom:1,children:[z.jsxDEV(J,{bold:!0,color:"cyan",children:[R.emoji," 任务预览"]},void 0,!0,void 0,this),z.jsxDEV(Z,{flexGrow:1},void 0,!1,void 0,this),A&&X&&z.jsxDEV(J,{color:"green",children:"Enter 执行"},void 0,!1,void 0,this),Y&&z.jsxDEV(z.Fragment,{children:[A&&X&&z.jsxDEV(J,{dimColor:!0,children:" | "},void 0,!1,void 0,this),z.jsxDEV(J,{color:"red",children:"Delete 删除"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV(J,{dimColor:!0,children:" | "},void 0,!1,void 0,this),z.jsxDEV(J,{dimColor:!0,children:"Esc 退出"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV(Z,{marginBottom:1,children:z.jsxDEV(J,{bold:!0,color:"white",children:H.title},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV(Z,{marginBottom:1,children:[z.jsxDEV(J,{color:R.color,children:[R.emoji," ",R.label]},void 0,!0,void 0,this),G&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV(J,{children:" • "},void 0,!1,void 0,this),z.jsxDEV(J,{children:[G.emoji," ",G.label]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),H.estimatedTime&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV(J,{children:" • "},void 0,!1,void 0,this),z.jsxDEV(J,{children:["⏱️ ",H.estimatedTime]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV(Z,{marginBottom:1,flexDirection:"column",children:[z.jsxDEV(J,{color:"gray",bold:!0,children:"描述:"},void 0,!1,void 0,this),z.jsxDEV(J,{children:H.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV(Z,{marginBottom:1,children:[z.jsxDEV(J,{color:"gray",children:"ID: "},void 0,!1,void 0,this),z.jsxDEV(J,{dimColor:!0,children:H.id},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H.agentType&&z.jsxDEV(Z,{marginBottom:1,children:[z.jsxDEV(J,{color:"gray",children:"建议 Agent: "},void 0,!1,void 0,this),z.jsxDEV(J,{color:"yellow",children:H.agentType},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H.assignedTo&&z.jsxDEV(Z,{marginBottom:1,children:[z.jsxDEV(J,{color:"gray",children:"分配给: "},void 0,!1,void 0,this),z.jsxDEV(J,{color:"blue",children:H.assignedTo},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H.threadId&&z.jsxDEV(Z,{marginBottom:1,children:[z.jsxDEV(J,{color:"gray",children:"Thread ID: "},void 0,!1,void 0,this),z.jsxDEV(J,{dimColor:!0,children:H.threadId},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H.dependencies&&H.dependencies.length>0&&z.jsxDEV(Z,{marginBottom:1,flexDirection:"column",children:[z.jsxDEV(J,{color:"gray",bold:!0,children:"依赖任务:"},void 0,!1,void 0,this),z.jsxDEV(J,{dimColor:!0,children:H.dependencies.join(", ")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H.acceptanceCriteria&&H.acceptanceCriteria.length>0&&z.jsxDEV(Z,{marginBottom:1,flexDirection:"column",children:[z.jsxDEV(J,{color:"gray",bold:!0,children:"验收标准:"},void 0,!1,void 0,this),H.acceptanceCriteria.map((K,M)=>z.jsxDEV(J,{dimColor:!0,children:[M+1,". ",K]},`ac-${M}-${H.id}`,!0,void 0,this))]},void 0,!0,void 0,this),H.children&&H.children.length>0&&z.jsxDEV(Z,{flexDirection:"column",children:[z.jsxDEV(J,{color:"gray",bold:!0,children:["子任务 (",H.children.length,"):"]},void 0,!0,void 0,this),H.children.map((K,M)=>{let U=K.status?F[K.status]:F.pickup;return z.jsxDEV(Z,{children:z.jsxDEV(J,{color:U.color,children:[U.emoji," ",M+1,". ",K.title]},void 0,!0,void 0,this)},K.id,!1,void 0,this)})]},void 0,!0,void 0,this),H.status==="error"&&H.error&&z.jsxDEV(Z,{marginTop:1,flexDirection:"column",borderStyle:"single",paddingX:1,children:[z.jsxDEV(J,{color:"red",bold:!0,children:"错误:"},void 0,!1,void 0,this),z.jsxDEV(J,{color:"red",children:H.error.message},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},V=E;var $=q(m(),1),P={pickup:{emoji:"\uD83D\uDCE5",color:"cyan",label:"待领取"},running:{emoji:"\uD83D\uDD04",color:"yellow",label:"运行中"},complete:{emoji:"✅",color:"green",label:"已完成"},error:{emoji:"❌",color:"red",label:"失败"},review:{emoji:"\uD83D\uDC40",color:"blue",label:"待审核"},feedback:{emoji:"\uD83D\uDCAC",color:"magenta",label:"待反馈"}},r={simple:{emoji:"\uD83D\uDFE2",label:"简单"},medium:{emoji:"\uD83D\uDFE1",label:"中等"},complex:{emoji:"\uD83D\uDD34",label:"复杂"}},n=({onClose:H,onExecuteTask:Q})=>{let{data:X=[]}=f(),Y=I(),[R,A]=L.useState(null),G=L.useRef(A),K=L.useRef(Q);L.default.useEffect(()=>{G.current=A},[A]),L.default.useEffect(()=>{K.current=Q},[Q]);let M=L.useCallback(()=>{A(null)},[]),U=L.useCallback(async(W)=>{await Y.mutateAsync(W.id),A((N)=>N?.id===W.id?null:N)},[Y]),v=L.useCallback((W,N,B)=>{let O=W.status?P[W.status]:P.pickup,_=W.complexity?r[W.complexity]:null;return $.jsxDEV(D,{isSelected:B,children:$.jsxDEV(Z,{children:[$.jsxDEV(J,{color:"cyan",dimColor:O===P.complete,children:[O.emoji," ",N+1,". ",W.title]},void 0,!0,void 0,this),$.jsxDEV(j,{},void 0,!1,void 0,this),$.jsxDEV(J,{color:"yellow",dimColor:!0,children:O.label},void 0,!1,void 0,this),_&&$.jsxDEV(J,{dimColor:!0,children:[_.emoji," ",_.label]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},`task-${W.id}`,!1,void 0,this)},[]),g=L.useCallback((W)=>{let N=W.filter((b)=>b.status==="running").length,B=W.filter((b)=>b.status==="complete").length,O=W.filter((b)=>b.status==="error").length,_=W.filter((b)=>b.status==="pickup"||b.status==="error"||b.status==="feedback").length;return $.jsxDEV(J,{color:"gray",children:["运行: ",N," | 完成: ",B," | 失败: ",O,_>0&&$.jsxDEV(J,{color:"green",children:[" | 可执行: ",_]},void 0,!0,void 0,this),$.jsxDEV(J,{dimColor:!0,children:" | Backspace 删除"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},[]),h=L.useCallback((W)=>{G.current(W)},[]),c=L.default.useMemo(()=>({id:"tasks",title:"任务看板",icon:"\uD83D\uDCCB",dataSource:async()=>X,searchable:!0,searchFields:["title","description"],searchPlaceholder:"搜索任务...",filterable:!0,filters:[{id:"all",label:"全部",predicate:()=>!0},{id:"pickup",label:"待领取",predicate:(W)=>W.status==="pickup"},{id:"running",label:"运行中",predicate:(W)=>W.status==="running"},{id:"complete",label:"已完成",predicate:(W)=>W.status==="complete"},{id:"error",label:"失败",predicate:(W)=>W.status==="error"}],defaultFilter:"all",itemHeight:3,visibleCount:10,renderItem:v,onSelect:h,onDelete:U,showCount:!0,statusInfo:g}),[X,v,g,h,U]);return $.jsxDEV($.Fragment,{children:R?$.jsxDEV(V,{task:R,onClose:M,onExecuteTask:Q,onDelete:U},void 0,!1,void 0,this):$.jsxDEV(u,{config:c,onClose:H},void 0,!1,void 0,this)},void 0,!1,void 0,this)},Zz=n;export{Zz as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{kb as a}from"./chunk-jkbtx9va.js";import"./chunk-cze71w02.js";export{a as FileSystemConfigStore};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ta as a,ua as b,va as c}from"./chunk-0fhpz98a.js";import"./chunk-bjywwcgn.js";import"./chunk-sft6ep0c.js";import"./chunk-dh3jz71n.js";import"./chunk-yaa4eesd.js";import"./chunk-jkbtx9va.js";import"./chunk-kbs4px1b.js";import"./chunk-9k57afdm.js";import"./chunk-cze71w02.js";export{c as getAgentListFromPackage,a as createSubAgentsMiddleware,b as SubAgentsMiddleware};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$a as t,Oa as b,Pa as h,Qa as i,Ra as j,Sa as k,Ta as l,Ua as m,Va as n,Wa as o,Xa as p,Ya as q,Za as r,_a as s,ab as u,bb as v,cb as w,db as x,eb as y,fb as z,gb as A}from"./chunk-dh3jz71n.js";import{hb as a,ib as f,jb as g}from"./chunk-yaa4eesd.js";import{kb as c}from"./chunk-jkbtx9va.js";import{lb as d}from"./chunk-kbs4px1b.js";import{mb as e}from"./chunk-9k57afdm.js";import"./chunk-cze71w02.js";export{i as createServerWithManager,m as createRemoteManager,f as createFSManager,g as createCustomManager,h as createConfigServer,y as TaskStoreSchema,A as TaskStoreManager,t as TaskStatusSchema,w as TaskNodeSchema,v as TaskExecutionSchema,x as TaskExecutionRecordSchema,s as SparkStoreSchema,z as SparkStoreManager,p as SparkStatusSchema,q as SparkSourceSchema,o as SparkPrioritySchema,n as SparkItemTypeSchema,r as SparkItemSchema,k as RemoteSkillStore,l as RemotePluginStore,j as RemoteConfigStore,d as FileSystemSkillStore,e as FileSystemPluginStore,c as FileSystemConfigStore,b as ConfigServer,a as ConfigManager,u as AgentTypeSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as A,b as W}from"./chunk-5wn1nfqy.js";import"./chunk-7dp8kq2f.js";import{U as q,X as R}from"./chunk-bgpcx3bm.js";import{nb as V}from"./chunk-cze71w02.js";var x=V(W(),1);function B(M){if(M===null||typeof M!=="object")return JSON.stringify(M);if(Array.isArray(M))return JSON.stringify(M.map((J)=>B(J)));let F={},G=Object.keys(M).sort();for(let J of G)F[J]=M[J];return JSON.stringify(F,(J,Q)=>{if(Q!==null&&typeof Q==="object"&&!Array.isArray(Q)){let X={},Y=Object.keys(Q).sort();for(let Z of Y)X[Z]=Q[Z];return X}return Q})}var P=[{index:"checkpoints",prefix:"checkpoint:",schema:{"$.thread_id":{type:"TAG",AS:"thread_id"},"$.checkpoint_ns":{type:"TAG",AS:"checkpoint_ns"},"$.checkpoint_id":{type:"TAG",AS:"checkpoint_id"},"$.parent_checkpoint_id":{type:"TAG",AS:"parent_checkpoint_id"},"$.checkpoint_ts":{type:"NUMERIC",AS:"checkpoint_ts"},"$.has_writes":{type:"TAG",AS:"has_writes"},"$.source":{type:"TAG",AS:"source"},"$.step":{type:"NUMERIC",AS:"step"}}},{index:"checkpoint_writes",prefix:"checkpoint_write:",schema:{"$.thread_id":{type:"TAG",AS:"thread_id"},"$.checkpoint_ns":{type:"TAG",AS:"checkpoint_ns"},"$.checkpoint_id":{type:"TAG",AS:"checkpoint_id"},"$.task_id":{type:"TAG",AS:"task_id"},"$.idx":{type:"NUMERIC",AS:"idx"},"$.channel":{type:"TAG",AS:"channel"},"$.type":{type:"TAG",AS:"type"}}}],N=class M extends R{client;ttlConfig;constructor(F,G){super();this.client=F,this.ttlConfig=G}static async fromUrl(F,G){let J=x.createClient({url:F});await J.connect();let Q=new M(J,G);return await Q.ensureIndexes(),Q}async get(F){return(await this.getTuple(F))?.checkpoint}async put(F,G,J,Q){await this.ensureIndexes();let X=F.configurable?.thread_id,Y=F.configurable?.checkpoint_ns??"",Z=F.configurable?.checkpoint_id;if(!X)throw Error("thread_id is required");let _=G.id||q(0),E=`checkpoint:${X}:${Y}:shallow`,H=null,$=null;try{if(H=await this.client.json.get(E),H&&typeof H==="object")$=H.checkpoint_id}catch(O){}if($&&$!==_)await this.cleanupOldCheckpoint(X,Y,$);let L={...G,channel_values:G.channel_values||{},channel_blobs:void 0},U={thread_id:X,checkpoint_ns:Y,checkpoint_id:_,parent_checkpoint_id:Z||null,checkpoint:L,metadata:this.sanitizeMetadata(J),checkpoint_ts:Date.now(),has_writes:"false"};if(this.addSearchableMetadataFields(U,J),await this.client.json.set(E,"$",U),this.ttlConfig?.defaultTTL)await this.applyTTL(E);return{configurable:{thread_id:X,checkpoint_ns:Y,checkpoint_id:_}}}async getTuple(F){let G=F.configurable?.thread_id,J=F.configurable?.checkpoint_ns??"",Q=F.configurable?.checkpoint_id;if(!G)return;let X=`checkpoint:${G}:${J}:shallow`,Y=await this.client.json.get(X);if(!Y)return;if(Q&&Y.checkpoint_id!==Q)return;if(this.ttlConfig?.refreshOnRead&&this.ttlConfig?.defaultTTL)await this.applyTTL(X);let Z=await this.serde.loadsTyped("json",JSON.stringify(Y.checkpoint)),_;if(Y.has_writes==="true")_=await this.loadPendingWrites(Y.thread_id,Y.checkpoint_ns,Y.checkpoint_id);return await this.createCheckpointTuple(Y,Z,_)}async*list(F,G){if(await this.ensureIndexes(),F?.configurable?.thread_id){let J=await this.getTuple(F);if(J)if(G?.filter){if(this.checkMetadataFilterMatch(J.metadata,G.filter))yield J}else yield J}else{let J=[];if(G?.filter){for(let[Y,Z]of Object.entries(G.filter))if(Z===void 0);else if(Z===null);else if(typeof Z==="string"){let _=A(Y),E=A(Z);J.push(`(@${_}:{${E}})`)}else if(typeof Z==="number"){let _=A(Y);J.push(`(@${_}:[${Z} ${Z}])`)}}if(J.length===0)J.push("*");let Q=J.join(" "),X=G?.limit??10;try{let Y=await this.client.ft.search("checkpoints",Q,{LIMIT:{from:0,size:X*2},SORTBY:{BY:"checkpoint_ts",DIRECTION:"DESC"}}),Z=new Set,_=0;for(let E of Y.documents){if(_>=X)break;let H=E.value,$=`${H.thread_id}:${H.checkpoint_ns}`;if(Z.has($))continue;if(Z.add($),G?.filter){if(!this.checkMetadataFilterMatch(H.metadata,G.filter))continue}let L=await this.serde.loadsTyped("json",JSON.stringify(H.checkpoint));yield await this.createCheckpointTuple(H,L),_++}}catch(Y){if(Y.message?.includes("no such index")){let Z=await this.client.keys("checkpoint:*:*:shallow");if(Z.length===0)return;Z.sort().reverse();let _=new Set,E=0,H=G?.limit??10;for(let $ of Z){if(E>=H)break;let L=await this.client.json.get($);if(!L)continue;let U=`${L.thread_id}:${L.checkpoint_ns}`;if(_.has(U))continue;if(_.add(U),G?.filter){if(!this.checkMetadataFilterMatch(L.metadata,G.filter))continue}let O=await this.serde.loadsTyped("json",JSON.stringify(L.checkpoint));yield await this.createCheckpointTuple(L,O),E++}return}throw Y}}}async putWrites(F,G,J){await this.ensureIndexes();let Q=F.configurable?.thread_id,X=F.configurable?.checkpoint_ns??"",Y=F.configurable?.checkpoint_id;if(!Q||!Y)throw Error("thread_id and checkpoint_id are required");let Z=`checkpoint_write:${Q}:${X}:${Y}:${J}:*`,_=await this.client.keys(Z);if(_.length>0)await this.client.del(_);let E=[];for(let $=0;$<G.length;$++){let[L,U]=G[$],O=`checkpoint_write:${Q}:${X}:${Y}:${J}:${$}`;E.push(O);let T={thread_id:Q,checkpoint_ns:X,checkpoint_id:Y,task_id:J,idx:$,channel:L,type:typeof U==="object"?"json":"string",value:U};await this.client.json.set(O,"$",T)}if(E.length>0){let $=`write_keys_zset:${Q}:${X}:${Y}`,L={};if(E.forEach((U,O)=>{L[U]=O}),await this.client.zAdd($,Object.entries(L).map(([U,O])=>({score:O,value:U}))),this.ttlConfig?.defaultTTL)await this.applyTTL(...E,$)}let H=`checkpoint:${Q}:${X}:shallow`;if(await this.client.exists(H)){let $=await this.client.json.get(H);if($)$.has_writes="true",await this.client.json.set(H,"$",$)}}async deleteThread(F){let G=`checkpoint:${F}:*:shallow`,J=await this.client.keys(G);if(J.length>0)await this.client.del(J);let Q=`checkpoint_write:${F}:*`,X=await this.client.keys(Q);if(X.length>0)await this.client.del(X);let Y=`write_keys_zset:${F}:*`,Z=await this.client.keys(Y);if(Z.length>0)await this.client.del(Z)}async end(){await this.client.quit()}addSearchableMetadataFields(F,G){if(!G)return;if("source"in G)F.source=G.source;if("step"in G)F.step=G.step;if("writes"in G)F.writes=typeof G.writes==="object"?JSON.stringify(G.writes):G.writes;if("score"in G)F.score=G.score}async createCheckpointTuple(F,G,J){let Q=await this.serde.loadsTyped("json",JSON.stringify(F.metadata));return{config:{configurable:{thread_id:F.thread_id,checkpoint_ns:F.checkpoint_ns,checkpoint_id:F.checkpoint_id}},checkpoint:G,metadata:Q,parentConfig:F.parent_checkpoint_id?{configurable:{thread_id:F.thread_id,checkpoint_ns:F.checkpoint_ns,checkpoint_id:F.parent_checkpoint_id}}:void 0,pendingWrites:J}}async applyTTL(...F){if(!this.ttlConfig?.defaultTTL)return;let G=Math.floor(this.ttlConfig.defaultTTL*60),J=await Promise.allSettled(F.map((Q)=>this.client.expire(Q,G)));for(let Q=0;Q<J.length;Q++)if(J[Q].status==="rejected")console.warn(`Failed to set TTL for key ${F[Q]}:`,J[Q].reason)}async loadPendingWrites(F,G,J){let Q=`write_keys_zset:${F}:${G}:${J}`,X=await this.client.zRange(Q,0,-1);if(X.length===0)return;let Y=[];for(let Z of X){let _=await this.client.json.get(Z);if(_){let E=await this.serde.loadsTyped("json",JSON.stringify(_.value));Y.push([_.task_id,_.channel,E])}}return Y}checkMetadataFilterMatch(F,G){for(let[J,Q]of Object.entries(G)){let X=F?.[J];if(Q===null){if(!(J in(F||{}))||X!==null)return!1}else if(typeof Q==="object"&&!Array.isArray(Q)){if(typeof X!=="object"||X===null)return!1;if(B(Q)!==B(X))return!1}else if(X!==Q)return!1}return!0}async cleanupOldCheckpoint(F,G,J){let Q=`checkpoint_write:${F}:${G}:${J}:*`,X=await this.client.keys(Q);if(X.length>0)await this.client.del(X);let Y=`write_keys_zset:${F}:${G}:${J}`;await this.client.del(Y);let Z=`checkpoint_blob:${F}:${G}:${J}:*`,_=await this.client.keys(Z);if(_.length>0)await this.client.del(_)}sanitizeMetadata(F){if(!F)return{};let G={};for(let[J,Q]of Object.entries(F)){let X=J.replace(/\x00/g,"");G[X]=typeof Q==="string"?Q.replace(/\x00/g,""):Q}return G}async ensureIndexes(){for(let F of P)try{await this.client.ft.create(F.index,F.schema,{ON:"JSON",PREFIX:F.prefix})}catch(G){if(!G.message?.includes("Index already exists"))console.error(`Failed to create index ${F.index}:`,G.message)}}};export{N as ShallowRedisSaver};
|