forked from zanfranceschi/rinha-de-backend-2024-q1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.logs
199 lines (199 loc) · 809 KB
/
docker-compose.logs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
api02 Pulling
api01 Pulling
api02 Pulled
api01 Pulled
Container erickmarx-postgres-1 Creating
Container erickmarx-postgres-1 Created
Container erickmarx-api01-1 Creating
Container erickmarx-api02-1 Creating
Container erickmarx-api02-1 Created
Container erickmarx-api01-1 Created
Container erickmarx-nginx-1 Creating
Container erickmarx-nginx-1 Created
Attaching to api01-1, api02-1, nginx-1, postgres-1
postgres-1 | The files belonging to this database system will be owned by user "postgres".
postgres-1 | This user must also own the server process.
postgres-1 |
postgres-1 | The database cluster will be initialized with locale "en_US.utf8".
postgres-1 | The default database encoding has accordingly been set to "UTF8".
postgres-1 | The default text search configuration will be set to "english".
postgres-1 |
postgres-1 | Data page checksums are disabled.
postgres-1 |
postgres-1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
postgres-1 | creating subdirectories ... ok
postgres-1 | selecting dynamic shared memory implementation ... posix
postgres-1 | selecting default max_connections ... 100
postgres-1 | selecting default shared_buffers ... 128MB
postgres-1 | selecting default time zone ... Etc/UTC
postgres-1 | creating configuration files ... ok
postgres-1 | running bootstrap script ... ok
postgres-1 | performing post-bootstrap initialization ... ok
postgres-1 | syncing data to disk ... ok
postgres-1 |
postgres-1 |
postgres-1 | Success. You can now start the database server using:
postgres-1 |
postgres-1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
postgres-1 |
postgres-1 | initdb: warning: enabling "trust" authentication for local connections
postgres-1 | initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
postgres-1 | waiting for server to start.... done
postgres-1 | server started
postgres-1 | CREATE DATABASE
postgres-1 |
postgres-1 |
postgres-1 | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/2_init.sql
postgres-1 | SET
postgres-1 | SET
postgres-1 | SET
postgres-1 | SET
postgres-1 | SET
postgres-1 | SET
postgres-1 | SET
postgres-1 | SET
postgres-1 | SET
postgres-1 | CREATE TABLE
postgres-1 | CREATE TABLE
postgres-1 | CREATE INDEX
postgres-1 | DO
postgres-1 | CREATE FUNCTION
postgres-1 | CREATE FUNCTION
postgres-1 |
postgres-1 |
postgres-1 | waiting for server to shut down.... done
postgres-1 | server stopped
postgres-1 |
postgres-1 | PostgreSQL init process complete; ready for start up.
postgres-1 |
api01-1 | Server is running at on port 8081...
api02-1 | Server is running at on port 8082...
nginx-1 | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx-1 | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx-1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx-1 | 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
nginx-1 | 10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
nginx-1 | /docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
nginx-1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx-1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
nginx-1 | /docker-entrypoint.sh: Configuration complete; ready for start up
postgres-1 | 2024-02-19 04:54:58.020 UTC [85] FATAL: terminating connection due to unexpected postmaster exit
postgres-1 | 2024-02-19 04:54:58.020 UTC [92] FATAL: terminating connection due to unexpected postmaster exit
api01-1 | 1 | // @bun
postgres-1 | 2024-02-19 04:54:58.021 UTC [88] FATAL: terminating connection due to unexpected postmaster exit
postgres-1 | 2024-02-19 04:54:58.023 UTC [86] FATAL: terminating connection due to unexpected postmaster exit
postgres-1 | 2024-02-19 04:54:58.023 UTC [79] FATAL: terminating connection due to unexpected postmaster exit
postgres-1 | 2024-02-19 04:54:58.023 UTC [78] FATAL: terminating connection due to unexpected postmaster exit
postgres-1 | 2024-02-19 04:54:58.024 UTC [84] FATAL: terminating connection due to unexpected postmaster exit
api01-1 | 2 | var K$=Object.create;var{defineProperty:y,getPrototypeOf:H$,getOwnPropertyNames:f0,getOwnPropertyDescriptor:O$}=Object,g0=Object.prototype.hasOwnProperty;var _$=($,U,X)=>{X=$!=null?K$(H$($)):{};const Z=U||!$||!$.__esModule?y(X,"default",{value:$,enumerable:!0}):X;for(let J of f0($))if(!g0.call(Z,J))y(Z,J,{get:()=>$[J],enumerable:!0});return Z},c0=($)=>{const U=c0.moduleCache??=new WeakMap;var X=U.get($);if(X)return X;var Z=y({},"__esModule",{value:!0}),J={enumerable:!1};if($&&typeof $==="object"||typeof $==="function"){for(let G of f0($))if(!g0.call(Z,G))y(Z,G,{get:()=>$[G],enumerable:!(J=O$($,G))||J.enumerable})}return U.set($,Z),Z};var H=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports);var z$=($,U)=>{for(var X in U)y($,X,{get:U[X],enumerable:!0,configurable:!0,set:(Z)=>U[X]=()=>Z})};var R$=($,U)=>()=>($&&(U=$($=0)),U);var j0=H((F$)=>{var L$=function($){return $};F$.parse=function($,U){return new Q0($,U).parse()};class Q0{constructor($,U){this.source=$,this.transform=U||L$,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 U;if(this.recorded.length>0||$){if(U=this.recorded.join(""),U==="NULL"&&!$)U=null;if(U!==null)U=this.transform(U);this.entries.push(U),this.recorded=[]}}consumeDimensions(){if(this.source[0]==="[")while(!this.isEof()){var $=this.nextCharacter();if($.value==="=")break}}parse($){var U,X,Z;this.consumeDimensions();while(!this.isEof())if(U=this.nextCharacter(),U.value==="{"&&!Z){if(this.dimension++,this.dimension>1)X=new Q0(this.source.substr(this.position-1),this.transform),this.entries.push(X.parse(!0)),this.position+=X.position-2}else if(U.value==="}"&&!Z){if(this.dimension--,!this.dimension){if(this.newEntry(),$)return this.entries}}else if(U.value==='"'&&!U.escaped){if(Z)this.newEntry(!0);Z=!Z}else if(U.value===","&&!Z)this.newEntry();else this.record(U.value);if(this.dimension!==0)throw new Error("array dimension not balanced");return this.entries}}});var W0=H((r9,l0)=>{var A$=j0();l0.exports={create:function($,U){return{parse:function(){return A$.parse($,U)}}}}});var i0=H((e9,n0)=>{var T$=function($){var U=V$.exec($);if(!U)return;var X=parseInt(U[1],10),Z=!!U[4];if(Z)X=o0(X);var J=parseInt(U[2],10)-1,G=U[3],Y=new Date(X,J,G);if(K0(X))Y.setFullYear(X);return Y},P$=function($){if($.endsWith("+00"))return 0;var U=E$.exec($.split(" ")[1]);if(!U)return;var X=U[1];if(X==="Z")return 0;var Z=X==="-"?-1:1,J=parseInt(U[2],10)*3600+parseInt(U[3]||0,10)*60+parseInt(U[4]||0,10);return J*Z*1000},o0=function($){return-($-1)},K0=function($){return $>=0&&$<100},N$=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,V$=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,E$=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,S$=/^-?infinity$/;n0.exports=function $(U){if(S$.test(U))return Number(U.replace("i","I"));var X=N$.exec(U);if(!X)return T$(U)||null;var Z=!!X[8],J=parseInt(X[1],10);if(Z)J=o0(J);var G=parseInt(X[2],10)-1,Y=X[3],Q=parseInt(X[4],10),j=parseInt(X[5],10),W=parseInt(X[6],10),K=X[7];K=K?1000*parseFloat(K):0;var O,_=P$(U);if(_!=null){if(O=new Date(Date.UTC(J,G,Y,Q,j,W,K)),K0(J))O.setUTCFullYear(J);if(_!==0)O.setTime(O.getTime()-_)}else if(O=new Date(J,G,Y,Q,j,W,K),K0(J))O.setFullYear(J);return O}});var t0=H(($U,a0)=>{var q$=function($){for(var U=1;U<arguments.length;U++){var X=arguments[U];for(var Z in X)if(C$.call(X,Z))$[Z]=X[Z]}return $};a0.exports=q$;var C$=Object.prototype.hasOwnProperty});var e0=H((UU,r0)=>{var k=function($){if(!(this instanceof k))return new k($);D$(this,p$($))},m$=function($){var U=$+"000000".slice($.length);return parseInt(U,10)/1000},p$=function($){if(!$)return{};var U=y$.exec($),X=U[8]==="-";return Object.keys(s0).reduce(function(Z,J){var G=s0[J],Y=U[G];if(!Y)return Z;if(Y=J==="milliseconds"?m$(Y):parseInt(Y,10),!Y)return Z;if(X&&~d$.indexOf(J))Y*=-1;return Z[J]=Y,Z},{})},D$=t0();r0.exports=k;var k$=["seconds","minutes","hours","days","months","years"];k.prototype.toPostgres=function(){var $=k$.filter(this.hasOwnProperty,this);if(this.milliseconds&&$.indexOf("seconds")<0)$.push("seconds");if($.length===0)return"0";return $.map(function(U){var X=this[U]||0;if(U==="seconds"&&this.milliseconds)X=(X+this.milliseconds/1000).toFixed(6).replace(/\.?0+$/,"");return X+" "+U},this).join(" ")};var B$={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"S"},I$=["years","months","days"],x$=["hours","minutes","seconds"];k.prototype.toISOString=k.prototype.toISO=function(){var $=I$.map(X,this).join(""),U=x$.map(X,this).join("");return"P"+$+"T"+U;function X(Z){var J=this[Z]||0;if(Z==="seconds"&&this.milliseconds)J=(J+this.milliseconds/1000).toFixed(6).replace(/0+$/,"");return J+B$[Z]}};var H0="([+-]?\\d+)",w$=H0+"\\s+years?",h$=H0+"\\s+mons?",b$=H0+"\\s+days?",v$="([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",y$=new RegExp([w$,h$,b$,v$].map(function($){return"("+$+")?"}).join("\\s*")),s0={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},d$=["hours","minutes","seconds","milliseconds"]});var U1=H((XU,$1)=>{$1.exports=function $(U){if(/^\\x/.test(U))return new Buffer(U.substr(2),"hex");var X="",Z=0;while(Z<U.length)if(U[Z]!=="\\")X+=U[Z],++Z;else if(/[0-7]{3}/.test(U.substr(Z+1,3)))X+=String.fromCharCode(parseInt(U.substr(Z+1,3),8)),Z+=4;else{var J=1;while(Z+J<U.length&&U[Z+J]==="\\")J++;for(var G=0;G<Math.floor(J/2);++G)X+="\\";Z+=Math.floor(J/2)*2}return new Buffer(X,"binary")}});var j1=H((ZU,Q1)=>{var t=function($){return function U(X){if(X===null)return X;return $(X)}},G1=function($){if($===null)return $;return $==="TRUE"||$==="t"||$==="true"||$==="y"||$==="yes"||$==="on"||$==="1"},u$=function($){if(!$)return null;return d.parse($,G1)},f$=function($){return parseInt($,10)},O0=function($){if(!$)return null;return d.parse($,t(f$))},g$=function($){if(!$)return null;return d.parse($,t(function(U){return Y1(U).trim()}))},d=j0(),m=W0(),a=i0(),Z1=e0(),J1=U1(),c$=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=L0(X);return X});return U.parse()},_0=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=parseFloat(X);return X});return U.parse()},S=function($){if(!$)return null;var U=m.create($);return U.parse()},z0=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=a(X);return X});return U.parse()},l$=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=Z1(X);return X});return U.parse()},o$=function($){if(!$)return null;return d.parse($,t(J1))},R0=function($){return parseInt($,10)},Y1=function($){var U=String($);if(/^\d+$/.test(U))return U;return $},X1=function($){if(!$)return null;return d.parse($,t(JSON.parse))},L0=function($){if($[0]!=="(")return null;return $=$.substring(1,$.length-1).split(","),{x:parseFloat($[0]),y:parseFloat($[1])}},n$=function($){if($[0]!=="<"&&$[1]!=="(")return null;var U="(",X="",Z=!1;for(var J=2;J<$.length-1;J++){if(!Z)U+=$[J];if($[J]===")"){Z=!0;continue}else if(!Z)continue;if($[J]===",")continue;X+=$[J]}var G=L0(U);return G.radius=parseFloat(X),G},i$=function($){$(20,Y1),$(21,R0),$(23,R0),$(26,R0),$(700,parseFloat),$(701,parseFloat),$(16,G1),$(1082,a),$(1114,a),$(1184,a),$(600,L0),$(651,S),$(718,n$),$(1000,u$),$(1001,o$),$(1005,O0),$(1007,O0),$(1028,O0),$(1016,g$),$(1017,c$),$(1021,_0),$(1022,_0),$(1231,_0),$(1014,S),$(1015,S),$(1008,S),$(1009,S),$(1040,S),$(1041,S),$(1115,z0),$(1182,z0),$(1185,z0),$(1186,Z1),$(1187,l$),$(17,J1),$(114,JSON.parse.bind(JSON)),$(3802,JSON.parse.bind(JSON)),$(199,X1),$(3807,X1),$(3907,S),$(2951,S),$(791,S),$(1183,S),$(1270,S)};Q1.exports={init:i$}});var K1=H((JU,W1)=>{var a$=function($){var U=$.readInt32BE(0),X=$.readUInt32BE(4),Z="";if(U<0)U=~U+(X===0),X=~X+1>>>0,Z="-";var J="",G,Y,Q,j,W,K;{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}return G=U%N,Y=4294967296*G+X,Q=""+Y%N,Z+Q+J},N=1e6;W1.exports=a$});var R1=H((GU,z1)=>{var t$=K1(),z=function($,U,X,Z,J){X=X||0,Z=Z||!1,J=J||function(E,G0,Y0){return E*Math.pow(2,Y0)+G0};var G=X>>3,Y=function(E){if(Z)return~E&255;return E},Q=255,j=8-X%8;if(U<j)Q=255<<8-U&255,j=U;if(X)Q=Q>>X%8;var W=0;if(X%8+U>=8)W=J(0,Y($[G])&Q,j);var K=U+X>>3;for(var O=G+1;O<K;O++)W=J(W,Y($[O]),8);var _=(U+X)%8;if(_>0)W=J(W,Y($[K])>>8-_,_);return W},_1=function($,U,X){var Z=Math.pow(2,X-1)-1,J=z($,1),G=z($,X,1);if(G===0)return 0;var Y=1,Q=function(W,K,O){if(W===0)W=1;for(var _=1;_<=O;_++)if(Y/=2,(K&1<<O-_)>0)W+=Y;return W},j=z($,U,X+1,!1,Q);if(G==Math.pow(2,X+1)-1){if(j===0)return J===0?Infinity:(-Infinity);return NaN}return(J===0?1:-1)*Math.pow(2,G-Z)*j},s$=function($){if(z($,1)==1)return-1*(z($,15,1,!0)+1);return z($,15,1)},H1=function($){if(z($,1)==1)return-1*(z($,31,1,!0)+1);return z($,31,1)},r$=function($){return _1($,23,8)},e$=function($){return _1($,52,11)},$4=function($){var U=z($,16,32);if(U==49152)return NaN;var X=Math.pow(1e4,z($,16,16)),Z=0,J=[],G=z($,16);for(var Y=0;Y<G;Y++)Z+=z($,16,64+16*Y)*X,X/=1e4;var Q=Math.pow(10,z($,16,48));return(U===0?1:-1)*Math.round(Z*Q)/Q},O1=function($,U){var X=z(U,1),Z=z(U,63,1),J=new Date((X===0?1:-1)*Z/1000+946684800000);if(!$)J.setTime(J.getTime()+J.getTimezoneOffset()*60000);return J.usec=Z%1000,J.getMicroSeconds=function(){return this.usec},J.setMicroSeconds=function(G){this.usec=G},J.getUTCMicroSeconds=function(){return this.usec},J},p=function($){var U=z($,32),X=z($,32,32),Z=z($,32,64),J=96,G=[];for(var Y=0;Y<U;Y++)G[Y]=z($,32,J),J+=32,J+=32;var Q=function(W){var K=z($,32,J);if(J+=32,K==4294967295)return null;var O;if(W==23||W==20)return O=z($,K*8,J),J+=K*8,O;else if(W==25)return O=$.toString(this.encoding,J>>3,(J+=K<<3)>>3),O;else console.log("ERROR: ElementType not implemented: "+W)},j=function(W,K){var O=[],_;if(W.length>1){var E=W.shift();for(_=0;_<E;_++)O[_]=j(W,K);W.unshift(E)}else for(_=0;_<W[0];_++)O[_]=Q(K);return O};return j(G,Z)},U4=function($){return $.toString("utf8")},X4=function($){if($===null)return null;return z($,8)>0},Z4=function($){$(20,t$),$(21,s$),$(23,H1),$(26,H1),$(1700,$4),$(700,r$),$(701,e$),$(16,X4),$(1114,O1.bind(null,!1)),$(1184,O1.bind(null,!0)),$(1000,p),$(1007,p),$(1016,p),$(1008,p),$(1009,p),$(25,U4)};z1.exports={init:Z4}});var F1=H((YU,L1)=>{L1.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 f=H((K4)=>{var M1=function($){return String($)},j4=function($,U){if(U=U||"text",!u[U])return M1;return u[U][$]||M1},W4=function($,U,X){if(typeof U=="function")X=U,U="text";u[U][$]=X},J4=j1(),G4=R1(),Y4=W0(),Q4=F1();K4.getTypeParser=j4;K4.setTypeParser=W4;K4.arrayParser=Y4;K4.builtins=Q4;var u={text:{},binary:{}};J4.init(function($,U){u.text[$]=U});G4.init(function($,U){u.binary[$]=U})});var g=H((jU,F0)=>{F0.exports={host:"localhost",user:process.platform==="win32"?process.env.USERNAME:process.env.USER,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 B=f(),R4=B.getTypeParser(20,"text"),L4=B.getTypeParser(1016,"text");F0.exports.__defineSetter__("parseInt8",function($){B.setTypeParser(20,"text",$?B.getTypeParser(23,"text"):R4),B.setTypeParser(1016,"text",$?B.getTypeParser(1007,"text"):L4)})});var c=H((WU,N1)=>{var M4=function($){var U=$.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return'"'+U+'"'},A1=function($){var U="{";for(var X=0;X<$.length;X++){if(X>0)U=U+",";if($[X]===null||typeof $[X]==="undefined")U=U+"NULL";else if(Array.isArray($[X]))U=U+A1($[X]);else if($[X]instanceof Buffer)U+="\\\\x"+$[X].toString("hex");else U+=M4(s($[X]))}return U=U+"}",U},A4=function($,U){if($&&typeof $.toPostgres==="function"){if(U=U||[],U.indexOf($)!==-1)throw new Error('circular reference detected while preparing "'+$+'" for query');return U.push($),s($.toPostgres(s),U)}return JSON.stringify($)},M=function($,U){$=""+$;while($.length<U)$="0"+$;return $},N4=function($){var U=-$.getTimezoneOffset(),X=$.getFullYear(),Z=X<1;if(Z)X=Math.abs(X)+1;var J=M(X,4)+"-"+M($.getMonth()+1,2)+"-"+M($.getDate(),2)+"T"+M($.getHours(),2)+":"+M($.getMinutes(),2)+":"+M($.getSeconds(),2)+"."+M($.getMilliseconds(),3);if(U<0)J+="-",U*=-1;else J+="+";if(J+=M(Math.floor(U/60),2)+":"+M(U%60,2),Z)J+=" BC";return J},V4=function($){var U=$.getUTCFullYear(),X=U<1;if(X)U=Math.abs(U)+1;var Z=M(U,4)+"-"+M($.getUTCMonth()+1,2)+"-"+M($.getUTCDate(),2)+"T"+M($.getUTCHours(),2)+":"+M($.getUTCMinutes(),2)+":"+M($.getUTCSeconds(),2)+"."+M($.getUTCMilliseconds(),3);if(Z+="+00:00",X)Z+=" BC";return Z},E4=function($,U,X){if($=typeof $==="string"?{text:$}:$,U)if(typeof U==="function")$.callback=U;else $.values=U;if(X)$.callback=X;return $},F4=g(),s=function($,U){if($==null)return null;if($ instanceof Buffer)return $;if(ArrayBuffer.isView($)){var X=Buffer.from($.buffer,$.byteOffset,$.byteLength);if(X.length===$.byteLength)return X;return X.slice($.byteOffset,$.byteOffset+$.byteLength)}if($ instanceof Date)if(F4.parseInputDatesAsUTC)return V4($);else return N4($);if(Array.isArray($))return A1($);if(typeof $==="object")return A4($,U);return $.toString()},S4=function($){return'"'+$.replace(/"/g,'""')+'"'},T4=function($){var U=!1,X="'";for(var Z=0;Z<$.length;Z++){var J=$[Z];if(J==="'")X+=J+J;else if(J==="\\")X+=J+J,U=!0;else X+=J}if(X+="'",U===!0)X=" E"+X;return X};N1.exports={prepareValue:function $(U){return s(U)},normalizeQueryConfig:E4,escapeIdentifier:S4,escapeLiteral:T4}});var E1=H((KU,V1)=>{var M0=function($){return l.createHash("md5").update($,"utf-8").digest("hex")},P4=function($,U,X){var Z=M0(U+$),J=M0(Buffer.concat([Buffer.from(Z),X]));return"md5"+J},C4=function($){return l.createHash("sha256").update($).digest()},q4=function($,U){return l.createHmac("sha256",$).update(U).digest()};async function D4($,U,X){return l.pbkdf2Sync($,U,X,32,"sha256")}var l=import.meta.require("crypto");V1.exports={postgresMd5PasswordHash:P4,randomBytes:l.randomBytes,deriveKey:D4,sha256:C4,hmacSha256:q4,md5:M0}});var C1=H((HU,P1)=>{var k4=function($){return T1.getRandomValues(Buffer.alloc($))};async function A0($){try{return S1.createHash("md5").update($,"utf-8").digest("hex")}catch(U){const X=typeof $==="string"?N0.encode($):$,Z=await I.digest("MD5",X);return Array.from(new Uint8Array(Z)).map((J)=>J.toString(16).padStart(2,"0")).join("")}}async function B4($,U,X){var Z=await A0(U+$),J=await A0(Buffer.concat([Buffer.from(Z),X]));return"md5"+J}async function I4($){return await I.digest("SHA-256",$)}async function x4($,U){const X=await I.importKey("raw",$,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return await I.sign("HMAC",X,N0.encode(U))}async function w4($,U,X){const Z=await I.importKey("raw",N0.encode($),"PBKDF2",!1,["deriveBits"]),J={name:"PBKDF2",hash:"SHA-256",salt:U,iterations:X};return await I.deriveBits(J,Z,256,["deriveBits"])}var S1=import.meta.require("crypto");P1.exports={postgresMd5PasswordHash:B4,randomBytes:k4,deriveKey:w4,sha256:I4,hmacSha256:x4,md5:A0};var T1=S1.webcrypto||globalThis.crypto,I=T1.subtle,N0=new TextEncoder});var E0=H((OU,V0)=>{var h4=parseInt(process.versions&&process.versions.node&&process.versions.node.split(".")[0])<15;if(h4)V0.exports=E1();else V0.exports=C1()});var B1=H((_U,k1)=>{var b4=function($){if($.indexOf("SCRAM-SHA-256")===-1)throw new Error("SASL: Only mechanism SCRAM-SHA-256 is currently supported");const U=q.randomBytes(18).toString("base64");return{mechanism:"SCRAM-SHA-256",clientNonce:U,response:"n,,n=*,r="+U,message:"SASLInitialResponse"}};async function v4($,U,X){if($.message!=="SASLInitialResponse")throw new Error("SASL: Last message was not SASLInitialResponse");if(typeof U!=="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");if(U==="")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string");if(typeof X!=="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");const Z=m4(X);if(!Z.nonce.startsWith($.clientNonce))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");else if(Z.nonce.length===$.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short");var J="n=*,r="+$.clientNonce,G="r="+Z.nonce+",s="+Z.salt+",i="+Z.iteration,Y="c=biws,r="+Z.nonce,Q=J+","+G+","+Y,j=Buffer.from(Z.salt,"base64"),W=await q.deriveKey(U,j,Z.iteration),K=await q.hmacSha256(W,"Client Key"),O=await q.sha256(K),_=await q.hmacSha256(O,Q),E=u4(Buffer.from(K),Buffer.from(_)).toString("base64"),G0=await q.hmacSha256(W,"Server Key"),Y0=await q.hmacSha256(G0,Q);$.message="SASLResponse",$.serverSignature=Buffer.from(Y0).toString("base64"),$.response=Y+",p="+E}var y4=function($,U){if($.message!=="SASLResponse")throw new Error("SASL: Last message was not SASLResponse");if(typeof U!=="string")throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");const{serverSignature:X}=p4(U);if(X!==$.serverSignature)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match")},d4=function($){if(typeof $!=="string")throw new TypeError("SASL: text must be a string");return $.split("").map((U,X)=>$.charCodeAt(X)).every((U)=>U>=33&&U<=43||U>=45&&U<=126)},q1=function($){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test($)},D1=function($){if(typeof $!=="string")throw new TypeError("SASL: attribute pairs text must be a string");return new Map($.split(",").map((U)=>{if(!/^.=/.test(U))throw new Error("SASL: Invalid attribute pair entry");const X=U[0],Z=U.substring(2);return[X,Z]}))},m4=function($){const U=D1($),X=U.get("r");if(!X)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");else if(!d4(X))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters");const Z=U.get("s");if(!Z)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing");else if(!q1(Z))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64");const J=U.get("i");if(!J)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing");else if(!/^[1-9][0-9]*$/.test(J))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count");const G=parseInt(J,10);return{nonce:X,salt:Z,iteration:G}},p4=function($){const X=D1($).get("v");if(!X)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");else if(!q1(X))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64");return{serverSignature:X}},u4=function($,U){if(!Buffer.isBuffer($))throw new TypeError("first argument must be a Buffer");if(!Buffer.isBuffer(U))throw new TypeError("second argument must be a Buffer");if($.length!==U.length)throw new Error("Buffer lengths must match");if($.length===0)throw new Error("Buffers cannot be empty");return Buffer.from($.map((X,Z)=>$[Z]^U[Z]))},q=E0();k1.exports={startSession:b4,continueSession:v4,finalizeSession:y4}});var S0=H((zU,I1)=>{var r=function($){this._types=$||f4,this.text={},this.binary={}},f4=f();r.prototype.getOverrides=function($){switch($){case"text":return this.text;case"binary":return this.binary;default:return{}}};r.prototype.setTypeParser=function($,U,X){if(typeof U==="function")X=U,U="text";this.getOverrides(U)[$]=X};r.prototype.getTypeParser=function($,U){return U=U||"text",this.getOverrides(U)[$]||this._types.getTypeParser($,U)};I1.exports=r});var w1=H((RU,x1)=>{var T0=function($){if($.charAt(0)==="/"){const Q=$.split(" ");return{host:Q[0],database:Q[1]}}const U={};let X,Z=!1;if(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test($))$=encodeURI($).replace(/\%25(\d\d)/g,"%$1");try{X=new URL($,"postgres://base")}catch(Q){X=new URL($.replace("@/","@___DUMMY___/"),"postgres://base"),Z=!0}for(let Q of X.searchParams.entries())U[Q[0]]=Q[1];if(U.user=U.user||decodeURIComponent(X.username),U.password=U.password||decodeURIComponent(X.password),X.protocol=="socket:")return U.host=decodeURI(X.pathname),U.database=X.searchParams.get("db"),U.client_encoding=X.searchParams.get("encoding"),U;const J=Z?"":X.hostname;if(!U.host)U.host=decodeURIComponent(J);else if(J&&/^%2f/i.test(J))X.pathname=J+X.pathname;if(!U.port)U.port=X.port;const G=X.pathname.slice(1)||null;if(U.database=G?decodeURI(G):null,U.ssl==="true"||U.ssl==="1")U.ssl=!0;if(U.ssl==="0")U.ssl=!1;if(U.sslcert||U.sslkey||U.sslrootcert||U.sslmode)U.ssl={};const Y=U.sslcert||U.sslkey||U.sslrootcert?import.meta.require("fs"):null;if(U.sslcert)U.ssl.cert=Y.readFileSync(U.sslcert).toString();if(U.sslkey)U.ssl.key=Y.readFileSync(U.sslkey).toString();if(U.sslrootcert)U.ssl.ca=Y.readFileSync(U.sslrootcert).toString();switch(U.sslmode){case"disable":{U.ssl=!1;break}case"prefer":case"require":case"verify-ca":case"verify-full":break;case"no-verify":{U.ssl.rejectUnauthorized=!1;break}}return U};x1.exports=T0;T0.parse=T0});var P0=H((LU,y1)=>{var g4=import.meta.require("dns"),b1=g(),h1=w1().parse,A=function($,U,X){if(X===void 0)X=process.env["PG"+$.toUpperCase()];else if(X===!1);else X=process.env[X];return U[$]||X||b1[$]},c4=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 b1.ssl},x=function($){return"'"+(""+$).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},T=function($,U,X){var Z=U[X];if(Z!==void 0&&Z!==null)$.push(X+"="+x(Z))};class v1{constructor($){if($=typeof $==="string"?h1($):$||{},$.connectionString)$=Object.assign({},$,h1($.connectionString));if(this.user=A("user",$),this.database=A("database",$),this.database===void 0)this.database=this.user;if(this.port=parseInt(A("port",$),10),this.host=A("host",$),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:A("password",$)}),this.binary=A("binary",$),this.options=A("options",$),this.ssl=typeof $.ssl==="undefined"?c4():$.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=A("client_encoding",$),this.replication=A("replication",$),this.isDomainSocket=!(this.host||"").indexOf("/"),this.application_name=A("application_name",$,"PGAPPNAME"),this.fallback_application_name=A("fallback_application_name",$,!1),this.statement_timeout=A("statement_timeout",$,!1),this.lock_timeout=A("lock_timeout",$,!1),this.idle_in_transaction_session_timeout=A("idle_in_transaction_session_timeout",$,!1),this.query_timeout=A("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($){var U=[];T(U,this,"user"),T(U,this,"password"),T(U,this,"port"),T(U,this,"application_name"),T(U,this,"fallback_application_name"),T(U,this,"connect_timeout"),T(U,this,"options");var X=typeof this.ssl==="object"?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(T(U,X,"sslmode"),T(U,X,"sslca"),T(U,X,"sslkey"),T(U,X,"sslcert"),T(U,X,"sslrootcert"),this.database)U.push("dbname="+x(this.database));if(this.replication)U.push("replication="+x(this.replication));if(this.host)U.push("host="+x(this.host));if(this.isDomainSocket)return $(null,U.join(" "));if(this.client_encoding)U.push("client_encoding="+x(this.client_encoding));g4.lookup(this.host,function(Z,J){if(Z)return $(Z,null);return U.push("hostaddr="+x(J)),$(null,U.join(" "))})}}y1.exports=v1});var u1=H((FU,p1)=>{var l4=f(),d1=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/;class m1{constructor($,U){if(this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0,this._types=U,this.RowCtor=null,this.rowAsArray=$==="array",this.rowAsArray)this.parseRow=this._parseRowAsArray;this._prebuiltEmptyResultObject=null}addCommandComplete($){var U;if($.text)U=d1.exec($.text);else U=d1.exec($.command);if(U){if(this.command=U[1],U[3])this.oid=parseInt(U[2],10),this.rowCount=parseInt(U[3],10);else if(U[2])this.rowCount=parseInt(U[2],10)}}_parseRowAsArray($){var U=new Array($.length);for(var X=0,Z=$.length;X<Z;X++){var J=$[X];if(J!==null)U[X]=this._parsers[X](J);else U[X]=null}return U}parseRow($){var U={...this._prebuiltEmptyResultObject};for(var X=0,Z=$.length;X<Z;X++){var J=$[X],G=this.fields[X].name;if(J!==null)U[G]=this._parsers[X](J)}return U}addRow($){this.rows.push($)}addFields($){if(this.fields=$,this.fields.length)this._parsers=new Array($.length);for(var U=0;U<$.length;U++){var X=$[U];if(this._types)this._parsers[U]=this._types.getTypeParser(X.dataTypeID,X.format||"text");else this._parsers[U]=l4.getTypeParser(X.dataTypeID,X.format||"text")}this._createPrebuiltEmptyResultObject()}_createPrebuiltEmptyResultObject(){var $={};for(var U=0;U<this.fields.length;U++)$[this.fields[U].name]=null;this._prebuiltEmptyResultObject={...$}}}p1.exports=m1});var o1=H((MU,l1)=>{var{EventEmitter:o4}=import.meta.require("events"),f1=u1(),g1=c();class c1 extends o4{constructor($,U,X){super();if($=g1.normalizeQueryConfig($,U,X),this.text=$.text,this.values=$.values,this.rows=$.rows,this.types=$.types,this.name=$.name,this.binary=$.binary,this.portal=$.portal||"",this.callback=$.callback,this._rowMode=$.rowMode,process.domain&&$.callback)this.callback=process.domain.bind($.callback);this._result=new f1(this._rowMode,this.types),this._results=this._result,this.isPreparedStatement=!1,this._canceledDueToError=!1,this._promise=null}requiresPreparation(){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 f1(this._rowMode,this.types),this._results.push(this._result)}}handleRowDescription($){this._checkForMultirow(),this._result.addFields($.fields),this._accumulateRows=this.callback||!this.listeners("row").length}handleDataRow($){let U;if(this._canceledDueToError)return;try{U=this._result.parseRow($.fields)}catch(X){this._canceledDueToError=X;return}if(this.emit("row",U,this._result),this._accumulateRows)this._result.addRow(U)}handleCommandComplete($,U){if(this._checkForMultirow(),this._result.addCommandComplete($),this.rows)U.sync()}handleEmptyQuery($){if(this.rows)$.sync()}handleError($,U){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(U){process.nextTick(()=>{throw U})}this.emit("end",this._results)}submit($){if(typeof this.text!=="string"&&typeof this.name!=="string")return new Error("A query must have either text or a name. Supplying neither is unsupported.");const U=$.parsedStatements[this.name];if(this.text&&U&&this.text!==U)return new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);if(this.values&&!Array.isArray(this.values))return new Error("Query values must be an array");if(this.requiresPreparation())this.prepare($);else $.query(this.text);return null}hasBeenParsed($){return this.name&&$.parsedStatements[this.name]}handlePortalSuspended($){this._getRows($,this.rows)}_getRows($,U){if($.execute({portal:this.portal,rows:U}),!U)$.sync();else $.flush()}prepare($){if(this.isPreparedStatement=!0,!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:g1.prepareValue})}catch(U){this.handleError(U,$);return}$.describe({type:"P",name:this.portal||""}),this._getRows($,this.rows)}handleCopyInResponse($){$.sendCopyFail("No source stream defined")}handleCopyData($,U){}}l1.exports=c1});var C0=H((Q8)=>{Object.defineProperty(Q8,"__esModule",{value:!0});Q8.NoticeMessage=Q8.DataRowMessage=Q8.CommandCompleteMessage=Q8.ReadyForQueryMessage=Q8.NotificationResponseMessage=Q8.BackendKeyDataMessage=Q8.AuthenticationMD5Password=Q8.ParameterStatusMessage=Q8.ParameterDescriptionMessage=Q8.RowDescriptionMessage=Q8.Field=Q8.CopyResponse=Q8.CopyDataMessage=Q8.DatabaseError=Q8.copyDone=Q8.emptyQuery=Q8.replicationStart=Q8.portalSuspended=Q8.noData=Q8.closeComplete=Q8.bindComplete=Q8.parseComplete=void 0;Q8.parseComplete={name:"parseComplete",length:5};Q8.bindComplete={name:"bindComplete",length:5};Q8.closeComplete={name:"closeComplete",length:5};Q8.noData={name:"noData",length:5};Q8.portalSuspended={name:"portalSuspended",length:5};Q8.replicationStart={name:"replicationStart",length:4};Q8.emptyQuery={name:"emptyQuery",length:4};Q8.copyDone={name:"copyDone",length:4};class n1 extends Error{constructor($,U,X){super($);this.length=U,this.name=X}}Q8.DatabaseError=n1;class i1{constructor($,U){this.length=$,this.chunk=U,this.name="copyData"}}Q8.CopyDataMessage=i1;class a1{constructor($,U,X,Z){this.length=$,this.name=U,this.binary=X,this.columnTypes=new Array(Z)}}Q8.CopyResponse=a1;class t1{constructor($,U,X,Z,J,G,Y){this.name=$,this.tableID=U,this.columnID=X,this.dataTypeID=Z,this.dataTypeSize=J,this.dataTypeModifier=G,this.format=Y}}Q8.Field=t1;class s1{constructor($,U){this.length=$,this.fieldCount=U,this.name="rowDescription",this.fields=new Array(this.fieldCount)}}Q8.RowDescriptionMessage=s1;class r1{constructor($,U){this.length=$,this.parameterCount=U,this.name="parameterDescription",this.dataTypeIDs=new Array(this.parameterCount)}}Q8.ParameterDescriptionMessage=r1;class e1{constructor($,U,X){this.length=$,this.parameterName=U,this.parameterValue=X,this.name="parameterStatus"}}Q8.ParameterStatusMessage=e1;class $8{constructor($,U){this.length=$,this.salt=U,this.name="authenticationMD5Password"}}Q8.AuthenticationMD5Password=$8;class U8{constructor($,U,X){this.length=$,this.processID=U,this.secretKey=X,this.name="backendKeyData"}}Q8.BackendKeyDataMessage=U8;class X8{constructor($,U,X,Z){this.length=$,this.processId=U,this.channel=X,this.payload=Z,this.name="notification"}}Q8.NotificationResponseMessage=X8;class Z8{constructor($,U){this.length=$,this.status=U,this.name="readyForQuery"}}Q8.ReadyForQueryMessage=Z8;class J8{constructor($,U){this.length=$,this.text=U,this.name="commandComplete"}}Q8.CommandCompleteMessage=J8;class G8{constructor($,U){this.length=$,this.fields=U,this.name="dataRow",this.fieldCount=U.length}}Q8.DataRowMessage=G8;class Y8{constructor($,U){this.length=$,this.message=U,this.name="notice"}}Q8.NoticeMessage=Y8});var O8=H((K8)=>{Object.defineProperty(K8,"__esModule",{value:!0});K8.Writer=void 0;class W8{constructor($=256){this.size=$,this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe($)}ensure($){var U=this.buffer.length-this.offset;if(U<$){var X=this.buffer,Z=X.length+(X.length>>1)+$;this.buffer=Buffer.allocUnsafe(Z),X.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{var U=Buffer.byteLength($);this.ensure(U+1),this.buffer.write($,this.offset,"utf-8"),this.offset+=U}return this.buffer[this.offset++]=0,this}addString($=""){var U=Buffer.byteLength($);return this.ensure(U),this.buffer.write($,this.offset),this.offset+=U,this}add($){return this.ensure($.length),$.copy(this.buffer,this.offset),this.offset+=$.length,this}join($){if($){this.buffer[this.headerPosition]=$;const U=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(U,this.headerPosition+1)}return this.buffer.slice($?0:5,this.offset)}flush($){var U=this.join($);return this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(this.size),U}}K8.Writer=W8});var L8=H((z8)=>{Object.defineProperty(z8,"__esModule",{value:!0});z8.serialize=void 0;var q0=O8(),R=new q0.Writer,z5=($)=>{R.addInt16(3).addInt16(0);for(let Z of Object.keys($))R.addCString(Z).addCString($[Z]);R.addCString("client_encoding").addCString("UTF8");var U=R.addCString("").flush(),X=U.length+4;return new q0.Writer().addInt32(X).add(U).flush()},R5=()=>{const $=Buffer.allocUnsafe(8);return $.writeInt32BE(8,0),$.writeInt32BE(80877103,4),$},L5=($)=>{return R.addCString($).flush(112)},F5=function($,U){return R.addCString($).addInt32(Buffer.byteLength(U)).addString(U),R.flush(112)},M5=function($){return R.addString($).flush(112)},A5=($)=>{return R.addCString($).flush(81)},_8=[],N5=($)=>{const U=$.name||"";if(U.length>63)console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",U,U.length),console.error("This can cause conflicts and silent errors executing queries");const X=$.types||_8;var Z=X.length,J=R.addCString(U).addCString($.text).addInt16(Z);for(var G=0;G<Z;G++)J.addInt32(X[G]);return R.flush(80)},w=new q0.Writer,V5=function($,U){for(let X=0;X<$.length;X++){const Z=U?U($[X],X):$[X];if(Z==null)R.addInt16(0),w.addInt32(-1);else if(Z instanceof Buffer)R.addInt16(1),w.addInt32(Z.length),w.add(Z);else R.addInt16(0),w.addInt32(Buffer.byteLength(Z)),w.addString(Z)}},E5=($={})=>{const U=$.portal||"",X=$.statement||"",Z=$.binary||!1,J=$.values||_8,G=J.length;return R.addCString(U).addCString(X),R.addInt16(G),V5(J,$.valueMapper),R.addInt16(G),R.add(w.flush()),R.addInt16(Z?1:0),R.flush(66)},S5=Buffer.from([69,0,0,0,9,0,0,0,0,0]),T5=($)=>{if(!$||!$.portal&&!$.rows)return S5;const U=$.portal||"",X=$.rows||0,Z=Buffer.byteLength(U),J=4+Z+1+4,G=Buffer.allocUnsafe(1+J);return G[0]=69,G.writeInt32BE(J,1),G.write(U,5,"utf-8"),G[Z+5]=0,G.writeUInt32BE(X,G.length-4),G},P5=($,U)=>{const X=Buffer.allocUnsafe(16);return X.writeInt32BE(16,0),X.writeInt16BE(1234,4),X.writeInt16BE(5678,6),X.writeInt32BE($,8),X.writeInt32BE(U,12),X},D0=($,U)=>{const Z=4+Buffer.byteLength(U)+1,J=Buffer.allocUnsafe(1+Z);return J[0]=$,J.writeInt32BE(Z,1),J.write(U,5,"utf-8"),J[Z]=0,J},C5=R.addCString("P").flush(68),q5=R.addCString("S").flush(68),D5=($)=>{return $.name?D0(68,`${$.type}${$.name||""}`):$.type==="P"?C5:q5},k5=($)=>{const U=`${$.type}${$.name||""}`;return D0(67,U)},B5=($)=>{return R.add($).flush(100)},I5=($)=>{return D0(102,$)},e=($)=>Buffer.from([$,0,0,0,4]),x5=e(72),w5=e(83),h5=e(88),b5=e(99),v5={startup:z5,password:L5,requestSsl:R5,sendSASLInitialResponseMessage:F5,sendSCRAMClientFinalMessage:M5,query:A5,parse:N5,bind:E5,execute:T5,describe:D5,close:k5,flush:()=>x5,sync:()=>w5,end:()=>h5,copyData:B5,copyDone:()=>b5,copyFail:I5,cancel:P5};z8.serialize=v5});var N8=H((M8)=>{Object.defineProperty(M8,"__esModule",{value:!0});M8.BufferReader=void 0;var y5=Buffer.allocUnsafe(0);class F8{constructor($=0){this.offset=$,this.buffer=y5,this.encoding="utf-8"}setBuffer($,U){this.offset=$,this.buffer=U}int16(){const $=this.buffer.readInt16BE(this.offset);return this.offset+=2,$}byte(){const $=this.buffer[this.offset];return this.offset++,$}int32(){const $=this.buffer.readInt32BE(this.offset);return this.offset+=4,$}string($){const U=this.buffer.toString(this.encoding,this.offset,this.offset+$);return this.offset+=$,U}cstring(){const $=this.offset;let U=$;while(this.buffer[U++]!==0);return this.offset=U,this.buffer.toString(this.encoding,$,U-1)}bytes($){const U=this.buffer.slice(this.offset,this.offset+$);return this.offset+=$,U}}M8.BufferReader=F8});var T8=H((h)=>{var d5=h&&h.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(h,"__esModule",{value:!0});h.Parser=void 0;var L=C0(),m5=N8(),p5=d5(import.meta.require("assert")),k0=1,u5=4,V8=k0+u5,E8=Buffer.allocUnsafe(0);class S8{constructor($){if(this.buffer=E8,this.bufferLength=0,this.bufferOffset=0,this.reader=new m5.BufferReader,($===null||$===void 0?void 0:$.mode)==="binary")throw new Error("Binary mode not supported yet");this.mode=($===null||$===void 0?void 0:$.mode)||"text"}parse($,U){this.mergeBuffer($);const X=this.bufferOffset+this.bufferLength;let Z=this.bufferOffset;while(Z+V8<=X){const J=this.buffer[Z],G=this.buffer.readUInt32BE(Z+k0),Y=k0+G;if(Y+Z<=X){const Q=this.handlePacket(Z+V8,J,G,this.buffer);U(Q),Z+=Y}else break}if(Z===X)this.buffer=E8,this.bufferLength=0,this.bufferOffset=0;else this.bufferLength=X-Z,this.bufferOffset=Z}mergeBuffer($){if(this.bufferLength>0){const U=this.bufferLength+$.byteLength;if(U+this.bufferOffset>this.buffer.byteLength){let Z;if(U<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)Z=this.buffer;else{let J=this.buffer.byteLength*2;while(U>=J)J*=2;Z=Buffer.allocUnsafe(J)}this.buffer.copy(Z,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=Z,this.bufferOffset=0}$.copy(this.buffer,this.bufferOffset+this.bufferLength),this.bufferLength=U}else this.buffer=$,this.bufferOffset=0,this.bufferLength=$.byteLength}handlePacket($,U,X,Z){switch(U){case 50:return L.bindComplete;case 49:return L.parseComplete;case 51:return L.closeComplete;case 110:return L.noData;case 115:return L.portalSuspended;case 99:return L.copyDone;case 87:return L.replicationStart;case 73:return L.emptyQuery;case 68:return this.parseDataRowMessage($,X,Z);case 67:return this.parseCommandCompleteMessage($,X,Z);case 90:return this.parseReadyForQueryMessage($,X,Z);case 65:return this.parseNotificationMessage($,X,Z);case 82:return this.parseAuthenticationResponse($,X,Z);case 83:return this.parseParameterStatusMessage($,X,Z);case 75:return this.parseBackendKeyData($,X,Z);case 69:return this.parseErrorMessage($,X,Z,"error");case 78:return this.parseErrorMessage($,X,Z,"notice");case 84:return this.parseRowDescriptionMessage($,X,Z);case 116:return this.parseParameterDescriptionMessage($,X,Z);case 71:return this.parseCopyInMessage($,X,Z);case 72:return this.parseCopyOutMessage($,X,Z);case 100:return this.parseCopyData($,X,Z);default:p5.default.fail(`unknown message code: ${U.toString(16)}`)}}parseReadyForQueryMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.string(1);return new L.ReadyForQueryMessage(U,Z)}parseCommandCompleteMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.cstring();return new L.CommandCompleteMessage(U,Z)}parseCopyData($,U,X){const Z=X.slice($,$+(U-4));return new L.CopyDataMessage(U,Z)}parseCopyInMessage($,U,X){return this.parseCopyMessage($,U,X,"copyInResponse")}parseCopyOutMessage($,U,X){return this.parseCopyMessage($,U,X,"copyOutResponse")}parseCopyMessage($,U,X,Z){this.reader.setBuffer($,X);const J=this.reader.byte()!==0,G=this.reader.int16(),Y=new L.CopyResponse(U,Z,J,G);for(let Q=0;Q<G;Q++)Y.columnTypes[Q]=this.reader.int16();return Y}parseNotificationMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J=this.reader.cstring(),G=this.reader.cstring();return new L.NotificationResponseMessage(U,Z,J,G)}parseRowDescriptionMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new L.RowDescriptionMessage(U,Z);for(let G=0;G<Z;G++)J.fields[G]=this.parseField();return J}parseField(){const $=this.reader.cstring(),U=this.reader.int32(),X=this.reader.int16(),Z=this.reader.int32(),J=this.reader.int16(),G=this.reader.int32(),Y=this.reader.int16()===0?"text":"binary";return new L.Field($,U,X,Z,J,G,Y)}parseParameterDescriptionMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new L.ParameterDescriptionMessage(U,Z);for(let G=0;G<Z;G++)J.dataTypeIDs[G]=this.reader.int32();return J}parseDataRowMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new Array(Z);for(let G=0;G<Z;G++){const Y=this.reader.int32();J[G]=Y===-1?null:this.reader.string(Y)}return new L.DataRowMessage(U,J)}parseParameterStatusMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.cstring(),J=this.reader.cstring();return new L.ParameterStatusMessage(U,Z,J)}parseBackendKeyData($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J=this.reader.int32();return new L.BackendKeyDataMessage(U,Z,J)}parseAuthenticationResponse($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J={name:"authenticationOk",length:U};switch(Z){case 0:break;case 3:if(J.length===8)J.name="authenticationCleartextPassword";break;case 5:if(J.length===12){J.name="authenticationMD5Password";const Y=this.reader.bytes(4);return new L.AuthenticationMD5Password(U,Y)}break;case 10:J.name="authenticationSASL",J.mechanisms=[];let G;do if(G=this.reader.cstring(),G)J.mechanisms.push(G);while(G);break;case 11:J.name="authenticationSASLContinue",J.data=this.reader.string(U-8);break;case 12:J.name="authenticationSASLFinal",J.data=this.reader.string(U-8);break;default:throw new Error("Unknown authenticationOk message type "+Z)}return J}parseErrorMessage($,U,X,Z){this.reader.setBuffer($,X);const J={};let G=this.reader.string(1);while(G!=="\0")J[G]=this.reader.cstring(),G=this.reader.string(1);const Y=J.M,Q=Z==="notice"?new L.NoticeMessage(U,Y):new L.DatabaseError(Y,U,Z);return Q.severity=J.S,Q.code=J.C,Q.detail=J.D,Q.hint=J.H,Q.position=J.P,Q.internalPosition=J.p,Q.internalQuery=J.q,Q.where=J.W,Q.schema=J.s,Q.table=J.t,Q.column=J.c,Q.dataType=J.d,Q.constraint=J.n,Q.file=J.F,Q.line=J.L,Q.routine=J.R,Q}}h.Parser=S8});var B0=H(($0)=>{var l5=function($,U){const X=new c5.Parser;return $.on("data",(Z)=>X.parse(Z,U)),new Promise((Z)=>$.on("end",()=>Z()))};Object.defineProperty($0,"__esModule",{value:!0});$0.DatabaseError=$0.serialize=$0.parse=void 0;var f5=C0();Object.defineProperty($0,"DatabaseError",{enumerable:!0,get:function(){return f5.DatabaseError}});var g5=L8();Object.defineProperty($0,"serialize",{enumerable:!0,get:function(){return g5.serialize}});var c5=T8();$0.parse=l5});var P8={};z$(P8,{default:()=>{{return i5}}});var i5;var C8=R$(()=>{i5={}});var q8=H((a5,I0)=>{a5.getStream=function $(U){const X=import.meta.require("net");if(typeof X.Socket==="function")return new X.Socket;else{const{CloudflareSocket:Z}=(C8(),c0(P8));return new Z(U)}};a5.getSecureStream=function $(U){var X=import.meta.require("tls");if(X.connect)return X.connect(U);else return U.socket.startTls(U),U.socket}});var x0=H((qU,k8)=>{var CU=import.meta.require("net"),r5=import.meta.require("events").EventEmitter,{parse:e5,serialize:F}=B0(),{getStream:$9,getSecureStream:U9}=q8(),X9=F.flush(),Z9=F.sync(),J9=F.end();class D8 extends r5{constructor($){super();if($=$||{},this.stream=$.stream||$9($.ssl),typeof this.stream==="function")this.stream=this.stream($);this._keepAlive=$.keepAlive,this._keepAliveInitialDelayMillis=$.keepAliveInitialDelayMillis,this.lastBuffer=!1,this.parsedStatements={},this.ssl=$.ssl||!1,this._ending=!1,this._emitMessage=!1;var U=this;this.on("newListener",function(X){if(X==="message")U._emitMessage=!0})}connect($,U){var X=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect($,U),this.stream.once("connect",function(){if(X._keepAlive)X.stream.setKeepAlive(!0,X._keepAliveInitialDelayMillis);X.emit("connect")});const Z=function(J){if(X._ending&&(J.code==="ECONNRESET"||J.code==="EPIPE"))return;X.emit("error",J)};if(this.stream.on("error",Z),this.stream.on("close",function(){X.emit("end")}),!this.ssl)return this.attachListeners(this.stream);this.stream.once("data",function(J){var G=J.toString("utf8");switch(G){case"S":break;case"N":return X.stream.end(),X.emit("error",new Error("The server does not support SSL connections"));default:return X.stream.end(),X.emit("error",new Error("There was an error establishing an SSL connection"))}const Y={socket:X.stream};if(X.ssl!==!0){if(Object.assign(Y,X.ssl),"key"in X.ssl)Y.key=X.ssl.key}var Q=import.meta.require("net");if(Q.isIP&&Q.isIP(U)===0)Y.servername=U;try{X.stream=U9(Y)}catch(j){return X.emit("error",j)}X.attachListeners(X.stream),X.stream.on("error",Z),X.emit("sslconnect")})}attachListeners($){e5($,(U)=>{var X=U.name==="error"?"errorMessage":U.name;if(this._emitMessage)this.emit("message",U);this.emit(X,U)})}requestSsl(){this.stream.write(F.requestSsl())}startup($){this.stream.write(F.startup($))}cancel($,U){this._send(F.cancel($,U))}password($){this._send(F.password($))}sendSASLInitialResponseMessage($,U){this._send(F.sendSASLInitialResponseMessage($,U))}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(X9)}sync(){this._ending=!0,this._send(Z9)}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(J9,()=>{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($))}}k8.exports=D8});var w8=H((DU,x8)=>{var Q9=function($,U,X){let Z;if(this.overflow){if(Z=this[U0].write($).split(this.matcher),Z.length===1)return X();Z.shift(),this.overflow=!1}else this[C]+=this[U0].write($),Z=this[C].split(this.matcher);this[C]=Z.pop();for(let J=0;J<Z.length;J++)try{I8(this,this.mapper(Z[J]))}catch(G){return X(G)}if(this.overflow=this[C].length>this.maxLength,this.overflow&&!this.skipOverflow){X(new Error("maximum buffer reached"));return}X()},j9=function($){if(this[C]+=this[U0].end(),this[C])try{I8(this,this.mapper(this[C]))}catch(U){return $(U)}$()},I8=function($,U){if(U!==void 0)$.push(U)},B8=function($){return $},W9=function($,U,X){switch($=$||/\r?\n/,U=U||B8,X=X||{},arguments.length){case 1:if(typeof $==="function")U=$,$=/\r?\n/;else if(typeof $==="object"&&!($ instanceof RegExp)&&!$[Symbol.split])X=$,$=/\r?\n/;break;case 2:if(typeof $==="function")X=U,U=$,$=/\r?\n/;else if(typeof U==="object")X=U,U=B8}X=Object.assign({},X),X.autoDestroy=!0,X.transform=Q9,X.flush=j9,X.readableObjectMode=!0;const Z=new G9(X);return Z[C]="",Z[U0]=new Y9("utf8"),Z.matcher=$,Z.mapper=U,Z.maxLength=X.maxLength,Z.skipOverflow=X.skipOverflow||!1,Z.overflow=!1,Z._destroy=function(J,G){this._writableState.errorEmitted=!1,G(J)},Z},{Transform:G9}=import.meta.require("stream"),{StringDecoder:Y9}=import.meta.require("string_decoder"),C=Symbol("last"),U0=Symbol("decoder");x8.exports=W9});var v8=H((E9,P)=>{var F9=function($){return($&R9)==L9},h0=function(){var $=o instanceof K9&&o.writable===!0;if($){var U=Array.prototype.slice.call(arguments).concat("\n");o.write(b8.format.apply(b8,U))}},h8=import.meta.require("path"),K9=import.meta.require("stream").Stream,H9=w8(),b8=import.meta.require("util"),O9=5432,X0=process.platform==="win32",o=process.stderr,_9=56,z9=7,R9=61440,L9=32768,b=["host","port","database","user","password"],w0=b.length,M9=b[w0-1];Object.defineProperty(E9,"isWin",{get:function(){return X0},set:function($){X0=$}});E9.warnTo=function($){var U=o;return o=$,U};E9.getFileName=function($){var U=$||process.env,X=U.PGPASSFILE||(X0?h8.join(U.APPDATA||"./","postgresql","pgpass.conf"):h8.join(U.HOME||"./",".pgpass"));return X};E9.usePgPass=function($,U){if(Object.prototype.hasOwnProperty.call(process.env,"PGPASSWORD"))return!1;if(X0)return!0;if(U=U||"<unkn>",!F9($.mode))return h0('WARNING: password file "%s" is not a plain file',U),!1;if($.mode&(_9|z9))return h0('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less',U),!1;return!0};var A9=E9.match=function($,U){return b.slice(0,-1).reduce(function(X,Z,J){if(J==1){if(Number($[Z]||O9)===Number(U[Z]))return X&&!0}return X&&(U[Z]==="*"||U[Z]===$[Z])},!0)};E9.getPassword=function($,U,X){var Z,J=U.pipe(H9());function G(j){var W=N9(j);if(W&&V9(W)&&A9($,W))Z=W[M9],J.end()}var Y=function(){U.destroy(),X(Z)},Q=function(j){U.destroy(),h0("WARNING: error on reading file: %s",j),X(void 0)};U.on("error",Q),J.on("data",G).on("end",Y).on("error",Q)};var N9=E9.parseLine=function($){if($.length<11||$.match(/^\s+#/))return null;var U="",X="",Z=0,J=0,G=0,Y={},Q=!1,j=function(K,O,_){var E=$.substring(O,_);if(!Object.hasOwnProperty.call(process.env,"PGPASS_NO_DEESCAPE"))E=E.replace(/\\([:\\])/g,"$1");Y[b[K]]=E};for(var W=0;W<$.length-1;W+=1){if(U=$.charAt(W+1),X=$.charAt(W),Q=Z==w0-1,Q){j(Z,J);break}if(W>=0&&U==":"&&X!=="\\")j(Z,J,W+1),J=W+2,Z+=1}return Y=Object.keys(Y).length===w0?Y:null,Y},V9=E9.isValidEntry=function($){var U={0:function(Y){return Y.length>0},1:function(Y){if(Y==="*")return!0;return Y=Number(Y),isFinite(Y)&&Y>0&&Y<9007199254740992&&Math.floor(Y)===Y},2:function(Y){return Y.length>0},3:function(Y){return Y.length>0},4:function(Y){return Y.length>0}};for(var X=0;X<b.length;X+=1){var Z=U[X],J=$[b[X]]||"",G=Z(J);if(!G)return!1}return!0}});var d8=H((wU,b0)=>{var xU=import.meta.require("path"),y8=import.meta.require("fs"),Z0=v8();b0.exports=function($,U){var X=Z0.getFileName();y8.stat(X,function(Z,J){if(Z||!Z0.usePgPass(J,X))return U(void 0);var G=y8.createReadStream(X);Z0.getPassword($,G,U)})};b0.exports.warnTo=Z0.warnTo});var f8=H((hU,u8)=>{var q9=import.meta.require("events").EventEmitter,m8=c(),v0=B1(),D9=S0(),k9=P0(),p8=o1(),B9=g(),I9=x0(),x9=E0();class y0 extends q9{constructor($){super();this.connectionParameters=new k9($),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;var U=$||{};if(this._Promise=U.Promise||global.Promise,this._types=new D9(U.types),this._ending=!1,this._ended=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this.connection=U.connection||new I9({stream:U.stream,ssl:this.connectionParameters.ssl,keepAlive:U.keepAlive||!1,keepAliveInitialDelayMillis:U.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||"utf8"}),this.queryQueue=[],this.binary=U.binary||B9.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=U.connectionTimeoutMillis||0}_errorAllQueries($){const U=(X)=>{process.nextTick(()=>{X.handleError($,this.connection)})};if(this.activeQuery)U(this.activeQuery),this.activeQuery=null;this.queryQueue.forEach(U),this.queryQueue.length=0}_connect($){var U=this,X=this.connection;if(this._connectionCallback=$,this._connecting||this._connected){const Z=new Error("Client has already been connected. You cannot reuse a client.");process.nextTick(()=>{$(Z)});return}if(this._connecting=!0,this.connectionTimeoutHandle,this._connectionTimeoutMillis>0)this.connectionTimeoutHandle=setTimeout(()=>{X._ending=!0,X.stream.destroy(new Error("timeout expired"))},this._connectionTimeoutMillis);if(this.host&&this.host.indexOf("/")===0)X.connect(this.host+"/.s.PGSQL."+this.port);else X.connect(this.port,this.host);X.on("connect",function(){if(U.ssl)X.requestSsl();else X.startup(U.getStartupConf())}),X.on("sslconnect",function(){X.startup(U.getStartupConf())}),this._attachListeners(X),X.once("end",()=>{const Z=this._ending?new Error("Connection terminated"):new Error("Connection terminated unexpectedly");if(clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(Z),this._ended=!0,!this._ending){if(this._connecting&&!this._connectionError)if(this._connectionCallback)this._connectionCallback(Z);else this._handleErrorEvent(Z);else if(!this._connectionError)this._handleErrorEvent(Z)}process.nextTick(()=>{this.emit("end")})})}connect($){if($){this._connect($);return}return new this._Promise((U,X)=>{this._connect((Z)=>{if(Z)X(Z);else U()})})}_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))}_checkPgPass($){const U=this.connection;if(typeof this.password==="function")this._Promise.resolve().then(()=>this.password()).then((X)=>{if(X!==void 0){if(typeof X!=="string"){U.emit("error",new TypeError("Password must be a string"));return}this.connectionParameters.password=this.password=X}else this.connectionParameters.password=this.password=null;$()}).catch((X)=>{U.emit("error",X)});else if(this.password!==null)$();else try{d8()(this.connectionParameters,(Z)=>{if(Z!==void 0)this.connectionParameters.password=this.password=Z;$()})}catch(X){this.emit("error",X)}}_handleAuthCleartextPassword($){this._checkPgPass(()=>{this.connection.password(this.password)})}_handleAuthMD5Password($){this._checkPgPass(async()=>{try{const U=await x9.postgresMd5PasswordHash(this.user,this.password,$.salt);this.connection.password(U)}catch(U){this.emit("error",U)}})}_handleAuthSASL($){this._checkPgPass(()=>{try{this.saslSession=v0.startSession($.mechanisms),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)}catch(U){this.connection.emit("error",U)}})}async _handleAuthSASLContinue($){try{await v0.continueSession(this.saslSession,this.password,$.data),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}catch(U){this.connection.emit("error",U)}}_handleAuthSASLFinal($){try{v0.finalizeSession(this.saslSession,$.data),this.saslSession=null}catch(U){this.connection.emit("error",U)}}_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")}const{activeQuery:U}=this;if(this.activeQuery=null,this.readyForQuery=!0,U)U.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($);const U=this.activeQuery;if(!U){this._handleErrorEvent($);return}this.activeQuery=null,U.handleError($,this.connection)}_handleRowDescription($){this.activeQuery.handleRowDescription($)}_handleDataRow($){this.activeQuery.handleDataRow($)}_handlePortalSuspended($){this.activeQuery.handlePortalSuspended(this.connection)}_handleEmptyQuery($){this.activeQuery.handleEmptyQuery(this.connection)}_handleCommandComplete($){this.activeQuery.handleCommandComplete($,this.connection)}_handleParseComplete($){if(this.activeQuery.name)this.connection.parsedStatements[this.activeQuery.name]=this.activeQuery.text}_handleCopyInResponse($){this.activeQuery.handleCopyInResponse(this.connection)}_handleCopyData($){this.activeQuery.handleCopyData($,this.connection)}_handleNotification($){this.emit("notification",$)}_handleNotice($){this.emit("notice",$)}getStartupConf(){var $=this.connectionParameters,U={user:$.user,database:$.database},X=$.application_name||$.fallback_application_name;if(X)U.application_name=X;if($.replication)U.replication=""+$.replication;if($.statement_timeout)U.statement_timeout=String(parseInt($.statement_timeout,10));if($.lock_timeout)U.lock_timeout=String(parseInt($.lock_timeout,10));if($.idle_in_transaction_session_timeout)U.idle_in_transaction_session_timeout=String(parseInt($.idle_in_transaction_session_timeout,10));if($.options)U.options=$.options;return U}cancel($,U){if($.activeQuery===U){var X=this.connection;if(this.host&&this.host.indexOf("/")===0)X.connect(this.host+"/.s.PGSQL."+this.port);else X.connect(this.port,this.host);X.on("connect",function(){X.cancel($.processID,$.secretKey)})}else if($.queryQueue.indexOf(U)!==-1)$.queryQueue.splice($.queryQueue.indexOf(U),1)}setTypeParser($,U,X){return this._types.setTypeParser($,U,X)}getTypeParser($,U){return this._types.getTypeParser($,U)}escapeIdentifier($){return m8.escapeIdentifier($)}escapeLiteral($){return m8.escapeLiteral($)}_pulseQueryQueue(){if(this.readyForQuery===!0){if(this.activeQuery=this.queryQueue.shift(),this.activeQuery){this.readyForQuery=!1,this.hasExecuted=!0;const $=this.activeQuery.submit(this.connection);if($)process.nextTick(()=>{this.activeQuery.handleError($,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else if(this.hasExecuted)this.activeQuery=null,this.emit("drain")}}query($,U,X){var Z,J,G,Y,Q;if($===null||$===void 0)throw new TypeError("Client was passed a null or undefined query");else if(typeof $.submit==="function"){if(G=$.query_timeout||this.connectionParameters.query_timeout,J=Z=$,typeof U==="function")Z.callback=Z.callback||U}else if(G=this.connectionParameters.query_timeout,Z=new p8($,U,X),!Z.callback)J=new this._Promise((j,W)=>{Z.callback=(K,O)=>K?W(K):j(O)}).catch((j)=>{throw Error.captureStackTrace(j),j});if(G)Q=Z.callback,Y=setTimeout(()=>{var j=new Error("Query read timeout");process.nextTick(()=>{Z.handleError(j,this.connection)}),Q(j),Z.callback=()=>{};var W=this.queryQueue.indexOf(Z);if(W>-1)this.queryQueue.splice(W,1);this._pulseQueryQueue()},G),Z.callback=(j,W)=>{clearTimeout(Y),Q(j,W)};if(this.binary&&!Z.binary)Z.binary=!0;if(Z._result&&!Z._result._types)Z._result._types=this._types;if(!this._queryable)return process.nextTick(()=>{Z.handleError(new Error("Client has encountered a connection error and is not queryable"),this.connection)}),J;if(this._ending)return process.nextTick(()=>{Z.handleError(new Error("Client was closed and is not queryable"),this.connection)}),J;return this.queryQueue.push(Z),this._pulseQueryQueue(),J}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.activeQuery||!this._queryable)this.connection.stream.destroy();else this.connection.end();if($)this.connection.once("end",$);else return new this._Promise((U)=>{this.connection.once("end",U)})}}y0.Query=p8;u8.exports=y0});var i8=H((bU,n8)=>{var h9=function(){throw new Error("Release called on client which has already been released to the pool.")},J0=function($,U){if(U)return{callback:U,result:void 0};let X,Z;const J=function(Y,Q){Y?X(Y):Z(Q)},G=new $(function(Y,Q){Z=Y,X=Q}).catch((Y)=>{throw Error.captureStackTrace(Y),Y});return{callback:J,result:G}},b9=function($,U){return function X(Z){Z.client=U,U.removeListener("error",X),U.on("error",()=>{$.log("additional client error after disconnection due to error",Z)}),$._remove(U),$.emit("error",Z,U)}},w9=import.meta.require("events").EventEmitter,g8=function(){},c8=($,U)=>{const X=$.findIndex(U);return X===-1?void 0:$.splice(X,1)[0]};class l8{constructor($,U,X){this.client=$,this.idleListener=U,this.timeoutId=X}}class n{constructor($){this.callback=$}}class o8 extends w9{constructor($,U){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.maxUses=this.options.maxUses||Infinity,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||U||d0().Client,this.Promise=this.options.Promise||global.Promise,typeof this.options.idleTimeoutMillis==="undefined")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}_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((U)=>{this._remove(U.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;const $=this._pendingQueue.shift();if(this._idle.length){const U=this._idle.pop();clearTimeout(U.timeoutId);const X=U.client;X.ref&&X.ref();const Z=U.idleListener;return this._acquireClient(X,$,Z,!1)}if(!this._isFull())return this.newClient($);throw new Error("unexpected condition")}_remove($){const U=c8(this._idle,(X)=>X.client===$);if(U!==void 0)clearTimeout(U.timeoutId);this._clients=this._clients.filter((X)=>X!==$),$.end(),this.emit("remove",$)}connect($){if(this.ending){const Z=new Error("Cannot use a pool after calling end on the pool");return $?$(Z):this.Promise.reject(Z)}const U=J0(this.Promise,$),X=U.result;if(this._isFull()||this._idle.length){if(this._idle.length)process.nextTick(()=>this._pulseQueue());if(!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new n(U.callback)),X;const Z=(Y,Q,j)=>{clearTimeout(G),U.callback(Y,Q,j)},J=new n(Z),G=setTimeout(()=>{c8(this._pendingQueue,(Y)=>Y.callback===Z),J.timedOut=!0,U.callback(new Error("timeout exceeded when trying to connect"))},this.options.connectionTimeoutMillis);return this._pendingQueue.push(J),X}return this.newClient(new n(U.callback)),X}newClient($){const U=new this.Client(this.options);this._clients.push(U);const X=b9(this,U);this.log("checking client timeout");let Z,J=!1;if(this.options.connectionTimeoutMillis)Z=setTimeout(()=>{this.log("ending client due to timeout"),J=!0,U.connection?U.connection.stream.destroy():U.end()},this.options.connectionTimeoutMillis);this.log("connecting new client"),U.connect((G)=>{if(Z)clearTimeout(Z);if(U.on("error",X),G){if(this.log("client failed to connect",G),this._clients=this._clients.filter((Y)=>Y!==U),J)G.message="Connection terminated due to connection timeout";if(this._pulseQueue(),!$.timedOut)$.callback(G,void 0,g8)}else{if(this.log("new client connected"),this.options.maxLifetimeSeconds!==0){const Y=setTimeout(()=>{if(this.log("ending client due to expired lifetime"),this._expired.add(U),this._idle.findIndex((j)=>j.client===U)!==-1)this._acquireClient(U,new n((j,W,K)=>K()),X,!1)},this.options.maxLifetimeSeconds*1000);Y.unref(),U.once("end",()=>clearTimeout(Y))}return this._acquireClient(U,$,X,!0)}})}_acquireClient($,U,X,Z){if(Z)this.emit("connect",$);if(this.emit("acquire",$),$.release=this._releaseOnce($,X),$.removeListener("error",X),!U.timedOut)if(Z&&this.options.verify)this.options.verify($,(J)=>{if(J)return $.release(J),U.callback(J,void 0,g8);U.callback(void 0,$,$.release)});else U.callback(void 0,$,$.release);else if(Z&&this.options.verify)this.options.verify($,$.release);else $.release()}_releaseOnce($,U){let X=!1;return(Z)=>{if(X)h9();X=!0,this._release($,U,Z)}}_release($,U,X){if($.on("error",U),$._poolUseCount=($._poolUseCount||0)+1,this.emit("release",X,$),X||this.ending||!$._queryable||$._ending||$._poolUseCount>=this.options.maxUses){if($._poolUseCount>=this.options.maxUses)this.log("remove expended client");this._remove($),this._pulseQueue();return}if(this._expired.has($)){this.log("remove expired client"),this._expired.delete($),this._remove($),this._pulseQueue();return}let J;if(this.options.idleTimeoutMillis){if(J=setTimeout(()=>{this.log("remove idle client"),this._remove($)},this.options.idleTimeoutMillis),this.options.allowExitOnIdle)J.unref()}if(this.options.allowExitOnIdle)$.unref();this._idle.push(new l8($,U,J)),this._pulseQueue()}query($,U,X){if(typeof $==="function"){const J=J0(this.Promise,$);return setImmediate(function(){return J.callback(new Error("Passing a function as the first parameter to pool.query is not supported"))}),J.result}if(typeof U==="function")X=U,U=void 0;const Z=J0(this.Promise,X);return X=Z.callback,this.connect((J,G)=>{if(J)return X(J);let Y=!1;const Q=(j)=>{if(Y)return;Y=!0,G.release(j),X(j)};G.once("error",Q),this.log("dispatching query");try{G.query($,U,(j,W)=>{if(this.log("query dispatched"),G.removeListener("error",Q),Y)return;if(Y=!0,G.release(j),j)return X(j);return X(void 0,W)})}catch(j){return G.release(j),X(j)}}),Z.result}end($){if(this.log("ending"),this.ending){const X=new Error("Called end on pool more than once");return $?$(X):this.Promise.reject(X)}this.ending=!0;const U=J0(this.Promise,$);return this._endCallback=U.callback,this._pulseQueue(),U.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce(($,U)=>$+(this._expired.has(U)?1:0),0)}get totalCount(){return this._clients.length}}n8.exports=o8});var s8=H((vU,t8)=>{var a8=import.meta.require("events").EventEmitter,v9=import.meta.require("util"),m0=c(),v=t8.exports=function($,U,X){a8.call(this),$=m0.normalizeQueryConfig($,U,X),this.text=$.text,this.values=$.values,this.name=$.name,this.callback=$.callback,this.state="new",this._arrayMode=$.rowMode==="array",this._emitRowEvents=!1,this.on("newListener",function(Z){if(Z==="row")this._emitRowEvents=!0}.bind(this))};v9.inherits(v,a8);var y9={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"file",sourceLine:"line",sourceFunction:"routine"};v.prototype.handleError=function($){var U=this.native.pq.resultErrorFields();if(U)for(var X in U){var Z=y9[X]||X;$[Z]=U[X]}if(this.callback)this.callback($);else this.emit("error",$);this.state="error"};v.prototype.then=function($,U){return this._getPromise().then($,U)};v.prototype.catch=function($){return this._getPromise().catch($)};v.prototype._getPromise=function(){if(this._promise)return this._promise;return this._promise=new Promise(function($,U){this._once("end",$),this._once("error",U)}.bind(this)),this._promise};v.prototype.submit=function($){this.state="running";var U=this;this.native=$.native,$.native.arrayMode=this._arrayMode;var X=function(G,Y,Q){if($.native.arrayMode=!1,setImmediate(function(){U.emit("_done")}),G)return U.handleError(G);if(U._emitRowEvents)if(Q.length>1)Y.forEach((j,W)=>{j.forEach((K)=>{U.emit("row",K,Q[W])})});else Y.forEach(function(j){U.emit("row",j,Q)});if(U.state="end",U.emit("end",Q),U.callback)U.callback(null,Q)};if(process.domain)X=process.domain.bind(X);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");var Z=(this.values||[]).map(m0.prepareValue);if($.namedQueries[this.name]){if(this.text&&$.namedQueries[this.name]!==this.text){const G=new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return X(G)}return $.native.execute(this.name,Z,X)}return $.native.prepare(this.name,this.text,Z.length,function(G){if(G)return X(G);return $.namedQueries[U.name]=U.text,U.native.execute(U.name,Z,X)})}else if(this.values){if(!Array.isArray(this.values)){const G=new Error("Query values must be an array");return X(G)}var J=this.values.map(m0.prepareValue);$.native.query(this.text,J,X)}else $.native.query(this.text,X)}});var p0=H((yU,U$)=>{var r8;try{r8=(()=>{throw new Error(`Cannot require module "pg-native"`);})()}catch($){throw $}var d9=S0(),e8=import.meta.require("events").EventEmitter,m9=import.meta.require("util"),p9=P0(),$$=s8(),V=U$.exports=function($){e8.call(this),$=$||{},this._Promise=$.Promise||global.Promise,this._types=new d9($.types),this.native=new r8({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;var U=this.connectionParameters=new p9($);if($.nativeConnectionString)U.nativeConnectionString=$.nativeConnectionString;this.user=U.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:U.password}),this.database=U.database,this.host=U.host,this.port=U.port,this.namedQueries={}};V.Query=$$;m9.inherits(V,e8);V.prototype._errorAllQueries=function($){const U=(X)=>{process.nextTick(()=>{X.native=this.native,X.handleError($)})};if(this._hasActiveQuery())U(this._activeQuery),this._activeQuery=null;this._queryQueue.forEach(U),this._queryQueue.length=0};V.prototype._connect=function($){var U=this;if(this._connecting){process.nextTick(()=>$(new Error("Client has already been connected. You cannot reuse a client.")));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(X,Z){if(U.connectionParameters.nativeConnectionString)Z=U.connectionParameters.nativeConnectionString;if(X)return $(X);U.native.connect(Z,function(J){if(J)return U.native.end(),$(J);U._connected=!0,U.native.on("error",function(G){U._queryable=!1,U._errorAllQueries(G),U.emit("error",G)}),U.native.on("notification",function(G){U.emit("notification",{channel:G.relname,payload:G.extra})}),U.emit("connect"),U._pulseQueryQueue(!0),$()})})};V.prototype.connect=function($){if($){this._connect($);return}return new this._Promise((U,X)=>{this._connect((Z)=>{if(Z)X(Z);else U()})})};V.prototype.query=function($,U,X){var Z,J,G,Y,Q;if($===null||$===void 0)throw new TypeError("Client was passed a null or undefined query");else if(typeof $.submit==="function"){if(G=$.query_timeout||this.connectionParameters.query_timeout,J=Z=$,typeof U==="function")$.callback=U}else if(G=this.connectionParameters.query_timeout,Z=new $$($,U,X),!Z.callback){let j,W;J=new this._Promise((K,O)=>{j=K,W=O}).catch((K)=>{throw Error.captureStackTrace(K),K}),Z.callback=(K,O)=>K?W(K):j(O)}if(G)Q=Z.callback,Y=setTimeout(()=>{var j=new Error("Query read timeout");process.nextTick(()=>{Z.handleError(j,this.connection)}),Q(j),Z.callback=()=>{};var W=this._queryQueue.indexOf(Z);if(W>-1)this._queryQueue.splice(W,1);this._pulseQueryQueue()},G),Z.callback=(j,W)=>{clearTimeout(Y),Q(j,W)};if(!this._queryable)return Z.native=this.native,process.nextTick(()=>{Z.handleError(new Error("Client has encountered a connection error and is not queryable"))}),J;if(this._ending)return Z.native=this.native,process.nextTick(()=>{Z.handleError(new Error("Client was closed and is not queryable"))}),J;return this._queryQueue.push(Z),this._pulseQueryQueue(),J};V.prototype.end=function($){var U=this;if(this._ending=!0,!this._connected)this.once("connect",this.end.bind(this,$));var X;if(!$)X=new this._Promise(function(Z,J){$=(G)=>G?J(G):Z()});return this.native.end(function(){U._errorAllQueries(new Error("Connection terminated")),process.nextTick(()=>{if(U.emit("end"),$)$()})}),X};V.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!=="error"&&this._activeQuery.state!=="end"};V.prototype._pulseQueryQueue=function($){if(!this._connected)return;if(this._hasActiveQuery())return;var U=this._queryQueue.shift();if(!U){if(!$)this.emit("drain");return}this._activeQuery=U,U.submit(this);var X=this;U.once("_done",function(){X._pulseQueryQueue()})};V.prototype.cancel=function($){if(this._activeQuery===$)this.native.cancel(function(){});else if(this._queryQueue.indexOf($)!==-1)this._queryQueue.splice(this._queryQueue.indexOf($),1)};V.prototype.ref=function(){};V.prototype.unref=function(){};V.prototype.setTypeParser=function($,U,X){return this._types.setTypeParser($,U,X)};V.prototype.getTypeParser=function($,U){return this._types.getTypeParser($,U)}});var d0=H((dU,i)=>{var u9=f8(),f9=g(),g9=x0(),c9=i8(),{DatabaseError:l9}=B0(),{escapeIdentifier:o9,escapeLiteral:n9}=c(),i9=($)=>{return class U extends c9{constructor(X){super(X,$)}}},u0=function($){this.defaults=f9,this.Client=$,this.Query=this.Client.Query,this.Pool=i9(this.Client),this._pools=[],this.Connection=g9,this.types=f(),this.DatabaseError=l9,this.escapeIdentifier=o9,this.escapeLiteral=n9};if(typeof process.env.NODE_PG_FORCE_NATIVE!=="undefined")i.exports=new u0(p0());else i.exports=new u0(u9),Object.defineProperty(i.exports,"native",{configurable:!0,enumerable:!1,get(){var $=null;try{$=new u0(p0())}catch(U){if(U.code!=="MODULE_NOT_FOUND")throw U}return Object.defineProperty(i.exports,"native",{value:$}),$}})});var X$=_$(d0(),1),D=new X$.Pool({host:"0.0.0.0",port:5432,user:"postgres",password:"123",database:"rinha"});function Z$($,U){if(typeof $!=="number"||$<1)U.status=422;return U}function J$($,U,X){if(typeof $!=="number"||$<1)X.status=422;if(!U.valor||typeof U.valor!=="number"||U.valor<1||!Number.isInteger(U.valor))X.status=422;if(!U.tipo||typeof U.tipo!=="string"||!["c","d"].includes(U.tipo))X.status=422;if(!U.descricao||typeof U.descricao!=="string"||U.descricao.length<1||U.descricao.length>10)X.status=422;return X}async function G$($,U){if(Z$($,U).status!==200)return;const Z=(await D.query("SELECT * FROM customers WHERE id = $1",[$])).rows[0];if(!Z){U.status=404;return}const J=(await D.query("SELECT * FROM transacoes WHERE customerId = $1 ORDER BY realizada_em DESC LIMIT 10",[$])).rows;return{saldo:{total:Z.saldo,data_extrato:(new Date()).toISOString(),limite:Z.limite},ultimas_transacoes:J}}async function Y$($,U,X){if(J$($,U,X).status!==200)return;const J=(await D.query("SELECT * FROM customers WHERE id = $1",[$])).rows[0];if(!J){X.status=404;return}let G=0;if(U.tipo==="d"){const Y=await D.query("SELECT * FROM debit ($1, $2, $3)",[$,U.valor,U.descricao]),{saldofinal:Q,error:j}=Y.rows[0];if(j)return X.status=422,"saldo insuficente";G=Q}if(U.tipo==="c")G=(await D.query("SELECT * FROM credit ($1, $2, $3)",[$,U.valor,U.descricao])).rows[0].saldofinal;return{limite:J.limite,saldo:G}}var Q$=new RegExp(/clientes\/(\d+)\/extrato/),j$=new RegExp(/clientes\/(\d+)\/transacoes/),a9=async($)=>{const U=new URL($.url),X={status:200};if($.method==="GET"&&Q$.test(U.pathname)){const Z=+Q$.exec(U.pathname)[1],J=await G$(Z,X);return{status:X.status,body:J}}if($.method==="POST"&&j$.test(U.pathname)){const Z=+j$.exec(U.pathname)[1],J=await $.json(),G=await Y$(Z,J,X);return{status:X.status,body:G}}},W$=Bun.env.PORT;Bun.serve({port:W$,async fetch($){const U=await a9($);if(!U)return new Response(null,{status:404});return new Response(JSON.stringify(U.body),{status:U.status})}});console.log(`Server is running at on port ${W$}...`);
api01-1 | ^
api01-1 | error: terminating connection due to unexpected postmaster exit
api01-1 | code: "57P01"
api01-1 |
api01-1 | at new n1 (/home/bun/app/index.js:2:30208)
api01-1 | at parseErrorMessage (/home/bun/app/index.js:2:42334)
api01-1 | at parse (/home/bun/app/index.js:2:37596)
api01-1 | at emit (native:1:1)
api01-1 | at addChunk (node:1:1940)
api01-1 | at readableAddChunk (node:1:1894)
api01-1 | at data (node:1:52)
postgres-1 | 2024-02-19 04:54:58.114 UTC [81] FATAL: terminating connection due to unexpected postmaster exit
postgres-1 | 2024-02-19 04:54:58.114 UTC [80] FATAL: terminating connection due to unexpected postmaster exit
api02-1 | 1 | // @bun
api02-1 | 2 | var K$=Object.create;var{defineProperty:y,getPrototypeOf:H$,getOwnPropertyNames:f0,getOwnPropertyDescriptor:O$}=Object,g0=Object.prototype.hasOwnProperty;var _$=($,U,X)=>{X=$!=null?K$(H$($)):{};const Z=U||!$||!$.__esModule?y(X,"default",{value:$,enumerable:!0}):X;for(let J of f0($))if(!g0.call(Z,J))y(Z,J,{get:()=>$[J],enumerable:!0});return Z},c0=($)=>{const U=c0.moduleCache??=new WeakMap;var X=U.get($);if(X)return X;var Z=y({},"__esModule",{value:!0}),J={enumerable:!1};if($&&typeof $==="object"||typeof $==="function"){for(let G of f0($))if(!g0.call(Z,G))y(Z,G,{get:()=>$[G],enumerable:!(J=O$($,G))||J.enumerable})}return U.set($,Z),Z};var H=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports);var z$=($,U)=>{for(var X in U)y($,X,{get:U[X],enumerable:!0,configurable:!0,set:(Z)=>U[X]=()=>Z})};var R$=($,U)=>()=>($&&(U=$($=0)),U);var j0=H((F$)=>{var L$=function($){return $};F$.parse=function($,U){return new Q0($,U).parse()};class Q0{constructor($,U){this.source=$,this.transform=U||L$,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 U;if(this.recorded.length>0||$){if(U=this.recorded.join(""),U==="NULL"&&!$)U=null;if(U!==null)U=this.transform(U);this.entries.push(U),this.recorded=[]}}consumeDimensions(){if(this.source[0]==="[")while(!this.isEof()){var $=this.nextCharacter();if($.value==="=")break}}parse($){var U,X,Z;this.consumeDimensions();while(!this.isEof())if(U=this.nextCharacter(),U.value==="{"&&!Z){if(this.dimension++,this.dimension>1)X=new Q0(this.source.substr(this.position-1),this.transform),this.entries.push(X.parse(!0)),this.position+=X.position-2}else if(U.value==="}"&&!Z){if(this.dimension--,!this.dimension){if(this.newEntry(),$)return this.entries}}else if(U.value==='"'&&!U.escaped){if(Z)this.newEntry(!0);Z=!Z}else if(U.value===","&&!Z)this.newEntry();else this.record(U.value);if(this.dimension!==0)throw new Error("array dimension not balanced");return this.entries}}});var W0=H((r9,l0)=>{var A$=j0();l0.exports={create:function($,U){return{parse:function(){return A$.parse($,U)}}}}});var i0=H((e9,n0)=>{var T$=function($){var U=V$.exec($);if(!U)return;var X=parseInt(U[1],10),Z=!!U[4];if(Z)X=o0(X);var J=parseInt(U[2],10)-1,G=U[3],Y=new Date(X,J,G);if(K0(X))Y.setFullYear(X);return Y},P$=function($){if($.endsWith("+00"))return 0;var U=E$.exec($.split(" ")[1]);if(!U)return;var X=U[1];if(X==="Z")return 0;var Z=X==="-"?-1:1,J=parseInt(U[2],10)*3600+parseInt(U[3]||0,10)*60+parseInt(U[4]||0,10);return J*Z*1000},o0=function($){return-($-1)},K0=function($){return $>=0&&$<100},N$=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,V$=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,E$=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,S$=/^-?infinity$/;n0.exports=function $(U){if(S$.test(U))return Number(U.replace("i","I"));var X=N$.exec(U);if(!X)return T$(U)||null;var Z=!!X[8],J=parseInt(X[1],10);if(Z)J=o0(J);var G=parseInt(X[2],10)-1,Y=X[3],Q=parseInt(X[4],10),j=parseInt(X[5],10),W=parseInt(X[6],10),K=X[7];K=K?1000*parseFloat(K):0;var O,_=P$(U);if(_!=null){if(O=new Date(Date.UTC(J,G,Y,Q,j,W,K)),K0(J))O.setUTCFullYear(J);if(_!==0)O.setTime(O.getTime()-_)}else if(O=new Date(J,G,Y,Q,j,W,K),K0(J))O.setFullYear(J);return O}});var t0=H(($U,a0)=>{var q$=function($){for(var U=1;U<arguments.length;U++){var X=arguments[U];for(var Z in X)if(C$.call(X,Z))$[Z]=X[Z]}return $};a0.exports=q$;var C$=Object.prototype.hasOwnProperty});var e0=H((UU,r0)=>{var k=function($){if(!(this instanceof k))return new k($);D$(this,p$($))},m$=function($){var U=$+"000000".slice($.length);return parseInt(U,10)/1000},p$=function($){if(!$)return{};var U=y$.exec($),X=U[8]==="-";return Object.keys(s0).reduce(function(Z,J){var G=s0[J],Y=U[G];if(!Y)return Z;if(Y=J==="milliseconds"?m$(Y):parseInt(Y,10),!Y)return Z;if(X&&~d$.indexOf(J))Y*=-1;return Z[J]=Y,Z},{})},D$=t0();r0.exports=k;var k$=["seconds","minutes","hours","days","months","years"];k.prototype.toPostgres=function(){var $=k$.filter(this.hasOwnProperty,this);if(this.milliseconds&&$.indexOf("seconds")<0)$.push("seconds");if($.length===0)return"0";return $.map(function(U){var X=this[U]||0;if(U==="seconds"&&this.milliseconds)X=(X+this.milliseconds/1000).toFixed(6).replace(/\.?0+$/,"");return X+" "+U},this).join(" ")};var B$={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"S"},I$=["years","months","days"],x$=["hours","minutes","seconds"];k.prototype.toISOString=k.prototype.toISO=function(){var $=I$.map(X,this).join(""),U=x$.map(X,this).join("");return"P"+$+"T"+U;function X(Z){var J=this[Z]||0;if(Z==="seconds"&&this.milliseconds)J=(J+this.milliseconds/1000).toFixed(6).replace(/0+$/,"");return J+B$[Z]}};var H0="([+-]?\\d+)",w$=H0+"\\s+years?",h$=H0+"\\s+mons?",b$=H0+"\\s+days?",v$="([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",y$=new RegExp([w$,h$,b$,v$].map(function($){return"("+$+")?"}).join("\\s*")),s0={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},d$=["hours","minutes","seconds","milliseconds"]});var U1=H((XU,$1)=>{$1.exports=function $(U){if(/^\\x/.test(U))return new Buffer(U.substr(2),"hex");var X="",Z=0;while(Z<U.length)if(U[Z]!=="\\")X+=U[Z],++Z;else if(/[0-7]{3}/.test(U.substr(Z+1,3)))X+=String.fromCharCode(parseInt(U.substr(Z+1,3),8)),Z+=4;else{var J=1;while(Z+J<U.length&&U[Z+J]==="\\")J++;for(var G=0;G<Math.floor(J/2);++G)X+="\\";Z+=Math.floor(J/2)*2}return new Buffer(X,"binary")}});var j1=H((ZU,Q1)=>{var t=function($){return function U(X){if(X===null)return X;return $(X)}},G1=function($){if($===null)return $;return $==="TRUE"||$==="t"||$==="true"||$==="y"||$==="yes"||$==="on"||$==="1"},u$=function($){if(!$)return null;return d.parse($,G1)},f$=function($){return parseInt($,10)},O0=function($){if(!$)return null;return d.parse($,t(f$))},g$=function($){if(!$)return null;return d.parse($,t(function(U){return Y1(U).trim()}))},d=j0(),m=W0(),a=i0(),Z1=e0(),J1=U1(),c$=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=L0(X);return X});return U.parse()},_0=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=parseFloat(X);return X});return U.parse()},S=function($){if(!$)return null;var U=m.create($);return U.parse()},z0=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=a(X);return X});return U.parse()},l$=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=Z1(X);return X});return U.parse()},o$=function($){if(!$)return null;return d.parse($,t(J1))},R0=function($){return parseInt($,10)},Y1=function($){var U=String($);if(/^\d+$/.test(U))return U;return $},X1=function($){if(!$)return null;return d.parse($,t(JSON.parse))},L0=function($){if($[0]!=="(")return null;return $=$.substring(1,$.length-1).split(","),{x:parseFloat($[0]),y:parseFloat($[1])}},n$=function($){if($[0]!=="<"&&$[1]!=="(")return null;var U="(",X="",Z=!1;for(var J=2;J<$.length-1;J++){if(!Z)U+=$[J];if($[J]===")"){Z=!0;continue}else if(!Z)continue;if($[J]===",")continue;X+=$[J]}var G=L0(U);return G.radius=parseFloat(X),G},i$=function($){$(20,Y1),$(21,R0),$(23,R0),$(26,R0),$(700,parseFloat),$(701,parseFloat),$(16,G1),$(1082,a),$(1114,a),$(1184,a),$(600,L0),$(651,S),$(718,n$),$(1000,u$),$(1001,o$),$(1005,O0),$(1007,O0),$(1028,O0),$(1016,g$),$(1017,c$),$(1021,_0),$(1022,_0),$(1231,_0),$(1014,S),$(1015,S),$(1008,S),$(1009,S),$(1040,S),$(1041,S),$(1115,z0),$(1182,z0),$(1185,z0),$(1186,Z1),$(1187,l$),$(17,J1),$(114,JSON.parse.bind(JSON)),$(3802,JSON.parse.bind(JSON)),$(199,X1),$(3807,X1),$(3907,S),$(2951,S),$(791,S),$(1183,S),$(1270,S)};Q1.exports={init:i$}});var K1=H((JU,W1)=>{var a$=function($){var U=$.readInt32BE(0),X=$.readUInt32BE(4),Z="";if(U<0)U=~U+(X===0),X=~X+1>>>0,Z="-";var J="",G,Y,Q,j,W,K;{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}return G=U%N,Y=4294967296*G+X,Q=""+Y%N,Z+Q+J},N=1e6;W1.exports=a$});var R1=H((GU,z1)=>{var t$=K1(),z=function($,U,X,Z,J){X=X||0,Z=Z||!1,J=J||function(E,G0,Y0){return E*Math.pow(2,Y0)+G0};var G=X>>3,Y=function(E){if(Z)return~E&255;return E},Q=255,j=8-X%8;if(U<j)Q=255<<8-U&255,j=U;if(X)Q=Q>>X%8;var W=0;if(X%8+U>=8)W=J(0,Y($[G])&Q,j);var K=U+X>>3;for(var O=G+1;O<K;O++)W=J(W,Y($[O]),8);var _=(U+X)%8;if(_>0)W=J(W,Y($[K])>>8-_,_);return W},_1=function($,U,X){var Z=Math.pow(2,X-1)-1,J=z($,1),G=z($,X,1);if(G===0)return 0;var Y=1,Q=function(W,K,O){if(W===0)W=1;for(var _=1;_<=O;_++)if(Y/=2,(K&1<<O-_)>0)W+=Y;return W},j=z($,U,X+1,!1,Q);if(G==Math.pow(2,X+1)-1){if(j===0)return J===0?Infinity:(-Infinity);return NaN}return(J===0?1:-1)*Math.pow(2,G-Z)*j},s$=function($){if(z($,1)==1)return-1*(z($,15,1,!0)+1);return z($,15,1)},H1=function($){if(z($,1)==1)return-1*(z($,31,1,!0)+1);return z($,31,1)},r$=function($){return _1($,23,8)},e$=function($){return _1($,52,11)},$4=function($){var U=z($,16,32);if(U==49152)return NaN;var X=Math.pow(1e4,z($,16,16)),Z=0,J=[],G=z($,16);for(var Y=0;Y<G;Y++)Z+=z($,16,64+16*Y)*X,X/=1e4;var Q=Math.pow(10,z($,16,48));return(U===0?1:-1)*Math.round(Z*Q)/Q},O1=function($,U){var X=z(U,1),Z=z(U,63,1),J=new Date((X===0?1:-1)*Z/1000+946684800000);if(!$)J.setTime(J.getTime()+J.getTimezoneOffset()*60000);return J.usec=Z%1000,J.getMicroSeconds=function(){return this.usec},J.setMicroSeconds=function(G){this.usec=G},J.getUTCMicroSeconds=function(){return this.usec},J},p=function($){var U=z($,32),X=z($,32,32),Z=z($,32,64),J=96,G=[];for(var Y=0;Y<U;Y++)G[Y]=z($,32,J),J+=32,J+=32;var Q=function(W){var K=z($,32,J);if(J+=32,K==4294967295)return null;var O;if(W==23||W==20)return O=z($,K*8,J),J+=K*8,O;else if(W==25)return O=$.toString(this.encoding,J>>3,(J+=K<<3)>>3),O;else console.log("ERROR: ElementType not implemented: "+W)},j=function(W,K){var O=[],_;if(W.length>1){var E=W.shift();for(_=0;_<E;_++)O[_]=j(W,K);W.unshift(E)}else for(_=0;_<W[0];_++)O[_]=Q(K);return O};return j(G,Z)},U4=function($){return $.toString("utf8")},X4=function($){if($===null)return null;return z($,8)>0},Z4=function($){$(20,t$),$(21,s$),$(23,H1),$(26,H1),$(1700,$4),$(700,r$),$(701,e$),$(16,X4),$(1114,O1.bind(null,!1)),$(1184,O1.bind(null,!0)),$(1000,p),$(1007,p),$(1016,p),$(1008,p),$(1009,p),$(25,U4)};z1.exports={init:Z4}});var F1=H((YU,L1)=>{L1.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 f=H((K4)=>{var M1=function($){return String($)},j4=function($,U){if(U=U||"text",!u[U])return M1;return u[U][$]||M1},W4=function($,U,X){if(typeof U=="function")X=U,U="text";u[U][$]=X},J4=j1(),G4=R1(),Y4=W0(),Q4=F1();K4.getTypeParser=j4;K4.setTypeParser=W4;K4.arrayParser=Y4;K4.builtins=Q4;var u={text:{},binary:{}};J4.init(function($,U){u.text[$]=U});G4.init(function($,U){u.binary[$]=U})});var g=H((jU,F0)=>{F0.exports={host:"localhost",user:process.platform==="win32"?process.env.USERNAME:process.env.USER,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 B=f(),R4=B.getTypeParser(20,"text"),L4=B.getTypeParser(1016,"text");F0.exports.__defineSetter__("parseInt8",function($){B.setTypeParser(20,"text",$?B.getTypeParser(23,"text"):R4),B.setTypeParser(1016,"text",$?B.getTypeParser(1007,"text"):L4)})});var c=H((WU,N1)=>{var M4=function($){var U=$.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return'"'+U+'"'},A1=function($){var U="{";for(var X=0;X<$.length;X++){if(X>0)U=U+",";if($[X]===null||typeof $[X]==="undefined")U=U+"NULL";else if(Array.isArray($[X]))U=U+A1($[X]);else if($[X]instanceof Buffer)U+="\\\\x"+$[X].toString("hex");else U+=M4(s($[X]))}return U=U+"}",U},A4=function($,U){if($&&typeof $.toPostgres==="function"){if(U=U||[],U.indexOf($)!==-1)throw new Error('circular reference detected while preparing "'+$+'" for query');return U.push($),s($.toPostgres(s),U)}return JSON.stringify($)},M=function($,U){$=""+$;while($.length<U)$="0"+$;return $},N4=function($){var U=-$.getTimezoneOffset(),X=$.getFullYear(),Z=X<1;if(Z)X=Math.abs(X)+1;var J=M(X,4)+"-"+M($.getMonth()+1,2)+"-"+M($.getDate(),2)+"T"+M($.getHours(),2)+":"+M($.getMinutes(),2)+":"+M($.getSeconds(),2)+"."+M($.getMilliseconds(),3);if(U<0)J+="-",U*=-1;else J+="+";if(J+=M(Math.floor(U/60),2)+":"+M(U%60,2),Z)J+=" BC";return J},V4=function($){var U=$.getUTCFullYear(),X=U<1;if(X)U=Math.abs(U)+1;var Z=M(U,4)+"-"+M($.getUTCMonth()+1,2)+"-"+M($.getUTCDate(),2)+"T"+M($.getUTCHours(),2)+":"+M($.getUTCMinutes(),2)+":"+M($.getUTCSeconds(),2)+"."+M($.getUTCMilliseconds(),3);if(Z+="+00:00",X)Z+=" BC";return Z},E4=function($,U,X){if($=typeof $==="string"?{text:$}:$,U)if(typeof U==="function")$.callback=U;else $.values=U;if(X)$.callback=X;return $},F4=g(),s=function($,U){if($==null)return null;if($ instanceof Buffer)return $;if(ArrayBuffer.isView($)){var X=Buffer.from($.buffer,$.byteOffset,$.byteLength);if(X.length===$.byteLength)return X;return X.slice($.byteOffset,$.byteOffset+$.byteLength)}if($ instanceof Date)if(F4.parseInputDatesAsUTC)return V4($);else return N4($);if(Array.isArray($))return A1($);if(typeof $==="object")return A4($,U);return $.toString()},S4=function($){return'"'+$.replace(/"/g,'""')+'"'},T4=function($){var U=!1,X="'";for(var Z=0;Z<$.length;Z++){var J=$[Z];if(J==="'")X+=J+J;else if(J==="\\")X+=J+J,U=!0;else X+=J}if(X+="'",U===!0)X=" E"+X;return X};N1.exports={prepareValue:function $(U){return s(U)},normalizeQueryConfig:E4,escapeIdentifier:S4,escapeLiteral:T4}});var E1=H((KU,V1)=>{var M0=function($){return l.createHash("md5").update($,"utf-8").digest("hex")},P4=function($,U,X){var Z=M0(U+$),J=M0(Buffer.concat([Buffer.from(Z),X]));return"md5"+J},C4=function($){return l.createHash("sha256").update($).digest()},q4=function($,U){return l.createHmac("sha256",$).update(U).digest()};async function D4($,U,X){return l.pbkdf2Sync($,U,X,32,"sha256")}var l=import.meta.require("crypto");V1.exports={postgresMd5PasswordHash:P4,randomBytes:l.randomBytes,deriveKey:D4,sha256:C4,hmacSha256:q4,md5:M0}});var C1=H((HU,P1)=>{var k4=function($){return T1.getRandomValues(Buffer.alloc($))};async function A0($){try{return S1.createHash("md5").update($,"utf-8").digest("hex")}catch(U){const X=typeof $==="string"?N0.encode($):$,Z=await I.digest("MD5",X);return Array.from(new Uint8Array(Z)).map((J)=>J.toString(16).padStart(2,"0")).join("")}}async function B4($,U,X){var Z=await A0(U+$),J=await A0(Buffer.concat([Buffer.from(Z),X]));return"md5"+J}async function I4($){return await I.digest("SHA-256",$)}async function x4($,U){const X=await I.importKey("raw",$,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return await I.sign("HMAC",X,N0.encode(U))}async function w4($,U,X){const Z=await I.importKey("raw",N0.encode($),"PBKDF2",!1,["deriveBits"]),J={name:"PBKDF2",hash:"SHA-256",salt:U,iterations:X};return await I.deriveBits(J,Z,256,["deriveBits"])}var S1=import.meta.require("crypto");P1.exports={postgresMd5PasswordHash:B4,randomBytes:k4,deriveKey:w4,sha256:I4,hmacSha256:x4,md5:A0};var T1=S1.webcrypto||globalThis.crypto,I=T1.subtle,N0=new TextEncoder});var E0=H((OU,V0)=>{var h4=parseInt(process.versions&&process.versions.node&&process.versions.node.split(".")[0])<15;if(h4)V0.exports=E1();else V0.exports=C1()});var B1=H((_U,k1)=>{var b4=function($){if($.indexOf("SCRAM-SHA-256")===-1)throw new Error("SASL: Only mechanism SCRAM-SHA-256 is currently supported");const U=q.randomBytes(18).toString("base64");return{mechanism:"SCRAM-SHA-256",clientNonce:U,response:"n,,n=*,r="+U,message:"SASLInitialResponse"}};async function v4($,U,X){if($.message!=="SASLInitialResponse")throw new Error("SASL: Last message was not SASLInitialResponse");if(typeof U!=="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");if(U==="")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string");if(typeof X!=="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");const Z=m4(X);if(!Z.nonce.startsWith($.clientNonce))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");else if(Z.nonce.length===$.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short");var J="n=*,r="+$.clientNonce,G="r="+Z.nonce+",s="+Z.salt+",i="+Z.iteration,Y="c=biws,r="+Z.nonce,Q=J+","+G+","+Y,j=Buffer.from(Z.salt,"base64"),W=await q.deriveKey(U,j,Z.iteration),K=await q.hmacSha256(W,"Client Key"),O=await q.sha256(K),_=await q.hmacSha256(O,Q),E=u4(Buffer.from(K),Buffer.from(_)).toString("base64"),G0=await q.hmacSha256(W,"Server Key"),Y0=await q.hmacSha256(G0,Q);$.message="SASLResponse",$.serverSignature=Buffer.from(Y0).toString("base64"),$.response=Y+",p="+E}var y4=function($,U){if($.message!=="SASLResponse")throw new Error("SASL: Last message was not SASLResponse");if(typeof U!=="string")throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");const{serverSignature:X}=p4(U);if(X!==$.serverSignature)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match")},d4=function($){if(typeof $!=="string")throw new TypeError("SASL: text must be a string");return $.split("").map((U,X)=>$.charCodeAt(X)).every((U)=>U>=33&&U<=43||U>=45&&U<=126)},q1=function($){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test($)},D1=function($){if(typeof $!=="string")throw new TypeError("SASL: attribute pairs text must be a string");return new Map($.split(",").map((U)=>{if(!/^.=/.test(U))throw new Error("SASL: Invalid attribute pair entry");const X=U[0],Z=U.substring(2);return[X,Z]}))},m4=function($){const U=D1($),X=U.get("r");if(!X)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");else if(!d4(X))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters");const Z=U.get("s");if(!Z)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing");else if(!q1(Z))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64");const J=U.get("i");if(!J)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing");else if(!/^[1-9][0-9]*$/.test(J))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count");const G=parseInt(J,10);return{nonce:X,salt:Z,iteration:G}},p4=function($){const X=D1($).get("v");if(!X)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");else if(!q1(X))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64");return{serverSignature:X}},u4=function($,U){if(!Buffer.isBuffer($))throw new TypeError("first argument must be a Buffer");if(!Buffer.isBuffer(U))throw new TypeError("second argument must be a Buffer");if($.length!==U.length)throw new Error("Buffer lengths must match");if($.length===0)throw new Error("Buffers cannot be empty");return Buffer.from($.map((X,Z)=>$[Z]^U[Z]))},q=E0();k1.exports={startSession:b4,continueSession:v4,finalizeSession:y4}});var S0=H((zU,I1)=>{var r=function($){this._types=$||f4,this.text={},this.binary={}},f4=f();r.prototype.getOverrides=function($){switch($){case"text":return this.text;case"binary":return this.binary;default:return{}}};r.prototype.setTypeParser=function($,U,X){if(typeof U==="function")X=U,U="text";this.getOverrides(U)[$]=X};r.prototype.getTypeParser=function($,U){return U=U||"text",this.getOverrides(U)[$]||this._types.getTypeParser($,U)};I1.exports=r});var w1=H((RU,x1)=>{var T0=function($){if($.charAt(0)==="/"){const Q=$.split(" ");return{host:Q[0],database:Q[1]}}const U={};let X,Z=!1;if(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test($))$=encodeURI($).replace(/\%25(\d\d)/g,"%$1");try{X=new URL($,"postgres://base")}catch(Q){X=new URL($.replace("@/","@___DUMMY___/"),"postgres://base"),Z=!0}for(let Q of X.searchParams.entries())U[Q[0]]=Q[1];if(U.user=U.user||decodeURIComponent(X.username),U.password=U.password||decodeURIComponent(X.password),X.protocol=="socket:")return U.host=decodeURI(X.pathname),U.database=X.searchParams.get("db"),U.client_encoding=X.searchParams.get("encoding"),U;const J=Z?"":X.hostname;if(!U.host)U.host=decodeURIComponent(J);else if(J&&/^%2f/i.test(J))X.pathname=J+X.pathname;if(!U.port)U.port=X.port;const G=X.pathname.slice(1)||null;if(U.database=G?decodeURI(G):null,U.ssl==="true"||U.ssl==="1")U.ssl=!0;if(U.ssl==="0")U.ssl=!1;if(U.sslcert||U.sslkey||U.sslrootcert||U.sslmode)U.ssl={};const Y=U.sslcert||U.sslkey||U.sslrootcert?import.meta.require("fs"):null;if(U.sslcert)U.ssl.cert=Y.readFileSync(U.sslcert).toString();if(U.sslkey)U.ssl.key=Y.readFileSync(U.sslkey).toString();if(U.sslrootcert)U.ssl.ca=Y.readFileSync(U.sslrootcert).toString();switch(U.sslmode){case"disable":{U.ssl=!1;break}case"prefer":case"require":case"verify-ca":case"verify-full":break;case"no-verify":{U.ssl.rejectUnauthorized=!1;break}}return U};x1.exports=T0;T0.parse=T0});var P0=H((LU,y1)=>{var g4=import.meta.require("dns"),b1=g(),h1=w1().parse,A=function($,U,X){if(X===void 0)X=process.env["PG"+$.toUpperCase()];else if(X===!1);else X=process.env[X];return U[$]||X||b1[$]},c4=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 b1.ssl},x=function($){return"'"+(""+$).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},T=function($,U,X){var Z=U[X];if(Z!==void 0&&Z!==null)$.push(X+"="+x(Z))};class v1{constructor($){if($=typeof $==="string"?h1($):$||{},$.connectionString)$=Object.assign({},$,h1($.connectionString));if(this.user=A("user",$),this.database=A("database",$),this.database===void 0)this.database=this.user;if(this.port=parseInt(A("port",$),10),this.host=A("host",$),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:A("password",$)}),this.binary=A("binary",$),this.options=A("options",$),this.ssl=typeof $.ssl==="undefined"?c4():$.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=A("client_encoding",$),this.replication=A("replication",$),this.isDomainSocket=!(this.host||"").indexOf("/"),this.application_name=A("application_name",$,"PGAPPNAME"),this.fallback_application_name=A("fallback_application_name",$,!1),this.statement_timeout=A("statement_timeout",$,!1),this.lock_timeout=A("lock_timeout",$,!1),this.idle_in_transaction_session_timeout=A("idle_in_transaction_session_timeout",$,!1),this.query_timeout=A("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($){var U=[];T(U,this,"user"),T(U,this,"password"),T(U,this,"port"),T(U,this,"application_name"),T(U,this,"fallback_application_name"),T(U,this,"connect_timeout"),T(U,this,"options");var X=typeof this.ssl==="object"?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(T(U,X,"sslmode"),T(U,X,"sslca"),T(U,X,"sslkey"),T(U,X,"sslcert"),T(U,X,"sslrootcert"),this.database)U.push("dbname="+x(this.database));if(this.replication)U.push("replication="+x(this.replication));if(this.host)U.push("host="+x(this.host));if(this.isDomainSocket)return $(null,U.join(" "));if(this.client_encoding)U.push("client_encoding="+x(this.client_encoding));g4.lookup(this.host,function(Z,J){if(Z)return $(Z,null);return U.push("hostaddr="+x(J)),$(null,U.join(" "))})}}y1.exports=v1});var u1=H((FU,p1)=>{var l4=f(),d1=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/;class m1{constructor($,U){if(this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0,this._types=U,this.RowCtor=null,this.rowAsArray=$==="array",this.rowAsArray)this.parseRow=this._parseRowAsArray;this._prebuiltEmptyResultObject=null}addCommandComplete($){var U;if($.text)U=d1.exec($.text);else U=d1.exec($.command);if(U){if(this.command=U[1],U[3])this.oid=parseInt(U[2],10),this.rowCount=parseInt(U[3],10);else if(U[2])this.rowCount=parseInt(U[2],10)}}_parseRowAsArray($){var U=new Array($.length);for(var X=0,Z=$.length;X<Z;X++){var J=$[X];if(J!==null)U[X]=this._parsers[X](J);else U[X]=null}return U}parseRow($){var U={...this._prebuiltEmptyResultObject};for(var X=0,Z=$.length;X<Z;X++){var J=$[X],G=this.fields[X].name;if(J!==null)U[G]=this._parsers[X](J)}return U}addRow($){this.rows.push($)}addFields($){if(this.fields=$,this.fields.length)this._parsers=new Array($.length);for(var U=0;U<$.length;U++){var X=$[U];if(this._types)this._parsers[U]=this._types.getTypeParser(X.dataTypeID,X.format||"text");else this._parsers[U]=l4.getTypeParser(X.dataTypeID,X.format||"text")}this._createPrebuiltEmptyResultObject()}_createPrebuiltEmptyResultObject(){var $={};for(var U=0;U<this.fields.length;U++)$[this.fields[U].name]=null;this._prebuiltEmptyResultObject={...$}}}p1.exports=m1});var o1=H((MU,l1)=>{var{EventEmitter:o4}=import.meta.require("events"),f1=u1(),g1=c();class c1 extends o4{constructor($,U,X){super();if($=g1.normalizeQueryConfig($,U,X),this.text=$.text,this.values=$.values,this.rows=$.rows,this.types=$.types,this.name=$.name,this.binary=$.binary,this.portal=$.portal||"",this.callback=$.callback,this._rowMode=$.rowMode,process.domain&&$.callback)this.callback=process.domain.bind($.callback);this._result=new f1(this._rowMode,this.types),this._results=this._result,this.isPreparedStatement=!1,this._canceledDueToError=!1,this._promise=null}requiresPreparation(){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 f1(this._rowMode,this.types),this._results.push(this._result)}}handleRowDescription($){this._checkForMultirow(),this._result.addFields($.fields),this._accumulateRows=this.callback||!this.listeners("row").length}handleDataRow($){let U;if(this._canceledDueToError)return;try{U=this._result.parseRow($.fields)}catch(X){this._canceledDueToError=X;return}if(this.emit("row",U,this._result),this._accumulateRows)this._result.addRow(U)}handleCommandComplete($,U){if(this._checkForMultirow(),this._result.addCommandComplete($),this.rows)U.sync()}handleEmptyQuery($){if(this.rows)$.sync()}handleError($,U){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(U){process.nextTick(()=>{throw U})}this.emit("end",this._results)}submit($){if(typeof this.text!=="string"&&typeof this.name!=="string")return new Error("A query must have either text or a name. Supplying neither is unsupported.");const U=$.parsedStatements[this.name];if(this.text&&U&&this.text!==U)return new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);if(this.values&&!Array.isArray(this.values))return new Error("Query values must be an array");if(this.requiresPreparation())this.prepare($);else $.query(this.text);return null}hasBeenParsed($){return this.name&&$.parsedStatements[this.name]}handlePortalSuspended($){this._getRows($,this.rows)}_getRows($,U){if($.execute({portal:this.portal,rows:U}),!U)$.sync();else $.flush()}prepare($){if(this.isPreparedStatement=!0,!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:g1.prepareValue})}catch(U){this.handleError(U,$);return}$.describe({type:"P",name:this.portal||""}),this._getRows($,this.rows)}handleCopyInResponse($){$.sendCopyFail("No source stream defined")}handleCopyData($,U){}}l1.exports=c1});var C0=H((Q8)=>{Object.defineProperty(Q8,"__esModule",{value:!0});Q8.NoticeMessage=Q8.DataRowMessage=Q8.CommandCompleteMessage=Q8.ReadyForQueryMessage=Q8.NotificationResponseMessage=Q8.BackendKeyDataMessage=Q8.AuthenticationMD5Password=Q8.ParameterStatusMessage=Q8.ParameterDescriptionMessage=Q8.RowDescriptionMessage=Q8.Field=Q8.CopyResponse=Q8.CopyDataMessage=Q8.DatabaseError=Q8.copyDone=Q8.emptyQuery=Q8.replicationStart=Q8.portalSuspended=Q8.noData=Q8.closeComplete=Q8.bindComplete=Q8.parseComplete=void 0;Q8.parseComplete={name:"parseComplete",length:5};Q8.bindComplete={name:"bindComplete",length:5};Q8.closeComplete={name:"closeComplete",length:5};Q8.noData={name:"noData",length:5};Q8.portalSuspended={name:"portalSuspended",length:5};Q8.replicationStart={name:"replicationStart",length:4};Q8.emptyQuery={name:"emptyQuery",length:4};Q8.copyDone={name:"copyDone",length:4};class n1 extends Error{constructor($,U,X){super($);this.length=U,this.name=X}}Q8.DatabaseError=n1;class i1{constructor($,U){this.length=$,this.chunk=U,this.name="copyData"}}Q8.CopyDataMessage=i1;class a1{constructor($,U,X,Z){this.length=$,this.name=U,this.binary=X,this.columnTypes=new Array(Z)}}Q8.CopyResponse=a1;class t1{constructor($,U,X,Z,J,G,Y){this.name=$,this.tableID=U,this.columnID=X,this.dataTypeID=Z,this.dataTypeSize=J,this.dataTypeModifier=G,this.format=Y}}Q8.Field=t1;class s1{constructor($,U){this.length=$,this.fieldCount=U,this.name="rowDescription",this.fields=new Array(this.fieldCount)}}Q8.RowDescriptionMessage=s1;class r1{constructor($,U){this.length=$,this.parameterCount=U,this.name="parameterDescription",this.dataTypeIDs=new Array(this.parameterCount)}}Q8.ParameterDescriptionMessage=r1;class e1{constructor($,U,X){this.length=$,this.parameterName=U,this.parameterValue=X,this.name="parameterStatus"}}Q8.ParameterStatusMessage=e1;class $8{constructor($,U){this.length=$,this.salt=U,this.name="authenticationMD5Password"}}Q8.AuthenticationMD5Password=$8;class U8{constructor($,U,X){this.length=$,this.processID=U,this.secretKey=X,this.name="backendKeyData"}}Q8.BackendKeyDataMessage=U8;class X8{constructor($,U,X,Z){this.length=$,this.processId=U,this.channel=X,this.payload=Z,this.name="notification"}}Q8.NotificationResponseMessage=X8;class Z8{constructor($,U){this.length=$,this.status=U,this.name="readyForQuery"}}Q8.ReadyForQueryMessage=Z8;class J8{constructor($,U){this.length=$,this.text=U,this.name="commandComplete"}}Q8.CommandCompleteMessage=J8;class G8{constructor($,U){this.length=$,this.fields=U,this.name="dataRow",this.fieldCount=U.length}}Q8.DataRowMessage=G8;class Y8{constructor($,U){this.length=$,this.message=U,this.name="notice"}}Q8.NoticeMessage=Y8});var O8=H((K8)=>{Object.defineProperty(K8,"__esModule",{value:!0});K8.Writer=void 0;class W8{constructor($=256){this.size=$,this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe($)}ensure($){var U=this.buffer.length-this.offset;if(U<$){var X=this.buffer,Z=X.length+(X.length>>1)+$;this.buffer=Buffer.allocUnsafe(Z),X.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{var U=Buffer.byteLength($);this.ensure(U+1),this.buffer.write($,this.offset,"utf-8"),this.offset+=U}return this.buffer[this.offset++]=0,this}addString($=""){var U=Buffer.byteLength($);return this.ensure(U),this.buffer.write($,this.offset),this.offset+=U,this}add($){return this.ensure($.length),$.copy(this.buffer,this.offset),this.offset+=$.length,this}join($){if($){this.buffer[this.headerPosition]=$;const U=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(U,this.headerPosition+1)}return this.buffer.slice($?0:5,this.offset)}flush($){var U=this.join($);return this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(this.size),U}}K8.Writer=W8});var L8=H((z8)=>{Object.defineProperty(z8,"__esModule",{value:!0});z8.serialize=void 0;var q0=O8(),R=new q0.Writer,z5=($)=>{R.addInt16(3).addInt16(0);for(let Z of Object.keys($))R.addCString(Z).addCString($[Z]);R.addCString("client_encoding").addCString("UTF8");var U=R.addCString("").flush(),X=U.length+4;return new q0.Writer().addInt32(X).add(U).flush()},R5=()=>{const $=Buffer.allocUnsafe(8);return $.writeInt32BE(8,0),$.writeInt32BE(80877103,4),$},L5=($)=>{return R.addCString($).flush(112)},F5=function($,U){return R.addCString($).addInt32(Buffer.byteLength(U)).addString(U),R.flush(112)},M5=function($){return R.addString($).flush(112)},A5=($)=>{return R.addCString($).flush(81)},_8=[],N5=($)=>{const U=$.name||"";if(U.length>63)console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",U,U.length),console.error("This can cause conflicts and silent errors executing queries");const X=$.types||_8;var Z=X.length,J=R.addCString(U).addCString($.text).addInt16(Z);for(var G=0;G<Z;G++)J.addInt32(X[G]);return R.flush(80)},w=new q0.Writer,V5=function($,U){for(let X=0;X<$.length;X++){const Z=U?U($[X],X):$[X];if(Z==null)R.addInt16(0),w.addInt32(-1);else if(Z instanceof Buffer)R.addInt16(1),w.addInt32(Z.length),w.add(Z);else R.addInt16(0),w.addInt32(Buffer.byteLength(Z)),w.addString(Z)}},E5=($={})=>{const U=$.portal||"",X=$.statement||"",Z=$.binary||!1,J=$.values||_8,G=J.length;return R.addCString(U).addCString(X),R.addInt16(G),V5(J,$.valueMapper),R.addInt16(G),R.add(w.flush()),R.addInt16(Z?1:0),R.flush(66)},S5=Buffer.from([69,0,0,0,9,0,0,0,0,0]),T5=($)=>{if(!$||!$.portal&&!$.rows)return S5;const U=$.portal||"",X=$.rows||0,Z=Buffer.byteLength(U),J=4+Z+1+4,G=Buffer.allocUnsafe(1+J);return G[0]=69,G.writeInt32BE(J,1),G.write(U,5,"utf-8"),G[Z+5]=0,G.writeUInt32BE(X,G.length-4),G},P5=($,U)=>{const X=Buffer.allocUnsafe(16);return X.writeInt32BE(16,0),X.writeInt16BE(1234,4),X.writeInt16BE(5678,6),X.writeInt32BE($,8),X.writeInt32BE(U,12),X},D0=($,U)=>{const Z=4+Buffer.byteLength(U)+1,J=Buffer.allocUnsafe(1+Z);return J[0]=$,J.writeInt32BE(Z,1),J.write(U,5,"utf-8"),J[Z]=0,J},C5=R.addCString("P").flush(68),q5=R.addCString("S").flush(68),D5=($)=>{return $.name?D0(68,`${$.type}${$.name||""}`):$.type==="P"?C5:q5},k5=($)=>{const U=`${$.type}${$.name||""}`;return D0(67,U)},B5=($)=>{return R.add($).flush(100)},I5=($)=>{return D0(102,$)},e=($)=>Buffer.from([$,0,0,0,4]),x5=e(72),w5=e(83),h5=e(88),b5=e(99),v5={startup:z5,password:L5,requestSsl:R5,sendSASLInitialResponseMessage:F5,sendSCRAMClientFinalMessage:M5,query:A5,parse:N5,bind:E5,execute:T5,describe:D5,close:k5,flush:()=>x5,sync:()=>w5,end:()=>h5,copyData:B5,copyDone:()=>b5,copyFail:I5,cancel:P5};z8.serialize=v5});var N8=H((M8)=>{Object.defineProperty(M8,"__esModule",{value:!0});M8.BufferReader=void 0;var y5=Buffer.allocUnsafe(0);class F8{constructor($=0){this.offset=$,this.buffer=y5,this.encoding="utf-8"}setBuffer($,U){this.offset=$,this.buffer=U}int16(){const $=this.buffer.readInt16BE(this.offset);return this.offset+=2,$}byte(){const $=this.buffer[this.offset];return this.offset++,$}int32(){const $=this.buffer.readInt32BE(this.offset);return this.offset+=4,$}string($){const U=this.buffer.toString(this.encoding,this.offset,this.offset+$);return this.offset+=$,U}cstring(){const $=this.offset;let U=$;while(this.buffer[U++]!==0);return this.offset=U,this.buffer.toString(this.encoding,$,U-1)}bytes($){const U=this.buffer.slice(this.offset,this.offset+$);return this.offset+=$,U}}M8.BufferReader=F8});var T8=H((h)=>{var d5=h&&h.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(h,"__esModule",{value:!0});h.Parser=void 0;var L=C0(),m5=N8(),p5=d5(import.meta.require("assert")),k0=1,u5=4,V8=k0+u5,E8=Buffer.allocUnsafe(0);class S8{constructor($){if(this.buffer=E8,this.bufferLength=0,this.bufferOffset=0,this.reader=new m5.BufferReader,($===null||$===void 0?void 0:$.mode)==="binary")throw new Error("Binary mode not supported yet");this.mode=($===null||$===void 0?void 0:$.mode)||"text"}parse($,U){this.mergeBuffer($);const X=this.bufferOffset+this.bufferLength;let Z=this.bufferOffset;while(Z+V8<=X){const J=this.buffer[Z],G=this.buffer.readUInt32BE(Z+k0),Y=k0+G;if(Y+Z<=X){const Q=this.handlePacket(Z+V8,J,G,this.buffer);U(Q),Z+=Y}else break}if(Z===X)this.buffer=E8,this.bufferLength=0,this.bufferOffset=0;else this.bufferLength=X-Z,this.bufferOffset=Z}mergeBuffer($){if(this.bufferLength>0){const U=this.bufferLength+$.byteLength;if(U+this.bufferOffset>this.buffer.byteLength){let Z;if(U<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)Z=this.buffer;else{let J=this.buffer.byteLength*2;while(U>=J)J*=2;Z=Buffer.allocUnsafe(J)}this.buffer.copy(Z,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=Z,this.bufferOffset=0}$.copy(this.buffer,this.bufferOffset+this.bufferLength),this.bufferLength=U}else this.buffer=$,this.bufferOffset=0,this.bufferLength=$.byteLength}handlePacket($,U,X,Z){switch(U){case 50:return L.bindComplete;case 49:return L.parseComplete;case 51:return L.closeComplete;case 110:return L.noData;case 115:return L.portalSuspended;case 99:return L.copyDone;case 87:return L.replicationStart;case 73:return L.emptyQuery;case 68:return this.parseDataRowMessage($,X,Z);case 67:return this.parseCommandCompleteMessage($,X,Z);case 90:return this.parseReadyForQueryMessage($,X,Z);case 65:return this.parseNotificationMessage($,X,Z);case 82:return this.parseAuthenticationResponse($,X,Z);case 83:return this.parseParameterStatusMessage($,X,Z);case 75:return this.parseBackendKeyData($,X,Z);case 69:return this.parseErrorMessage($,X,Z,"error");case 78:return this.parseErrorMessage($,X,Z,"notice");case 84:return this.parseRowDescriptionMessage($,X,Z);case 116:return this.parseParameterDescriptionMessage($,X,Z);case 71:return this.parseCopyInMessage($,X,Z);case 72:return this.parseCopyOutMessage($,X,Z);case 100:return this.parseCopyData($,X,Z);default:p5.default.fail(`unknown message code: ${U.toString(16)}`)}}parseReadyForQueryMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.string(1);return new L.ReadyForQueryMessage(U,Z)}parseCommandCompleteMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.cstring();return new L.CommandCompleteMessage(U,Z)}parseCopyData($,U,X){const Z=X.slice($,$+(U-4));return new L.CopyDataMessage(U,Z)}parseCopyInMessage($,U,X){return this.parseCopyMessage($,U,X,"copyInResponse")}parseCopyOutMessage($,U,X){return this.parseCopyMessage($,U,X,"copyOutResponse")}parseCopyMessage($,U,X,Z){this.reader.setBuffer($,X);const J=this.reader.byte()!==0,G=this.reader.int16(),Y=new L.CopyResponse(U,Z,J,G);for(let Q=0;Q<G;Q++)Y.columnTypes[Q]=this.reader.int16();return Y}parseNotificationMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J=this.reader.cstring(),G=this.reader.cstring();return new L.NotificationResponseMessage(U,Z,J,G)}parseRowDescriptionMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new L.RowDescriptionMessage(U,Z);for(let G=0;G<Z;G++)J.fields[G]=this.parseField();return J}parseField(){const $=this.reader.cstring(),U=this.reader.int32(),X=this.reader.int16(),Z=this.reader.int32(),J=this.reader.int16(),G=this.reader.int32(),Y=this.reader.int16()===0?"text":"binary";return new L.Field($,U,X,Z,J,G,Y)}parseParameterDescriptionMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new L.ParameterDescriptionMessage(U,Z);for(let G=0;G<Z;G++)J.dataTypeIDs[G]=this.reader.int32();return J}parseDataRowMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new Array(Z);for(let G=0;G<Z;G++){const Y=this.reader.int32();J[G]=Y===-1?null:this.reader.string(Y)}return new L.DataRowMessage(U,J)}parseParameterStatusMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.cstring(),J=this.reader.cstring();return new L.ParameterStatusMessage(U,Z,J)}parseBackendKeyData($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J=this.reader.int32();return new L.BackendKeyDataMessage(U,Z,J)}parseAuthenticationResponse($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J={name:"authenticationOk",length:U};switch(Z){case 0:break;case 3:if(J.length===8)J.name="authenticationCleartextPassword";break;case 5:if(J.length===12){J.name="authenticationMD5Password";const Y=this.reader.bytes(4);return new L.AuthenticationMD5Password(U,Y)}break;case 10:J.name="authenticationSASL",J.mechanisms=[];let G;do if(G=this.reader.cstring(),G)J.mechanisms.push(G);while(G);break;case 11:J.name="authenticationSASLContinue",J.data=this.reader.string(U-8);break;case 12:J.name="authenticationSASLFinal",J.data=this.reader.string(U-8);break;default:throw new Error("Unknown authenticationOk message type "+Z)}return J}parseErrorMessage($,U,X,Z){this.reader.setBuffer($,X);const J={};let G=this.reader.string(1);while(G!=="\0")J[G]=this.reader.cstring(),G=this.reader.string(1);const Y=J.M,Q=Z==="notice"?new L.NoticeMessage(U,Y):new L.DatabaseError(Y,U,Z);return Q.severity=J.S,Q.code=J.C,Q.detail=J.D,Q.hint=J.H,Q.position=J.P,Q.internalPosition=J.p,Q.internalQuery=J.q,Q.where=J.W,Q.schema=J.s,Q.table=J.t,Q.column=J.c,Q.dataType=J.d,Q.constraint=J.n,Q.file=J.F,Q.line=J.L,Q.routine=J.R,Q}}h.Parser=S8});var B0=H(($0)=>{var l5=function($,U){const X=new c5.Parser;return $.on("data",(Z)=>X.parse(Z,U)),new Promise((Z)=>$.on("end",()=>Z()))};Object.defineProperty($0,"__esModule",{value:!0});$0.DatabaseError=$0.serialize=$0.parse=void 0;var f5=C0();Object.defineProperty($0,"DatabaseError",{enumerable:!0,get:function(){return f5.DatabaseError}});var g5=L8();Object.defineProperty($0,"serialize",{enumerable:!0,get:function(){return g5.serialize}});var c5=T8();$0.parse=l5});var P8={};z$(P8,{default:()=>{{return i5}}});var i5;var C8=R$(()=>{i5={}});var q8=H((a5,I0)=>{a5.getStream=function $(U){const X=import.meta.require("net");if(typeof X.Socket==="function")return new X.Socket;else{const{CloudflareSocket:Z}=(C8(),c0(P8));return new Z(U)}};a5.getSecureStream=function $(U){var X=import.meta.require("tls");if(X.connect)return X.connect(U);else return U.socket.startTls(U),U.socket}});var x0=H((qU,k8)=>{var CU=import.meta.require("net"),r5=import.meta.require("events").EventEmitter,{parse:e5,serialize:F}=B0(),{getStream:$9,getSecureStream:U9}=q8(),X9=F.flush(),Z9=F.sync(),J9=F.end();class D8 extends r5{constructor($){super();if($=$||{},this.stream=$.stream||$9($.ssl),typeof this.stream==="function")this.stream=this.stream($);this._keepAlive=$.keepAlive,this._keepAliveInitialDelayMillis=$.keepAliveInitialDelayMillis,this.lastBuffer=!1,this.parsedStatements={},this.ssl=$.ssl||!1,this._ending=!1,this._emitMessage=!1;var U=this;this.on("newListener",function(X){if(X==="message")U._emitMessage=!0})}connect($,U){var X=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect($,U),this.stream.once("connect",function(){if(X._keepAlive)X.stream.setKeepAlive(!0,X._keepAliveInitialDelayMillis);X.emit("connect")});const Z=function(J){if(X._ending&&(J.code==="ECONNRESET"||J.code==="EPIPE"))return;X.emit("error",J)};if(this.stream.on("error",Z),this.stream.on("close",function(){X.emit("end")}),!this.ssl)return this.attachListeners(this.stream);this.stream.once("data",function(J){var G=J.toString("utf8");switch(G){case"S":break;case"N":return X.stream.end(),X.emit("error",new Error("The server does not support SSL connections"));default:return X.stream.end(),X.emit("error",new Error("There was an error establishing an SSL connection"))}const Y={socket:X.stream};if(X.ssl!==!0){if(Object.assign(Y,X.ssl),"key"in X.ssl)Y.key=X.ssl.key}var Q=import.meta.require("net");if(Q.isIP&&Q.isIP(U)===0)Y.servername=U;try{X.stream=U9(Y)}catch(j){return X.emit("error",j)}X.attachListeners(X.stream),X.stream.on("error",Z),X.emit("sslconnect")})}attachListeners($){e5($,(U)=>{var X=U.name==="error"?"errorMessage":U.name;if(this._emitMessage)this.emit("message",U);this.emit(X,U)})}requestSsl(){this.stream.write(F.requestSsl())}startup($){this.stream.write(F.startup($))}cancel($,U){this._send(F.cancel($,U))}password($){this._send(F.password($))}sendSASLInitialResponseMessage($,U){this._send(F.sendSASLInitialResponseMessage($,U))}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(X9)}sync(){this._ending=!0,this._send(Z9)}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(J9,()=>{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($))}}k8.exports=D8});var w8=H((DU,x8)=>{var Q9=function($,U,X){let Z;if(this.overflow){if(Z=this[U0].write($).split(this.matcher),Z.length===1)return X();Z.shift(),this.overflow=!1}else this[C]+=this[U0].write($),Z=this[C].split(this.matcher);this[C]=Z.pop();for(let J=0;J<Z.length;J++)try{I8(this,this.mapper(Z[J]))}catch(G){return X(G)}if(this.overflow=this[C].length>this.maxLength,this.overflow&&!this.skipOverflow){X(new Error("maximum buffer reached"));return}X()},j9=function($){if(this[C]+=this[U0].end(),this[C])try{I8(this,this.mapper(this[C]))}catch(U){return $(U)}$()},I8=function($,U){if(U!==void 0)$.push(U)},B8=function($){return $},W9=function($,U,X){switch($=$||/\r?\n/,U=U||B8,X=X||{},arguments.length){case 1:if(typeof $==="function")U=$,$=/\r?\n/;else if(typeof $==="object"&&!($ instanceof RegExp)&&!$[Symbol.split])X=$,$=/\r?\n/;break;case 2:if(typeof $==="function")X=U,U=$,$=/\r?\n/;else if(typeof U==="object")X=U,U=B8}X=Object.assign({},X),X.autoDestroy=!0,X.transform=Q9,X.flush=j9,X.readableObjectMode=!0;const Z=new G9(X);return Z[C]="",Z[U0]=new Y9("utf8"),Z.matcher=$,Z.mapper=U,Z.maxLength=X.maxLength,Z.skipOverflow=X.skipOverflow||!1,Z.overflow=!1,Z._destroy=function(J,G){this._writableState.errorEmitted=!1,G(J)},Z},{Transform:G9}=import.meta.require("stream"),{StringDecoder:Y9}=import.meta.require("string_decoder"),C=Symbol("last"),U0=Symbol("decoder");x8.exports=W9});var v8=H((E9,P)=>{var F9=function($){return($&R9)==L9},h0=function(){var $=o instanceof K9&&o.writable===!0;if($){var U=Array.prototype.slice.call(arguments).concat("\n");o.write(b8.format.apply(b8,U))}},h8=import.meta.require("path"),K9=import.meta.require("stream").Stream,H9=w8(),b8=import.meta.require("util"),O9=5432,X0=process.platform==="win32",o=process.stderr,_9=56,z9=7,R9=61440,L9=32768,b=["host","port","database","user","password"],w0=b.length,M9=b[w0-1];Object.defineProperty(E9,"isWin",{get:function(){return X0},set:function($){X0=$}});E9.warnTo=function($){var U=o;return o=$,U};E9.getFileName=function($){var U=$||process.env,X=U.PGPASSFILE||(X0?h8.join(U.APPDATA||"./","postgresql","pgpass.conf"):h8.join(U.HOME||"./",".pgpass"));return X};E9.usePgPass=function($,U){if(Object.prototype.hasOwnProperty.call(process.env,"PGPASSWORD"))return!1;if(X0)return!0;if(U=U||"<unkn>",!F9($.mode))return h0('WARNING: password file "%s" is not a plain file',U),!1;if($.mode&(_9|z9))return h0('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less',U),!1;return!0};var A9=E9.match=function($,U){return b.slice(0,-1).reduce(function(X,Z,J){if(J==1){if(Number($[Z]||O9)===Number(U[Z]))return X&&!0}return X&&(U[Z]==="*"||U[Z]===$[Z])},!0)};E9.getPassword=function($,U,X){var Z,J=U.pipe(H9());function G(j){var W=N9(j);if(W&&V9(W)&&A9($,W))Z=W[M9],J.end()}var Y=function(){U.destroy(),X(Z)},Q=function(j){U.destroy(),h0("WARNING: error on reading file: %s",j),X(void 0)};U.on("error",Q),J.on("data",G).on("end",Y).on("error",Q)};var N9=E9.parseLine=function($){if($.length<11||$.match(/^\s+#/))return null;var U="",X="",Z=0,J=0,G=0,Y={},Q=!1,j=function(K,O,_){var E=$.substring(O,_);if(!Object.hasOwnProperty.call(process.env,"PGPASS_NO_DEESCAPE"))E=E.replace(/\\([:\\])/g,"$1");Y[b[K]]=E};for(var W=0;W<$.length-1;W+=1){if(U=$.charAt(W+1),X=$.charAt(W),Q=Z==w0-1,Q){j(Z,J);break}if(W>=0&&U==":"&&X!=="\\")j(Z,J,W+1),J=W+2,Z+=1}return Y=Object.keys(Y).length===w0?Y:null,Y},V9=E9.isValidEntry=function($){var U={0:function(Y){return Y.length>0},1:function(Y){if(Y==="*")return!0;return Y=Number(Y),isFinite(Y)&&Y>0&&Y<9007199254740992&&Math.floor(Y)===Y},2:function(Y){return Y.length>0},3:function(Y){return Y.length>0},4:function(Y){return Y.length>0}};for(var X=0;X<b.length;X+=1){var Z=U[X],J=$[b[X]]||"",G=Z(J);if(!G)return!1}return!0}});var d8=H((wU,b0)=>{var xU=import.meta.require("path"),y8=import.meta.require("fs"),Z0=v8();b0.exports=function($,U){var X=Z0.getFileName();y8.stat(X,function(Z,J){if(Z||!Z0.usePgPass(J,X))return U(void 0);var G=y8.createReadStream(X);Z0.getPassword($,G,U)})};b0.exports.warnTo=Z0.warnTo});var f8=H((hU,u8)=>{var q9=import.meta.require("events").EventEmitter,m8=c(),v0=B1(),D9=S0(),k9=P0(),p8=o1(),B9=g(),I9=x0(),x9=E0();class y0 extends q9{constructor($){super();this.connectionParameters=new k9($),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;var U=$||{};if(this._Promise=U.Promise||global.Promise,this._types=new D9(U.types),this._ending=!1,this._ended=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this.connection=U.connection||new I9({stream:U.stream,ssl:this.connectionParameters.ssl,keepAlive:U.keepAlive||!1,keepAliveInitialDelayMillis:U.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||"utf8"}),this.queryQueue=[],this.binary=U.binary||B9.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=U.connectionTimeoutMillis||0}_errorAllQueries($){const U=(X)=>{process.nextTick(()=>{X.handleError($,this.connection)})};if(this.activeQuery)U(this.activeQuery),this.activeQuery=null;this.queryQueue.forEach(U),this.queryQueue.length=0}_connect($){var U=this,X=this.connection;if(this._connectionCallback=$,this._connecting||this._connected){const Z=new Error("Client has already been connected. You cannot reuse a client.");process.nextTick(()=>{$(Z)});return}if(this._connecting=!0,this.connectionTimeoutHandle,this._connectionTimeoutMillis>0)this.connectionTimeoutHandle=setTimeout(()=>{X._ending=!0,X.stream.destroy(new Error("timeout expired"))},this._connectionTimeoutMillis);if(this.host&&this.host.indexOf("/")===0)X.connect(this.host+"/.s.PGSQL."+this.port);else X.connect(this.port,this.host);X.on("connect",function(){if(U.ssl)X.requestSsl();else X.startup(U.getStartupConf())}),X.on("sslconnect",function(){X.startup(U.getStartupConf())}),this._attachListeners(X),X.once("end",()=>{const Z=this._ending?new Error("Connection terminated"):new Error("Connection terminated unexpectedly");if(clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(Z),this._ended=!0,!this._ending){if(this._connecting&&!this._connectionError)if(this._connectionCallback)this._connectionCallback(Z);else this._handleErrorEvent(Z);else if(!this._connectionError)this._handleErrorEvent(Z)}process.nextTick(()=>{this.emit("end")})})}connect($){if($){this._connect($);return}return new this._Promise((U,X)=>{this._connect((Z)=>{if(Z)X(Z);else U()})})}_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))}_checkPgPass($){const U=this.connection;if(typeof this.password==="function")this._Promise.resolve().then(()=>this.password()).then((X)=>{if(X!==void 0){if(typeof X!=="string"){U.emit("error",new TypeError("Password must be a string"));return}this.connectionParameters.password=this.password=X}else this.connectionParameters.password=this.password=null;$()}).catch((X)=>{U.emit("error",X)});else if(this.password!==null)$();else try{d8()(this.connectionParameters,(Z)=>{if(Z!==void 0)this.connectionParameters.password=this.password=Z;$()})}catch(X){this.emit("error",X)}}_handleAuthCleartextPassword($){this._checkPgPass(()=>{this.connection.password(this.password)})}_handleAuthMD5Password($){this._checkPgPass(async()=>{try{const U=await x9.postgresMd5PasswordHash(this.user,this.password,$.salt);this.connection.password(U)}catch(U){this.emit("error",U)}})}_handleAuthSASL($){this._checkPgPass(()=>{try{this.saslSession=v0.startSession($.mechanisms),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)}catch(U){this.connection.emit("error",U)}})}async _handleAuthSASLContinue($){try{await v0.continueSession(this.saslSession,this.password,$.data),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}catch(U){this.connection.emit("error",U)}}_handleAuthSASLFinal($){try{v0.finalizeSession(this.saslSession,$.data),this.saslSession=null}catch(U){this.connection.emit("error",U)}}_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")}const{activeQuery:U}=this;if(this.activeQuery=null,this.readyForQuery=!0,U)U.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($);const U=this.activeQuery;if(!U){this._handleErrorEvent($);return}this.activeQuery=null,U.handleError($,this.connection)}_handleRowDescription($){this.activeQuery.handleRowDescription($)}_handleDataRow($){this.activeQuery.handleDataRow($)}_handlePortalSuspended($){this.activeQuery.handlePortalSuspended(this.connection)}_handleEmptyQuery($){this.activeQuery.handleEmptyQuery(this.connection)}_handleCommandComplete($){this.activeQuery.handleCommandComplete($,this.connection)}_handleParseComplete($){if(this.activeQuery.name)this.connection.parsedStatements[this.activeQuery.name]=this.activeQuery.text}_handleCopyInResponse($){this.activeQuery.handleCopyInResponse(this.connection)}_handleCopyData($){this.activeQuery.handleCopyData($,this.connection)}_handleNotification($){this.emit("notification",$)}_handleNotice($){this.emit("notice",$)}getStartupConf(){var $=this.connectionParameters,U={user:$.user,database:$.database},X=$.application_name||$.fallback_application_name;if(X)U.application_name=X;if($.replication)U.replication=""+$.replication;if($.statement_timeout)U.statement_timeout=String(parseInt($.statement_timeout,10));if($.lock_timeout)U.lock_timeout=String(parseInt($.lock_timeout,10));if($.idle_in_transaction_session_timeout)U.idle_in_transaction_session_timeout=String(parseInt($.idle_in_transaction_session_timeout,10));if($.options)U.options=$.options;return U}cancel($,U){if($.activeQuery===U){var X=this.connection;if(this.host&&this.host.indexOf("/")===0)X.connect(this.host+"/.s.PGSQL."+this.port);else X.connect(this.port,this.host);X.on("connect",function(){X.cancel($.processID,$.secretKey)})}else if($.queryQueue.indexOf(U)!==-1)$.queryQueue.splice($.queryQueue.indexOf(U),1)}setTypeParser($,U,X){return this._types.setTypeParser($,U,X)}getTypeParser($,U){return this._types.getTypeParser($,U)}escapeIdentifier($){return m8.escapeIdentifier($)}escapeLiteral($){return m8.escapeLiteral($)}_pulseQueryQueue(){if(this.readyForQuery===!0){if(this.activeQuery=this.queryQueue.shift(),this.activeQuery){this.readyForQuery=!1,this.hasExecuted=!0;const $=this.activeQuery.submit(this.connection);if($)process.nextTick(()=>{this.activeQuery.handleError($,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else if(this.hasExecuted)this.activeQuery=null,this.emit("drain")}}query($,U,X){var Z,J,G,Y,Q;if($===null||$===void 0)throw new TypeError("Client was passed a null or undefined query");else if(typeof $.submit==="function"){if(G=$.query_timeout||this.connectionParameters.query_timeout,J=Z=$,typeof U==="function")Z.callback=Z.callback||U}else if(G=this.connectionParameters.query_timeout,Z=new p8($,U,X),!Z.callback)J=new this._Promise((j,W)=>{Z.callback=(K,O)=>K?W(K):j(O)}).catch((j)=>{throw Error.captureStackTrace(j),j});if(G)Q=Z.callback,Y=setTimeout(()=>{var j=new Error("Query read timeout");process.nextTick(()=>{Z.handleError(j,this.connection)}),Q(j),Z.callback=()=>{};var W=this.queryQueue.indexOf(Z);if(W>-1)this.queryQueue.splice(W,1);this._pulseQueryQueue()},G),Z.callback=(j,W)=>{clearTimeout(Y),Q(j,W)};if(this.binary&&!Z.binary)Z.binary=!0;if(Z._result&&!Z._result._types)Z._result._types=this._types;if(!this._queryable)return process.nextTick(()=>{Z.handleError(new Error("Client has encountered a connection error and is not queryable"),this.connection)}),J;if(this._ending)return process.nextTick(()=>{Z.handleError(new Error("Client was closed and is not queryable"),this.connection)}),J;return this.queryQueue.push(Z),this._pulseQueryQueue(),J}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.activeQuery||!this._queryable)this.connection.stream.destroy();else this.connection.end();if($)this.connection.once("end",$);else return new this._Promise((U)=>{this.connection.once("end",U)})}}y0.Query=p8;u8.exports=y0});var i8=H((bU,n8)=>{var h9=function(){throw new Error("Release called on client which has already been released to the pool.")},J0=function($,U){if(U)return{callback:U,result:void 0};let X,Z;const J=function(Y,Q){Y?X(Y):Z(Q)},G=new $(function(Y,Q){Z=Y,X=Q}).catch((Y)=>{throw Error.captureStackTrace(Y),Y});return{callback:J,result:G}},b9=function($,U){return function X(Z){Z.client=U,U.removeListener("error",X),U.on("error",()=>{$.log("additional client error after disconnection due to error",Z)}),$._remove(U),$.emit("error",Z,U)}},w9=import.meta.require("events").EventEmitter,g8=function(){},c8=($,U)=>{const X=$.findIndex(U);return X===-1?void 0:$.splice(X,1)[0]};class l8{constructor($,U,X){this.client=$,this.idleListener=U,this.timeoutId=X}}class n{constructor($){this.callback=$}}class o8 extends w9{constructor($,U){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.maxUses=this.options.maxUses||Infinity,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||U||d0().Client,this.Promise=this.options.Promise||global.Promise,typeof this.options.idleTimeoutMillis==="undefined")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}_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((U)=>{this._remove(U.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;const $=this._pendingQueue.shift();if(this._idle.length){const U=this._idle.pop();clearTimeout(U.timeoutId);const X=U.client;X.ref&&X.ref();const Z=U.idleListener;return this._acquireClient(X,$,Z,!1)}if(!this._isFull())return this.newClient($);throw new Error("unexpected condition")}_remove($){const U=c8(this._idle,(X)=>X.client===$);if(U!==void 0)clearTimeout(U.timeoutId);this._clients=this._clients.filter((X)=>X!==$),$.end(),this.emit("remove",$)}connect($){if(this.ending){const Z=new Error("Cannot use a pool after calling end on the pool");return $?$(Z):this.Promise.reject(Z)}const U=J0(this.Promise,$),X=U.result;if(this._isFull()||this._idle.length){if(this._idle.length)process.nextTick(()=>this._pulseQueue());if(!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new n(U.callback)),X;const Z=(Y,Q,j)=>{clearTimeout(G),U.callback(Y,Q,j)},J=new n(Z),G=setTimeout(()=>{c8(this._pendingQueue,(Y)=>Y.callback===Z),J.timedOut=!0,U.callback(new Error("timeout exceeded when trying to connect"))},this.options.connectionTimeoutMillis);return this._pendingQueue.push(J),X}return this.newClient(new n(U.callback)),X}newClient($){const U=new this.Client(this.options);this._clients.push(U);const X=b9(this,U);this.log("checking client timeout");let Z,J=!1;if(this.options.connectionTimeoutMillis)Z=setTimeout(()=>{this.log("ending client due to timeout"),J=!0,U.connection?U.connection.stream.destroy():U.end()},this.options.connectionTimeoutMillis);this.log("connecting new client"),U.connect((G)=>{if(Z)clearTimeout(Z);if(U.on("error",X),G){if(this.log("client failed to connect",G),this._clients=this._clients.filter((Y)=>Y!==U),J)G.message="Connection terminated due to connection timeout";if(this._pulseQueue(),!$.timedOut)$.callback(G,void 0,g8)}else{if(this.log("new client connected"),this.options.maxLifetimeSeconds!==0){const Y=setTimeout(()=>{if(this.log("ending client due to expired lifetime"),this._expired.add(U),this._idle.findIndex((j)=>j.client===U)!==-1)this._acquireClient(U,new n((j,W,K)=>K()),X,!1)},this.options.maxLifetimeSeconds*1000);Y.unref(),U.once("end",()=>clearTimeout(Y))}return this._acquireClient(U,$,X,!0)}})}_acquireClient($,U,X,Z){if(Z)this.emit("connect",$);if(this.emit("acquire",$),$.release=this._releaseOnce($,X),$.removeListener("error",X),!U.timedOut)if(Z&&this.options.verify)this.options.verify($,(J)=>{if(J)return $.release(J),U.callback(J,void 0,g8);U.callback(void 0,$,$.release)});else U.callback(void 0,$,$.release);else if(Z&&this.options.verify)this.options.verify($,$.release);else $.release()}_releaseOnce($,U){let X=!1;return(Z)=>{if(X)h9();X=!0,this._release($,U,Z)}}_release($,U,X){if($.on("error",U),$._poolUseCount=($._poolUseCount||0)+1,this.emit("release",X,$),X||this.ending||!$._queryable||$._ending||$._poolUseCount>=this.options.maxUses){if($._poolUseCount>=this.options.maxUses)this.log("remove expended client");this._remove($),this._pulseQueue();return}if(this._expired.has($)){this.log("remove expired client"),this._expired.delete($),this._remove($),this._pulseQueue();return}let J;if(this.options.idleTimeoutMillis){if(J=setTimeout(()=>{this.log("remove idle client"),this._remove($)},this.options.idleTimeoutMillis),this.options.allowExitOnIdle)J.unref()}if(this.options.allowExitOnIdle)$.unref();this._idle.push(new l8($,U,J)),this._pulseQueue()}query($,U,X){if(typeof $==="function"){const J=J0(this.Promise,$);return setImmediate(function(){return J.callback(new Error("Passing a function as the first parameter to pool.query is not supported"))}),J.result}if(typeof U==="function")X=U,U=void 0;const Z=J0(this.Promise,X);return X=Z.callback,this.connect((J,G)=>{if(J)return X(J);let Y=!1;const Q=(j)=>{if(Y)return;Y=!0,G.release(j),X(j)};G.once("error",Q),this.log("dispatching query");try{G.query($,U,(j,W)=>{if(this.log("query dispatched"),G.removeListener("error",Q),Y)return;if(Y=!0,G.release(j),j)return X(j);return X(void 0,W)})}catch(j){return G.release(j),X(j)}}),Z.result}end($){if(this.log("ending"),this.ending){const X=new Error("Called end on pool more than once");return $?$(X):this.Promise.reject(X)}this.ending=!0;const U=J0(this.Promise,$);return this._endCallback=U.callback,this._pulseQueue(),U.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce(($,U)=>$+(this._expired.has(U)?1:0),0)}get totalCount(){return this._clients.length}}n8.exports=o8});var s8=H((vU,t8)=>{var a8=import.meta.require("events").EventEmitter,v9=import.meta.require("util"),m0=c(),v=t8.exports=function($,U,X){a8.call(this),$=m0.normalizeQueryConfig($,U,X),this.text=$.text,this.values=$.values,this.name=$.name,this.callback=$.callback,this.state="new",this._arrayMode=$.rowMode==="array",this._emitRowEvents=!1,this.on("newListener",function(Z){if(Z==="row")this._emitRowEvents=!0}.bind(this))};v9.inherits(v,a8);var y9={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"file",sourceLine:"line",sourceFunction:"routine"};v.prototype.handleError=function($){var U=this.native.pq.resultErrorFields();if(U)for(var X in U){var Z=y9[X]||X;$[Z]=U[X]}if(this.callback)this.callback($);else this.emit("error",$);this.state="error"};v.prototype.then=function($,U){return this._getPromise().then($,U)};v.prototype.catch=function($){return this._getPromise().catch($)};v.prototype._getPromise=function(){if(this._promise)return this._promise;return this._promise=new Promise(function($,U){this._once("end",$),this._once("error",U)}.bind(this)),this._promise};v.prototype.submit=function($){this.state="running";var U=this;this.native=$.native,$.native.arrayMode=this._arrayMode;var X=function(G,Y,Q){if($.native.arrayMode=!1,setImmediate(function(){U.emit("_done")}),G)return U.handleError(G);if(U._emitRowEvents)if(Q.length>1)Y.forEach((j,W)=>{j.forEach((K)=>{U.emit("row",K,Q[W])})});else Y.forEach(function(j){U.emit("row",j,Q)});if(U.state="end",U.emit("end",Q),U.callback)U.callback(null,Q)};if(process.domain)X=process.domain.bind(X);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");var Z=(this.values||[]).map(m0.prepareValue);if($.namedQueries[this.name]){if(this.text&&$.namedQueries[this.name]!==this.text){const G=new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return X(G)}return $.native.execute(this.name,Z,X)}return $.native.prepare(this.name,this.text,Z.length,function(G){if(G)return X(G);return $.namedQueries[U.name]=U.text,U.native.execute(U.name,Z,X)})}else if(this.values){if(!Array.isArray(this.values)){const G=new Error("Query values must be an array");return X(G)}var J=this.values.map(m0.prepareValue);$.native.query(this.text,J,X)}else $.native.query(this.text,X)}});var p0=H((yU,U$)=>{var r8;try{r8=(()=>{throw new Error(`Cannot require module "pg-native"`);})()}catch($){throw $}var d9=S0(),e8=import.meta.require("events").EventEmitter,m9=import.meta.require("util"),p9=P0(),$$=s8(),V=U$.exports=function($){e8.call(this),$=$||{},this._Promise=$.Promise||global.Promise,this._types=new d9($.types),this.native=new r8({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;var U=this.connectionParameters=new p9($);if($.nativeConnectionString)U.nativeConnectionString=$.nativeConnectionString;this.user=U.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:U.password}),this.database=U.database,this.host=U.host,this.port=U.port,this.namedQueries={}};V.Query=$$;m9.inherits(V,e8);V.prototype._errorAllQueries=function($){const U=(X)=>{process.nextTick(()=>{X.native=this.native,X.handleError($)})};if(this._hasActiveQuery())U(this._activeQuery),this._activeQuery=null;this._queryQueue.forEach(U),this._queryQueue.length=0};V.prototype._connect=function($){var U=this;if(this._connecting){process.nextTick(()=>$(new Error("Client has already been connected. You cannot reuse a client.")));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(X,Z){if(U.connectionParameters.nativeConnectionString)Z=U.connectionParameters.nativeConnectionString;if(X)return $(X);U.native.connect(Z,function(J){if(J)return U.native.end(),$(J);U._connected=!0,U.native.on("error",function(G){U._queryable=!1,U._errorAllQueries(G),U.emit("error",G)}),U.native.on("notification",function(G){U.emit("notification",{channel:G.relname,payload:G.extra})}),U.emit("connect"),U._pulseQueryQueue(!0),$()})})};V.prototype.connect=function($){if($){this._connect($);return}return new this._Promise((U,X)=>{this._connect((Z)=>{if(Z)X(Z);else U()})})};V.prototype.query=function($,U,X){var Z,J,G,Y,Q;if($===null||$===void 0)throw new TypeError("Client was passed a null or undefined query");else if(typeof $.submit==="function"){if(G=$.query_timeout||this.connectionParameters.query_timeout,J=Z=$,typeof U==="function")$.callback=U}else if(G=this.connectionParameters.query_timeout,Z=new $$($,U,X),!Z.callback){let j,W;J=new this._Promise((K,O)=>{j=K,W=O}).catch((K)=>{throw Error.captureStackTrace(K),K}),Z.callback=(K,O)=>K?W(K):j(O)}if(G)Q=Z.callback,Y=setTimeout(()=>{var j=new Error("Query read timeout");process.nextTick(()=>{Z.handleError(j,this.connection)}),Q(j),Z.callback=()=>{};var W=this._queryQueue.indexOf(Z);if(W>-1)this._queryQueue.splice(W,1);this._pulseQueryQueue()},G),Z.callback=(j,W)=>{clearTimeout(Y),Q(j,W)};if(!this._queryable)return Z.native=this.native,process.nextTick(()=>{Z.handleError(new Error("Client has encountered a connection error and is not queryable"))}),J;if(this._ending)return Z.native=this.native,process.nextTick(()=>{Z.handleError(new Error("Client was closed and is not queryable"))}),J;return this._queryQueue.push(Z),this._pulseQueryQueue(),J};V.prototype.end=function($){var U=this;if(this._ending=!0,!this._connected)this.once("connect",this.end.bind(this,$));var X;if(!$)X=new this._Promise(function(Z,J){$=(G)=>G?J(G):Z()});return this.native.end(function(){U._errorAllQueries(new Error("Connection terminated")),process.nextTick(()=>{if(U.emit("end"),$)$()})}),X};V.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!=="error"&&this._activeQuery.state!=="end"};V.prototype._pulseQueryQueue=function($){if(!this._connected)return;if(this._hasActiveQuery())return;var U=this._queryQueue.shift();if(!U){if(!$)this.emit("drain");return}this._activeQuery=U,U.submit(this);var X=this;U.once("_done",function(){X._pulseQueryQueue()})};V.prototype.cancel=function($){if(this._activeQuery===$)this.native.cancel(function(){});else if(this._queryQueue.indexOf($)!==-1)this._queryQueue.splice(this._queryQueue.indexOf($),1)};V.prototype.ref=function(){};V.prototype.unref=function(){};V.prototype.setTypeParser=function($,U,X){return this._types.setTypeParser($,U,X)};V.prototype.getTypeParser=function($,U){return this._types.getTypeParser($,U)}});var d0=H((dU,i)=>{var u9=f8(),f9=g(),g9=x0(),c9=i8(),{DatabaseError:l9}=B0(),{escapeIdentifier:o9,escapeLiteral:n9}=c(),i9=($)=>{return class U extends c9{constructor(X){super(X,$)}}},u0=function($){this.defaults=f9,this.Client=$,this.Query=this.Client.Query,this.Pool=i9(this.Client),this._pools=[],this.Connection=g9,this.types=f(),this.DatabaseError=l9,this.escapeIdentifier=o9,this.escapeLiteral=n9};if(typeof process.env.NODE_PG_FORCE_NATIVE!=="undefined")i.exports=new u0(p0());else i.exports=new u0(u9),Object.defineProperty(i.exports,"native",{configurable:!0,enumerable:!1,get(){var $=null;try{$=new u0(p0())}catch(U){if(U.code!=="MODULE_NOT_FOUND")throw U}return Object.defineProperty(i.exports,"native",{value:$}),$}})});var X$=_$(d0(),1),D=new X$.Pool({host:"0.0.0.0",port:5432,user:"postgres",password:"123",database:"rinha"});function Z$($,U){if(typeof $!=="number"||$<1)U.status=422;return U}function J$($,U,X){if(typeof $!=="number"||$<1)X.status=422;if(!U.valor||typeof U.valor!=="number"||U.valor<1||!Number.isInteger(U.valor))X.status=422;if(!U.tipo||typeof U.tipo!=="string"||!["c","d"].includes(U.tipo))X.status=422;if(!U.descricao||typeof U.descricao!=="string"||U.descricao.length<1||U.descricao.length>10)X.status=422;return X}async function G$($,U){if(Z$($,U).status!==200)return;const Z=(await D.query("SELECT * FROM customers WHERE id = $1",[$])).rows[0];if(!Z){U.status=404;return}const J=(await D.query("SELECT * FROM transacoes WHERE customerId = $1 ORDER BY realizada_em DESC LIMIT 10",[$])).rows;return{saldo:{total:Z.saldo,data_extrato:(new Date()).toISOString(),limite:Z.limite},ultimas_transacoes:J}}async function Y$($,U,X){if(J$($,U,X).status!==200)return;const J=(await D.query("SELECT * FROM customers WHERE id = $1",[$])).rows[0];if(!J){X.status=404;return}let G=0;if(U.tipo==="d"){const Y=await D.query("SELECT * FROM debit ($1, $2, $3)",[$,U.valor,U.descricao]),{saldofinal:Q,error:j}=Y.rows[0];if(j)return X.status=422,"saldo insuficente";G=Q}if(U.tipo==="c")G=(await D.query("SELECT * FROM credit ($1, $2, $3)",[$,U.valor,U.descricao])).rows[0].saldofinal;return{limite:J.limite,saldo:G}}var Q$=new RegExp(/clientes\/(\d+)\/extrato/),j$=new RegExp(/clientes\/(\d+)\/transacoes/),a9=async($)=>{const U=new URL($.url),X={status:200};if($.method==="GET"&&Q$.test(U.pathname)){const Z=+Q$.exec(U.pathname)[1],J=await G$(Z,X);return{status:X.status,body:J}}if($.method==="POST"&&j$.test(U.pathname)){const Z=+j$.exec(U.pathname)[1],J=await $.json(),G=await Y$(Z,J,X);return{status:X.status,body:G}}},W$=Bun.env.PORT;Bun.serve({port:W$,async fetch($){const U=await a9($);if(!U)return new Response(null,{status:404});return new Response(JSON.stringify(U.body),{status:U.status})}});console.log(`Server is running at on port ${W$}...`);
nginx-1 | 2024/02/19 04:54:58 [error] 29#29: *19 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://127.0.0.1:8081/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:58 [error] 30#30: *12 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://127.0.0.1:8081/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:58 [error] 29#29: *40 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://[::1]:8082/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:58 [error] 31#31: *39 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://[::1]:8082/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:58 [error] 29#29: *14 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://127.0.0.1:8082/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:58 [error] 31#31: *37 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://127.0.0.1:8082/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:58 [error] 31#31: *35 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://[::1]:8082/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:58 [error] 29#29: *20 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://[::1]:8082/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:58 [error] 29#29: *23 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://[::1]:8082/clientes/1/transacoes", host: "localhost:9999"
api02-1 | ^
api02-1 | error: terminating connection due to unexpected postmaster exit
api02-1 | code: "57P01"
api02-1 |
api02-1 | at new n1 (/home/bun/app/index.js:2:30208)
api02-1 | at parseErrorMessage (/home/bun/app/index.js:2:42334)
api02-1 | at parse (/home/bun/app/index.js:2:37596)
api02-1 | at emit (native:1:1)
api02-1 | at addChunk (node:1:1940)
api02-1 | at readableAddChunk (node:1:1894)
api02-1 | at data (node:1:52)
nginx-1 | 2024/02/19 04:54:58 [error] 30#30: *55 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /clientes/1/extrato HTTP/1.1", upstream: "http://[::1]:8082/clientes/1/extrato", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:58 [error] 30#30: *55 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /clientes/1/extrato HTTP/1.1", upstream: "http://127.0.0.1:8082/clientes/1/extrato", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:58 [error] 30#30: *55 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /clientes/1/extrato HTTP/1.1", upstream: "http://[::1]:8081/clientes/1/extrato", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:58 [error] 30#30: *55 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "GET /clientes/1/extrato HTTP/1.1", upstream: "http://upstreamapi/clientes/1/extrato", host: "localhost:9999"
api02-1 exited with code 0
api01-1 exited with code 0
postgres-1 exited with code 0
postgres-1 |
postgres-1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres-1 |
api01-1 | Server is running at on port 8081...
api02-1 | Server is running at on port 8082...
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *59 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *60 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *61 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *62 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *63 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *64 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *65 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *66 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *67 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *68 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *69 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *70 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *71 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *72 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *73 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *74 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *75 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *76 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *77 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *78 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *79 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:54:59 [error] 30#30: *80 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/1/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/1/transacoes", host: "localhost:9999"
api01-1 | 2 | // @bun
api01-1 | 3 | var K$=Object.create;var{defineProperty:y,getPrototypeOf:H$,getOwnPropertyNames:f0,getOwnPropertyDescriptor:O$}=Object,g0=Object.prototype.hasOwnProperty;var _$=($,U,X)=>{X=$!=null?K$(H$($)):{};const Z=U||!$||!$.__esModule?y(X,"default",{value:$,enumerable:!0}):X;for(let J of f0($))if(!g0.call(Z,J))y(Z,J,{get:()=>$[J],enumerable:!0});return Z},c0=($)=>{const U=c0.moduleCache??=new WeakMap;var X=U.get($);if(X)return X;var Z=y({},"__esModule",{value:!0}),J={enumerable:!1};if($&&typeof $==="object"||typeof $==="function"){for(let G of f0($))if(!g0.call(Z,G))y(Z,G,{get:()=>$[G],enumerable:!(J=O$($,G))||J.enumerable})}return U.set($,Z),Z};var H=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports);var z$=($,U)=>{for(var X in U)y($,X,{get:U[X],enumerable:!0,configurable:!0,set:(Z)=>U[X]=()=>Z})};var R$=($,U)=>()=>($&&(U=$($=0)),U);var j0=H((F$)=>{var L$=function($){return $};F$.parse=function($,U){return new Q0($,U).parse()};class Q0{constructor($,U){this.source=$,this.transform=U||L$,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 U;if(this.recorded.length>0||$){if(U=this.recorded.join(""),U==="NULL"&&!$)U=null;if(U!==null)U=this.transform(U);this.entries.push(U),this.recorded=[]}}consumeDimensions(){if(this.source[0]==="[")while(!this.isEof()){var $=this.nextCharacter();if($.value==="=")break}}parse($){var U,X,Z;this.consumeDimensions();while(!this.isEof())if(U=this.nextCharacter(),U.value==="{"&&!Z){if(this.dimension++,this.dimension>1)X=new Q0(this.source.substr(this.position-1),this.transform),this.entries.push(X.parse(!0)),this.position+=X.position-2}else if(U.value==="}"&&!Z){if(this.dimension--,!this.dimension){if(this.newEntry(),$)return this.entries}}else if(U.value==='"'&&!U.escaped){if(Z)this.newEntry(!0);Z=!Z}else if(U.value===","&&!Z)this.newEntry();else this.record(U.value);if(this.dimension!==0)throw new Error("array dimension not balanced");return this.entries}}});var W0=H((r9,l0)=>{var A$=j0();l0.exports={create:function($,U){return{parse:function(){return A$.parse($,U)}}}}});var i0=H((e9,n0)=>{var T$=function($){var U=V$.exec($);if(!U)return;var X=parseInt(U[1],10),Z=!!U[4];if(Z)X=o0(X);var J=parseInt(U[2],10)-1,G=U[3],Y=new Date(X,J,G);if(K0(X))Y.setFullYear(X);return Y},P$=function($){if($.endsWith("+00"))return 0;var U=E$.exec($.split(" ")[1]);if(!U)return;var X=U[1];if(X==="Z")return 0;var Z=X==="-"?-1:1,J=parseInt(U[2],10)*3600+parseInt(U[3]||0,10)*60+parseInt(U[4]||0,10);return J*Z*1000},o0=function($){return-($-1)},K0=function($){return $>=0&&$<100},N$=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,V$=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,E$=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,S$=/^-?infinity$/;n0.exports=function $(U){if(S$.test(U))return Number(U.replace("i","I"));var X=N$.exec(U);if(!X)return T$(U)||null;var Z=!!X[8],J=parseInt(X[1],10);if(Z)J=o0(J);var G=parseInt(X[2],10)-1,Y=X[3],Q=parseInt(X[4],10),j=parseInt(X[5],10),W=parseInt(X[6],10),K=X[7];K=K?1000*parseFloat(K):0;var O,_=P$(U);if(_!=null){if(O=new Date(Date.UTC(J,G,Y,Q,j,W,K)),K0(J))O.setUTCFullYear(J);if(_!==0)O.setTime(O.getTime()-_)}else if(O=new Date(J,G,Y,Q,j,W,K),K0(J))O.setFullYear(J);return O}});var t0=H(($U,a0)=>{var q$=function($){for(var U=1;U<arguments.length;U++){var X=arguments[U];for(var Z in X)if(C$.call(X,Z))$[Z]=X[Z]}return $};a0.exports=q$;var C$=Object.prototype.hasOwnProperty});var e0=H((UU,r0)=>{var k=function($){if(!(this instanceof k))return new k($);D$(this,p$($))},m$=function($){var U=$+"000000".slice($.length);return parseInt(U,10)/1000},p$=function($){if(!$)return{};var U=y$.exec($),X=U[8]==="-";return Object.keys(s0).reduce(function(Z,J){var G=s0[J],Y=U[G];if(!Y)return Z;if(Y=J==="milliseconds"?m$(Y):parseInt(Y,10),!Y)return Z;if(X&&~d$.indexOf(J))Y*=-1;return Z[J]=Y,Z},{})},D$=t0();r0.exports=k;var k$=["seconds","minutes","hours","days","months","years"];k.prototype.toPostgres=function(){var $=k$.filter(this.hasOwnProperty,this);if(this.milliseconds&&$.indexOf("seconds")<0)$.push("seconds");if($.length===0)return"0";return $.map(function(U){var X=this[U]||0;if(U==="seconds"&&this.milliseconds)X=(X+this.milliseconds/1000).toFixed(6).replace(/\.?0+$/,"");return X+" "+U},this).join(" ")};var B$={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"S"},I$=["years","months","days"],x$=["hours","minutes","seconds"];k.prototype.toISOString=k.prototype.toISO=function(){var $=I$.map(X,this).join(""),U=x$.map(X,this).join("");return"P"+$+"T"+U;function X(Z){var J=this[Z]||0;if(Z==="seconds"&&this.milliseconds)J=(J+this.milliseconds/1000).toFixed(6).replace(/0+$/,"");return J+B$[Z]}};var H0="([+-]?\\d+)",w$=H0+"\\s+years?",h$=H0+"\\s+mons?",b$=H0+"\\s+days?",v$="([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",y$=new RegExp([w$,h$,b$,v$].map(function($){return"("+$+")?"}).join("\\s*")),s0={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},d$=["hours","minutes","seconds","milliseconds"]});var U1=H((XU,$1)=>{$1.exports=function $(U){if(/^\\x/.test(U))return new Buffer(U.substr(2),"hex");var X="",Z=0;while(Z<U.length)if(U[Z]!=="\\")X+=U[Z],++Z;else if(/[0-7]{3}/.test(U.substr(Z+1,3)))X+=String.fromCharCode(parseInt(U.substr(Z+1,3),8)),Z+=4;else{var J=1;while(Z+J<U.length&&U[Z+J]==="\\")J++;for(var G=0;G<Math.floor(J/2);++G)X+="\\";Z+=Math.floor(J/2)*2}return new Buffer(X,"binary")}});var j1=H((ZU,Q1)=>{var t=function($){return function U(X){if(X===null)return X;return $(X)}},G1=function($){if($===null)return $;return $==="TRUE"||$==="t"||$==="true"||$==="y"||$==="yes"||$==="on"||$==="1"},u$=function($){if(!$)return null;return d.parse($,G1)},f$=function($){return parseInt($,10)},O0=function($){if(!$)return null;return d.parse($,t(f$))},g$=function($){if(!$)return null;return d.parse($,t(function(U){return Y1(U).trim()}))},d=j0(),m=W0(),a=i0(),Z1=e0(),J1=U1(),c$=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=L0(X);return X});return U.parse()},_0=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=parseFloat(X);return X});return U.parse()},S=function($){if(!$)return null;var U=m.create($);return U.parse()},z0=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=a(X);return X});return U.parse()},l$=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=Z1(X);return X});return U.parse()},o$=function($){if(!$)return null;return d.parse($,t(J1))},R0=function($){return parseInt($,10)},Y1=function($){var U=String($);if(/^\d+$/.test(U))return U;return $},X1=function($){if(!$)return null;return d.parse($,t(JSON.parse))},L0=function($){if($[0]!=="(")return null;return $=$.substring(1,$.length-1).split(","),{x:parseFloat($[0]),y:parseFloat($[1])}},n$=function($){if($[0]!=="<"&&$[1]!=="(")return null;var U="(",X="",Z=!1;for(var J=2;J<$.length-1;J++){if(!Z)U+=$[J];if($[J]===")"){Z=!0;continue}else if(!Z)continue;if($[J]===",")continue;X+=$[J]}var G=L0(U);return G.radius=parseFloat(X),G},i$=function($){$(20,Y1),$(21,R0),$(23,R0),$(26,R0),$(700,parseFloat),$(701,parseFloat),$(16,G1),$(1082,a),$(1114,a),$(1184,a),$(600,L0),$(651,S),$(718,n$),$(1000,u$),$(1001,o$),$(1005,O0),$(1007,O0),$(1028,O0),$(1016,g$),$(1017,c$),$(1021,_0),$(1022,_0),$(1231,_0),$(1014,S),$(1015,S),$(1008,S),$(1009,S),$(1040,S),$(1041,S),$(1115,z0),$(1182,z0),$(1185,z0),$(1186,Z1),$(1187,l$),$(17,J1),$(114,JSON.parse.bind(JSON)),$(3802,JSON.parse.bind(JSON)),$(199,X1),$(3807,X1),$(3907,S),$(2951,S),$(791,S),$(1183,S),$(1270,S)};Q1.exports={init:i$}});var K1=H((JU,W1)=>{var a$=function($){var U=$.readInt32BE(0),X=$.readUInt32BE(4),Z="";if(U<0)U=~U+(X===0),X=~X+1>>>0,Z="-";var J="",G,Y,Q,j,W,K;{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}return G=U%N,Y=4294967296*G+X,Q=""+Y%N,Z+Q+J},N=1e6;W1.exports=a$});var R1=H((GU,z1)=>{var t$=K1(),z=function($,U,X,Z,J){X=X||0,Z=Z||!1,J=J||function(E,G0,Y0){return E*Math.pow(2,Y0)+G0};var G=X>>3,Y=function(E){if(Z)return~E&255;return E},Q=255,j=8-X%8;if(U<j)Q=255<<8-U&255,j=U;if(X)Q=Q>>X%8;var W=0;if(X%8+U>=8)W=J(0,Y($[G])&Q,j);var K=U+X>>3;for(var O=G+1;O<K;O++)W=J(W,Y($[O]),8);var _=(U+X)%8;if(_>0)W=J(W,Y($[K])>>8-_,_);return W},_1=function($,U,X){var Z=Math.pow(2,X-1)-1,J=z($,1),G=z($,X,1);if(G===0)return 0;var Y=1,Q=function(W,K,O){if(W===0)W=1;for(var _=1;_<=O;_++)if(Y/=2,(K&1<<O-_)>0)W+=Y;return W},j=z($,U,X+1,!1,Q);if(G==Math.pow(2,X+1)-1){if(j===0)return J===0?Infinity:(-Infinity);return NaN}return(J===0?1:-1)*Math.pow(2,G-Z)*j},s$=function($){if(z($,1)==1)return-1*(z($,15,1,!0)+1);return z($,15,1)},H1=function($){if(z($,1)==1)return-1*(z($,31,1,!0)+1);return z($,31,1)},r$=function($){return _1($,23,8)},e$=function($){return _1($,52,11)},$4=function($){var U=z($,16,32);if(U==49152)return NaN;var X=Math.pow(1e4,z($,16,16)),Z=0,J=[],G=z($,16);for(var Y=0;Y<G;Y++)Z+=z($,16,64+16*Y)*X,X/=1e4;var Q=Math.pow(10,z($,16,48));return(U===0?1:-1)*Math.round(Z*Q)/Q},O1=function($,U){var X=z(U,1),Z=z(U,63,1),J=new Date((X===0?1:-1)*Z/1000+946684800000);if(!$)J.setTime(J.getTime()+J.getTimezoneOffset()*60000);return J.usec=Z%1000,J.getMicroSeconds=function(){return this.usec},J.setMicroSeconds=function(G){this.usec=G},J.getUTCMicroSeconds=function(){return this.usec},J},p=function($){var U=z($,32),X=z($,32,32),Z=z($,32,64),J=96,G=[];for(var Y=0;Y<U;Y++)G[Y]=z($,32,J),J+=32,J+=32;var Q=function(W){var K=z($,32,J);if(J+=32,K==4294967295)return null;var O;if(W==23||W==20)return O=z($,K*8,J),J+=K*8,O;else if(W==25)return O=$.toString(this.encoding,J>>3,(J+=K<<3)>>3),O;else console.log("ERROR: ElementType not implemented: "+W)},j=function(W,K){var O=[],_;if(W.length>1){var E=W.shift();for(_=0;_<E;_++)O[_]=j(W,K);W.unshift(E)}else for(_=0;_<W[0];_++)O[_]=Q(K);return O};return j(G,Z)},U4=function($){return $.toString("utf8")},X4=function($){if($===null)return null;return z($,8)>0},Z4=function($){$(20,t$),$(21,s$),$(23,H1),$(26,H1),$(1700,$4),$(700,r$),$(701,e$),$(16,X4),$(1114,O1.bind(null,!1)),$(1184,O1.bind(null,!0)),$(1000,p),$(1007,p),$(1016,p),$(1008,p),$(1009,p),$(25,U4)};z1.exports={init:Z4}});var F1=H((YU,L1)=>{L1.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 f=H((K4)=>{var M1=function($){return String($)},j4=function($,U){if(U=U||"text",!u[U])return M1;return u[U][$]||M1},W4=function($,U,X){if(typeof U=="function")X=U,U="text";u[U][$]=X},J4=j1(),G4=R1(),Y4=W0(),Q4=F1();K4.getTypeParser=j4;K4.setTypeParser=W4;K4.arrayParser=Y4;K4.builtins=Q4;var u={text:{},binary:{}};J4.init(function($,U){u.text[$]=U});G4.init(function($,U){u.binary[$]=U})});var g=H((jU,F0)=>{F0.exports={host:"localhost",user:process.platform==="win32"?process.env.USERNAME:process.env.USER,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 B=f(),R4=B.getTypeParser(20,"text"),L4=B.getTypeParser(1016,"text");F0.exports.__defineSetter__("parseInt8",function($){B.setTypeParser(20,"text",$?B.getTypeParser(23,"text"):R4),B.setTypeParser(1016,"text",$?B.getTypeParser(1007,"text"):L4)})});var c=H((WU,N1)=>{var M4=function($){var U=$.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return'"'+U+'"'},A1=function($){var U="{";for(var X=0;X<$.length;X++){if(X>0)U=U+",";if($[X]===null||typeof $[X]==="undefined")U=U+"NULL";else if(Array.isArray($[X]))U=U+A1($[X]);else if($[X]instanceof Buffer)U+="\\\\x"+$[X].toString("hex");else U+=M4(s($[X]))}return U=U+"}",U},A4=function($,U){if($&&typeof $.toPostgres==="function"){if(U=U||[],U.indexOf($)!==-1)throw new Error('circular reference detected while preparing "'+$+'" for query');return U.push($),s($.toPostgres(s),U)}return JSON.stringify($)},M=function($,U){$=""+$;while($.length<U)$="0"+$;return $},N4=function($){var U=-$.getTimezoneOffset(),X=$.getFullYear(),Z=X<1;if(Z)X=Math.abs(X)+1;var J=M(X,4)+"-"+M($.getMonth()+1,2)+"-"+M($.getDate(),2)+"T"+M($.getHours(),2)+":"+M($.getMinutes(),2)+":"+M($.getSeconds(),2)+"."+M($.getMilliseconds(),3);if(U<0)J+="-",U*=-1;else J+="+";if(J+=M(Math.floor(U/60),2)+":"+M(U%60,2),Z)J+=" BC";return J},V4=function($){var U=$.getUTCFullYear(),X=U<1;if(X)U=Math.abs(U)+1;var Z=M(U,4)+"-"+M($.getUTCMonth()+1,2)+"-"+M($.getUTCDate(),2)+"T"+M($.getUTCHours(),2)+":"+M($.getUTCMinutes(),2)+":"+M($.getUTCSeconds(),2)+"."+M($.getUTCMilliseconds(),3);if(Z+="+00:00",X)Z+=" BC";return Z},E4=function($,U,X){if($=typeof $==="string"?{text:$}:$,U)if(typeof U==="function")$.callback=U;else $.values=U;if(X)$.callback=X;return $},F4=g(),s=function($,U){if($==null)return null;if($ instanceof Buffer)return $;if(ArrayBuffer.isView($)){var X=Buffer.from($.buffer,$.byteOffset,$.byteLength);if(X.length===$.byteLength)return X;return X.slice($.byteOffset,$.byteOffset+$.byteLength)}if($ instanceof Date)if(F4.parseInputDatesAsUTC)return V4($);else return N4($);if(Array.isArray($))return A1($);if(typeof $==="object")return A4($,U);return $.toString()},S4=function($){return'"'+$.replace(/"/g,'""')+'"'},T4=function($){var U=!1,X="'";for(var Z=0;Z<$.length;Z++){var J=$[Z];if(J==="'")X+=J+J;else if(J==="\\")X+=J+J,U=!0;else X+=J}if(X+="'",U===!0)X=" E"+X;return X};N1.exports={prepareValue:function $(U){return s(U)},normalizeQueryConfig:E4,escapeIdentifier:S4,escapeLiteral:T4}});var E1=H((KU,V1)=>{var M0=function($){return l.createHash("md5").update($,"utf-8").digest("hex")},P4=function($,U,X){var Z=M0(U+$),J=M0(Buffer.concat([Buffer.from(Z),X]));return"md5"+J},C4=function($){return l.createHash("sha256").update($).digest()},q4=function($,U){return l.createHmac("sha256",$).update(U).digest()};async function D4($,U,X){return l.pbkdf2Sync($,U,X,32,"sha256")}var l=import.meta.require("crypto");V1.exports={postgresMd5PasswordHash:P4,randomBytes:l.randomBytes,deriveKey:D4,sha256:C4,hmacSha256:q4,md5:M0}});var C1=H((HU,P1)=>{var k4=function($){return T1.getRandomValues(Buffer.alloc($))};async function A0($){try{return S1.createHash("md5").update($,"utf-8").digest("hex")}catch(U){const X=typeof $==="string"?N0.encode($):$,Z=await I.digest("MD5",X);return Array.from(new Uint8Array(Z)).map((J)=>J.toString(16).padStart(2,"0")).join("")}}async function B4($,U,X){var Z=await A0(U+$),J=await A0(Buffer.concat([Buffer.from(Z),X]));return"md5"+J}async function I4($){return await I.digest("SHA-256",$)}async function x4($,U){const X=await I.importKey("raw",$,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return await I.sign("HMAC",X,N0.encode(U))}async function w4($,U,X){const Z=await I.importKey("raw",N0.encode($),"PBKDF2",!1,["deriveBits"]),J={name:"PBKDF2",hash:"SHA-256",salt:U,iterations:X};return await I.deriveBits(J,Z,256,["deriveBits"])}var S1=import.meta.require("crypto");P1.exports={postgresMd5PasswordHash:B4,randomBytes:k4,deriveKey:w4,sha256:I4,hmacSha256:x4,md5:A0};var T1=S1.webcrypto||globalThis.crypto,I=T1.subtle,N0=new TextEncoder});var E0=H((OU,V0)=>{var h4=parseInt(process.versions&&process.versions.node&&process.versions.node.split(".")[0])<15;if(h4)V0.exports=E1();else V0.exports=C1()});var B1=H((_U,k1)=>{var b4=function($){if($.indexOf("SCRAM-SHA-256")===-1)throw new Error("SASL: Only mechanism SCRAM-SHA-256 is currently supported");const U=q.randomBytes(18).toString("base64");return{mechanism:"SCRAM-SHA-256",clientNonce:U,response:"n,,n=*,r="+U,message:"SASLInitialResponse"}};async function v4($,U,X){if($.message!=="SASLInitialResponse")throw new Error("SASL: Last message was not SASLInitialResponse");if(typeof U!=="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");if(U==="")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string");if(typeof X!=="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");const Z=m4(X);if(!Z.nonce.startsWith($.clientNonce))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");else if(Z.nonce.length===$.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short");var J="n=*,r="+$.clientNonce,G="r="+Z.nonce+",s="+Z.salt+",i="+Z.iteration,Y="c=biws,r="+Z.nonce,Q=J+","+G+","+Y,j=Buffer.from(Z.salt,"base64"),W=await q.deriveKey(U,j,Z.iteration),K=await q.hmacSha256(W,"Client Key"),O=await q.sha256(K),_=await q.hmacSha256(O,Q),E=u4(Buffer.from(K),Buffer.from(_)).toString("base64"),G0=await q.hmacSha256(W,"Server Key"),Y0=await q.hmacSha256(G0,Q);$.message="SASLResponse",$.serverSignature=Buffer.from(Y0).toString("base64"),$.response=Y+",p="+E}var y4=function($,U){if($.message!=="SASLResponse")throw new Error("SASL: Last message was not SASLResponse");if(typeof U!=="string")throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");const{serverSignature:X}=p4(U);if(X!==$.serverSignature)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match")},d4=function($){if(typeof $!=="string")throw new TypeError("SASL: text must be a string");return $.split("").map((U,X)=>$.charCodeAt(X)).every((U)=>U>=33&&U<=43||U>=45&&U<=126)},q1=function($){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test($)},D1=function($){if(typeof $!=="string")throw new TypeError("SASL: attribute pairs text must be a string");return new Map($.split(",").map((U)=>{if(!/^.=/.test(U))throw new Error("SASL: Invalid attribute pair entry");const X=U[0],Z=U.substring(2);return[X,Z]}))},m4=function($){const U=D1($),X=U.get("r");if(!X)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");else if(!d4(X))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters");const Z=U.get("s");if(!Z)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing");else if(!q1(Z))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64");const J=U.get("i");if(!J)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing");else if(!/^[1-9][0-9]*$/.test(J))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count");const G=parseInt(J,10);return{nonce:X,salt:Z,iteration:G}},p4=function($){const X=D1($).get("v");if(!X)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");else if(!q1(X))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64");return{serverSignature:X}},u4=function($,U){if(!Buffer.isBuffer($))throw new TypeError("first argument must be a Buffer");if(!Buffer.isBuffer(U))throw new TypeError("second argument must be a Buffer");if($.length!==U.length)throw new Error("Buffer lengths must match");if($.length===0)throw new Error("Buffers cannot be empty");return Buffer.from($.map((X,Z)=>$[Z]^U[Z]))},q=E0();k1.exports={startSession:b4,continueSession:v4,finalizeSession:y4}});var S0=H((zU,I1)=>{var r=function($){this._types=$||f4,this.text={},this.binary={}},f4=f();r.prototype.getOverrides=function($){switch($){case"text":return this.text;case"binary":return this.binary;default:return{}}};r.prototype.setTypeParser=function($,U,X){if(typeof U==="function")X=U,U="text";this.getOverrides(U)[$]=X};r.prototype.getTypeParser=function($,U){return U=U||"text",this.getOverrides(U)[$]||this._types.getTypeParser($,U)};I1.exports=r});var w1=H((RU,x1)=>{var T0=function($){if($.charAt(0)==="/"){const Q=$.split(" ");return{host:Q[0],database:Q[1]}}const U={};let X,Z=!1;if(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test($))$=encodeURI($).replace(/\%25(\d\d)/g,"%$1");try{X=new URL($,"postgres://base")}catch(Q){X=new URL($.replace("@/","@___DUMMY___/"),"postgres://base"),Z=!0}for(let Q of X.searchParams.entries())U[Q[0]]=Q[1];if(U.user=U.user||decodeURIComponent(X.username),U.password=U.password||decodeURIComponent(X.password),X.protocol=="socket:")return U.host=decodeURI(X.pathname),U.database=X.searchParams.get("db"),U.client_encoding=X.searchParams.get("encoding"),U;const J=Z?"":X.hostname;if(!U.host)U.host=decodeURIComponent(J);else if(J&&/^%2f/i.test(J))X.pathname=J+X.pathname;if(!U.port)U.port=X.port;const G=X.pathname.slice(1)||null;if(U.database=G?decodeURI(G):null,U.ssl==="true"||U.ssl==="1")U.ssl=!0;if(U.ssl==="0")U.ssl=!1;if(U.sslcert||U.sslkey||U.sslrootcert||U.sslmode)U.ssl={};const Y=U.sslcert||U.sslkey||U.sslrootcert?import.meta.require("fs"):null;if(U.sslcert)U.ssl.cert=Y.readFileSync(U.sslcert).toString();if(U.sslkey)U.ssl.key=Y.readFileSync(U.sslkey).toString();if(U.sslrootcert)U.ssl.ca=Y.readFileSync(U.sslrootcert).toString();switch(U.sslmode){case"disable":{U.ssl=!1;break}case"prefer":case"require":case"verify-ca":case"verify-full":break;case"no-verify":{U.ssl.rejectUnauthorized=!1;break}}return U};x1.exports=T0;T0.parse=T0});var P0=H((LU,y1)=>{var g4=import.meta.require("dns"),b1=g(),h1=w1().parse,A=function($,U,X){if(X===void 0)X=process.env["PG"+$.toUpperCase()];else if(X===!1);else X=process.env[X];return U[$]||X||b1[$]},c4=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 b1.ssl},x=function($){return"'"+(""+$).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},T=function($,U,X){var Z=U[X];if(Z!==void 0&&Z!==null)$.push(X+"="+x(Z))};class v1{constructor($){if($=typeof $==="string"?h1($):$||{},$.connectionString)$=Object.assign({},$,h1($.connectionString));if(this.user=A("user",$),this.database=A("database",$),this.database===void 0)this.database=this.user;if(this.port=parseInt(A("port",$),10),this.host=A("host",$),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:A("password",$)}),this.binary=A("binary",$),this.options=A("options",$),this.ssl=typeof $.ssl==="undefined"?c4():$.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=A("client_encoding",$),this.replication=A("replication",$),this.isDomainSocket=!(this.host||"").indexOf("/"),this.application_name=A("application_name",$,"PGAPPNAME"),this.fallback_application_name=A("fallback_application_name",$,!1),this.statement_timeout=A("statement_timeout",$,!1),this.lock_timeout=A("lock_timeout",$,!1),this.idle_in_transaction_session_timeout=A("idle_in_transaction_session_timeout",$,!1),this.query_timeout=A("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($){var U=[];T(U,this,"user"),T(U,this,"password"),T(U,this,"port"),T(U,this,"application_name"),T(U,this,"fallback_application_name"),T(U,this,"connect_timeout"),T(U,this,"options");var X=typeof this.ssl==="object"?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(T(U,X,"sslmode"),T(U,X,"sslca"),T(U,X,"sslkey"),T(U,X,"sslcert"),T(U,X,"sslrootcert"),this.database)U.push("dbname="+x(this.database));if(this.replication)U.push("replication="+x(this.replication));if(this.host)U.push("host="+x(this.host));if(this.isDomainSocket)return $(null,U.join(" "));if(this.client_encoding)U.push("client_encoding="+x(this.client_encoding));g4.lookup(this.host,function(Z,J){if(Z)return $(Z,null);return U.push("hostaddr="+x(J)),$(null,U.join(" "))})}}y1.exports=v1});var u1=H((FU,p1)=>{var l4=f(),d1=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/;class m1{constructor($,U){if(this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0,this._types=U,this.RowCtor=null,this.rowAsArray=$==="array",this.rowAsArray)this.parseRow=this._parseRowAsArray;this._prebuiltEmptyResultObject=null}addCommandComplete($){var U;if($.text)U=d1.exec($.text);else U=d1.exec($.command);if(U){if(this.command=U[1],U[3])this.oid=parseInt(U[2],10),this.rowCount=parseInt(U[3],10);else if(U[2])this.rowCount=parseInt(U[2],10)}}_parseRowAsArray($){var U=new Array($.length);for(var X=0,Z=$.length;X<Z;X++){var J=$[X];if(J!==null)U[X]=this._parsers[X](J);else U[X]=null}return U}parseRow($){var U={...this._prebuiltEmptyResultObject};for(var X=0,Z=$.length;X<Z;X++){var J=$[X],G=this.fields[X].name;if(J!==null)U[G]=this._parsers[X](J)}return U}addRow($){this.rows.push($)}addFields($){if(this.fields=$,this.fields.length)this._parsers=new Array($.length);for(var U=0;U<$.length;U++){var X=$[U];if(this._types)this._parsers[U]=this._types.getTypeParser(X.dataTypeID,X.format||"text");else this._parsers[U]=l4.getTypeParser(X.dataTypeID,X.format||"text")}this._createPrebuiltEmptyResultObject()}_createPrebuiltEmptyResultObject(){var $={};for(var U=0;U<this.fields.length;U++)$[this.fields[U].name]=null;this._prebuiltEmptyResultObject={...$}}}p1.exports=m1});var o1=H((MU,l1)=>{var{EventEmitter:o4}=import.meta.require("events"),f1=u1(),g1=c();class c1 extends o4{constructor($,U,X){super();if($=g1.normalizeQueryConfig($,U,X),this.text=$.text,this.values=$.values,this.rows=$.rows,this.types=$.types,this.name=$.name,this.binary=$.binary,this.portal=$.portal||"",this.callback=$.callback,this._rowMode=$.rowMode,process.domain&&$.callback)this.callback=process.domain.bind($.callback);this._result=new f1(this._rowMode,this.types),this._results=this._result,this.isPreparedStatement=!1,this._canceledDueToError=!1,this._promise=null}requiresPreparation(){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 f1(this._rowMode,this.types),this._results.push(this._result)}}handleRowDescription($){this._checkForMultirow(),this._result.addFields($.fields),this._accumulateRows=this.callback||!this.listeners("row").length}handleDataRow($){let U;if(this._canceledDueToError)return;try{U=this._result.parseRow($.fields)}catch(X){this._canceledDueToError=X;return}if(this.emit("row",U,this._result),this._accumulateRows)this._result.addRow(U)}handleCommandComplete($,U){if(this._checkForMultirow(),this._result.addCommandComplete($),this.rows)U.sync()}handleEmptyQuery($){if(this.rows)$.sync()}handleError($,U){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(U){process.nextTick(()=>{throw U})}this.emit("end",this._results)}submit($){if(typeof this.text!=="string"&&typeof this.name!=="string")return new Error("A query must have either text or a name. Supplying neither is unsupported.");const U=$.parsedStatements[this.name];if(this.text&&U&&this.text!==U)return new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);if(this.values&&!Array.isArray(this.values))return new Error("Query values must be an array");if(this.requiresPreparation())this.prepare($);else $.query(this.text);return null}hasBeenParsed($){return this.name&&$.parsedStatements[this.name]}handlePortalSuspended($){this._getRows($,this.rows)}_getRows($,U){if($.execute({portal:this.portal,rows:U}),!U)$.sync();else $.flush()}prepare($){if(this.isPreparedStatement=!0,!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:g1.prepareValue})}catch(U){this.handleError(U,$);return}$.describe({type:"P",name:this.portal||""}),this._getRows($,this.rows)}handleCopyInResponse($){$.sendCopyFail("No source stream defined")}handleCopyData($,U){}}l1.exports=c1});var C0=H((Q8)=>{Object.defineProperty(Q8,"__esModule",{value:!0});Q8.NoticeMessage=Q8.DataRowMessage=Q8.CommandCompleteMessage=Q8.ReadyForQueryMessage=Q8.NotificationResponseMessage=Q8.BackendKeyDataMessage=Q8.AuthenticationMD5Password=Q8.ParameterStatusMessage=Q8.ParameterDescriptionMessage=Q8.RowDescriptionMessage=Q8.Field=Q8.CopyResponse=Q8.CopyDataMessage=Q8.DatabaseError=Q8.copyDone=Q8.emptyQuery=Q8.replicationStart=Q8.portalSuspended=Q8.noData=Q8.closeComplete=Q8.bindComplete=Q8.parseComplete=void 0;Q8.parseComplete={name:"parseComplete",length:5};Q8.bindComplete={name:"bindComplete",length:5};Q8.closeComplete={name:"closeComplete",length:5};Q8.noData={name:"noData",length:5};Q8.portalSuspended={name:"portalSuspended",length:5};Q8.replicationStart={name:"replicationStart",length:4};Q8.emptyQuery={name:"emptyQuery",length:4};Q8.copyDone={name:"copyDone",length:4};class n1 extends Error{constructor($,U,X){super($);this.length=U,this.name=X}}Q8.DatabaseError=n1;class i1{constructor($,U){this.length=$,this.chunk=U,this.name="copyData"}}Q8.CopyDataMessage=i1;class a1{constructor($,U,X,Z){this.length=$,this.name=U,this.binary=X,this.columnTypes=new Array(Z)}}Q8.CopyResponse=a1;class t1{constructor($,U,X,Z,J,G,Y){this.name=$,this.tableID=U,this.columnID=X,this.dataTypeID=Z,this.dataTypeSize=J,this.dataTypeModifier=G,this.format=Y}}Q8.Field=t1;class s1{constructor($,U){this.length=$,this.fieldCount=U,this.name="rowDescription",this.fields=new Array(this.fieldCount)}}Q8.RowDescriptionMessage=s1;class r1{constructor($,U){this.length=$,this.parameterCount=U,this.name="parameterDescription",this.dataTypeIDs=new Array(this.parameterCount)}}Q8.ParameterDescriptionMessage=r1;class e1{constructor($,U,X){this.length=$,this.parameterName=U,this.parameterValue=X,this.name="parameterStatus"}}Q8.ParameterStatusMessage=e1;class $8{constructor($,U){this.length=$,this.salt=U,this.name="authenticationMD5Password"}}Q8.AuthenticationMD5Password=$8;class U8{constructor($,U,X){this.length=$,this.processID=U,this.secretKey=X,this.name="backendKeyData"}}Q8.BackendKeyDataMessage=U8;class X8{constructor($,U,X,Z){this.length=$,this.processId=U,this.channel=X,this.payload=Z,this.name="notification"}}Q8.NotificationResponseMessage=X8;class Z8{constructor($,U){this.length=$,this.status=U,this.name="readyForQuery"}}Q8.ReadyForQueryMessage=Z8;class J8{constructor($,U){this.length=$,this.text=U,this.name="commandComplete"}}Q8.CommandCompleteMessage=J8;class G8{constructor($,U){this.length=$,this.fields=U,this.name="dataRow",this.fieldCount=U.length}}Q8.DataRowMessage=G8;class Y8{constructor($,U){this.length=$,this.message=U,this.name="notice"}}Q8.NoticeMessage=Y8});var O8=H((K8)=>{Object.defineProperty(K8,"__esModule",{value:!0});K8.Writer=void 0;class W8{constructor($=256){this.size=$,this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe($)}ensure($){var U=this.buffer.length-this.offset;if(U<$){var X=this.buffer,Z=X.length+(X.length>>1)+$;this.buffer=Buffer.allocUnsafe(Z),X.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{var U=Buffer.byteLength($);this.ensure(U+1),this.buffer.write($,this.offset,"utf-8"),this.offset+=U}return this.buffer[this.offset++]=0,this}addString($=""){var U=Buffer.byteLength($);return this.ensure(U),this.buffer.write($,this.offset),this.offset+=U,this}add($){return this.ensure($.length),$.copy(this.buffer,this.offset),this.offset+=$.length,this}join($){if($){this.buffer[this.headerPosition]=$;const U=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(U,this.headerPosition+1)}return this.buffer.slice($?0:5,this.offset)}flush($){var U=this.join($);return this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(this.size),U}}K8.Writer=W8});var L8=H((z8)=>{Object.defineProperty(z8,"__esModule",{value:!0});z8.serialize=void 0;var q0=O8(),R=new q0.Writer,z5=($)=>{R.addInt16(3).addInt16(0);for(let Z of Object.keys($))R.addCString(Z).addCString($[Z]);R.addCString("client_encoding").addCString("UTF8");var U=R.addCString("").flush(),X=U.length+4;return new q0.Writer().addInt32(X).add(U).flush()},R5=()=>{const $=Buffer.allocUnsafe(8);return $.writeInt32BE(8,0),$.writeInt32BE(80877103,4),$},L5=($)=>{return R.addCString($).flush(112)},F5=function($,U){return R.addCString($).addInt32(Buffer.byteLength(U)).addString(U),R.flush(112)},M5=function($){return R.addString($).flush(112)},A5=($)=>{return R.addCString($).flush(81)},_8=[],N5=($)=>{const U=$.name||"";if(U.length>63)console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",U,U.length),console.error("This can cause conflicts and silent errors executing queries");const X=$.types||_8;var Z=X.length,J=R.addCString(U).addCString($.text).addInt16(Z);for(var G=0;G<Z;G++)J.addInt32(X[G]);return R.flush(80)},w=new q0.Writer,V5=function($,U){for(let X=0;X<$.length;X++){const Z=U?U($[X],X):$[X];if(Z==null)R.addInt16(0),w.addInt32(-1);else if(Z instanceof Buffer)R.addInt16(1),w.addInt32(Z.length),w.add(Z);else R.addInt16(0),w.addInt32(Buffer.byteLength(Z)),w.addString(Z)}},E5=($={})=>{const U=$.portal||"",X=$.statement||"",Z=$.binary||!1,J=$.values||_8,G=J.length;return R.addCString(U).addCString(X),R.addInt16(G),V5(J,$.valueMapper),R.addInt16(G),R.add(w.flush()),R.addInt16(Z?1:0),R.flush(66)},S5=Buffer.from([69,0,0,0,9,0,0,0,0,0]),T5=($)=>{if(!$||!$.portal&&!$.rows)return S5;const U=$.portal||"",X=$.rows||0,Z=Buffer.byteLength(U),J=4+Z+1+4,G=Buffer.allocUnsafe(1+J);return G[0]=69,G.writeInt32BE(J,1),G.write(U,5,"utf-8"),G[Z+5]=0,G.writeUInt32BE(X,G.length-4),G},P5=($,U)=>{const X=Buffer.allocUnsafe(16);return X.writeInt32BE(16,0),X.writeInt16BE(1234,4),X.writeInt16BE(5678,6),X.writeInt32BE($,8),X.writeInt32BE(U,12),X},D0=($,U)=>{const Z=4+Buffer.byteLength(U)+1,J=Buffer.allocUnsafe(1+Z);return J[0]=$,J.writeInt32BE(Z,1),J.write(U,5,"utf-8"),J[Z]=0,J},C5=R.addCString("P").flush(68),q5=R.addCString("S").flush(68),D5=($)=>{return $.name?D0(68,`${$.type}${$.name||""}`):$.type==="P"?C5:q5},k5=($)=>{const U=`${$.type}${$.name||""}`;return D0(67,U)},B5=($)=>{return R.add($).flush(100)},I5=($)=>{return D0(102,$)},e=($)=>Buffer.from([$,0,0,0,4]),x5=e(72),w5=e(83),h5=e(88),b5=e(99),v5={startup:z5,password:L5,requestSsl:R5,sendSASLInitialResponseMessage:F5,sendSCRAMClientFinalMessage:M5,query:A5,parse:N5,bind:E5,execute:T5,describe:D5,close:k5,flush:()=>x5,sync:()=>w5,end:()=>h5,copyData:B5,copyDone:()=>b5,copyFail:I5,cancel:P5};z8.serialize=v5});var N8=H((M8)=>{Object.defineProperty(M8,"__esModule",{value:!0});M8.BufferReader=void 0;var y5=Buffer.allocUnsafe(0);class F8{constructor($=0){this.offset=$,this.buffer=y5,this.encoding="utf-8"}setBuffer($,U){this.offset=$,this.buffer=U}int16(){const $=this.buffer.readInt16BE(this.offset);return this.offset+=2,$}byte(){const $=this.buffer[this.offset];return this.offset++,$}int32(){const $=this.buffer.readInt32BE(this.offset);return this.offset+=4,$}string($){const U=this.buffer.toString(this.encoding,this.offset,this.offset+$);return this.offset+=$,U}cstring(){const $=this.offset;let U=$;while(this.buffer[U++]!==0);return this.offset=U,this.buffer.toString(this.encoding,$,U-1)}bytes($){const U=this.buffer.slice(this.offset,this.offset+$);return this.offset+=$,U}}M8.BufferReader=F8});var T8=H((h)=>{var d5=h&&h.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(h,"__esModule",{value:!0});h.Parser=void 0;var L=C0(),m5=N8(),p5=d5(import.meta.require("assert")),k0=1,u5=4,V8=k0+u5,E8=Buffer.allocUnsafe(0);class S8{constructor($){if(this.buffer=E8,this.bufferLength=0,this.bufferOffset=0,this.reader=new m5.BufferReader,($===null||$===void 0?void 0:$.mode)==="binary")throw new Error("Binary mode not supported yet");this.mode=($===null||$===void 0?void 0:$.mode)||"text"}parse($,U){this.mergeBuffer($);const X=this.bufferOffset+this.bufferLength;let Z=this.bufferOffset;while(Z+V8<=X){const J=this.buffer[Z],G=this.buffer.readUInt32BE(Z+k0),Y=k0+G;if(Y+Z<=X){const Q=this.handlePacket(Z+V8,J,G,this.buffer);U(Q),Z+=Y}else break}if(Z===X)this.buffer=E8,this.bufferLength=0,this.bufferOffset=0;else this.bufferLength=X-Z,this.bufferOffset=Z}mergeBuffer($){if(this.bufferLength>0){const U=this.bufferLength+$.byteLength;if(U+this.bufferOffset>this.buffer.byteLength){let Z;if(U<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)Z=this.buffer;else{let J=this.buffer.byteLength*2;while(U>=J)J*=2;Z=Buffer.allocUnsafe(J)}this.buffer.copy(Z,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=Z,this.bufferOffset=0}$.copy(this.buffer,this.bufferOffset+this.bufferLength),this.bufferLength=U}else this.buffer=$,this.bufferOffset=0,this.bufferLength=$.byteLength}handlePacket($,U,X,Z){switch(U){case 50:return L.bindComplete;case 49:return L.parseComplete;case 51:return L.closeComplete;case 110:return L.noData;case 115:return L.portalSuspended;case 99:return L.copyDone;case 87:return L.replicationStart;case 73:return L.emptyQuery;case 68:return this.parseDataRowMessage($,X,Z);case 67:return this.parseCommandCompleteMessage($,X,Z);case 90:return this.parseReadyForQueryMessage($,X,Z);case 65:return this.parseNotificationMessage($,X,Z);case 82:return this.parseAuthenticationResponse($,X,Z);case 83:return this.parseParameterStatusMessage($,X,Z);case 75:return this.parseBackendKeyData($,X,Z);case 69:return this.parseErrorMessage($,X,Z,"error");case 78:return this.parseErrorMessage($,X,Z,"notice");case 84:return this.parseRowDescriptionMessage($,X,Z);case 116:return this.parseParameterDescriptionMessage($,X,Z);case 71:return this.parseCopyInMessage($,X,Z);case 72:return this.parseCopyOutMessage($,X,Z);case 100:return this.parseCopyData($,X,Z);default:p5.default.fail(`unknown message code: ${U.toString(16)}`)}}parseReadyForQueryMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.string(1);return new L.ReadyForQueryMessage(U,Z)}parseCommandCompleteMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.cstring();return new L.CommandCompleteMessage(U,Z)}parseCopyData($,U,X){const Z=X.slice($,$+(U-4));return new L.CopyDataMessage(U,Z)}parseCopyInMessage($,U,X){return this.parseCopyMessage($,U,X,"copyInResponse")}parseCopyOutMessage($,U,X){return this.parseCopyMessage($,U,X,"copyOutResponse")}parseCopyMessage($,U,X,Z){this.reader.setBuffer($,X);const J=this.reader.byte()!==0,G=this.reader.int16(),Y=new L.CopyResponse(U,Z,J,G);for(let Q=0;Q<G;Q++)Y.columnTypes[Q]=this.reader.int16();return Y}parseNotificationMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J=this.reader.cstring(),G=this.reader.cstring();return new L.NotificationResponseMessage(U,Z,J,G)}parseRowDescriptionMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new L.RowDescriptionMessage(U,Z);for(let G=0;G<Z;G++)J.fields[G]=this.parseField();return J}parseField(){const $=this.reader.cstring(),U=this.reader.int32(),X=this.reader.int16(),Z=this.reader.int32(),J=this.reader.int16(),G=this.reader.int32(),Y=this.reader.int16()===0?"text":"binary";return new L.Field($,U,X,Z,J,G,Y)}parseParameterDescriptionMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new L.ParameterDescriptionMessage(U,Z);for(let G=0;G<Z;G++)J.dataTypeIDs[G]=this.reader.int32();return J}parseDataRowMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new Array(Z);for(let G=0;G<Z;G++){const Y=this.reader.int32();J[G]=Y===-1?null:this.reader.string(Y)}return new L.DataRowMessage(U,J)}parseParameterStatusMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.cstring(),J=this.reader.cstring();return new L.ParameterStatusMessage(U,Z,J)}parseBackendKeyData($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J=this.reader.int32();return new L.BackendKeyDataMessage(U,Z,J)}parseAuthenticationResponse($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J={name:"authenticationOk",length:U};switch(Z){case 0:break;case 3:if(J.length===8)J.name="authenticationCleartextPassword";break;case 5:if(J.length===12){J.name="authenticationMD5Password";const Y=this.reader.bytes(4);return new L.AuthenticationMD5Password(U,Y)}break;case 10:J.name="authenticationSASL",J.mechanisms=[];let G;do if(G=this.reader.cstring(),G)J.mechanisms.push(G);while(G);break;case 11:J.name="authenticationSASLContinue",J.data=this.reader.string(U-8);break;case 12:J.name="authenticationSASLFinal",J.data=this.reader.string(U-8);break;default:throw new Error("Unknown authenticationOk message type "+Z)}return J}parseErrorMessage($,U,X,Z){this.reader.setBuffer($,X);const J={};let G=this.reader.string(1);while(G!=="\0")J[G]=this.reader.cstring(),G=this.reader.string(1);const Y=J.M,Q=Z==="notice"?new L.NoticeMessage(U,Y):new L.DatabaseError(Y,U,Z);return Q.severity=J.S,Q.code=J.C,Q.detail=J.D,Q.hint=J.H,Q.position=J.P,Q.internalPosition=J.p,Q.internalQuery=J.q,Q.where=J.W,Q.schema=J.s,Q.table=J.t,Q.column=J.c,Q.dataType=J.d,Q.constraint=J.n,Q.file=J.F,Q.line=J.L,Q.routine=J.R,Q}}h.Parser=S8});var B0=H(($0)=>{var l5=function($,U){const X=new c5.Parser;return $.on("data",(Z)=>X.parse(Z,U)),new Promise((Z)=>$.on("end",()=>Z()))};Object.defineProperty($0,"__esModule",{value:!0});$0.DatabaseError=$0.serialize=$0.parse=void 0;var f5=C0();Object.defineProperty($0,"DatabaseError",{enumerable:!0,get:function(){return f5.DatabaseError}});var g5=L8();Object.defineProperty($0,"serialize",{enumerable:!0,get:function(){return g5.serialize}});var c5=T8();$0.parse=l5});var P8={};z$(P8,{default:()=>{{return i5}}});var i5;var C8=R$(()=>{i5={}});var q8=H((a5,I0)=>{a5.getStream=function $(U){const X=import.meta.require("net");if(typeof X.Socket==="function")return new X.Socket;else{const{CloudflareSocket:Z}=(C8(),c0(P8));return new Z(U)}};a5.getSecureStream=function $(U){var X=import.meta.require("tls");if(X.connect)return X.connect(U);else return U.socket.startTls(U),U.socket}});var x0=H((qU,k8)=>{var CU=import.meta.require("net"),r5=import.meta.require("events").EventEmitter,{parse:e5,serialize:F}=B0(),{getStream:$9,getSecureStream:U9}=q8(),X9=F.flush(),Z9=F.sync(),J9=F.end();class D8 extends r5{constructor($){super();if($=$||{},this.stream=$.stream||$9($.ssl),typeof this.stream==="function")this.stream=this.stream($);this._keepAlive=$.keepAlive,this._keepAliveInitialDelayMillis=$.keepAliveInitialDelayMillis,this.lastBuffer=!1,this.parsedStatements={},this.ssl=$.ssl||!1,this._ending=!1,this._emitMessage=!1;var U=this;this.on("newListener",function(X){if(X==="message")U._emitMessage=!0})}connect($,U){var X=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect($,U),this.stream.once("connect",function(){if(X._keepAlive)X.stream.setKeepAlive(!0,X._keepAliveInitialDelayMillis);X.emit("connect")});const Z=function(J){if(X._ending&&(J.code==="ECONNRESET"||J.code==="EPIPE"))return;X.emit("error",J)};if(this.stream.on("error",Z),this.stream.on("close",function(){X.emit("end")}),!this.ssl)return this.attachListeners(this.stream);this.stream.once("data",function(J){var G=J.toString("utf8");switch(G){case"S":break;case"N":return X.stream.end(),X.emit("error",new Error("The server does not support SSL connections"));default:return X.stream.end(),X.emit("error",new Error("There was an error establishing an SSL connection"))}const Y={socket:X.stream};if(X.ssl!==!0){if(Object.assign(Y,X.ssl),"key"in X.ssl)Y.key=X.ssl.key}var Q=import.meta.require("net");if(Q.isIP&&Q.isIP(U)===0)Y.servername=U;try{X.stream=U9(Y)}catch(j){return X.emit("error",j)}X.attachListeners(X.stream),X.stream.on("error",Z),X.emit("sslconnect")})}attachListeners($){e5($,(U)=>{var X=U.name==="error"?"errorMessage":U.name;if(this._emitMessage)this.emit("message",U);this.emit(X,U)})}requestSsl(){this.stream.write(F.requestSsl())}startup($){this.stream.write(F.startup($))}cancel($,U){this._send(F.cancel($,U))}password($){this._send(F.password($))}sendSASLInitialResponseMessage($,U){this._send(F.sendSASLInitialResponseMessage($,U))}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(X9)}sync(){this._ending=!0,this._send(Z9)}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(J9,()=>{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($))}}k8.exports=D8});var w8=H((DU,x8)=>{var Q9=function($,U,X){let Z;if(this.overflow){if(Z=this[U0].write($).split(this.matcher),Z.length===1)return X();Z.shift(),this.overflow=!1}else this[C]+=this[U0].write($),Z=this[C].split(this.matcher);this[C]=Z.pop();for(let J=0;J<Z.length;J++)try{I8(this,this.mapper(Z[J]))}catch(G){return X(G)}if(this.overflow=this[C].length>this.maxLength,this.overflow&&!this.skipOverflow){X(new Error("maximum buffer reached"));return}X()},j9=function($){if(this[C]+=this[U0].end(),this[C])try{I8(this,this.mapper(this[C]))}catch(U){return $(U)}$()},I8=function($,U){if(U!==void 0)$.push(U)},B8=function($){return $},W9=function($,U,X){switch($=$||/\r?\n/,U=U||B8,X=X||{},arguments.length){case 1:if(typeof $==="function")U=$,$=/\r?\n/;else if(typeof $==="object"&&!($ instanceof RegExp)&&!$[Symbol.split])X=$,$=/\r?\n/;break;case 2:if(typeof $==="function")X=U,U=$,$=/\r?\n/;else if(typeof U==="object")X=U,U=B8}X=Object.assign({},X),X.autoDestroy=!0,X.transform=Q9,X.flush=j9,X.readableObjectMode=!0;const Z=new G9(X);return Z[C]="",Z[U0]=new Y9("utf8"),Z.matcher=$,Z.mapper=U,Z.maxLength=X.maxLength,Z.skipOverflow=X.skipOverflow||!1,Z.overflow=!1,Z._destroy=function(J,G){this._writableState.errorEmitted=!1,G(J)},Z},{Transform:G9}=import.meta.require("stream"),{StringDecoder:Y9}=import.meta.require("string_decoder"),C=Symbol("last"),U0=Symbol("decoder");x8.exports=W9});var v8=H((E9,P)=>{var F9=function($){return($&R9)==L9},h0=function(){var $=o instanceof K9&&o.writable===!0;if($){var U=Array.prototype.slice.call(arguments).concat("\n");o.write(b8.format.apply(b8,U))}},h8=import.meta.require("path"),K9=import.meta.require("stream").Stream,H9=w8(),b8=import.meta.require("util"),O9=5432,X0=process.platform==="win32",o=process.stderr,_9=56,z9=7,R9=61440,L9=32768,b=["host","port","database","user","password"],w0=b.length,M9=b[w0-1];Object.defineProperty(E9,"isWin",{get:function(){return X0},set:function($){X0=$}});E9.warnTo=function($){var U=o;return o=$,U};E9.getFileName=function($){var U=$||process.env,X=U.PGPASSFILE||(X0?h8.join(U.APPDATA||"./","postgresql","pgpass.conf"):h8.join(U.HOME||"./",".pgpass"));return X};E9.usePgPass=function($,U){if(Object.prototype.hasOwnProperty.call(process.env,"PGPASSWORD"))return!1;if(X0)return!0;if(U=U||"<unkn>",!F9($.mode))return h0('WARNING: password file "%s" is not a plain file',U),!1;if($.mode&(_9|z9))return h0('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less',U),!1;return!0};var A9=E9.match=function($,U){return b.slice(0,-1).reduce(function(X,Z,J){if(J==1){if(Number($[Z]||O9)===Number(U[Z]))return X&&!0}return X&&(U[Z]==="*"||U[Z]===$[Z])},!0)};E9.getPassword=function($,U,X){var Z,J=U.pipe(H9());function G(j){var W=N9(j);if(W&&V9(W)&&A9($,W))Z=W[M9],J.end()}var Y=function(){U.destroy(),X(Z)},Q=function(j){U.destroy(),h0("WARNING: error on reading file: %s",j),X(void 0)};U.on("error",Q),J.on("data",G).on("end",Y).on("error",Q)};var N9=E9.parseLine=function($){if($.length<11||$.match(/^\s+#/))return null;var U="",X="",Z=0,J=0,G=0,Y={},Q=!1,j=function(K,O,_){var E=$.substring(O,_);if(!Object.hasOwnProperty.call(process.env,"PGPASS_NO_DEESCAPE"))E=E.replace(/\\([:\\])/g,"$1");Y[b[K]]=E};for(var W=0;W<$.length-1;W+=1){if(U=$.charAt(W+1),X=$.charAt(W),Q=Z==w0-1,Q){j(Z,J);break}if(W>=0&&U==":"&&X!=="\\")j(Z,J,W+1),J=W+2,Z+=1}return Y=Object.keys(Y).length===w0?Y:null,Y},V9=E9.isValidEntry=function($){var U={0:function(Y){return Y.length>0},1:function(Y){if(Y==="*")return!0;return Y=Number(Y),isFinite(Y)&&Y>0&&Y<9007199254740992&&Math.floor(Y)===Y},2:function(Y){return Y.length>0},3:function(Y){return Y.length>0},4:function(Y){return Y.length>0}};for(var X=0;X<b.length;X+=1){var Z=U[X],J=$[b[X]]||"",G=Z(J);if(!G)return!1}return!0}});var d8=H((wU,b0)=>{var xU=import.meta.require("path"),y8=import.meta.require("fs"),Z0=v8();b0.exports=function($,U){var X=Z0.getFileName();y8.stat(X,function(Z,J){if(Z||!Z0.usePgPass(J,X))return U(void 0);var G=y8.createReadStream(X);Z0.getPassword($,G,U)})};b0.exports.warnTo=Z0.warnTo});var f8=H((hU,u8)=>{var q9=import.meta.require("events").EventEmitter,m8=c(),v0=B1(),D9=S0(),k9=P0(),p8=o1(),B9=g(),I9=x0(),x9=E0();class y0 extends q9{constructor($){super();this.connectionParameters=new k9($),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;var U=$||{};if(this._Promise=U.Promise||global.Promise,this._types=new D9(U.types),this._ending=!1,this._ended=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this.connection=U.connection||new I9({stream:U.stream,ssl:this.connectionParameters.ssl,keepAlive:U.keepAlive||!1,keepAliveInitialDelayMillis:U.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||"utf8"}),this.queryQueue=[],this.binary=U.binary||B9.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=U.connectionTimeoutMillis||0}_errorAllQueries($){const U=(X)=>{process.nextTick(()=>{X.handleError($,this.connection)})};if(this.activeQuery)U(this.activeQuery),this.activeQuery=null;this.queryQueue.forEach(U),this.queryQueue.length=0}_connect($){var U=this,X=this.connection;if(this._connectionCallback=$,this._connecting||this._connected){const Z=new Error("Client has already been connected. You cannot reuse a client.");process.nextTick(()=>{$(Z)});return}if(this._connecting=!0,this.connectionTimeoutHandle,this._connectionTimeoutMillis>0)this.connectionTimeoutHandle=setTimeout(()=>{X._ending=!0,X.stream.destroy(new Error("timeout expired"))},this._connectionTimeoutMillis);if(this.host&&this.host.indexOf("/")===0)X.connect(this.host+"/.s.PGSQL."+this.port);else X.connect(this.port,this.host);X.on("connect",function(){if(U.ssl)X.requestSsl();else X.startup(U.getStartupConf())}),X.on("sslconnect",function(){X.startup(U.getStartupConf())}),this._attachListeners(X),X.once("end",()=>{const Z=this._ending?new Error("Connection terminated"):new Error("Connection terminated unexpectedly");if(clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(Z),this._ended=!0,!this._ending){if(this._connecting&&!this._connectionError)if(this._connectionCallback)this._connectionCallback(Z);else this._handleErrorEvent(Z);else if(!this._connectionError)this._handleErrorEvent(Z)}process.nextTick(()=>{this.emit("end")})})}connect($){if($){this._connect($);return}return new this._Promise((U,X)=>{this._connect((Z)=>{if(Z)X(Z);else U()})})}_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))}_checkPgPass($){const U=this.connection;if(typeof this.password==="function")this._Promise.resolve().then(()=>this.password()).then((X)=>{if(X!==void 0){if(typeof X!=="string"){U.emit("error",new TypeError("Password must be a string"));return}this.connectionParameters.password=this.password=X}else this.connectionParameters.password=this.password=null;$()}).catch((X)=>{U.emit("error",X)});else if(this.password!==null)$();else try{d8()(this.connectionParameters,(Z)=>{if(Z!==void 0)this.connectionParameters.password=this.password=Z;$()})}catch(X){this.emit("error",X)}}_handleAuthCleartextPassword($){this._checkPgPass(()=>{this.connection.password(this.password)})}_handleAuthMD5Password($){this._checkPgPass(async()=>{try{const U=await x9.postgresMd5PasswordHash(this.user,this.password,$.salt);this.connection.password(U)}catch(U){this.emit("error",U)}})}_handleAuthSASL($){this._checkPgPass(()=>{try{this.saslSession=v0.startSession($.mechanisms),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)}catch(U){this.connection.emit("error",U)}})}async _handleAuthSASLContinue($){try{await v0.continueSession(this.saslSession,this.password,$.data),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}catch(U){this.connection.emit("error",U)}}_handleAuthSASLFinal($){try{v0.finalizeSession(this.saslSession,$.data),this.saslSession=null}catch(U){this.connection.emit("error",U)}}_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")}const{activeQuery:U}=this;if(this.activeQuery=null,this.readyForQuery=!0,U)U.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($);const U=this.activeQuery;if(!U){this._handleErrorEvent($);return}this.activeQuery=null,U.handleError($,this.connection)}_handleRowDescription($){this.activeQuery.handleRowDescription($)}_handleDataRow($){this.activeQuery.handleDataRow($)}_handlePortalSuspended($){this.activeQuery.handlePortalSuspended(this.connection)}_handleEmptyQuery($){this.activeQuery.handleEmptyQuery(this.connection)}_handleCommandComplete($){this.activeQuery.handleCommandComplete($,this.connection)}_handleParseComplete($){if(this.activeQuery.name)this.connection.parsedStatements[this.activeQuery.name]=this.activeQuery.text}_handleCopyInResponse($){this.activeQuery.handleCopyInResponse(this.connection)}_handleCopyData($){this.activeQuery.handleCopyData($,this.connection)}_handleNotification($){this.emit("notification",$)}_handleNotice($){this.emit("notice",$)}getStartupConf(){var $=this.connectionParameters,U={user:$.user,database:$.database},X=$.application_name||$.fallback_application_name;if(X)U.application_name=X;if($.replication)U.replication=""+$.replication;if($.statement_timeout)U.statement_timeout=String(parseInt($.statement_timeout,10));if($.lock_timeout)U.lock_timeout=String(parseInt($.lock_timeout,10));if($.idle_in_transaction_session_timeout)U.idle_in_transaction_session_timeout=String(parseInt($.idle_in_transaction_session_timeout,10));if($.options)U.options=$.options;return U}cancel($,U){if($.activeQuery===U){var X=this.connection;if(this.host&&this.host.indexOf("/")===0)X.connect(this.host+"/.s.PGSQL."+this.port);else X.connect(this.port,this.host);X.on("connect",function(){X.cancel($.processID,$.secretKey)})}else if($.queryQueue.indexOf(U)!==-1)$.queryQueue.splice($.queryQueue.indexOf(U),1)}setTypeParser($,U,X){return this._types.setTypeParser($,U,X)}getTypeParser($,U){return this._types.getTypeParser($,U)}escapeIdentifier($){return m8.escapeIdentifier($)}escapeLiteral($){return m8.escapeLiteral($)}_pulseQueryQueue(){if(this.readyForQuery===!0){if(this.activeQuery=this.queryQueue.shift(),this.activeQuery){this.readyForQuery=!1,this.hasExecuted=!0;const $=this.activeQuery.submit(this.connection);if($)process.nextTick(()=>{this.activeQuery.handleError($,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else if(this.hasExecuted)this.activeQuery=null,this.emit("drain")}}query($,U,X){var Z,J,G,Y,Q;if($===null||$===void 0)throw new TypeError("Client was passed a null or undefined query");else if(typeof $.submit==="function"){if(G=$.query_timeout||this.connectionParameters.query_timeout,J=Z=$,typeof U==="function")Z.callback=Z.callback||U}else if(G=this.connectionParameters.query_timeout,Z=new p8($,U,X),!Z.callback)J=new this._Promise((j,W)=>{Z.callback=(K,O)=>K?W(K):j(O)}).catch((j)=>{throw Error.captureStackTrace(j),j});if(G)Q=Z.callback,Y=setTimeout(()=>{var j=new Error("Query read timeout");process.nextTick(()=>{Z.handleError(j,this.connection)}),Q(j),Z.callback=()=>{};var W=this.queryQueue.indexOf(Z);if(W>-1)this.queryQueue.splice(W,1);this._pulseQueryQueue()},G),Z.callback=(j,W)=>{clearTimeout(Y),Q(j,W)};if(this.binary&&!Z.binary)Z.binary=!0;if(Z._result&&!Z._result._types)Z._result._types=this._types;if(!this._queryable)return process.nextTick(()=>{Z.handleError(new Error("Client has encountered a connection error and is not queryable"),this.connection)}),J;if(this._ending)return process.nextTick(()=>{Z.handleError(new Error("Client was closed and is not queryable"),this.connection)}),J;return this.queryQueue.push(Z),this._pulseQueryQueue(),J}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.activeQuery||!this._queryable)this.connection.stream.destroy();else this.connection.end();if($)this.connection.once("end",$);else return new this._Promise((U)=>{this.connection.once("end",U)})}}y0.Query=p8;u8.exports=y0});var i8=H((bU,n8)=>{var h9=function(){throw new Error("Release called on client which has already been released to the pool.")},J0=function($,U){if(U)return{callback:U,result:void 0};let X,Z;const J=function(Y,Q){Y?X(Y):Z(Q)},G=new $(function(Y,Q){Z=Y,X=Q}).catch((Y)=>{throw Error.captureStackTrace(Y),Y});return{callback:J,result:G}},b9=function($,U){return function X(Z){Z.client=U,U.removeListener("error",X),U.on("error",()=>{$.log("additional client error after disconnection due to error",Z)}),$._remove(U),$.emit("error",Z,U)}},w9=import.meta.require("events").EventEmitter,g8=function(){},c8=($,U)=>{const X=$.findIndex(U);return X===-1?void 0:$.splice(X,1)[0]};class l8{constructor($,U,X){this.client=$,this.idleListener=U,this.timeoutId=X}}class n{constructor($){this.callback=$}}class o8 extends w9{constructor($,U){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.maxUses=this.options.maxUses||Infinity,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||U||d0().Client,this.Promise=this.options.Promise||global.Promise,typeof this.options.idleTimeoutMillis==="undefined")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}_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((U)=>{this._remove(U.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;const $=this._pendingQueue.shift();if(this._idle.length){const U=this._idle.pop();clearTimeout(U.timeoutId);const X=U.client;X.ref&&X.ref();const Z=U.idleListener;return this._acquireClient(X,$,Z,!1)}if(!this._isFull())return this.newClient($);throw new Error("unexpected condition")}_remove($){const U=c8(this._idle,(X)=>X.client===$);if(U!==void 0)clearTimeout(U.timeoutId);this._clients=this._clients.filter((X)=>X!==$),$.end(),this.emit("remove",$)}connect($){if(this.ending){const Z=new Error("Cannot use a pool after calling end on the pool");return $?$(Z):this.Promise.reject(Z)}const U=J0(this.Promise,$),X=U.result;if(this._isFull()||this._idle.length){if(this._idle.length)process.nextTick(()=>this._pulseQueue());if(!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new n(U.callback)),X;const Z=(Y,Q,j)=>{clearTimeout(G),U.callback(Y,Q,j)},J=new n(Z),G=setTimeout(()=>{c8(this._pendingQueue,(Y)=>Y.callback===Z),J.timedOut=!0,U.callback(new Error("timeout exceeded when trying to connect"))},this.options.connectionTimeoutMillis);return this._pendingQueue.push(J),X}return this.newClient(new n(U.callback)),X}newClient($){const U=new this.Client(this.options);this._clients.push(U);const X=b9(this,U);this.log("checking client timeout");let Z,J=!1;if(this.options.connectionTimeoutMillis)Z=setTimeout(()=>{this.log("ending client due to timeout"),J=!0,U.connection?U.connection.stream.destroy():U.end()},this.options.connectionTimeoutMillis);this.log("connecting new client"),U.connect((G)=>{if(Z)clearTimeout(Z);if(U.on("error",X),G){if(this.log("client failed to connect",G),this._clients=this._clients.filter((Y)=>Y!==U),J)G.message="Connection terminated due to connection timeout";if(this._pulseQueue(),!$.timedOut)$.callback(G,void 0,g8)}else{if(this.log("new client connected"),this.options.maxLifetimeSeconds!==0){const Y=setTimeout(()=>{if(this.log("ending client due to expired lifetime"),this._expired.add(U),this._idle.findIndex((j)=>j.client===U)!==-1)this._acquireClient(U,new n((j,W,K)=>K()),X,!1)},this.options.maxLifetimeSeconds*1000);Y.unref(),U.once("end",()=>clearTimeout(Y))}return this._acquireClient(U,$,X,!0)}})}_acquireClient($,U,X,Z){if(Z)this.emit("connect",$);if(this.emit("acquire",$),$.release=this._releaseOnce($,X),$.removeListener("error",X),!U.timedOut)if(Z&&this.options.verify)this.options.verify($,(J)=>{if(J)return $.release(J),U.callback(J,void 0,g8);U.callback(void 0,$,$.release)});else U.callback(void 0,$,$.release);else if(Z&&this.options.verify)this.options.verify($,$.release);else $.release()}_releaseOnce($,U){let X=!1;return(Z)=>{if(X)h9();X=!0,this._release($,U,Z)}}_release($,U,X){if($.on("error",U),$._poolUseCount=($._poolUseCount||0)+1,this.emit("release",X,$),X||this.ending||!$._queryable||$._ending||$._poolUseCount>=this.options.maxUses){if($._poolUseCount>=this.options.maxUses)this.log("remove expended client");this._remove($),this._pulseQueue();return}if(this._expired.has($)){this.log("remove expired client"),this._expired.delete($),this._remove($),this._pulseQueue();return}let J;if(this.options.idleTimeoutMillis){if(J=setTimeout(()=>{this.log("remove idle client"),this._remove($)},this.options.idleTimeoutMillis),this.options.allowExitOnIdle)J.unref()}if(this.options.allowExitOnIdle)$.unref();this._idle.push(new l8($,U,J)),this._pulseQueue()}query($,U,X){if(typeof $==="function"){const J=J0(this.Promise,$);return setImmediate(function(){return J.callback(new Error("Passing a function as the first parameter to pool.query is not supported"))}),J.result}if(typeof U==="function")X=U,U=void 0;const Z=J0(this.Promise,X);return X=Z.callback,this.connect((J,G)=>{if(J)return X(J);let Y=!1;const Q=(j)=>{if(Y)return;Y=!0,G.release(j),X(j)};G.once("error",Q),this.log("dispatching query");try{G.query($,U,(j,W)=>{if(this.log("query dispatched"),G.removeListener("error",Q),Y)return;if(Y=!0,G.release(j),j)return X(j);return X(void 0,W)})}catch(j){return G.release(j),X(j)}}),Z.result}end($){if(this.log("ending"),this.ending){const X=new Error("Called end on pool more than once");return $?$(X):this.Promise.reject(X)}this.ending=!0;const U=J0(this.Promise,$);return this._endCallback=U.callback,this._pulseQueue(),U.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce(($,U)=>$+(this._expired.has(U)?1:0),0)}get totalCount(){return this._clients.length}}n8.exports=o8});var s8=H((vU,t8)=>{var a8=import.meta.require("events").EventEmitter,v9=import.meta.require("util"),m0=c(),v=t8.exports=function($,U,X){a8.call(this),$=m0.normalizeQueryConfig($,U,X),this.text=$.text,this.values=$.values,this.name=$.name,this.callback=$.callback,this.state="new",this._arrayMode=$.rowMode==="array",this._emitRowEvents=!1,this.on("newListener",function(Z){if(Z==="row")this._emitRowEvents=!0}.bind(this))};v9.inherits(v,a8);var y9={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"file",sourceLine:"line",sourceFunction:"routine"};v.prototype.handleError=function($){var U=this.native.pq.resultErrorFields();if(U)for(var X in U){var Z=y9[X]||X;$[Z]=U[X]}if(this.callback)this.callback($);else this.emit("error",$);this.state="error"};v.prototype.then=function($,U){return this._getPromise().then($,U)};v.prototype.catch=function($){return this._getPromise().catch($)};v.prototype._getPromise=function(){if(this._promise)return this._promise;return this._promise=new Promise(function($,U){this._once("end",$),this._once("error",U)}.bind(this)),this._promise};v.prototype.submit=function($){this.state="running";var U=this;this.native=$.native,$.native.arrayMode=this._arrayMode;var X=function(G,Y,Q){if($.native.arrayMode=!1,setImmediate(function(){U.emit("_done")}),G)return U.handleError(G);if(U._emitRowEvents)if(Q.length>1)Y.forEach((j,W)=>{j.forEach((K)=>{U.emit("row",K,Q[W])})});else Y.forEach(function(j){U.emit("row",j,Q)});if(U.state="end",U.emit("end",Q),U.callback)U.callback(null,Q)};if(process.domain)X=process.domain.bind(X);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");var Z=(this.values||[]).map(m0.prepareValue);if($.namedQueries[this.name]){if(this.text&&$.namedQueries[this.name]!==this.text){const G=new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return X(G)}return $.native.execute(this.name,Z,X)}return $.native.prepare(this.name,this.text,Z.length,function(G){if(G)return X(G);return $.namedQueries[U.name]=U.text,U.native.execute(U.name,Z,X)})}else if(this.values){if(!Array.isArray(this.values)){const G=new Error("Query values must be an array");return X(G)}var J=this.values.map(m0.prepareValue);$.native.query(this.text,J,X)}else $.native.query(this.text,X)}});var p0=H((yU,U$)=>{var r8;try{r8=(()=>{throw new Error(`Cannot require module "pg-native"`);})()}catch($){throw $}var d9=S0(),e8=import.meta.require("events").EventEmitter,m9=import.meta.require("util"),p9=P0(),$$=s8(),V=U$.exports=function($){e8.call(this),$=$||{},this._Promise=$.Promise||global.Promise,this._types=new d9($.types),this.native=new r8({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;var U=this.connectionParameters=new p9($);if($.nativeConnectionString)U.nativeConnectionString=$.nativeConnectionString;this.user=U.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:U.password}),this.database=U.database,this.host=U.host,this.port=U.port,this.namedQueries={}};V.Query=$$;m9.inherits(V,e8);V.prototype._errorAllQueries=function($){const U=(X)=>{process.nextTick(()=>{X.native=this.native,X.handleError($)})};if(this._hasActiveQuery())U(this._activeQuery),this._activeQuery=null;this._queryQueue.forEach(U),this._queryQueue.length=0};V.prototype._connect=function($){var U=this;if(this._connecting){process.nextTick(()=>$(new Error("Client has already been connected. You cannot reuse a client.")));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(X,Z){if(U.connectionParameters.nativeConnectionString)Z=U.connectionParameters.nativeConnectionString;if(X)return $(X);U.native.connect(Z,function(J){if(J)return U.native.end(),$(J);U._connected=!0,U.native.on("error",function(G){U._queryable=!1,U._errorAllQueries(G),U.emit("error",G)}),U.native.on("notification",function(G){U.emit("notification",{channel:G.relname,payload:G.extra})}),U.emit("connect"),U._pulseQueryQueue(!0),$()})})};V.prototype.connect=function($){if($){this._connect($);return}return new this._Promise((U,X)=>{this._connect((Z)=>{if(Z)X(Z);else U()})})};V.prototype.query=function($,U,X){var Z,J,G,Y,Q;if($===null||$===void 0)throw new TypeError("Client was passed a null or undefined query");else if(typeof $.submit==="function"){if(G=$.query_timeout||this.connectionParameters.query_timeout,J=Z=$,typeof U==="function")$.callback=U}else if(G=this.connectionParameters.query_timeout,Z=new $$($,U,X),!Z.callback){let j,W;J=new this._Promise((K,O)=>{j=K,W=O}).catch((K)=>{throw Error.captureStackTrace(K),K}),Z.callback=(K,O)=>K?W(K):j(O)}if(G)Q=Z.callback,Y=setTimeout(()=>{var j=new Error("Query read timeout");process.nextTick(()=>{Z.handleError(j,this.connection)}),Q(j),Z.callback=()=>{};var W=this._queryQueue.indexOf(Z);if(W>-1)this._queryQueue.splice(W,1);this._pulseQueryQueue()},G),Z.callback=(j,W)=>{clearTimeout(Y),Q(j,W)};if(!this._queryable)return Z.native=this.native,process.nextTick(()=>{Z.handleError(new Error("Client has encountered a connection error and is not queryable"))}),J;if(this._ending)return Z.native=this.native,process.nextTick(()=>{Z.handleError(new Error("Client was closed and is not queryable"))}),J;return this._queryQueue.push(Z),this._pulseQueryQueue(),J};V.prototype.end=function($){var U=this;if(this._ending=!0,!this._connected)this.once("connect",this.end.bind(this,$));var X;if(!$)X=new this._Promise(function(Z,J){$=(G)=>G?J(G):Z()});return this.native.end(function(){U._errorAllQueries(new Error("Connection terminated")),process.nextTick(()=>{if(U.emit("end"),$)$()})}),X};V.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!=="error"&&this._activeQuery.state!=="end"};V.prototype._pulseQueryQueue=function($){if(!this._connected)return;if(this._hasActiveQuery())return;var U=this._queryQueue.shift();if(!U){if(!$)this.emit("drain");return}this._activeQuery=U,U.submit(this);var X=this;U.once("_done",function(){X._pulseQueryQueue()})};V.prototype.cancel=function($){if(this._activeQuery===$)this.native.cancel(function(){});else if(this._queryQueue.indexOf($)!==-1)this._queryQueue.splice(this._queryQueue.indexOf($),1)};V.prototype.ref=function(){};V.prototype.unref=function(){};V.prototype.setTypeParser=function($,U,X){return this._types.setTypeParser($,U,X)};V.prototype.getTypeParser=function($,U){return this._types.getTypeParser($,U)}});var d0=H((dU,i)=>{var u9=f8(),f9=g(),g9=x0(),c9=i8(),{DatabaseError:l9}=B0(),{escapeIdentifier:o9,escapeLiteral:n9}=c(),i9=($)=>{return class U extends c9{constructor(X){super(X,$)}}},u0=function($){this.defaults=f9,this.Client=$,this.Query=this.Client.Query,this.Pool=i9(this.Client),this._pools=[],this.Connection=g9,this.types=f(),this.DatabaseError=l9,this.escapeIdentifier=o9,this.escapeLiteral=n9};if(typeof process.env.NODE_PG_FORCE_NATIVE!=="undefined")i.exports=new u0(p0());else i.exports=new u0(u9),Object.defineProperty(i.exports,"native",{configurable:!0,enumerable:!1,get(){var $=null;try{$=new u0(p0())}catch(U){if(U.code!=="MODULE_NOT_FOUND")throw U}return Object.defineProperty(i.exports,"native",{value:$}),$}})});var X$=_$(d0(),1),D=new X$.Pool({host:"0.0.0.0",port:5432,user:"postgres",password:"123",database:"rinha"});function Z$($,U){if(typeof $!=="number"||$<1)U.status=422;return U}function J$($,U,X){if(typeof $!=="number"||$<1)X.status=422;if(!U.valor||typeof U.valor!=="number"||U.valor<1||!Number.isInteger(U.valor))X.status=422;if(!U.tipo||typeof U.tipo!=="string"||!["c","d"].includes(U.tipo))X.status=422;if(!U.descricao||typeof U.descricao!=="string"||U.descricao.length<1||U.descricao.length>10)X.status=422;return X}async function G$($,U){if(Z$($,U).status!==200)return;const Z=(await D.query("SELECT * FROM customers WHERE id = $1",[$])).rows[0];if(!Z){U.status=404;return}const J=(await D.query("SELECT * FROM transacoes WHERE customerId = $1 ORDER BY realizada_em DESC LIMIT 10",[$])).rows;return{saldo:{total:Z.saldo,data_extrato:(new Date()).toISOString(),limite:Z.limite},ultimas_transacoes:J}}async function Y$($,U,X){if(J$($,U,X).status!==200)return;const J=(await D.query("SELECT * FROM customers WHERE id = $1",[$])).rows[0];if(!J){X.status=404;return}let G=0;if(U.tipo==="d"){const Y=await D.query("SELECT * FROM debit ($1, $2, $3)",[$,U.valor,U.descricao]),{saldofinal:Q,error:j}=Y.rows[0];if(j)return X.status=422,"saldo insuficente";G=Q}if(U.tipo==="c")G=(await D.query("SELECT * FROM credit ($1, $2, $3)",[$,U.valor,U.descricao])).rows[0].saldofinal;return{limite:J.limite,saldo:G}}var Q$=new RegExp(/clientes\/(\d+)\/extrato/),j$=new RegExp(/clientes\/(\d+)\/transacoes/),a9=async($)=>{const U=new URL($.url),X={status:200};if($.method==="GET"&&Q$.test(U.pathname)){const Z=+Q$.exec(U.pathname)[1],J=await G$(Z,X);return{status:X.status,body:J}}if($.method==="POST"&&j$.test(U.pathname)){const Z=+j$.exec(U.pathname)[1],J=await $.json(),G=await Y$(Z,J,X);return{status:X.status,body:G}}},W$=Bun.env.PORT;Bun.serve({port:W$,async fetch($){const U=await a9($);if(!U)return new Response(null,{status:404});return new Response(JSON.stringify(U.body),{status:U.status})}});console.log(`Server is running at on port ${W$}...`);
api01-1 | ^
api01-1 | ECONNREFUSED: Failed to connect
api01-1 | syscall: "connect"
api01-1 |
api01-1 | at /home/bun/app/index.js:3:121740
api01-1 | at promiseReactionJob (native:1:1)
api01-1 | at processTicksAndRejections (native:1:1)
api01-1 | 2 | // @bun
api01-1 | 3 | var K$=Object.create;var{defineProperty:y,getPrototypeOf:H$,getOwnPropertyNames:f0,getOwnPropertyDescriptor:O$}=Object,g0=Object.prototype.hasOwnProperty;var _$=($,U,X)=>{X=$!=null?K$(H$($)):{};const Z=U||!$||!$.__esModule?y(X,"default",{value:$,enumerable:!0}):X;for(let J of f0($))if(!g0.call(Z,J))y(Z,J,{get:()=>$[J],enumerable:!0});return Z},c0=($)=>{const U=c0.moduleCache??=new WeakMap;var X=U.get($);if(X)return X;var Z=y({},"__esModule",{value:!0}),J={enumerable:!1};if($&&typeof $==="object"||typeof $==="function"){for(let G of f0($))if(!g0.call(Z,G))y(Z,G,{get:()=>$[G],enumerable:!(J=O$($,G))||J.enumerable})}return U.set($,Z),Z};var H=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports);var z$=($,U)=>{for(var X in U)y($,X,{get:U[X],enumerable:!0,configurable:!0,set:(Z)=>U[X]=()=>Z})};var R$=($,U)=>()=>($&&(U=$($=0)),U);var j0=H((F$)=>{var L$=function($){return $};F$.parse=function($,U){return new Q0($,U).parse()};class Q0{constructor($,U){this.source=$,this.transform=U||L$,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 U;if(this.recorded.length>0||$){if(U=this.recorded.join(""),U==="NULL"&&!$)U=null;if(U!==null)U=this.transform(U);this.entries.push(U),this.recorded=[]}}consumeDimensions(){if(this.source[0]==="[")while(!this.isEof()){var $=this.nextCharacter();if($.value==="=")break}}parse($){var U,X,Z;this.consumeDimensions();while(!this.isEof())if(U=this.nextCharacter(),U.value==="{"&&!Z){if(this.dimension++,this.dimension>1)X=new Q0(this.source.substr(this.position-1),this.transform),this.entries.push(X.parse(!0)),this.position+=X.position-2}else if(U.value==="}"&&!Z){if(this.dimension--,!this.dimension){if(this.newEntry(),$)return this.entries}}else if(U.value==='"'&&!U.escaped){if(Z)this.newEntry(!0);Z=!Z}else if(U.value===","&&!Z)this.newEntry();else this.record(U.value);if(this.dimension!==0)throw new Error("array dimension not balanced");return this.entries}}});var W0=H((r9,l0)=>{var A$=j0();l0.exports={create:function($,U){return{parse:function(){return A$.parse($,U)}}}}});var i0=H((e9,n0)=>{var T$=function($){var U=V$.exec($);if(!U)return;var X=parseInt(U[1],10),Z=!!U[4];if(Z)X=o0(X);var J=parseInt(U[2],10)-1,G=U[3],Y=new Date(X,J,G);if(K0(X))Y.setFullYear(X);return Y},P$=function($){if($.endsWith("+00"))return 0;var U=E$.exec($.split(" ")[1]);if(!U)return;var X=U[1];if(X==="Z")return 0;var Z=X==="-"?-1:1,J=parseInt(U[2],10)*3600+parseInt(U[3]||0,10)*60+parseInt(U[4]||0,10);return J*Z*1000},o0=function($){return-($-1)},K0=function($){return $>=0&&$<100},N$=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,V$=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,E$=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,S$=/^-?infinity$/;n0.exports=function $(U){if(S$.test(U))return Number(U.replace("i","I"));var X=N$.exec(U);if(!X)return T$(U)||null;var Z=!!X[8],J=parseInt(X[1],10);if(Z)J=o0(J);var G=parseInt(X[2],10)-1,Y=X[3],Q=parseInt(X[4],10),j=parseInt(X[5],10),W=parseInt(X[6],10),K=X[7];K=K?1000*parseFloat(K):0;var O,_=P$(U);if(_!=null){if(O=new Date(Date.UTC(J,G,Y,Q,j,W,K)),K0(J))O.setUTCFullYear(J);if(_!==0)O.setTime(O.getTime()-_)}else if(O=new Date(J,G,Y,Q,j,W,K),K0(J))O.setFullYear(J);return O}});var t0=H(($U,a0)=>{var q$=function($){for(var U=1;U<arguments.length;U++){var X=arguments[U];for(var Z in X)if(C$.call(X,Z))$[Z]=X[Z]}return $};a0.exports=q$;var C$=Object.prototype.hasOwnProperty});var e0=H((UU,r0)=>{var k=function($){if(!(this instanceof k))return new k($);D$(this,p$($))},m$=function($){var U=$+"000000".slice($.length);return parseInt(U,10)/1000},p$=function($){if(!$)return{};var U=y$.exec($),X=U[8]==="-";return Object.keys(s0).reduce(function(Z,J){var G=s0[J],Y=U[G];if(!Y)return Z;if(Y=J==="milliseconds"?m$(Y):parseInt(Y,10),!Y)return Z;if(X&&~d$.indexOf(J))Y*=-1;return Z[J]=Y,Z},{})},D$=t0();r0.exports=k;var k$=["seconds","minutes","hours","days","months","years"];k.prototype.toPostgres=function(){var $=k$.filter(this.hasOwnProperty,this);if(this.milliseconds&&$.indexOf("seconds")<0)$.push("seconds");if($.length===0)return"0";return $.map(function(U){var X=this[U]||0;if(U==="seconds"&&this.milliseconds)X=(X+this.milliseconds/1000).toFixed(6).replace(/\.?0+$/,"");return X+" "+U},this).join(" ")};var B$={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"S"},I$=["years","months","days"],x$=["hours","minutes","seconds"];k.prototype.toISOString=k.prototype.toISO=function(){var $=I$.map(X,this).join(""),U=x$.map(X,this).join("");return"P"+$+"T"+U;function X(Z){var J=this[Z]||0;if(Z==="seconds"&&this.milliseconds)J=(J+this.milliseconds/1000).toFixed(6).replace(/0+$/,"");return J+B$[Z]}};var H0="([+-]?\\d+)",w$=H0+"\\s+years?",h$=H0+"\\s+mons?",b$=H0+"\\s+days?",v$="([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",y$=new RegExp([w$,h$,b$,v$].map(function($){return"("+$+")?"}).join("\\s*")),s0={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},d$=["hours","minutes","seconds","milliseconds"]});var U1=H((XU,$1)=>{$1.exports=function $(U){if(/^\\x/.test(U))return new Buffer(U.substr(2),"hex");var X="",Z=0;while(Z<U.length)if(U[Z]!=="\\")X+=U[Z],++Z;else if(/[0-7]{3}/.test(U.substr(Z+1,3)))X+=String.fromCharCode(parseInt(U.substr(Z+1,3),8)),Z+=4;else{var J=1;while(Z+J<U.length&&U[Z+J]==="\\")J++;for(var G=0;G<Math.floor(J/2);++G)X+="\\";Z+=Math.floor(J/2)*2}return new Buffer(X,"binary")}});var j1=H((ZU,Q1)=>{var t=function($){return function U(X){if(X===null)return X;return $(X)}},G1=function($){if($===null)return $;return $==="TRUE"||$==="t"||$==="true"||$==="y"||$==="yes"||$==="on"||$==="1"},u$=function($){if(!$)return null;return d.parse($,G1)},f$=function($){return parseInt($,10)},O0=function($){if(!$)return null;return d.parse($,t(f$))},g$=function($){if(!$)return null;return d.parse($,t(function(U){return Y1(U).trim()}))},d=j0(),m=W0(),a=i0(),Z1=e0(),J1=U1(),c$=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=L0(X);return X});return U.parse()},_0=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=parseFloat(X);return X});return U.parse()},S=function($){if(!$)return null;var U=m.create($);return U.parse()},z0=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=a(X);return X});return U.parse()},l$=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=Z1(X);return X});return U.parse()},o$=function($){if(!$)return null;return d.parse($,t(J1))},R0=function($){return parseInt($,10)},Y1=function($){var U=String($);if(/^\d+$/.test(U))return U;return $},X1=function($){if(!$)return null;return d.parse($,t(JSON.parse))},L0=function($){if($[0]!=="(")return null;return $=$.substring(1,$.length-1).split(","),{x:parseFloat($[0]),y:parseFloat($[1])}},n$=function($){if($[0]!=="<"&&$[1]!=="(")return null;var U="(",X="",Z=!1;for(var J=2;J<$.length-1;J++){if(!Z)U+=$[J];if($[J]===")"){Z=!0;continue}else if(!Z)continue;if($[J]===",")continue;X+=$[J]}var G=L0(U);return G.radius=parseFloat(X),G},i$=function($){$(20,Y1),$(21,R0),$(23,R0),$(26,R0),$(700,parseFloat),$(701,parseFloat),$(16,G1),$(1082,a),$(1114,a),$(1184,a),$(600,L0),$(651,S),$(718,n$),$(1000,u$),$(1001,o$),$(1005,O0),$(1007,O0),$(1028,O0),$(1016,g$),$(1017,c$),$(1021,_0),$(1022,_0),$(1231,_0),$(1014,S),$(1015,S),$(1008,S),$(1009,S),$(1040,S),$(1041,S),$(1115,z0),$(1182,z0),$(1185,z0),$(1186,Z1),$(1187,l$),$(17,J1),$(114,JSON.parse.bind(JSON)),$(3802,JSON.parse.bind(JSON)),$(199,X1),$(3807,X1),$(3907,S),$(2951,S),$(791,S),$(1183,S),$(1270,S)};Q1.exports={init:i$}});var K1=H((JU,W1)=>{var a$=function($){var U=$.readInt32BE(0),X=$.readUInt32BE(4),Z="";if(U<0)U=~U+(X===0),X=~X+1>>>0,Z="-";var J="",G,Y,Q,j,W,K;{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}return G=U%N,Y=4294967296*G+X,Q=""+Y%N,Z+Q+J},N=1e6;W1.exports=a$});var R1=H((GU,z1)=>{var t$=K1(),z=function($,U,X,Z,J){X=X||0,Z=Z||!1,J=J||function(E,G0,Y0){return E*Math.pow(2,Y0)+G0};var G=X>>3,Y=function(E){if(Z)return~E&255;return E},Q=255,j=8-X%8;if(U<j)Q=255<<8-U&255,j=U;if(X)Q=Q>>X%8;var W=0;if(X%8+U>=8)W=J(0,Y($[G])&Q,j);var K=U+X>>3;for(var O=G+1;O<K;O++)W=J(W,Y($[O]),8);var _=(U+X)%8;if(_>0)W=J(W,Y($[K])>>8-_,_);return W},_1=function($,U,X){var Z=Math.pow(2,X-1)-1,J=z($,1),G=z($,X,1);if(G===0)return 0;var Y=1,Q=function(W,K,O){if(W===0)W=1;for(var _=1;_<=O;_++)if(Y/=2,(K&1<<O-_)>0)W+=Y;return W},j=z($,U,X+1,!1,Q);if(G==Math.pow(2,X+1)-1){if(j===0)return J===0?Infinity:(-Infinity);return NaN}return(J===0?1:-1)*Math.pow(2,G-Z)*j},s$=function($){if(z($,1)==1)return-1*(z($,15,1,!0)+1);return z($,15,1)},H1=function($){if(z($,1)==1)return-1*(z($,31,1,!0)+1);return z($,31,1)},r$=function($){return _1($,23,8)},e$=function($){return _1($,52,11)},$4=function($){var U=z($,16,32);if(U==49152)return NaN;var X=Math.pow(1e4,z($,16,16)),Z=0,J=[],G=z($,16);for(var Y=0;Y<G;Y++)Z+=z($,16,64+16*Y)*X,X/=1e4;var Q=Math.pow(10,z($,16,48));return(U===0?1:-1)*Math.round(Z*Q)/Q},O1=function($,U){var X=z(U,1),Z=z(U,63,1),J=new Date((X===0?1:-1)*Z/1000+946684800000);if(!$)J.setTime(J.getTime()+J.getTimezoneOffset()*60000);return J.usec=Z%1000,J.getMicroSeconds=function(){return this.usec},J.setMicroSeconds=function(G){this.usec=G},J.getUTCMicroSeconds=function(){return this.usec},J},p=function($){var U=z($,32),X=z($,32,32),Z=z($,32,64),J=96,G=[];for(var Y=0;Y<U;Y++)G[Y]=z($,32,J),J+=32,J+=32;var Q=function(W){var K=z($,32,J);if(J+=32,K==4294967295)return null;var O;if(W==23||W==20)return O=z($,K*8,J),J+=K*8,O;else if(W==25)return O=$.toString(this.encoding,J>>3,(J+=K<<3)>>3),O;else console.log("ERROR: ElementType not implemented: "+W)},j=function(W,K){var O=[],_;if(W.length>1){var E=W.shift();for(_=0;_<E;_++)O[_]=j(W,K);W.unshift(E)}else for(_=0;_<W[0];_++)O[_]=Q(K);return O};return j(G,Z)},U4=function($){return $.toString("utf8")},X4=function($){if($===null)return null;return z($,8)>0},Z4=function($){$(20,t$),$(21,s$),$(23,H1),$(26,H1),$(1700,$4),$(700,r$),$(701,e$),$(16,X4),$(1114,O1.bind(null,!1)),$(1184,O1.bind(null,!0)),$(1000,p),$(1007,p),$(1016,p),$(1008,p),$(1009,p),$(25,U4)};z1.exports={init:Z4}});var F1=H((YU,L1)=>{L1.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 f=H((K4)=>{var M1=function($){return String($)},j4=function($,U){if(U=U||"text",!u[U])return M1;return u[U][$]||M1},W4=function($,U,X){if(typeof U=="function")X=U,U="text";u[U][$]=X},J4=j1(),G4=R1(),Y4=W0(),Q4=F1();K4.getTypeParser=j4;K4.setTypeParser=W4;K4.arrayParser=Y4;K4.builtins=Q4;var u={text:{},binary:{}};J4.init(function($,U){u.text[$]=U});G4.init(function($,U){u.binary[$]=U})});var g=H((jU,F0)=>{F0.exports={host:"localhost",user:process.platform==="win32"?process.env.USERNAME:process.env.USER,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 B=f(),R4=B.getTypeParser(20,"text"),L4=B.getTypeParser(1016,"text");F0.exports.__defineSetter__("parseInt8",function($){B.setTypeParser(20,"text",$?B.getTypeParser(23,"text"):R4),B.setTypeParser(1016,"text",$?B.getTypeParser(1007,"text"):L4)})});var c=H((WU,N1)=>{var M4=function($){var U=$.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return'"'+U+'"'},A1=function($){var U="{";for(var X=0;X<$.length;X++){if(X>0)U=U+",";if($[X]===null||typeof $[X]==="undefined")U=U+"NULL";else if(Array.isArray($[X]))U=U+A1($[X]);else if($[X]instanceof Buffer)U+="\\\\x"+$[X].toString("hex");else U+=M4(s($[X]))}return U=U+"}",U},A4=function($,U){if($&&typeof $.toPostgres==="function"){if(U=U||[],U.indexOf($)!==-1)throw new Error('circular reference detected while preparing "'+$+'" for query');return U.push($),s($.toPostgres(s),U)}return JSON.stringify($)},M=function($,U){$=""+$;while($.length<U)$="0"+$;return $},N4=function($){var U=-$.getTimezoneOffset(),X=$.getFullYear(),Z=X<1;if(Z)X=Math.abs(X)+1;var J=M(X,4)+"-"+M($.getMonth()+1,2)+"-"+M($.getDate(),2)+"T"+M($.getHours(),2)+":"+M($.getMinutes(),2)+":"+M($.getSeconds(),2)+"."+M($.getMilliseconds(),3);if(U<0)J+="-",U*=-1;else J+="+";if(J+=M(Math.floor(U/60),2)+":"+M(U%60,2),Z)J+=" BC";return J},V4=function($){var U=$.getUTCFullYear(),X=U<1;if(X)U=Math.abs(U)+1;var Z=M(U,4)+"-"+M($.getUTCMonth()+1,2)+"-"+M($.getUTCDate(),2)+"T"+M($.getUTCHours(),2)+":"+M($.getUTCMinutes(),2)+":"+M($.getUTCSeconds(),2)+"."+M($.getUTCMilliseconds(),3);if(Z+="+00:00",X)Z+=" BC";return Z},E4=function($,U,X){if($=typeof $==="string"?{text:$}:$,U)if(typeof U==="function")$.callback=U;else $.values=U;if(X)$.callback=X;return $},F4=g(),s=function($,U){if($==null)return null;if($ instanceof Buffer)return $;if(ArrayBuffer.isView($)){var X=Buffer.from($.buffer,$.byteOffset,$.byteLength);if(X.length===$.byteLength)return X;return X.slice($.byteOffset,$.byteOffset+$.byteLength)}if($ instanceof Date)if(F4.parseInputDatesAsUTC)return V4($);else return N4($);if(Array.isArray($))return A1($);if(typeof $==="object")return A4($,U);return $.toString()},S4=function($){return'"'+$.replace(/"/g,'""')+'"'},T4=function($){var U=!1,X="'";for(var Z=0;Z<$.length;Z++){var J=$[Z];if(J==="'")X+=J+J;else if(J==="\\")X+=J+J,U=!0;else X+=J}if(X+="'",U===!0)X=" E"+X;return X};N1.exports={prepareValue:function $(U){return s(U)},normalizeQueryConfig:E4,escapeIdentifier:S4,escapeLiteral:T4}});var E1=H((KU,V1)=>{var M0=function($){return l.createHash("md5").update($,"utf-8").digest("hex")},P4=function($,U,X){var Z=M0(U+$),J=M0(Buffer.concat([Buffer.from(Z),X]));return"md5"+J},C4=function($){return l.createHash("sha256").update($).digest()},q4=function($,U){return l.createHmac("sha256",$).update(U).digest()};async function D4($,U,X){return l.pbkdf2Sync($,U,X,32,"sha256")}var l=import.meta.require("crypto");V1.exports={postgresMd5PasswordHash:P4,randomBytes:l.randomBytes,deriveKey:D4,sha256:C4,hmacSha256:q4,md5:M0}});var C1=H((HU,P1)=>{var k4=function($){return T1.getRandomValues(Buffer.alloc($))};async function A0($){try{return S1.createHash("md5").update($,"utf-8").digest("hex")}catch(U){const X=typeof $==="string"?N0.encode($):$,Z=await I.digest("MD5",X);return Array.from(new Uint8Array(Z)).map((J)=>J.toString(16).padStart(2,"0")).join("")}}async function B4($,U,X){var Z=await A0(U+$),J=await A0(Buffer.concat([Buffer.from(Z),X]));return"md5"+J}async function I4($){return await I.digest("SHA-256",$)}async function x4($,U){const X=await I.importKey("raw",$,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return await I.sign("HMAC",X,N0.encode(U))}async function w4($,U,X){const Z=await I.importKey("raw",N0.encode($),"PBKDF2",!1,["deriveBits"]),J={name:"PBKDF2",hash:"SHA-256",salt:U,iterations:X};return await I.deriveBits(J,Z,256,["deriveBits"])}var S1=import.meta.require("crypto");P1.exports={postgresMd5PasswordHash:B4,randomBytes:k4,deriveKey:w4,sha256:I4,hmacSha256:x4,md5:A0};var T1=S1.webcrypto||globalThis.crypto,I=T1.subtle,N0=new TextEncoder});var E0=H((OU,V0)=>{var h4=parseInt(process.versions&&process.versions.node&&process.versions.node.split(".")[0])<15;if(h4)V0.exports=E1();else V0.exports=C1()});var B1=H((_U,k1)=>{var b4=function($){if($.indexOf("SCRAM-SHA-256")===-1)throw new Error("SASL: Only mechanism SCRAM-SHA-256 is currently supported");const U=q.randomBytes(18).toString("base64");return{mechanism:"SCRAM-SHA-256",clientNonce:U,response:"n,,n=*,r="+U,message:"SASLInitialResponse"}};async function v4($,U,X){if($.message!=="SASLInitialResponse")throw new Error("SASL: Last message was not SASLInitialResponse");if(typeof U!=="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");if(U==="")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string");if(typeof X!=="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");const Z=m4(X);if(!Z.nonce.startsWith($.clientNonce))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");else if(Z.nonce.length===$.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short");var J="n=*,r="+$.clientNonce,G="r="+Z.nonce+",s="+Z.salt+",i="+Z.iteration,Y="c=biws,r="+Z.nonce,Q=J+","+G+","+Y,j=Buffer.from(Z.salt,"base64"),W=await q.deriveKey(U,j,Z.iteration),K=await q.hmacSha256(W,"Client Key"),O=await q.sha256(K),_=await q.hmacSha256(O,Q),E=u4(Buffer.from(K),Buffer.from(_)).toString("base64"),G0=await q.hmacSha256(W,"Server Key"),Y0=await q.hmacSha256(G0,Q);$.message="SASLResponse",$.serverSignature=Buffer.from(Y0).toString("base64"),$.response=Y+",p="+E}var y4=function($,U){if($.message!=="SASLResponse")throw new Error("SASL: Last message was not SASLResponse");if(typeof U!=="string")throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");const{serverSignature:X}=p4(U);if(X!==$.serverSignature)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match")},d4=function($){if(typeof $!=="string")throw new TypeError("SASL: text must be a string");return $.split("").map((U,X)=>$.charCodeAt(X)).every((U)=>U>=33&&U<=43||U>=45&&U<=126)},q1=function($){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test($)},D1=function($){if(typeof $!=="string")throw new TypeError("SASL: attribute pairs text must be a string");return new Map($.split(",").map((U)=>{if(!/^.=/.test(U))throw new Error("SASL: Invalid attribute pair entry");const X=U[0],Z=U.substring(2);return[X,Z]}))},m4=function($){const U=D1($),X=U.get("r");if(!X)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");else if(!d4(X))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters");const Z=U.get("s");if(!Z)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing");else if(!q1(Z))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64");const J=U.get("i");if(!J)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing");else if(!/^[1-9][0-9]*$/.test(J))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count");const G=parseInt(J,10);return{nonce:X,salt:Z,iteration:G}},p4=function($){const X=D1($).get("v");if(!X)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");else if(!q1(X))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64");return{serverSignature:X}},u4=function($,U){if(!Buffer.isBuffer($))throw new TypeError("first argument must be a Buffer");if(!Buffer.isBuffer(U))throw new TypeError("second argument must be a Buffer");if($.length!==U.length)throw new Error("Buffer lengths must match");if($.length===0)throw new Error("Buffers cannot be empty");return Buffer.from($.map((X,Z)=>$[Z]^U[Z]))},q=E0();k1.exports={startSession:b4,continueSession:v4,finalizeSession:y4}});var S0=H((zU,I1)=>{var r=function($){this._types=$||f4,this.text={},this.binary={}},f4=f();r.prototype.getOverrides=function($){switch($){case"text":return this.text;case"binary":return this.binary;default:return{}}};r.prototype.setTypeParser=function($,U,X){if(typeof U==="function")X=U,U="text";this.getOverrides(U)[$]=X};r.prototype.getTypeParser=function($,U){return U=U||"text",this.getOverrides(U)[$]||this._types.getTypeParser($,U)};I1.exports=r});var w1=H((RU,x1)=>{var T0=function($){if($.charAt(0)==="/"){const Q=$.split(" ");return{host:Q[0],database:Q[1]}}const U={};let X,Z=!1;if(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test($))$=encodeURI($).replace(/\%25(\d\d)/g,"%$1");try{X=new URL($,"postgres://base")}catch(Q){X=new URL($.replace("@/","@___DUMMY___/"),"postgres://base"),Z=!0}for(let Q of X.searchParams.entries())U[Q[0]]=Q[1];if(U.user=U.user||decodeURIComponent(X.username),U.password=U.password||decodeURIComponent(X.password),X.protocol=="socket:")return U.host=decodeURI(X.pathname),U.database=X.searchParams.get("db"),U.client_encoding=X.searchParams.get("encoding"),U;const J=Z?"":X.hostname;if(!U.host)U.host=decodeURIComponent(J);else if(J&&/^%2f/i.test(J))X.pathname=J+X.pathname;if(!U.port)U.port=X.port;const G=X.pathname.slice(1)||null;if(U.database=G?decodeURI(G):null,U.ssl==="true"||U.ssl==="1")U.ssl=!0;if(U.ssl==="0")U.ssl=!1;if(U.sslcert||U.sslkey||U.sslrootcert||U.sslmode)U.ssl={};const Y=U.sslcert||U.sslkey||U.sslrootcert?import.meta.require("fs"):null;if(U.sslcert)U.ssl.cert=Y.readFileSync(U.sslcert).toString();if(U.sslkey)U.ssl.key=Y.readFileSync(U.sslkey).toString();if(U.sslrootcert)U.ssl.ca=Y.readFileSync(U.sslrootcert).toString();switch(U.sslmode){case"disable":{U.ssl=!1;break}case"prefer":case"require":case"verify-ca":case"verify-full":break;case"no-verify":{U.ssl.rejectUnauthorized=!1;break}}return U};x1.exports=T0;T0.parse=T0});var P0=H((LU,y1)=>{var g4=import.meta.require("dns"),b1=g(),h1=w1().parse,A=function($,U,X){if(X===void 0)X=process.env["PG"+$.toUpperCase()];else if(X===!1);else X=process.env[X];return U[$]||X||b1[$]},c4=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 b1.ssl},x=function($){return"'"+(""+$).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},T=function($,U,X){var Z=U[X];if(Z!==void 0&&Z!==null)$.push(X+"="+x(Z))};class v1{constructor($){if($=typeof $==="string"?h1($):$||{},$.connectionString)$=Object.assign({},$,h1($.connectionString));if(this.user=A("user",$),this.database=A("database",$),this.database===void 0)this.database=this.user;if(this.port=parseInt(A("port",$),10),this.host=A("host",$),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:A("password",$)}),this.binary=A("binary",$),this.options=A("options",$),this.ssl=typeof $.ssl==="undefined"?c4():$.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=A("client_encoding",$),this.replication=A("replication",$),this.isDomainSocket=!(this.host||"").indexOf("/"),this.application_name=A("application_name",$,"PGAPPNAME"),this.fallback_application_name=A("fallback_application_name",$,!1),this.statement_timeout=A("statement_timeout",$,!1),this.lock_timeout=A("lock_timeout",$,!1),this.idle_in_transaction_session_timeout=A("idle_in_transaction_session_timeout",$,!1),this.query_timeout=A("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($){var U=[];T(U,this,"user"),T(U,this,"password"),T(U,this,"port"),T(U,this,"application_name"),T(U,this,"fallback_application_name"),T(U,this,"connect_timeout"),T(U,this,"options");var X=typeof this.ssl==="object"?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(T(U,X,"sslmode"),T(U,X,"sslca"),T(U,X,"sslkey"),T(U,X,"sslcert"),T(U,X,"sslrootcert"),this.database)U.push("dbname="+x(this.database));if(this.replication)U.push("replication="+x(this.replication));if(this.host)U.push("host="+x(this.host));if(this.isDomainSocket)return $(null,U.join(" "));if(this.client_encoding)U.push("client_encoding="+x(this.client_encoding));g4.lookup(this.host,function(Z,J){if(Z)return $(Z,null);return U.push("hostaddr="+x(J)),$(null,U.join(" "))})}}y1.exports=v1});var u1=H((FU,p1)=>{var l4=f(),d1=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/;class m1{constructor($,U){if(this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0,this._types=U,this.RowCtor=null,this.rowAsArray=$==="array",this.rowAsArray)this.parseRow=this._parseRowAsArray;this._prebuiltEmptyResultObject=null}addCommandComplete($){var U;if($.text)U=d1.exec($.text);else U=d1.exec($.command);if(U){if(this.command=U[1],U[3])this.oid=parseInt(U[2],10),this.rowCount=parseInt(U[3],10);else if(U[2])this.rowCount=parseInt(U[2],10)}}_parseRowAsArray($){var U=new Array($.length);for(var X=0,Z=$.length;X<Z;X++){var J=$[X];if(J!==null)U[X]=this._parsers[X](J);else U[X]=null}return U}parseRow($){var U={...this._prebuiltEmptyResultObject};for(var X=0,Z=$.length;X<Z;X++){var J=$[X],G=this.fields[X].name;if(J!==null)U[G]=this._parsers[X](J)}return U}addRow($){this.rows.push($)}addFields($){if(this.fields=$,this.fields.length)this._parsers=new Array($.length);for(var U=0;U<$.length;U++){var X=$[U];if(this._types)this._parsers[U]=this._types.getTypeParser(X.dataTypeID,X.format||"text");else this._parsers[U]=l4.getTypeParser(X.dataTypeID,X.format||"text")}this._createPrebuiltEmptyResultObject()}_createPrebuiltEmptyResultObject(){var $={};for(var U=0;U<this.fields.length;U++)$[this.fields[U].name]=null;this._prebuiltEmptyResultObject={...$}}}p1.exports=m1});var o1=H((MU,l1)=>{var{EventEmitter:o4}=import.meta.require("events"),f1=u1(),g1=c();class c1 extends o4{constructor($,U,X){super();if($=g1.normalizeQueryConfig($,U,X),this.text=$.text,this.values=$.values,this.rows=$.rows,this.types=$.types,this.name=$.name,this.binary=$.binary,this.portal=$.portal||"",this.callback=$.callback,this._rowMode=$.rowMode,process.domain&&$.callback)this.callback=process.domain.bind($.callback);this._result=new f1(this._rowMode,this.types),this._results=this._result,this.isPreparedStatement=!1,this._canceledDueToError=!1,this._promise=null}requiresPreparation(){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 f1(this._rowMode,this.types),this._results.push(this._result)}}handleRowDescription($){this._checkForMultirow(),this._result.addFields($.fields),this._accumulateRows=this.callback||!this.listeners("row").length}handleDataRow($){let U;if(this._canceledDueToError)return;try{U=this._result.parseRow($.fields)}catch(X){this._canceledDueToError=X;return}if(this.emit("row",U,this._result),this._accumulateRows)this._result.addRow(U)}handleCommandComplete($,U){if(this._checkForMultirow(),this._result.addCommandComplete($),this.rows)U.sync()}handleEmptyQuery($){if(this.rows)$.sync()}handleError($,U){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(U){process.nextTick(()=>{throw U})}this.emit("end",this._results)}submit($){if(typeof this.text!=="string"&&typeof this.name!=="string")return new Error("A query must have either text or a name. Supplying neither is unsupported.");const U=$.parsedStatements[this.name];if(this.text&&U&&this.text!==U)return new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);if(this.values&&!Array.isArray(this.values))return new Error("Query values must be an array");if(this.requiresPreparation())this.prepare($);else $.query(this.text);return null}hasBeenParsed($){return this.name&&$.parsedStatements[this.name]}handlePortalSuspended($){this._getRows($,this.rows)}_getRows($,U){if($.execute({portal:this.portal,rows:U}),!U)$.sync();else $.flush()}prepare($){if(this.isPreparedStatement=!0,!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:g1.prepareValue})}catch(U){this.handleError(U,$);return}$.describe({type:"P",name:this.portal||""}),this._getRows($,this.rows)}handleCopyInResponse($){$.sendCopyFail("No source stream defined")}handleCopyData($,U){}}l1.exports=c1});var C0=H((Q8)=>{Object.defineProperty(Q8,"__esModule",{value:!0});Q8.NoticeMessage=Q8.DataRowMessage=Q8.CommandCompleteMessage=Q8.ReadyForQueryMessage=Q8.NotificationResponseMessage=Q8.BackendKeyDataMessage=Q8.AuthenticationMD5Password=Q8.ParameterStatusMessage=Q8.ParameterDescriptionMessage=Q8.RowDescriptionMessage=Q8.Field=Q8.CopyResponse=Q8.CopyDataMessage=Q8.DatabaseError=Q8.copyDone=Q8.emptyQuery=Q8.replicationStart=Q8.portalSuspended=Q8.noData=Q8.closeComplete=Q8.bindComplete=Q8.parseComplete=void 0;Q8.parseComplete={name:"parseComplete",length:5};Q8.bindComplete={name:"bindComplete",length:5};Q8.closeComplete={name:"closeComplete",length:5};Q8.noData={name:"noData",length:5};Q8.portalSuspended={name:"portalSuspended",length:5};Q8.replicationStart={name:"replicationStart",length:4};Q8.emptyQuery={name:"emptyQuery",length:4};Q8.copyDone={name:"copyDone",length:4};class n1 extends Error{constructor($,U,X){super($);this.length=U,this.name=X}}Q8.DatabaseError=n1;class i1{constructor($,U){this.length=$,this.chunk=U,this.name="copyData"}}Q8.CopyDataMessage=i1;class a1{constructor($,U,X,Z){this.length=$,this.name=U,this.binary=X,this.columnTypes=new Array(Z)}}Q8.CopyResponse=a1;class t1{constructor($,U,X,Z,J,G,Y){this.name=$,this.tableID=U,this.columnID=X,this.dataTypeID=Z,this.dataTypeSize=J,this.dataTypeModifier=G,this.format=Y}}Q8.Field=t1;class s1{constructor($,U){this.length=$,this.fieldCount=U,this.name="rowDescription",this.fields=new Array(this.fieldCount)}}Q8.RowDescriptionMessage=s1;class r1{constructor($,U){this.length=$,this.parameterCount=U,this.name="parameterDescription",this.dataTypeIDs=new Array(this.parameterCount)}}Q8.ParameterDescriptionMessage=r1;class e1{constructor($,U,X){this.length=$,this.parameterName=U,this.parameterValue=X,this.name="parameterStatus"}}Q8.ParameterStatusMessage=e1;class $8{constructor($,U){this.length=$,this.salt=U,this.name="authenticationMD5Password"}}Q8.AuthenticationMD5Password=$8;class U8{constructor($,U,X){this.length=$,this.processID=U,this.secretKey=X,this.name="backendKeyData"}}Q8.BackendKeyDataMessage=U8;class X8{constructor($,U,X,Z){this.length=$,this.processId=U,this.channel=X,this.payload=Z,this.name="notification"}}Q8.NotificationResponseMessage=X8;class Z8{constructor($,U){this.length=$,this.status=U,this.name="readyForQuery"}}Q8.ReadyForQueryMessage=Z8;class J8{constructor($,U){this.length=$,this.text=U,this.name="commandComplete"}}Q8.CommandCompleteMessage=J8;class G8{constructor($,U){this.length=$,this.fields=U,this.name="dataRow",this.fieldCount=U.length}}Q8.DataRowMessage=G8;class Y8{constructor($,U){this.length=$,this.message=U,this.name="notice"}}Q8.NoticeMessage=Y8});var O8=H((K8)=>{Object.defineProperty(K8,"__esModule",{value:!0});K8.Writer=void 0;class W8{constructor($=256){this.size=$,this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe($)}ensure($){var U=this.buffer.length-this.offset;if(U<$){var X=this.buffer,Z=X.length+(X.length>>1)+$;this.buffer=Buffer.allocUnsafe(Z),X.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{var U=Buffer.byteLength($);this.ensure(U+1),this.buffer.write($,this.offset,"utf-8"),this.offset+=U}return this.buffer[this.offset++]=0,this}addString($=""){var U=Buffer.byteLength($);return this.ensure(U),this.buffer.write($,this.offset),this.offset+=U,this}add($){return this.ensure($.length),$.copy(this.buffer,this.offset),this.offset+=$.length,this}join($){if($){this.buffer[this.headerPosition]=$;const U=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(U,this.headerPosition+1)}return this.buffer.slice($?0:5,this.offset)}flush($){var U=this.join($);return this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(this.size),U}}K8.Writer=W8});var L8=H((z8)=>{Object.defineProperty(z8,"__esModule",{value:!0});z8.serialize=void 0;var q0=O8(),R=new q0.Writer,z5=($)=>{R.addInt16(3).addInt16(0);for(let Z of Object.keys($))R.addCString(Z).addCString($[Z]);R.addCString("client_encoding").addCString("UTF8");var U=R.addCString("").flush(),X=U.length+4;return new q0.Writer().addInt32(X).add(U).flush()},R5=()=>{const $=Buffer.allocUnsafe(8);return $.writeInt32BE(8,0),$.writeInt32BE(80877103,4),$},L5=($)=>{return R.addCString($).flush(112)},F5=function($,U){return R.addCString($).addInt32(Buffer.byteLength(U)).addString(U),R.flush(112)},M5=function($){return R.addString($).flush(112)},A5=($)=>{return R.addCString($).flush(81)},_8=[],N5=($)=>{const U=$.name||"";if(U.length>63)console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",U,U.length),console.error("This can cause conflicts and silent errors executing queries");const X=$.types||_8;var Z=X.length,J=R.addCString(U).addCString($.text).addInt16(Z);for(var G=0;G<Z;G++)J.addInt32(X[G]);return R.flush(80)},w=new q0.Writer,V5=function($,U){for(let X=0;X<$.length;X++){const Z=U?U($[X],X):$[X];if(Z==null)R.addInt16(0),w.addInt32(-1);else if(Z instanceof Buffer)R.addInt16(1),w.addInt32(Z.length),w.add(Z);else R.addInt16(0),w.addInt32(Buffer.byteLength(Z)),w.addString(Z)}},E5=($={})=>{const U=$.portal||"",X=$.statement||"",Z=$.binary||!1,J=$.values||_8,G=J.length;return R.addCString(U).addCString(X),R.addInt16(G),V5(J,$.valueMapper),R.addInt16(G),R.add(w.flush()),R.addInt16(Z?1:0),R.flush(66)},S5=Buffer.from([69,0,0,0,9,0,0,0,0,0]),T5=($)=>{if(!$||!$.portal&&!$.rows)return S5;const U=$.portal||"",X=$.rows||0,Z=Buffer.byteLength(U),J=4+Z+1+4,G=Buffer.allocUnsafe(1+J);return G[0]=69,G.writeInt32BE(J,1),G.write(U,5,"utf-8"),G[Z+5]=0,G.writeUInt32BE(X,G.length-4),G},P5=($,U)=>{const X=Buffer.allocUnsafe(16);return X.writeInt32BE(16,0),X.writeInt16BE(1234,4),X.writeInt16BE(5678,6),X.writeInt32BE($,8),X.writeInt32BE(U,12),X},D0=($,U)=>{const Z=4+Buffer.byteLength(U)+1,J=Buffer.allocUnsafe(1+Z);return J[0]=$,J.writeInt32BE(Z,1),J.write(U,5,"utf-8"),J[Z]=0,J},C5=R.addCString("P").flush(68),q5=R.addCString("S").flush(68),D5=($)=>{return $.name?D0(68,`${$.type}${$.name||""}`):$.type==="P"?C5:q5},k5=($)=>{const U=`${$.type}${$.name||""}`;return D0(67,U)},B5=($)=>{return R.add($).flush(100)},I5=($)=>{return D0(102,$)},e=($)=>Buffer.from([$,0,0,0,4]),x5=e(72),w5=e(83),h5=e(88),b5=e(99),v5={startup:z5,password:L5,requestSsl:R5,sendSASLInitialResponseMessage:F5,sendSCRAMClientFinalMessage:M5,query:A5,parse:N5,bind:E5,execute:T5,describe:D5,close:k5,flush:()=>x5,sync:()=>w5,end:()=>h5,copyData:B5,copyDone:()=>b5,copyFail:I5,cancel:P5};z8.serialize=v5});var N8=H((M8)=>{Object.defineProperty(M8,"__esModule",{value:!0});M8.BufferReader=void 0;var y5=Buffer.allocUnsafe(0);class F8{constructor($=0){this.offset=$,this.buffer=y5,this.encoding="utf-8"}setBuffer($,U){this.offset=$,this.buffer=U}int16(){const $=this.buffer.readInt16BE(this.offset);return this.offset+=2,$}byte(){const $=this.buffer[this.offset];return this.offset++,$}int32(){const $=this.buffer.readInt32BE(this.offset);return this.offset+=4,$}string($){const U=this.buffer.toString(this.encoding,this.offset,this.offset+$);return this.offset+=$,U}cstring(){const $=this.offset;let U=$;while(this.buffer[U++]!==0);return this.offset=U,this.buffer.toString(this.encoding,$,U-1)}bytes($){const U=this.buffer.slice(this.offset,this.offset+$);return this.offset+=$,U}}M8.BufferReader=F8});var T8=H((h)=>{var d5=h&&h.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(h,"__esModule",{value:!0});h.Parser=void 0;var L=C0(),m5=N8(),p5=d5(import.meta.require("assert")),k0=1,u5=4,V8=k0+u5,E8=Buffer.allocUnsafe(0);class S8{constructor($){if(this.buffer=E8,this.bufferLength=0,this.bufferOffset=0,this.reader=new m5.BufferReader,($===null||$===void 0?void 0:$.mode)==="binary")throw new Error("Binary mode not supported yet");this.mode=($===null||$===void 0?void 0:$.mode)||"text"}parse($,U){this.mergeBuffer($);const X=this.bufferOffset+this.bufferLength;let Z=this.bufferOffset;while(Z+V8<=X){const J=this.buffer[Z],G=this.buffer.readUInt32BE(Z+k0),Y=k0+G;if(Y+Z<=X){const Q=this.handlePacket(Z+V8,J,G,this.buffer);U(Q),Z+=Y}else break}if(Z===X)this.buffer=E8,this.bufferLength=0,this.bufferOffset=0;else this.bufferLength=X-Z,this.bufferOffset=Z}mergeBuffer($){if(this.bufferLength>0){const U=this.bufferLength+$.byteLength;if(U+this.bufferOffset>this.buffer.byteLength){let Z;if(U<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)Z=this.buffer;else{let J=this.buffer.byteLength*2;while(U>=J)J*=2;Z=Buffer.allocUnsafe(J)}this.buffer.copy(Z,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=Z,this.bufferOffset=0}$.copy(this.buffer,this.bufferOffset+this.bufferLength),this.bufferLength=U}else this.buffer=$,this.bufferOffset=0,this.bufferLength=$.byteLength}handlePacket($,U,X,Z){switch(U){case 50:return L.bindComplete;case 49:return L.parseComplete;case 51:return L.closeComplete;case 110:return L.noData;case 115:return L.portalSuspended;case 99:return L.copyDone;case 87:return L.replicationStart;case 73:return L.emptyQuery;case 68:return this.parseDataRowMessage($,X,Z);case 67:return this.parseCommandCompleteMessage($,X,Z);case 90:return this.parseReadyForQueryMessage($,X,Z);case 65:return this.parseNotificationMessage($,X,Z);case 82:return this.parseAuthenticationResponse($,X,Z);case 83:return this.parseParameterStatusMessage($,X,Z);case 75:return this.parseBackendKeyData($,X,Z);case 69:return this.parseErrorMessage($,X,Z,"error");case 78:return this.parseErrorMessage($,X,Z,"notice");case 84:return this.parseRowDescriptionMessage($,X,Z);case 116:return this.parseParameterDescriptionMessage($,X,Z);case 71:return this.parseCopyInMessage($,X,Z);case 72:return this.parseCopyOutMessage($,X,Z);case 100:return this.parseCopyData($,X,Z);default:p5.default.fail(`unknown message code: ${U.toString(16)}`)}}parseReadyForQueryMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.string(1);return new L.ReadyForQueryMessage(U,Z)}parseCommandCompleteMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.cstring();return new L.CommandCompleteMessage(U,Z)}parseCopyData($,U,X){const Z=X.slice($,$+(U-4));return new L.CopyDataMessage(U,Z)}parseCopyInMessage($,U,X){return this.parseCopyMessage($,U,X,"copyInResponse")}parseCopyOutMessage($,U,X){return this.parseCopyMessage($,U,X,"copyOutResponse")}parseCopyMessage($,U,X,Z){this.reader.setBuffer($,X);const J=this.reader.byte()!==0,G=this.reader.int16(),Y=new L.CopyResponse(U,Z,J,G);for(let Q=0;Q<G;Q++)Y.columnTypes[Q]=this.reader.int16();return Y}parseNotificationMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J=this.reader.cstring(),G=this.reader.cstring();return new L.NotificationResponseMessage(U,Z,J,G)}parseRowDescriptionMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new L.RowDescriptionMessage(U,Z);for(let G=0;G<Z;G++)J.fields[G]=this.parseField();return J}parseField(){const $=this.reader.cstring(),U=this.reader.int32(),X=this.reader.int16(),Z=this.reader.int32(),J=this.reader.int16(),G=this.reader.int32(),Y=this.reader.int16()===0?"text":"binary";return new L.Field($,U,X,Z,J,G,Y)}parseParameterDescriptionMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new L.ParameterDescriptionMessage(U,Z);for(let G=0;G<Z;G++)J.dataTypeIDs[G]=this.reader.int32();return J}parseDataRowMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new Array(Z);for(let G=0;G<Z;G++){const Y=this.reader.int32();J[G]=Y===-1?null:this.reader.string(Y)}return new L.DataRowMessage(U,J)}parseParameterStatusMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.cstring(),J=this.reader.cstring();return new L.ParameterStatusMessage(U,Z,J)}parseBackendKeyData($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J=this.reader.int32();return new L.BackendKeyDataMessage(U,Z,J)}parseAuthenticationResponse($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J={name:"authenticationOk",length:U};switch(Z){case 0:break;case 3:if(J.length===8)J.name="authenticationCleartextPassword";break;case 5:if(J.length===12){J.name="authenticationMD5Password";const Y=this.reader.bytes(4);return new L.AuthenticationMD5Password(U,Y)}break;case 10:J.name="authenticationSASL",J.mechanisms=[];let G;do if(G=this.reader.cstring(),G)J.mechanisms.push(G);while(G);break;case 11:J.name="authenticationSASLContinue",J.data=this.reader.string(U-8);break;case 12:J.name="authenticationSASLFinal",J.data=this.reader.string(U-8);break;default:throw new Error("Unknown authenticationOk message type "+Z)}return J}parseErrorMessage($,U,X,Z){this.reader.setBuffer($,X);const J={};let G=this.reader.string(1);while(G!=="\0")J[G]=this.reader.cstring(),G=this.reader.string(1);const Y=J.M,Q=Z==="notice"?new L.NoticeMessage(U,Y):new L.DatabaseError(Y,U,Z);return Q.severity=J.S,Q.code=J.C,Q.detail=J.D,Q.hint=J.H,Q.position=J.P,Q.internalPosition=J.p,Q.internalQuery=J.q,Q.where=J.W,Q.schema=J.s,Q.table=J.t,Q.column=J.c,Q.dataType=J.d,Q.constraint=J.n,Q.file=J.F,Q.line=J.L,Q.routine=J.R,Q}}h.Parser=S8});var B0=H(($0)=>{var l5=function($,U){const X=new c5.Parser;return $.on("data",(Z)=>X.parse(Z,U)),new Promise((Z)=>$.on("end",()=>Z()))};Object.defineProperty($0,"__esModule",{value:!0});$0.DatabaseError=$0.serialize=$0.parse=void 0;var f5=C0();Object.defineProperty($0,"DatabaseError",{enumerable:!0,get:function(){return f5.DatabaseError}});var g5=L8();Object.defineProperty($0,"serialize",{enumerable:!0,get:function(){return g5.serialize}});var c5=T8();$0.parse=l5});var P8={};z$(P8,{default:()=>{{return i5}}});var i5;var C8=R$(()=>{i5={}});var q8=H((a5,I0)=>{a5.getStream=function $(U){const X=import.meta.require("net");if(typeof X.Socket==="function")return new X.Socket;else{const{CloudflareSocket:Z}=(C8(),c0(P8));return new Z(U)}};a5.getSecureStream=function $(U){var X=import.meta.require("tls");if(X.connect)return X.connect(U);else return U.socket.startTls(U),U.socket}});var x0=H((qU,k8)=>{var CU=import.meta.require("net"),r5=import.meta.require("events").EventEmitter,{parse:e5,serialize:F}=B0(),{getStream:$9,getSecureStream:U9}=q8(),X9=F.flush(),Z9=F.sync(),J9=F.end();class D8 extends r5{constructor($){super();if($=$||{},this.stream=$.stream||$9($.ssl),typeof this.stream==="function")this.stream=this.stream($);this._keepAlive=$.keepAlive,this._keepAliveInitialDelayMillis=$.keepAliveInitialDelayMillis,this.lastBuffer=!1,this.parsedStatements={},this.ssl=$.ssl||!1,this._ending=!1,this._emitMessage=!1;var U=this;this.on("newListener",function(X){if(X==="message")U._emitMessage=!0})}connect($,U){var X=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect($,U),this.stream.once("connect",function(){if(X._keepAlive)X.stream.setKeepAlive(!0,X._keepAliveInitialDelayMillis);X.emit("connect")});const Z=function(J){if(X._ending&&(J.code==="ECONNRESET"||J.code==="EPIPE"))return;X.emit("error",J)};if(this.stream.on("error",Z),this.stream.on("close",function(){X.emit("end")}),!this.ssl)return this.attachListeners(this.stream);this.stream.once("data",function(J){var G=J.toString("utf8");switch(G){case"S":break;case"N":return X.stream.end(),X.emit("error",new Error("The server does not support SSL connections"));default:return X.stream.end(),X.emit("error",new Error("There was an error establishing an SSL connection"))}const Y={socket:X.stream};if(X.ssl!==!0){if(Object.assign(Y,X.ssl),"key"in X.ssl)Y.key=X.ssl.key}var Q=import.meta.require("net");if(Q.isIP&&Q.isIP(U)===0)Y.servername=U;try{X.stream=U9(Y)}catch(j){return X.emit("error",j)}X.attachListeners(X.stream),X.stream.on("error",Z),X.emit("sslconnect")})}attachListeners($){e5($,(U)=>{var X=U.name==="error"?"errorMessage":U.name;if(this._emitMessage)this.emit("message",U);this.emit(X,U)})}requestSsl(){this.stream.write(F.requestSsl())}startup($){this.stream.write(F.startup($))}cancel($,U){this._send(F.cancel($,U))}password($){this._send(F.password($))}sendSASLInitialResponseMessage($,U){this._send(F.sendSASLInitialResponseMessage($,U))}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(X9)}sync(){this._ending=!0,this._send(Z9)}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(J9,()=>{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($))}}k8.exports=D8});var w8=H((DU,x8)=>{var Q9=function($,U,X){let Z;if(this.overflow){if(Z=this[U0].write($).split(this.matcher),Z.length===1)return X();Z.shift(),this.overflow=!1}else this[C]+=this[U0].write($),Z=this[C].split(this.matcher);this[C]=Z.pop();for(let J=0;J<Z.length;J++)try{I8(this,this.mapper(Z[J]))}catch(G){return X(G)}if(this.overflow=this[C].length>this.maxLength,this.overflow&&!this.skipOverflow){X(new Error("maximum buffer reached"));return}X()},j9=function($){if(this[C]+=this[U0].end(),this[C])try{I8(this,this.mapper(this[C]))}catch(U){return $(U)}$()},I8=function($,U){if(U!==void 0)$.push(U)},B8=function($){return $},W9=function($,U,X){switch($=$||/\r?\n/,U=U||B8,X=X||{},arguments.length){case 1:if(typeof $==="function")U=$,$=/\r?\n/;else if(typeof $==="object"&&!($ instanceof RegExp)&&!$[Symbol.split])X=$,$=/\r?\n/;break;case 2:if(typeof $==="function")X=U,U=$,$=/\r?\n/;else if(typeof U==="object")X=U,U=B8}X=Object.assign({},X),X.autoDestroy=!0,X.transform=Q9,X.flush=j9,X.readableObjectMode=!0;const Z=new G9(X);return Z[C]="",Z[U0]=new Y9("utf8"),Z.matcher=$,Z.mapper=U,Z.maxLength=X.maxLength,Z.skipOverflow=X.skipOverflow||!1,Z.overflow=!1,Z._destroy=function(J,G){this._writableState.errorEmitted=!1,G(J)},Z},{Transform:G9}=import.meta.require("stream"),{StringDecoder:Y9}=import.meta.require("string_decoder"),C=Symbol("last"),U0=Symbol("decoder");x8.exports=W9});var v8=H((E9,P)=>{var F9=function($){return($&R9)==L9},h0=function(){var $=o instanceof K9&&o.writable===!0;if($){var U=Array.prototype.slice.call(arguments).concat("\n");o.write(b8.format.apply(b8,U))}},h8=import.meta.require("path"),K9=import.meta.require("stream").Stream,H9=w8(),b8=import.meta.require("util"),O9=5432,X0=process.platform==="win32",o=process.stderr,_9=56,z9=7,R9=61440,L9=32768,b=["host","port","database","user","password"],w0=b.length,M9=b[w0-1];Object.defineProperty(E9,"isWin",{get:function(){return X0},set:function($){X0=$}});E9.warnTo=function($){var U=o;return o=$,U};E9.getFileName=function($){var U=$||process.env,X=U.PGPASSFILE||(X0?h8.join(U.APPDATA||"./","postgresql","pgpass.conf"):h8.join(U.HOME||"./",".pgpass"));return X};E9.usePgPass=function($,U){if(Object.prototype.hasOwnProperty.call(process.env,"PGPASSWORD"))return!1;if(X0)return!0;if(U=U||"<unkn>",!F9($.mode))return h0('WARNING: password file "%s" is not a plain file',U),!1;if($.mode&(_9|z9))return h0('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less',U),!1;return!0};var A9=E9.match=function($,U){return b.slice(0,-1).reduce(function(X,Z,J){if(J==1){if(Number($[Z]||O9)===Number(U[Z]))return X&&!0}return X&&(U[Z]==="*"||U[Z]===$[Z])},!0)};E9.getPassword=function($,U,X){var Z,J=U.pipe(H9());function G(j){var W=N9(j);if(W&&V9(W)&&A9($,W))Z=W[M9],J.end()}var Y=function(){U.destroy(),X(Z)},Q=function(j){U.destroy(),h0("WARNING: error on reading file: %s",j),X(void 0)};U.on("error",Q),J.on("data",G).on("end",Y).on("error",Q)};var N9=E9.parseLine=function($){if($.length<11||$.match(/^\s+#/))return null;var U="",X="",Z=0,J=0,G=0,Y={},Q=!1,j=function(K,O,_){var E=$.substring(O,_);if(!Object.hasOwnProperty.call(process.env,"PGPASS_NO_DEESCAPE"))E=E.replace(/\\([:\\])/g,"$1");Y[b[K]]=E};for(var W=0;W<$.length-1;W+=1){if(U=$.charAt(W+1),X=$.charAt(W),Q=Z==w0-1,Q){j(Z,J);break}if(W>=0&&U==":"&&X!=="\\")j(Z,J,W+1),J=W+2,Z+=1}return Y=Object.keys(Y).length===w0?Y:null,Y},V9=E9.isValidEntry=function($){var U={0:function(Y){return Y.length>0},1:function(Y){if(Y==="*")return!0;return Y=Number(Y),isFinite(Y)&&Y>0&&Y<9007199254740992&&Math.floor(Y)===Y},2:function(Y){return Y.length>0},3:function(Y){return Y.length>0},4:function(Y){return Y.length>0}};for(var X=0;X<b.length;X+=1){var Z=U[X],J=$[b[X]]||"",G=Z(J);if(!G)return!1}return!0}});var d8=H((wU,b0)=>{var xU=import.meta.require("path"),y8=import.meta.require("fs"),Z0=v8();b0.exports=function($,U){var X=Z0.getFileName();y8.stat(X,function(Z,J){if(Z||!Z0.usePgPass(J,X))return U(void 0);var G=y8.createReadStream(X);Z0.getPassword($,G,U)})};b0.exports.warnTo=Z0.warnTo});var f8=H((hU,u8)=>{var q9=import.meta.require("events").EventEmitter,m8=c(),v0=B1(),D9=S0(),k9=P0(),p8=o1(),B9=g(),I9=x0(),x9=E0();class y0 extends q9{constructor($){super();this.connectionParameters=new k9($),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;var U=$||{};if(this._Promise=U.Promise||global.Promise,this._types=new D9(U.types),this._ending=!1,this._ended=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this.connection=U.connection||new I9({stream:U.stream,ssl:this.connectionParameters.ssl,keepAlive:U.keepAlive||!1,keepAliveInitialDelayMillis:U.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||"utf8"}),this.queryQueue=[],this.binary=U.binary||B9.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=U.connectionTimeoutMillis||0}_errorAllQueries($){const U=(X)=>{process.nextTick(()=>{X.handleError($,this.connection)})};if(this.activeQuery)U(this.activeQuery),this.activeQuery=null;this.queryQueue.forEach(U),this.queryQueue.length=0}_connect($){var U=this,X=this.connection;if(this._connectionCallback=$,this._connecting||this._connected){const Z=new Error("Client has already been connected. You cannot reuse a client.");process.nextTick(()=>{$(Z)});return}if(this._connecting=!0,this.connectionTimeoutHandle,this._connectionTimeoutMillis>0)this.connectionTimeoutHandle=setTimeout(()=>{X._ending=!0,X.stream.destroy(new Error("timeout expired"))},this._connectionTimeoutMillis);if(this.host&&this.host.indexOf("/")===0)X.connect(this.host+"/.s.PGSQL."+this.port);else X.connect(this.port,this.host);X.on("connect",function(){if(U.ssl)X.requestSsl();else X.startup(U.getStartupConf())}),X.on("sslconnect",function(){X.startup(U.getStartupConf())}),this._attachListeners(X),X.once("end",()=>{const Z=this._ending?new Error("Connection terminated"):new Error("Connection terminated unexpectedly");if(clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(Z),this._ended=!0,!this._ending){if(this._connecting&&!this._connectionError)if(this._connectionCallback)this._connectionCallback(Z);else this._handleErrorEvent(Z);else if(!this._connectionError)this._handleErrorEvent(Z)}process.nextTick(()=>{this.emit("end")})})}connect($){if($){this._connect($);return}return new this._Promise((U,X)=>{this._connect((Z)=>{if(Z)X(Z);else U()})})}_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))}_checkPgPass($){const U=this.connection;if(typeof this.password==="function")this._Promise.resolve().then(()=>this.password()).then((X)=>{if(X!==void 0){if(typeof X!=="string"){U.emit("error",new TypeError("Password must be a string"));return}this.connectionParameters.password=this.password=X}else this.connectionParameters.password=this.password=null;$()}).catch((X)=>{U.emit("error",X)});else if(this.password!==null)$();else try{d8()(this.connectionParameters,(Z)=>{if(Z!==void 0)this.connectionParameters.password=this.password=Z;$()})}catch(X){this.emit("error",X)}}_handleAuthCleartextPassword($){this._checkPgPass(()=>{this.connection.password(this.password)})}_handleAuthMD5Password($){this._checkPgPass(async()=>{try{const U=await x9.postgresMd5PasswordHash(this.user,this.password,$.salt);this.connection.password(U)}catch(U){this.emit("error",U)}})}_handleAuthSASL($){this._checkPgPass(()=>{try{this.saslSession=v0.startSession($.mechanisms),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)}catch(U){this.connection.emit("error",U)}})}async _handleAuthSASLContinue($){try{await v0.continueSession(this.saslSession,this.password,$.data),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}catch(U){this.connection.emit("error",U)}}_handleAuthSASLFinal($){try{v0.finalizeSession(this.saslSession,$.data),this.saslSession=null}catch(U){this.connection.emit("error",U)}}_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")}const{activeQuery:U}=this;if(this.activeQuery=null,this.readyForQuery=!0,U)U.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($);const U=this.activeQuery;if(!U){this._handleErrorEvent($);return}this.activeQuery=null,U.handleError($,this.connection)}_handleRowDescription($){this.activeQuery.handleRowDescription($)}_handleDataRow($){this.activeQuery.handleDataRow($)}_handlePortalSuspended($){this.activeQuery.handlePortalSuspended(this.connection)}_handleEmptyQuery($){this.activeQuery.handleEmptyQuery(this.connection)}_handleCommandComplete($){this.activeQuery.handleCommandComplete($,this.connection)}_handleParseComplete($){if(this.activeQuery.name)this.connection.parsedStatements[this.activeQuery.name]=this.activeQuery.text}_handleCopyInResponse($){this.activeQuery.handleCopyInResponse(this.connection)}_handleCopyData($){this.activeQuery.handleCopyData($,this.connection)}_handleNotification($){this.emit("notification",$)}_handleNotice($){this.emit("notice",$)}getStartupConf(){var $=this.connectionParameters,U={user:$.user,database:$.database},X=$.application_name||$.fallback_application_name;if(X)U.application_name=X;if($.replication)U.replication=""+$.replication;if($.statement_timeout)U.statement_timeout=String(parseInt($.statement_timeout,10));if($.lock_timeout)U.lock_timeout=String(parseInt($.lock_timeout,10));if($.idle_in_transaction_session_timeout)U.idle_in_transaction_session_timeout=String(parseInt($.idle_in_transaction_session_timeout,10));if($.options)U.options=$.options;return U}cancel($,U){if($.activeQuery===U){var X=this.connection;if(this.host&&this.host.indexOf("/")===0)X.connect(this.host+"/.s.PGSQL."+this.port);else X.connect(this.port,this.host);X.on("connect",function(){X.cancel($.processID,$.secretKey)})}else if($.queryQueue.indexOf(U)!==-1)$.queryQueue.splice($.queryQueue.indexOf(U),1)}setTypeParser($,U,X){return this._types.setTypeParser($,U,X)}getTypeParser($,U){return this._types.getTypeParser($,U)}escapeIdentifier($){return m8.escapeIdentifier($)}escapeLiteral($){return m8.escapeLiteral($)}_pulseQueryQueue(){if(this.readyForQuery===!0){if(this.activeQuery=this.queryQueue.shift(),this.activeQuery){this.readyForQuery=!1,this.hasExecuted=!0;const $=this.activeQuery.submit(this.connection);if($)process.nextTick(()=>{this.activeQuery.handleError($,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else if(this.hasExecuted)this.activeQuery=null,this.emit("drain")}}query($,U,X){var Z,J,G,Y,Q;if($===null||$===void 0)throw new TypeError("Client was passed a null or undefined query");else if(typeof $.submit==="function"){if(G=$.query_timeout||this.connectionParameters.query_timeout,J=Z=$,typeof U==="function")Z.callback=Z.callback||U}else if(G=this.connectionParameters.query_timeout,Z=new p8($,U,X),!Z.callback)J=new this._Promise((j,W)=>{Z.callback=(K,O)=>K?W(K):j(O)}).catch((j)=>{throw Error.captureStackTrace(j),j});if(G)Q=Z.callback,Y=setTimeout(()=>{var j=new Error("Query read timeout");process.nextTick(()=>{Z.handleError(j,this.connection)}),Q(j),Z.callback=()=>{};var W=this.queryQueue.indexOf(Z);if(W>-1)this.queryQueue.splice(W,1);this._pulseQueryQueue()},G),Z.callback=(j,W)=>{clearTimeout(Y),Q(j,W)};if(this.binary&&!Z.binary)Z.binary=!0;if(Z._result&&!Z._result._types)Z._result._types=this._types;if(!this._queryable)return process.nextTick(()=>{Z.handleError(new Error("Client has encountered a connection error and is not queryable"),this.connection)}),J;if(this._ending)return process.nextTick(()=>{Z.handleError(new Error("Client was closed and is not queryable"),this.connection)}),J;return this.queryQueue.push(Z),this._pulseQueryQueue(),J}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.activeQuery||!this._queryable)this.connection.stream.destroy();else this.connection.end();if($)this.connection.once("end",$);else return new this._Promise((U)=>{this.connection.once("end",U)})}}y0.Query=p8;u8.exports=y0});var i8=H((bU,n8)=>{var h9=function(){throw new Error("Release called on client which has already been released to the pool.")},J0=function($,U){if(U)return{callback:U,result:void 0};let X,Z;const J=function(Y,Q){Y?X(Y):Z(Q)},G=new $(function(Y,Q){Z=Y,X=Q}).catch((Y)=>{throw Error.captureStackTrace(Y),Y});return{callback:J,result:G}},b9=function($,U){return function X(Z){Z.client=U,U.removeListener("error",X),U.on("error",()=>{$.log("additional client error after disconnection due to error",Z)}),$._remove(U),$.emit("error",Z,U)}},w9=import.meta.require("events").EventEmitter,g8=function(){},c8=($,U)=>{const X=$.findIndex(U);return X===-1?void 0:$.splice(X,1)[0]};class l8{constructor($,U,X){this.client=$,this.idleListener=U,this.timeoutId=X}}class n{constructor($){this.callback=$}}class o8 extends w9{constructor($,U){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.maxUses=this.options.maxUses||Infinity,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||U||d0().Client,this.Promise=this.options.Promise||global.Promise,typeof this.options.idleTimeoutMillis==="undefined")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}_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((U)=>{this._remove(U.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;const $=this._pendingQueue.shift();if(this._idle.length){const U=this._idle.pop();clearTimeout(U.timeoutId);const X=U.client;X.ref&&X.ref();const Z=U.idleListener;return this._acquireClient(X,$,Z,!1)}if(!this._isFull())return this.newClient($);throw new Error("unexpected condition")}_remove($){const U=c8(this._idle,(X)=>X.client===$);if(U!==void 0)clearTimeout(U.timeoutId);this._clients=this._clients.filter((X)=>X!==$),$.end(),this.emit("remove",$)}connect($){if(this.ending){const Z=new Error("Cannot use a pool after calling end on the pool");return $?$(Z):this.Promise.reject(Z)}const U=J0(this.Promise,$),X=U.result;if(this._isFull()||this._idle.length){if(this._idle.length)process.nextTick(()=>this._pulseQueue());if(!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new n(U.callback)),X;const Z=(Y,Q,j)=>{clearTimeout(G),U.callback(Y,Q,j)},J=new n(Z),G=setTimeout(()=>{c8(this._pendingQueue,(Y)=>Y.callback===Z),J.timedOut=!0,U.callback(new Error("timeout exceeded when trying to connect"))},this.options.connectionTimeoutMillis);return this._pendingQueue.push(J),X}return this.newClient(new n(U.callback)),X}newClient($){const U=new this.Client(this.options);this._clients.push(U);const X=b9(this,U);this.log("checking client timeout");let Z,J=!1;if(this.options.connectionTimeoutMillis)Z=setTimeout(()=>{this.log("ending client due to timeout"),J=!0,U.connection?U.connection.stream.destroy():U.end()},this.options.connectionTimeoutMillis);this.log("connecting new client"),U.connect((G)=>{if(Z)clearTimeout(Z);if(U.on("error",X),G){if(this.log("client failed to connect",G),this._clients=this._clients.filter((Y)=>Y!==U),J)G.message="Connection terminated due to connection timeout";if(this._pulseQueue(),!$.timedOut)$.callback(G,void 0,g8)}else{if(this.log("new client connected"),this.options.maxLifetimeSeconds!==0){const Y=setTimeout(()=>{if(this.log("ending client due to expired lifetime"),this._expired.add(U),this._idle.findIndex((j)=>j.client===U)!==-1)this._acquireClient(U,new n((j,W,K)=>K()),X,!1)},this.options.maxLifetimeSeconds*1000);Y.unref(),U.once("end",()=>clearTimeout(Y))}return this._acquireClient(U,$,X,!0)}})}_acquireClient($,U,X,Z){if(Z)this.emit("connect",$);if(this.emit("acquire",$),$.release=this._releaseOnce($,X),$.removeListener("error",X),!U.timedOut)if(Z&&this.options.verify)this.options.verify($,(J)=>{if(J)return $.release(J),U.callback(J,void 0,g8);U.callback(void 0,$,$.release)});else U.callback(void 0,$,$.release);else if(Z&&this.options.verify)this.options.verify($,$.release);else $.release()}_releaseOnce($,U){let X=!1;return(Z)=>{if(X)h9();X=!0,this._release($,U,Z)}}_release($,U,X){if($.on("error",U),$._poolUseCount=($._poolUseCount||0)+1,this.emit("release",X,$),X||this.ending||!$._queryable||$._ending||$._poolUseCount>=this.options.maxUses){if($._poolUseCount>=this.options.maxUses)this.log("remove expended client");this._remove($),this._pulseQueue();return}if(this._expired.has($)){this.log("remove expired client"),this._expired.delete($),this._remove($),this._pulseQueue();return}let J;if(this.options.idleTimeoutMillis){if(J=setTimeout(()=>{this.log("remove idle client"),this._remove($)},this.options.idleTimeoutMillis),this.options.allowExitOnIdle)J.unref()}if(this.options.allowExitOnIdle)$.unref();this._idle.push(new l8($,U,J)),this._pulseQueue()}query($,U,X){if(typeof $==="function"){const J=J0(this.Promise,$);return setImmediate(function(){return J.callback(new Error("Passing a function as the first parameter to pool.query is not supported"))}),J.result}if(typeof U==="function")X=U,U=void 0;const Z=J0(this.Promise,X);return X=Z.callback,this.connect((J,G)=>{if(J)return X(J);let Y=!1;const Q=(j)=>{if(Y)return;Y=!0,G.release(j),X(j)};G.once("error",Q),this.log("dispatching query");try{G.query($,U,(j,W)=>{if(this.log("query dispatched"),G.removeListener("error",Q),Y)return;if(Y=!0,G.release(j),j)return X(j);return X(void 0,W)})}catch(j){return G.release(j),X(j)}}),Z.result}end($){if(this.log("ending"),this.ending){const X=new Error("Called end on pool more than once");return $?$(X):this.Promise.reject(X)}this.ending=!0;const U=J0(this.Promise,$);return this._endCallback=U.callback,this._pulseQueue(),U.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce(($,U)=>$+(this._expired.has(U)?1:0),0)}get totalCount(){return this._clients.length}}n8.exports=o8});var s8=H((vU,t8)=>{var a8=import.meta.require("events").EventEmitter,v9=import.meta.require("util"),m0=c(),v=t8.exports=function($,U,X){a8.call(this),$=m0.normalizeQueryConfig($,U,X),this.text=$.text,this.values=$.values,this.name=$.name,this.callback=$.callback,this.state="new",this._arrayMode=$.rowMode==="array",this._emitRowEvents=!1,this.on("newListener",function(Z){if(Z==="row")this._emitRowEvents=!0}.bind(this))};v9.inherits(v,a8);var y9={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"file",sourceLine:"line",sourceFunction:"routine"};v.prototype.handleError=function($){var U=this.native.pq.resultErrorFields();if(U)for(var X in U){var Z=y9[X]||X;$[Z]=U[X]}if(this.callback)this.callback($);else this.emit("error",$);this.state="error"};v.prototype.then=function($,U){return this._getPromise().then($,U)};v.prototype.catch=function($){return this._getPromise().catch($)};v.prototype._getPromise=function(){if(this._promise)return this._promise;return this._promise=new Promise(function($,U){this._once("end",$),this._once("error",U)}.bind(this)),this._promise};v.prototype.submit=function($){this.state="running";var U=this;this.native=$.native,$.native.arrayMode=this._arrayMode;var X=function(G,Y,Q){if($.native.arrayMode=!1,setImmediate(function(){U.emit("_done")}),G)return U.handleError(G);if(U._emitRowEvents)if(Q.length>1)Y.forEach((j,W)=>{j.forEach((K)=>{U.emit("row",K,Q[W])})});else Y.forEach(function(j){U.emit("row",j,Q)});if(U.state="end",U.emit("end",Q),U.callback)U.callback(null,Q)};if(process.domain)X=process.domain.bind(X);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");var Z=(this.values||[]).map(m0.prepareValue);if($.namedQueries[this.name]){if(this.text&&$.namedQueries[this.name]!==this.text){const G=new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return X(G)}return $.native.execute(this.name,Z,X)}return $.native.prepare(this.name,this.text,Z.length,function(G){if(G)return X(G);return $.namedQueries[U.name]=U.text,U.native.execute(U.name,Z,X)})}else if(this.values){if(!Array.isArray(this.values)){const G=new Error("Query values must be an array");return X(G)}var J=this.values.map(m0.prepareValue);$.native.query(this.text,J,X)}else $.native.query(this.text,X)}});var p0=H((yU,U$)=>{var r8;try{r8=(()=>{throw new Error(`Cannot require module "pg-native"`);})()}catch($){throw $}var d9=S0(),e8=import.meta.require("events").EventEmitter,m9=import.meta.require("util"),p9=P0(),$$=s8(),V=U$.exports=function($){e8.call(this),$=$||{},this._Promise=$.Promise||global.Promise,this._types=new d9($.types),this.native=new r8({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;var U=this.connectionParameters=new p9($);if($.nativeConnectionString)U.nativeConnectionString=$.nativeConnectionString;this.user=U.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:U.password}),this.database=U.database,this.host=U.host,this.port=U.port,this.namedQueries={}};V.Query=$$;m9.inherits(V,e8);V.prototype._errorAllQueries=function($){const U=(X)=>{process.nextTick(()=>{X.native=this.native,X.handleError($)})};if(this._hasActiveQuery())U(this._activeQuery),this._activeQuery=null;this._queryQueue.forEach(U),this._queryQueue.length=0};V.prototype._connect=function($){var U=this;if(this._connecting){process.nextTick(()=>$(new Error("Client has already been connected. You cannot reuse a client.")));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(X,Z){if(U.connectionParameters.nativeConnectionString)Z=U.connectionParameters.nativeConnectionString;if(X)return $(X);U.native.connect(Z,function(J){if(J)return U.native.end(),$(J);U._connected=!0,U.native.on("error",function(G){U._queryable=!1,U._errorAllQueries(G),U.emit("error",G)}),U.native.on("notification",function(G){U.emit("notification",{channel:G.relname,payload:G.extra})}),U.emit("connect"),U._pulseQueryQueue(!0),$()})})};V.prototype.connect=function($){if($){this._connect($);return}return new this._Promise((U,X)=>{this._connect((Z)=>{if(Z)X(Z);else U()})})};V.prototype.query=function($,U,X){var Z,J,G,Y,Q;if($===null||$===void 0)throw new TypeError("Client was passed a null or undefined query");else if(typeof $.submit==="function"){if(G=$.query_timeout||this.connectionParameters.query_timeout,J=Z=$,typeof U==="function")$.callback=U}else if(G=this.connectionParameters.query_timeout,Z=new $$($,U,X),!Z.callback){let j,W;J=new this._Promise((K,O)=>{j=K,W=O}).catch((K)=>{throw Error.captureStackTrace(K),K}),Z.callback=(K,O)=>K?W(K):j(O)}if(G)Q=Z.callback,Y=setTimeout(()=>{var j=new Error("Query read timeout");process.nextTick(()=>{Z.handleError(j,this.connection)}),Q(j),Z.callback=()=>{};var W=this._queryQueue.indexOf(Z);if(W>-1)this._queryQueue.splice(W,1);this._pulseQueryQueue()},G),Z.callback=(j,W)=>{clearTimeout(Y),Q(j,W)};if(!this._queryable)return Z.native=this.native,process.nextTick(()=>{Z.handleError(new Error("Client has encountered a connection error and is not queryable"))}),J;if(this._ending)return Z.native=this.native,process.nextTick(()=>{Z.handleError(new Error("Client was closed and is not queryable"))}),J;return this._queryQueue.push(Z),this._pulseQueryQueue(),J};V.prototype.end=function($){var U=this;if(this._ending=!0,!this._connected)this.once("connect",this.end.bind(this,$));var X;if(!$)X=new this._Promise(function(Z,J){$=(G)=>G?J(G):Z()});return this.native.end(function(){U._errorAllQueries(new Error("Connection terminated")),process.nextTick(()=>{if(U.emit("end"),$)$()})}),X};V.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!=="error"&&this._activeQuery.state!=="end"};V.prototype._pulseQueryQueue=function($){if(!this._connected)return;if(this._hasActiveQuery())return;var U=this._queryQueue.shift();if(!U){if(!$)this.emit("drain");return}this._activeQuery=U,U.submit(this);var X=this;U.once("_done",function(){X._pulseQueryQueue()})};V.prototype.cancel=function($){if(this._activeQuery===$)this.native.cancel(function(){});else if(this._queryQueue.indexOf($)!==-1)this._queryQueue.splice(this._queryQueue.indexOf($),1)};V.prototype.ref=function(){};V.prototype.unref=function(){};V.prototype.setTypeParser=function($,U,X){return this._types.setTypeParser($,U,X)};V.prototype.getTypeParser=function($,U){return this._types.getTypeParser($,U)}});var d0=H((dU,i)=>{var u9=f8(),f9=g(),g9=x0(),c9=i8(),{DatabaseError:l9}=B0(),{escapeIdentifier:o9,escapeLiteral:n9}=c(),i9=($)=>{return class U extends c9{constructor(X){super(X,$)}}},u0=function($){this.defaults=f9,this.Client=$,this.Query=this.Client.Query,this.Pool=i9(this.Client),this._pools=[],this.Connection=g9,this.types=f(),this.DatabaseError=l9,this.escapeIdentifier=o9,this.escapeLiteral=n9};if(typeof process.env.NODE_PG_FORCE_NATIVE!=="undefined")i.exports=new u0(p0());else i.exports=new u0(u9),Object.defineProperty(i.exports,"native",{configurable:!0,enumerable:!1,get(){var $=null;try{$=new u0(p0())}catch(U){if(U.code!=="MODULE_NOT_FOUND")throw U}return Object.defineProperty(i.exports,"native",{value:$}),$}})});var X$=_$(d0(),1),D=new X$.Pool({host:"0.0.0.0",port:5432,user:"postgres",password:"123",database:"rinha"});function Z$($,U){if(typeof $!=="number"||$<1)U.status=422;return U}function J$($,U,X){if(typeof $!=="number"||$<1)X.status=422;if(!U.valor||typeof U.valor!=="number"||U.valor<1||!Number.isInteger(U.valor))X.status=422;if(!U.tipo||typeof U.tipo!=="string"||!["c","d"].includes(U.tipo))X.status=422;if(!U.descricao||typeof U.descricao!=="string"||U.descricao.length<1||U.descricao.length>10)X.status=422;return X}async function G$($,U){if(Z$($,U).status!==200)return;const Z=(await D.query("SELECT * FROM customers WHERE id = $1",[$])).rows[0];if(!Z){U.status=404;return}const J=(await D.query("SELECT * FROM transacoes WHERE customerId = $1 ORDER BY realizada_em DESC LIMIT 10",[$])).rows;return{saldo:{total:Z.saldo,data_extrato:(new Date()).toISOString(),limite:Z.limite},ultimas_transacoes:J}}async function Y$($,U,X){if(J$($,U,X).status!==200)return;const J=(await D.query("SELECT * FROM customers WHERE id = $1",[$])).rows[0];if(!J){X.status=404;return}let G=0;if(U.tipo==="d"){const Y=await D.query("SELECT * FROM debit ($1, $2, $3)",[$,U.valor,U.descricao]),{saldofinal:Q,error:j}=Y.rows[0];if(j)return X.status=422,"saldo insuficente";G=Q}if(U.tipo==="c")G=(await D.query("SELECT * FROM credit ($1, $2, $3)",[$,U.valor,U.descricao])).rows[0].saldofinal;return{limite:J.limite,saldo:G}}var Q$=new RegExp(/clientes\/(\d+)\/extrato/),j$=new RegExp(/clientes\/(\d+)\/transacoes/),a9=async($)=>{const U=new URL($.url),X={status:200};if($.method==="GET"&&Q$.test(U.pathname)){const Z=+Q$.exec(U.pathname)[1],J=await G$(Z,X);return{status:X.status,body:J}}if($.method==="POST"&&j$.test(U.pathname)){const Z=+j$.exec(U.pathname)[1],J=await $.json(),G=await Y$(Z,J,X);return{status:X.status,body:G}}},W$=Bun.env.PORT;Bun.serve({port:W$,async fetch($){const U=await a9($);if(!U)return new Response(null,{status:404});return new Response(JSON.stringify(U.body),{status:U.status})}});console.log(`Server is running at on port ${W$}...`);
api01-1 | ^
api01-1 | ECONNREFUSED: Failed to connect
api01-1 | syscall: "connect"
api01-1 |
api01-1 | at /home/bun/app/index.js:3:121740
api01-1 | at promiseReactionJob (native:1:1)
api01-1 | at processTicksAndRejections (native:1:1)
api01-1 | 2 | // @bun
api01-1 | 3 | var K$=Object.create;var{defineProperty:y,getPrototypeOf:H$,getOwnPropertyNames:f0,getOwnPropertyDescriptor:O$}=Object,g0=Object.prototype.hasOwnProperty;var _$=($,U,X)=>{X=$!=null?K$(H$($)):{};const Z=U||!$||!$.__esModule?y(X,"default",{value:$,enumerable:!0}):X;for(let J of f0($))if(!g0.call(Z,J))y(Z,J,{get:()=>$[J],enumerable:!0});return Z},c0=($)=>{const U=c0.moduleCache??=new WeakMap;var X=U.get($);if(X)return X;var Z=y({},"__esModule",{value:!0}),J={enumerable:!1};if($&&typeof $==="object"||typeof $==="function"){for(let G of f0($))if(!g0.call(Z,G))y(Z,G,{get:()=>$[G],enumerable:!(J=O$($,G))||J.enumerable})}return U.set($,Z),Z};var H=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports);var z$=($,U)=>{for(var X in U)y($,X,{get:U[X],enumerable:!0,configurable:!0,set:(Z)=>U[X]=()=>Z})};var R$=($,U)=>()=>($&&(U=$($=0)),U);var j0=H((F$)=>{var L$=function($){return $};F$.parse=function($,U){return new Q0($,U).parse()};class Q0{constructor($,U){this.source=$,this.transform=U||L$,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 U;if(this.recorded.length>0||$){if(U=this.recorded.join(""),U==="NULL"&&!$)U=null;if(U!==null)U=this.transform(U);this.entries.push(U),this.recorded=[]}}consumeDimensions(){if(this.source[0]==="[")while(!this.isEof()){var $=this.nextCharacter();if($.value==="=")break}}parse($){var U,X,Z;this.consumeDimensions();while(!this.isEof())if(U=this.nextCharacter(),U.value==="{"&&!Z){if(this.dimension++,this.dimension>1)X=new Q0(this.source.substr(this.position-1),this.transform),this.entries.push(X.parse(!0)),this.position+=X.position-2}else if(U.value==="}"&&!Z){if(this.dimension--,!this.dimension){if(this.newEntry(),$)return this.entries}}else if(U.value==='"'&&!U.escaped){if(Z)this.newEntry(!0);Z=!Z}else if(U.value===","&&!Z)this.newEntry();else this.record(U.value);if(this.dimension!==0)throw new Error("array dimension not balanced");return this.entries}}});var W0=H((r9,l0)=>{var A$=j0();l0.exports={create:function($,U){return{parse:function(){return A$.parse($,U)}}}}});var i0=H((e9,n0)=>{var T$=function($){var U=V$.exec($);if(!U)return;var X=parseInt(U[1],10),Z=!!U[4];if(Z)X=o0(X);var J=parseInt(U[2],10)-1,G=U[3],Y=new Date(X,J,G);if(K0(X))Y.setFullYear(X);return Y},P$=function($){if($.endsWith("+00"))return 0;var U=E$.exec($.split(" ")[1]);if(!U)return;var X=U[1];if(X==="Z")return 0;var Z=X==="-"?-1:1,J=parseInt(U[2],10)*3600+parseInt(U[3]||0,10)*60+parseInt(U[4]||0,10);return J*Z*1000},o0=function($){return-($-1)},K0=function($){return $>=0&&$<100},N$=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,V$=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,E$=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,S$=/^-?infinity$/;n0.exports=function $(U){if(S$.test(U))return Number(U.replace("i","I"));var X=N$.exec(U);if(!X)return T$(U)||null;var Z=!!X[8],J=parseInt(X[1],10);if(Z)J=o0(J);var G=parseInt(X[2],10)-1,Y=X[3],Q=parseInt(X[4],10),j=parseInt(X[5],10),W=parseInt(X[6],10),K=X[7];K=K?1000*parseFloat(K):0;var O,_=P$(U);if(_!=null){if(O=new Date(Date.UTC(J,G,Y,Q,j,W,K)),K0(J))O.setUTCFullYear(J);if(_!==0)O.setTime(O.getTime()-_)}else if(O=new Date(J,G,Y,Q,j,W,K),K0(J))O.setFullYear(J);return O}});var t0=H(($U,a0)=>{var q$=function($){for(var U=1;U<arguments.length;U++){var X=arguments[U];for(var Z in X)if(C$.call(X,Z))$[Z]=X[Z]}return $};a0.exports=q$;var C$=Object.prototype.hasOwnProperty});var e0=H((UU,r0)=>{var k=function($){if(!(this instanceof k))return new k($);D$(this,p$($))},m$=function($){var U=$+"000000".slice($.length);return parseInt(U,10)/1000},p$=function($){if(!$)return{};var U=y$.exec($),X=U[8]==="-";return Object.keys(s0).reduce(function(Z,J){var G=s0[J],Y=U[G];if(!Y)return Z;if(Y=J==="milliseconds"?m$(Y):parseInt(Y,10),!Y)return Z;if(X&&~d$.indexOf(J))Y*=-1;return Z[J]=Y,Z},{})},D$=t0();r0.exports=k;var k$=["seconds","minutes","hours","days","months","years"];k.prototype.toPostgres=function(){var $=k$.filter(this.hasOwnProperty,this);if(this.milliseconds&&$.indexOf("seconds")<0)$.push("seconds");if($.length===0)return"0";return $.map(function(U){var X=this[U]||0;if(U==="seconds"&&this.milliseconds)X=(X+this.milliseconds/1000).toFixed(6).replace(/\.?0+$/,"");return X+" "+U},this).join(" ")};var B$={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"S"},I$=["years","months","days"],x$=["hours","minutes","seconds"];k.prototype.toISOString=k.prototype.toISO=function(){var $=I$.map(X,this).join(""),U=x$.map(X,this).join("");return"P"+$+"T"+U;function X(Z){var J=this[Z]||0;if(Z==="seconds"&&this.milliseconds)J=(J+this.milliseconds/1000).toFixed(6).replace(/0+$/,"");return J+B$[Z]}};var H0="([+-]?\\d+)",w$=H0+"\\s+years?",h$=H0+"\\s+mons?",b$=H0+"\\s+days?",v$="([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",y$=new RegExp([w$,h$,b$,v$].map(function($){return"("+$+")?"}).join("\\s*")),s0={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},d$=["hours","minutes","seconds","milliseconds"]});var U1=H((XU,$1)=>{$1.exports=function $(U){if(/^\\x/.test(U))return new Buffer(U.substr(2),"hex");var X="",Z=0;while(Z<U.length)if(U[Z]!=="\\")X+=U[Z],++Z;else if(/[0-7]{3}/.test(U.substr(Z+1,3)))X+=String.fromCharCode(parseInt(U.substr(Z+1,3),8)),Z+=4;else{var J=1;while(Z+J<U.length&&U[Z+J]==="\\")J++;for(var G=0;G<Math.floor(J/2);++G)X+="\\";Z+=Math.floor(J/2)*2}return new Buffer(X,"binary")}});var j1=H((ZU,Q1)=>{var t=function($){return function U(X){if(X===null)return X;return $(X)}},G1=function($){if($===null)return $;return $==="TRUE"||$==="t"||$==="true"||$==="y"||$==="yes"||$==="on"||$==="1"},u$=function($){if(!$)return null;return d.parse($,G1)},f$=function($){return parseInt($,10)},O0=function($){if(!$)return null;return d.parse($,t(f$))},g$=function($){if(!$)return null;return d.parse($,t(function(U){return Y1(U).trim()}))},d=j0(),m=W0(),a=i0(),Z1=e0(),J1=U1(),c$=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=L0(X);return X});return U.parse()},_0=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=parseFloat(X);return X});return U.parse()},S=function($){if(!$)return null;var U=m.create($);return U.parse()},z0=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=a(X);return X});return U.parse()},l$=function($){if(!$)return null;var U=m.create($,function(X){if(X!==null)X=Z1(X);return X});return U.parse()},o$=function($){if(!$)return null;return d.parse($,t(J1))},R0=function($){return parseInt($,10)},Y1=function($){var U=String($);if(/^\d+$/.test(U))return U;return $},X1=function($){if(!$)return null;return d.parse($,t(JSON.parse))},L0=function($){if($[0]!=="(")return null;return $=$.substring(1,$.length-1).split(","),{x:parseFloat($[0]),y:parseFloat($[1])}},n$=function($){if($[0]!=="<"&&$[1]!=="(")return null;var U="(",X="",Z=!1;for(var J=2;J<$.length-1;J++){if(!Z)U+=$[J];if($[J]===")"){Z=!0;continue}else if(!Z)continue;if($[J]===",")continue;X+=$[J]}var G=L0(U);return G.radius=parseFloat(X),G},i$=function($){$(20,Y1),$(21,R0),$(23,R0),$(26,R0),$(700,parseFloat),$(701,parseFloat),$(16,G1),$(1082,a),$(1114,a),$(1184,a),$(600,L0),$(651,S),$(718,n$),$(1000,u$),$(1001,o$),$(1005,O0),$(1007,O0),$(1028,O0),$(1016,g$),$(1017,c$),$(1021,_0),$(1022,_0),$(1231,_0),$(1014,S),$(1015,S),$(1008,S),$(1009,S),$(1040,S),$(1041,S),$(1115,z0),$(1182,z0),$(1185,z0),$(1186,Z1),$(1187,l$),$(17,J1),$(114,JSON.parse.bind(JSON)),$(3802,JSON.parse.bind(JSON)),$(199,X1),$(3807,X1),$(3907,S),$(2951,S),$(791,S),$(1183,S),$(1270,S)};Q1.exports={init:i$}});var K1=H((JU,W1)=>{var a$=function($){var U=$.readInt32BE(0),X=$.readUInt32BE(4),Z="";if(U<0)U=~U+(X===0),X=~X+1>>>0,Z="-";var J="",G,Y,Q,j,W,K;{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}{if(G=U%N,U=U/N>>>0,Y=4294967296*G+X,X=Y/N>>>0,Q=""+(Y-N*X),X===0&&U===0)return Z+Q+J;j="",W=6-Q.length;for(K=0;K<W;K++)j+="0";J=j+Q+J}return G=U%N,Y=4294967296*G+X,Q=""+Y%N,Z+Q+J},N=1e6;W1.exports=a$});var R1=H((GU,z1)=>{var t$=K1(),z=function($,U,X,Z,J){X=X||0,Z=Z||!1,J=J||function(E,G0,Y0){return E*Math.pow(2,Y0)+G0};var G=X>>3,Y=function(E){if(Z)return~E&255;return E},Q=255,j=8-X%8;if(U<j)Q=255<<8-U&255,j=U;if(X)Q=Q>>X%8;var W=0;if(X%8+U>=8)W=J(0,Y($[G])&Q,j);var K=U+X>>3;for(var O=G+1;O<K;O++)W=J(W,Y($[O]),8);var _=(U+X)%8;if(_>0)W=J(W,Y($[K])>>8-_,_);return W},_1=function($,U,X){var Z=Math.pow(2,X-1)-1,J=z($,1),G=z($,X,1);if(G===0)return 0;var Y=1,Q=function(W,K,O){if(W===0)W=1;for(var _=1;_<=O;_++)if(Y/=2,(K&1<<O-_)>0)W+=Y;return W},j=z($,U,X+1,!1,Q);if(G==Math.pow(2,X+1)-1){if(j===0)return J===0?Infinity:(-Infinity);return NaN}return(J===0?1:-1)*Math.pow(2,G-Z)*j},s$=function($){if(z($,1)==1)return-1*(z($,15,1,!0)+1);return z($,15,1)},H1=function($){if(z($,1)==1)return-1*(z($,31,1,!0)+1);return z($,31,1)},r$=function($){return _1($,23,8)},e$=function($){return _1($,52,11)},$4=function($){var U=z($,16,32);if(U==49152)return NaN;var X=Math.pow(1e4,z($,16,16)),Z=0,J=[],G=z($,16);for(var Y=0;Y<G;Y++)Z+=z($,16,64+16*Y)*X,X/=1e4;var Q=Math.pow(10,z($,16,48));return(U===0?1:-1)*Math.round(Z*Q)/Q},O1=function($,U){var X=z(U,1),Z=z(U,63,1),J=new Date((X===0?1:-1)*Z/1000+946684800000);if(!$)J.setTime(J.getTime()+J.getTimezoneOffset()*60000);return J.usec=Z%1000,J.getMicroSeconds=function(){return this.usec},J.setMicroSeconds=function(G){this.usec=G},J.getUTCMicroSeconds=function(){return this.usec},J},p=function($){var U=z($,32),X=z($,32,32),Z=z($,32,64),J=96,G=[];for(var Y=0;Y<U;Y++)G[Y]=z($,32,J),J+=32,J+=32;var Q=function(W){var K=z($,32,J);if(J+=32,K==4294967295)return null;var O;if(W==23||W==20)return O=z($,K*8,J),J+=K*8,O;else if(W==25)return O=$.toString(this.encoding,J>>3,(J+=K<<3)>>3),O;else console.log("ERROR: ElementType not implemented: "+W)},j=function(W,K){var O=[],_;if(W.length>1){var E=W.shift();for(_=0;_<E;_++)O[_]=j(W,K);W.unshift(E)}else for(_=0;_<W[0];_++)O[_]=Q(K);return O};return j(G,Z)},U4=function($){return $.toString("utf8")},X4=function($){if($===null)return null;return z($,8)>0},Z4=function($){$(20,t$),$(21,s$),$(23,H1),$(26,H1),$(1700,$4),$(700,r$),$(701,e$),$(16,X4),$(1114,O1.bind(null,!1)),$(1184,O1.bind(null,!0)),$(1000,p),$(1007,p),$(1016,p),$(1008,p),$(1009,p),$(25,U4)};z1.exports={init:Z4}});var F1=H((YU,L1)=>{L1.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 f=H((K4)=>{var M1=function($){return String($)},j4=function($,U){if(U=U||"text",!u[U])return M1;return u[U][$]||M1},W4=function($,U,X){if(typeof U=="function")X=U,U="text";u[U][$]=X},J4=j1(),G4=R1(),Y4=W0(),Q4=F1();K4.getTypeParser=j4;K4.setTypeParser=W4;K4.arrayParser=Y4;K4.builtins=Q4;var u={text:{},binary:{}};J4.init(function($,U){u.text[$]=U});G4.init(function($,U){u.binary[$]=U})});var g=H((jU,F0)=>{F0.exports={host:"localhost",user:process.platform==="win32"?process.env.USERNAME:process.env.USER,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 B=f(),R4=B.getTypeParser(20,"text"),L4=B.getTypeParser(1016,"text");F0.exports.__defineSetter__("parseInt8",function($){B.setTypeParser(20,"text",$?B.getTypeParser(23,"text"):R4),B.setTypeParser(1016,"text",$?B.getTypeParser(1007,"text"):L4)})});var c=H((WU,N1)=>{var M4=function($){var U=$.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return'"'+U+'"'},A1=function($){var U="{";for(var X=0;X<$.length;X++){if(X>0)U=U+",";if($[X]===null||typeof $[X]==="undefined")U=U+"NULL";else if(Array.isArray($[X]))U=U+A1($[X]);else if($[X]instanceof Buffer)U+="\\\\x"+$[X].toString("hex");else U+=M4(s($[X]))}return U=U+"}",U},A4=function($,U){if($&&typeof $.toPostgres==="function"){if(U=U||[],U.indexOf($)!==-1)throw new Error('circular reference detected while preparing "'+$+'" for query');return U.push($),s($.toPostgres(s),U)}return JSON.stringify($)},M=function($,U){$=""+$;while($.length<U)$="0"+$;return $},N4=function($){var U=-$.getTimezoneOffset(),X=$.getFullYear(),Z=X<1;if(Z)X=Math.abs(X)+1;var J=M(X,4)+"-"+M($.getMonth()+1,2)+"-"+M($.getDate(),2)+"T"+M($.getHours(),2)+":"+M($.getMinutes(),2)+":"+M($.getSeconds(),2)+"."+M($.getMilliseconds(),3);if(U<0)J+="-",U*=-1;else J+="+";if(J+=M(Math.floor(U/60),2)+":"+M(U%60,2),Z)J+=" BC";return J},V4=function($){var U=$.getUTCFullYear(),X=U<1;if(X)U=Math.abs(U)+1;var Z=M(U,4)+"-"+M($.getUTCMonth()+1,2)+"-"+M($.getUTCDate(),2)+"T"+M($.getUTCHours(),2)+":"+M($.getUTCMinutes(),2)+":"+M($.getUTCSeconds(),2)+"."+M($.getUTCMilliseconds(),3);if(Z+="+00:00",X)Z+=" BC";return Z},E4=function($,U,X){if($=typeof $==="string"?{text:$}:$,U)if(typeof U==="function")$.callback=U;else $.values=U;if(X)$.callback=X;return $},F4=g(),s=function($,U){if($==null)return null;if($ instanceof Buffer)return $;if(ArrayBuffer.isView($)){var X=Buffer.from($.buffer,$.byteOffset,$.byteLength);if(X.length===$.byteLength)return X;return X.slice($.byteOffset,$.byteOffset+$.byteLength)}if($ instanceof Date)if(F4.parseInputDatesAsUTC)return V4($);else return N4($);if(Array.isArray($))return A1($);if(typeof $==="object")return A4($,U);return $.toString()},S4=function($){return'"'+$.replace(/"/g,'""')+'"'},T4=function($){var U=!1,X="'";for(var Z=0;Z<$.length;Z++){var J=$[Z];if(J==="'")X+=J+J;else if(J==="\\")X+=J+J,U=!0;else X+=J}if(X+="'",U===!0)X=" E"+X;return X};N1.exports={prepareValue:function $(U){return s(U)},normalizeQueryConfig:E4,escapeIdentifier:S4,escapeLiteral:T4}});var E1=H((KU,V1)=>{var M0=function($){return l.createHash("md5").update($,"utf-8").digest("hex")},P4=function($,U,X){var Z=M0(U+$),J=M0(Buffer.concat([Buffer.from(Z),X]));return"md5"+J},C4=function($){return l.createHash("sha256").update($).digest()},q4=function($,U){return l.createHmac("sha256",$).update(U).digest()};async function D4($,U,X){return l.pbkdf2Sync($,U,X,32,"sha256")}var l=import.meta.require("crypto");V1.exports={postgresMd5PasswordHash:P4,randomBytes:l.randomBytes,deriveKey:D4,sha256:C4,hmacSha256:q4,md5:M0}});var C1=H((HU,P1)=>{var k4=function($){return T1.getRandomValues(Buffer.alloc($))};async function A0($){try{return S1.createHash("md5").update($,"utf-8").digest("hex")}catch(U){const X=typeof $==="string"?N0.encode($):$,Z=await I.digest("MD5",X);return Array.from(new Uint8Array(Z)).map((J)=>J.toString(16).padStart(2,"0")).join("")}}async function B4($,U,X){var Z=await A0(U+$),J=await A0(Buffer.concat([Buffer.from(Z),X]));return"md5"+J}async function I4($){return await I.digest("SHA-256",$)}async function x4($,U){const X=await I.importKey("raw",$,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return await I.sign("HMAC",X,N0.encode(U))}async function w4($,U,X){const Z=await I.importKey("raw",N0.encode($),"PBKDF2",!1,["deriveBits"]),J={name:"PBKDF2",hash:"SHA-256",salt:U,iterations:X};return await I.deriveBits(J,Z,256,["deriveBits"])}var S1=import.meta.require("crypto");P1.exports={postgresMd5PasswordHash:B4,randomBytes:k4,deriveKey:w4,sha256:I4,hmacSha256:x4,md5:A0};var T1=S1.webcrypto||globalThis.crypto,I=T1.subtle,N0=new TextEncoder});var E0=H((OU,V0)=>{var h4=parseInt(process.versions&&process.versions.node&&process.versions.node.split(".")[0])<15;if(h4)V0.exports=E1();else V0.exports=C1()});var B1=H((_U,k1)=>{var b4=function($){if($.indexOf("SCRAM-SHA-256")===-1)throw new Error("SASL: Only mechanism SCRAM-SHA-256 is currently supported");const U=q.randomBytes(18).toString("base64");return{mechanism:"SCRAM-SHA-256",clientNonce:U,response:"n,,n=*,r="+U,message:"SASLInitialResponse"}};async function v4($,U,X){if($.message!=="SASLInitialResponse")throw new Error("SASL: Last message was not SASLInitialResponse");if(typeof U!=="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");if(U==="")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string");if(typeof X!=="string")throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");const Z=m4(X);if(!Z.nonce.startsWith($.clientNonce))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");else if(Z.nonce.length===$.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short");var J="n=*,r="+$.clientNonce,G="r="+Z.nonce+",s="+Z.salt+",i="+Z.iteration,Y="c=biws,r="+Z.nonce,Q=J+","+G+","+Y,j=Buffer.from(Z.salt,"base64"),W=await q.deriveKey(U,j,Z.iteration),K=await q.hmacSha256(W,"Client Key"),O=await q.sha256(K),_=await q.hmacSha256(O,Q),E=u4(Buffer.from(K),Buffer.from(_)).toString("base64"),G0=await q.hmacSha256(W,"Server Key"),Y0=await q.hmacSha256(G0,Q);$.message="SASLResponse",$.serverSignature=Buffer.from(Y0).toString("base64"),$.response=Y+",p="+E}var y4=function($,U){if($.message!=="SASLResponse")throw new Error("SASL: Last message was not SASLResponse");if(typeof U!=="string")throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");const{serverSignature:X}=p4(U);if(X!==$.serverSignature)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match")},d4=function($){if(typeof $!=="string")throw new TypeError("SASL: text must be a string");return $.split("").map((U,X)=>$.charCodeAt(X)).every((U)=>U>=33&&U<=43||U>=45&&U<=126)},q1=function($){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test($)},D1=function($){if(typeof $!=="string")throw new TypeError("SASL: attribute pairs text must be a string");return new Map($.split(",").map((U)=>{if(!/^.=/.test(U))throw new Error("SASL: Invalid attribute pair entry");const X=U[0],Z=U.substring(2);return[X,Z]}))},m4=function($){const U=D1($),X=U.get("r");if(!X)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing");else if(!d4(X))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters");const Z=U.get("s");if(!Z)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing");else if(!q1(Z))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64");const J=U.get("i");if(!J)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing");else if(!/^[1-9][0-9]*$/.test(J))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count");const G=parseInt(J,10);return{nonce:X,salt:Z,iteration:G}},p4=function($){const X=D1($).get("v");if(!X)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");else if(!q1(X))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64");return{serverSignature:X}},u4=function($,U){if(!Buffer.isBuffer($))throw new TypeError("first argument must be a Buffer");if(!Buffer.isBuffer(U))throw new TypeError("second argument must be a Buffer");if($.length!==U.length)throw new Error("Buffer lengths must match");if($.length===0)throw new Error("Buffers cannot be empty");return Buffer.from($.map((X,Z)=>$[Z]^U[Z]))},q=E0();k1.exports={startSession:b4,continueSession:v4,finalizeSession:y4}});var S0=H((zU,I1)=>{var r=function($){this._types=$||f4,this.text={},this.binary={}},f4=f();r.prototype.getOverrides=function($){switch($){case"text":return this.text;case"binary":return this.binary;default:return{}}};r.prototype.setTypeParser=function($,U,X){if(typeof U==="function")X=U,U="text";this.getOverrides(U)[$]=X};r.prototype.getTypeParser=function($,U){return U=U||"text",this.getOverrides(U)[$]||this._types.getTypeParser($,U)};I1.exports=r});var w1=H((RU,x1)=>{var T0=function($){if($.charAt(0)==="/"){const Q=$.split(" ");return{host:Q[0],database:Q[1]}}const U={};let X,Z=!1;if(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test($))$=encodeURI($).replace(/\%25(\d\d)/g,"%$1");try{X=new URL($,"postgres://base")}catch(Q){X=new URL($.replace("@/","@___DUMMY___/"),"postgres://base"),Z=!0}for(let Q of X.searchParams.entries())U[Q[0]]=Q[1];if(U.user=U.user||decodeURIComponent(X.username),U.password=U.password||decodeURIComponent(X.password),X.protocol=="socket:")return U.host=decodeURI(X.pathname),U.database=X.searchParams.get("db"),U.client_encoding=X.searchParams.get("encoding"),U;const J=Z?"":X.hostname;if(!U.host)U.host=decodeURIComponent(J);else if(J&&/^%2f/i.test(J))X.pathname=J+X.pathname;if(!U.port)U.port=X.port;const G=X.pathname.slice(1)||null;if(U.database=G?decodeURI(G):null,U.ssl==="true"||U.ssl==="1")U.ssl=!0;if(U.ssl==="0")U.ssl=!1;if(U.sslcert||U.sslkey||U.sslrootcert||U.sslmode)U.ssl={};const Y=U.sslcert||U.sslkey||U.sslrootcert?import.meta.require("fs"):null;if(U.sslcert)U.ssl.cert=Y.readFileSync(U.sslcert).toString();if(U.sslkey)U.ssl.key=Y.readFileSync(U.sslkey).toString();if(U.sslrootcert)U.ssl.ca=Y.readFileSync(U.sslrootcert).toString();switch(U.sslmode){case"disable":{U.ssl=!1;break}case"prefer":case"require":case"verify-ca":case"verify-full":break;case"no-verify":{U.ssl.rejectUnauthorized=!1;break}}return U};x1.exports=T0;T0.parse=T0});var P0=H((LU,y1)=>{var g4=import.meta.require("dns"),b1=g(),h1=w1().parse,A=function($,U,X){if(X===void 0)X=process.env["PG"+$.toUpperCase()];else if(X===!1);else X=process.env[X];return U[$]||X||b1[$]},c4=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 b1.ssl},x=function($){return"'"+(""+$).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},T=function($,U,X){var Z=U[X];if(Z!==void 0&&Z!==null)$.push(X+"="+x(Z))};class v1{constructor($){if($=typeof $==="string"?h1($):$||{},$.connectionString)$=Object.assign({},$,h1($.connectionString));if(this.user=A("user",$),this.database=A("database",$),this.database===void 0)this.database=this.user;if(this.port=parseInt(A("port",$),10),this.host=A("host",$),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:A("password",$)}),this.binary=A("binary",$),this.options=A("options",$),this.ssl=typeof $.ssl==="undefined"?c4():$.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=A("client_encoding",$),this.replication=A("replication",$),this.isDomainSocket=!(this.host||"").indexOf("/"),this.application_name=A("application_name",$,"PGAPPNAME"),this.fallback_application_name=A("fallback_application_name",$,!1),this.statement_timeout=A("statement_timeout",$,!1),this.lock_timeout=A("lock_timeout",$,!1),this.idle_in_transaction_session_timeout=A("idle_in_transaction_session_timeout",$,!1),this.query_timeout=A("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($){var U=[];T(U,this,"user"),T(U,this,"password"),T(U,this,"port"),T(U,this,"application_name"),T(U,this,"fallback_application_name"),T(U,this,"connect_timeout"),T(U,this,"options");var X=typeof this.ssl==="object"?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(T(U,X,"sslmode"),T(U,X,"sslca"),T(U,X,"sslkey"),T(U,X,"sslcert"),T(U,X,"sslrootcert"),this.database)U.push("dbname="+x(this.database));if(this.replication)U.push("replication="+x(this.replication));if(this.host)U.push("host="+x(this.host));if(this.isDomainSocket)return $(null,U.join(" "));if(this.client_encoding)U.push("client_encoding="+x(this.client_encoding));g4.lookup(this.host,function(Z,J){if(Z)return $(Z,null);return U.push("hostaddr="+x(J)),$(null,U.join(" "))})}}y1.exports=v1});var u1=H((FU,p1)=>{var l4=f(),d1=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/;class m1{constructor($,U){if(this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0,this._types=U,this.RowCtor=null,this.rowAsArray=$==="array",this.rowAsArray)this.parseRow=this._parseRowAsArray;this._prebuiltEmptyResultObject=null}addCommandComplete($){var U;if($.text)U=d1.exec($.text);else U=d1.exec($.command);if(U){if(this.command=U[1],U[3])this.oid=parseInt(U[2],10),this.rowCount=parseInt(U[3],10);else if(U[2])this.rowCount=parseInt(U[2],10)}}_parseRowAsArray($){var U=new Array($.length);for(var X=0,Z=$.length;X<Z;X++){var J=$[X];if(J!==null)U[X]=this._parsers[X](J);else U[X]=null}return U}parseRow($){var U={...this._prebuiltEmptyResultObject};for(var X=0,Z=$.length;X<Z;X++){var J=$[X],G=this.fields[X].name;if(J!==null)U[G]=this._parsers[X](J)}return U}addRow($){this.rows.push($)}addFields($){if(this.fields=$,this.fields.length)this._parsers=new Array($.length);for(var U=0;U<$.length;U++){var X=$[U];if(this._types)this._parsers[U]=this._types.getTypeParser(X.dataTypeID,X.format||"text");else this._parsers[U]=l4.getTypeParser(X.dataTypeID,X.format||"text")}this._createPrebuiltEmptyResultObject()}_createPrebuiltEmptyResultObject(){var $={};for(var U=0;U<this.fields.length;U++)$[this.fields[U].name]=null;this._prebuiltEmptyResultObject={...$}}}p1.exports=m1});var o1=H((MU,l1)=>{var{EventEmitter:o4}=import.meta.require("events"),f1=u1(),g1=c();class c1 extends o4{constructor($,U,X){super();if($=g1.normalizeQueryConfig($,U,X),this.text=$.text,this.values=$.values,this.rows=$.rows,this.types=$.types,this.name=$.name,this.binary=$.binary,this.portal=$.portal||"",this.callback=$.callback,this._rowMode=$.rowMode,process.domain&&$.callback)this.callback=process.domain.bind($.callback);this._result=new f1(this._rowMode,this.types),this._results=this._result,this.isPreparedStatement=!1,this._canceledDueToError=!1,this._promise=null}requiresPreparation(){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 f1(this._rowMode,this.types),this._results.push(this._result)}}handleRowDescription($){this._checkForMultirow(),this._result.addFields($.fields),this._accumulateRows=this.callback||!this.listeners("row").length}handleDataRow($){let U;if(this._canceledDueToError)return;try{U=this._result.parseRow($.fields)}catch(X){this._canceledDueToError=X;return}if(this.emit("row",U,this._result),this._accumulateRows)this._result.addRow(U)}handleCommandComplete($,U){if(this._checkForMultirow(),this._result.addCommandComplete($),this.rows)U.sync()}handleEmptyQuery($){if(this.rows)$.sync()}handleError($,U){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(U){process.nextTick(()=>{throw U})}this.emit("end",this._results)}submit($){if(typeof this.text!=="string"&&typeof this.name!=="string")return new Error("A query must have either text or a name. Supplying neither is unsupported.");const U=$.parsedStatements[this.name];if(this.text&&U&&this.text!==U)return new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);if(this.values&&!Array.isArray(this.values))return new Error("Query values must be an array");if(this.requiresPreparation())this.prepare($);else $.query(this.text);return null}hasBeenParsed($){return this.name&&$.parsedStatements[this.name]}handlePortalSuspended($){this._getRows($,this.rows)}_getRows($,U){if($.execute({portal:this.portal,rows:U}),!U)$.sync();else $.flush()}prepare($){if(this.isPreparedStatement=!0,!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:g1.prepareValue})}catch(U){this.handleError(U,$);return}$.describe({type:"P",name:this.portal||""}),this._getRows($,this.rows)}handleCopyInResponse($){$.sendCopyFail("No source stream defined")}handleCopyData($,U){}}l1.exports=c1});var C0=H((Q8)=>{Object.defineProperty(Q8,"__esModule",{value:!0});Q8.NoticeMessage=Q8.DataRowMessage=Q8.CommandCompleteMessage=Q8.ReadyForQueryMessage=Q8.NotificationResponseMessage=Q8.BackendKeyDataMessage=Q8.AuthenticationMD5Password=Q8.ParameterStatusMessage=Q8.ParameterDescriptionMessage=Q8.RowDescriptionMessage=Q8.Field=Q8.CopyResponse=Q8.CopyDataMessage=Q8.DatabaseError=Q8.copyDone=Q8.emptyQuery=Q8.replicationStart=Q8.portalSuspended=Q8.noData=Q8.closeComplete=Q8.bindComplete=Q8.parseComplete=void 0;Q8.parseComplete={name:"parseComplete",length:5};Q8.bindComplete={name:"bindComplete",length:5};Q8.closeComplete={name:"closeComplete",length:5};Q8.noData={name:"noData",length:5};Q8.portalSuspended={name:"portalSuspended",length:5};Q8.replicationStart={name:"replicationStart",length:4};Q8.emptyQuery={name:"emptyQuery",length:4};Q8.copyDone={name:"copyDone",length:4};class n1 extends Error{constructor($,U,X){super($);this.length=U,this.name=X}}Q8.DatabaseError=n1;class i1{constructor($,U){this.length=$,this.chunk=U,this.name="copyData"}}Q8.CopyDataMessage=i1;class a1{constructor($,U,X,Z){this.length=$,this.name=U,this.binary=X,this.columnTypes=new Array(Z)}}Q8.CopyResponse=a1;class t1{constructor($,U,X,Z,J,G,Y){this.name=$,this.tableID=U,this.columnID=X,this.dataTypeID=Z,this.dataTypeSize=J,this.dataTypeModifier=G,this.format=Y}}Q8.Field=t1;class s1{constructor($,U){this.length=$,this.fieldCount=U,this.name="rowDescription",this.fields=new Array(this.fieldCount)}}Q8.RowDescriptionMessage=s1;class r1{constructor($,U){this.length=$,this.parameterCount=U,this.name="parameterDescription",this.dataTypeIDs=new Array(this.parameterCount)}}Q8.ParameterDescriptionMessage=r1;class e1{constructor($,U,X){this.length=$,this.parameterName=U,this.parameterValue=X,this.name="parameterStatus"}}Q8.ParameterStatusMessage=e1;class $8{constructor($,U){this.length=$,this.salt=U,this.name="authenticationMD5Password"}}Q8.AuthenticationMD5Password=$8;class U8{constructor($,U,X){this.length=$,this.processID=U,this.secretKey=X,this.name="backendKeyData"}}Q8.BackendKeyDataMessage=U8;class X8{constructor($,U,X,Z){this.length=$,this.processId=U,this.channel=X,this.payload=Z,this.name="notification"}}Q8.NotificationResponseMessage=X8;class Z8{constructor($,U){this.length=$,this.status=U,this.name="readyForQuery"}}Q8.ReadyForQueryMessage=Z8;class J8{constructor($,U){this.length=$,this.text=U,this.name="commandComplete"}}Q8.CommandCompleteMessage=J8;class G8{constructor($,U){this.length=$,this.fields=U,this.name="dataRow",this.fieldCount=U.length}}Q8.DataRowMessage=G8;class Y8{constructor($,U){this.length=$,this.message=U,this.name="notice"}}Q8.NoticeMessage=Y8});var O8=H((K8)=>{Object.defineProperty(K8,"__esModule",{value:!0});K8.Writer=void 0;class W8{constructor($=256){this.size=$,this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe($)}ensure($){var U=this.buffer.length-this.offset;if(U<$){var X=this.buffer,Z=X.length+(X.length>>1)+$;this.buffer=Buffer.allocUnsafe(Z),X.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{var U=Buffer.byteLength($);this.ensure(U+1),this.buffer.write($,this.offset,"utf-8"),this.offset+=U}return this.buffer[this.offset++]=0,this}addString($=""){var U=Buffer.byteLength($);return this.ensure(U),this.buffer.write($,this.offset),this.offset+=U,this}add($){return this.ensure($.length),$.copy(this.buffer,this.offset),this.offset+=$.length,this}join($){if($){this.buffer[this.headerPosition]=$;const U=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(U,this.headerPosition+1)}return this.buffer.slice($?0:5,this.offset)}flush($){var U=this.join($);return this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(this.size),U}}K8.Writer=W8});var L8=H((z8)=>{Object.defineProperty(z8,"__esModule",{value:!0});z8.serialize=void 0;var q0=O8(),R=new q0.Writer,z5=($)=>{R.addInt16(3).addInt16(0);for(let Z of Object.keys($))R.addCString(Z).addCString($[Z]);R.addCString("client_encoding").addCString("UTF8");var U=R.addCString("").flush(),X=U.length+4;return new q0.Writer().addInt32(X).add(U).flush()},R5=()=>{const $=Buffer.allocUnsafe(8);return $.writeInt32BE(8,0),$.writeInt32BE(80877103,4),$},L5=($)=>{return R.addCString($).flush(112)},F5=function($,U){return R.addCString($).addInt32(Buffer.byteLength(U)).addString(U),R.flush(112)},M5=function($){return R.addString($).flush(112)},A5=($)=>{return R.addCString($).flush(81)},_8=[],N5=($)=>{const U=$.name||"";if(U.length>63)console.error("Warning! Postgres only supports 63 characters for query names."),console.error("You supplied %s (%s)",U,U.length),console.error("This can cause conflicts and silent errors executing queries");const X=$.types||_8;var Z=X.length,J=R.addCString(U).addCString($.text).addInt16(Z);for(var G=0;G<Z;G++)J.addInt32(X[G]);return R.flush(80)},w=new q0.Writer,V5=function($,U){for(let X=0;X<$.length;X++){const Z=U?U($[X],X):$[X];if(Z==null)R.addInt16(0),w.addInt32(-1);else if(Z instanceof Buffer)R.addInt16(1),w.addInt32(Z.length),w.add(Z);else R.addInt16(0),w.addInt32(Buffer.byteLength(Z)),w.addString(Z)}},E5=($={})=>{const U=$.portal||"",X=$.statement||"",Z=$.binary||!1,J=$.values||_8,G=J.length;return R.addCString(U).addCString(X),R.addInt16(G),V5(J,$.valueMapper),R.addInt16(G),R.add(w.flush()),R.addInt16(Z?1:0),R.flush(66)},S5=Buffer.from([69,0,0,0,9,0,0,0,0,0]),T5=($)=>{if(!$||!$.portal&&!$.rows)return S5;const U=$.portal||"",X=$.rows||0,Z=Buffer.byteLength(U),J=4+Z+1+4,G=Buffer.allocUnsafe(1+J);return G[0]=69,G.writeInt32BE(J,1),G.write(U,5,"utf-8"),G[Z+5]=0,G.writeUInt32BE(X,G.length-4),G},P5=($,U)=>{const X=Buffer.allocUnsafe(16);return X.writeInt32BE(16,0),X.writeInt16BE(1234,4),X.writeInt16BE(5678,6),X.writeInt32BE($,8),X.writeInt32BE(U,12),X},D0=($,U)=>{const Z=4+Buffer.byteLength(U)+1,J=Buffer.allocUnsafe(1+Z);return J[0]=$,J.writeInt32BE(Z,1),J.write(U,5,"utf-8"),J[Z]=0,J},C5=R.addCString("P").flush(68),q5=R.addCString("S").flush(68),D5=($)=>{return $.name?D0(68,`${$.type}${$.name||""}`):$.type==="P"?C5:q5},k5=($)=>{const U=`${$.type}${$.name||""}`;return D0(67,U)},B5=($)=>{return R.add($).flush(100)},I5=($)=>{return D0(102,$)},e=($)=>Buffer.from([$,0,0,0,4]),x5=e(72),w5=e(83),h5=e(88),b5=e(99),v5={startup:z5,password:L5,requestSsl:R5,sendSASLInitialResponseMessage:F5,sendSCRAMClientFinalMessage:M5,query:A5,parse:N5,bind:E5,execute:T5,describe:D5,close:k5,flush:()=>x5,sync:()=>w5,end:()=>h5,copyData:B5,copyDone:()=>b5,copyFail:I5,cancel:P5};z8.serialize=v5});var N8=H((M8)=>{Object.defineProperty(M8,"__esModule",{value:!0});M8.BufferReader=void 0;var y5=Buffer.allocUnsafe(0);class F8{constructor($=0){this.offset=$,this.buffer=y5,this.encoding="utf-8"}setBuffer($,U){this.offset=$,this.buffer=U}int16(){const $=this.buffer.readInt16BE(this.offset);return this.offset+=2,$}byte(){const $=this.buffer[this.offset];return this.offset++,$}int32(){const $=this.buffer.readInt32BE(this.offset);return this.offset+=4,$}string($){const U=this.buffer.toString(this.encoding,this.offset,this.offset+$);return this.offset+=$,U}cstring(){const $=this.offset;let U=$;while(this.buffer[U++]!==0);return this.offset=U,this.buffer.toString(this.encoding,$,U-1)}bytes($){const U=this.buffer.slice(this.offset,this.offset+$);return this.offset+=$,U}}M8.BufferReader=F8});var T8=H((h)=>{var d5=h&&h.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(h,"__esModule",{value:!0});h.Parser=void 0;var L=C0(),m5=N8(),p5=d5(import.meta.require("assert")),k0=1,u5=4,V8=k0+u5,E8=Buffer.allocUnsafe(0);class S8{constructor($){if(this.buffer=E8,this.bufferLength=0,this.bufferOffset=0,this.reader=new m5.BufferReader,($===null||$===void 0?void 0:$.mode)==="binary")throw new Error("Binary mode not supported yet");this.mode=($===null||$===void 0?void 0:$.mode)||"text"}parse($,U){this.mergeBuffer($);const X=this.bufferOffset+this.bufferLength;let Z=this.bufferOffset;while(Z+V8<=X){const J=this.buffer[Z],G=this.buffer.readUInt32BE(Z+k0),Y=k0+G;if(Y+Z<=X){const Q=this.handlePacket(Z+V8,J,G,this.buffer);U(Q),Z+=Y}else break}if(Z===X)this.buffer=E8,this.bufferLength=0,this.bufferOffset=0;else this.bufferLength=X-Z,this.bufferOffset=Z}mergeBuffer($){if(this.bufferLength>0){const U=this.bufferLength+$.byteLength;if(U+this.bufferOffset>this.buffer.byteLength){let Z;if(U<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)Z=this.buffer;else{let J=this.buffer.byteLength*2;while(U>=J)J*=2;Z=Buffer.allocUnsafe(J)}this.buffer.copy(Z,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=Z,this.bufferOffset=0}$.copy(this.buffer,this.bufferOffset+this.bufferLength),this.bufferLength=U}else this.buffer=$,this.bufferOffset=0,this.bufferLength=$.byteLength}handlePacket($,U,X,Z){switch(U){case 50:return L.bindComplete;case 49:return L.parseComplete;case 51:return L.closeComplete;case 110:return L.noData;case 115:return L.portalSuspended;case 99:return L.copyDone;case 87:return L.replicationStart;case 73:return L.emptyQuery;case 68:return this.parseDataRowMessage($,X,Z);case 67:return this.parseCommandCompleteMessage($,X,Z);case 90:return this.parseReadyForQueryMessage($,X,Z);case 65:return this.parseNotificationMessage($,X,Z);case 82:return this.parseAuthenticationResponse($,X,Z);case 83:return this.parseParameterStatusMessage($,X,Z);case 75:return this.parseBackendKeyData($,X,Z);case 69:return this.parseErrorMessage($,X,Z,"error");case 78:return this.parseErrorMessage($,X,Z,"notice");case 84:return this.parseRowDescriptionMessage($,X,Z);case 116:return this.parseParameterDescriptionMessage($,X,Z);case 71:return this.parseCopyInMessage($,X,Z);case 72:return this.parseCopyOutMessage($,X,Z);case 100:return this.parseCopyData($,X,Z);default:p5.default.fail(`unknown message code: ${U.toString(16)}`)}}parseReadyForQueryMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.string(1);return new L.ReadyForQueryMessage(U,Z)}parseCommandCompleteMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.cstring();return new L.CommandCompleteMessage(U,Z)}parseCopyData($,U,X){const Z=X.slice($,$+(U-4));return new L.CopyDataMessage(U,Z)}parseCopyInMessage($,U,X){return this.parseCopyMessage($,U,X,"copyInResponse")}parseCopyOutMessage($,U,X){return this.parseCopyMessage($,U,X,"copyOutResponse")}parseCopyMessage($,U,X,Z){this.reader.setBuffer($,X);const J=this.reader.byte()!==0,G=this.reader.int16(),Y=new L.CopyResponse(U,Z,J,G);for(let Q=0;Q<G;Q++)Y.columnTypes[Q]=this.reader.int16();return Y}parseNotificationMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J=this.reader.cstring(),G=this.reader.cstring();return new L.NotificationResponseMessage(U,Z,J,G)}parseRowDescriptionMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new L.RowDescriptionMessage(U,Z);for(let G=0;G<Z;G++)J.fields[G]=this.parseField();return J}parseField(){const $=this.reader.cstring(),U=this.reader.int32(),X=this.reader.int16(),Z=this.reader.int32(),J=this.reader.int16(),G=this.reader.int32(),Y=this.reader.int16()===0?"text":"binary";return new L.Field($,U,X,Z,J,G,Y)}parseParameterDescriptionMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new L.ParameterDescriptionMessage(U,Z);for(let G=0;G<Z;G++)J.dataTypeIDs[G]=this.reader.int32();return J}parseDataRowMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int16(),J=new Array(Z);for(let G=0;G<Z;G++){const Y=this.reader.int32();J[G]=Y===-1?null:this.reader.string(Y)}return new L.DataRowMessage(U,J)}parseParameterStatusMessage($,U,X){this.reader.setBuffer($,X);const Z=this.reader.cstring(),J=this.reader.cstring();return new L.ParameterStatusMessage(U,Z,J)}parseBackendKeyData($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J=this.reader.int32();return new L.BackendKeyDataMessage(U,Z,J)}parseAuthenticationResponse($,U,X){this.reader.setBuffer($,X);const Z=this.reader.int32(),J={name:"authenticationOk",length:U};switch(Z){case 0:break;case 3:if(J.length===8)J.name="authenticationCleartextPassword";break;case 5:if(J.length===12){J.name="authenticationMD5Password";const Y=this.reader.bytes(4);return new L.AuthenticationMD5Password(U,Y)}break;case 10:J.name="authenticationSASL",J.mechanisms=[];let G;do if(G=this.reader.cstring(),G)J.mechanisms.push(G);while(G);break;case 11:J.name="authenticationSASLContinue",J.data=this.reader.string(U-8);break;case 12:J.name="authenticationSASLFinal",J.data=this.reader.string(U-8);break;default:throw new Error("Unknown authenticationOk message type "+Z)}return J}parseErrorMessage($,U,X,Z){this.reader.setBuffer($,X);const J={};let G=this.reader.string(1);while(G!=="\0")J[G]=this.reader.cstring(),G=this.reader.string(1);const Y=J.M,Q=Z==="notice"?new L.NoticeMessage(U,Y):new L.DatabaseError(Y,U,Z);return Q.severity=J.S,Q.code=J.C,Q.detail=J.D,Q.hint=J.H,Q.position=J.P,Q.internalPosition=J.p,Q.internalQuery=J.q,Q.where=J.W,Q.schema=J.s,Q.table=J.t,Q.column=J.c,Q.dataType=J.d,Q.constraint=J.n,Q.file=J.F,Q.line=J.L,Q.routine=J.R,Q}}h.Parser=S8});var B0=H(($0)=>{var l5=function($,U){const X=new c5.Parser;return $.on("data",(Z)=>X.parse(Z,U)),new Promise((Z)=>$.on("end",()=>Z()))};Object.defineProperty($0,"__esModule",{value:!0});$0.DatabaseError=$0.serialize=$0.parse=void 0;var f5=C0();Object.defineProperty($0,"DatabaseError",{enumerable:!0,get:function(){return f5.DatabaseError}});var g5=L8();Object.defineProperty($0,"serialize",{enumerable:!0,get:function(){return g5.serialize}});var c5=T8();$0.parse=l5});var P8={};z$(P8,{default:()=>{{return i5}}});var i5;var C8=R$(()=>{i5={}});var q8=H((a5,I0)=>{a5.getStream=function $(U){const X=import.meta.require("net");if(typeof X.Socket==="function")return new X.Socket;else{const{CloudflareSocket:Z}=(C8(),c0(P8));return new Z(U)}};a5.getSecureStream=function $(U){var X=import.meta.require("tls");if(X.connect)return X.connect(U);else return U.socket.startTls(U),U.socket}});var x0=H((qU,k8)=>{var CU=import.meta.require("net"),r5=import.meta.require("events").EventEmitter,{parse:e5,serialize:F}=B0(),{getStream:$9,getSecureStream:U9}=q8(),X9=F.flush(),Z9=F.sync(),J9=F.end();class D8 extends r5{constructor($){super();if($=$||{},this.stream=$.stream||$9($.ssl),typeof this.stream==="function")this.stream=this.stream($);this._keepAlive=$.keepAlive,this._keepAliveInitialDelayMillis=$.keepAliveInitialDelayMillis,this.lastBuffer=!1,this.parsedStatements={},this.ssl=$.ssl||!1,this._ending=!1,this._emitMessage=!1;var U=this;this.on("newListener",function(X){if(X==="message")U._emitMessage=!0})}connect($,U){var X=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect($,U),this.stream.once("connect",function(){if(X._keepAlive)X.stream.setKeepAlive(!0,X._keepAliveInitialDelayMillis);X.emit("connect")});const Z=function(J){if(X._ending&&(J.code==="ECONNRESET"||J.code==="EPIPE"))return;X.emit("error",J)};if(this.stream.on("error",Z),this.stream.on("close",function(){X.emit("end")}),!this.ssl)return this.attachListeners(this.stream);this.stream.once("data",function(J){var G=J.toString("utf8");switch(G){case"S":break;case"N":return X.stream.end(),X.emit("error",new Error("The server does not support SSL connections"));default:return X.stream.end(),X.emit("error",new Error("There was an error establishing an SSL connection"))}const Y={socket:X.stream};if(X.ssl!==!0){if(Object.assign(Y,X.ssl),"key"in X.ssl)Y.key=X.ssl.key}var Q=import.meta.require("net");if(Q.isIP&&Q.isIP(U)===0)Y.servername=U;try{X.stream=U9(Y)}catch(j){return X.emit("error",j)}X.attachListeners(X.stream),X.stream.on("error",Z),X.emit("sslconnect")})}attachListeners($){e5($,(U)=>{var X=U.name==="error"?"errorMessage":U.name;if(this._emitMessage)this.emit("message",U);this.emit(X,U)})}requestSsl(){this.stream.write(F.requestSsl())}startup($){this.stream.write(F.startup($))}cancel($,U){this._send(F.cancel($,U))}password($){this._send(F.password($))}sendSASLInitialResponseMessage($,U){this._send(F.sendSASLInitialResponseMessage($,U))}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(X9)}sync(){this._ending=!0,this._send(Z9)}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(J9,()=>{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($))}}k8.exports=D8});var w8=H((DU,x8)=>{var Q9=function($,U,X){let Z;if(this.overflow){if(Z=this[U0].write($).split(this.matcher),Z.length===1)return X();Z.shift(),this.overflow=!1}else this[C]+=this[U0].write($),Z=this[C].split(this.matcher);this[C]=Z.pop();for(let J=0;J<Z.length;J++)try{I8(this,this.mapper(Z[J]))}catch(G){return X(G)}if(this.overflow=this[C].length>this.maxLength,this.overflow&&!this.skipOverflow){X(new Error("maximum buffer reached"));return}X()},j9=function($){if(this[C]+=this[U0].end(),this[C])try{I8(this,this.mapper(this[C]))}catch(U){return $(U)}$()},I8=function($,U){if(U!==void 0)$.push(U)},B8=function($){return $},W9=function($,U,X){switch($=$||/\r?\n/,U=U||B8,X=X||{},arguments.length){case 1:if(typeof $==="function")U=$,$=/\r?\n/;else if(typeof $==="object"&&!($ instanceof RegExp)&&!$[Symbol.split])X=$,$=/\r?\n/;break;case 2:if(typeof $==="function")X=U,U=$,$=/\r?\n/;else if(typeof U==="object")X=U,U=B8}X=Object.assign({},X),X.autoDestroy=!0,X.transform=Q9,X.flush=j9,X.readableObjectMode=!0;const Z=new G9(X);return Z[C]="",Z[U0]=new Y9("utf8"),Z.matcher=$,Z.mapper=U,Z.maxLength=X.maxLength,Z.skipOverflow=X.skipOverflow||!1,Z.overflow=!1,Z._destroy=function(J,G){this._writableState.errorEmitted=!1,G(J)},Z},{Transform:G9}=import.meta.require("stream"),{StringDecoder:Y9}=import.meta.require("string_decoder"),C=Symbol("last"),U0=Symbol("decoder");x8.exports=W9});var v8=H((E9,P)=>{var F9=function($){return($&R9)==L9},h0=function(){var $=o instanceof K9&&o.writable===!0;if($){var U=Array.prototype.slice.call(arguments).concat("\n");o.write(b8.format.apply(b8,U))}},h8=import.meta.require("path"),K9=import.meta.require("stream").Stream,H9=w8(),b8=import.meta.require("util"),O9=5432,X0=process.platform==="win32",o=process.stderr,_9=56,z9=7,R9=61440,L9=32768,b=["host","port","database","user","password"],w0=b.length,M9=b[w0-1];Object.defineProperty(E9,"isWin",{get:function(){return X0},set:function($){X0=$}});E9.warnTo=function($){var U=o;return o=$,U};E9.getFileName=function($){var U=$||process.env,X=U.PGPASSFILE||(X0?h8.join(U.APPDATA||"./","postgresql","pgpass.conf"):h8.join(U.HOME||"./",".pgpass"));return X};E9.usePgPass=function($,U){if(Object.prototype.hasOwnProperty.call(process.env,"PGPASSWORD"))return!1;if(X0)return!0;if(U=U||"<unkn>",!F9($.mode))return h0('WARNING: password file "%s" is not a plain file',U),!1;if($.mode&(_9|z9))return h0('WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less',U),!1;return!0};var A9=E9.match=function($,U){return b.slice(0,-1).reduce(function(X,Z,J){if(J==1){if(Number($[Z]||O9)===Number(U[Z]))return X&&!0}return X&&(U[Z]==="*"||U[Z]===$[Z])},!0)};E9.getPassword=function($,U,X){var Z,J=U.pipe(H9());function G(j){var W=N9(j);if(W&&V9(W)&&A9($,W))Z=W[M9],J.end()}var Y=function(){U.destroy(),X(Z)},Q=function(j){U.destroy(),h0("WARNING: error on reading file: %s",j),X(void 0)};U.on("error",Q),J.on("data",G).on("end",Y).on("error",Q)};var N9=E9.parseLine=function($){if($.length<11||$.match(/^\s+#/))return null;var U="",X="",Z=0,J=0,G=0,Y={},Q=!1,j=function(K,O,_){var E=$.substring(O,_);if(!Object.hasOwnProperty.call(process.env,"PGPASS_NO_DEESCAPE"))E=E.replace(/\\([:\\])/g,"$1");Y[b[K]]=E};for(var W=0;W<$.length-1;W+=1){if(U=$.charAt(W+1),X=$.charAt(W),Q=Z==w0-1,Q){j(Z,J);break}if(W>=0&&U==":"&&X!=="\\")j(Z,J,W+1),J=W+2,Z+=1}return Y=Object.keys(Y).length===w0?Y:null,Y},V9=E9.isValidEntry=function($){var U={0:function(Y){return Y.length>0},1:function(Y){if(Y==="*")return!0;return Y=Number(Y),isFinite(Y)&&Y>0&&Y<9007199254740992&&Math.floor(Y)===Y},2:function(Y){return Y.length>0},3:function(Y){return Y.length>0},4:function(Y){return Y.length>0}};for(var X=0;X<b.length;X+=1){var Z=U[X],J=$[b[X]]||"",G=Z(J);if(!G)return!1}return!0}});var d8=H((wU,b0)=>{var xU=import.meta.require("path"),y8=import.meta.require("fs"),Z0=v8();b0.exports=function($,U){var X=Z0.getFileName();y8.stat(X,function(Z,J){if(Z||!Z0.usePgPass(J,X))return U(void 0);var G=y8.createReadStream(X);Z0.getPassword($,G,U)})};b0.exports.warnTo=Z0.warnTo});var f8=H((hU,u8)=>{var q9=import.meta.require("events").EventEmitter,m8=c(),v0=B1(),D9=S0(),k9=P0(),p8=o1(),B9=g(),I9=x0(),x9=E0();class y0 extends q9{constructor($){super();this.connectionParameters=new k9($),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;var U=$||{};if(this._Promise=U.Promise||global.Promise,this._types=new D9(U.types),this._ending=!1,this._ended=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this.connection=U.connection||new I9({stream:U.stream,ssl:this.connectionParameters.ssl,keepAlive:U.keepAlive||!1,keepAliveInitialDelayMillis:U.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||"utf8"}),this.queryQueue=[],this.binary=U.binary||B9.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=U.connectionTimeoutMillis||0}_errorAllQueries($){const U=(X)=>{process.nextTick(()=>{X.handleError($,this.connection)})};if(this.activeQuery)U(this.activeQuery),this.activeQuery=null;this.queryQueue.forEach(U),this.queryQueue.length=0}_connect($){var U=this,X=this.connection;if(this._connectionCallback=$,this._connecting||this._connected){const Z=new Error("Client has already been connected. You cannot reuse a client.");process.nextTick(()=>{$(Z)});return}if(this._connecting=!0,this.connectionTimeoutHandle,this._connectionTimeoutMillis>0)this.connectionTimeoutHandle=setTimeout(()=>{X._ending=!0,X.stream.destroy(new Error("timeout expired"))},this._connectionTimeoutMillis);if(this.host&&this.host.indexOf("/")===0)X.connect(this.host+"/.s.PGSQL."+this.port);else X.connect(this.port,this.host);X.on("connect",function(){if(U.ssl)X.requestSsl();else X.startup(U.getStartupConf())}),X.on("sslconnect",function(){X.startup(U.getStartupConf())}),this._attachListeners(X),X.once("end",()=>{const Z=this._ending?new Error("Connection terminated"):new Error("Connection terminated unexpectedly");if(clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(Z),this._ended=!0,!this._ending){if(this._connecting&&!this._connectionError)if(this._connectionCallback)this._connectionCallback(Z);else this._handleErrorEvent(Z);else if(!this._connectionError)this._handleErrorEvent(Z)}process.nextTick(()=>{this.emit("end")})})}connect($){if($){this._connect($);return}return new this._Promise((U,X)=>{this._connect((Z)=>{if(Z)X(Z);else U()})})}_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))}_checkPgPass($){const U=this.connection;if(typeof this.password==="function")this._Promise.resolve().then(()=>this.password()).then((X)=>{if(X!==void 0){if(typeof X!=="string"){U.emit("error",new TypeError("Password must be a string"));return}this.connectionParameters.password=this.password=X}else this.connectionParameters.password=this.password=null;$()}).catch((X)=>{U.emit("error",X)});else if(this.password!==null)$();else try{d8()(this.connectionParameters,(Z)=>{if(Z!==void 0)this.connectionParameters.password=this.password=Z;$()})}catch(X){this.emit("error",X)}}_handleAuthCleartextPassword($){this._checkPgPass(()=>{this.connection.password(this.password)})}_handleAuthMD5Password($){this._checkPgPass(async()=>{try{const U=await x9.postgresMd5PasswordHash(this.user,this.password,$.salt);this.connection.password(U)}catch(U){this.emit("error",U)}})}_handleAuthSASL($){this._checkPgPass(()=>{try{this.saslSession=v0.startSession($.mechanisms),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)}catch(U){this.connection.emit("error",U)}})}async _handleAuthSASLContinue($){try{await v0.continueSession(this.saslSession,this.password,$.data),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}catch(U){this.connection.emit("error",U)}}_handleAuthSASLFinal($){try{v0.finalizeSession(this.saslSession,$.data),this.saslSession=null}catch(U){this.connection.emit("error",U)}}_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")}const{activeQuery:U}=this;if(this.activeQuery=null,this.readyForQuery=!0,U)U.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($);const U=this.activeQuery;if(!U){this._handleErrorEvent($);return}this.activeQuery=null,U.handleError($,this.connection)}_handleRowDescription($){this.activeQuery.handleRowDescription($)}_handleDataRow($){this.activeQuery.handleDataRow($)}_handlePortalSuspended($){this.activeQuery.handlePortalSuspended(this.connection)}_handleEmptyQuery($){this.activeQuery.handleEmptyQuery(this.connection)}_handleCommandComplete($){this.activeQuery.handleCommandComplete($,this.connection)}_handleParseComplete($){if(this.activeQuery.name)this.connection.parsedStatements[this.activeQuery.name]=this.activeQuery.text}_handleCopyInResponse($){this.activeQuery.handleCopyInResponse(this.connection)}_handleCopyData($){this.activeQuery.handleCopyData($,this.connection)}_handleNotification($){this.emit("notification",$)}_handleNotice($){this.emit("notice",$)}getStartupConf(){var $=this.connectionParameters,U={user:$.user,database:$.database},X=$.application_name||$.fallback_application_name;if(X)U.application_name=X;if($.replication)U.replication=""+$.replication;if($.statement_timeout)U.statement_timeout=String(parseInt($.statement_timeout,10));if($.lock_timeout)U.lock_timeout=String(parseInt($.lock_timeout,10));if($.idle_in_transaction_session_timeout)U.idle_in_transaction_session_timeout=String(parseInt($.idle_in_transaction_session_timeout,10));if($.options)U.options=$.options;return U}cancel($,U){if($.activeQuery===U){var X=this.connection;if(this.host&&this.host.indexOf("/")===0)X.connect(this.host+"/.s.PGSQL."+this.port);else X.connect(this.port,this.host);X.on("connect",function(){X.cancel($.processID,$.secretKey)})}else if($.queryQueue.indexOf(U)!==-1)$.queryQueue.splice($.queryQueue.indexOf(U),1)}setTypeParser($,U,X){return this._types.setTypeParser($,U,X)}getTypeParser($,U){return this._types.getTypeParser($,U)}escapeIdentifier($){return m8.escapeIdentifier($)}escapeLiteral($){return m8.escapeLiteral($)}_pulseQueryQueue(){if(this.readyForQuery===!0){if(this.activeQuery=this.queryQueue.shift(),this.activeQuery){this.readyForQuery=!1,this.hasExecuted=!0;const $=this.activeQuery.submit(this.connection);if($)process.nextTick(()=>{this.activeQuery.handleError($,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else if(this.hasExecuted)this.activeQuery=null,this.emit("drain")}}query($,U,X){var Z,J,G,Y,Q;if($===null||$===void 0)throw new TypeError("Client was passed a null or undefined query");else if(typeof $.submit==="function"){if(G=$.query_timeout||this.connectionParameters.query_timeout,J=Z=$,typeof U==="function")Z.callback=Z.callback||U}else if(G=this.connectionParameters.query_timeout,Z=new p8($,U,X),!Z.callback)J=new this._Promise((j,W)=>{Z.callback=(K,O)=>K?W(K):j(O)}).catch((j)=>{throw Error.captureStackTrace(j),j});if(G)Q=Z.callback,Y=setTimeout(()=>{var j=new Error("Query read timeout");process.nextTick(()=>{Z.handleError(j,this.connection)}),Q(j),Z.callback=()=>{};var W=this.queryQueue.indexOf(Z);if(W>-1)this.queryQueue.splice(W,1);this._pulseQueryQueue()},G),Z.callback=(j,W)=>{clearTimeout(Y),Q(j,W)};if(this.binary&&!Z.binary)Z.binary=!0;if(Z._result&&!Z._result._types)Z._result._types=this._types;if(!this._queryable)return process.nextTick(()=>{Z.handleError(new Error("Client has encountered a connection error and is not queryable"),this.connection)}),J;if(this._ending)return process.nextTick(()=>{Z.handleError(new Error("Client was closed and is not queryable"),this.connection)}),J;return this.queryQueue.push(Z),this._pulseQueryQueue(),J}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.activeQuery||!this._queryable)this.connection.stream.destroy();else this.connection.end();if($)this.connection.once("end",$);else return new this._Promise((U)=>{this.connection.once("end",U)})}}y0.Query=p8;u8.exports=y0});var i8=H((bU,n8)=>{var h9=function(){throw new Error("Release called on client which has already been released to the pool.")},J0=function($,U){if(U)return{callback:U,result:void 0};let X,Z;const J=function(Y,Q){Y?X(Y):Z(Q)},G=new $(function(Y,Q){Z=Y,X=Q}).catch((Y)=>{throw Error.captureStackTrace(Y),Y});return{callback:J,result:G}},b9=function($,U){return function X(Z){Z.client=U,U.removeListener("error",X),U.on("error",()=>{$.log("additional client error after disconnection due to error",Z)}),$._remove(U),$.emit("error",Z,U)}},w9=import.meta.require("events").EventEmitter,g8=function(){},c8=($,U)=>{const X=$.findIndex(U);return X===-1?void 0:$.splice(X,1)[0]};class l8{constructor($,U,X){this.client=$,this.idleListener=U,this.timeoutId=X}}class n{constructor($){this.callback=$}}class o8 extends w9{constructor($,U){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.maxUses=this.options.maxUses||Infinity,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||U||d0().Client,this.Promise=this.options.Promise||global.Promise,typeof this.options.idleTimeoutMillis==="undefined")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}_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((U)=>{this._remove(U.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;const $=this._pendingQueue.shift();if(this._idle.length){const U=this._idle.pop();clearTimeout(U.timeoutId);const X=U.client;X.ref&&X.ref();const Z=U.idleListener;return this._acquireClient(X,$,Z,!1)}if(!this._isFull())return this.newClient($);throw new Error("unexpected condition")}_remove($){const U=c8(this._idle,(X)=>X.client===$);if(U!==void 0)clearTimeout(U.timeoutId);this._clients=this._clients.filter((X)=>X!==$),$.end(),this.emit("remove",$)}connect($){if(this.ending){const Z=new Error("Cannot use a pool after calling end on the pool");return $?$(Z):this.Promise.reject(Z)}const U=J0(this.Promise,$),X=U.result;if(this._isFull()||this._idle.length){if(this._idle.length)process.nextTick(()=>this._pulseQueue());if(!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new n(U.callback)),X;const Z=(Y,Q,j)=>{clearTimeout(G),U.callback(Y,Q,j)},J=new n(Z),G=setTimeout(()=>{c8(this._pendingQueue,(Y)=>Y.callback===Z),J.timedOut=!0,U.callback(new Error("timeout exceeded when trying to connect"))},this.options.connectionTimeoutMillis);return this._pendingQueue.push(J),X}return this.newClient(new n(U.callback)),X}newClient($){const U=new this.Client(this.options);this._clients.push(U);const X=b9(this,U);this.log("checking client timeout");let Z,J=!1;if(this.options.connectionTimeoutMillis)Z=setTimeout(()=>{this.log("ending client due to timeout"),J=!0,U.connection?U.connection.stream.destroy():U.end()},this.options.connectionTimeoutMillis);this.log("connecting new client"),U.connect((G)=>{if(Z)clearTimeout(Z);if(U.on("error",X),G){if(this.log("client failed to connect",G),this._clients=this._clients.filter((Y)=>Y!==U),J)G.message="Connection terminated due to connection timeout";if(this._pulseQueue(),!$.timedOut)$.callback(G,void 0,g8)}else{if(this.log("new client connected"),this.options.maxLifetimeSeconds!==0){const Y=setTimeout(()=>{if(this.log("ending client due to expired lifetime"),this._expired.add(U),this._idle.findIndex((j)=>j.client===U)!==-1)this._acquireClient(U,new n((j,W,K)=>K()),X,!1)},this.options.maxLifetimeSeconds*1000);Y.unref(),U.once("end",()=>clearTimeout(Y))}return this._acquireClient(U,$,X,!0)}})}_acquireClient($,U,X,Z){if(Z)this.emit("connect",$);if(this.emit("acquire",$),$.release=this._releaseOnce($,X),$.removeListener("error",X),!U.timedOut)if(Z&&this.options.verify)this.options.verify($,(J)=>{if(J)return $.release(J),U.callback(J,void 0,g8);U.callback(void 0,$,$.release)});else U.callback(void 0,$,$.release);else if(Z&&this.options.verify)this.options.verify($,$.release);else $.release()}_releaseOnce($,U){let X=!1;return(Z)=>{if(X)h9();X=!0,this._release($,U,Z)}}_release($,U,X){if($.on("error",U),$._poolUseCount=($._poolUseCount||0)+1,this.emit("release",X,$),X||this.ending||!$._queryable||$._ending||$._poolUseCount>=this.options.maxUses){if($._poolUseCount>=this.options.maxUses)this.log("remove expended client");this._remove($),this._pulseQueue();return}if(this._expired.has($)){this.log("remove expired client"),this._expired.delete($),this._remove($),this._pulseQueue();return}let J;if(this.options.idleTimeoutMillis){if(J=setTimeout(()=>{this.log("remove idle client"),this._remove($)},this.options.idleTimeoutMillis),this.options.allowExitOnIdle)J.unref()}if(this.options.allowExitOnIdle)$.unref();this._idle.push(new l8($,U,J)),this._pulseQueue()}query($,U,X){if(typeof $==="function"){const J=J0(this.Promise,$);return setImmediate(function(){return J.callback(new Error("Passing a function as the first parameter to pool.query is not supported"))}),J.result}if(typeof U==="function")X=U,U=void 0;const Z=J0(this.Promise,X);return X=Z.callback,this.connect((J,G)=>{if(J)return X(J);let Y=!1;const Q=(j)=>{if(Y)return;Y=!0,G.release(j),X(j)};G.once("error",Q),this.log("dispatching query");try{G.query($,U,(j,W)=>{if(this.log("query dispatched"),G.removeListener("error",Q),Y)return;if(Y=!0,G.release(j),j)return X(j);return X(void 0,W)})}catch(j){return G.release(j),X(j)}}),Z.result}end($){if(this.log("ending"),this.ending){const X=new Error("Called end on pool more than once");return $?$(X):this.Promise.reject(X)}this.ending=!0;const U=J0(this.Promise,$);return this._endCallback=U.callback,this._pulseQueue(),U.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce(($,U)=>$+(this._expired.has(U)?1:0),0)}get totalCount(){return this._clients.length}}n8.exports=o8});var s8=H((vU,t8)=>{var a8=import.meta.require("events").EventEmitter,v9=import.meta.require("util"),m0=c(),v=t8.exports=function($,U,X){a8.call(this),$=m0.normalizeQueryConfig($,U,X),this.text=$.text,this.values=$.values,this.name=$.name,this.callback=$.callback,this.state="new",this._arrayMode=$.rowMode==="array",this._emitRowEvents=!1,this.on("newListener",function(Z){if(Z==="row")this._emitRowEvents=!0}.bind(this))};v9.inherits(v,a8);var y9={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"file",sourceLine:"line",sourceFunction:"routine"};v.prototype.handleError=function($){var U=this.native.pq.resultErrorFields();if(U)for(var X in U){var Z=y9[X]||X;$[Z]=U[X]}if(this.callback)this.callback($);else this.emit("error",$);this.state="error"};v.prototype.then=function($,U){return this._getPromise().then($,U)};v.prototype.catch=function($){return this._getPromise().catch($)};v.prototype._getPromise=function(){if(this._promise)return this._promise;return this._promise=new Promise(function($,U){this._once("end",$),this._once("error",U)}.bind(this)),this._promise};v.prototype.submit=function($){this.state="running";var U=this;this.native=$.native,$.native.arrayMode=this._arrayMode;var X=function(G,Y,Q){if($.native.arrayMode=!1,setImmediate(function(){U.emit("_done")}),G)return U.handleError(G);if(U._emitRowEvents)if(Q.length>1)Y.forEach((j,W)=>{j.forEach((K)=>{U.emit("row",K,Q[W])})});else Y.forEach(function(j){U.emit("row",j,Q)});if(U.state="end",U.emit("end",Q),U.callback)U.callback(null,Q)};if(process.domain)X=process.domain.bind(X);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");var Z=(this.values||[]).map(m0.prepareValue);if($.namedQueries[this.name]){if(this.text&&$.namedQueries[this.name]!==this.text){const G=new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return X(G)}return $.native.execute(this.name,Z,X)}return $.native.prepare(this.name,this.text,Z.length,function(G){if(G)return X(G);return $.namedQueries[U.name]=U.text,U.native.execute(U.name,Z,X)})}else if(this.values){if(!Array.isArray(this.values)){const G=new Error("Query values must be an array");return X(G)}var J=this.values.map(m0.prepareValue);$.native.query(this.text,J,X)}else $.native.query(this.text,X)}});var p0=H((yU,U$)=>{var r8;try{r8=(()=>{throw new Error(`Cannot require module "pg-native"`);})()}catch($){throw $}var d9=S0(),e8=import.meta.require("events").EventEmitter,m9=import.meta.require("util"),p9=P0(),$$=s8(),V=U$.exports=function($){e8.call(this),$=$||{},this._Promise=$.Promise||global.Promise,this._types=new d9($.types),this.native=new r8({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;var U=this.connectionParameters=new p9($);if($.nativeConnectionString)U.nativeConnectionString=$.nativeConnectionString;this.user=U.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:U.password}),this.database=U.database,this.host=U.host,this.port=U.port,this.namedQueries={}};V.Query=$$;m9.inherits(V,e8);V.prototype._errorAllQueries=function($){const U=(X)=>{process.nextTick(()=>{X.native=this.native,X.handleError($)})};if(this._hasActiveQuery())U(this._activeQuery),this._activeQuery=null;this._queryQueue.forEach(U),this._queryQueue.length=0};V.prototype._connect=function($){var U=this;if(this._connecting){process.nextTick(()=>$(new Error("Client has already been connected. You cannot reuse a client.")));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(X,Z){if(U.connectionParameters.nativeConnectionString)Z=U.connectionParameters.nativeConnectionString;if(X)return $(X);U.native.connect(Z,function(J){if(J)return U.native.end(),$(J);U._connected=!0,U.native.on("error",function(G){U._queryable=!1,U._errorAllQueries(G),U.emit("error",G)}),U.native.on("notification",function(G){U.emit("notification",{channel:G.relname,payload:G.extra})}),U.emit("connect"),U._pulseQueryQueue(!0),$()})})};V.prototype.connect=function($){if($){this._connect($);return}return new this._Promise((U,X)=>{this._connect((Z)=>{if(Z)X(Z);else U()})})};V.prototype.query=function($,U,X){var Z,J,G,Y,Q;if($===null||$===void 0)throw new TypeError("Client was passed a null or undefined query");else if(typeof $.submit==="function"){if(G=$.query_timeout||this.connectionParameters.query_timeout,J=Z=$,typeof U==="function")$.callback=U}else if(G=this.connectionParameters.query_timeout,Z=new $$($,U,X),!Z.callback){let j,W;J=new this._Promise((K,O)=>{j=K,W=O}).catch((K)=>{throw Error.captureStackTrace(K),K}),Z.callback=(K,O)=>K?W(K):j(O)}if(G)Q=Z.callback,Y=setTimeout(()=>{var j=new Error("Query read timeout");process.nextTick(()=>{Z.handleError(j,this.connection)}),Q(j),Z.callback=()=>{};var W=this._queryQueue.indexOf(Z);if(W>-1)this._queryQueue.splice(W,1);this._pulseQueryQueue()},G),Z.callback=(j,W)=>{clearTimeout(Y),Q(j,W)};if(!this._queryable)return Z.native=this.native,process.nextTick(()=>{Z.handleError(new Error("Client has encountered a connection error and is not queryable"))}),J;if(this._ending)return Z.native=this.native,process.nextTick(()=>{Z.handleError(new Error("Client was closed and is not queryable"))}),J;return this._queryQueue.push(Z),this._pulseQueryQueue(),J};V.prototype.end=function($){var U=this;if(this._ending=!0,!this._connected)this.once("connect",this.end.bind(this,$));var X;if(!$)X=new this._Promise(function(Z,J){$=(G)=>G?J(G):Z()});return this.native.end(function(){U._errorAllQueries(new Error("Connection terminated")),process.nextTick(()=>{if(U.emit("end"),$)$()})}),X};V.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!=="error"&&this._activeQuery.state!=="end"};V.prototype._pulseQueryQueue=function($){if(!this._connected)return;if(this._hasActiveQuery())return;var U=this._queryQueue.shift();if(!U){if(!$)this.emit("drain");return}this._activeQuery=U,U.submit(this);var X=this;U.once("_done",function(){X._pulseQueryQueue()})};V.prototype.cancel=function($){if(this._activeQuery===$)this.native.cancel(function(){});else if(this._queryQueue.indexOf($)!==-1)this._queryQueue.splice(this._queryQueue.indexOf($),1)};V.prototype.ref=function(){};V.prototype.unref=function(){};V.prototype.setTypeParser=function($,U,X){return this._types.setTypeParser($,U,X)};V.prototype.getTypeParser=function($,U){return this._types.getTypeParser($,U)}});var d0=H((dU,i)=>{var u9=f8(),f9=g(),g9=x0(),c9=i8(),{DatabaseError:l9}=B0(),{escapeIdentifier:o9,escapeLiteral:n9}=c(),i9=($)=>{return class U extends c9{constructor(X){super(X,$)}}},u0=function($){this.defaults=f9,this.Client=$,this.Query=this.Client.Query,this.Pool=i9(this.Client),this._pools=[],this.Connection=g9,this.types=f(),this.DatabaseError=l9,this.escapeIdentifier=o9,this.escapeLiteral=n9};if(typeof process.env.NODE_PG_FORCE_NATIVE!=="undefined")i.exports=new u0(p0());else i.exports=new u0(u9),Object.defineProperty(i.exports,"native",{configurable:!0,enumerable:!1,get(){var $=null;try{$=new u0(p0())}catch(U){if(U.code!=="MODULE_NOT_FOUND")throw U}return Object.defineProperty(i.exports,"native",{value:$}),$}})});var X$=_$(d0(),1),D=new X$.Pool({host:"0.0.0.0",port:5432,user:"postgres",password:"123",database:"rinha"});function Z$($,U){if(typeof $!=="number"||$<1)U.status=422;return U}function J$($,U,X){if(typeof $!=="number"||$<1)X.status=422;if(!U.valor||typeof U.valor!=="number"||U.valor<1||!Number.isInteger(U.valor))X.status=422;if(!U.tipo||typeof U.tipo!=="string"||!["c","d"].includes(U.tipo))X.status=422;if(!U.descricao||typeof U.descricao!=="string"||U.descricao.length<1||U.descricao.length>10)X.status=422;return X}async function G$($,U){if(Z$($,U).status!==200)return;const Z=(await D.query("SELECT * FROM customers WHERE id = $1",[$])).rows[0];if(!Z){U.status=404;return}const J=(await D.query("SELECT * FROM transacoes WHERE customerId = $1 ORDER BY realizada_em DESC LIMIT 10",[$])).rows;return{saldo:{total:Z.saldo,data_extrato:(new Date()).toISOString(),limite:Z.limite},ultimas_transacoes:J}}async function Y$($,U,X){if(J$($,U,X).status!==200)return;const J=(await D.query("SELECT * FROM customers WHERE id = $1",[$])).rows[0];if(!J){X.status=404;return}let G=0;if(U.tipo==="d"){const Y=await D.query("SELECT * FROM debit ($1, $2, $3)",[$,U.valor,U.descricao]),{saldofinal:Q,error:j}=Y.rows[0];if(j)return X.status=422,"saldo insuficente";G=Q}if(U.tipo==="c")G=(await D.query("SELECT * FROM credit ($1, $2, $3)",[$,U.valor,U.descricao])).rows[0].saldofinal;return{limite:J.limite,saldo:G}}var Q$=new RegExp(/clientes\/(\d+)\/extrato/),j$=new RegExp(/clientes\/(\d+)\/transacoes/),a9=async($)=>{const U=new URL($.url),X={status:200};if($.method==="GET"&&Q$.test(U.pathname)){const Z=+Q$.exec(U.pathname)[1],J=await G$(Z,X);return{status:X.status,body:J}}if($.method==="POST"&&j$.test(U.pathname)){const Z=+j$.exec(U.pathname)[1],J=await $.json(),G=await Y$(Z,J,X);return{status:X.status,body:G}}},W$=Bun.env.PORT;Bun.serve({port:W$,async fetch($){const U=await a9($);if(!U)return new Response(null,{status:404});return new Response(JSON.stringify(U.body),{status:U.status})}});console.log(`Server is running at on port ${W$}...`);
api01-1 | ^
api01-1 | ECONNREFUSED: Failed to connect
api01-1 | syscall: "connect"
api01-1 |
api01-1 | at /home/bun/app/index.js:3:121740
api01-1 | at promiseReactionJob (native:1:1)
api01-1 | at processTicksAndRejections (native:1:1)
nginx-1 | 2024/02/19 04:55:04 [error] 30#30: *170 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/5/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/5/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:55:06 [error] 30#30: *211 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "GET /clientes/5/extrato HTTP/1.1", upstream: "http://upstreamapi/clientes/5/extrato", host: "localhost:9999"
nginx-1 | 2024/02/19 04:55:06 [error] 30#30: *212 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/5/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/5/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:55:06 [error] 30#30: *213 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/2/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/2/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:55:06 [error] 30#30: *214 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/5/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/5/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:55:06 [error] 30#30: *215 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/4/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/4/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:55:06 [error] 30#30: *216 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/5/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/5/transacoes", host: "localhost:9999"
nginx-1 | 2024/02/19 04:55:07 [error] 30#30: *217 no live upstreams while connecting to upstream, client: 127.0.0.1, server: , request: "POST /clientes/3/transacoes HTTP/1.1", upstream: "http://upstreamapi/clientes/3/transacoes", host: "localhost:9999"
nginx-1 exited with code 0
nginx-1 exited with code 0
api02-1 exited with code 0
api02-1 exited with code 137
api01-1 exited with code 0
api01-1 exited with code 137
postgres-1 exited with code 0