From f34009203bdbf32b0b0ffd9bb9aae6bf1ea4b4e4 Mon Sep 17 00:00:00 2001 From: Jeff Christoffersen Date: Wed, 3 Sep 2025 15:18:37 -0600 Subject: [PATCH 1/2] updated serverless driver to support Neon Local --- CONFIG.md | 29 + index.d.mts | 37 + index.d.ts | 37 + index.js | 1520 +++++++++-------- index.mjs | 1496 ++++++++-------- src/client.ts | 12 +- src/httpQuery.ts | 18 +- src/shims/net/index.ts | 234 ++- .../cloudflare/neon_local/test-all-custom.js | 86 + .../neon_local/test-cloudflare-http.js | 156 ++ .../neon_local/test-comprehensive.js | 120 ++ .../neon_local/test-legacy-behavior.js | 95 ++ .../neon_local/test-neon-local-behavior.js | 145 ++ tests/cloudflare/neon_local/test-non-local.js | 106 ++ 14 files changed, 2533 insertions(+), 1558 deletions(-) create mode 100644 tests/cloudflare/neon_local/test-all-custom.js create mode 100644 tests/cloudflare/neon_local/test-cloudflare-http.js create mode 100644 tests/cloudflare/neon_local/test-comprehensive.js create mode 100644 tests/cloudflare/neon_local/test-legacy-behavior.js create mode 100644 tests/cloudflare/neon_local/test-neon-local-behavior.js create mode 100644 tests/cloudflare/neon_local/test-non-local.js diff --git a/CONFIG.md b/CONFIG.md index d0027b0..1f321ff 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -348,6 +348,35 @@ Its value is a string containing zero or more certificates in PEM format. Default: `""` (the empty string). +#### `isNeonLocal: boolean` + +Set `isNeonLocal` to `true` when connecting to a Neon Local proxy instance. This flag enables specific optimizations and behaviors for local development environments. + +**Key behaviors when `isNeonLocal` is `true`:** + +1. **Automatic endpoint configuration**: The SQL fetch endpoint automatically uses the host and port from your connection string instead of the Neon cloud API endpoints. +2. **Protocol handling**: Uses `https://` when `useSecureWebSocket` is `true`, `http://` when `false`. +3. **Port handling**: Standard ports (443 for HTTPS, 80 for HTTP) are omitted from URLs; custom ports are included. +4. **Automatic credential injection**: Credentials from the connection string are automatically sent as WebSocket headers for the Neon Local proxy to inject into the PostgreSQL protocol. + +For example: + +```javascript +```javascript +import { neonConfig, Client } from '@neondatabase/serverless'; + +// Enable Neon Local mode +neonConfig.isNeonLocal = true; + +// Connection string credentials are automatically extracted and sent as headers +const client = new Client('postgresql://postgres:password@localhost:5432/mydb'); +await client.connect(); +// WebSocket headers: X-Neon-User: postgres, X-Neon-Password: password, X-Neon-Database: mydb +``` + +**Note**: This feature requires a custom `webSocketConstructor` (like the `ws` library in Node.js) that supports headers. Browser WebSocket APIs don't support custom headers, but Neon Local typically runs in server-side environments. +Default: `false`. + #### `pipelineTLS: boolean` **Only when using experimental pure-JS encryption**, the driver will pipeline the SSL request message and TLS Client Hello if `pipelineTLS` is set to `true`. Currently, this is only supported by Neon database hosts, and will fail when communicating with an ordinary Postgres or pgbouncer back-end. diff --git a/index.d.mts b/index.d.mts index c1617a8..e8674c6 100644 --- a/index.d.mts +++ b/index.d.mts @@ -441,11 +441,17 @@ export declare interface NeonConfig { pipelineTLS: boolean; disableSNI: boolean; disableWarningInBrowsers: boolean; + isNeonLocal: boolean; } export declare class neonConfig extends EventEmitter { static defaults: NeonConfig; static opts: Partial; + /** + * Set connection string credentials for automatic injection in Neon Local mode. + * This is called automatically by the Client class when isNeonLocal is true. + */ + setConnectionCredentials(credentials: NeonLocalCredentials): void; /** * **Experimentally**, when `poolQueryViaFetch` is `true`, and no listeners * for the `"connect"`, `"acquire"`, `"release"` or `"remove"` events are set @@ -619,6 +625,17 @@ export declare class neonConfig extends EventEmitter { static set rootCerts(newValue: NeonConfig['rootCerts']); get rootCerts(): NeonConfig["rootCerts"]; set rootCerts(newValue: NeonConfig['rootCerts']); + /** + * Set `isNeonLocal` to `true` when connecting to a Neon Local proxy instance. + * This flag can be used by the driver to enable specific optimizations and + * behaviors when working with local development environments. + * + * Default: `false`. + */ + static get isNeonLocal(): NeonConfig["isNeonLocal"]; + static set isNeonLocal(newValue: NeonConfig['isNeonLocal']); + get isNeonLocal(): NeonConfig["isNeonLocal"]; + set isNeonLocal(newValue: NeonConfig['isNeonLocal']); wsProxyAddrForHost(host: string, port: number): string; connecting: boolean; pending: boolean; @@ -665,6 +682,12 @@ export declare class NeonDbError extends Error { constructor(message: string); } +declare interface NeonLocalCredentials { + user?: string; + password?: string; + database?: string; +} + export declare interface NeonQueryFunction { (strings: TemplateStringsArray, ...params: any[]): NeonQueryPromise : QueryRows>; /** @@ -797,6 +820,8 @@ export declare interface PoolClient extends PoolClient_2 { export { PoolConfig } +export declare function processQueryResult(rawResults: any, { arrayMode, fullResults, types: customTypes }: ProcessQueryResultOptions): any; + export declare interface ProcessQueryResultOptions { arrayMode: boolean; fullResults: boolean; @@ -913,6 +938,18 @@ export declare interface WebSocketLike { close(code?: number, reason?: string): void; send(data: any): void; addEventListener(type: 'open' | 'message' | 'close' | 'error', listener: (this: WebSocketLike, ev: any) => any, options?: any): void; + onopen?: (this: WebSocketLike) => void; + onmessage?: (this: WebSocketLike, ev: { + data: any; + }) => void; + onerror?: (this: WebSocketLike, ev: { + error?: any; + message?: string; + }) => void; + onclose?: (this: WebSocketLike, ev: { + code: number; + reason?: string; + }) => void; } export declare class WebSocketReadQueue extends ReadQueue { diff --git a/index.d.ts b/index.d.ts index c1617a8..e8674c6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -441,11 +441,17 @@ export declare interface NeonConfig { pipelineTLS: boolean; disableSNI: boolean; disableWarningInBrowsers: boolean; + isNeonLocal: boolean; } export declare class neonConfig extends EventEmitter { static defaults: NeonConfig; static opts: Partial; + /** + * Set connection string credentials for automatic injection in Neon Local mode. + * This is called automatically by the Client class when isNeonLocal is true. + */ + setConnectionCredentials(credentials: NeonLocalCredentials): void; /** * **Experimentally**, when `poolQueryViaFetch` is `true`, and no listeners * for the `"connect"`, `"acquire"`, `"release"` or `"remove"` events are set @@ -619,6 +625,17 @@ export declare class neonConfig extends EventEmitter { static set rootCerts(newValue: NeonConfig['rootCerts']); get rootCerts(): NeonConfig["rootCerts"]; set rootCerts(newValue: NeonConfig['rootCerts']); + /** + * Set `isNeonLocal` to `true` when connecting to a Neon Local proxy instance. + * This flag can be used by the driver to enable specific optimizations and + * behaviors when working with local development environments. + * + * Default: `false`. + */ + static get isNeonLocal(): NeonConfig["isNeonLocal"]; + static set isNeonLocal(newValue: NeonConfig['isNeonLocal']); + get isNeonLocal(): NeonConfig["isNeonLocal"]; + set isNeonLocal(newValue: NeonConfig['isNeonLocal']); wsProxyAddrForHost(host: string, port: number): string; connecting: boolean; pending: boolean; @@ -665,6 +682,12 @@ export declare class NeonDbError extends Error { constructor(message: string); } +declare interface NeonLocalCredentials { + user?: string; + password?: string; + database?: string; +} + export declare interface NeonQueryFunction { (strings: TemplateStringsArray, ...params: any[]): NeonQueryPromise : QueryRows>; /** @@ -797,6 +820,8 @@ export declare interface PoolClient extends PoolClient_2 { export { PoolConfig } +export declare function processQueryResult(rawResults: any, { arrayMode, fullResults, types: customTypes }: ProcessQueryResultOptions): any; + export declare interface ProcessQueryResultOptions { arrayMode: boolean; fullResults: boolean; @@ -913,6 +938,18 @@ export declare interface WebSocketLike { close(code?: number, reason?: string): void; send(data: any): void; addEventListener(type: 'open' | 'message' | 'close' | 'error', listener: (this: WebSocketLike, ev: any) => any, options?: any): void; + onopen?: (this: WebSocketLike) => void; + onmessage?: (this: WebSocketLike, ev: { + data: any; + }) => void; + onerror?: (this: WebSocketLike, ev: { + error?: any; + message?: string; + }) => void; + onclose?: (this: WebSocketLike, ev: { + code: number; + reason?: string; + }) => void; } export declare class WebSocketReadQueue extends ReadQueue { diff --git a/index.js b/index.js index 509f593..7b1f554 100644 --- a/index.js +++ b/index.js @@ -1,73 +1,73 @@ -"use strict";var So=Object.create;var Te=Object.defineProperty;var Eo=Object.getOwnPropertyDescriptor;var Ao=Object.getOwnPropertyNames;var Co=Object.getPrototypeOf,_o=Object.prototype.hasOwnProperty;var Io=(r,e,t)=>e in r?Te(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var a=(r,e)=>Te(r,"name",{value:e,configurable:!0});var G=(r,e)=>()=>(r&&(e=r(r=0)),e);var T=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),te=(r,e)=>{for(var t in e)Te(r,t,{get:e[t], -enumerable:!0})},On=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ao(e))!_o. -call(r,i)&&i!==t&&Te(r,i,{get:()=>e[i],enumerable:!(n=Eo(e,i))||n.enumerable});return r};var Ae=(r,e,t)=>(t=r!=null?So(Co(r)):{},On(e||!r||!r.__esModule?Te(t,"default",{value:r,enumerable:!0}): -t,r)),O=r=>On(Te({},"__esModule",{value:!0}),r);var E=(r,e,t)=>Io(r,typeof e!="symbol"?e+"":e,t);var Nn=T(ft=>{"use strict";p();ft.byteLength=Po;ft.toByteArray=Ro;ft.fromByteArray=ko;var ue=[],re=[], -To=typeof Uint8Array<"u"?Uint8Array:Array,Qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01\ -23456789+/";for(Ce=0,qn=Qt.length;Ce0)throw new Error("Invalid string. Length must be \ -a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}a(Qn,"getLens"); -function Po(r){var e=Qn(r),t=e[0],n=e[1];return(t+n)*3/4-n}a(Po,"byteLength");function Bo(r,e,t){return(e+ -t)*3/4-t}a(Bo,"_byteLength");function Ro(r){var e,t=Qn(r),n=t[0],i=t[1],s=new To(Bo(r,n,i)),o=0,u=i> +"use strict";var Eo=Object.create;var Te=Object.defineProperty;var Ao=Object.getOwnPropertyDescriptor;var Co=Object.getOwnPropertyNames;var _o=Object.getPrototypeOf,Io=Object.prototype.hasOwnProperty;var To=(r,e,t)=>e in r?Te(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var a=(r,e)=>Te(r,"name",{value:e,configurable:!0});var G=(r,e)=>()=>(r&&(e=r(r=0)),e);var T=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),te=(r,e)=>{for(var t in e)Te(r,t,{get:e[t], +enumerable:!0})},qn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Co(e))!Io. +call(r,i)&&i!==t&&Te(r,i,{get:()=>e[i],enumerable:!(n=Ao(e,i))||n.enumerable});return r};var Ae=(r,e,t)=>(t=r!=null?Eo(_o(r)):{},qn(e||!r||!r.__esModule?Te(t,"default",{value:r,enumerable:!0}): +t,r)),O=r=>qn(Te({},"__esModule",{value:!0}),r);var A=(r,e,t)=>To(r,typeof e!="symbol"?e+"":e,t);var jn=T(ht=>{"use strict";d();ht.byteLength=Lo;ht.toByteArray=Ro;ht.fromByteArray=Mo;var oe=[],re=[], +Po=typeof Uint8Array<"u"?Uint8Array:Array,Qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01\ +23456789+/";for(Ce=0,Qn=Qt.length;Ce0)throw new Error("Invalid string. Length must be \ +a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}a(Wn,"getLens"); +function Lo(r){var e=Wn(r),t=e[0],n=e[1];return(t+n)*3/4-n}a(Lo,"byteLength");function Bo(r,e,t){return(e+ +t)*3/4-t}a(Bo,"_byteLength");function Ro(r){var e,t=Wn(r),n=t[0],i=t[1],s=new Po(Bo(r,n,i)),o=0,u=i> 0?n-4:n,c;for(c=0;c>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=re[r.charCodeAt( c)]<<2|re[r.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=re[r.charCodeAt(c)]<<10|re[r.charCodeAt(c+1)]<< -4|re[r.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}a(Ro,"toByteArray");function Lo(r){return ue[r>> -18&63]+ue[r>>12&63]+ue[r>>6&63]+ue[r&63]}a(Lo,"tripletToBase64");function Fo(r,e,t){for(var n,i=[],s=e;s< -t;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(Lo(n));return i.join("")}a(Fo,"en\ -codeChunk");function ko(r){for(var e,t=r.length,n=t%3,i=[],s=16383,o=0,u=t-n;ou?u:o+s));return n===1?(e=r[t-1],i.push(ue[e>>2]+ue[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1], -i.push(ue[e>>10]+ue[e>>4&63]+ue[e<<2&63]+"=")),i.join("")}a(ko,"fromByteArray")});var Wn=T(Nt=>{p();Nt.read=function(r,e,t,n,i){var s,o,u=i*8-n-1,c=(1<>1,f=-7,y=t?i-1:0,g=t? --1:1,A=r[e+y];for(y+=g,s=A&(1<<-f)-1,A>>=-f,f+=u;f>0;s=s*256+r[e+y],y+=g,f-=8);for(o=s&(1<<-f)-1,s>>= --f,f+=n;f>0;o=o*256+r[e+y],y+=g,f-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(A?-1:1)*(1/0);o=o+Math. -pow(2,n),s=s-l}return(A?-1:1)*o*Math.pow(2,s-n)};Nt.write=function(r,e,t,n,i,s){var o,u,c,l=s*8-i-1, -f=(1<>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=n?0:s-1,C=n?1:-1,D=e<0||e===0&&1/e<0? +4|re[r.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}a(Ro,"toByteArray");function ko(r){return oe[r>> +18&63]+oe[r>>12&63]+oe[r>>6&63]+oe[r&63]}a(ko,"tripletToBase64");function Fo(r,e,t){for(var n,i=[],s=e;s< +t;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(ko(n));return i.join("")}a(Fo,"en\ +codeChunk");function Mo(r){for(var e,t=r.length,n=t%3,i=[],s=16383,o=0,u=t-n;ou?u:o+s));return n===1?(e=r[t-1],i.push(oe[e>>2]+oe[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1], +i.push(oe[e>>10]+oe[e>>4&63]+oe[e<<2&63]+"=")),i.join("")}a(Mo,"fromByteArray")});var Hn=T(Wt=>{d();Wt.read=function(r,e,t,n,i){var s,o,u=i*8-n-1,c=(1<>1,f=-7,p=t?i-1:0,g=t? +-1:1,E=r[e+p];for(p+=g,s=E&(1<<-f)-1,E>>=-f,f+=u;f>0;s=s*256+r[e+p],p+=g,f-=8);for(o=s&(1<<-f)-1,s>>= +-f,f+=n;f>0;o=o*256+r[e+p],p+=g,f-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(E?-1:1)*(1/0);o=o+Math. +pow(2,n),s=s-l}return(E?-1:1)*o*Math.pow(2,s-n)};Wt.write=function(r,e,t,n,i,s){var o,u,c,l=s*8-i-1, +f=(1<>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=n?0:s-1,C=n?1:-1,D=e<0||e===0&&1/e<0? 1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,o=f):(o=Math.floor(Math.log(e)/Math.LN2),e*(c= -Math.pow(2,-o))<1&&(o--,c*=2),o+y>=1?e+=g/c:e+=g*Math.pow(2,1-y),e*c>=2&&(o++,c/=2),o+y>=f?(u=0,o=f): -o+y>=1?(u=(e*c-1)*Math.pow(2,i),o=o+y):(u=e*Math.pow(2,y-1)*Math.pow(2,i),o=0));i>=8;r[t+A]=u&255,A+= -C,u/=256,i-=8);for(o=o<0;r[t+A]=o&255,A+=C,o/=256,l-=8);r[t+A-C]|=D*128}});var si=T(Le=>{"use strict";p();var Wt=Nn(),Be=Wn(),jn=typeof Symbol=="function"&&typeof Symbol.for== -"function"?Symbol.for("nodejs.util.inspect.custom"):null;Le.Buffer=h;Le.SlowBuffer=Qo;Le.INSPECT_MAX_BYTES= -50;var ht=2147483647;Le.kMaxLength=ht;h.TYPED_ARRAY_SUPPORT=Mo();!h.TYPED_ARRAY_SUPPORT&&typeof console< +Math.pow(2,-o))<1&&(o--,c*=2),o+p>=1?e+=g/c:e+=g*Math.pow(2,1-p),e*c>=2&&(o++,c/=2),o+p>=f?(u=0,o=f): +o+p>=1?(u=(e*c-1)*Math.pow(2,i),o=o+p):(u=e*Math.pow(2,p-1)*Math.pow(2,i),o=0));i>=8;r[t+E]=u&255,E+= +C,u/=256,i-=8);for(o=o<0;r[t+E]=o&255,E+=C,o/=256,l-=8);r[t+E-C]|=D*128}});var ai=T(Re=>{"use strict";d();var jt=jn(),Le=Hn(),$n=typeof Symbol=="function"&&typeof Symbol.for== +"function"?Symbol.for("nodejs.util.inspect.custom"):null;Re.Buffer=h;Re.SlowBuffer=Qo;Re.INSPECT_MAX_BYTES= +50;var dt=2147483647;Re.kMaxLength=dt;h.TYPED_ARRAY_SUPPORT=Uo();!h.TYPED_ARRAY_SUPPORT&&typeof console< "u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) su\ -pport which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Mo(){ +pport which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Uo(){ try{let r=new Uint8Array(1),e={foo:a(function(){return 42},"foo")};return Object.setPrototypeOf(e,Uint8Array. -prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}a(Mo,"typedArraySupport");Object. +prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}a(Uo,"typedArraySupport");Object. defineProperty(h.prototype,"parent",{enumerable:!0,get:a(function(){if(h.isBuffer(this))return this. buffer},"get")});Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:a(function(){if(h.isBuffer( -this))return this.byteOffset},"get")});function pe(r){if(r>ht)throw new RangeError('The value "'+r+'\ +this))return this.byteOffset},"get")});function fe(r){if(r>dt)throw new RangeError('The value "'+r+'\ " is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,h.prototype), -e}a(pe,"createBuffer");function h(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError( -'The "string" argument must be of type string. Received type number');return Gt(r)}return Vn(r,e,t)} -a(h,"Buffer");h.poolSize=8192;function Vn(r,e,t){if(typeof r=="string")return Do(r,e);if(ArrayBuffer. -isView(r))return Oo(r);if(r==null)throw new TypeError("The first argument must be one of type string\ -, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(ce(r,ArrayBuffer)|| -r&&ce(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ce(r,SharedArrayBuffer)||r&&ce(r.buffer, -SharedArrayBuffer)))return Ht(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument\ +e}a(fe,"createBuffer");function h(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError( +'The "string" argument must be of type string. Received type number');return Vt(r)}return Kn(r,e,t)} +a(h,"Buffer");h.poolSize=8192;function Kn(r,e,t){if(typeof r=="string")return Oo(r,e);if(ArrayBuffer. +isView(r))return No(r);if(r==null)throw new TypeError("The first argument must be one of type string\ +, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(ae(r,ArrayBuffer)|| +r&&ae(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ae(r,SharedArrayBuffer)||r&&ae(r.buffer, +SharedArrayBuffer)))return $t(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument\ must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return h. from(n,e,t);let i=qo(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol. toPrimitive]=="function")return h.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The\ first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Receiv\ -ed type "+typeof r)}a(Vn,"from");h.from=function(r,e,t){return Vn(r,e,t)};Object.setPrototypeOf(h.prototype, -Uint8Array.prototype);Object.setPrototypeOf(h,Uint8Array);function zn(r){if(typeof r!="number")throw new TypeError( +ed type "+typeof r)}a(Kn,"from");h.from=function(r,e,t){return Kn(r,e,t)};Object.setPrototypeOf(h.prototype, +Uint8Array.prototype);Object.setPrototypeOf(h,Uint8Array);function Yn(r){if(typeof r!="number")throw new TypeError( '"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid \ -for option "size"')}a(zn,"assertSize");function Uo(r,e,t){return zn(r),r<=0?pe(r):e!==void 0?typeof t== -"string"?pe(r).fill(e,t):pe(r).fill(e):pe(r)}a(Uo,"alloc");h.alloc=function(r,e,t){return Uo(r,e,t)}; -function Gt(r){return zn(r),pe(r<0?0:Vt(r)|0)}a(Gt,"allocUnsafe");h.allocUnsafe=function(r){return Gt( -r)};h.allocUnsafeSlow=function(r){return Gt(r)};function Do(r,e){if((typeof e!="string"||e==="")&&(e= -"utf8"),!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=Kn(r,e)|0,n=pe(t),i=n.write( -r,e);return i!==t&&(n=n.slice(0,i)),n}a(Do,"fromString");function jt(r){let e=r.length<0?0:Vt(r.length)| -0,t=pe(e);for(let n=0;n=ht)throw new RangeError("Attempt to allocate Buffer larger t\ -han maximum size: 0x"+ht.toString(16)+" bytes");return r|0}a(Vt,"checked");function Qo(r){return+r!= +r,e,t),Object.setPrototypeOf(n,h.prototype),n}a($t,"fromArrayBuffer");function qo(r){if(h.isBuffer(r)){ +let e=zt(r.length)|0,t=fe(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r. +length!="number"||Yt(r.length)?fe(0):Ht(r);if(r.type==="Buffer"&&Array.isArray(r.data))return Ht(r.data)} +a(qo,"fromObject");function zt(r){if(r>=dt)throw new RangeError("Attempt to allocate Buffer larger t\ +han maximum size: 0x"+dt.toString(16)+" bytes");return r|0}a(zt,"checked");function Qo(r){return+r!= r&&(r=0),h.alloc(+r)}a(Qo,"SlowBuffer");h.isBuffer=a(function(e){return e!=null&&e._isBuffer===!0&&e!== -h.prototype},"isBuffer");h.compare=a(function(e,t){if(ce(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)), -ce(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(e)||!h.isBuffer(t))throw new TypeError( +h.prototype},"isBuffer");h.compare=a(function(e,t){if(ae(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)), +ae(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(e)||!h.isBuffer(t))throw new TypeError( 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length, i=t.length;for(let s=0,o=Math.min(n,i);si.length?(h.isBuffer(o)||(o=h.from(o)),o.copy(i,s)):Uint8Array.prototype. +if(ae(o,Uint8Array))s+o.length>i.length?(h.isBuffer(o)||(o=h.from(o)),o.copy(i,s)):Uint8Array.prototype. set.call(i,o,s);else if(h.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be \ -an Array of Buffers');s+=o.length}return i},"concat");function Kn(r,e){if(h.isBuffer(r))return r.length; -if(ArrayBuffer.isView(r)||ce(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError( +an Array of Buffers');s+=o.length}return i},"concat");function Xn(r,e){if(h.isBuffer(r))return r.length; +if(ArrayBuffer.isView(r)||ae(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError( 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r); let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(e){case"\ -ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return $t(r).length;case"ucs2":case"\ -ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return ii(r).length;default: -if(i)return n?-1:$t(r).length;e=(""+e).toLowerCase(),i=!0}}a(Kn,"byteLength");h.byteLength=Kn;function No(r,e,t){ +ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Gt(r).length;case"ucs2":case"\ +ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return oi(r).length;default: +if(i)return n?-1:Gt(r).length;e=(""+e).toLowerCase(),i=!0}}a(Xn,"byteLength");h.byteLength=Xn;function Wo(r,e,t){ let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<= 0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Zo(this,e,t);case"u\ -tf8":case"utf-8":return Zn(this,e,t);case"ascii":return Ko(this,e,t);case"latin1":case"binary":return Yo( -this,e,t);case"base64":return Vo(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Jo( -this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}a(No, +tf8":case"utf-8":return Jn(this,e,t);case"ascii":return Yo(this,e,t);case"latin1":case"binary":return Xo( +this,e,t);case"base64":return zo(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Jo( +this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}a(Wo, "slowToString");h.prototype._isBuffer=!0;function _e(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}a(_e,"swap"); h.prototype.swap16=a(function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must \ be a multiple of 16-bits");for(let t=0;tt&&(e+=" ... "),""},"inspect");jn&&(h.prototype[jn]=h.prototype.inspect);h.prototype.compare=a(function(e,t,n,i,s){ -if(ce(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),!h.isBuffer(e))throw new TypeError('The "ta\ +er "+e+">"},"inspect");$n&&(h.prototype[$n]=h.prototype.inspect);h.prototype.compare=a(function(e,t,n,i,s){ +if(ae(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),!h.isBuffer(e))throw new TypeError('The "ta\ rget" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t= 0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),t<0||n>e.length||i<0|| s>this.length)throw new RangeError("out of range index");if(i>=s&&t>=n)return 0;if(i>=s)return-1;if(t>= n)return 1;if(t>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,u=n-t,c=Math.min(o,u),l=this.slice( -i,s),f=e.slice(t,n);for(let y=0;y2147483647? -t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Kt(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r. +i,s),f=e.slice(t,n);for(let p=0;p2147483647? +t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Yt(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r. length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=h.from( -e,n)),h.isBuffer(e))return e.length===0?-1:Hn(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array. +e,n)),h.isBuffer(e))return e.length===0?-1:Gn(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array. prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf. -call(r,e,t):Hn(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}a(Yn,"bidire\ -ctionalIndexOf");function Hn(r,e,t,n,i){let s=1,o=r.length,u=e.length;if(n!==void 0&&(n=String(n).toLowerCase(), +call(r,e,t):Gn(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}a(Zn,"bidire\ +ctionalIndexOf");function Gn(r,e,t,n,i){let s=1,o=r.length,u=e.length;if(n!==void 0&&(n=String(n).toLowerCase(), n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;s=2,o/=2, -u/=2,t/=2}function c(f,y){return s===1?f[y]:f.readUInt16BE(y*s)}a(c,"read");let l;if(i){let f=-1;for(l= +u/=2,t/=2}function c(f,p){return s===1?f[p]:f.readUInt16BE(p*s)}a(c,"read");let l;if(i){let f=-1;for(l= t;lo&&(t=o-u),l=t;l>=0;l--){let f=!0;for(let y=0;yo&&(t=o-u),l=t;l>=0;l--){let f=!0;for(let p=0;pi&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o= -0;o>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.wri\ te(string, encoding, offset[, length]) is no longer supported");let s=this.length-t;if((n===void 0|| n>s)&&(n=s),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buf\ -fer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return Wo(this,e,t,n);case"utf8":case"\ -utf-8":return jo(this,e,t,n);case"ascii":case"latin1":case"binary":return Ho(this,e,t,n);case"base64": -return $o(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Go(this,e,t,n);default: +fer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return jo(this,e,t,n);case"utf8":case"\ +utf-8":return Ho(this,e,t,n);case"ascii":case"latin1":case"binary":return $o(this,e,t,n);case"base64": +return Go(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Vo(this,e,t,n);default: if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},"write");h.prototype. toJSON=a(function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},"toJSO\ -N");function Vo(r,e,t){return e===0&&t===r.length?Wt.fromByteArray(r):Wt.fromByteArray(r.slice(e,t))} -a(Vo,"base64Slice");function Zn(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i239?4:s>223?3:s>191?2:1;if(i+u<=t){let c,l,f,y;switch(u){case 1:s<128&&(o=s);break;case 2:c=r[i+ -1],(c&192)===128&&(y=(s&31)<<6|c&63,y>127&&(o=y));break;case 3:c=r[i+1],l=r[i+2],(c&192)===128&&(l&192)=== -128&&(y=(s&15)<<12|(c&63)<<6|l&63,y>2047&&(y<55296||y>57343)&&(o=y));break;case 4:c=r[i+1],l=r[i+2], -f=r[i+3],(c&192)===128&&(l&192)===128&&(f&192)===128&&(y=(s&15)<<18|(c&63)<<12|(l&63)<<6|f&63,y>65535&& -y<1114112&&(o=y))}}o===null?(o=65533,u=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023), -n.push(o),i+=u}return zo(n)}a(Zn,"utf8Slice");var $n=4096;function zo(r){let e=r.length;if(e<=$n)return String. +N");function zo(r,e,t){return e===0&&t===r.length?jt.fromByteArray(r):jt.fromByteArray(r.slice(e,t))} +a(zo,"base64Slice");function Jn(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i239?4:s>223?3:s>191?2:1;if(i+u<=t){let c,l,f,p;switch(u){case 1:s<128&&(o=s);break;case 2:c=r[i+ +1],(c&192)===128&&(p=(s&31)<<6|c&63,p>127&&(o=p));break;case 3:c=r[i+1],l=r[i+2],(c&192)===128&&(l&192)=== +128&&(p=(s&15)<<12|(c&63)<<6|l&63,p>2047&&(p<55296||p>57343)&&(o=p));break;case 4:c=r[i+1],l=r[i+2], +f=r[i+3],(c&192)===128&&(l&192)===128&&(f&192)===128&&(p=(s&15)<<18|(c&63)<<12|(l&63)<<6|f&63,p>65535&& +p<1114112&&(o=p))}}o===null?(o=65533,u=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023), +n.push(o),i+=u}return Ko(n)}a(Jn,"utf8Slice");var Vn=4096;function Ko(r){let e=r.length;if(e<=Vn)return String. fromCharCode.apply(String,r);let t="",n=0;for(;nn)&&(t=n);let i="";for(let s=e;sn)&&(t=n);let i="";for(let s=e;sn&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t< -e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,h.prototype),i},"slice");function q(r,e,t){ +e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,h.prototype),i},"slice");function N(r,e,t){ if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to \ -access beyond buffer length")}a(q,"checkOffset");h.prototype.readUintLE=h.prototype.readUIntLE=a(function(e,t,n){ -e=e>>>0,t=t>>>0,n||q(e,t,this.length);let i=this[e],s=1,o=0;for(;++o>>0,t=t>>>0,n||q(e, +access beyond buffer length")}a(N,"checkOffset");h.prototype.readUintLE=h.prototype.readUIntLE=a(function(e,t,n){ +e=e>>>0,t=t>>>0,n||N(e,t,this.length);let i=this[e],s=1,o=0;for(;++o>>0,t=t>>>0,n||N(e, t,this.length);let i=this[e+--t],s=1;for(;t>0&&(s*=256);)i+=this[e+--t]*s;return i},"readUIntBE");h. -prototype.readUint8=h.prototype.readUInt8=a(function(e,t){return e=e>>>0,t||q(e,1,this.length),this[e]}, -"readUInt8");h.prototype.readUint16LE=h.prototype.readUInt16LE=a(function(e,t){return e=e>>>0,t||q(e, +prototype.readUint8=h.prototype.readUInt8=a(function(e,t){return e=e>>>0,t||N(e,1,this.length),this[e]}, +"readUInt8");h.prototype.readUint16LE=h.prototype.readUInt16LE=a(function(e,t){return e=e>>>0,t||N(e, 2,this.length),this[e]|this[e+1]<<8},"readUInt16LE");h.prototype.readUint16BE=h.prototype.readUInt16BE= -a(function(e,t){return e=e>>>0,t||q(e,2,this.length),this[e]<<8|this[e+1]},"readUInt16BE");h.prototype. -readUint32LE=h.prototype.readUInt32LE=a(function(e,t){return e=e>>>0,t||q(e,4,this.length),(this[e]| +a(function(e,t){return e=e>>>0,t||N(e,2,this.length),this[e]<<8|this[e+1]},"readUInt16BE");h.prototype. +readUint32LE=h.prototype.readUInt32LE=a(function(e,t){return e=e>>>0,t||N(e,4,this.length),(this[e]| this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},"readUInt32LE");h.prototype.readUint32BE=h.prototype. -readUInt32BE=a(function(e,t){return e=e>>>0,t||q(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+ -2]<<8|this[e+3])},"readUInt32BE");h.prototype.readBigUInt64LE=be(a(function(e){e=e>>>0,Re(e,"offset"); -let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ve(e,this.length-8);let i=t+this[++e]*2**8+this[++e]* +readUInt32BE=a(function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+ +2]<<8|this[e+3])},"readUInt32BE");h.prototype.readBigUInt64LE=ge(a(function(e){e=e>>>0,Be(e,"offset"); +let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ge(e,this.length-8);let i=t+this[++e]*2**8+this[++e]* 2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<< -BigInt(32))},"readBigUInt64LE"));h.prototype.readBigUInt64BE=be(a(function(e){e=e>>>0,Re(e,"offset"); -let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ve(e,this.length-8);let i=t*2**24+this[++e]*2**16+ +BigInt(32))},"readBigUInt64LE"));h.prototype.readBigUInt64BE=ge(a(function(e){e=e>>>0,Be(e,"offset"); +let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ge(e,this.length-8);let i=t*2**24+this[++e]*2**16+ this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<>>0,t=t>>>0,n||q(e,t, +32))+BigInt(s)},"readBigUInt64BE"));h.prototype.readIntLE=a(function(e,t,n){e=e>>>0,t=t>>>0,n||N(e,t, this.length);let i=this[e],s=1,o=0;for(;++o=s&&(i-=Math. -pow(2,8*t)),i},"readIntLE");h.prototype.readIntBE=a(function(e,t,n){e=e>>>0,t=t>>>0,n||q(e,t,this.length); +pow(2,8*t)),i},"readIntLE");h.prototype.readIntBE=a(function(e,t,n){e=e>>>0,t=t>>>0,n||N(e,t,this.length); let i=t,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8* -t)),o},"readIntBE");h.prototype.readInt8=a(function(e,t){return e=e>>>0,t||q(e,1,this.length),this[e]& -128?(255-this[e]+1)*-1:this[e]},"readInt8");h.prototype.readInt16LE=a(function(e,t){e=e>>>0,t||q(e,2, +t)),o},"readIntBE");h.prototype.readInt8=a(function(e,t){return e=e>>>0,t||N(e,1,this.length),this[e]& +128?(255-this[e]+1)*-1:this[e]},"readInt8");h.prototype.readInt16LE=a(function(e,t){e=e>>>0,t||N(e,2, this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},"readInt16LE");h.prototype.readInt16BE= -a(function(e,t){e=e>>>0,t||q(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760: -n},"readInt16BE");h.prototype.readInt32LE=a(function(e,t){return e=e>>>0,t||q(e,4,this.length),this[e]| +a(function(e,t){e=e>>>0,t||N(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760: +n},"readInt16BE");h.prototype.readInt32LE=a(function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]| this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},"readInt32LE");h.prototype.readInt32BE=a(function(e,t){return e= -e>>>0,t||q(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},"readInt32BE");h.prototype. -readBigInt64LE=be(a(function(e){e=e>>>0,Re(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&& -Ve(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<>>0,t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},"readInt32BE");h.prototype. +readBigInt64LE=ge(a(function(e){e=e>>>0,Be(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&& +Ge(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<>>0,Re(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ve(e,this. +ge(a(function(e){e=e>>>0,Be(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ge(e,this. length-8);let i=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<>>0,t||q(e,4,this.length),Be.read(this,e,!0,23,4)},"readFloatLE");h.prototype.readFloatBE= -a(function(e,t){return e=e>>>0,t||q(e,4,this.length),Be.read(this,e,!1,23,4)},"readFloatBE");h.prototype. -readDoubleLE=a(function(e,t){return e=e>>>0,t||q(e,8,this.length),Be.read(this,e,!0,52,8)},"readDoub\ -leLE");h.prototype.readDoubleBE=a(function(e,t){return e=e>>>0,t||q(e,8,this.length),Be.read(this,e, +return e=e>>>0,t||N(e,4,this.length),Le.read(this,e,!0,23,4)},"readFloatLE");h.prototype.readFloatBE= +a(function(e,t){return e=e>>>0,t||N(e,4,this.length),Le.read(this,e,!1,23,4)},"readFloatBE");h.prototype. +readDoubleLE=a(function(e,t){return e=e>>>0,t||N(e,8,this.length),Le.read(this,e,!0,52,8)},"readDoub\ +leLE");h.prototype.readDoubleBE=a(function(e,t){return e=e>>>0,t||N(e,8,this.length),Le.read(this,e, !1,52,8)},"readDoubleBE");function V(r,e,t,n,i,s){if(!h.isBuffer(r))throw new TypeError('"buffer" ar\ gument must be a Buffer instance');if(e>i||er.length)throw new RangeError("Index out of range")}a(V,"checkInt");h.prototype.writeUintLE= @@ -207,14 +207,14 @@ e>>>8,t+2},"writeUInt16LE");h.prototype.writeUint16BE=h.prototype.writeUInt16BE= writeUint32LE=h.prototype.writeUInt32LE=a(function(e,t,n){return e=+e,t=t>>>0,n||V(this,e,t,4,4294967295, 0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},"writeUInt32LE");h.prototype. writeUint32BE=h.prototype.writeUInt32BE=a(function(e,t,n){return e=+e,t=t>>>0,n||V(this,e,t,4,4294967295, -0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},"writeUInt32BE");function Jn(r,e,t,n,i){ -ni(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295));r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]= +0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},"writeUInt32BE");function ei(r,e,t,n,i){ +si(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295));r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]= s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>> -8,r[t++]=o,t}a(Jn,"wrtBigUInt64LE");function Xn(r,e,t,n,i){ni(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295)); +8,r[t++]=o,t}a(ei,"wrtBigUInt64LE");function ti(r,e,t,n,i){si(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295)); r[t+7]=s,s=s>>8,r[t+6]=s,s=s>>8,r[t+5]=s,s=s>>8,r[t+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295)); -return r[t+3]=o,o=o>>8,r[t+2]=o,o=o>>8,r[t+1]=o,o=o>>8,r[t]=o,t+8}a(Xn,"wrtBigUInt64BE");h.prototype. -writeBigUInt64LE=be(a(function(e,t=0){return Jn(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))},"w\ -riteBigUInt64LE"));h.prototype.writeBigUInt64BE=be(a(function(e,t=0){return Xn(this,e,t,BigInt(0),BigInt( +return r[t+3]=o,o=o>>8,r[t+2]=o,o=o>>8,r[t+1]=o,o=o>>8,r[t]=o,t+8}a(ti,"wrtBigUInt64BE");h.prototype. +writeBigUInt64LE=ge(a(function(e,t=0){return ei(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))},"w\ +riteBigUInt64LE"));h.prototype.writeBigUInt64BE=ge(a(function(e,t=0){return ti(this,e,t,BigInt(0),BigInt( "0xffffffffffffffff"))},"writeBigUInt64BE"));h.prototype.writeIntLE=a(function(e,t,n,i){if(e=+e,t=t>>> 0,!i){let c=Math.pow(2,8*n-1);V(this,e,t,n,c-1,-c)}let s=0,o=1,u=0;for(this[t]=e&255;++s>0)-u&255;return t+n},"writeIntLE");h.prototype.writeIntBE= @@ -228,17 +228,17 @@ writeInt16BE=a(function(e,t,n){return e=+e,t=t>>>0,n||V(this,e,t,2,32767,-32768) e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},"\ writeInt32LE");h.prototype.writeInt32BE=a(function(e,t,n){return e=+e,t=t>>>0,n||V(this,e,t,4,2147483647, -2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255, -t+4},"writeInt32BE");h.prototype.writeBigInt64LE=be(a(function(e,t=0){return Jn(this,e,t,-BigInt("0x\ -8000000000000000"),BigInt("0x7fffffffffffffff"))},"writeBigInt64LE"));h.prototype.writeBigInt64BE=be( -a(function(e,t=0){return Xn(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))},"w\ -riteBigInt64BE"));function ei(r,e,t,n,i,s){if(t+n>r.length)throw new RangeError("Index out of range"); -if(t<0)throw new RangeError("Index out of range")}a(ei,"checkIEEE754");function ti(r,e,t,n,i){return e= -+e,t=t>>>0,i||ei(r,e,t,4,34028234663852886e22,-34028234663852886e22),Be.write(r,e,t,n,23,4),t+4}a(ti, -"writeFloat");h.prototype.writeFloatLE=a(function(e,t,n){return ti(this,e,t,!0,n)},"writeFloatLE");h. -prototype.writeFloatBE=a(function(e,t,n){return ti(this,e,t,!1,n)},"writeFloatBE");function ri(r,e,t,n,i){ -return e=+e,t=t>>>0,i||ei(r,e,t,8,17976931348623157e292,-17976931348623157e292),Be.write(r,e,t,n,52, -8),t+8}a(ri,"writeDouble");h.prototype.writeDoubleLE=a(function(e,t,n){return ri(this,e,t,!0,n)},"wr\ -iteDoubleLE");h.prototype.writeDoubleBE=a(function(e,t,n){return ri(this,e,t,!1,n)},"writeDoubleBE"); +t+4},"writeInt32BE");h.prototype.writeBigInt64LE=ge(a(function(e,t=0){return ei(this,e,t,-BigInt("0x\ +8000000000000000"),BigInt("0x7fffffffffffffff"))},"writeBigInt64LE"));h.prototype.writeBigInt64BE=ge( +a(function(e,t=0){return ti(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))},"w\ +riteBigInt64BE"));function ri(r,e,t,n,i,s){if(t+n>r.length)throw new RangeError("Index out of range"); +if(t<0)throw new RangeError("Index out of range")}a(ri,"checkIEEE754");function ni(r,e,t,n,i){return e= ++e,t=t>>>0,i||ri(r,e,t,4,34028234663852886e22,-34028234663852886e22),Le.write(r,e,t,n,23,4),t+4}a(ni, +"writeFloat");h.prototype.writeFloatLE=a(function(e,t,n){return ni(this,e,t,!0,n)},"writeFloatLE");h. +prototype.writeFloatBE=a(function(e,t,n){return ni(this,e,t,!1,n)},"writeFloatBE");function ii(r,e,t,n,i){ +return e=+e,t=t>>>0,i||ri(r,e,t,8,17976931348623157e292,-17976931348623157e292),Le.write(r,e,t,n,52, +8),t+8}a(ii,"writeDouble");h.prototype.writeDoubleLE=a(function(e,t,n){return ii(this,e,t,!0,n)},"wr\ +iteDoubleLE");h.prototype.writeDoubleBE=a(function(e,t,n){return ii(this,e,t,!1,n)},"writeDoubleBE"); h.prototype.copy=a(function(e,t,n,i){if(!h.isBuffer(e))throw new TypeError("argument should be a Buf\ fer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i>>0,n=n===void 0?this.length:n>>> 0,e||(e=0);let s;if(typeof e=="number")for(s=t;s2**32?i=Gn(String(t)):typeof t=="bigint"&&(i=String( -t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=Gn(i)),i+="n"),n+=` It must be ${e}. Re\ -ceived ${i}`,n},RangeError);function Gn(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`\ -_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}a(Gn,"addNumericalSeparator");function Xo(r,e,t){ -Re(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&Ve(e,r.length-(t+1))}a(Xo,"checkBounds");function ni(r,e,t,n,i,s){ +e ${typeof e}`},TypeError);Kt("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out o\ +f range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=zn(String(t)):typeof t=="bigint"&&(i=String( +t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=zn(i)),i+="n"),n+=` It must be ${e}. Re\ +ceived ${i}`,n},RangeError);function zn(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`\ +_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}a(zn,"addNumericalSeparator");function ea(r,e,t){ +Be(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&Ge(e,r.length-(t+1))}a(ea,"checkBounds");function si(r,e,t,n,i,s){ if(r>t||r3?e===0||e===BigInt(0)?u=`>= 0${o} and < 2${o}\ ** ${(s+1)*8}${o}`:u=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:u=`>= ${e}${o} a\ -nd <= ${t}${o}`,new Pe.ERR_OUT_OF_RANGE("value",u,r)}Xo(n,i,s)}a(ni,"checkIntBI");function Re(r,e){if(typeof r!= -"number")throw new Pe.ERR_INVALID_ARG_TYPE(e,"number",r)}a(Re,"validateNumber");function Ve(r,e,t){throw Math. -floor(r)!==r?(Re(r,t),new Pe.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new Pe.ERR_BUFFER_OUT_OF_BOUNDS: -new Pe.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}a(Ve,"boundsError");var ea=/[^+/0-9A-Za-z-_]/g; -function ta(r){if(r=r.split("=")[0],r=r.trim().replace(ea,""),r.length<2)return"";for(;r.length%4!== -0;)r=r+"=";return r}a(ta,"base64clean");function $t(r,e){e=e||1/0;let t,n=r.length,i=null,s=[];for(let o=0;o< +nd <= ${t}${o}`,new Pe.ERR_OUT_OF_RANGE("value",u,r)}ea(n,i,s)}a(si,"checkIntBI");function Be(r,e){if(typeof r!= +"number")throw new Pe.ERR_INVALID_ARG_TYPE(e,"number",r)}a(Be,"validateNumber");function Ge(r,e,t){throw Math. +floor(r)!==r?(Be(r,t),new Pe.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new Pe.ERR_BUFFER_OUT_OF_BOUNDS: +new Pe.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}a(Ge,"boundsError");var ta=/[^+/0-9A-Za-z-_]/g; +function ra(r){if(r=r.split("=")[0],r=r.trim().replace(ta,""),r.length<2)return"";for(;r.length%4!== +0;)r=r+"=";return r}a(ra,"base64clean");function Gt(r,e){e=e||1/0;let t,n=r.length,i=null,s=[];for(let o=0;o< n;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+ 1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189), i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,t<128){if((e-= 1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-= 3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18| -240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}a($t,"utf\ -8ToBytes");function ra(r){let e=[];for(let t=0;t>8,i=t%256,s.push(i),s.push(n);return s}a(na,"utf16leToBytes");function ii(r){return Wt.toByteArray( -ta(r))}a(ii,"base64ToBytes");function pt(r,e,t,n){let i;for(i=0;i=e.length||i>=r.length);++i) -e[i+t]=r[i];return i}a(pt,"blitBuffer");function ce(r,e){return r instanceof e||r!=null&&r.constructor!= -null&&r.constructor.name!=null&&r.constructor.name===e.name}a(ce,"isInstance");function Kt(r){return r!== -r}a(Kt,"numberIsNaN");var ia=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){ -let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e}();function be(r){return typeof BigInt>"u"? -sa:r}a(be,"defineBigIntMethod");function sa(){throw new Error("BigInt not supported")}a(sa,"BufferBi\ -gIntNotDefined")});var b,v,x,d,m,p=G(()=>{"use strict";b=globalThis,v=globalThis.setImmediate??(r=>setTimeout(r,0)),x=globalThis. -clearImmediate??(r=>clearTimeout(r)),d=typeof globalThis.Buffer=="function"&&typeof globalThis.Buffer. -allocUnsafe=="function"?globalThis.Buffer:si().Buffer,m=globalThis.process??{};m.env??(m.env={});try{ -m.nextTick(()=>{})}catch{let e=Promise.resolve();m.nextTick=e.then.bind(e)}});var ve=T((Fl,Yt)=>{"use strict";p();var Fe=typeof Reflect=="object"?Reflect:null,oi=Fe&&typeof Fe.apply== -"function"?Fe.apply:a(function(e,t,n){return Function.prototype.apply.call(e,t,n)},"ReflectApply"),dt; -Fe&&typeof Fe.ownKeys=="function"?dt=Fe.ownKeys:Object.getOwnPropertySymbols?dt=a(function(e){return Object. -getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))},"ReflectOwnKeys"):dt=a(function(e){return Object. -getOwnPropertyNames(e)},"ReflectOwnKeys");function oa(r){console&&console.warn&&console.warn(r)}a(oa, -"ProcessEmitWarning");var ui=Number.isNaN||a(function(e){return e!==e},"NumberIsNaN");function B(){B. -init.call(this)}a(B,"EventEmitter");Yt.exports=B;Yt.exports.once=la;B.EventEmitter=B;B.prototype._events= -void 0;B.prototype._eventsCount=0;B.prototype._maxListeners=void 0;var ai=10;function yt(r){if(typeof r!= +240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}a(Gt,"utf\ +8ToBytes");function na(r){let e=[];for(let t=0;t>8,i=t%256,s.push(i),s.push(n);return s}a(ia,"utf16leToBytes");function oi(r){return jt.toByteArray( +ra(r))}a(oi,"base64ToBytes");function pt(r,e,t,n){let i;for(i=0;i=e.length||i>=r.length);++i) +e[i+t]=r[i];return i}a(pt,"blitBuffer");function ae(r,e){return r instanceof e||r!=null&&r.constructor!= +null&&r.constructor.name!=null&&r.constructor.name===e.name}a(ae,"isInstance");function Yt(r){return r!== +r}a(Yt,"numberIsNaN");var sa=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){ +let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e}();function ge(r){return typeof BigInt>"u"? +oa:r}a(ge,"defineBigIntMethod");function oa(){throw new Error("BigInt not supported")}a(oa,"BufferBi\ +gIntNotDefined")});var v,S,x,y,m,d=G(()=>{"use strict";v=globalThis,S=globalThis.setImmediate??(r=>setTimeout(r,0)),x=globalThis. +clearImmediate??(r=>clearTimeout(r)),y=typeof globalThis.Buffer=="function"&&typeof globalThis.Buffer. +allocUnsafe=="function"?globalThis.Buffer:ai().Buffer,m=globalThis.process??{};m.env??(m.env={});try{ +m.nextTick(()=>{})}catch{let e=Promise.resolve();m.nextTick=e.then.bind(e)}});var be=T((Fl,Xt)=>{"use strict";d();var ke=typeof Reflect=="object"?Reflect:null,ui=ke&&typeof ke.apply== +"function"?ke.apply:a(function(e,t,n){return Function.prototype.apply.call(e,t,n)},"ReflectApply"),yt; +ke&&typeof ke.ownKeys=="function"?yt=ke.ownKeys:Object.getOwnPropertySymbols?yt=a(function(e){return Object. +getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))},"ReflectOwnKeys"):yt=a(function(e){return Object. +getOwnPropertyNames(e)},"ReflectOwnKeys");function aa(r){console&&console.warn&&console.warn(r)}a(aa, +"ProcessEmitWarning");var li=Number.isNaN||a(function(e){return e!==e},"NumberIsNaN");function L(){L. +init.call(this)}a(L,"EventEmitter");Xt.exports=L;Xt.exports.once=fa;L.EventEmitter=L;L.prototype._events= +void 0;L.prototype._eventsCount=0;L.prototype._maxListeners=void 0;var ci=10;function mt(r){if(typeof r!= "function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)} -a(yt,"checkListener");Object.defineProperty(B,"defaultMaxListeners",{enumerable:!0,get:a(function(){ -return ai},"get"),set:a(function(r){if(typeof r!="number"||r<0||ui(r))throw new RangeError('The valu\ -e of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");ai=r}, -"set")});B.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&& +a(mt,"checkListener");Object.defineProperty(L,"defaultMaxListeners",{enumerable:!0,get:a(function(){ +return ci},"get"),set:a(function(r){if(typeof r!="number"||r<0||li(r))throw new RangeError('The valu\ +e of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");ci=r}, +"set")});L.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&& (this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}; -B.prototype.setMaxListeners=a(function(e){if(typeof e!="number"||e<0||ui(e))throw new RangeError('Th\ +L.prototype.setMaxListeners=a(function(e){if(typeof e!="number"||e<0||li(e))throw new RangeError('Th\ e value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners= -e,this},"setMaxListeners");function ci(r){return r._maxListeners===void 0?B.defaultMaxListeners:r._maxListeners} -a(ci,"_getMaxListeners");B.prototype.getMaxListeners=a(function(){return ci(this)},"getMaxListeners"); -B.prototype.emit=a(function(e){for(var t=[],n=1;n 0&&(o=t[0]),o instanceof Error)throw o;var u=new Error("Unhandled error."+(o?" ("+o.message+")":"")); -throw u.context=o,u}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")oi(c,this,t);else for(var l=c. -length,f=di(c,l),n=0;n0&&o.length>i&&!o.warned){o.warned= +"function"?o=s[e]=n?[t,o]:[o,t]:n?o.unshift(t):o.push(t),i=fi(r),i>0&&o.length>i&&!o.warned){o.warned= !0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners\ added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter= -r,u.type=e,u.count=o.length,oa(u)}return r}a(li,"_addListener");B.prototype.addListener=a(function(e,t){ -return li(this,e,t,!1)},"addListener");B.prototype.on=B.prototype.addListener;B.prototype.prependListener= -a(function(e,t){return li(this,e,t,!0)},"prependListener");function aa(){if(!this.fired)return this. +r,u.type=e,u.count=o.length,aa(u)}return r}a(hi,"_addListener");L.prototype.addListener=a(function(e,t){ +return hi(this,e,t,!1)},"addListener");L.prototype.on=L.prototype.addListener;L.prototype.prependListener= +a(function(e,t){return hi(this,e,t,!0)},"prependListener");function ua(){if(!this.fired)return this. target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this. -target):this.listener.apply(this.target,arguments)}a(aa,"onceWrapper");function fi(r,e,t){var n={fired:!1, -wrapFn:void 0,target:r,type:e,listener:t},i=aa.bind(n);return i.listener=t,n.wrapFn=i,i}a(fi,"_onceW\ -rap");B.prototype.once=a(function(e,t){return yt(t),this.on(e,fi(this,e,t)),this},"once");B.prototype. -prependOnceListener=a(function(e,t){return yt(t),this.prependListener(e,fi(this,e,t)),this},"prepend\ -OnceListener");B.prototype.removeListener=a(function(e,t){var n,i,s,o,u;if(yt(t),i=this._events,i=== +target):this.listener.apply(this.target,arguments)}a(ua,"onceWrapper");function di(r,e,t){var n={fired:!1, +wrapFn:void 0,target:r,type:e,listener:t},i=ua.bind(n);return i.listener=t,n.wrapFn=i,i}a(di,"_onceW\ +rap");L.prototype.once=a(function(e,t){return mt(t),this.on(e,di(this,e,t)),this},"once");L.prototype. +prependOnceListener=a(function(e,t){return mt(t),this.prependListener(e,di(this,e,t)),this},"prepend\ +OnceListener");L.prototype.removeListener=a(function(e,t){var n,i,s,o,u;if(mt(t),i=this._events,i=== void 0)return this;if(n=i[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0? this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener|| t));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){u=n[o]. -listener,s=o;break}if(s<0)return this;s===0?n.shift():ua(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!== -void 0&&this.emit("removeListener",e,u||t)}return this},"removeListener");B.prototype.off=B.prototype. -removeListener;B.prototype.removeAllListeners=a(function(e){var t,n,i;if(n=this._events,n===void 0)return this; +listener,s=o;break}if(s<0)return this;s===0?n.shift():ca(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!== +void 0&&this.emit("removeListener",e,u||t)}return this},"removeListener");L.prototype.off=L.prototype. +removeListener;L.prototype.removeAllListeners=a(function(e){var t,n,i;if(n=this._events,n===void 0)return this; if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount= 0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments. length===0){var s=Object.keys(n),o;for(i=0;i= -0;i--)this.removeListener(e,t[i]);return this},"removeAllListeners");function hi(r,e,t){var n=r._events; +0;i--)this.removeListener(e,t[i]);return this},"removeAllListeners");function pi(r,e,t){var n=r._events; if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?t?[i.listener||i]:[i]:t? -ca(i):di(i,i.length)}a(hi,"_listeners");B.prototype.listeners=a(function(e){return hi(this,e,!0)},"l\ -isteners");B.prototype.rawListeners=a(function(e){return hi(this,e,!1)},"rawListeners");B.listenerCount= -function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):pi.call(r,e)};B.prototype. -listenerCount=pi;function pi(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function") -return 1;if(t!==void 0)return t.length}return 0}a(pi,"listenerCount");B.prototype.eventNames=a(function(){ -return this._eventsCount>0?dt(this._events):[]},"eventNames");function di(r,e){for(var t=new Array(e), -n=0;n0?yt(this._events):[]},"eventNames");function mi(r,e){for(var t=new Array(e), +n=0;nse,isIP:()=>ha});function ha(r){return 0}var wi,mi,S,se,ke=G(()=>{"use s\ -trict";p();wi=Ae(ve(),1);a(ha,"isIP");mi=/^[^.]+\./,S=class S extends wi.EventEmitter{constructor(){ -super(...arguments);E(this,"opts",{});E(this,"connecting",!1);E(this,"pending",!0);E(this,"writable", -!0);E(this,"encrypted",!1);E(this,"authorized",!1);E(this,"destroyed",!1);E(this,"ws",null);E(this,"\ -writeBuffer");E(this,"tlsState",0);E(this,"tlsRead");E(this,"tlsWrite")}static get poolQueryViaFetch(){ -return S.opts.poolQueryViaFetch??S.defaults.poolQueryViaFetch}static set poolQueryViaFetch(t){S.opts. -poolQueryViaFetch=t}static get fetchEndpoint(){return S.opts.fetchEndpoint??S.defaults.fetchEndpoint}static set fetchEndpoint(t){ -S.opts.fetchEndpoint=t}static get fetchConnectionCache(){return!0}static set fetchConnectionCache(t){ -console.warn("The `fetchConnectionCache` option is deprecated (now always `true`)")}static get fetchFunction(){ -return S.opts.fetchFunction??S.defaults.fetchFunction}static set fetchFunction(t){S.opts.fetchFunction= -t}static get webSocketConstructor(){return S.opts.webSocketConstructor??S.defaults.webSocketConstructor}static set webSocketConstructor(t){ -S.opts.webSocketConstructor=t}get webSocketConstructor(){return this.opts.webSocketConstructor??S.webSocketConstructor}set webSocketConstructor(t){ -this.opts.webSocketConstructor=t}static get wsProxy(){return S.opts.wsProxy??S.defaults.wsProxy}static set wsProxy(t){ -S.opts.wsProxy=t}get wsProxy(){return this.opts.wsProxy??S.wsProxy}set wsProxy(t){this.opts.wsProxy= -t}static get coalesceWrites(){return S.opts.coalesceWrites??S.defaults.coalesceWrites}static set coalesceWrites(t){ -S.opts.coalesceWrites=t}get coalesceWrites(){return this.opts.coalesceWrites??S.coalesceWrites}set coalesceWrites(t){ -this.opts.coalesceWrites=t}static get useSecureWebSocket(){return S.opts.useSecureWebSocket??S.defaults. -useSecureWebSocket}static set useSecureWebSocket(t){S.opts.useSecureWebSocket=t}get useSecureWebSocket(){ -return this.opts.useSecureWebSocket??S.useSecureWebSocket}set useSecureWebSocket(t){this.opts.useSecureWebSocket= -t}static get forceDisablePgSSL(){return S.opts.forceDisablePgSSL??S.defaults.forceDisablePgSSL}static set forceDisablePgSSL(t){ -S.opts.forceDisablePgSSL=t}get forceDisablePgSSL(){return this.opts.forceDisablePgSSL??S.forceDisablePgSSL}set forceDisablePgSSL(t){ -this.opts.forceDisablePgSSL=t}static get disableSNI(){return S.opts.disableSNI??S.defaults.disableSNI}static set disableSNI(t){ -S.opts.disableSNI=t}get disableSNI(){return this.opts.disableSNI??S.disableSNI}set disableSNI(t){this. -opts.disableSNI=t}static get disableWarningInBrowsers(){return S.opts.disableWarningInBrowsers??S.defaults. -disableWarningInBrowsers}static set disableWarningInBrowsers(t){S.opts.disableWarningInBrowsers=t}get disableWarningInBrowsers(){ -return this.opts.disableWarningInBrowsers??S.disableWarningInBrowsers}set disableWarningInBrowsers(t){ -this.opts.disableWarningInBrowsers=t}static get pipelineConnect(){return S.opts.pipelineConnect??S.defaults. -pipelineConnect}static set pipelineConnect(t){S.opts.pipelineConnect=t}get pipelineConnect(){return this. -opts.pipelineConnect??S.pipelineConnect}set pipelineConnect(t){this.opts.pipelineConnect=t}static get subtls(){ -return S.opts.subtls??S.defaults.subtls}static set subtls(t){S.opts.subtls=t}get subtls(){return this. -opts.subtls??S.subtls}set subtls(t){this.opts.subtls=t}static get pipelineTLS(){return S.opts.pipelineTLS?? -S.defaults.pipelineTLS}static set pipelineTLS(t){S.opts.pipelineTLS=t}get pipelineTLS(){return this. -opts.pipelineTLS??S.pipelineTLS}set pipelineTLS(t){this.opts.pipelineTLS=t}static get rootCerts(){return S. -opts.rootCerts??S.defaults.rootCerts}static set rootCerts(t){S.opts.rootCerts=t}get rootCerts(){return this. -opts.rootCerts??S.rootCerts}set rootCerts(t){this.opts.rootCerts=t}wsProxyAddrForHost(t,n){let i=this. -wsProxy;if(i===void 0)throw new Error("No WebSocket proxy is configured. Please see https://github.c\ -om/neondatabase/serverless/blob/main/CONFIG.md#wsproxy-string--host-string-port-number--string--stri\ -ng");return typeof i=="function"?i(t,n):`${i}?address=${t}:${n}`}setNoDelay(){return this}setKeepAlive(){ +ust be of type EventEmitter. Received type '+typeof r)}a(wi,"eventTargetAgnosticAddListener")});var vi={};te(vi,{Socket:()=>ue,isIP:()=>da});function da(r){return 0}var bi,gi,b,ue,Ve=G(()=>{"use s\ +trict";d();bi=Ae(be(),1);a(da,"isIP");gi=/^[^.]+\./,b=class b extends bi.EventEmitter{constructor(){ +super(...arguments);A(this,"opts",{});A(this,"connectionCredentials");A(this,"connecting",!1);A(this, +"pending",!0);A(this,"writable",!0);A(this,"encrypted",!1);A(this,"authorized",!1);A(this,"destroyed", +!1);A(this,"ws",null);A(this,"writeBuffer");A(this,"tlsState",0);A(this,"tlsRead");A(this,"tlsWrite")}setConnectionCredentials(t){ +this.connectionCredentials=t}static get poolQueryViaFetch(){return b.opts.poolQueryViaFetch??b.defaults. +poolQueryViaFetch}static set poolQueryViaFetch(t){b.opts.poolQueryViaFetch=t}static get fetchEndpoint(){ +return b.opts.fetchEndpoint??b.defaults.fetchEndpoint}static set fetchEndpoint(t){b.opts.fetchEndpoint= +t}static get fetchConnectionCache(){return!0}static set fetchConnectionCache(t){console.warn("The `f\ +etchConnectionCache` option is deprecated (now always `true`)")}static get fetchFunction(){return b. +opts.fetchFunction??b.defaults.fetchFunction}static set fetchFunction(t){b.opts.fetchFunction=t}static get webSocketConstructor(){ +return b.opts.webSocketConstructor??b.defaults.webSocketConstructor}static set webSocketConstructor(t){ +b.opts.webSocketConstructor=t}get webSocketConstructor(){return this.opts.webSocketConstructor??b.webSocketConstructor}set webSocketConstructor(t){ +this.opts.webSocketConstructor=t}static get wsProxy(){return b.opts.wsProxy??b.defaults.wsProxy}static set wsProxy(t){ +b.opts.wsProxy=t}get wsProxy(){return this.opts.wsProxy??b.wsProxy}set wsProxy(t){this.opts.wsProxy= +t}static get coalesceWrites(){return b.opts.coalesceWrites??b.defaults.coalesceWrites}static set coalesceWrites(t){ +b.opts.coalesceWrites=t}get coalesceWrites(){return this.opts.coalesceWrites??b.coalesceWrites}set coalesceWrites(t){ +this.opts.coalesceWrites=t}static get useSecureWebSocket(){return b.isNeonLocal?!1:b.opts.useSecureWebSocket?? +b.defaults.useSecureWebSocket}static set useSecureWebSocket(t){b.opts.useSecureWebSocket=t}get useSecureWebSocket(){ +return b.isNeonLocal||this.isNeonLocal?!1:this.opts.useSecureWebSocket??b.useSecureWebSocket}set useSecureWebSocket(t){ +this.opts.useSecureWebSocket=t}static get forceDisablePgSSL(){return b.opts.forceDisablePgSSL??b.defaults. +forceDisablePgSSL}static set forceDisablePgSSL(t){b.opts.forceDisablePgSSL=t}get forceDisablePgSSL(){ +return this.opts.forceDisablePgSSL??b.forceDisablePgSSL}set forceDisablePgSSL(t){this.opts.forceDisablePgSSL= +t}static get disableSNI(){return b.opts.disableSNI??b.defaults.disableSNI}static set disableSNI(t){b. +opts.disableSNI=t}get disableSNI(){return this.opts.disableSNI??b.disableSNI}set disableSNI(t){this. +opts.disableSNI=t}static get disableWarningInBrowsers(){return b.opts.disableWarningInBrowsers??b.defaults. +disableWarningInBrowsers}static set disableWarningInBrowsers(t){b.opts.disableWarningInBrowsers=t}get disableWarningInBrowsers(){ +return this.opts.disableWarningInBrowsers??b.disableWarningInBrowsers}set disableWarningInBrowsers(t){ +this.opts.disableWarningInBrowsers=t}static get pipelineConnect(){return b.opts.pipelineConnect??b.defaults. +pipelineConnect}static set pipelineConnect(t){b.opts.pipelineConnect=t}get pipelineConnect(){return this. +opts.pipelineConnect??b.pipelineConnect}set pipelineConnect(t){this.opts.pipelineConnect=t}static get subtls(){ +return b.opts.subtls??b.defaults.subtls}static set subtls(t){b.opts.subtls=t}get subtls(){return this. +opts.subtls??b.subtls}set subtls(t){this.opts.subtls=t}static get pipelineTLS(){return b.opts.pipelineTLS?? +b.defaults.pipelineTLS}static set pipelineTLS(t){b.opts.pipelineTLS=t}get pipelineTLS(){return this. +opts.pipelineTLS??b.pipelineTLS}set pipelineTLS(t){this.opts.pipelineTLS=t}static get rootCerts(){return b. +opts.rootCerts??b.defaults.rootCerts}static set rootCerts(t){b.opts.rootCerts=t}get rootCerts(){return this. +opts.rootCerts??b.rootCerts}set rootCerts(t){this.opts.rootCerts=t}static get isNeonLocal(){return b. +opts.isNeonLocal??b.defaults.isNeonLocal}static set isNeonLocal(t){b.opts.isNeonLocal=t}get isNeonLocal(){ +return this.opts.isNeonLocal??b.isNeonLocal}set isNeonLocal(t){this.opts.isNeonLocal=t}wsProxyAddrForHost(t,n){ +let i=this.wsProxy;if(i===void 0)throw new Error("No WebSocket proxy is configured. Please see https\ +://github.com/neondatabase/serverless/blob/main/CONFIG.md#wsproxy-string--host-string-port-number--s\ +tring--string");return typeof i=="function"?i(t,n):`${i}?address=${t}:${n}`}setNoDelay(){return this}setKeepAlive(){ return this}ref(){return this}unref(){return this}connect(t,n,i){this.connecting=!0,i&&this.once("co\ nnect",i);let s=a(()=>{this.connecting=!1,this.pending=!1,this.emit("connect"),this.emit("ready")},"\ -handleWebSocketOpen"),o=a((c,l=!1)=>{c.binaryType="arraybuffer",c.addEventListener("error",f=>{this. -emit("error",f),this.emit("close")}),c.addEventListener("message",f=>{if(this.tlsState===0){let y=d. -from(f.data);this.emit("data",y)}}),c.addEventListener("close",()=>{this.emit("close")}),l?s():c.addEventListener( -"open",s)},"configureWebSocket"),u;try{u=this.wsProxyAddrForHost(n,typeof t=="string"?parseInt(t,10): -t)}catch(c){this.emit("error",c),this.emit("close");return}try{let l=(this.useSecureWebSocket?"wss:": -"ws:")+"//"+u;if(this.webSocketConstructor!==void 0)this.ws=new this.webSocketConstructor(l),o(this. -ws);else try{this.ws=new WebSocket(l),o(this.ws)}catch{this.ws=new __unstable_WebSocket(l),o(this.ws)}}catch(c){ -let f=(this.useSecureWebSocket?"https:":"http:")+"//"+u;fetch(f,{headers:{Upgrade:"websocket"}}).then( -y=>{if(this.ws=y.webSocket,this.ws==null)throw c;this.ws.accept(),o(this.ws,!0)}).catch(y=>{this.emit( -"error",new Error(`All attempts to open a WebSocket to connect to the database failed. Please refer \ -to https://github.com/neondatabase/serverless/blob/main/CONFIG.md#websocketconstructor-typeof-websoc\ -ket--undefined. Details: ${y}`)),this.emit("close")})}}async startTls(t){if(this.subtls===void 0)throw new Error( -"For Postgres SSL connections, you must set `neonConfig.subtls` to the subtls library. See https://g\ -ithub.com/neondatabase/serverless/blob/main/CONFIG.md for more information.");this.tlsState=1;let n=await this. -subtls.TrustedCert.databaseFromPEM(this.rootCerts),i=new this.subtls.WebSocketReadQueue(this.ws),s=i. -read.bind(i),o=this.rawWrite.bind(this),{read:u,write:c}=await this.subtls.startTls(t,n,s,o,{useSNI:!this. -disableSNI,expectPreData:this.pipelineTLS?new Uint8Array([83]):void 0});this.tlsRead=u,this.tlsWrite= -c,this.tlsState=2,this.encrypted=!0,this.authorized=!0,this.emit("secureConnection",this),this.tlsReadLoop()}async tlsReadLoop(){ -for(;;){let t=await this.tlsRead();if(t===void 0)break;{let n=d.from(t);this.emit("data",n)}}}rawWrite(t){ +handleWebSocketOpen"),o=a((u,c=!1)=>{u.binaryType="arraybuffer",u.addEventListener("error",l=>{this. +emit("error",l),this.emit("close")}),u.addEventListener("message",l=>{if(this.tlsState===0){let f=y. +from(l.data);this.emit("data",f)}}),u.addEventListener("close",()=>{this.emit("close")}),c?s():u.addEventListener( +"open",s)},"configureWebSocket");try{if(b.isNeonLocal){let c="ws:",l=t&&t!=="443"&&t!=="80"?`:${t}`: +"",f=`${c}//${n}${l}/sql`,p={headers:{Upgrade:"websocket",Connection:"Upgrade"}};if(this.connectionCredentials){ +let E=this.connectionCredentials;E.user&&(p.headers["X-Neon-User"]=E.user),E.password&&(p.headers["X\ +-Neon-Password"]=E.password),E.database&&(p.headers["X-Neon-Database"]=E.database)}let g=this.webSocketConstructor|| +(typeof WebSocket<"u"?WebSocket:void 0);if(!g)throw new Error("No WebSocket implementation available\ +. Please provide a webSocketConstructor.");this.ws=new g(f,p),this.ws&&o(this.ws);return}let u;try{u= +this.wsProxyAddrForHost(n,typeof t=="string"?parseInt(t,10):t)}catch(c){this.emit("error",c),this.emit( +"close");return}try{let l=(this.useSecureWebSocket?"wss:":"ws:")+"//"+u;if(this.webSocketConstructor!== +void 0)this.ws=new this.webSocketConstructor(l),o(this.ws);else try{this.ws=new WebSocket(l),o(this. +ws)}catch{this.ws=new __unstable_WebSocket(l),o(this.ws)}}catch(c){let f=(this.useSecureWebSocket?"h\ +ttps:":"http:")+"//"+u;fetch(f,{headers:{Upgrade:"websocket"}}).then(p=>{if(this.ws=p.webSocket,this. +ws==null)throw c;this.ws.accept(),o(this.ws,!0)}).catch(p=>{this.emit("error",new Error(`All attempt\ +s to open a WebSocket to connect to the database failed. Please refer to https://github.com/neondata\ +base/serverless/blob/main/CONFIG.md#websocketconstructor-typeof-websocket--undefined. Details: ${p}`)), +this.emit("close")})}}catch(u){this.emit("error",new Error(`Failed to establish WebSocket connection\ +. ${u}`)),this.emit("close")}}async startTls(t){if(this.subtls===void 0)throw new Error("For Postgre\ +s SSL connections, you must set `neonConfig.subtls` to the subtls library. See https://github.com/ne\ +ondatabase/serverless/blob/main/CONFIG.md for more information.");this.tlsState=1;let n=await this.subtls. +TrustedCert.databaseFromPEM(this.rootCerts),i=new this.subtls.WebSocketReadQueue(this.ws),s=i.read.bind( +i),o=this.rawWrite.bind(this),{read:u,write:c}=await this.subtls.startTls(t,n,s,o,{useSNI:!this.disableSNI, +expectPreData:this.pipelineTLS?new Uint8Array([83]):void 0});this.tlsRead=u,this.tlsWrite=c,this.tlsState= +2,this.encrypted=!0,this.authorized=!0,this.emit("secureConnection",this),this.tlsReadLoop()}async tlsReadLoop(){ +for(;;){let t=await this.tlsRead();if(t===void 0)break;{let n=y.from(t);this.emit("data",n)}}}rawWrite(t){ if(!this.coalesceWrites){this.ws&&this.ws.send(t);return}if(this.writeBuffer===void 0)this.writeBuffer= t,setTimeout(()=>{this.ws&&this.ws.send(this.writeBuffer),this.writeBuffer=void 0},0);else{let n=new Uint8Array( this.writeBuffer.length+t.length);n.set(this.writeBuffer),n.set(t,this.writeBuffer.length),this.writeBuffer= -n}}write(t,n="utf8",i=s=>{}){return t.length===0?(i(),!0):(typeof t=="string"&&(t=d.from(t,n)),this. +n}}write(t,n="utf8",i=s=>{}){return t.length===0?(i(),!0):(typeof t=="string"&&(t=y.from(t,n)),this. tlsState===0?(this.rawWrite(t),i()):this.tlsState===1?this.once("secureConnection",()=>{this.write(t, -n,i)}):(this.tlsWrite(t),i()),!0)}end(t=d.alloc(0),n="utf8",i=()=>{}){return this.write(t,n,()=>{this. -ws.close(),i()}),this}destroy(){return this.destroyed=!0,this.end()}};a(S,"Socket"),E(S,"defaults",{ -poolQueryViaFetch:!1,fetchEndpoint:a((t,n,i)=>{let s;return i?.jwtAuth?s=t.replace(mi,"apiauth."):s= -t.replace(mi,"api."),"https://"+s+"/sql"},"fetchEndpoint"),fetchConnectionCache:!0,fetchFunction:void 0, -webSocketConstructor:void 0,wsProxy:a(t=>t+"/v2","wsProxy"),useSecureWebSocket:!0,forceDisablePgSSL:!0, -coalesceWrites:!0,pipelineConnect:"password",subtls:void 0,rootCerts:"",pipelineTLS:!1,disableSNI:!1, -disableWarningInBrowsers:!1}),E(S,"opts",{});se=S});var bi={};te(bi,{parse:()=>Zt});function Zt(r,e=!1){let{protocol:t}=new URL(r),n="http:"+r.substring( -t.length),{username:i,password:s,host:o,hostname:u,port:c,pathname:l,search:f,searchParams:y,hash:g}=new URL( -n);s=decodeURIComponent(s),i=decodeURIComponent(i),l=decodeURIComponent(l);let A=i+":"+s,C=e?Object. -fromEntries(y.entries()):f;return{href:r,protocol:t,auth:A,username:i,password:s,host:o,hostname:u,port:c, -pathname:l,search:f,query:C,hash:g}}var Jt=G(()=>{"use strict";p();a(Zt,"parse")});var rr=T(Ci=>{"use strict";p();Ci.parse=function(r,e){return new tr(r,e).parse()};var vt=class vt{constructor(e,t){ -this.source=e,this.transform=t||Ca,this.position=0,this.entries=[],this.recorded=[],this.dimension=0}isEof(){ +n,i)}):(this.tlsWrite(t),i()),!0)}end(t=y.alloc(0),n="utf8",i=()=>{}){return this.write(t,n,()=>{this. +ws.close(),i()}),this}destroy(){return this.destroyed=!0,this.end()}};a(b,"Socket"),A(b,"defaults",{ +poolQueryViaFetch:!1,fetchEndpoint:a((t,n,i)=>{if(b.isNeonLocal){let o="http",u=n&&n!=="443"&&n!=="8\ +0"?`:${n}`:"";return`${o}://${t}${u}/sql`}let s;return i?.jwtAuth?s=t.replace(gi,"apiauth."):s=t.replace( +gi,"api."),"https://"+s+"/sql"},"fetchEndpoint"),fetchConnectionCache:!0,fetchFunction:void 0,webSocketConstructor:void 0, +wsProxy:a(t=>t+"/v2","wsProxy"),useSecureWebSocket:!0,forceDisablePgSSL:!0,coalesceWrites:!0,pipelineConnect:"\ +password",subtls:void 0,rootCerts:"",pipelineTLS:!1,disableSNI:!1,disableWarningInBrowsers:!1,isNeonLocal:!1}), +A(b,"opts",{});ue=b});var Si={};te(Si,{parse:()=>Zt});function Zt(r,e=!1){let{protocol:t}=new URL(r),n="http:"+r.substring( +t.length),{username:i,password:s,host:o,hostname:u,port:c,pathname:l,search:f,searchParams:p,hash:g}=new URL( +n);s=decodeURIComponent(s),i=decodeURIComponent(i),l=decodeURIComponent(l);let E=i+":"+s,C=e?Object. +fromEntries(p.entries()):f;return{href:r,protocol:t,auth:E,username:i,password:s,host:o,hostname:u,port:c, +pathname:l,search:f,query:C,hash:g}}var Jt=G(()=>{"use strict";d();a(Zt,"parse")});var nr=T(Ii=>{"use strict";d();Ii.parse=function(r,e){return new rr(r,e).parse()};var St=class St{constructor(e,t){ +this.source=e,this.transform=t||_a,this.position=0,this.entries=[],this.recorded=[],this.dimension=0}isEof(){ return this.position>=this.source.length}nextCharacter(){var e=this.source[this.position++];return e=== "\\"?{value:this.source[this.position++],escaped:!0}:{value:e,escaped:!1}}record(e){this.recorded.push( e)}newEntry(e){var t;(this.recorded.length>0||e)&&(t=this.recorded.join(""),t==="NULL"&&!e&&(t=null), t!==null&&(t=this.transform(t)),this.entries.push(t),this.recorded=[])}consumeDimensions(){if(this.source[0]=== "[")for(;!this.isEof();){var e=this.nextCharacter();if(e.value==="=")break}}parse(e){var t,n,i;for(this. consumeDimensions();!this.isEof();)if(t=this.nextCharacter(),t.value==="{"&&!i)this.dimension++,this. -dimension>1&&(n=new vt(this.source.substr(this.position-1),this.transform),this.entries.push(n.parse( +dimension>1&&(n=new St(this.source.substr(this.position-1),this.transform),this.entries.push(n.parse( !0)),this.position+=n.position-2);else if(t.value==="}"&&!i){if(this.dimension--,!this.dimension&&(this. newEntry(),e))return this.entries}else t.value==='"'&&!t.escaped?(i&&this.newEntry(!0),i=!i):t.value=== ","&&!i?this.newEntry():this.record(t.value);if(this.dimension!==0)throw new Error("array dimension \ -not balanced");return this.entries}};a(vt,"ArrayParser");var tr=vt;function Ca(r){return r}a(Ca,"ide\ -ntity")});var nr=T((Xl,_i)=>{p();var _a=rr();_i.exports={create:a(function(r,e){return{parse:a(function(){return _a. -parse(r,e)},"parse")}},"create")}});var Pi=T((rf,Ti)=>{"use strict";p();var Ia=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/, -Ta=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,Pa=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,Ba=/^-?infinity$/;Ti. -exports=a(function(e){if(Ba.test(e))return Number(e.replace("i","I"));var t=Ia.exec(e);if(!t)return Ra( -e)||null;var n=!!t[8],i=parseInt(t[1],10);n&&(i=Ii(i));var s=parseInt(t[2],10)-1,o=t[3],u=parseInt(t[4], -10),c=parseInt(t[5],10),l=parseInt(t[6],10),f=t[7];f=f?1e3*parseFloat(f):0;var y,g=La(e);return g!=null? -(y=new Date(Date.UTC(i,s,o,u,c,l,f)),ir(i)&&y.setUTCFullYear(i),g!==0&&y.setTime(y.getTime()-g)):(y= -new Date(i,s,o,u,c,l,f),ir(i)&&y.setFullYear(i)),y},"parseDate");function Ra(r){var e=Ta.exec(r);if(e){ -var t=parseInt(e[1],10),n=!!e[4];n&&(t=Ii(t));var i=parseInt(e[2],10)-1,s=e[3],o=new Date(t,i,s);return ir( -t)&&o.setFullYear(t),o}}a(Ra,"getDate");function La(r){if(r.endsWith("+00"))return 0;var e=Pa.exec(r. +not balanced");return this.entries}};a(St,"ArrayParser");var rr=St;function _a(r){return r}a(_a,"ide\ +ntity")});var ir=T((ef,Ti)=>{d();var Ia=nr();Ti.exports={create:a(function(r,e){return{parse:a(function(){return Ia. +parse(r,e)},"parse")}},"create")}});var Bi=T((nf,Li)=>{"use strict";d();var Ta=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/, +Pa=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,La=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,Ba=/^-?infinity$/;Li. +exports=a(function(e){if(Ba.test(e))return Number(e.replace("i","I"));var t=Ta.exec(e);if(!t)return Ra( +e)||null;var n=!!t[8],i=parseInt(t[1],10);n&&(i=Pi(i));var s=parseInt(t[2],10)-1,o=t[3],u=parseInt(t[4], +10),c=parseInt(t[5],10),l=parseInt(t[6],10),f=t[7];f=f?1e3*parseFloat(f):0;var p,g=ka(e);return g!=null? +(p=new Date(Date.UTC(i,s,o,u,c,l,f)),sr(i)&&p.setUTCFullYear(i),g!==0&&p.setTime(p.getTime()-g)):(p= +new Date(i,s,o,u,c,l,f),sr(i)&&p.setFullYear(i)),p},"parseDate");function Ra(r){var e=Pa.exec(r);if(e){ +var t=parseInt(e[1],10),n=!!e[4];n&&(t=Pi(t));var i=parseInt(e[2],10)-1,s=e[3],o=new Date(t,i,s);return sr( +t)&&o.setFullYear(t),o}}a(Ra,"getDate");function ka(r){if(r.endsWith("+00"))return 0;var e=La.exec(r. split(" ")[1]);if(e){var t=e[1];if(t==="Z")return 0;var n=t==="-"?-1:1,i=parseInt(e[2],10)*3600+parseInt( -e[3]||0,10)*60+parseInt(e[4]||0,10);return i*n*1e3}}a(La,"timeZoneOffset");function Ii(r){return-(r- -1)}a(Ii,"bcYearToNegativeYear");function ir(r){return r>=0&&r<100}a(ir,"is0To99")});var Ri=T((of,Bi)=>{p();Bi.exports=ka;var Fa=Object.prototype.hasOwnProperty;function ka(r){for(var e=1;e< -arguments.length;e++){var t=arguments[e];for(var n in t)Fa.call(t,n)&&(r[n]=t[n])}return r}a(ka,"ext\ -end")});var ki=T((cf,Fi)=>{"use strict";p();var Ma=Ri();Fi.exports=De;function De(r){if(!(this instanceof De)) -return new De(r);Ma(this,Va(r))}a(De,"PostgresInterval");var Ua=["seconds","minutes","hours","days", -"months","years"];De.prototype.toPostgres=function(){var r=Ua.filter(this.hasOwnProperty,this);return this. +e[3]||0,10)*60+parseInt(e[4]||0,10);return i*n*1e3}}a(ka,"timeZoneOffset");function Pi(r){return-(r- +1)}a(Pi,"bcYearToNegativeYear");function sr(r){return r>=0&&r<100}a(sr,"is0To99")});var ki=T((af,Ri)=>{d();Ri.exports=Ma;var Fa=Object.prototype.hasOwnProperty;function Ma(r){for(var e=1;e< +arguments.length;e++){var t=arguments[e];for(var n in t)Fa.call(t,n)&&(r[n]=t[n])}return r}a(Ma,"ext\ +end")});var Ui=T((lf,Mi)=>{"use strict";d();var Ua=ki();Mi.exports=Ue;function Ue(r){if(!(this instanceof Ue)) +return new Ue(r);Ua(this,za(r))}a(Ue,"PostgresInterval");var Da=["seconds","minutes","hours","days", +"months","years"];Ue.prototype.toPostgres=function(){var r=Da.filter(this.hasOwnProperty,this);return this. milliseconds&&r.indexOf("seconds")<0&&r.push("seconds"),r.length===0?"0":r.map(function(e){var t=this[e]|| 0;return e==="seconds"&&this.milliseconds&&(t=(t+this.milliseconds/1e3).toFixed(6).replace(/\.?0+$/, -"")),t+" "+e},this).join(" ")};var Da={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"\ -S"},Oa=["years","months","days"],qa=["hours","minutes","seconds"];De.prototype.toISOString=De.prototype. -toISO=function(){var r=Oa.map(t,this).join(""),e=qa.map(t,this).join("");return"P"+r+"T"+e;function t(n){ +"")),t+" "+e},this).join(" ")};var Oa={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"\ +S"},Na=["years","months","days"],qa=["hours","minutes","seconds"];Ue.prototype.toISOString=Ue.prototype. +toISO=function(){var r=Na.map(t,this).join(""),e=qa.map(t,this).join("");return"P"+r+"T"+e;function t(n){ var i=this[n]||0;return n==="seconds"&&this.milliseconds&&(i=(i+this.milliseconds/1e3).toFixed(6).replace( -/0+$/,"")),i+Da[n]}};var sr="([+-]?\\d+)",Qa=sr+"\\s+years?",Na=sr+"\\s+mons?",Wa=sr+"\\s+days?",ja="\ -([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",Ha=new RegExp([Qa,Na,Wa,ja].map(function(r){return"\ -("+r+")?"}).join("\\s*")),Li={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12}, -$a=["hours","minutes","seconds","milliseconds"];function Ga(r){var e=r+"000000".slice(r.length);return parseInt( -e,10)/1e3}a(Ga,"parseMilliseconds");function Va(r){if(!r)return{};var e=Ha.exec(r),t=e[8]==="-";return Object. -keys(Li).reduce(function(n,i){var s=Li[i],o=e[s];return!o||(o=i==="milliseconds"?Ga(o):parseInt(o,10), -!o)||(t&&~$a.indexOf(i)&&(o*=-1),n[i]=o),n},{})}a(Va,"parse")});var Ui=T((hf,Mi)=>{"use strict";p();Mi.exports=a(function(e){if(/^\\x/.test(e))return new d(e.substr( +/0+$/,"")),i+Oa[n]}};var or="([+-]?\\d+)",Qa=or+"\\s+years?",Wa=or+"\\s+mons?",ja=or+"\\s+days?",Ha="\ +([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",$a=new RegExp([Qa,Wa,ja,Ha].map(function(r){return"\ +("+r+")?"}).join("\\s*")),Fi={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12}, +Ga=["hours","minutes","seconds","milliseconds"];function Va(r){var e=r+"000000".slice(r.length);return parseInt( +e,10)/1e3}a(Va,"parseMilliseconds");function za(r){if(!r)return{};var e=$a.exec(r),t=e[8]==="-";return Object. +keys(Fi).reduce(function(n,i){var s=Fi[i],o=e[s];return!o||(o=i==="milliseconds"?Va(o):parseInt(o,10), +!o)||(t&&~Ga.indexOf(i)&&(o*=-1),n[i]=o),n},{})}a(za,"parse")});var Oi=T((df,Di)=>{"use strict";d();Di.exports=a(function(e){if(/^\\x/.test(e))return new y(e.substr( 2),"hex");for(var t="",n=0;n{p();var Ye=rr(),Ze=nr(),xt=Pi(),Oi=ki(),qi=Ui();function St(r){return a(function(t){ -return t===null?t:r(t)},"nullAllowed")}a(St,"allowNull");function Qi(r){return r===null?r:r==="TRUE"|| -r==="t"||r==="true"||r==="y"||r==="yes"||r==="on"||r==="1"}a(Qi,"parseBool");function za(r){return r? -Ye.parse(r,Qi):null}a(za,"parseBoolArray");function Ka(r){return parseInt(r,10)}a(Ka,"parseBaseTenIn\ -t");function or(r){return r?Ye.parse(r,St(Ka)):null}a(or,"parseIntegerArray");function Ya(r){return r? -Ye.parse(r,St(function(e){return Ni(e).trim()})):null}a(Ya,"parseBigIntegerArray");var Za=a(function(r){ -if(!r)return null;var e=Ze.create(r,function(t){return t!==null&&(t=lr(t)),t});return e.parse()},"pa\ -rsePointArray"),ar=a(function(r){if(!r)return null;var e=Ze.create(r,function(t){return t!==null&&(t= -parseFloat(t)),t});return e.parse()},"parseFloatArray"),ne=a(function(r){if(!r)return null;var e=Ze. -create(r);return e.parse()},"parseStringArray"),ur=a(function(r){if(!r)return null;var e=Ze.create(r, +"\\";)i++;for(var s=0;s{d();var Ye=nr(),Xe=ir(),xt=Bi(),qi=Ui(),Qi=Oi();function Et(r){return a(function(t){ +return t===null?t:r(t)},"nullAllowed")}a(Et,"allowNull");function Wi(r){return r===null?r:r==="TRUE"|| +r==="t"||r==="true"||r==="y"||r==="yes"||r==="on"||r==="1"}a(Wi,"parseBool");function Ka(r){return r? +Ye.parse(r,Wi):null}a(Ka,"parseBoolArray");function Ya(r){return parseInt(r,10)}a(Ya,"parseBaseTenIn\ +t");function ar(r){return r?Ye.parse(r,Et(Ya)):null}a(ar,"parseIntegerArray");function Xa(r){return r? +Ye.parse(r,Et(function(e){return ji(e).trim()})):null}a(Xa,"parseBigIntegerArray");var Za=a(function(r){ +if(!r)return null;var e=Xe.create(r,function(t){return t!==null&&(t=fr(t)),t});return e.parse()},"pa\ +rsePointArray"),ur=a(function(r){if(!r)return null;var e=Xe.create(r,function(t){return t!==null&&(t= +parseFloat(t)),t});return e.parse()},"parseFloatArray"),ne=a(function(r){if(!r)return null;var e=Xe. +create(r);return e.parse()},"parseStringArray"),cr=a(function(r){if(!r)return null;var e=Xe.create(r, function(t){return t!==null&&(t=xt(t)),t});return e.parse()},"parseDateArray"),Ja=a(function(r){if(!r) -return null;var e=Ze.create(r,function(t){return t!==null&&(t=Oi(t)),t});return e.parse()},"parseInt\ -ervalArray"),Xa=a(function(r){return r?Ye.parse(r,St(qi)):null},"parseByteAArray"),cr=a(function(r){ -return parseInt(r,10)},"parseInteger"),Ni=a(function(r){var e=String(r);return/^\d+$/.test(e)?e:r},"\ -parseBigInteger"),Di=a(function(r){return r?Ye.parse(r,St(JSON.parse)):null},"parseJsonArray"),lr=a( +return null;var e=Xe.create(r,function(t){return t!==null&&(t=qi(t)),t});return e.parse()},"parseInt\ +ervalArray"),eu=a(function(r){return r?Ye.parse(r,Et(Qi)):null},"parseByteAArray"),lr=a(function(r){ +return parseInt(r,10)},"parseInteger"),ji=a(function(r){var e=String(r);return/^\d+$/.test(e)?e:r},"\ +parseBigInteger"),Ni=a(function(r){return r?Ye.parse(r,Et(JSON.parse)):null},"parseJsonArray"),fr=a( function(r){return r[0]!=="("?null:(r=r.substring(1,r.length-1).split(","),{x:parseFloat(r[0]),y:parseFloat( -r[1])})},"parsePoint"),eu=a(function(r){if(r[0]!=="<"&&r[1]!=="(")return null;for(var e="(",t="",n=!1, +r[1])})},"parsePoint"),tu=a(function(r){if(r[0]!=="<"&&r[1]!=="(")return null;for(var e="(",t="",n=!1, i=2;i{"use strict";p();var z=1e6;function ru(r){var e=r.readInt32BE(0),t=r.readUInt32BE( +r[i])}var s=fr(e);return s.radius=parseFloat(t),s},"parseCircle"),ru=a(function(r){r(20,ji),r(21,lr), +r(23,lr),r(26,lr),r(700,parseFloat),r(701,parseFloat),r(16,Wi),r(1082,xt),r(1114,xt),r(1184,xt),r(600, +fr),r(651,ne),r(718,tu),r(1e3,Ka),r(1001,eu),r(1005,ar),r(1007,ar),r(1028,ar),r(1016,Xa),r(1017,Za), +r(1021,ur),r(1022,ur),r(1231,ur),r(1014,ne),r(1015,ne),r(1008,ne),r(1009,ne),r(1040,ne),r(1041,ne),r( +1115,cr),r(1182,cr),r(1185,cr),r(1186,qi),r(1187,Ja),r(17,Qi),r(114,JSON.parse.bind(JSON)),r(3802,JSON. +parse.bind(JSON)),r(199,Ni),r(3807,Ni),r(3907,ne),r(2951,ne),r(791,ne),r(1183,ne),r(1270,ne)},"init"); +Hi.exports={init:ru}});var Vi=T((bf,Gi)=>{"use strict";d();var z=1e6;function nu(r){var e=r.readInt32BE(0),t=r.readUInt32BE( 4),n="";e<0&&(e=~e+(t===0),t=~t+1>>>0,n="-");var i="",s,o,u,c,l,f;{if(s=e%z,e=e/z>>>0,o=4294967296*s+ t,t=o/z>>>0,u=""+(o-z*t),t===0&&e===0)return n+u+i;for(c="",l=6-u.length,f=0;f>>0,o=4294967296*s+t,t=o/z>>>0,u=""+(o-z*t),t===0&&e===0)return n+u+i;for(c="",l=6-u. length,f=0;f>>0,o=4294967296*s+t,t=o/z>>>0,u=""+(o-z*t),t===0&& e===0)return n+u+i;for(c="",l=6-u.length,f=0;f{p();var nu=$i(),L=a(function(r,e,t,n,i){t=t||0,n=n||!1,i=i||function(A,C,D){return A* -Math.pow(2,D)+C};var s=t>>3,o=a(function(A){return n?~A&255:A},"inv"),u=255,c=8-t%8;e>t%8);var l=0;t%8+e>=8&&(l=i(0,o(r[s])&u,c));for(var f=e+t>>3,y=s+1;y0&&(l=i(l,o(r[f])>>8-g,g)),l},"parseBits"),zi=a(function(r,e,t){var n=Math. -pow(2,t-1)-1,i=L(r,1),s=L(r,t,1);if(s===0)return 0;var o=1,u=a(function(l,f,y){l===0&&(l=1);for(var g=1;g<= -y;g++)o/=2,(f&1<0&&(l+=o);return l},"parsePrecisionBits"),c=L(r,e,t+1,!1,u);return s==Math.pow( -2,t+1)-1?c===0?i===0?1/0:-1/0:NaN:(i===0?1:-1)*Math.pow(2,s-n)*c},"parseFloatFromBits"),iu=a(function(r){ -return L(r,1)==1?-1*(L(r,15,1,!0)+1):L(r,15,1)},"parseInt16"),Gi=a(function(r){return L(r,1)==1?-1*(L( -r,31,1,!0)+1):L(r,31,1)},"parseInt32"),su=a(function(r){return zi(r,23,8)},"parseFloat32"),ou=a(function(r){ -return zi(r,52,11)},"parseFloat64"),au=a(function(r){var e=L(r,16,32);if(e==49152)return NaN;for(var t=Math. -pow(1e4,L(r,16,16)),n=0,i=[],s=L(r,16),o=0;o{d();var iu=Vi(),R=a(function(r,e,t,n,i){t=t||0,n=n||!1,i=i||function(E,C,D){return E* +Math.pow(2,D)+C};var s=t>>3,o=a(function(E){return n?~E&255:E},"inv"),u=255,c=8-t%8;e>t%8);var l=0;t%8+e>=8&&(l=i(0,o(r[s])&u,c));for(var f=e+t>>3,p=s+1;p0&&(l=i(l,o(r[f])>>8-g,g)),l},"parseBits"),Yi=a(function(r,e,t){var n=Math. +pow(2,t-1)-1,i=R(r,1),s=R(r,t,1);if(s===0)return 0;var o=1,u=a(function(l,f,p){l===0&&(l=1);for(var g=1;g<= +p;g++)o/=2,(f&1<0&&(l+=o);return l},"parsePrecisionBits"),c=R(r,e,t+1,!1,u);return s==Math.pow( +2,t+1)-1?c===0?i===0?1/0:-1/0:NaN:(i===0?1:-1)*Math.pow(2,s-n)*c},"parseFloatFromBits"),su=a(function(r){ +return R(r,1)==1?-1*(R(r,15,1,!0)+1):R(r,15,1)},"parseInt16"),zi=a(function(r){return R(r,1)==1?-1*(R( +r,31,1,!0)+1):R(r,31,1)},"parseInt32"),ou=a(function(r){return Yi(r,23,8)},"parseFloat32"),au=a(function(r){ +return Yi(r,52,11)},"parseFloat64"),uu=a(function(r){var e=R(r,16,32);if(e==49152)return NaN;for(var t=Math. +pow(1e4,R(r,16,16)),n=0,i=[],s=R(r,16),o=0;o>3,(i+=f<<3)>>3),y;console.log("ERROR: ElementType no\ -t implemented: "+l)},"parseElement"),c=a(function(l,f){var y=[],g;if(l.length>1){var A=l.shift();for(g= -0;g0},"parseBool"),lu=a(function(r){r(20,nu),r(21,iu),r(23,Gi),r(26,Gi),r(1700,au),r(700,su), -r(701,ou),r(16,cu),r(1114,Vi.bind(null,!1)),r(1184,Vi.bind(null,!0)),r(1e3,Je),r(1007,Je),r(1016,Je), -r(1008,Je),r(1009,Je),r(25,uu)},"init");Ki.exports={init:lu}});var Ji=T((Af,Zi)=>{p();Zi.exports={BOOL:16,BYTEA:17,CHAR:18,INT8:20,INT2:21,INT4:23,REGPROC:24,TEXT:25, +usec=s},i.getUTCMicroSeconds=function(){return this.usec},i},"parseDate"),Ze=a(function(r){for(var e=R( +r,32),t=R(r,32,32),n=R(r,32,64),i=96,s=[],o=0;o>3,(i+=f<<3)>>3),p;console.log("ERROR: ElementType no\ +t implemented: "+l)},"parseElement"),c=a(function(l,f){var p=[],g;if(l.length>1){var E=l.shift();for(g= +0;g0},"parseBool"),fu=a(function(r){r(20,iu),r(21,su),r(23,zi),r(26,zi),r(1700,uu),r(700,ou), +r(701,au),r(16,lu),r(1114,Ki.bind(null,!1)),r(1184,Ki.bind(null,!0)),r(1e3,Ze),r(1007,Ze),r(1016,Ze), +r(1008,Ze),r(1009,Ze),r(25,cu)},"init");Xi.exports={init:fu}});var es=T((Cf,Ji)=>{d();Ji.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 tt=T(et=>{p();var fu=ji(),hu=Yi(),pu=nr(),du=Ji();et.getTypeParser=yu;et.setTypeParser=mu;et.arrayParser= -pu;et.builtins=du;var Xe={text:{},binary:{}};function Xi(r){return String(r)}a(Xi,"noParse");function yu(r,e){ -return e=e||"text",Xe[e]&&Xe[e][r]||Xi}a(yu,"getTypeParser");function mu(r,e,t){typeof e=="function"&& -(t=e,e="text"),Xe[e][r]=t}a(mu,"setTypeParser");fu.init(function(r,e){Xe.text[r]=e});hu.init(function(r,e){ -Xe.binary[r]=e})});var At=T((Pf,es)=>{"use strict";p();var wu=tt();function Et(r){this._types=r||wu,this.text={},this.binary= -{}}a(Et,"TypeOverrides");Et.prototype.getOverrides=function(r){switch(r){case"text":return this.text;case"\ -binary":return this.binary;default:return{}}};Et.prototype.setTypeParser=function(r,e,t){typeof e=="\ -function"&&(t=e,e="text"),this.getOverrides(e)[r]=t};Et.prototype.getTypeParser=function(r,e){return e= -e||"text",this.getOverrides(e)[r]||this._types.getTypeParser(r,e)};es.exports=Et});function rt(r){let e=1779033703,t=3144134277,n=1013904242,i=2773480762,s=1359893119,o=2600822924,u=528734635, -c=1541459225,l=0,f=0,y=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748, +REGROLE:4096}});var tt=T(et=>{d();var hu=$i(),du=Zi(),pu=ir(),yu=es();et.getTypeParser=mu;et.setTypeParser=wu;et.arrayParser= +pu;et.builtins=yu;var Je={text:{},binary:{}};function ts(r){return String(r)}a(ts,"noParse");function mu(r,e){ +return e=e||"text",Je[e]&&Je[e][r]||ts}a(mu,"getTypeParser");function wu(r,e,t){typeof e=="function"&& +(t=e,e="text"),Je[e][r]=t}a(wu,"setTypeParser");hu.init(function(r,e){Je.text[r]=e});du.init(function(r,e){ +Je.binary[r]=e})});var Ct=T((Lf,rs)=>{"use strict";d();var gu=tt();function At(r){this._types=r||gu,this.text={},this.binary= +{}}a(At,"TypeOverrides");At.prototype.getOverrides=function(r){switch(r){case"text":return this.text;case"\ +binary":return this.binary;default:return{}}};At.prototype.setTypeParser=function(r,e,t){typeof e=="\ +function"&&(t=e,e="text"),this.getOverrides(e)[r]=t};At.prototype.getTypeParser=function(r,e){return e= +e||"text",this.getOverrides(e)[r]||this._types.getTypeParser(r,e)};rs.exports=At});function rt(r){let e=1779033703,t=3144134277,n=1013904242,i=2773480762,s=1359893119,o=2600822924,u=528734635, +c=1541459225,l=0,f=0,p=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748, 2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401, 4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808, 3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700, 1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909, 275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222, 2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],g=a((I,w)=>I>>>w|I<<32- -w,"rrot"),A=new Uint32Array(64),C=new Uint8Array(64),D=a(()=>{for(let R=0,j=0;R<16;R++,j+=4)A[R]=C[j]<< -24|C[j+1]<<16|C[j+2]<<8|C[j+3];for(let R=16;R<64;R++){let j=g(A[R-15],7)^g(A[R-15],18)^A[R-15]>>>3,fe=g( -A[R-2],17)^g(A[R-2],19)^A[R-2]>>>10;A[R]=A[R-16]+j+A[R-7]+fe|0}let I=e,w=t,Z=n,W=i,J=s,X=o,oe=u,ae=c; -for(let R=0;R<64;R++){let j=g(J,6)^g(J,11)^g(J,25),fe=J&X^~J&oe,me=ae+j+fe+y[R]+A[R]|0,Ge=g(I,2)^g(I, -13)^g(I,22),he=I&w^I&Z^w&Z,Ie=Ge+he|0;ae=oe,oe=X,X=J,J=W+me|0,W=Z,Z=w,w=I,I=me+Ie|0}e=e+I|0,t=t+w|0, -n=n+Z|0,i=i+W|0,s=s+J|0,o=o+X|0,u=u+oe|0,c=c+ae|0,f=0},"process"),Y=a(I=>{typeof I=="string"&&(I=new TextEncoder(). +w,"rrot"),E=new Uint32Array(64),C=new Uint8Array(64),D=a(()=>{for(let B=0,H=0;B<16;B++,H+=4)E[B]=C[H]<< +24|C[H+1]<<16|C[H+2]<<8|C[H+3];for(let B=16;B<64;B++){let H=g(E[B-15],7)^g(E[B-15],18)^E[B-15]>>>3,le=g( +E[B-2],17)^g(E[B-2],19)^E[B-2]>>>10;E[B]=E[B-16]+H+E[B-7]+le|0}let I=e,w=t,X=n,j=i,Z=s,pe=o,J=u,se=c; +for(let B=0;B<64;B++){let H=g(Z,6)^g(Z,11)^g(Z,25),le=Z&pe^~Z&J,ye=se+H+le+p[B]+E[B]|0,Ee=g(I,2)^g(I, +13)^g(I,22),$e=I&w^I&X^w&X,ee=Ee+$e|0;se=J,J=pe,pe=Z,Z=j+ye|0,j=X,X=w,w=I,I=ye+ee|0}e=e+I|0,t=t+w|0, +n=n+X|0,i=i+j|0,s=s+Z|0,o=o+pe|0,u=u+J|0,c=c+se|0,f=0},"process"),Y=a(I=>{typeof I=="string"&&(I=new TextEncoder(). encode(I));for(let w=0;w{if(C[f++]= 128,f==64&&D(),f+8>64){for(;f<64;)C[f++]=0;D()}for(;f<58;)C[f++]=0;let I=l*8;C[f++]=I/1099511627776& 255,C[f++]=I/4294967296&255,C[f++]=I>>>24,C[f++]=I>>>16&255,C[f++]=I>>>8&255,C[f++]=I&255,D();let w=new Uint8Array( @@ -567,9 +579,9 @@ encode(I));for(let w=0;w>>8&255,w[15]=i&255,w[16]=s>>>24,w[17]=s>>>16&255,w[18]=s>>>8&255,w[19]=s&255,w[20]=o>>>24,w[21]= o>>>16&255,w[22]=o>>>8&255,w[23]=o&255,w[24]=u>>>24,w[25]=u>>>16&255,w[26]=u>>>8&255,w[27]=u&255,w[28]= c>>>24,w[29]=c>>>16&255,w[30]=c>>>8&255,w[31]=c&255,w},"digest");return r===void 0?{add:Y,digest:P}: -(Y(r),P())}var ts=G(()=>{"use strict";p();a(rt,"sha256")});var U,nt,rs=G(()=>{"use strict";p();U=class U{constructor(){E(this,"_dataLength",0);E(this,"_bufferL\ -ength",0);E(this,"_state",new Int32Array(4));E(this,"_buffer",new ArrayBuffer(68));E(this,"_buffer8"); -E(this,"_buffer32");this._buffer8=new Uint8Array(this._buffer,0,68),this._buffer32=new Uint32Array(this. +(Y(r),P())}var ns=G(()=>{"use strict";d();a(rt,"sha256")});var U,nt,is=G(()=>{"use strict";d();U=class U{constructor(){A(this,"_dataLength",0);A(this,"_bufferL\ +ength",0);A(this,"_state",new Int32Array(4));A(this,"_buffer",new ArrayBuffer(68));A(this,"_buffer8"); +A(this,"_buffer32");this._buffer8=new Uint8Array(this._buffer,0,68),this._buffer32=new Uint32Array(this. _buffer,0,17),this.start()}static hashByteArray(e,t=!1){return this.onePassHasher.start().appendByteArray( e).end(t)}static hashStr(e,t=!1){return this.onePassHasher.start().appendStr(e).end(t)}static hashAsciiStr(e,t=!1){ return this.onePassHasher.start().appendAsciiStr(e).end(t)}static _hex(e){let t=U.hexChars,n=U.hexOut, @@ -627,128 +639,128 @@ _buffer8,i=this._buffer32,s=(t>>2)+1;this._dataLength+=t;let o=this._dataLength* n[t+2]=n[t+3]=0,i.set(U.buffer32Identity.subarray(s),s),t>55&&(U._md5cycle(this._state,i),i.set(U.buffer32Identity)), o<=4294967295)i[14]=o;else{let u=o.toString(16).match(/(.*?)(.{0,8})$/);if(u===null)return;let c=parseInt( u[2],16),l=parseInt(u[1],16)||0;i[14]=c,i[15]=l}return U._md5cycle(this._state,i),e?this._state:U._hex( -this._state)}};a(U,"Md5"),E(U,"stateIdentity",new Int32Array([1732584193,-271733879,-1732584194,271733878])), -E(U,"buffer32Identity",new Int32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])),E(U,"hexChars","0123456789\ -abcdef"),E(U,"hexOut",[]),E(U,"onePassHasher",new U);nt=U});var fr={};te(fr,{createHash:()=>bu,createHmac:()=>vu,randomBytes:()=>gu});function gu(r){return crypto. -getRandomValues(d.alloc(r))}function bu(r){if(r==="sha256")return{update:a(function(e){return{digest:a( -function(){return d.from(rt(e))},"digest")}},"update")};if(r==="md5")return{update:a(function(e){return{ +this._state)}};a(U,"Md5"),A(U,"stateIdentity",new Int32Array([1732584193,-271733879,-1732584194,271733878])), +A(U,"buffer32Identity",new Int32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])),A(U,"hexChars","0123456789\ +abcdef"),A(U,"hexOut",[]),A(U,"onePassHasher",new U);nt=U});var hr={};te(hr,{createHash:()=>vu,createHmac:()=>Su,randomBytes:()=>bu});function bu(r){return crypto. +getRandomValues(y.alloc(r))}function vu(r){if(r==="sha256")return{update:a(function(e){return{digest:a( +function(){return y.from(rt(e))},"digest")}},"update")};if(r==="md5")return{update:a(function(e){return{ digest:a(function(){return typeof e=="string"?nt.hashStr(e):nt.hashByteArray(e)},"digest")}},"update")}; -throw new Error(`Hash type '${r}' not supported`)}function vu(r,e){if(r!=="sha256")throw new Error(`\ +throw new Error(`Hash type '${r}' not supported`)}function Su(r,e){if(r!=="sha256")throw new Error(`\ Only sha256 is supported (requested: '${r}')`);return{update:a(function(t){return{digest:a(function(){ typeof e=="string"&&(e=new TextEncoder().encode(e)),typeof t=="string"&&(t=new TextEncoder().encode( t));let n=e.length;if(n>64)e=rt(e);else if(n<64){let c=new Uint8Array(64);c.set(e),e=c}let i=new Uint8Array( 64),s=new Uint8Array(64);for(let c=0;c<64;c++)i[c]=54^e[c],s[c]=92^e[c];let o=new Uint8Array(t.length+ -64);o.set(i,0),o.set(t,64);let u=new Uint8Array(96);return u.set(s,0),u.set(rt(o),64),d.from(rt(u))}, -"digest")}},"update")}}var hr=G(()=>{"use strict";p();ts();rs();a(gu,"randomBytes");a(bu,"createHash"); -a(vu,"createHmac")});var it=T((Wf,pr)=>{"use strict";p();pr.exports={host:"localhost",user:m.platform==="win32"?m.env.USERNAME: +64);o.set(i,0),o.set(t,64);let u=new Uint8Array(96);return u.set(s,0),u.set(rt(o),64),y.from(rt(u))}, +"digest")}},"update")}}var dr=G(()=>{"use strict";d();ns();is();a(bu,"randomBytes");a(vu,"createHash"); +a(Su,"createHmac")});var it=T((jf,pr)=>{"use strict";d();pr.exports={host:"localhost",user:m.platform==="win32"?m.env.USERNAME: m.env.USER,database:void 0,password:null,connectionString:void 0,port:5432,rows:0,binary:!1,max:10,idleTimeoutMillis:3e4, 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 Oe=tt(),xu=Oe.getTypeParser(20,"text"),Su=Oe.getTypeParser(1016, -"text");pr.exports.__defineSetter__("parseInt8",function(r){Oe.setTypeParser(20,"text",r?Oe.getTypeParser( -23,"text"):xu),Oe.setTypeParser(1016,"text",r?Oe.getTypeParser(1007,"text"):Su)})});var st=T((Hf,is)=>{"use strict";p();var Eu=(hr(),O(fr)),Au=it();function Cu(r){var e=r.replace(/\\/g, -"\\\\").replace(/"/g,'\\"');return'"'+e+'"'}a(Cu,"escapeElement");function ns(r){for(var e="{",t=0;t< -r.length;t++)t>0&&(e=e+","),r[t]===null||typeof r[t]>"u"?e=e+"NULL":Array.isArray(r[t])?e=e+ns(r[t]): -r[t]instanceof d?e+="\\\\x"+r[t].toString("hex"):e+=Cu(Ct(r[t]));return e=e+"}",e}a(ns,"arrayString"); -var Ct=a(function(r,e){if(r==null)return null;if(r instanceof d)return r;if(ArrayBuffer.isView(r)){var t=d. +keepalives:1,keepalives_idle:0};var De=tt(),xu=De.getTypeParser(20,"text"),Eu=De.getTypeParser(1016, +"text");pr.exports.__defineSetter__("parseInt8",function(r){De.setTypeParser(20,"text",r?De.getTypeParser( +23,"text"):xu),De.setTypeParser(1016,"text",r?De.getTypeParser(1007,"text"):Eu)})});var st=T(($f,os)=>{"use strict";d();var Au=(dr(),O(hr)),Cu=it();function _u(r){var e=r.replace(/\\/g, +"\\\\").replace(/"/g,'\\"');return'"'+e+'"'}a(_u,"escapeElement");function ss(r){for(var e="{",t=0;t< +r.length;t++)t>0&&(e=e+","),r[t]===null||typeof r[t]>"u"?e=e+"NULL":Array.isArray(r[t])?e=e+ss(r[t]): +r[t]instanceof y?e+="\\\\x"+r[t].toString("hex"):e+=_u(_t(r[t]));return e=e+"}",e}a(ss,"arrayString"); +var _t=a(function(r,e){if(r==null)return null;if(r instanceof y)return r;if(ArrayBuffer.isView(r)){var t=y. from(r.buffer,r.byteOffset,r.byteLength);return t.length===r.byteLength?t:t.slice(r.byteOffset,r.byteOffset+ -r.byteLength)}return r instanceof Date?Au.parseInputDatesAsUTC?Tu(r):Iu(r):Array.isArray(r)?ns(r):typeof r== -"object"?_u(r,e):r.toString()},"prepareValue");function _u(r,e){if(r&&typeof r.toPostgres=="function"){ +r.byteLength)}return r instanceof Date?Cu.parseInputDatesAsUTC?Pu(r):Tu(r):Array.isArray(r)?ss(r):typeof r== +"object"?Iu(r,e):r.toString()},"prepareValue");function Iu(r,e){if(r&&typeof r.toPostgres=="function"){ if(e=e||[],e.indexOf(r)!==-1)throw new Error('circular reference detected while preparing "'+r+'" fo\ -r query');return e.push(r),Ct(r.toPostgres(Ct),e)}return JSON.stringify(r)}a(_u,"prepareObject");function N(r,e){ -for(r=""+r;r.lengthku});var ku,at=G(()=>{"use strict";p();ku={}});var ds=T((nh,ps)=>{"use strict";p();var wr=(hr(),O(fr));function Mu(r){if(r.indexOf("SCRAM-SHA-256")=== --1)throw new Error("SASL: Only mechanism SCRAM-SHA-256 is currently supported");let e=wr.randomBytes( +t),r}a(Lu,"normalizeQueryConfig");var yr=a(function(r){return Au.createHash("md5").update(r,"utf-8"). +digest("hex")},"md5"),Bu=a(function(r,e,t){var n=yr(e+r),i=yr(y.concat([y.from(n),t]));return"md5"+i}, +"postgresMd5PasswordHash");os.exports={prepareValue:a(function(e){return _t(e)},"prepareValueWrapper"), +normalizeQueryConfig:Lu,postgresMd5PasswordHash:Bu,md5:yr}});var ot={};te(ot,{default:()=>Mu});var Mu,at=G(()=>{"use strict";d();Mu={}});var ys=T((nh,ps)=>{"use strict";d();var br=(dr(),O(hr));function Uu(r){if(r.indexOf("SCRAM-SHA-256")=== +-1)throw new Error("SASL: Only mechanism SCRAM-SHA-256 is currently supported");let e=br.randomBytes( 18).toString("base64");return{mechanism:"SCRAM-SHA-256",clientNonce:e,response:"n,,n=*,r="+e,message:"\ -SASLInitialResponse"}}a(Mu,"startSession");function Uu(r,e,t){if(r.message!=="SASLInitialResponse")throw new Error( +SASLInitialResponse"}}a(Uu,"startSession");function Du(r,e,t){if(r.message!=="SASLInitialResponse")throw new Error( "SASL: Last message was not SASLInitialResponse");if(typeof e!="string")throw new Error("SASL: SCRAM\ -SERVER-FIRST-MESSAGE: client password must be a string");if(typeof t!="string")throw new Error("SAS\ L: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");let n=qu(t);if(n.nonce.startsWith(r.clientNonce)){ if(n.nonce.length===r.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server n\ once is too short")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not st\ -art with client nonce");var i=d.from(n.salt,"base64"),s=Wu(e,i,n.iteration),o=qe(s,"Client Key"),u=Nu( -o),c="n=*,r="+r.clientNonce,l="r="+n.nonce+",s="+n.salt+",i="+n.iteration,f="c=biws,r="+n.nonce,y=c+ -","+l+","+f,g=qe(u,y),A=hs(o,g),C=A.toString("base64"),D=qe(s,"Server Key"),Y=qe(D,y);r.message="SAS\ -LResponse",r.serverSignature=Y.toString("base64"),r.response=f+",p="+C}a(Uu,"continueSession");function Du(r,e){ +art with client nonce");var i=y.from(n.salt,"base64"),s=ju(e,i,n.iteration),o=Oe(s,"Client Key"),u=Wu( +o),c="n=*,r="+r.clientNonce,l="r="+n.nonce+",s="+n.salt+",i="+n.iteration,f="c=biws,r="+n.nonce,p=c+ +","+l+","+f,g=Oe(u,p),E=ds(o,g),C=E.toString("base64"),D=Oe(s,"Server Key"),Y=Oe(D,p);r.message="SAS\ +LResponse",r.serverSignature=Y.toString("base64"),r.response=f+",p="+C}a(Du,"continueSession");function Ou(r,e){ if(r.message!=="SASLResponse")throw new Error("SASL: Last message was not SASLResponse");if(typeof e!= "string")throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");let{serverSignature:t}=Qu( e);if(t!==r.serverSignature)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does\ - not match")}a(Du,"finalizeSession");function Ou(r){if(typeof r!="string")throw new TypeError("SASL:\ + not match")}a(Ou,"finalizeSession");function Nu(r){if(typeof r!="string")throw new TypeError("SASL:\ text must be a string");return r.split("").map((e,t)=>r.charCodeAt(t)).every(e=>e>=33&&e<=43||e>=45&& -e<=126)}a(Ou,"isPrintableChars");function ls(r){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/. -test(r)}a(ls,"isBase64");function fs(r){if(typeof r!="string")throw new TypeError("SASL: attribute p\ +e<=126)}a(Nu,"isPrintableChars");function fs(r){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/. +test(r)}a(fs,"isBase64");function hs(r){if(typeof r!="string")throw new TypeError("SASL: attribute p\ airs text must be a string");return new Map(r.split(",").map(e=>{if(!/^.=/.test(e))throw new Error("\ -SASL: Invalid attribute pair entry");let t=e[0],n=e.substring(2);return[t,n]}))}a(fs,"parseAttribute\ -Pairs");function qu(r){let e=fs(r),t=e.get("r");if(t){if(!Ou(t))throw new Error("SASL: SCRAM-SERVER-\ +SASL: Invalid attribute pair entry");let t=e[0],n=e.substring(2);return[t,n]}))}a(hs,"parseAttribute\ +Pairs");function qu(r){let e=hs(r),t=e.get("r");if(t){if(!Nu(t))throw new Error("SASL: SCRAM-SERVER-\ FIRST-MESSAGE: nonce must only contain printable characters")}else throw new Error("SASL: SCRAM-SERV\ -ER-FIRST-MESSAGE: nonce missing");let n=e.get("s");if(n){if(!ls(n))throw new Error("SASL: SCRAM-SERV\ +ER-FIRST-MESSAGE: nonce missing");let n=e.get("s");if(n){if(!fs(n))throw new Error("SASL: SCRAM-SERV\ ER-FIRST-MESSAGE: salt must be base64")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt\ missing");let i=e.get("i");if(i){if(!/^[1-9][0-9]*$/.test(i))throw new Error("SASL: SCRAM-SERVER-FI\ RST-MESSAGE: invalid iteration count")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: itera\ tion missing");let s=parseInt(i,10);return{nonce:t,salt:n,iteration:s}}a(qu,"parseServerFirstMessage"); -function Qu(r){let t=fs(r).get("v");if(t){if(!ls(t))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAG\ +function Qu(r){let t=hs(r).get("v");if(t){if(!fs(t))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAG\ E: server signature must be base64")}else throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server \ -signature is missing");return{serverSignature:t}}a(Qu,"parseServerFinalMessage");function hs(r,e){if(!d. -isBuffer(r))throw new TypeError("first argument must be a Buffer");if(!d.isBuffer(e))throw new TypeError( +signature is missing");return{serverSignature:t}}a(Qu,"parseServerFinalMessage");function ds(r,e){if(!y. +isBuffer(r))throw new TypeError("first argument must be a Buffer");if(!y.isBuffer(e))throw new TypeError( "second argument must be a Buffer");if(r.length!==e.length)throw new Error("Buffer lengths must matc\ -h");if(r.length===0)throw new Error("Buffers cannot be empty");return d.from(r.map((t,n)=>r[n]^e[n]))} -a(hs,"xorBuffers");function Nu(r){return wr.createHash("sha256").update(r).digest()}a(Nu,"sha256");function qe(r,e){ -return wr.createHmac("sha256",r).update(e).digest()}a(qe,"hmacSha256");function Wu(r,e,t){for(var n=qe( -r,d.concat([e,d.from([0,0,0,1])])),i=n,s=0;sju});function ju(...r){return r.join("/")}var br=G(()=>{"use strict";p();a( -ju,"join")});var vr={};te(vr,{stat:()=>Hu});function Hu(r,e){e(new Error("No filesystem"))}var xr=G(()=>{"use str\ -ict";p();a(Hu,"stat")});var Sr={};te(Sr,{default:()=>$u});var $u,Er=G(()=>{"use strict";p();$u={}});var ys={};te(ys,{StringDecoder:()=>Ar});var Cr,Ar,ms=G(()=>{"use strict";p();Cr=class Cr{constructor(e){ -E(this,"td");this.td=new TextDecoder(e)}write(e){return this.td.decode(e,{stream:!0})}end(e){return this. -td.decode(e)}};a(Cr,"StringDecoder");Ar=Cr});var vs=T((ph,bs)=>{"use strict";p();var{Transform:Gu}=(Er(),O(Sr)),{StringDecoder:Vu}=(ms(),O(ys)),Se=Symbol( -"last"),It=Symbol("decoder");function zu(r,e,t){let n;if(this.overflow){if(n=this[It].write(r).split( -this.matcher),n.length===1)return t();n.shift(),this.overflow=!1}else this[Se]+=this[It].write(r),n= -this[Se].split(this.matcher);this[Se]=n.pop();for(let i=0;ir[n]^e[n]))} +a(ds,"xorBuffers");function Wu(r){return br.createHash("sha256").update(r).digest()}a(Wu,"sha256");function Oe(r,e){ +return br.createHmac("sha256",r).update(e).digest()}a(Oe,"hmacSha256");function ju(r,e,t){for(var n=Oe( +r,y.concat([e,y.from([0,0,0,1])])),i=n,s=0;sHu});function Hu(...r){return r.join("/")}var Sr=G(()=>{"use strict";d();a( +Hu,"join")});var xr={};te(xr,{stat:()=>$u});function $u(r,e){e(new Error("No filesystem"))}var Er=G(()=>{"use str\ +ict";d();a($u,"stat")});var Ar={};te(Ar,{default:()=>Gu});var Gu,Cr=G(()=>{"use strict";d();Gu={}});var ms={};te(ms,{StringDecoder:()=>_r});var Ir,_r,ws=G(()=>{"use strict";d();Ir=class Ir{constructor(e){ +A(this,"td");this.td=new TextDecoder(e)}write(e){return this.td.decode(e,{stream:!0})}end(e){return this. +td.decode(e)}};a(Ir,"StringDecoder");_r=Ir});var Ss=T((dh,vs)=>{"use strict";d();var{Transform:Vu}=(Cr(),O(Ar)),{StringDecoder:zu}=(ws(),O(ms)),Se=Symbol( +"last"),Tt=Symbol("decoder");function Ku(r,e,t){let n;if(this.overflow){if(n=this[Tt].write(r).split( +this.matcher),n.length===1)return t();n.shift(),this.overflow=!1}else this[Se]+=this[Tt].write(r),n= +this[Se].split(this.matcher);this[Se]=n.pop();for(let i=0;ithis.maxLength,this.overflow&&!this.skipOverflow){t(new Error( -"maximum buffer reached"));return}t()}a(zu,"transform");function Ku(r){if(this[Se]+=this[It].end(),this[Se]) -try{gs(this,this.mapper(this[Se]))}catch(e){return r(e)}r()}a(Ku,"flush");function gs(r,e){e!==void 0&& -r.push(e)}a(gs,"push");function ws(r){return r}a(ws,"noop");function Yu(r,e,t){switch(r=r||/\r?\n/,e= -e||ws,t=t||{},arguments.length){case 1:typeof r=="function"?(e=r,r=/\r?\n/):typeof r=="object"&&!(r instanceof +"maximum buffer reached"));return}t()}a(Ku,"transform");function Yu(r){if(this[Se]+=this[Tt].end(),this[Se]) +try{bs(this,this.mapper(this[Se]))}catch(e){return r(e)}r()}a(Yu,"flush");function bs(r,e){e!==void 0&& +r.push(e)}a(bs,"push");function gs(r){return r}a(gs,"noop");function Xu(r,e,t){switch(r=r||/\r?\n/,e= +e||gs,t=t||{},arguments.length){case 1:typeof r=="function"?(e=r,r=/\r?\n/):typeof r=="object"&&!(r instanceof RegExp)&&!r[Symbol.split]&&(t=r,r=/\r?\n/);break;case 2:typeof r=="function"?(t=e,e=r,r=/\r?\n/):typeof e== -"object"&&(t=e,e=ws)}t=Object.assign({},t),t.autoDestroy=!0,t.transform=zu,t.flush=Ku,t.readableObjectMode= -!0;let n=new Gu(t);return n[Se]="",n[It]=new Vu("utf8"),n.matcher=r,n.mapper=e,n.maxLength=t.maxLength, +"object"&&(t=e,e=gs)}t=Object.assign({},t),t.autoDestroy=!0,t.transform=Ku,t.flush=Yu,t.readableObjectMode= +!0;let n=new Vu(t);return n[Se]="",n[Tt]=new zu("utf8"),n.matcher=r,n.mapper=e,n.maxLength=t.maxLength, n.skipOverflow=t.skipOverflow||!1,n.overflow=!1,n._destroy=function(i,s){this._writableState.errorEmitted= -!1,s(i)},n}a(Yu,"split");bs.exports=Yu});var Es=T((mh,ye)=>{"use strict";p();var xs=(br(),O(gr)),Zu=(Er(),O(Sr)).Stream,Ju=vs(),Ss=(at(),O(ot)), -Xu=5432,Tt=m.platform==="win32",ut=m.stderr,ec=56,tc=7,rc=61440,nc=32768;function ic(r){return(r&rc)== -nc}a(ic,"isRegFile");var Qe=["host","port","database","user","password"],_r=Qe.length,sc=Qe[_r-1];function Ir(){ +!1,s(i)},n}a(Xu,"split");vs.exports=Xu});var As=T((mh,de)=>{"use strict";d();var xs=(Sr(),O(vr)),Zu=(Cr(),O(Ar)).Stream,Ju=Ss(),Es=(at(),O(ot)), +ec=5432,Pt=m.platform==="win32",ut=m.stderr,tc=56,rc=7,nc=61440,ic=32768;function sc(r){return(r&nc)== +ic}a(sc,"isRegFile");var Ne=["host","port","database","user","password"],Tr=Ne.length,oc=Ne[Tr-1];function Pr(){ var r=ut instanceof Zu&&ut.writable===!0;if(r){var e=Array.prototype.slice.call(arguments).concat(` -`);ut.write(Ss.format.apply(Ss,e))}}a(Ir,"warn");Object.defineProperty(ye.exports,"isWin",{get:a(function(){ -return Tt},"get"),set:a(function(r){Tt=r},"set")});ye.exports.warnTo=function(r){var e=ut;return ut= -r,e};ye.exports.getFileName=function(r){var e=r||m.env,t=e.PGPASSFILE||(Tt?xs.join(e.APPDATA||"./","\ -postgresql","pgpass.conf"):xs.join(e.HOME||"./",".pgpass"));return t};ye.exports.usePgPass=function(r,e){ -return Object.prototype.hasOwnProperty.call(m.env,"PGPASSWORD")?!1:Tt?!0:(e=e||"",ic(r.mode)?r. -mode&(ec|tc)?(Ir('WARNING: password file "%s" has group or world access; permissions should be u=rw \ -(0600) or less',e),!1):!0:(Ir('WARNING: password file "%s" is not a plain file',e),!1))};var oc=ye.exports. -match=function(r,e){return Qe.slice(0,-1).reduce(function(t,n,i){return i==1&&Number(r[n]||Xu)===Number( -e[n])?t&&!0:t&&(e[n]==="*"||e[n]===r[n])},!0)};ye.exports.getPassword=function(r,e,t){var n,i=e.pipe( -Ju());function s(c){var l=ac(c);l&&uc(l)&&oc(r,l)&&(n=l[sc],i.end())}a(s,"onLine");var o=a(function(){ -e.destroy(),t(n)},"onEnd"),u=a(function(c){e.destroy(),Ir("WARNING: error on reading file: %s",c),t( -void 0)},"onErr");e.on("error",u),i.on("data",s).on("end",o).on("error",u)};var ac=ye.exports.parseLine= +`);ut.write(Es.format.apply(Es,e))}}a(Pr,"warn");Object.defineProperty(de.exports,"isWin",{get:a(function(){ +return Pt},"get"),set:a(function(r){Pt=r},"set")});de.exports.warnTo=function(r){var e=ut;return ut= +r,e};de.exports.getFileName=function(r){var e=r||m.env,t=e.PGPASSFILE||(Pt?xs.join(e.APPDATA||"./","\ +postgresql","pgpass.conf"):xs.join(e.HOME||"./",".pgpass"));return t};de.exports.usePgPass=function(r,e){ +return Object.prototype.hasOwnProperty.call(m.env,"PGPASSWORD")?!1:Pt?!0:(e=e||"",sc(r.mode)?r. +mode&(tc|rc)?(Pr('WARNING: password file "%s" has group or world access; permissions should be u=rw \ +(0600) or less',e),!1):!0:(Pr('WARNING: password file "%s" is not a plain file',e),!1))};var ac=de.exports. +match=function(r,e){return Ne.slice(0,-1).reduce(function(t,n,i){return i==1&&Number(r[n]||ec)===Number( +e[n])?t&&!0:t&&(e[n]==="*"||e[n]===r[n])},!0)};de.exports.getPassword=function(r,e,t){var n,i=e.pipe( +Ju());function s(c){var l=uc(c);l&&cc(l)&&ac(r,l)&&(n=l[oc],i.end())}a(s,"onLine");var o=a(function(){ +e.destroy(),t(n)},"onEnd"),u=a(function(c){e.destroy(),Pr("WARNING: error on reading file: %s",c),t( +void 0)},"onErr");e.on("error",u),i.on("data",s).on("end",o).on("error",u)};var uc=de.exports.parseLine= function(r){if(r.length<11||r.match(/^\s+#/))return null;for(var e="",t="",n=0,i=0,s=0,o={},u=!1,c=a( -function(f,y,g){var A=r.substring(y,g);Object.hasOwnProperty.call(m.env,"PGPASS_NO_DEESCAPE")||(A=A. -replace(/\\([:\\])/g,"$1")),o[Qe[f]]=A},"addToObj"),l=0;l=0&&e==":"&&t!=="\\"&&(c(n,i,l+1),i=l+2,n+=1)}return o=Object.keys(o). -length===_r?o:null,o},uc=ye.exports.isValidEntry=function(r){for(var e={0:function(o){return o.length> +function(f,p,g){var E=r.substring(p,g);Object.hasOwnProperty.call(m.env,"PGPASS_NO_DEESCAPE")||(E=E. +replace(/\\([:\\])/g,"$1")),o[Ne[f]]=E},"addToObj"),l=0;l=0&&e==":"&&t!=="\\"&&(c(n,i,l+1),i=l+2,n+=1)}return o=Object.keys(o). +length===Tr?o:null,o},cc=de.exports.isValidEntry=function(r){for(var e={0:function(o){return o.length> 0},1:function(o){return o==="*"?!0:(o=Number(o),isFinite(o)&&o>0&&o<9007199254740992&&Math.floor(o)=== o)},2:function(o){return o.length>0},3:function(o){return o.length>0},4:function(o){return o.length> -0}},t=0;t{"use strict";p();var bh=(br(),O(gr)),As=(xr(),O(vr)),Pt=Es();Tr.exports=function(r,e){ -var t=Pt.getFileName();As.stat(t,function(n,i){if(n||!Pt.usePgPass(i,t))return e(void 0);var s=As.createReadStream( -t);Pt.getPassword(r,s,e)})};Tr.exports.warnTo=Pt.warnTo});var _s={};te(_s,{default:()=>cc});var cc,Is=G(()=>{"use strict";p();cc={}});var Ps=T((Eh,Ts)=>{"use strict";p();var lc=(Jt(),O(bi)),Pr=(xr(),O(vr));function Br(r){if(r.charAt(0)=== -"/"){var t=r.split(" ");return{host:t[0],database:t[1]}}var e=lc.parse(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i. +0}},t=0;t{"use strict";d();var bh=(Sr(),O(vr)),Cs=(Er(),O(xr)),Lt=As();Lr.exports=function(r,e){ +var t=Lt.getFileName();Cs.stat(t,function(n,i){if(n||!Lt.usePgPass(i,t))return e(void 0);var s=Cs.createReadStream( +t);Lt.getPassword(r,s,e)})};Lr.exports.warnTo=Lt.warnTo});var Is={};te(Is,{default:()=>lc});var lc,Ts=G(()=>{"use strict";d();lc={}});var Ls=T((Eh,Ps)=>{"use strict";d();var fc=(Jt(),O(Si)),Br=(Er(),O(xr));function Rr(r){if(r.charAt(0)=== +"/"){var t=r.split(" ");return{host:t[0],database:t[1]}}var e=fc.parse(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i. test(r)?encodeURI(r).replace(/\%25(\d\d)/g,"%$1"):r,!0),t=e.query;for(var n in t)Array.isArray(t[n])&& (t[n]=t[n][t[n].length-1]);var i=(e.auth||":").split(":");if(t.user=i[0],t.password=i.splice(1).join( ":"),t.port=e.port,e.protocol=="socket:")return t.host=decodeURI(e.pathname),t.database=e.query.db,t. @@ -756,37 +768,37 @@ client_encoding=e.query.encoding,t;t.host||(t.host=e.hostname);var s=e.pathname; test(s)){var o=s.split("/");t.host=decodeURIComponent(o[0]),s=o.splice(1).join("/")}switch(s&&s.charAt( 0)==="/"&&(s=s.slice(1)||null),t.database=s&&decodeURI(s),(t.ssl==="true"||t.ssl==="1")&&(t.ssl=!0), t.ssl==="0"&&(t.ssl=!1),(t.sslcert||t.sslkey||t.sslrootcert||t.sslmode)&&(t.ssl={}),t.sslcert&&(t.ssl. -cert=Pr.readFileSync(t.sslcert).toString()),t.sslkey&&(t.ssl.key=Pr.readFileSync(t.sslkey).toString()), -t.sslrootcert&&(t.ssl.ca=Pr.readFileSync(t.sslrootcert).toString()),t.sslmode){case"disable":{t.ssl= +cert=Br.readFileSync(t.sslcert).toString()),t.sslkey&&(t.ssl.key=Br.readFileSync(t.sslkey).toString()), +t.sslrootcert&&(t.ssl.ca=Br.readFileSync(t.sslrootcert).toString()),t.sslmode){case"disable":{t.ssl= !1;break}case"prefer":case"require":case"verify-ca":case"verify-full":break;case"no-verify":{t.ssl.rejectUnauthorized= -!1;break}}return t}a(Br,"parse");Ts.exports=Br;Br.parse=Br});var Bt=T((_h,Ls)=>{"use strict";p();var fc=(Is(),O(_s)),Rs=it(),Bs=Ps().parse,H=a(function(r,e,t){return t=== -void 0?t=m.env["PG"+r.toUpperCase()]:t===!1||(t=m.env[t]),e[r]||t||Rs[r]},"val"),hc=a(function(){switch(m. +!1;break}}return t}a(Rr,"parse");Ps.exports=Rr;Rr.parse=Rr});var Bt=T((_h,ks)=>{"use strict";d();var hc=(Ts(),O(Is)),Rs=it(),Bs=Ls().parse,$=a(function(r,e,t){return t=== +void 0?t=m.env["PG"+r.toUpperCase()]:t===!1||(t=m.env[t]),e[r]||t||Rs[r]},"val"),dc=a(function(){switch(m. 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 Rs.ssl},"readSSLConfigFromEnvironment"),Ne=a(function(r){ +no-verify":return{rejectUnauthorized:!1}}return Rs.ssl},"readSSLConfigFromEnvironment"),qe=a(function(r){ return"'"+(""+r).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},"quoteParamValue"),ie=a(function(r,e,t){ -var n=e[t];n!=null&&r.push(t+"="+Ne(n))},"add"),Lr=class Lr{constructor(e){e=typeof e=="string"?Bs(e): -e||{},e.connectionString&&(e=Object.assign({},e,Bs(e.connectionString))),this.user=H("user",e),this. -database=H("database",e),this.database===void 0&&(this.database=this.user),this.port=parseInt(H("por\ -t",e),10),this.host=H("host",e),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1, -writable:!0,value:H("password",e)}),this.binary=H("binary",e),this.options=H("options",e),this.ssl=typeof e. -ssl>"u"?hc():e.ssl,typeof this.ssl=="string"&&this.ssl==="true"&&(this.ssl=!0),this.ssl==="no-verify"&& +var n=e[t];n!=null&&r.push(t+"="+qe(n))},"add"),Fr=class Fr{constructor(e){e=typeof e=="string"?Bs(e): +e||{},e.connectionString&&(e=Object.assign({},e,Bs(e.connectionString))),this.user=$("user",e),this. +database=$("database",e),this.database===void 0&&(this.database=this.user),this.port=parseInt($("por\ +t",e),10),this.host=$("host",e),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1, +writable:!0,value:$("password",e)}),this.binary=$("binary",e),this.options=$("options",e),this.ssl=typeof e. +ssl>"u"?dc():e.ssl,typeof this.ssl=="string"&&this.ssl==="true"&&(this.ssl=!0),this.ssl==="no-verify"&& (this.ssl={rejectUnauthorized:!1}),this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}), -this.client_encoding=H("client_encoding",e),this.replication=H("replication",e),this.isDomainSocket= -!(this.host||"").indexOf("/"),this.application_name=H("application_name",e,"PGAPPNAME"),this.fallback_application_name= -H("fallback_application_name",e,!1),this.statement_timeout=H("statement_timeout",e,!1),this.lock_timeout= -H("lock_timeout",e,!1),this.idle_in_transaction_session_timeout=H("idle_in_transaction_session_timeo\ -ut",e,!1),this.query_timeout=H("query_timeout",e,!1),e.connectionTimeoutMillis===void 0?this.connect_timeout= +this.client_encoding=$("client_encoding",e),this.replication=$("replication",e),this.isDomainSocket= +!(this.host||"").indexOf("/"),this.application_name=$("application_name",e,"PGAPPNAME"),this.fallback_application_name= +$("fallback_application_name",e,!1),this.statement_timeout=$("statement_timeout",e,!1),this.lock_timeout= +$("lock_timeout",e,!1),this.idle_in_transaction_session_timeout=$("idle_in_transaction_session_timeo\ +ut",e,!1),this.query_timeout=$("query_timeout",e,!1),e.connectionTimeoutMillis===void 0?this.connect_timeout= m.env.PGCONNECT_TIMEOUT||0:this.connect_timeout=Math.floor(e.connectionTimeoutMillis/1e3),e.keepAlive=== !1?this.keepalives=0:e.keepAlive===!0&&(this.keepalives=1),typeof e.keepAliveInitialDelayMillis=="nu\ mber"&&(this.keepalives_idle=Math.floor(e.keepAliveInitialDelayMillis/1e3))}getLibpqConnectionString(e){ var t=[];ie(t,this,"user"),ie(t,this,"password"),ie(t,this,"port"),ie(t,this,"application_name"),ie( t,this,"fallback_application_name"),ie(t,this,"connect_timeout"),ie(t,this,"options");var n=typeof this. ssl=="object"?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(ie(t,n,"sslmode"),ie(t,n,"sslca"),ie(t,n,"s\ -slkey"),ie(t,n,"sslcert"),ie(t,n,"sslrootcert"),this.database&&t.push("dbname="+Ne(this.database)),this. -replication&&t.push("replication="+Ne(this.replication)),this.host&&t.push("host="+Ne(this.host)),this. -isDomainSocket)return e(null,t.join(" "));this.client_encoding&&t.push("client_encoding="+Ne(this.client_encoding)), -fc.lookup(this.host,function(i,s){return i?e(i,null):(t.push("hostaddr="+Ne(s)),e(null,t.join(" ")))})}}; -a(Lr,"ConnectionParameters");var Rr=Lr;Ls.exports=Rr});var Ms=T((Ph,ks)=>{"use strict";p();var pc=tt(),Fs=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/,kr=class kr{constructor(e,t){ +slkey"),ie(t,n,"sslcert"),ie(t,n,"sslrootcert"),this.database&&t.push("dbname="+qe(this.database)),this. +replication&&t.push("replication="+qe(this.replication)),this.host&&t.push("host="+qe(this.host)),this. +isDomainSocket)return e(null,t.join(" "));this.client_encoding&&t.push("client_encoding="+qe(this.client_encoding)), +hc.lookup(this.host,function(i,s){return i?e(i,null):(t.push("hostaddr="+qe(s)),e(null,t.join(" ")))})}}; +a(Fr,"ConnectionParameters");var kr=Fr;ks.exports=kr});var Us=T((Ph,Ms)=>{"use strict";d();var pc=tt(),Fs=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/,Ur=class Ur{constructor(e,t){ this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0, this._types=t,this.RowCtor=null,this.rowAsArray=e==="array",this.rowAsArray&&(this.parseRow=this._parseRowAsArray)}addCommandComplete(e){ var t;e.text?t=Fs.exec(e.text):t=Fs.exec(e.command),t&&(this.command=t[1],t[3]?(this.oid=parseInt(t[2], @@ -796,14 +808,14 @@ for(var t={},n=0,i=e.length;n{"use strict";p();var{EventEmitter:dc}=ve(),Us=Ms(),Ds=st(),Ur=class Ur extends dc{constructor(e,t,n){ -super(),e=Ds.normalizeQueryConfig(e,t,n),this.text=e.text,this.values=e.values,this.rows=e.rows,this. +format||"text")}}};a(Ur,"Result");var Mr=Ur;Ms.exports=Mr});var qs=T((Rh,Ns)=>{"use strict";d();var{EventEmitter:yc}=be(),Ds=Us(),Os=st(),Or=class Or extends yc{constructor(e,t,n){ +super(),e=Os.normalizeQueryConfig(e,t,n),this.text=e.text,this.values=e.values,this.rows=e.rows,this. types=e.types,this.name=e.name,this.binary=e.binary,this.portal=e.portal||"",this.callback=e.callback, this._rowMode=e.rowMode,m.domain&&e.callback&&(this.callback=m.domain.bind(e.callback)),this._result= -new Us(this._rowMode,this.types),this._results=this._result,this.isPreparedStatement=!1,this._canceledDueToError= +new Ds(this._rowMode,this.types),this._results=this._result,this.isPreparedStatement=!1,this._canceledDueToError= !1,this._promise=null}requiresPreparation(){return this.name||this.rows?!0:!this.text||!this.values? !1:this.values.length>0}_checkForMultirow(){this._result.command&&(Array.isArray(this._results)||(this. -_results=[this._result]),this._result=new Us(this._rowMode,this.types),this._results.push(this._result))}handleRowDescription(e){ +_results=[this._result]),this._result=new Ds(this._rowMode,this.types),this._results.push(this._result))}handleRowDescription(e){ this._checkForMultirow(),this._result.addFields(e.fields),this._accumulateRows=this.callback||!this. listeners("row").length}handleDataRow(e){let t;if(!this._canceledDueToError){try{t=this._result.parseRow( e.fields)}catch(n){this._canceledDueToError=n;return}this.emit("row",t,this._result),this._accumulateRows&& @@ -820,10 +832,10 @@ ues must be an array"):(this.requiresPreparation()?this.prepare(e):e.query(this. return this.name&&e.parsedStatements[this.name]}handlePortalSuspended(e){this._getRows(e,this.rows)}_getRows(e,t){ e.execute({portal:this.portal,rows:t}),t?e.flush():e.sync()}prepare(e){this.isPreparedStatement=!0,this. hasBeenParsed(e)||e.parse({text:this.text,name:this.name,types:this.types});try{e.bind({portal:this. -portal,statement:this.name,values:this.values,binary:this.binary,valueMapper:Ds.prepareValue})}catch(t){ +portal,statement:this.name,values:this.values,binary:this.binary,valueMapper:Os.prepareValue})}catch(t){ this.handleError(t,e);return}e.describe({type:"P",name:this.portal||""}),this._getRows(e,this.rows)}handleCopyInResponse(e){ -e.sendCopyFail("No source stream defined")}handleCopyData(e,t){}};a(Ur,"Query");var Mr=Ur;Os.exports= -Mr});var hn=T(_=>{"use strict";p();Object.defineProperty(_,"__esModule",{value:!0});_.NoticeMessage=_.DataRowMessage= +e.sendCopyFail("No source stream defined")}handleCopyData(e,t){}};a(Or,"Query");var Dr=Or;Ns.exports= +Dr});var pn=T(_=>{"use strict";d();Object.defineProperty(_,"__esModule",{value:!0});_.NoticeMessage=_.DataRowMessage= _.CommandCompleteMessage=_.ReadyForQueryMessage=_.NotificationResponseMessage=_.BackendKeyDataMessage= _.AuthenticationMD5Password=_.ParameterStatusMessage=_.ParameterDescriptionMessage=_.RowDescriptionMessage= _.Field=_.CopyResponse=_.CopyDataMessage=_.DatabaseError=_.copyDone=_.emptyQuery=_.replicationStart= @@ -831,137 +843,137 @@ _.portalSuspended=_.noData=_.closeComplete=_.bindComplete=_.parseComplete=void 0 parseComplete",length:5};_.bindComplete={name:"bindComplete",length:5};_.closeComplete={name:"closeC\ omplete",length:5};_.noData={name:"noData",length:5};_.portalSuspended={name:"portalSuspended",length:5}; _.replicationStart={name:"replicationStart",length:4};_.emptyQuery={name:"emptyQuery",length:4};_.copyDone= -{name:"copyDone",length:4};var Zr=class Zr extends Error{constructor(e,t,n){super(e),this.length=t,this. -name=n}};a(Zr,"DatabaseError");var Dr=Zr;_.DatabaseError=Dr;var Jr=class Jr{constructor(e,t){this.length= -e,this.chunk=t,this.name="copyData"}};a(Jr,"CopyDataMessage");var Or=Jr;_.CopyDataMessage=Or;var Xr=class Xr{constructor(e,t,n,i){ -this.length=e,this.name=t,this.binary=n,this.columnTypes=new Array(i)}};a(Xr,"CopyResponse");var qr=Xr; -_.CopyResponse=qr;var en=class en{constructor(e,t,n,i,s,o,u){this.name=e,this.tableID=t,this.columnID= -n,this.dataTypeID=i,this.dataTypeSize=s,this.dataTypeModifier=o,this.format=u}};a(en,"Field");var Qr=en; -_.Field=Qr;var tn=class tn{constructor(e,t){this.length=e,this.fieldCount=t,this.name="rowDescriptio\ -n",this.fields=new Array(this.fieldCount)}};a(tn,"RowDescriptionMessage");var Nr=tn;_.RowDescriptionMessage= -Nr;var rn=class rn{constructor(e,t){this.length=e,this.parameterCount=t,this.name="parameterDescript\ -ion",this.dataTypeIDs=new Array(this.parameterCount)}};a(rn,"ParameterDescriptionMessage");var Wr=rn; -_.ParameterDescriptionMessage=Wr;var nn=class nn{constructor(e,t,n){this.length=e,this.parameterName= -t,this.parameterValue=n,this.name="parameterStatus"}};a(nn,"ParameterStatusMessage");var jr=nn;_.ParameterStatusMessage= -jr;var sn=class sn{constructor(e,t){this.length=e,this.salt=t,this.name="authenticationMD5Password"}}; -a(sn,"AuthenticationMD5Password");var Hr=sn;_.AuthenticationMD5Password=Hr;var on=class on{constructor(e,t,n){ -this.length=e,this.processID=t,this.secretKey=n,this.name="backendKeyData"}};a(on,"BackendKeyDataMes\ -sage");var $r=on;_.BackendKeyDataMessage=$r;var an=class an{constructor(e,t,n,i){this.length=e,this. -processId=t,this.channel=n,this.payload=i,this.name="notification"}};a(an,"NotificationResponseMessa\ -ge");var Gr=an;_.NotificationResponseMessage=Gr;var un=class un{constructor(e,t){this.length=e,this. -status=t,this.name="readyForQuery"}};a(un,"ReadyForQueryMessage");var Vr=un;_.ReadyForQueryMessage=Vr; -var cn=class cn{constructor(e,t){this.length=e,this.text=t,this.name="commandComplete"}};a(cn,"Comma\ -ndCompleteMessage");var zr=cn;_.CommandCompleteMessage=zr;var ln=class ln{constructor(e,t){this.length= -e,this.fields=t,this.name="dataRow",this.fieldCount=t.length}};a(ln,"DataRowMessage");var Kr=ln;_.DataRowMessage= -Kr;var fn=class fn{constructor(e,t){this.length=e,this.message=t,this.name="notice"}};a(fn,"NoticeMe\ -ssage");var Yr=fn;_.NoticeMessage=Yr});var Qs=T(Rt=>{"use strict";p();Object.defineProperty(Rt,"__esModule",{value:!0});Rt.Writer=void 0;var dn=class dn{constructor(e=256){ -this.size=e,this.offset=5,this.headerPosition=0,this.buffer=d.allocUnsafe(e)}ensure(e){if(this.buffer. -length-this.offset>1)+e;this.buffer=d.allocUnsafe(i),n.copy( +{name:"copyDone",length:4};var Jr=class Jr extends Error{constructor(e,t,n){super(e),this.length=t,this. +name=n}};a(Jr,"DatabaseError");var Nr=Jr;_.DatabaseError=Nr;var en=class en{constructor(e,t){this.length= +e,this.chunk=t,this.name="copyData"}};a(en,"CopyDataMessage");var qr=en;_.CopyDataMessage=qr;var tn=class tn{constructor(e,t,n,i){ +this.length=e,this.name=t,this.binary=n,this.columnTypes=new Array(i)}};a(tn,"CopyResponse");var Qr=tn; +_.CopyResponse=Qr;var rn=class rn{constructor(e,t,n,i,s,o,u){this.name=e,this.tableID=t,this.columnID= +n,this.dataTypeID=i,this.dataTypeSize=s,this.dataTypeModifier=o,this.format=u}};a(rn,"Field");var Wr=rn; +_.Field=Wr;var nn=class nn{constructor(e,t){this.length=e,this.fieldCount=t,this.name="rowDescriptio\ +n",this.fields=new Array(this.fieldCount)}};a(nn,"RowDescriptionMessage");var jr=nn;_.RowDescriptionMessage= +jr;var sn=class sn{constructor(e,t){this.length=e,this.parameterCount=t,this.name="parameterDescript\ +ion",this.dataTypeIDs=new Array(this.parameterCount)}};a(sn,"ParameterDescriptionMessage");var Hr=sn; +_.ParameterDescriptionMessage=Hr;var on=class on{constructor(e,t,n){this.length=e,this.parameterName= +t,this.parameterValue=n,this.name="parameterStatus"}};a(on,"ParameterStatusMessage");var $r=on;_.ParameterStatusMessage= +$r;var an=class an{constructor(e,t){this.length=e,this.salt=t,this.name="authenticationMD5Password"}}; +a(an,"AuthenticationMD5Password");var Gr=an;_.AuthenticationMD5Password=Gr;var un=class un{constructor(e,t,n){ +this.length=e,this.processID=t,this.secretKey=n,this.name="backendKeyData"}};a(un,"BackendKeyDataMes\ +sage");var Vr=un;_.BackendKeyDataMessage=Vr;var cn=class cn{constructor(e,t,n,i){this.length=e,this. +processId=t,this.channel=n,this.payload=i,this.name="notification"}};a(cn,"NotificationResponseMessa\ +ge");var zr=cn;_.NotificationResponseMessage=zr;var ln=class ln{constructor(e,t){this.length=e,this. +status=t,this.name="readyForQuery"}};a(ln,"ReadyForQueryMessage");var Kr=ln;_.ReadyForQueryMessage=Kr; +var fn=class fn{constructor(e,t){this.length=e,this.text=t,this.name="commandComplete"}};a(fn,"Comma\ +ndCompleteMessage");var Yr=fn;_.CommandCompleteMessage=Yr;var hn=class hn{constructor(e,t){this.length= +e,this.fields=t,this.name="dataRow",this.fieldCount=t.length}};a(hn,"DataRowMessage");var Xr=hn;_.DataRowMessage= +Xr;var dn=class dn{constructor(e,t){this.length=e,this.message=t,this.name="notice"}};a(dn,"NoticeMe\ +ssage");var Zr=dn;_.NoticeMessage=Zr});var Qs=T(Rt=>{"use strict";d();Object.defineProperty(Rt,"__esModule",{value:!0});Rt.Writer=void 0;var mn=class mn{constructor(e=256){ +this.size=e,this.offset=5,this.headerPosition=0,this.buffer=y.allocUnsafe(e)}ensure(e){if(this.buffer. +length-this.offset>1)+e;this.buffer=y.allocUnsafe(i),n.copy( this.buffer)}}addInt32(e){return this.ensure(4),this.buffer[this.offset++]=e>>>24&255,this.buffer[this. offset++]=e>>>16&255,this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addInt16(e){ return this.ensure(2),this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addCString(e){ -if(!e)this.ensure(1);else{let t=d.byteLength(e);this.ensure(t+1),this.buffer.write(e,this.offset,"ut\ -f-8"),this.offset+=t}return this.buffer[this.offset++]=0,this}addString(e=""){let t=d.byteLength(e); +if(!e)this.ensure(1);else{let t=y.byteLength(e);this.ensure(t+1),this.buffer.write(e,this.offset,"ut\ +f-8"),this.offset+=t}return this.buffer[this.offset++]=0,this}addString(e=""){let t=y.byteLength(e); return this.ensure(t),this.buffer.write(e,this.offset),this.offset+=t,this}add(e){return this.ensure( e.length),e.copy(this.buffer,this.offset),this.offset+=e.length,this}join(e){if(e){this.buffer[this. headerPosition]=e;let t=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(t,this.headerPosition+ 1)}return this.buffer.slice(e?0:5,this.offset)}flush(e){let t=this.join(e);return this.offset=5,this. -headerPosition=0,this.buffer=d.allocUnsafe(this.size),t}};a(dn,"Writer");var pn=dn;Rt.Writer=pn});var Ws=T(Ft=>{"use strict";p();Object.defineProperty(Ft,"__esModule",{value:!0});Ft.serialize=void 0; -var yn=Qs(),F=new yn.Writer,yc=a(r=>{F.addInt16(3).addInt16(0);for(let n of Object.keys(r))F.addCString( -n).addCString(r[n]);F.addCString("client_encoding").addCString("UTF8");let e=F.addCString("").flush(), -t=e.length+4;return new yn.Writer().addInt32(t).add(e).flush()},"startup"),mc=a(()=>{let r=d.allocUnsafe( -8);return r.writeInt32BE(8,0),r.writeInt32BE(80877103,4),r},"requestSsl"),wc=a(r=>F.addCString(r).flush( -112),"password"),gc=a(function(r,e){return F.addCString(r).addInt32(d.byteLength(e)).addString(e),F. -flush(112)},"sendSASLInitialResponseMessage"),bc=a(function(r){return F.addString(r).flush(112)},"se\ -ndSCRAMClientFinalMessage"),vc=a(r=>F.addCString(r).flush(81),"query"),Ns=[],xc=a(r=>{let e=r.name|| +headerPosition=0,this.buffer=y.allocUnsafe(this.size),t}};a(mn,"Writer");var yn=mn;Rt.Writer=yn});var js=T(Ft=>{"use strict";d();Object.defineProperty(Ft,"__esModule",{value:!0});Ft.serialize=void 0; +var wn=Qs(),k=new wn.Writer,mc=a(r=>{k.addInt16(3).addInt16(0);for(let n of Object.keys(r))k.addCString( +n).addCString(r[n]);k.addCString("client_encoding").addCString("UTF8");let e=k.addCString("").flush(), +t=e.length+4;return new wn.Writer().addInt32(t).add(e).flush()},"startup"),wc=a(()=>{let r=y.allocUnsafe( +8);return r.writeInt32BE(8,0),r.writeInt32BE(80877103,4),r},"requestSsl"),gc=a(r=>k.addCString(r).flush( +112),"password"),bc=a(function(r,e){return k.addCString(r).addInt32(y.byteLength(e)).addString(e),k. +flush(112)},"sendSASLInitialResponseMessage"),vc=a(function(r){return k.addString(r).flush(112)},"se\ +ndSCRAMClientFinalMessage"),Sc=a(r=>k.addCString(r).flush(81),"query"),Ws=[],xc=a(r=>{let e=r.name|| "";e.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console. error("You supplied %s (%s)",e,e.length),console.error("This can cause conflicts and silent errors e\ -xecuting queries"));let t=r.types||Ns,n=t.length,i=F.addCString(e).addCString(r.text).addInt16(n);for(let s=0;s< -n;s++)i.addInt32(t[s]);return F.flush(80)},"parse"),We=new yn.Writer,Sc=a(function(r,e){for(let t=0;t< -r.length;t++){let n=e?e(r[t],t):r[t];n==null?(F.addInt16(0),We.addInt32(-1)):n instanceof d?(F.addInt16( -1),We.addInt32(n.length),We.add(n)):(F.addInt16(0),We.addInt32(d.byteLength(n)),We.addString(n))}},"\ -writeValues"),Ec=a((r={})=>{let e=r.portal||"",t=r.statement||"",n=r.binary||!1,i=r.values||Ns,s=i.length; -return F.addCString(e).addCString(t),F.addInt16(s),Sc(i,r.valueMapper),F.addInt16(s),F.add(We.flush()), -F.addInt16(n?1:0),F.flush(66)},"bind"),Ac=d.from([69,0,0,0,9,0,0,0,0,0]),Cc=a(r=>{if(!r||!r.portal&& -!r.rows)return Ac;let e=r.portal||"",t=r.rows||0,n=d.byteLength(e),i=4+n+1+4,s=d.allocUnsafe(1+i);return s[0]= -69,s.writeInt32BE(i,1),s.write(e,5,"utf-8"),s[n+5]=0,s.writeUInt32BE(t,s.length-4),s},"execute"),_c=a( -(r,e)=>{let t=d.allocUnsafe(16);return t.writeInt32BE(16,0),t.writeInt16BE(1234,4),t.writeInt16BE(5678, -6),t.writeInt32BE(r,8),t.writeInt32BE(e,12),t},"cancel"),mn=a((r,e)=>{let n=4+d.byteLength(e)+1,i=d. +xecuting queries"));let t=r.types||Ws,n=t.length,i=k.addCString(e).addCString(r.text).addInt16(n);for(let s=0;s< +n;s++)i.addInt32(t[s]);return k.flush(80)},"parse"),Qe=new wn.Writer,Ec=a(function(r,e){for(let t=0;t< +r.length;t++){let n=e?e(r[t],t):r[t];n==null?(k.addInt16(0),Qe.addInt32(-1)):n instanceof y?(k.addInt16( +1),Qe.addInt32(n.length),Qe.add(n)):(k.addInt16(0),Qe.addInt32(y.byteLength(n)),Qe.addString(n))}},"\ +writeValues"),Ac=a((r={})=>{let e=r.portal||"",t=r.statement||"",n=r.binary||!1,i=r.values||Ws,s=i.length; +return k.addCString(e).addCString(t),k.addInt16(s),Ec(i,r.valueMapper),k.addInt16(s),k.add(Qe.flush()), +k.addInt16(n?1:0),k.flush(66)},"bind"),Cc=y.from([69,0,0,0,9,0,0,0,0,0]),_c=a(r=>{if(!r||!r.portal&& +!r.rows)return Cc;let e=r.portal||"",t=r.rows||0,n=y.byteLength(e),i=4+n+1+4,s=y.allocUnsafe(1+i);return s[0]= +69,s.writeInt32BE(i,1),s.write(e,5,"utf-8"),s[n+5]=0,s.writeUInt32BE(t,s.length-4),s},"execute"),Ic=a( +(r,e)=>{let t=y.allocUnsafe(16);return t.writeInt32BE(16,0),t.writeInt16BE(1234,4),t.writeInt16BE(5678, +6),t.writeInt32BE(r,8),t.writeInt32BE(e,12),t},"cancel"),gn=a((r,e)=>{let n=4+y.byteLength(e)+1,i=y. allocUnsafe(1+n);return i[0]=r,i.writeInt32BE(n,1),i.write(e,5,"utf-8"),i[n]=0,i},"cstringMessage"), -Ic=F.addCString("P").flush(68),Tc=F.addCString("S").flush(68),Pc=a(r=>r.name?mn(68,`${r.type}${r.name|| -""}`):r.type==="P"?Ic:Tc,"describe"),Bc=a(r=>{let e=`${r.type}${r.name||""}`;return mn(67,e)},"close"), -Rc=a(r=>F.add(r).flush(100),"copyData"),Lc=a(r=>mn(102,r),"copyFail"),Lt=a(r=>d.from([r,0,0,0,4]),"c\ -odeOnlyBuffer"),Fc=Lt(72),kc=Lt(83),Mc=Lt(88),Uc=Lt(99),Dc={startup:yc,password:wc,requestSsl:mc,sendSASLInitialResponseMessage:gc, -sendSCRAMClientFinalMessage:bc,query:vc,parse:xc,bind:Ec,execute:Cc,describe:Pc,close:Bc,flush:a(()=>Fc, -"flush"),sync:a(()=>kc,"sync"),end:a(()=>Mc,"end"),copyData:Rc,copyDone:a(()=>Uc,"copyDone"),copyFail:Lc, -cancel:_c};Ft.serialize=Dc});var js=T(kt=>{"use strict";p();Object.defineProperty(kt,"__esModule",{value:!0});kt.BufferReader=void 0; -var Oc=d.allocUnsafe(0),gn=class gn{constructor(e=0){this.offset=e,this.buffer=Oc,this.encoding="utf\ +Tc=k.addCString("P").flush(68),Pc=k.addCString("S").flush(68),Lc=a(r=>r.name?gn(68,`${r.type}${r.name|| +""}`):r.type==="P"?Tc:Pc,"describe"),Bc=a(r=>{let e=`${r.type}${r.name||""}`;return gn(67,e)},"close"), +Rc=a(r=>k.add(r).flush(100),"copyData"),kc=a(r=>gn(102,r),"copyFail"),kt=a(r=>y.from([r,0,0,0,4]),"c\ +odeOnlyBuffer"),Fc=kt(72),Mc=kt(83),Uc=kt(88),Dc=kt(99),Oc={startup:mc,password:gc,requestSsl:wc,sendSASLInitialResponseMessage:bc, +sendSCRAMClientFinalMessage:vc,query:Sc,parse:xc,bind:Ac,execute:_c,describe:Lc,close:Bc,flush:a(()=>Fc, +"flush"),sync:a(()=>Mc,"sync"),end:a(()=>Uc,"end"),copyData:Rc,copyDone:a(()=>Dc,"copyDone"),copyFail:kc, +cancel:Ic};Ft.serialize=Oc});var Hs=T(Mt=>{"use strict";d();Object.defineProperty(Mt,"__esModule",{value:!0});Mt.BufferReader=void 0; +var Nc=y.allocUnsafe(0),vn=class vn{constructor(e=0){this.offset=e,this.buffer=Nc,this.encoding="utf\ -8"}setBuffer(e,t){this.offset=e,this.buffer=t}int16(){let e=this.buffer.readInt16BE(this.offset);return this. offset+=2,e}byte(){let e=this.buffer[this.offset];return this.offset++,e}int32(){let e=this.buffer.readInt32BE( this.offset);return this.offset+=4,e}uint32(){let e=this.buffer.readUInt32BE(this.offset);return this. offset+=4,e}string(e){let t=this.buffer.toString(this.encoding,this.offset,this.offset+e);return this. offset+=e,t}cstring(){let e=this.offset,t=e;for(;this.buffer[t++]!==0;);return this.offset=t,this.buffer. toString(this.encoding,e,t-1)}bytes(e){let t=this.buffer.slice(this.offset,this.offset+e);return this. -offset+=e,t}};a(gn,"BufferReader");var wn=gn;kt.BufferReader=wn});var Gs=T(Mt=>{"use strict";p();Object.defineProperty(Mt,"__esModule",{value:!0});Mt.Parser=void 0;var k=hn(), -qc=js(),bn=1,Qc=4,Hs=bn+Qc,$s=d.allocUnsafe(0),xn=class xn{constructor(e){if(this.buffer=$s,this.bufferLength= +offset+=e,t}};a(vn,"BufferReader");var bn=vn;Mt.BufferReader=bn});var Vs=T(Ut=>{"use strict";d();Object.defineProperty(Ut,"__esModule",{value:!0});Ut.Parser=void 0;var F=pn(), +qc=Hs(),Sn=1,Qc=4,$s=Sn+Qc,Gs=y.allocUnsafe(0),En=class En{constructor(e){if(this.buffer=Gs,this.bufferLength= 0,this.bufferOffset=0,this.reader=new qc.BufferReader,e?.mode==="binary")throw new Error("Binary mod\ e not supported yet");this.mode=e?.mode||"text"}parse(e,t){this.mergeBuffer(e);let n=this.bufferOffset+ -this.bufferLength,i=this.bufferOffset;for(;i+Hs<=n;){let s=this.buffer[i],o=this.buffer.readUInt32BE( -i+bn),u=bn+o;if(u+i<=n){let c=this.handlePacket(i+Hs,s,o,this.buffer);t(c),i+=u}else break}i===n?(this. -buffer=$s,this.bufferLength=0,this.bufferOffset=0):(this.bufferLength=n-i,this.bufferOffset=i)}mergeBuffer(e){ +this.bufferLength,i=this.bufferOffset;for(;i+$s<=n;){let s=this.buffer[i],o=this.buffer.readUInt32BE( +i+Sn),u=Sn+o;if(u+i<=n){let c=this.handlePacket(i+$s,s,o,this.buffer);t(c),i+=u}else break}i===n?(this. +buffer=Gs,this.bufferLength=0,this.bufferOffset=0):(this.bufferLength=n-i,this.bufferOffset=i)}mergeBuffer(e){ if(this.bufferLength>0){let t=this.bufferLength+e.byteLength;if(t+this.bufferOffset>this.buffer.byteLength){ let i;if(t<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)i=this.buffer;else{let s=this. -buffer.byteLength*2;for(;t>=s;)s*=2;i=d.allocUnsafe(s)}this.buffer.copy(i,0,this.bufferOffset,this.bufferOffset+ +buffer.byteLength*2;for(;t>=s;)s*=2;i=y.allocUnsafe(s)}this.buffer.copy(i,0,this.bufferOffset,this.bufferOffset+ this.bufferLength),this.buffer=i,this.bufferOffset=0}e.copy(this.buffer,this.bufferOffset+this.bufferLength), this.bufferLength=t}else this.buffer=e,this.bufferOffset=0,this.bufferLength=e.byteLength}handlePacket(e,t,n,i){ -switch(t){case 50:return k.bindComplete;case 49:return k.parseComplete;case 51:return k.closeComplete;case 110: -return k.noData;case 115:return k.portalSuspended;case 99:return k.copyDone;case 87:return k.replicationStart;case 73: -return k.emptyQuery;case 68:return this.parseDataRowMessage(e,n,i);case 67:return this.parseCommandCompleteMessage( +switch(t){case 50:return F.bindComplete;case 49:return F.parseComplete;case 51:return F.closeComplete;case 110: +return F.noData;case 115:return F.portalSuspended;case 99:return F.copyDone;case 87:return F.replicationStart;case 73: +return F.emptyQuery;case 68:return this.parseDataRowMessage(e,n,i);case 67:return this.parseCommandCompleteMessage( e,n,i);case 90:return this.parseReadyForQueryMessage(e,n,i);case 65:return this.parseNotificationMessage( e,n,i);case 82:return this.parseAuthenticationResponse(e,n,i);case 83:return this.parseParameterStatusMessage( e,n,i);case 75:return this.parseBackendKeyData(e,n,i);case 69:return this.parseErrorMessage(e,n,i,"e\ rror");case 78:return this.parseErrorMessage(e,n,i,"notice");case 84:return this.parseRowDescriptionMessage( e,n,i);case 116:return this.parseParameterDescriptionMessage(e,n,i);case 71:return this.parseCopyInMessage( e,n,i);case 72:return this.parseCopyOutMessage(e,n,i);case 100:return this.parseCopyData(e,n,i);default: -return new k.DatabaseError("received invalid response: "+t.toString(16),n,"error")}}parseReadyForQueryMessage(e,t,n){ -this.reader.setBuffer(e,n);let i=this.reader.string(1);return new k.ReadyForQueryMessage(t,i)}parseCommandCompleteMessage(e,t,n){ -this.reader.setBuffer(e,n);let i=this.reader.cstring();return new k.CommandCompleteMessage(t,i)}parseCopyData(e,t,n){ -let i=n.slice(e,e+(t-4));return new k.CopyDataMessage(t,i)}parseCopyInMessage(e,t,n){return this.parseCopyMessage( +return new F.DatabaseError("received invalid response: "+t.toString(16),n,"error")}}parseReadyForQueryMessage(e,t,n){ +this.reader.setBuffer(e,n);let i=this.reader.string(1);return new F.ReadyForQueryMessage(t,i)}parseCommandCompleteMessage(e,t,n){ +this.reader.setBuffer(e,n);let i=this.reader.cstring();return new F.CommandCompleteMessage(t,i)}parseCopyData(e,t,n){ +let i=n.slice(e,e+(t-4));return new F.CopyDataMessage(t,i)}parseCopyInMessage(e,t,n){return this.parseCopyMessage( e,t,n,"copyInResponse")}parseCopyOutMessage(e,t,n){return this.parseCopyMessage(e,t,n,"copyOutRespon\ se")}parseCopyMessage(e,t,n,i){this.reader.setBuffer(e,n);let s=this.reader.byte()!==0,o=this.reader. -int16(),u=new k.CopyResponse(t,i,s,o);for(let c=0;c{"use strict";p();Object.defineProperty(Ee,"__esModule",{value:!0});Ee.DatabaseError=Ee. -serialize=Ee.parse=void 0;var Nc=hn();Object.defineProperty(Ee,"DatabaseError",{enumerable:!0,get:a( -function(){return Nc.DatabaseError},"get")});var Wc=Ws();Object.defineProperty(Ee,"serialize",{enumerable:!0, -get:a(function(){return Wc.serialize},"get")});var jc=Gs();function Hc(r,e){let t=new jc.Parser;return r. -on("data",n=>t.parse(n,e)),new Promise(n=>r.on("end",()=>n()))}a(Hc,"parse");Ee.parse=Hc});var Vs={};te(Vs,{connect:()=>$c});function $c({socket:r,servername:e}){return r.startTls(e),r}var zs=G( -()=>{"use strict";p();a($c,"connect")});var Cn=T((tp,Zs)=>{"use strict";p();var Ks=(ke(),O(gi)),Gc=ve().EventEmitter,{parse:Vc,serialize:Q}=Sn(), -Ys=Q.flush(),zc=Q.sync(),Kc=Q.end(),An=class An extends Gc{constructor(e){super(),e=e||{},this.stream= -e.stream||new Ks.Socket,this._keepAlive=e.keepAlive,this._keepAliveInitialDelayMillis=e.keepAliveInitialDelayMillis, +a(En,"Parser");var xn=En;Ut.Parser=xn});var An=T(xe=>{"use strict";d();Object.defineProperty(xe,"__esModule",{value:!0});xe.DatabaseError=xe. +serialize=xe.parse=void 0;var Wc=pn();Object.defineProperty(xe,"DatabaseError",{enumerable:!0,get:a( +function(){return Wc.DatabaseError},"get")});var jc=js();Object.defineProperty(xe,"serialize",{enumerable:!0, +get:a(function(){return jc.serialize},"get")});var Hc=Vs();function $c(r,e){let t=new Hc.Parser;return r. +on("data",n=>t.parse(n,e)),new Promise(n=>r.on("end",()=>n()))}a($c,"parse");xe.parse=$c});var zs={};te(zs,{connect:()=>Gc});function Gc({socket:r,servername:e}){return r.startTls(e),r}var Ks=G( +()=>{"use strict";d();a(Gc,"connect")});var In=T((td,Zs)=>{"use strict";d();var Ys=(Ve(),O(vi)),Vc=be().EventEmitter,{parse:zc,serialize:q}=An(), +Xs=q.flush(),Kc=q.sync(),Yc=q.end(),_n=class _n extends Vc{constructor(e){super(),e=e||{},this.stream= +e.stream||new Ys.Socket,this._keepAlive=e.keepAlive,this._keepAliveInitialDelayMillis=e.keepAliveInitialDelayMillis, this.lastBuffer=!1,this.parsedStatements={},this.ssl=e.ssl||!1,this._ending=!1,this._emitMessage=!1; var t=this;this.on("newListener",function(n){n==="message"&&(t._emitMessage=!0)})}connect(e,t){var n=this; this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect(e,t),this.stream.once("connect",function(){ @@ -971,30 +983,30 @@ stream.on("error",i),this.stream.on("close",function(){n.emit("end")}),!this.ssl this.stream);this.stream.once("data",function(s){var o=s.toString("utf8");switch(o){case"S":break;case"\ N":return n.stream.end(),n.emit("error",new Error("The server does not support SSL connections"));default: return n.stream.end(),n.emit("error",new Error("There was an error establishing an SSL connection"))} -var u=(zs(),O(Vs));let c={socket:n.stream};n.ssl!==!0&&(Object.assign(c,n.ssl),"key"in n.ssl&&(c.key= -n.ssl.key)),Ks.isIP(t)===0&&(c.servername=t);try{n.stream=u.connect(c)}catch(l){return n.emit("error", +var u=(Ks(),O(zs));let c={socket:n.stream};n.ssl!==!0&&(Object.assign(c,n.ssl),"key"in n.ssl&&(c.key= +n.ssl.key)),Ys.isIP(t)===0&&(c.servername=t);try{n.stream=u.connect(c)}catch(l){return n.emit("error", l)}n.attachListeners(n.stream),n.stream.on("error",i),n.emit("sslconnect")})}attachListeners(e){e.on( -"end",()=>{this.emit("end")}),Vc(e,t=>{var n=t.name==="error"?"errorMessage":t.name;this._emitMessage&& -this.emit("message",t),this.emit(n,t)})}requestSsl(){this.stream.write(Q.requestSsl())}startup(e){this. -stream.write(Q.startup(e))}cancel(e,t){this._send(Q.cancel(e,t))}password(e){this._send(Q.password(e))}sendSASLInitialResponseMessage(e,t){ -this._send(Q.sendSASLInitialResponseMessage(e,t))}sendSCRAMClientFinalMessage(e){this._send(Q.sendSCRAMClientFinalMessage( -e))}_send(e){return this.stream.writable?this.stream.write(e):!1}query(e){this._send(Q.query(e))}parse(e){ -this._send(Q.parse(e))}bind(e){this._send(Q.bind(e))}execute(e){this._send(Q.execute(e))}flush(){this. -stream.writable&&this.stream.write(Ys)}sync(){this._ending=!0,this._send(Ys),this._send(zc)}ref(){this. +"end",()=>{this.emit("end")}),zc(e,t=>{var n=t.name==="error"?"errorMessage":t.name;this._emitMessage&& +this.emit("message",t),this.emit(n,t)})}requestSsl(){this.stream.write(q.requestSsl())}startup(e){this. +stream.write(q.startup(e))}cancel(e,t){this._send(q.cancel(e,t))}password(e){this._send(q.password(e))}sendSASLInitialResponseMessage(e,t){ +this._send(q.sendSASLInitialResponseMessage(e,t))}sendSCRAMClientFinalMessage(e){this._send(q.sendSCRAMClientFinalMessage( +e))}_send(e){return this.stream.writable?this.stream.write(e):!1}query(e){this._send(q.query(e))}parse(e){ +this._send(q.parse(e))}bind(e){this._send(q.bind(e))}execute(e){this._send(q.execute(e))}flush(){this. +stream.writable&&this.stream.write(Xs)}sync(){this._ending=!0,this._send(Xs),this._send(Kc)}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(Kc,()=>{this.stream.end()})}close(e){this._send(Q. -close(e))}describe(e){this._send(Q.describe(e))}sendCopyFromChunk(e){this._send(Q.copyData(e))}endCopyFrom(){ -this._send(Q.copyDone())}sendCopyFail(e){this._send(Q.copyFail(e))}};a(An,"Connection");var En=An;Zs. -exports=En});var eo=T((sp,Xs)=>{"use strict";p();var Yc=ve().EventEmitter,ip=(at(),O(ot)),Zc=st(),_n=ds(),Jc=Cs(), -Xc=At(),el=Bt(),Js=qs(),tl=it(),rl=Cn(),In=class In extends Yc{constructor(e){super(),this.connectionParameters= -new el(e),this.user=this.connectionParameters.user,this.database=this.connectionParameters.database, +this.stream.end();return}return this.stream.write(Yc,()=>{this.stream.end()})}close(e){this._send(q. +close(e))}describe(e){this._send(q.describe(e))}sendCopyFromChunk(e){this._send(q.copyData(e))}endCopyFrom(){ +this._send(q.copyDone())}sendCopyFail(e){this._send(q.copyFail(e))}};a(_n,"Connection");var Cn=_n;Zs. +exports=Cn});var to=T((sd,eo)=>{"use strict";d();var Xc=be().EventEmitter,id=(at(),O(ot)),Zc=st(),Tn=ys(),Jc=_s(), +el=Ct(),tl=Bt(),Js=qs(),rl=it(),nl=In(),Pn=class Pn extends Xc{constructor(e){super(),this.connectionParameters= +new tl(e),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 t=e||{};this._Promise=t.Promise||b.Promise, -this._types=new Xc(t.types),this._ending=!1,this._connecting=!1,this._connected=!1,this._connectionError= -!1,this._queryable=!0,this.connection=t.connection||new rl({stream:t.stream,ssl:this.connectionParameters. +this.replication=this.connectionParameters.replication;var t=e||{};this._Promise=t.Promise||v.Promise, +this._types=new el(t.types),this._ending=!1,this._connecting=!1,this._connected=!1,this._connectionError= +!1,this._queryable=!0,this.connection=t.connection||new nl({stream:t.stream,ssl:this.connectionParameters. ssl,keepAlive:t.keepAlive||!1,keepAliveInitialDelayMillis:t.keepAliveInitialDelayMillis||0,encoding:this. -connectionParameters.client_encoding||"utf8"}),this.queryQueue=[],this.binary=t.binary||tl.binary,this. +connectionParameters.client_encoding||"utf8"}),this.queryQueue=[],this.binary=t.binary||rl.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=t.connectionTimeoutMillis|| 0}_errorAllQueries(e){let t=a(n=>{m.nextTick(()=>{n.handleError(e,this.connection)})},"enqueueError"); @@ -1029,10 +1041,10 @@ password=this.password=null;e()}).catch(n=>{t.emit("error",n)}):this.password!== n=>{n!==void 0&&(this.connectionParameters.password=this.password=n),e()})}_handleAuthCleartextPassword(e){ this._checkPgPass(()=>{this.connection.password(this.password)})}_handleAuthMD5Password(e){this._checkPgPass( ()=>{let t=Zc.postgresMd5PasswordHash(this.user,this.password,e.salt);this.connection.password(t)})}_handleAuthSASL(e){ -this._checkPgPass(()=>{this.saslSession=_n.startSession(e.mechanisms),this.connection.sendSASLInitialResponseMessage( -this.saslSession.mechanism,this.saslSession.response)})}_handleAuthSASLContinue(e){_n.continueSession( +this._checkPgPass(()=>{this.saslSession=Tn.startSession(e.mechanisms),this.connection.sendSASLInitialResponseMessage( +this.saslSession.mechanism,this.saslSession.response)})}_handleAuthSASLContinue(e){Tn.continueSession( this.saslSession,this.password,e.data),this.connection.sendSCRAMClientFinalMessage(this.saslSession. -response)}_handleAuthSASLFinal(e){_n.finalizeSession(this.saslSession,e.data),this.saslSession=null}_handleBackendKeyData(e){ +response)}_handleAuthSASLFinal(e){Tn.finalizeSession(this.saslSession,e.data),this.saslSession=null}_handleBackendKeyData(e){ this.processID=e.processID,this.secretKey=e.secretKey}_handleReadyForQuery(e){this._connecting&&(this. _connecting=!1,this._connected=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback&& (this._connectionCallback(null,this),this._connectionCallback=null),this.emit("connect"));let{activeQuery:t}=this; @@ -1067,7 +1079,7 @@ handleError(e,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}e "Client was passed a null or undefined query");return typeof e.submit=="function"?(o=e.query_timeout|| this.connectionParameters.query_timeout,s=i=e,typeof t=="function"&&(i.callback=i.callback||t)):(o=this. connectionParameters.query_timeout,i=new Js(e,t,n),i.callback||(s=new this._Promise((l,f)=>{i.callback= -(y,g)=>y?f(y):l(g)}))),o&&(c=i.callback,u=setTimeout(()=>{var l=new Error("Query read timeout");m.nextTick( +(p,g)=>p?f(p):l(g)}))),o&&(c=i.callback,u=setTimeout(()=>{var l=new Error("Query read timeout");m.nextTick( ()=>{i.handleError(l,this.connection)}),c(l),i.callback=()=>{};var f=this.queryQueue.indexOf(i);f>-1&& this.queryQueue.splice(f,1),this._pulseQueryQueue()},o),i.callback=(l,f)=>{clearTimeout(u),c(l,f)}), this.binary&&!i.binary&&(i.binary=!0),i._result&&!i._result._types&&(i._result._types=this._types),this. @@ -1077,23 +1089,23 @@ handleError(new Error("Client has encountered a connection error and is not quer s)}ref(){this.connection.ref()}unref(){this.connection.unref()}end(e){if(this._ending=!0,!this.connection. _connecting)if(e)e();else return this._Promise.resolve();if(this.activeQuery||!this._queryable?this. connection.stream.destroy():this.connection.end(),e)this.connection.once("end",e);else return new this. -_Promise(t=>{this.connection.once("end",t)})}};a(In,"Client");var Ut=In;Ut.Query=Js;Xs.exports=Ut});var io=T((up,no)=>{"use strict";p();var nl=ve().EventEmitter,to=a(function(){},"NOOP"),ro=a((r,e)=>{ -let t=r.findIndex(e);return t===-1?void 0:r.splice(t,1)[0]},"removeWhere"),Bn=class Bn{constructor(e,t,n){ -this.client=e,this.idleListener=t,this.timeoutId=n}};a(Bn,"IdleItem");var Tn=Bn,Rn=class Rn{constructor(e){ -this.callback=e}};a(Rn,"PendingItem");var je=Rn;function il(){throw new Error("Release called on cli\ -ent which has already been released to the pool.")}a(il,"throwOnDoubleRelease");function Dt(r,e){if(e) +_Promise(t=>{this.connection.once("end",t)})}};a(Pn,"Client");var Dt=Pn;Dt.Query=Js;eo.exports=Dt});var so=T((ud,io)=>{"use strict";d();var il=be().EventEmitter,ro=a(function(){},"NOOP"),no=a((r,e)=>{ +let t=r.findIndex(e);return t===-1?void 0:r.splice(t,1)[0]},"removeWhere"),Rn=class Rn{constructor(e,t,n){ +this.client=e,this.idleListener=t,this.timeoutId=n}};a(Rn,"IdleItem");var Ln=Rn,kn=class kn{constructor(e){ +this.callback=e}};a(kn,"PendingItem");var We=kn;function sl(){throw new Error("Release called on cli\ +ent which has already been released to the pool.")}a(sl,"throwOnDoubleRelease");function Ot(r,e){if(e) return{callback:e,result:void 0};let t,n,i=a(function(o,u){o?t(o):n(u)},"cb"),s=new r(function(o,u){ -n=o,t=u}).catch(o=>{throw Error.captureStackTrace(o),o});return{callback:i,result:s}}a(Dt,"promisify"); -function sl(r,e){return a(function t(n){n.client=e,e.removeListener("error",t),e.on("error",()=>{r.log( +n=o,t=u}).catch(o=>{throw Error.captureStackTrace(o),o});return{callback:i,result:s}}a(Ot,"promisify"); +function ol(r,e){return a(function t(n){n.client=e,e.removeListener("error",t),e.on("error",()=>{r.log( "additional client error after disconnection due to error",n)}),r._remove(e),r.emit("error",n,e)},"i\ -dleListener")}a(sl,"makeIdleListener");var Ln=class Ln extends nl{constructor(e,t){super(),this.options= +dleListener")}a(ol,"makeIdleListener");var Fn=class Fn extends il{constructor(e,t){super(),this.options= Object.assign({},e),e!=null&&"password"in e&&Object.defineProperty(this.options,"password",{configurable:!0, enumerable:!1,writable:!0,value:e.password}),e!=null&&e.ssl&&e.ssl.key&&Object.defineProperty(this.options. ssl,"key",{enumerable:!1}),this.options.max=this.options.max||this.options.poolSize||10,this.options. min=this.options.min||0,this.options.maxUses=this.options.maxUses||1/0,this.options.allowExitOnIdle= this.options.allowExitOnIdle||!1,this.options.maxLifetimeSeconds=this.options.maxLifetimeSeconds||0, this.log=this.options.log||function(){},this.Client=this.options.Client||t||ct().Client,this.Promise= -this.options.Promise||b.Promise,typeof this.options.idleTimeoutMillis>"u"&&(this.options.idleTimeoutMillis= +this.options.Promise||v.Promise,typeof this.options.idleTimeoutMillis>"u"&&(this.options.idleTimeoutMillis= 1e4),this._clients=[],this._idle=[],this._expired=new WeakSet,this._pendingQueue=[],this._endCallback= void 0,this.ending=!1,this.ended=!1}_isFull(){return this._clients.length>=this.options.max}_isAboveMin(){ return this._clients.length>this.options.min}_pulseQueue(){if(this.log("pulse queue"),this.ended){this. @@ -1102,47 +1114,47 @@ this._idle.slice().map(t=>{this._remove(t.client)}),this._clients.length||(this. return}if(!this._pendingQueue.length){this.log("no queued requests");return}if(!this._idle.length&&this. _isFull())return;let e=this._pendingQueue.shift();if(this._idle.length){let t=this._idle.pop();clearTimeout( t.timeoutId);let n=t.client;n.ref&&n.ref();let i=t.idleListener;return this._acquireClient(n,e,i,!1)} -if(!this._isFull())return this.newClient(e);throw new Error("unexpected condition")}_remove(e){let t=ro( +if(!this._isFull())return this.newClient(e);throw new Error("unexpected condition")}_remove(e){let t=no( this._idle,n=>n.client===e);t!==void 0&&clearTimeout(t.timeoutId),this._clients=this._clients.filter( n=>n!==e),e.end(),this.emit("remove",e)}connect(e){if(this.ending){let i=new Error("Cannot use a poo\ -l after calling end on the pool");return e?e(i):this.Promise.reject(i)}let t=Dt(this.Promise,e),n=t. +l after calling end on the pool");return e?e(i):this.Promise.reject(i)}let t=Ot(this.Promise,e),n=t. result;if(this._isFull()||this._idle.length){if(this._idle.length&&m.nextTick(()=>this._pulseQueue()), -!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new je(t.callback)),n;let i=a((u,c,l)=>{ -clearTimeout(o),t.callback(u,c,l)},"queueCallback"),s=new je(i),o=setTimeout(()=>{ro(this._pendingQueue, +!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new We(t.callback)),n;let i=a((u,c,l)=>{ +clearTimeout(o),t.callback(u,c,l)},"queueCallback"),s=new We(i),o=setTimeout(()=>{no(this._pendingQueue, u=>u.callback===i),s.timedOut=!0,t.callback(new Error("timeout exceeded when trying to connect"))},this. options.connectionTimeoutMillis);return o.unref&&o.unref(),this._pendingQueue.push(s),n}return this. -newClient(new je(t.callback)),n}newClient(e){let t=new this.Client(this.options);this._clients.push( -t);let n=sl(this,t);this.log("checking client timeout");let i,s=!1;this.options.connectionTimeoutMillis&& +newClient(new We(t.callback)),n}newClient(e){let t=new this.Client(this.options);this._clients.push( +t);let n=ol(this,t);this.log("checking client timeout");let i,s=!1;this.options.connectionTimeoutMillis&& (i=setTimeout(()=>{this.log("ending client due to timeout"),s=!0,t.connection?t.connection.stream.destroy(): t.end()},this.options.connectionTimeoutMillis)),this.log("connecting new client"),t.connect(o=>{if(i&& clearTimeout(i),t.on("error",n),o)this.log("client failed to connect",o),this._clients=this._clients. filter(u=>u!==t),s&&(o=new Error("Connection terminated due to connection timeout",{cause:o})),this. -_pulseQueue(),e.timedOut||e.callback(o,void 0,to);else{if(this.log("new client connected"),this.options. +_pulseQueue(),e.timedOut||e.callback(o,void 0,ro);else{if(this.log("new client connected"),this.options. maxLifetimeSeconds!==0){let u=setTimeout(()=>{this.log("ending client due to expired lifetime"),this. -_expired.add(t),this._idle.findIndex(l=>l.client===t)!==-1&&this._acquireClient(t,new je((l,f,y)=>y()), +_expired.add(t),this._idle.findIndex(l=>l.client===t)!==-1&&this._acquireClient(t,new We((l,f,p)=>p()), n,!1)},this.options.maxLifetimeSeconds*1e3);u.unref(),t.once("end",()=>clearTimeout(u))}return this. _acquireClient(t,e,n,!0)}})}_acquireClient(e,t,n,i){i&&this.emit("connect",e),this.emit("acquire",e), e.release=this._releaseOnce(e,n),e.removeListener("error",n),t.timedOut?i&&this.options.verify?this. options.verify(e,e.release):e.release():i&&this.options.verify?this.options.verify(e,s=>{if(s)return e. -release(s),t.callback(s,void 0,to);t.callback(void 0,e,e.release)}):t.callback(void 0,e,e.release)}_releaseOnce(e,t){ -let n=!1;return i=>{n&&il(),n=!0,this._release(e,t,i)}}_release(e,t,n){if(e.on("error",t),e._poolUseCount= +release(s),t.callback(s,void 0,ro);t.callback(void 0,e,e.release)}):t.callback(void 0,e,e.release)}_releaseOnce(e,t){ +let n=!1;return i=>{n&&sl(),n=!0,this._release(e,t,i)}}_release(e,t,n){if(e.on("error",t),e._poolUseCount= (e._poolUseCount||0)+1,this.emit("release",n,e),n||this.ending||!e._queryable||e._ending||e._poolUseCount>= this.options.maxUses){e._poolUseCount>=this.options.maxUses&&this.log("remove expended client"),this. _remove(e),this._pulseQueue();return}if(this._expired.has(e)){this.log("remove expired client"),this. _expired.delete(e),this._remove(e),this._pulseQueue();return}let s;this.options.idleTimeoutMillis&&this. _isAboveMin()&&(s=setTimeout(()=>{this.log("remove idle client"),this._remove(e)},this.options.idleTimeoutMillis), -this.options.allowExitOnIdle&&s.unref()),this.options.allowExitOnIdle&&e.unref(),this._idle.push(new Tn( -e,t,s)),this._pulseQueue()}query(e,t,n){if(typeof e=="function"){let s=Dt(this.Promise,e);return v(function(){ +this.options.allowExitOnIdle&&s.unref()),this.options.allowExitOnIdle&&e.unref(),this._idle.push(new Ln( +e,t,s)),this._pulseQueue()}query(e,t,n){if(typeof e=="function"){let s=Ot(this.Promise,e);return S(function(){ return s.callback(new Error("Passing a function as the first parameter to pool.query is not supporte\ -d"))}),s.result}typeof t=="function"&&(n=t,t=void 0);let i=Dt(this.Promise,n);return n=i.callback,this. +d"))}),s.result}typeof t=="function"&&(n=t,t=void 0);let i=Ot(this.Promise,n);return n=i.callback,this. connect((s,o)=>{if(s)return n(s);let u=!1,c=a(l=>{u||(u=!0,o.release(l),n(l))},"onError");o.once("er\ ror",c),this.log("dispatching query");try{o.query(e,t,(l,f)=>{if(this.log("query dispatched"),o.removeListener( "error",c),!u)return u=!0,o.release(l),l?n(l):n(void 0,f)})}catch(l){return o.release(l),n(l)}}),i.result}end(e){ if(this.log("ending"),this.ending){let n=new Error("Called end on pool more than once");return e?e(n): -this.Promise.reject(n)}this.ending=!0;let t=Dt(this.Promise,e);return this._endCallback=t.callback,this. +this.Promise.reject(n)}this.ending=!0;let t=Ot(this.Promise,e);return this._endCallback=t.callback,this. _pulseQueue(),t.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this. _idle.length}get expiredCount(){return this._clients.reduce((e,t)=>e+(this._expired.has(t)?1:0),0)}get totalCount(){ -return this._clients.length}};a(Ln,"Pool");var Pn=Ln;no.exports=Pn});var so={};te(so,{default:()=>ol});var ol,oo=G(()=>{"use strict";p();ol={}});var ao=T((hp,al)=>{al.exports={name:"pg",version:"8.8.0",description:"PostgreSQL client - pure javas\ +return this._clients.length}};a(Fn,"Pool");var Bn=Fn;io.exports=Bn});var oo={};te(oo,{default:()=>al});var al,ao=G(()=>{"use strict";d();al={}});var uo=T((hd,ul)=>{ul.exports={name:"pg",version:"8.8.0",description:"PostgreSQL client - pure javas\ cript & libpq with the same API",keywords:["database","libpq","pg","postgre","postgres","postgresql", "rdbms"],homepage:"https://github.com/brianc/node-postgres",repository:{type:"git",url:"git://github\ .com/brianc/node-postgres.git",directory:"packages/pg"},author:"Brian Carlson =3.0.1"},peerDependenciesMeta:{"pg-native":{optional:!0}},scripts:{test:"make test-all"},files:["li\ b","SPONSORS.md"],license:"MIT",engines:{node:">= 8.0.0"},gitHead:"c99fb2c127ddf8d712500db2c7b9a5491\ -a178655"}});var lo=T((pp,co)=>{"use strict";p();var uo=ve().EventEmitter,ul=(at(),O(ot)),Fn=st(),He=co.exports=function(r,e,t){ -uo.call(this),r=Fn.normalizeQueryConfig(r,e,t),this.text=r.text,this.values=r.values,this.name=r.name, +a178655"}});var fo=T((dd,lo)=>{"use strict";d();var co=be().EventEmitter,cl=(at(),O(ot)),Mn=st(),je=lo.exports=function(r,e,t){ +co.call(this),r=Mn.normalizeQueryConfig(r,e,t),this.text=r.text,this.values=r.values,this.name=r.name, this.callback=r.callback,this.state="new",this._arrayMode=r.rowMode==="array",this._emitRowEvents=!1, -this.on("newListener",function(n){n==="row"&&(this._emitRowEvents=!0)}.bind(this))};ul.inherits(He,uo); -var cl={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"\ +this.on("newListener",function(n){n==="row"&&(this._emitRowEvents=!0)}.bind(this))};cl.inherits(je,co); +var ll={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"\ schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"\ -file",sourceLine:"line",sourceFunction:"routine"};He.prototype.handleError=function(r){var e=this.native. -pq.resultErrorFields();if(e)for(var t in e){var n=cl[t]||t;r[n]=e[t]}this.callback?this.callback(r): -this.emit("error",r),this.state="error"};He.prototype.then=function(r,e){return this._getPromise().then( -r,e)};He.prototype.catch=function(r){return this._getPromise().catch(r)};He.prototype._getPromise=function(){ +file",sourceLine:"line",sourceFunction:"routine"};je.prototype.handleError=function(r){var e=this.native. +pq.resultErrorFields();if(e)for(var t in e){var n=ll[t]||t;r[n]=e[t]}this.callback?this.callback(r): +this.emit("error",r),this.state="error"};je.prototype.then=function(r,e){return this._getPromise().then( +r,e)};je.prototype.catch=function(r){return this._getPromise().catch(r)};je.prototype._getPromise=function(){ return this._promise?this._promise:(this._promise=new Promise(function(r,e){this._once("end",r),this. -_once("error",e)}.bind(this)),this._promise)};He.prototype.submit=function(r){this.state="running";var e=this; +_once("error",e)}.bind(this)),this._promise)};je.prototype.submit=function(r){this.state="running";var e=this; this.native=r.native,r.native.arrayMode=this._arrayMode;var t=a(function(s,o,u){if(r.native.arrayMode= -!1,v(function(){e.emit("_done")}),s)return e.handleError(s);e._emitRowEvents&&(u.length>1?o.forEach( +!1,S(function(){e.emit("_done")}),s)return e.handleError(s);e._emitRowEvents&&(u.length>1?o.forEach( (c,l)=>{c.forEach(f=>{e.emit("row",f,u[l])})}):o.forEach(function(c){e.emit("row",c,u)})),e.state="e\ nd",e.emit("end",u),e.callback&&e.callback(null,u)},"after");if(m.domain&&(t=m.domain.bind(t)),this. name){this.name.length>63&&(console.error("Warning! Postgres only supports 63 characters for query n\ ames."),console.error("You supplied %s (%s)",this.name,this.name.length),console.error("This can cau\ -se conflicts and silent errors executing queries"));var n=(this.values||[]).map(Fn.prepareValue);if(r. +se conflicts and silent errors executing queries"));var n=(this.values||[]).map(Mn.prepareValue);if(r. namedQueries[this.name]){if(this.text&&r.namedQueries[this.name]!==this.text){let s=new Error(`Prepa\ red statements must be unique - '${this.name}' was used for a different statement`);return t(s)}return r. native.execute(this.name,n,t)}return r.native.prepare(this.name,this.text,n.length,function(s){return s? t(s):(r.namedQueries[e.name]=e.text,e.native.execute(e.name,n,t))})}else if(this.values){if(!Array.isArray( -this.values)){let s=new Error("Query values must be an array");return t(s)}var i=this.values.map(Fn. -prepareValue);r.native.query(this.text,i,t)}else r.native.query(this.text,t)}});var yo=T((wp,po)=>{"use strict";p();var ll=(oo(),O(so)),fl=At(),mp=ao(),fo=ve().EventEmitter,hl=(at(),O(ot)), -pl=Bt(),ho=lo(),K=po.exports=function(r){fo.call(this),r=r||{},this._Promise=r.Promise||b.Promise,this. -_types=new fl(r.types),this.native=new ll({types:this._types}),this._queryQueue=[],this._ending=!1,this. +this.values)){let s=new Error("Query values must be an array");return t(s)}var i=this.values.map(Mn. +prepareValue);r.native.query(this.text,i,t)}else r.native.query(this.text,t)}});var mo=T((wd,yo)=>{"use strict";d();var fl=(ao(),O(oo)),hl=Ct(),md=uo(),ho=be().EventEmitter,dl=(at(),O(ot)), +pl=Bt(),po=fo(),K=yo.exports=function(r){ho.call(this),r=r||{},this._Promise=r.Promise||v.Promise,this. +_types=new hl(r.types),this.native=new fl({types:this._types}),this._queryQueue=[],this._ending=!1,this. _connecting=!1,this._connected=!1,this._queryable=!0;var e=this.connectionParameters=new pl(r);this. user=e.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:e. password}),this.database=e.database,this.host=e.host,this.port=e.port,this.namedQueries={}};K.Query= -ho;hl.inherits(K,fo);K.prototype._errorAllQueries=function(r){let e=a(t=>{m.nextTick(()=>{t.native=this. +po;dl.inherits(K,ho);K.prototype._errorAllQueries=function(r){let e=a(t=>{m.nextTick(()=>{t.native=this. native,t.handleError(r)})},"enqueueError");this._hasActiveQuery()&&(e(this._activeQuery),this._activeQuery= null),this._queryQueue.forEach(e),this._queryQueue.length=0};K.prototype._connect=function(r){var e=this; if(this._connecting){m.nextTick(()=>r(new Error("Client has already been connected. You cannot reuse\ @@ -1193,8 +1205,8 @@ _pulseQueryQueue(!0),r()})})};K.prototype.connect=function(r){if(r){this._connec _Promise((e,t)=>{this._connect(n=>{n?t(n):e()})})};K.prototype.query=function(r,e,t){var n,i,s,o,u;if(r== null)throw new TypeError("Client was passed a null or undefined query");if(typeof r.submit=="functio\ n")s=r.query_timeout||this.connectionParameters.query_timeout,i=n=r,typeof e=="function"&&(r.callback= -e);else if(s=this.connectionParameters.query_timeout,n=new ho(r,e,t),!n.callback){let c,l;i=new this. -_Promise((f,y)=>{c=f,l=y}),n.callback=(f,y)=>f?l(f):c(y)}return s&&(u=n.callback,o=setTimeout(()=>{var c=new Error( +e);else if(s=this.connectionParameters.query_timeout,n=new po(r,e,t),!n.callback){let c,l;i=new this. +_Promise((f,p)=>{c=f,l=p}),n.callback=(f,p)=>f?l(f):c(p)}return s&&(u=n.callback,o=setTimeout(()=>{var c=new Error( "Query read timeout");m.nextTick(()=>{n.handleError(c,this.connection)}),u(c),n.callback=()=>{};var l=this. _queryQueue.indexOf(n);l>-1&&this._queryQueue.splice(l,1),this._pulseQueryQueue()},s),n.callback=(c,l)=>{ clearTimeout(o),u(c,l)}),this._queryable?this._ending?(n.native=this.native,m.nextTick(()=>{n.handleError( @@ -1210,39 +1222,39 @@ in");return}this._activeQuery=e,e.submit(this);var t=this;e.once("_done",functio K.prototype.cancel=function(r){this._activeQuery===r?this.native.cancel(function(){}):this._queryQueue. indexOf(r)!==-1&&this._queryQueue.splice(this._queryQueue.indexOf(r),1)};K.prototype.ref=function(){}; K.prototype.unref=function(){};K.prototype.setTypeParser=function(r,e,t){return this._types.setTypeParser( -r,e,t)};K.prototype.getTypeParser=function(r,e){return this._types.getTypeParser(r,e)}});var kn=T((vp,mo)=>{"use strict";p();mo.exports=yo()});var ct=T((Sp,lt)=>{"use strict";p();var dl=eo(),yl=it(),ml=Cn(),wl=io(),{DatabaseError:gl}=Sn(),bl=a( -r=>{var e;return e=class extends wl{constructor(n){super(n,r)}},a(e,"BoundPool"),e},"poolFactory"),Mn=a( -function(r){this.defaults=yl,this.Client=r,this.Query=this.Client.Query,this.Pool=bl(this.Client),this. -_pools=[],this.Connection=ml,this.types=tt(),this.DatabaseError=gl},"PG");typeof m.env.NODE_PG_FORCE_NATIVE< -"u"?lt.exports=new Mn(kn()):(lt.exports=new Mn(dl),Object.defineProperty(lt.exports,"native",{configurable:!0, -enumerable:!1,get(){var r=null;try{r=new Mn(kn())}catch(e){if(e.code!=="MODULE_NOT_FOUND")throw e}return Object. -defineProperty(lt.exports,"native",{value:r}),r}}))});var Sl={};te(Sl,{Client:()=>$e,DatabaseError:()=>le.DatabaseError,NeonDbError:()=>de,NeonQueryPromise:()=>xe, -Pool:()=>Ot,SqlTemplate:()=>Me,UnsafeRawSql:()=>Ue,_bundleExt:()=>xl,defaults:()=>le.defaults,escapeIdentifier:()=>le.escapeIdentifier, -escapeLiteral:()=>le.escapeLiteral,neon:()=>yr,neonConfig:()=>se,types:()=>le.types,warnIfBrowser:()=>Ke}); -module.exports=O(Sl);p();p();ke();Jt();p();var pa=Object.defineProperty,da=Object.defineProperties,ya=Object.getOwnPropertyDescriptors,vi=Object. -getOwnPropertySymbols,ma=Object.prototype.hasOwnProperty,wa=Object.prototype.propertyIsEnumerable,xi=a( +r,e,t)};K.prototype.getTypeParser=function(r,e){return this._types.getTypeParser(r,e)}});var Un=T((vd,wo)=>{"use strict";d();wo.exports=mo()});var ct=T((xd,lt)=>{"use strict";d();var yl=to(),ml=it(),wl=In(),gl=so(),{DatabaseError:bl}=An(),vl=a( +r=>{var e;return e=class extends gl{constructor(n){super(n,r)}},a(e,"BoundPool"),e},"poolFactory"),Dn=a( +function(r){this.defaults=ml,this.Client=r,this.Query=this.Client.Query,this.Pool=vl(this.Client),this. +_pools=[],this.Connection=wl,this.types=tt(),this.DatabaseError=bl},"PG");typeof m.env.NODE_PG_FORCE_NATIVE< +"u"?lt.exports=new Dn(Un()):(lt.exports=new Dn(yl),Object.defineProperty(lt.exports,"native",{configurable:!0, +enumerable:!1,get(){var r=null;try{r=new Dn(Un())}catch(e){if(e.code!=="MODULE_NOT_FOUND")throw e}return Object. +defineProperty(lt.exports,"native",{value:r}),r}}))});var El={};te(El,{Client:()=>He,DatabaseError:()=>ce.DatabaseError,NeonDbError:()=>he,NeonQueryPromise:()=>ve, +Pool:()=>Nt,SqlTemplate:()=>Fe,UnsafeRawSql:()=>Me,_bundleExt:()=>xl,defaults:()=>ce.defaults,escapeIdentifier:()=>ce.escapeIdentifier, +escapeLiteral:()=>ce.escapeLiteral,neon:()=>wr,neonConfig:()=>ue,processQueryResult:()=>mr,types:()=>ce.types, +warnIfBrowser:()=>Ke});module.exports=O(El);d();d();Ve();Jt();d();var pa=Object.defineProperty,ya=Object.defineProperties,ma=Object.getOwnPropertyDescriptors,xi=Object. +getOwnPropertySymbols,wa=Object.prototype.hasOwnProperty,ga=Object.prototype.propertyIsEnumerable,Ei=a( (r,e,t)=>e in r?pa(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,"__defNormalProp"), -ga=a((r,e)=>{for(var t in e||(e={}))ma.call(e,t)&&xi(r,t,e[t]);if(vi)for(var t of vi(e))wa.call(e,t)&& -xi(r,t,e[t]);return r},"__spreadValues"),ba=a((r,e)=>da(r,ya(e)),"__spreadProps"),va=1008e3,Si=new Uint8Array( -new Uint16Array([258]).buffer)[0]===2,xa=new TextDecoder,Xt=new TextEncoder,mt=Xt.encode("0123456789\ -abcdef"),wt=Xt.encode("0123456789ABCDEF"),Sa=Xt.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr\ -stuvwxyz0123456789+/");var Ei=Sa.slice();Ei[62]=45;Ei[63]=95;var ze,gt;function Ea(r,{alphabet:e,scratchArr:t}={}){if(!ze)if(ze= -new Uint16Array(256),gt=new Uint16Array(256),Si)for(let C=0;C<256;C++)ze[C]=mt[C&15]<<8|mt[C>>>4],gt[C]= -wt[C&15]<<8|wt[C>>>4];else for(let C=0;C<256;C++)ze[C]=mt[C&15]|mt[C>>>4]<<8,gt[C]=wt[C&15]|wt[C>>>4]<< +ba=a((r,e)=>{for(var t in e||(e={}))wa.call(e,t)&&Ei(r,t,e[t]);if(xi)for(var t of xi(e))ga.call(e,t)&& +Ei(r,t,e[t]);return r},"__spreadValues"),va=a((r,e)=>ya(r,ma(e)),"__spreadProps"),Sa=1008e3,Ai=new Uint8Array( +new Uint16Array([258]).buffer)[0]===2,xa=new TextDecoder,er=new TextEncoder,wt=er.encode("0123456789\ +abcdef"),gt=er.encode("0123456789ABCDEF"),Ea=er.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr\ +stuvwxyz0123456789+/");var Ci=Ea.slice();Ci[62]=45;Ci[63]=95;var ze,bt;function Aa(r,{alphabet:e,scratchArr:t}={}){if(!ze)if(ze= +new Uint16Array(256),bt=new Uint16Array(256),Ai)for(let C=0;C<256;C++)ze[C]=wt[C&15]<<8|wt[C>>>4],bt[C]= +gt[C&15]<<8|gt[C>>>4];else for(let C=0;C<256;C++)ze[C]=wt[C&15]|wt[C>>>4]<<8,bt[C]=gt[C&15]|gt[C>>>4]<< 8;r.byteOffset%4!==0&&(r=new Uint8Array(r));let n=r.length,i=n>>>1,s=n>>>2,o=t||new Uint16Array(n),u=new Uint32Array( -r.buffer,r.byteOffset,s),c=new Uint32Array(o.buffer,o.byteOffset,i),l=e==="upper"?gt:ze,f=0,y=0,g;if(Si) -for(;f>>8&255]<<16|l[g&255],c[y++]=l[g>>>24]<<16|l[g>>>16&255];else for(;f>>24]<<16|l[g>>>16&255],c[y++]=l[g>>>8&255]<<16|l[g&255];for(f<<=2;f>>1,s=Math. -ceil(n/i),o=new Uint16Array(s>1?i:n);for(let u=0;u>>8&255]<<16|l[g&255],c[p++]=l[g>>>24]<<16|l[g>>>16&255];else for(;f>>24]<<16|l[g>>>16&255],c[p++]=l[g>>>8&255]<<16|l[g&255];for(f<<=2;f>>1,s=Math. +ceil(n/i),o=new Uint16Array(s>1?i:n);for(let u=0;uLu((0,cs.prepareValue)(n)))}}a(os,"prep\ -areQuery");function yr(r,{arrayMode:e,fullResults:t,fetchOptions:n,isolationLevel:i,readOnly:s,deferrable:o, +ry","where","schema","table","column","dataType","constraint","file","line","routine"];function ku(r){ +return r instanceof y?"\\x"+_i(r):r}a(ku,"encodeBuffersAsBytea");function us(r){let{query:e,params:t}=r instanceof +Fe?r.toParameterizedQuery():r;return{query:e,params:t.map(n=>ku((0,ls.prepareValue)(n)))}}a(us,"prep\ +areQuery");function wr(r,{arrayMode:e,fullResults:t,fetchOptions:n,isolationLevel:i,readOnly:s,deferrable:o, authToken:u,disableWarningInBrowsers:c}={}){if(!r)throw new Error("No database connection string was\ provided to `neon()`. Perhaps an environment variable has not been set?");let l;try{l=Zt(r)}catch{throw new Error( "Database connection string provided to `neon()` is not a valid URL. Connection string: "+String(r))} -let{protocol:f,username:y,hostname:g,port:A,pathname:C}=l;if(f!=="postgres:"&&f!=="postgresql:"||!y|| +let{protocol:f,username:p,hostname:g,port:E,pathname:C}=l;if(f!=="postgres:"&&f!=="postgresql:"||!p|| !g||!C)throw new Error("Database connection string format for `neon()` should be: postgresql://user:\ password@host.tld/dbname?option=value");function D(P,...I){if(!(Array.isArray(P)&&Array.isArray(P.raw)&& Array.isArray(I)))throw new Error('This function can now be called only as a tagged-template functio\ n: sql`SELECT ${value}`, not sql("SELECT $1", [value], options). For a conventional function call wi\ -th value placeholders ($1, $2, etc.), use sql.query("SELECT $1", [value], options).');return new xe( -Y,new Me(P,I))}a(D,"templateFn"),D.query=(P,I,w)=>new xe(Y,{query:P,params:I??[]},w),D.unsafe=P=>new Ue( -P),D.transaction=async(P,I)=>{if(typeof P=="function"&&(P=P(D)),!Array.isArray(P))throw new Error(ss); -P.forEach(W=>{if(!(W instanceof xe))throw new Error(ss)});let w=P.map(W=>W.queryData),Z=P.map(W=>W.opts?? -{});return Y(w,Z,I)};async function Y(P,I,w){let{fetchEndpoint:Z,fetchFunction:W}=se,J=Array.isArray( -P)?{queries:P.map(ee=>os(ee))}:os(P),X=n??{},oe=e??!1,ae=t??!1,R=i,j=s,fe=o;w!==void 0&&(w.fetchOptions!== -void 0&&(X={...X,...w.fetchOptions}),w.arrayMode!==void 0&&(oe=w.arrayMode),w.fullResults!==void 0&& -(ae=w.fullResults),w.isolationLevel!==void 0&&(R=w.isolationLevel),w.readOnly!==void 0&&(j=w.readOnly), -w.deferrable!==void 0&&(fe=w.deferrable)),I!==void 0&&!Array.isArray(I)&&I.fetchOptions!==void 0&&(X= -{...X,...I.fetchOptions});let me=u;!Array.isArray(I)&&I?.authToken!==void 0&&(me=I.authToken);let Ge=typeof Z== -"function"?Z(g,A,{jwtAuth:me!==void 0}):Z,he={"Neon-Connection-String":r,"Neon-Raw-Text-Output":"tru\ -e","Neon-Array-Mode":"true"},Ie=await Fu(me);Ie&&(he.Authorization=`Bearer ${Ie}`),Array.isArray(P)&& -(R!==void 0&&(he["Neon-Batch-Isolation-Level"]=R),j!==void 0&&(he["Neon-Batch-Read-Only"]=String(j)), -fe!==void 0&&(he["Neon-Batch-Deferrable"]=String(fe))),c||se.disableWarningInBrowsers||Ke();let we;try{ -we=await(W??fetch)(Ge,{method:"POST",body:JSON.stringify(J),headers:he,...X})}catch(ee){let M=new de( -`Error connecting to database: ${ee}`);throw M.sourceError=ee,M}if(we.ok){let ee=await we.json();if(Array. -isArray(P)){let M=ee.results;if(!Array.isArray(M))throw new de("Neon internal error: unexpected resu\ -lt format");return M.map(($,ge)=>{let qt=I[ge]??{},vo=qt.arrayMode??oe,xo=qt.fullResults??ae;return as( -$,{arrayMode:vo,fullResults:xo,types:qt.types})})}else{let M=I??{},$=M.arrayMode??oe,ge=M.fullResults?? -ae;return as(ee,{arrayMode:$,fullResults:ge,types:M.types})}}else{let{status:ee}=we;if(ee===400){let M=await we. -json(),$=new de(M.message);for(let ge of Ru)$[ge]=M[ge]??void 0;throw $}else{let M=await we.text();throw new de( -`Server error (HTTP status ${ee}): ${M}`)}}}return a(Y,"execute"),D}a(yr,"neon");var mr=class mr{constructor(e,t,n){ +th value placeholders ($1, $2, etc.), use sql.query("SELECT $1", [value], options).');return new ve( +Y,new Fe(P,I))}a(D,"templateFn"),D.query=(P,I,w)=>new ve(Y,{query:P,params:I??[]},w),D.unsafe=P=>new Me( +P),D.transaction=async(P,I)=>{if(typeof P=="function"&&(P=P(D)),!Array.isArray(P))throw new Error(as); +P.forEach(j=>{if(!(j instanceof ve))throw new Error(as)});let w=P.map(j=>j.queryData),X=P.map(j=>j.opts?? +{});return Y(w,X,I)};async function Y(P,I,w){let{fetchEndpoint:X,fetchFunction:j,isNeonLocal:Z}=ue,pe=Array. +isArray(P)?{queries:P.map(Q=>us(Q))}:us(P),J=n??{},se=e??!1,B=t??!1,H=i,le=s,ye=o;w!==void 0&&(w.fetchOptions!== +void 0&&(J={...J,...w.fetchOptions}),w.arrayMode!==void 0&&(se=w.arrayMode),w.fullResults!==void 0&& +(B=w.fullResults),w.isolationLevel!==void 0&&(H=w.isolationLevel),w.readOnly!==void 0&&(le=w.readOnly), +w.deferrable!==void 0&&(ye=w.deferrable)),I!==void 0&&!Array.isArray(I)&&I.fetchOptions!==void 0&&(J= +{...J,...I.fetchOptions});let Ee=u;!Array.isArray(I)&&I?.authToken!==void 0&&(Ee=I.authToken);let $e=typeof X== +"function"?X(g,E,{jwtAuth:Ee!==void 0}):X,ee={"Neon-Connection-String":r,"Neon-Raw-Text-Output":"tru\ +e","Neon-Array-Mode":"true"};Z&&(ee["X-Neon-User"]=p,ee["X-Neon-Password"]=l.password||"",ee["X-Neon\ +-Database"]=C.slice(1));let ft=await Fu(Ee);ft&&(ee.Authorization=`Bearer ${ft}`),Array.isArray(P)&& +(H!==void 0&&(ee["Neon-Batch-Isolation-Level"]=H),le!==void 0&&(ee["Neon-Batch-Read-Only"]=String(le)), +ye!==void 0&&(ee["Neon-Batch-Deferrable"]=String(ye))),c||ue.disableWarningInBrowsers||Ke();let me;try{ +me=await(j??fetch)($e,{method:"POST",body:JSON.stringify(pe),headers:ee,...J})}catch(Q){let M=new he( +`Error connecting to database: ${Q}`);throw M.sourceError=Q,M}if(me.ok){let Q=await me.json();if(Array. +isArray(P)){let M=Q.results;if(!Array.isArray(M))throw new he("Neon internal error: unexpected resul\ +t format");return M.map((we,Ie)=>{let qt=I[Ie]??{},So=qt.arrayMode??se,xo=qt.fullResults??B;return mr( +we,{arrayMode:So,fullResults:xo,types:qt.types})})}else{let M=I??{},we=M.arrayMode??se,Ie=M.fullResults?? +B;return mr(Q,{arrayMode:we,fullResults:Ie,types:M.types})}}else{let{status:Q}=me;if(Q===400){let M=await me. +json(),we=new he(M.message);for(let Ie of Ru)we[Ie]=M[Ie]??void 0;throw we}else{let M=await me.text(); +throw new he(`Server error (HTTP status ${Q}): ${M}`)}}}return a(Y,"execute"),D}a(wr,"neon");var gr=class gr{constructor(e,t,n){ this.execute=e;this.queryData=t;this.opts=n}then(e,t){return this.execute(this.queryData,this.opts). then(e,t)}catch(e){return this.execute(this.queryData,this.opts).catch(e)}finally(e){return this.execute( -this.queryData,this.opts).finally(e)}};a(mr,"NeonQueryPromise");var xe=mr;function as(r,{arrayMode:e, -fullResults:t,types:n}){let i=new us.default(n),s=r.fields.map(c=>c.name),o=r.fields.map(c=>i.getTypeParser( +this.queryData,this.opts).finally(e)}};a(gr,"NeonQueryPromise");var ve=gr;function mr(r,{arrayMode:e, +fullResults:t,types:n}){let i=new cs.default(n),s=r.fields.map(c=>c.name),o=r.fields.map(c=>i.getTypeParser( c.dataTypeID)),u=e===!0?r.rows.map(c=>c.map((l,f)=>l===null?null:o[f](l))):r.rows.map(c=>Object.fromEntries( c.map((l,f)=>[s[f],l===null?null:o[f](l)])));return t?(r.viaNeonFetch=!0,r.rowAsArray=e,r.rows=u,r._parsers= -o,r._types=i,r):u}a(as,"processQueryResult");async function Fu(r){if(typeof r=="string")return r;if(typeof r== -"function")try{return await Promise.resolve(r())}catch(e){let t=new de("Error getting auth token."); -throw e instanceof Error&&(t=new de(`Error getting auth token: ${e.message}`)),t}}a(Fu,"getAuthToken");p();var go=Ae(ct());p();var wo=Ae(ct());var Un=class Un extends wo.Client{constructor(t){super(t);this.config=t}get neonConfig(){return this. -connection.stream}connect(t){let{neonConfig:n}=this;n.forceDisablePgSSL&&(this.ssl=this.connection.ssl= -!1),this.ssl&&n.useSecureWebSocket&&console.warn("SSL is enabled for both Postgres (e.g. ?sslmode=re\ -quire in the connection string + forceDisablePgSSL = false) and the WebSocket tunnel (useSecureWebSo\ -cket = true). Double encryption will increase latency and CPU usage. It may be appropriate to disabl\ -e SSL in the Postgres connection parameters or set forceDisablePgSSL = true.");let i=typeof this.config!= -"string"&&this.config?.host!==void 0||typeof this.config!="string"&&this.config?.connectionString!== -void 0||m.env.PGHOST!==void 0,s=m.env.USER??m.env.USERNAME;if(!i&&this.host==="localhost"&&this.user=== -s&&this.database===s&&this.password===null)throw new Error(`No database host or connection string wa\ -s set, and key parameters have default values (host: localhost, user: ${s}, db: ${s}, password: null\ -). Is an environment variable missing? Alternatively, if you intended to connect with these paramete\ -rs, please set the host to 'localhost' explicitly.`);let o=super.connect(t),u=n.pipelineTLS&&this.ssl, -c=n.pipelineConnect==="password";if(!u&&!n.pipelineConnect)return o;let l=this.connection;if(u&&l.on( -"connect",()=>l.stream.emit("data","S")),c){l.removeAllListeners("authenticationCleartextPassword"), -l.removeAllListeners("readyForQuery"),l.once("readyForQuery",()=>l.on("readyForQuery",this._handleReadyForQuery. -bind(this)));let f=this.ssl?"sslconnect":"connect";l.on(f,()=>{this.neonConfig.disableWarningInBrowsers|| -Ke(),this._handleAuthCleartextPassword(),this._handleReadyForQuery()})}return o}async _handleAuthSASLContinue(t){ -if(typeof crypto>"u"||crypto.subtle===void 0||crypto.subtle.importKey===void 0)throw new Error("Cann\ -ot use SASL auth when `crypto.subtle` is not defined");let n=crypto.subtle,i=this.saslSession,s=this. -password,o=t.data;if(i.message!=="SASLInitialResponse"||typeof s!="string"||typeof o!="string")throw new Error( -"SASL: protocol error");let u=Object.fromEntries(o.split(",").map(M=>{if(!/^.=/.test(M))throw new Error( -"SASL: Invalid attribute pair entry");let $=M[0],ge=M.substring(2);return[$,ge]})),c=u.r,l=u.s,f=u.i; -if(!c||!/^[!-+--~]+$/.test(c))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing/unpri\ -ntable");if(!l||!/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(l))throw new Error( -"SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing/not base64");if(!f||!/^[1-9][0-9]*$/.test(f))throw new Error( -"SASL: SCRAM-SERVER-FIRST-MESSAGE: missing/invalid iteration count");if(!c.startsWith(i.clientNonce)) -throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");if(c. -length===i.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too\ - short");let y=parseInt(f,10),g=d.from(l,"base64"),A=new TextEncoder,C=A.encode(s),D=await n.importKey( -"raw",C,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),Y=new Uint8Array(await n.sign("HMAC",D,d.concat( -[g,d.from([0,0,0,1])]))),P=Y;for(var I=0;IP[$]^Y[$]));let w=P,Z=await n.importKey("raw",w,{name:"HMAC",hash:{name:"SHA-256"}},!1, -["sign"]),W=new Uint8Array(await n.sign("HMAC",Z,A.encode("Client Key"))),J=await n.digest("SHA-256", -W),X="n=*,r="+i.clientNonce,oe="r="+c+",s="+l+",i="+y,ae="c=biws,r="+c,R=X+","+oe+","+ae,j=await n.importKey( -"raw",J,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);var fe=new Uint8Array(await n.sign("HMAC",j, -A.encode(R))),me=d.from(W.map((M,$)=>W[$]^fe[$])),Ge=me.toString("base64");let he=await n.importKey( -"raw",w,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),Ie=await n.sign("HMAC",he,A.encode("Server \ -Key")),we=await n.importKey("raw",Ie,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);var ee=d.from( -await n.sign("HMAC",we,A.encode(R)));i.message="SASLResponse",i.serverSignature=ee.toString("base64"), -i.response=ae+",p="+Ge,this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}};a(Un, -"NeonClient");var $e=Un;ke();var bo=Ae(Bt());function vl(r,e){if(e)return{callback:e,result:void 0};let t,n,i=a(function(o,u){o?t(o):n(u)},"cb"), -s=new r(function(o,u){n=o,t=u});return{callback:i,result:s}}a(vl,"promisify");var Dn=class Dn extends go.Pool{constructor(){ -super(...arguments);E(this,"Client",$e);E(this,"hasFetchUnsupportedListeners",!1);E(this,"addListene\ +o,r._types=i,r):u}a(mr,"processQueryResult");async function Fu(r){if(typeof r=="string")return r;if(typeof r== +"function")try{return await Promise.resolve(r())}catch(e){let t=new he("Error getting auth token."); +throw e instanceof Error&&(t=new he(`Error getting auth token: ${e.message}`)),t}}a(Fu,"getAuthToken");d();var bo=Ae(ct());d();var go=Ae(ct());var On=class On extends go.Client{constructor(t){super(t);this.config=t}get neonConfig(){return this. +connection.stream}connect(t){let{neonConfig:n}=this;n.isNeonLocal&&n.setConnectionCredentials({user:this. +user||void 0,password:this.password||void 0,database:this.database||void 0}),n.forceDisablePgSSL&&(this. +ssl=this.connection.ssl=!1),this.ssl&&n.useSecureWebSocket&&console.warn("SSL is enabled for both Po\ +stgres (e.g. ?sslmode=require in the connection string + forceDisablePgSSL = false) and the WebSocke\ +t tunnel (useSecureWebSocket = true). Double encryption will increase latency and CPU usage. It may \ +be appropriate to disable SSL in the Postgres connection parameters or set forceDisablePgSSL = true."); +let i=typeof this.config!="string"&&this.config?.host!==void 0||typeof this.config!="string"&&this.config?. +connectionString!==void 0||m.env.PGHOST!==void 0,s=m.env.USER??m.env.USERNAME;if(!i&&this.host==="lo\ +calhost"&&this.user===s&&this.database===s&&this.password===null)throw new Error(`No database host o\ +r connection string was set, and key parameters have default values (host: localhost, user: ${s}, db\ +: ${s}, password: null). Is an environment variable missing? Alternatively, if you intended to conne\ +ct with these parameters, please set the host to 'localhost' explicitly.`);let o=super.connect(t),u=n. +pipelineTLS&&this.ssl,c=n.pipelineConnect==="password";if(!u&&!n.pipelineConnect)return o;let l=this. +connection;if(u&&l.on("connect",()=>l.stream.emit("data","S")),c){l.removeAllListeners("authenticati\ +onCleartextPassword"),l.removeAllListeners("readyForQuery"),l.once("readyForQuery",()=>l.on("readyFo\ +rQuery",this._handleReadyForQuery.bind(this)));let f=this.ssl?"sslconnect":"connect";l.on(f,()=>{this. +neonConfig.disableWarningInBrowsers||Ke(),this._handleAuthCleartextPassword(),this._handleReadyForQuery()})} +return o}async _handleAuthSASLContinue(t){if(typeof crypto>"u"||crypto.subtle===void 0||crypto.subtle. +importKey===void 0)throw new Error("Cannot use SASL auth when `crypto.subtle` is not defined");let n=crypto. +subtle,i=this.saslSession,s=this.password,o=t.data;if(i.message!=="SASLInitialResponse"||typeof s!="\ +string"||typeof o!="string")throw new Error("SASL: protocol error");let u=Object.fromEntries(o.split( +",").map(Q=>{if(!/^.=/.test(Q))throw new Error("SASL: Invalid attribute pair entry");let M=Q[0],we=Q. +substring(2);return[M,we]})),c=u.r,l=u.s,f=u.i;if(!c||!/^[!-+--~]+$/.test(c))throw new Error("SASL: \ +SCRAM-SERVER-FIRST-MESSAGE: nonce missing/unprintable");if(!l||!/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/. +test(l))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing/not base64");if(!f||!/^[1-9][0-9]*$/. +test(f))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: missing/invalid iteration count");if(!c.startsWith( +i.clientNonce))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with c\ +lient nonce");if(c.length===i.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: \ +server nonce is too short");let p=parseInt(f,10),g=y.from(l,"base64"),E=new TextEncoder,C=E.encode(s), +D=await n.importKey("raw",C,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),Y=new Uint8Array(await n. +sign("HMAC",D,y.concat([g,y.from([0,0,0,1])]))),P=Y;for(var I=0;IP[M]^Y[M]));let w=P,X=await n.importKey("raw",w,{name:"HMAC",hash:{ +name:"SHA-256"}},!1,["sign"]),j=new Uint8Array(await n.sign("HMAC",X,E.encode("Client Key"))),Z=await n. +digest("SHA-256",j),pe="n=*,r="+i.clientNonce,J="r="+c+",s="+l+",i="+p,se="c=biws,r="+c,B=pe+","+J+"\ +,"+se,H=await n.importKey("raw",Z,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);var le=new Uint8Array( +await n.sign("HMAC",H,E.encode(B))),ye=y.from(j.map((Q,M)=>j[M]^le[M])),Ee=ye.toString("base64");let $e=await n. +importKey("raw",w,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),ee=await n.sign("HMAC",$e,E.encode( +"Server Key")),ft=await n.importKey("raw",ee,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);var me=y. +from(await n.sign("HMAC",ft,E.encode(B)));i.message="SASLResponse",i.serverSignature=me.toString("ba\ +se64"),i.response=se+",p="+Ee,this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}}; +a(On,"NeonClient");var He=On;Ve();var vo=Ae(Bt());function Sl(r,e){if(e)return{callback:e,result:void 0};let t,n,i=a(function(o,u){o?t(o):n(u)},"cb"), +s=new r(function(o,u){n=o,t=u});return{callback:i,result:s}}a(Sl,"promisify");var Nn=class Nn extends bo.Pool{constructor(){ +super(...arguments);A(this,"Client",He);A(this,"hasFetchUnsupportedListeners",!1);A(this,"addListene\ r",this.on)}on(t,n){return t!=="error"&&(this.hasFetchUnsupportedListeners=!0),super.on(t,n)}query(t,n,i){ -if(!se.poolQueryViaFetch||this.hasFetchUnsupportedListeners||typeof t=="function")return super.query( -t,n,i);typeof n=="function"&&(i=n,n=void 0);let s=vl(this.Promise,i);i=s.callback;try{let o=new bo.default( +if(!ue.poolQueryViaFetch||this.hasFetchUnsupportedListeners||typeof t=="function")return super.query( +t,n,i);typeof n=="function"&&(i=n,n=void 0);let s=Sl(this.Promise,i);i=s.callback;try{let o=new vo.default( this.options),u=encodeURIComponent,c=encodeURI,l=`postgresql://${u(o.user)}:${u(o.password)}@${u(o.host)}\ -/${c(o.database)}`,f=typeof t=="string"?t:t.text,y=n??t.values??[];yr(l,{fullResults:!0,arrayMode:t. -rowMode==="array"}).query(f,y,{types:t.types??this.options?.types}).then(A=>i(void 0,A)).catch(A=>i( -A))}catch(o){i(o)}return s.result}};a(Dn,"NeonPool");var Ot=Dn;ke();var le=Ae(ct()),xl="js"; +/${c(o.database)}`,f=typeof t=="string"?t:t.text,p=n??t.values??[];wr(l,{fullResults:!0,arrayMode:t. +rowMode==="array"}).query(f,p,{types:t.types??this.options?.types}).then(E=>i(void 0,E)).catch(E=>i( +E))}catch(o){i(o)}return s.result}};a(Nn,"NeonPool");var Nt=Nn;Ve();var ce=Ae(ct()),xl="js"; /*! Bundled license information: ieee754/index.js: diff --git a/index.mjs b/index.mjs index dbd561c..4a1471f 100644 --- a/index.mjs +++ b/index.mjs @@ -1,74 +1,74 @@ /* @ts-self-types="./index.d.mts" */ -var So=Object.create;var Ie=Object.defineProperty;var Eo=Object.getOwnPropertyDescriptor;var Ao=Object.getOwnPropertyNames;var Co=Object.getPrototypeOf,_o=Object.prototype.hasOwnProperty;var Io=(r,e,t)=>e in r?Ie(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var a=(r,e)=>Ie(r,"name",{value:e,configurable:!0});var G=(r,e)=>()=>(r&&(e=r(r=0)),e);var T=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ie=(r,e)=>{for(var t in e)Ie(r,t,{get:e[t], -enumerable:!0})},Dn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ao(e))!_o. -call(r,i)&&i!==t&&Ie(r,i,{get:()=>e[i],enumerable:!(n=Eo(e,i))||n.enumerable});return r};var Se=(r,e,t)=>(t=r!=null?So(Co(r)):{},Dn(e||!r||!r.__esModule?Ie(t,"default",{value:r,enumerable:!0}): -t,r)),O=r=>Dn(Ie({},"__esModule",{value:!0}),r);var E=(r,e,t)=>Io(r,typeof e!="symbol"?e+"":e,t);var Qn=T(lt=>{"use strict";p();lt.byteLength=Po;lt.toByteArray=Ro;lt.fromByteArray=ko;var ae=[],te=[], -To=typeof Uint8Array<"u"?Uint8Array:Array,qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01\ -23456789+/";for(Ee=0,On=qt.length;Eee in r?Ie(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var a=(r,e)=>Ie(r,"name",{value:e,configurable:!0});var G=(r,e)=>()=>(r&&(e=r(r=0)),e);var T=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ie=(r,e)=>{for(var t in e)Ie(r,t,{get:e[t], +enumerable:!0})},On=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Co(e))!Io. +call(r,i)&&i!==t&&Ie(r,i,{get:()=>e[i],enumerable:!(n=Ao(e,i))||n.enumerable});return r};var xe=(r,e,t)=>(t=r!=null?Eo(_o(r)):{},On(e||!r||!r.__esModule?Ie(t,"default",{value:r,enumerable:!0}): +t,r)),O=r=>On(Ie({},"__esModule",{value:!0}),r);var A=(r,e,t)=>To(r,typeof e!="symbol"?e+"":e,t);var Qn=T(ft=>{"use strict";d();ft.byteLength=Lo;ft.toByteArray=Ro;ft.fromByteArray=Mo;var oe=[],te=[], +Po=typeof Uint8Array<"u"?Uint8Array:Array,qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01\ +23456789+/";for(Ee=0,Nn=qt.length;Ee0)throw new Error("Invalid string. Length must be \ a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}a(qn,"getLens"); -function Po(r){var e=qn(r),t=e[0],n=e[1];return(t+n)*3/4-n}a(Po,"byteLength");function Bo(r,e,t){return(e+ -t)*3/4-t}a(Bo,"_byteLength");function Ro(r){var e,t=qn(r),n=t[0],i=t[1],s=new To(Bo(r,n,i)),o=0,u=i> +function Lo(r){var e=qn(r),t=e[0],n=e[1];return(t+n)*3/4-n}a(Lo,"byteLength");function Bo(r,e,t){return(e+ +t)*3/4-t}a(Bo,"_byteLength");function Ro(r){var e,t=qn(r),n=t[0],i=t[1],s=new Po(Bo(r,n,i)),o=0,u=i> 0?n-4:n,c;for(c=0;c>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=te[r.charCodeAt( c)]<<2|te[r.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=te[r.charCodeAt(c)]<<10|te[r.charCodeAt(c+1)]<< -4|te[r.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}a(Ro,"toByteArray");function Lo(r){return ae[r>> -18&63]+ae[r>>12&63]+ae[r>>6&63]+ae[r&63]}a(Lo,"tripletToBase64");function Fo(r,e,t){for(var n,i=[],s=e;s< -t;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(Lo(n));return i.join("")}a(Fo,"en\ -codeChunk");function ko(r){for(var e,t=r.length,n=t%3,i=[],s=16383,o=0,u=t-n;ou?u:o+s));return n===1?(e=r[t-1],i.push(ae[e>>2]+ae[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1], -i.push(ae[e>>10]+ae[e>>4&63]+ae[e<<2&63]+"=")),i.join("")}a(ko,"fromByteArray")});var Nn=T(Qt=>{p();Qt.read=function(r,e,t,n,i){var s,o,u=i*8-n-1,c=(1<>1,f=-7,y=t?i-1:0,g=t? --1:1,A=r[e+y];for(y+=g,s=A&(1<<-f)-1,A>>=-f,f+=u;f>0;s=s*256+r[e+y],y+=g,f-=8);for(o=s&(1<<-f)-1,s>>= --f,f+=n;f>0;o=o*256+r[e+y],y+=g,f-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(A?-1:1)*(1/0);o=o+Math. -pow(2,n),s=s-l}return(A?-1:1)*o*Math.pow(2,s-n)};Qt.write=function(r,e,t,n,i,s){var o,u,c,l=s*8-i-1, -f=(1<>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=n?0:s-1,C=n?1:-1,D=e<0||e===0&&1/e<0? +4|te[r.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}a(Ro,"toByteArray");function ko(r){return oe[r>> +18&63]+oe[r>>12&63]+oe[r>>6&63]+oe[r&63]}a(ko,"tripletToBase64");function Fo(r,e,t){for(var n,i=[],s=e;s< +t;s+=3)n=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),i.push(ko(n));return i.join("")}a(Fo,"en\ +codeChunk");function Mo(r){for(var e,t=r.length,n=t%3,i=[],s=16383,o=0,u=t-n;ou?u:o+s));return n===1?(e=r[t-1],i.push(oe[e>>2]+oe[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1], +i.push(oe[e>>10]+oe[e>>4&63]+oe[e<<2&63]+"=")),i.join("")}a(Mo,"fromByteArray")});var Wn=T(Qt=>{d();Qt.read=function(r,e,t,n,i){var s,o,u=i*8-n-1,c=(1<>1,f=-7,p=t?i-1:0,g=t? +-1:1,E=r[e+p];for(p+=g,s=E&(1<<-f)-1,E>>=-f,f+=u;f>0;s=s*256+r[e+p],p+=g,f-=8);for(o=s&(1<<-f)-1,s>>= +-f,f+=n;f>0;o=o*256+r[e+p],p+=g,f-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(E?-1:1)*(1/0);o=o+Math. +pow(2,n),s=s-l}return(E?-1:1)*o*Math.pow(2,s-n)};Qt.write=function(r,e,t,n,i,s){var o,u,c,l=s*8-i-1, +f=(1<>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=n?0:s-1,C=n?1:-1,D=e<0||e===0&&1/e<0? 1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,o=f):(o=Math.floor(Math.log(e)/Math.LN2),e*(c= -Math.pow(2,-o))<1&&(o--,c*=2),o+y>=1?e+=g/c:e+=g*Math.pow(2,1-y),e*c>=2&&(o++,c/=2),o+y>=f?(u=0,o=f): -o+y>=1?(u=(e*c-1)*Math.pow(2,i),o=o+y):(u=e*Math.pow(2,y-1)*Math.pow(2,i),o=0));i>=8;r[t+A]=u&255,A+= -C,u/=256,i-=8);for(o=o<0;r[t+A]=o&255,A+=C,o/=256,l-=8);r[t+A-C]|=D*128}});var ii=T(Re=>{"use strict";p();var Nt=Qn(),Pe=Nn(),Wn=typeof Symbol=="function"&&typeof Symbol.for== -"function"?Symbol.for("nodejs.util.inspect.custom"):null;Re.Buffer=h;Re.SlowBuffer=Qo;Re.INSPECT_MAX_BYTES= -50;var ft=2147483647;Re.kMaxLength=ft;h.TYPED_ARRAY_SUPPORT=Mo();!h.TYPED_ARRAY_SUPPORT&&typeof console< +Math.pow(2,-o))<1&&(o--,c*=2),o+p>=1?e+=g/c:e+=g*Math.pow(2,1-p),e*c>=2&&(o++,c/=2),o+p>=f?(u=0,o=f): +o+p>=1?(u=(e*c-1)*Math.pow(2,i),o=o+p):(u=e*Math.pow(2,p-1)*Math.pow(2,i),o=0));i>=8;r[t+E]=u&255,E+= +C,u/=256,i-=8);for(o=o<0;r[t+E]=o&255,E+=C,o/=256,l-=8);r[t+E-C]|=D*128}});var si=T(Be=>{"use strict";d();var Wt=Qn(),Pe=Wn(),jn=typeof Symbol=="function"&&typeof Symbol.for== +"function"?Symbol.for("nodejs.util.inspect.custom"):null;Be.Buffer=h;Be.SlowBuffer=Qo;Be.INSPECT_MAX_BYTES= +50;var ht=2147483647;Be.kMaxLength=ht;h.TYPED_ARRAY_SUPPORT=Uo();!h.TYPED_ARRAY_SUPPORT&&typeof console< "u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) su\ -pport which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Mo(){ +pport which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Uo(){ try{let r=new Uint8Array(1),e={foo:a(function(){return 42},"foo")};return Object.setPrototypeOf(e,Uint8Array. -prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}a(Mo,"typedArraySupport");Object. +prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}a(Uo,"typedArraySupport");Object. defineProperty(h.prototype,"parent",{enumerable:!0,get:a(function(){if(h.isBuffer(this))return this. buffer},"get")});Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:a(function(){if(h.isBuffer( -this))return this.byteOffset},"get")});function he(r){if(r>ft)throw new RangeError('The value "'+r+'\ +this))return this.byteOffset},"get")});function ce(r){if(r>ht)throw new RangeError('The value "'+r+'\ " is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,h.prototype), -e}a(he,"createBuffer");function h(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError( -'The "string" argument must be of type string. Received type number');return $t(r)}return Gn(r,e,t)} -a(h,"Buffer");h.poolSize=8192;function Gn(r,e,t){if(typeof r=="string")return Do(r,e);if(ArrayBuffer. -isView(r))return Oo(r);if(r==null)throw new TypeError("The first argument must be one of type string\ -, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(ue(r,ArrayBuffer)|| -r&&ue(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ue(r,SharedArrayBuffer)||r&&ue(r.buffer, -SharedArrayBuffer)))return jt(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument\ +e}a(ce,"createBuffer");function h(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError( +'The "string" argument must be of type string. Received type number');return Gt(r)}return Vn(r,e,t)} +a(h,"Buffer");h.poolSize=8192;function Vn(r,e,t){if(typeof r=="string")return Oo(r,e);if(ArrayBuffer. +isView(r))return No(r);if(r==null)throw new TypeError("The first argument must be one of type string\ +, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(ae(r,ArrayBuffer)|| +r&&ae(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ae(r,SharedArrayBuffer)||r&&ae(r.buffer, +SharedArrayBuffer)))return Ht(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument\ must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return h. from(n,e,t);let i=qo(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol. toPrimitive]=="function")return h.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The\ first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Receiv\ -ed type "+typeof r)}a(Gn,"from");h.from=function(r,e,t){return Gn(r,e,t)};Object.setPrototypeOf(h.prototype, -Uint8Array.prototype);Object.setPrototypeOf(h,Uint8Array);function Vn(r){if(typeof r!="number")throw new TypeError( +ed type "+typeof r)}a(Vn,"from");h.from=function(r,e,t){return Vn(r,e,t)};Object.setPrototypeOf(h.prototype, +Uint8Array.prototype);Object.setPrototypeOf(h,Uint8Array);function zn(r){if(typeof r!="number")throw new TypeError( '"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid \ -for option "size"')}a(Vn,"assertSize");function Uo(r,e,t){return Vn(r),r<=0?he(r):e!==void 0?typeof t== -"string"?he(r).fill(e,t):he(r).fill(e):he(r)}a(Uo,"alloc");h.alloc=function(r,e,t){return Uo(r,e,t)}; -function $t(r){return Vn(r),he(r<0?0:Gt(r)|0)}a($t,"allocUnsafe");h.allocUnsafe=function(r){return $t( -r)};h.allocUnsafeSlow=function(r){return $t(r)};function Do(r,e){if((typeof e!="string"||e==="")&&(e= -"utf8"),!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=zn(r,e)|0,n=he(t),i=n.write( -r,e);return i!==t&&(n=n.slice(0,i)),n}a(Do,"fromString");function Wt(r){let e=r.length<0?0:Gt(r.length)| -0,t=he(e);for(let n=0;n=ft)throw new RangeError("Attempt to allocate Buffer larger t\ -han maximum size: 0x"+ft.toString(16)+" bytes");return r|0}a(Gt,"checked");function Qo(r){return+r!= +r,e,t),Object.setPrototypeOf(n,h.prototype),n}a(Ht,"fromArrayBuffer");function qo(r){if(h.isBuffer(r)){ +let e=Vt(r.length)|0,t=ce(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r. +length!="number"||Kt(r.length)?ce(0):jt(r);if(r.type==="Buffer"&&Array.isArray(r.data))return jt(r.data)} +a(qo,"fromObject");function Vt(r){if(r>=ht)throw new RangeError("Attempt to allocate Buffer larger t\ +han maximum size: 0x"+ht.toString(16)+" bytes");return r|0}a(Vt,"checked");function Qo(r){return+r!= r&&(r=0),h.alloc(+r)}a(Qo,"SlowBuffer");h.isBuffer=a(function(e){return e!=null&&e._isBuffer===!0&&e!== -h.prototype},"isBuffer");h.compare=a(function(e,t){if(ue(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)), -ue(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(e)||!h.isBuffer(t))throw new TypeError( +h.prototype},"isBuffer");h.compare=a(function(e,t){if(ae(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)), +ae(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(e)||!h.isBuffer(t))throw new TypeError( 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length, i=t.length;for(let s=0,o=Math.min(n,i);si.length?(h.isBuffer(o)||(o=h.from(o)),o.copy(i,s)):Uint8Array.prototype. +if(ae(o,Uint8Array))s+o.length>i.length?(h.isBuffer(o)||(o=h.from(o)),o.copy(i,s)):Uint8Array.prototype. set.call(i,o,s);else if(h.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be \ -an Array of Buffers');s+=o.length}return i},"concat");function zn(r,e){if(h.isBuffer(r))return r.length; -if(ArrayBuffer.isView(r)||ue(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError( +an Array of Buffers');s+=o.length}return i},"concat");function Kn(r,e){if(h.isBuffer(r))return r.length; +if(ArrayBuffer.isView(r)||ae(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError( 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r); let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(e){case"\ -ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Ht(r).length;case"ucs2":case"\ -ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return ni(r).length;default: -if(i)return n?-1:Ht(r).length;e=(""+e).toLowerCase(),i=!0}}a(zn,"byteLength");h.byteLength=zn;function No(r,e,t){ +ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return $t(r).length;case"ucs2":case"\ +ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return ii(r).length;default: +if(i)return n?-1:$t(r).length;e=(""+e).toLowerCase(),i=!0}}a(Kn,"byteLength");h.byteLength=Kn;function Wo(r,e,t){ let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<= 0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Zo(this,e,t);case"u\ -tf8":case"utf-8":return Yn(this,e,t);case"ascii":return Ko(this,e,t);case"latin1":case"binary":return Yo( -this,e,t);case"base64":return Vo(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Jo( -this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}a(No, +tf8":case"utf-8":return Xn(this,e,t);case"ascii":return Yo(this,e,t);case"latin1":case"binary":return Xo( +this,e,t);case"base64":return zo(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Jo( +this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}a(Wo, "slowToString");h.prototype._isBuffer=!0;function Ae(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}a(Ae,"swap"); h.prototype.swap16=a(function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must \ be a multiple of 16-bits");for(let t=0;tt&&(e+=" ... "),""},"inspect");Wn&&(h.prototype[Wn]=h.prototype.inspect);h.prototype.compare=a(function(e,t,n,i,s){ -if(ue(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),!h.isBuffer(e))throw new TypeError('The "ta\ +er "+e+">"},"inspect");jn&&(h.prototype[jn]=h.prototype.inspect);h.prototype.compare=a(function(e,t,n,i,s){ +if(ae(e,Uint8Array)&&(e=h.from(e,e.offset,e.byteLength)),!h.isBuffer(e))throw new TypeError('The "ta\ rget" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t= 0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),t<0||n>e.length||i<0|| s>this.length)throw new RangeError("out of range index");if(i>=s&&t>=n)return 0;if(i>=s)return-1;if(t>= n)return 1;if(t>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,u=n-t,c=Math.min(o,u),l=this.slice( -i,s),f=e.slice(t,n);for(let y=0;y2147483647? -t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,zt(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r. +i,s),f=e.slice(t,n);for(let p=0;p2147483647? +t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Kt(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r. length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=h.from( -e,n)),h.isBuffer(e))return e.length===0?-1:jn(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array. +e,n)),h.isBuffer(e))return e.length===0?-1:Hn(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array. prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf. -call(r,e,t):jn(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}a(Kn,"bidire\ -ctionalIndexOf");function jn(r,e,t,n,i){let s=1,o=r.length,u=e.length;if(n!==void 0&&(n=String(n).toLowerCase(), +call(r,e,t):Hn(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}a(Yn,"bidire\ +ctionalIndexOf");function Hn(r,e,t,n,i){let s=1,o=r.length,u=e.length;if(n!==void 0&&(n=String(n).toLowerCase(), n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;s=2,o/=2, -u/=2,t/=2}function c(f,y){return s===1?f[y]:f.readUInt16BE(y*s)}a(c,"read");let l;if(i){let f=-1;for(l= +u/=2,t/=2}function c(f,p){return s===1?f[p]:f.readUInt16BE(p*s)}a(c,"read");let l;if(i){let f=-1;for(l= t;lo&&(t=o-u),l=t;l>=0;l--){let f=!0;for(let y=0;yo&&(t=o-u),l=t;l>=0;l--){let f=!0;for(let p=0;pi&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o= -0;o>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.wri\ te(string, encoding, offset[, length]) is no longer supported");let s=this.length-t;if((n===void 0|| n>s)&&(n=s),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buf\ -fer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return Wo(this,e,t,n);case"utf8":case"\ -utf-8":return jo(this,e,t,n);case"ascii":case"latin1":case"binary":return Ho(this,e,t,n);case"base64": -return $o(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Go(this,e,t,n);default: +fer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return jo(this,e,t,n);case"utf8":case"\ +utf-8":return Ho(this,e,t,n);case"ascii":case"latin1":case"binary":return $o(this,e,t,n);case"base64": +return Go(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Vo(this,e,t,n);default: if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},"write");h.prototype. toJSON=a(function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},"toJSO\ -N");function Vo(r,e,t){return e===0&&t===r.length?Nt.fromByteArray(r):Nt.fromByteArray(r.slice(e,t))} -a(Vo,"base64Slice");function Yn(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i239?4:s>223?3:s>191?2:1;if(i+u<=t){let c,l,f,y;switch(u){case 1:s<128&&(o=s);break;case 2:c=r[i+ -1],(c&192)===128&&(y=(s&31)<<6|c&63,y>127&&(o=y));break;case 3:c=r[i+1],l=r[i+2],(c&192)===128&&(l&192)=== -128&&(y=(s&15)<<12|(c&63)<<6|l&63,y>2047&&(y<55296||y>57343)&&(o=y));break;case 4:c=r[i+1],l=r[i+2], -f=r[i+3],(c&192)===128&&(l&192)===128&&(f&192)===128&&(y=(s&15)<<18|(c&63)<<12|(l&63)<<6|f&63,y>65535&& -y<1114112&&(o=y))}}o===null?(o=65533,u=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023), -n.push(o),i+=u}return zo(n)}a(Yn,"utf8Slice");var Hn=4096;function zo(r){let e=r.length;if(e<=Hn)return String. +N");function zo(r,e,t){return e===0&&t===r.length?Wt.fromByteArray(r):Wt.fromByteArray(r.slice(e,t))} +a(zo,"base64Slice");function Xn(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i239?4:s>223?3:s>191?2:1;if(i+u<=t){let c,l,f,p;switch(u){case 1:s<128&&(o=s);break;case 2:c=r[i+ +1],(c&192)===128&&(p=(s&31)<<6|c&63,p>127&&(o=p));break;case 3:c=r[i+1],l=r[i+2],(c&192)===128&&(l&192)=== +128&&(p=(s&15)<<12|(c&63)<<6|l&63,p>2047&&(p<55296||p>57343)&&(o=p));break;case 4:c=r[i+1],l=r[i+2], +f=r[i+3],(c&192)===128&&(l&192)===128&&(f&192)===128&&(p=(s&15)<<18|(c&63)<<12|(l&63)<<6|f&63,p>65535&& +p<1114112&&(o=p))}}o===null?(o=65533,u=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023), +n.push(o),i+=u}return Ko(n)}a(Xn,"utf8Slice");var $n=4096;function Ko(r){let e=r.length;if(e<=$n)return String. fromCharCode.apply(String,r);let t="",n=0;for(;nn)&&(t=n);let i="";for(let s=e;sn)&&(t=n);let i="";for(let s=e;sn&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t< -e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,h.prototype),i},"slice");function q(r,e,t){ +e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,h.prototype),i},"slice");function N(r,e,t){ if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to \ -access beyond buffer length")}a(q,"checkOffset");h.prototype.readUintLE=h.prototype.readUIntLE=a(function(e,t,n){ -e=e>>>0,t=t>>>0,n||q(e,t,this.length);let i=this[e],s=1,o=0;for(;++o>>0,t=t>>>0,n||q(e, +access beyond buffer length")}a(N,"checkOffset");h.prototype.readUintLE=h.prototype.readUIntLE=a(function(e,t,n){ +e=e>>>0,t=t>>>0,n||N(e,t,this.length);let i=this[e],s=1,o=0;for(;++o>>0,t=t>>>0,n||N(e, t,this.length);let i=this[e+--t],s=1;for(;t>0&&(s*=256);)i+=this[e+--t]*s;return i},"readUIntBE");h. -prototype.readUint8=h.prototype.readUInt8=a(function(e,t){return e=e>>>0,t||q(e,1,this.length),this[e]}, -"readUInt8");h.prototype.readUint16LE=h.prototype.readUInt16LE=a(function(e,t){return e=e>>>0,t||q(e, +prototype.readUint8=h.prototype.readUInt8=a(function(e,t){return e=e>>>0,t||N(e,1,this.length),this[e]}, +"readUInt8");h.prototype.readUint16LE=h.prototype.readUInt16LE=a(function(e,t){return e=e>>>0,t||N(e, 2,this.length),this[e]|this[e+1]<<8},"readUInt16LE");h.prototype.readUint16BE=h.prototype.readUInt16BE= -a(function(e,t){return e=e>>>0,t||q(e,2,this.length),this[e]<<8|this[e+1]},"readUInt16BE");h.prototype. -readUint32LE=h.prototype.readUInt32LE=a(function(e,t){return e=e>>>0,t||q(e,4,this.length),(this[e]| +a(function(e,t){return e=e>>>0,t||N(e,2,this.length),this[e]<<8|this[e+1]},"readUInt16BE");h.prototype. +readUint32LE=h.prototype.readUInt32LE=a(function(e,t){return e=e>>>0,t||N(e,4,this.length),(this[e]| this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},"readUInt32LE");h.prototype.readUint32BE=h.prototype. -readUInt32BE=a(function(e,t){return e=e>>>0,t||q(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+ -2]<<8|this[e+3])},"readUInt32BE");h.prototype.readBigUInt64LE=we(a(function(e){e=e>>>0,Be(e,"offset"); -let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&je(e,this.length-8);let i=t+this[++e]*2**8+this[++e]* +readUInt32BE=a(function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+ +2]<<8|this[e+3])},"readUInt32BE");h.prototype.readBigUInt64LE=me(a(function(e){e=e>>>0,Le(e,"offset"); +let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&We(e,this.length-8);let i=t+this[++e]*2**8+this[++e]* 2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<< -BigInt(32))},"readBigUInt64LE"));h.prototype.readBigUInt64BE=we(a(function(e){e=e>>>0,Be(e,"offset"); -let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&je(e,this.length-8);let i=t*2**24+this[++e]*2**16+ +BigInt(32))},"readBigUInt64LE"));h.prototype.readBigUInt64BE=me(a(function(e){e=e>>>0,Le(e,"offset"); +let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&We(e,this.length-8);let i=t*2**24+this[++e]*2**16+ this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<>>0,t=t>>>0,n||q(e,t, +32))+BigInt(s)},"readBigUInt64BE"));h.prototype.readIntLE=a(function(e,t,n){e=e>>>0,t=t>>>0,n||N(e,t, this.length);let i=this[e],s=1,o=0;for(;++o=s&&(i-=Math. -pow(2,8*t)),i},"readIntLE");h.prototype.readIntBE=a(function(e,t,n){e=e>>>0,t=t>>>0,n||q(e,t,this.length); +pow(2,8*t)),i},"readIntLE");h.prototype.readIntBE=a(function(e,t,n){e=e>>>0,t=t>>>0,n||N(e,t,this.length); let i=t,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8* -t)),o},"readIntBE");h.prototype.readInt8=a(function(e,t){return e=e>>>0,t||q(e,1,this.length),this[e]& -128?(255-this[e]+1)*-1:this[e]},"readInt8");h.prototype.readInt16LE=a(function(e,t){e=e>>>0,t||q(e,2, +t)),o},"readIntBE");h.prototype.readInt8=a(function(e,t){return e=e>>>0,t||N(e,1,this.length),this[e]& +128?(255-this[e]+1)*-1:this[e]},"readInt8");h.prototype.readInt16LE=a(function(e,t){e=e>>>0,t||N(e,2, this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},"readInt16LE");h.prototype.readInt16BE= -a(function(e,t){e=e>>>0,t||q(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760: -n},"readInt16BE");h.prototype.readInt32LE=a(function(e,t){return e=e>>>0,t||q(e,4,this.length),this[e]| +a(function(e,t){e=e>>>0,t||N(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760: +n},"readInt16BE");h.prototype.readInt32LE=a(function(e,t){return e=e>>>0,t||N(e,4,this.length),this[e]| this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},"readInt32LE");h.prototype.readInt32BE=a(function(e,t){return e= -e>>>0,t||q(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},"readInt32BE");h.prototype. -readBigInt64LE=we(a(function(e){e=e>>>0,Be(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&& -je(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<>>0,t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},"readInt32BE");h.prototype. +readBigInt64LE=me(a(function(e){e=e>>>0,Le(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&& +We(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<>>0,Be(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&je(e,this. +me(a(function(e){e=e>>>0,Le(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&We(e,this. length-8);let i=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<>>0,t||q(e,4,this.length),Pe.read(this,e,!0,23,4)},"readFloatLE");h.prototype.readFloatBE= -a(function(e,t){return e=e>>>0,t||q(e,4,this.length),Pe.read(this,e,!1,23,4)},"readFloatBE");h.prototype. -readDoubleLE=a(function(e,t){return e=e>>>0,t||q(e,8,this.length),Pe.read(this,e,!0,52,8)},"readDoub\ -leLE");h.prototype.readDoubleBE=a(function(e,t){return e=e>>>0,t||q(e,8,this.length),Pe.read(this,e, +return e=e>>>0,t||N(e,4,this.length),Pe.read(this,e,!0,23,4)},"readFloatLE");h.prototype.readFloatBE= +a(function(e,t){return e=e>>>0,t||N(e,4,this.length),Pe.read(this,e,!1,23,4)},"readFloatBE");h.prototype. +readDoubleLE=a(function(e,t){return e=e>>>0,t||N(e,8,this.length),Pe.read(this,e,!0,52,8)},"readDoub\ +leLE");h.prototype.readDoubleBE=a(function(e,t){return e=e>>>0,t||N(e,8,this.length),Pe.read(this,e, !1,52,8)},"readDoubleBE");function V(r,e,t,n,i,s){if(!h.isBuffer(r))throw new TypeError('"buffer" ar\ gument must be a Buffer instance');if(e>i||er.length)throw new RangeError("Index out of range")}a(V,"checkInt");h.prototype.writeUintLE= @@ -209,13 +209,13 @@ writeUint32LE=h.prototype.writeUInt32LE=a(function(e,t,n){return e=+e,t=t>>>0,n| 0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},"writeUInt32LE");h.prototype. writeUint32BE=h.prototype.writeUInt32BE=a(function(e,t,n){return e=+e,t=t>>>0,n||V(this,e,t,4,4294967295, 0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},"writeUInt32BE");function Zn(r,e,t,n,i){ -ri(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295));r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]= +ni(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295));r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]= s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>> -8,r[t++]=o,t}a(Zn,"wrtBigUInt64LE");function Jn(r,e,t,n,i){ri(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295)); +8,r[t++]=o,t}a(Zn,"wrtBigUInt64LE");function Jn(r,e,t,n,i){ni(e,n,i,r,t,7);let s=Number(e&BigInt(4294967295)); r[t+7]=s,s=s>>8,r[t+6]=s,s=s>>8,r[t+5]=s,s=s>>8,r[t+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295)); return r[t+3]=o,o=o>>8,r[t+2]=o,o=o>>8,r[t+1]=o,o=o>>8,r[t]=o,t+8}a(Jn,"wrtBigUInt64BE");h.prototype. -writeBigUInt64LE=we(a(function(e,t=0){return Zn(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))},"w\ -riteBigUInt64LE"));h.prototype.writeBigUInt64BE=we(a(function(e,t=0){return Jn(this,e,t,BigInt(0),BigInt( +writeBigUInt64LE=me(a(function(e,t=0){return Zn(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))},"w\ +riteBigUInt64LE"));h.prototype.writeBigUInt64BE=me(a(function(e,t=0){return Jn(this,e,t,BigInt(0),BigInt( "0xffffffffffffffff"))},"writeBigUInt64BE"));h.prototype.writeIntLE=a(function(e,t,n,i){if(e=+e,t=t>>> 0,!i){let c=Math.pow(2,8*n-1);V(this,e,t,n,c-1,-c)}let s=0,o=1,u=0;for(this[t]=e&255;++s>0)-u&255;return t+n},"writeIntLE");h.prototype.writeIntBE= @@ -229,17 +229,17 @@ writeInt16BE=a(function(e,t,n){return e=+e,t=t>>>0,n||V(this,e,t,2,32767,-32768) e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},"\ writeInt32LE");h.prototype.writeInt32BE=a(function(e,t,n){return e=+e,t=t>>>0,n||V(this,e,t,4,2147483647, -2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255, -t+4},"writeInt32BE");h.prototype.writeBigInt64LE=we(a(function(e,t=0){return Zn(this,e,t,-BigInt("0x\ -8000000000000000"),BigInt("0x7fffffffffffffff"))},"writeBigInt64LE"));h.prototype.writeBigInt64BE=we( +t+4},"writeInt32BE");h.prototype.writeBigInt64LE=me(a(function(e,t=0){return Zn(this,e,t,-BigInt("0x\ +8000000000000000"),BigInt("0x7fffffffffffffff"))},"writeBigInt64LE"));h.prototype.writeBigInt64BE=me( a(function(e,t=0){return Jn(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))},"w\ -riteBigInt64BE"));function Xn(r,e,t,n,i,s){if(t+n>r.length)throw new RangeError("Index out of range"); -if(t<0)throw new RangeError("Index out of range")}a(Xn,"checkIEEE754");function ei(r,e,t,n,i){return e= -+e,t=t>>>0,i||Xn(r,e,t,4,34028234663852886e22,-34028234663852886e22),Pe.write(r,e,t,n,23,4),t+4}a(ei, -"writeFloat");h.prototype.writeFloatLE=a(function(e,t,n){return ei(this,e,t,!0,n)},"writeFloatLE");h. -prototype.writeFloatBE=a(function(e,t,n){return ei(this,e,t,!1,n)},"writeFloatBE");function ti(r,e,t,n,i){ -return e=+e,t=t>>>0,i||Xn(r,e,t,8,17976931348623157e292,-17976931348623157e292),Pe.write(r,e,t,n,52, -8),t+8}a(ti,"writeDouble");h.prototype.writeDoubleLE=a(function(e,t,n){return ti(this,e,t,!0,n)},"wr\ -iteDoubleLE");h.prototype.writeDoubleBE=a(function(e,t,n){return ti(this,e,t,!1,n)},"writeDoubleBE"); +riteBigInt64BE"));function ei(r,e,t,n,i,s){if(t+n>r.length)throw new RangeError("Index out of range"); +if(t<0)throw new RangeError("Index out of range")}a(ei,"checkIEEE754");function ti(r,e,t,n,i){return e= ++e,t=t>>>0,i||ei(r,e,t,4,34028234663852886e22,-34028234663852886e22),Pe.write(r,e,t,n,23,4),t+4}a(ti, +"writeFloat");h.prototype.writeFloatLE=a(function(e,t,n){return ti(this,e,t,!0,n)},"writeFloatLE");h. +prototype.writeFloatBE=a(function(e,t,n){return ti(this,e,t,!1,n)},"writeFloatBE");function ri(r,e,t,n,i){ +return e=+e,t=t>>>0,i||ei(r,e,t,8,17976931348623157e292,-17976931348623157e292),Pe.write(r,e,t,n,52, +8),t+8}a(ri,"writeDouble");h.prototype.writeDoubleLE=a(function(e,t,n){return ri(this,e,t,!0,n)},"wr\ +iteDoubleLE");h.prototype.writeDoubleBE=a(function(e,t,n){return ri(this,e,t,!1,n)},"writeDoubleBE"); h.prototype.copy=a(function(e,t,n,i){if(!h.isBuffer(e))throw new TypeError("argument should be a Buf\ fer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i>>0,n=n===void 0?this.length:n>>> 0,e||(e=0);let s;if(typeof e=="number")for(s=t;s2**32?i=$n(String(t)):typeof t=="bigint"&&(i=String( -t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=$n(i)),i+="n"),n+=` It must be ${e}. Re\ -ceived ${i}`,n},RangeError);function $n(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`\ -_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}a($n,"addNumericalSeparator");function Xo(r,e,t){ -Be(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&je(e,r.length-(t+1))}a(Xo,"checkBounds");function ri(r,e,t,n,i,s){ +e ${typeof e}`},TypeError);zt("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out o\ +f range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=Gn(String(t)):typeof t=="bigint"&&(i=String( +t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=Gn(i)),i+="n"),n+=` It must be ${e}. Re\ +ceived ${i}`,n},RangeError);function Gn(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`\ +_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}a(Gn,"addNumericalSeparator");function ea(r,e,t){ +Le(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&We(e,r.length-(t+1))}a(ea,"checkBounds");function ni(r,e,t,n,i,s){ if(r>t||r3?e===0||e===BigInt(0)?u=`>= 0${o} and < 2${o}\ ** ${(s+1)*8}${o}`:u=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:u=`>= ${e}${o} a\ -nd <= ${t}${o}`,new Te.ERR_OUT_OF_RANGE("value",u,r)}Xo(n,i,s)}a(ri,"checkIntBI");function Be(r,e){if(typeof r!= -"number")throw new Te.ERR_INVALID_ARG_TYPE(e,"number",r)}a(Be,"validateNumber");function je(r,e,t){throw Math. -floor(r)!==r?(Be(r,t),new Te.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new Te.ERR_BUFFER_OUT_OF_BOUNDS: -new Te.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}a(je,"boundsError");var ea=/[^+/0-9A-Za-z-_]/g; -function ta(r){if(r=r.split("=")[0],r=r.trim().replace(ea,""),r.length<2)return"";for(;r.length%4!== -0;)r=r+"=";return r}a(ta,"base64clean");function Ht(r,e){e=e||1/0;let t,n=r.length,i=null,s=[];for(let o=0;o< +nd <= ${t}${o}`,new Te.ERR_OUT_OF_RANGE("value",u,r)}ea(n,i,s)}a(ni,"checkIntBI");function Le(r,e){if(typeof r!= +"number")throw new Te.ERR_INVALID_ARG_TYPE(e,"number",r)}a(Le,"validateNumber");function We(r,e,t){throw Math. +floor(r)!==r?(Le(r,t),new Te.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new Te.ERR_BUFFER_OUT_OF_BOUNDS: +new Te.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}a(We,"boundsError");var ta=/[^+/0-9A-Za-z-_]/g; +function ra(r){if(r=r.split("=")[0],r=r.trim().replace(ta,""),r.length<2)return"";for(;r.length%4!== +0;)r=r+"=";return r}a(ra,"base64clean");function $t(r,e){e=e||1/0;let t,n=r.length,i=null,s=[];for(let o=0;o< n;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+ 1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189), i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,t<128){if((e-= 1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-= 3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18| -240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}a(Ht,"utf\ -8ToBytes");function ra(r){let e=[];for(let t=0;t>8,i=t%256,s.push(i),s.push(n);return s}a(na,"utf16leToBytes");function ni(r){return Nt.toByteArray( -ta(r))}a(ni,"base64ToBytes");function ht(r,e,t,n){let i;for(i=0;i=e.length||i>=r.length);++i) -e[i+t]=r[i];return i}a(ht,"blitBuffer");function ue(r,e){return r instanceof e||r!=null&&r.constructor!= -null&&r.constructor.name!=null&&r.constructor.name===e.name}a(ue,"isInstance");function zt(r){return r!== -r}a(zt,"numberIsNaN");var ia=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){ -let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e}();function we(r){return typeof BigInt>"u"? -sa:r}a(we,"defineBigIntMethod");function sa(){throw new Error("BigInt not supported")}a(sa,"BufferBi\ -gIntNotDefined")});var b,v,x,d,m,p=G(()=>{"use strict";b=globalThis,v=globalThis.setImmediate??(r=>setTimeout(r,0)),x=globalThis. -clearImmediate??(r=>clearTimeout(r)),d=typeof globalThis.Buffer=="function"&&typeof globalThis.Buffer. -allocUnsafe=="function"?globalThis.Buffer:ii().Buffer,m=globalThis.process??{};m.env??(m.env={});try{ -m.nextTick(()=>{})}catch{let e=Promise.resolve();m.nextTick=e.then.bind(e)}});var ge=T((Rl,Kt)=>{"use strict";p();var Le=typeof Reflect=="object"?Reflect:null,si=Le&&typeof Le.apply== -"function"?Le.apply:a(function(e,t,n){return Function.prototype.apply.call(e,t,n)},"ReflectApply"),pt; -Le&&typeof Le.ownKeys=="function"?pt=Le.ownKeys:Object.getOwnPropertySymbols?pt=a(function(e){return Object. +240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}a($t,"utf\ +8ToBytes");function na(r){let e=[];for(let t=0;t>8,i=t%256,s.push(i),s.push(n);return s}a(ia,"utf16leToBytes");function ii(r){return Wt.toByteArray( +ra(r))}a(ii,"base64ToBytes");function dt(r,e,t,n){let i;for(i=0;i=e.length||i>=r.length);++i) +e[i+t]=r[i];return i}a(dt,"blitBuffer");function ae(r,e){return r instanceof e||r!=null&&r.constructor!= +null&&r.constructor.name!=null&&r.constructor.name===e.name}a(ae,"isInstance");function Kt(r){return r!== +r}a(Kt,"numberIsNaN");var sa=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){ +let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e}();function me(r){return typeof BigInt>"u"? +oa:r}a(me,"defineBigIntMethod");function oa(){throw new Error("BigInt not supported")}a(oa,"BufferBi\ +gIntNotDefined")});var v,S,x,y,m,d=G(()=>{"use strict";v=globalThis,S=globalThis.setImmediate??(r=>setTimeout(r,0)),x=globalThis. +clearImmediate??(r=>clearTimeout(r)),y=typeof globalThis.Buffer=="function"&&typeof globalThis.Buffer. +allocUnsafe=="function"?globalThis.Buffer:si().Buffer,m=globalThis.process??{};m.env??(m.env={});try{ +m.nextTick(()=>{})}catch{let e=Promise.resolve();m.nextTick=e.then.bind(e)}});var we=T((Rl,Yt)=>{"use strict";d();var Re=typeof Reflect=="object"?Reflect:null,oi=Re&&typeof Re.apply== +"function"?Re.apply:a(function(e,t,n){return Function.prototype.apply.call(e,t,n)},"ReflectApply"),pt; +Re&&typeof Re.ownKeys=="function"?pt=Re.ownKeys:Object.getOwnPropertySymbols?pt=a(function(e){return Object. getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))},"ReflectOwnKeys"):pt=a(function(e){return Object. -getOwnPropertyNames(e)},"ReflectOwnKeys");function oa(r){console&&console.warn&&console.warn(r)}a(oa, -"ProcessEmitWarning");var ai=Number.isNaN||a(function(e){return e!==e},"NumberIsNaN");function B(){B. -init.call(this)}a(B,"EventEmitter");Kt.exports=B;Kt.exports.once=la;B.EventEmitter=B;B.prototype._events= -void 0;B.prototype._eventsCount=0;B.prototype._maxListeners=void 0;var oi=10;function dt(r){if(typeof r!= +getOwnPropertyNames(e)},"ReflectOwnKeys");function aa(r){console&&console.warn&&console.warn(r)}a(aa, +"ProcessEmitWarning");var ui=Number.isNaN||a(function(e){return e!==e},"NumberIsNaN");function L(){L. +init.call(this)}a(L,"EventEmitter");Yt.exports=L;Yt.exports.once=fa;L.EventEmitter=L;L.prototype._events= +void 0;L.prototype._eventsCount=0;L.prototype._maxListeners=void 0;var ai=10;function yt(r){if(typeof r!= "function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)} -a(dt,"checkListener");Object.defineProperty(B,"defaultMaxListeners",{enumerable:!0,get:a(function(){ -return oi},"get"),set:a(function(r){if(typeof r!="number"||r<0||ai(r))throw new RangeError('The valu\ -e of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");oi=r}, -"set")});B.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&& +a(yt,"checkListener");Object.defineProperty(L,"defaultMaxListeners",{enumerable:!0,get:a(function(){ +return ai},"get"),set:a(function(r){if(typeof r!="number"||r<0||ui(r))throw new RangeError('The valu\ +e of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");ai=r}, +"set")});L.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&& (this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}; -B.prototype.setMaxListeners=a(function(e){if(typeof e!="number"||e<0||ai(e))throw new RangeError('Th\ +L.prototype.setMaxListeners=a(function(e){if(typeof e!="number"||e<0||ui(e))throw new RangeError('Th\ e value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners= -e,this},"setMaxListeners");function ui(r){return r._maxListeners===void 0?B.defaultMaxListeners:r._maxListeners} -a(ui,"_getMaxListeners");B.prototype.getMaxListeners=a(function(){return ui(this)},"getMaxListeners"); -B.prototype.emit=a(function(e){for(var t=[],n=1;n 0&&(o=t[0]),o instanceof Error)throw o;var u=new Error("Unhandled error."+(o?" ("+o.message+")":"")); -throw u.context=o,u}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")si(c,this,t);else for(var l=c. -length,f=pi(c,l),n=0;n0&&o.length>i&&!o.warned){o.warned= +"function"?o=s[e]=n?[t,o]:[o,t]:n?o.unshift(t):o.push(t),i=ci(r),i>0&&o.length>i&&!o.warned){o.warned= !0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners\ added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter= -r,u.type=e,u.count=o.length,oa(u)}return r}a(ci,"_addListener");B.prototype.addListener=a(function(e,t){ -return ci(this,e,t,!1)},"addListener");B.prototype.on=B.prototype.addListener;B.prototype.prependListener= -a(function(e,t){return ci(this,e,t,!0)},"prependListener");function aa(){if(!this.fired)return this. +r,u.type=e,u.count=o.length,aa(u)}return r}a(li,"_addListener");L.prototype.addListener=a(function(e,t){ +return li(this,e,t,!1)},"addListener");L.prototype.on=L.prototype.addListener;L.prototype.prependListener= +a(function(e,t){return li(this,e,t,!0)},"prependListener");function ua(){if(!this.fired)return this. target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this. -target):this.listener.apply(this.target,arguments)}a(aa,"onceWrapper");function li(r,e,t){var n={fired:!1, -wrapFn:void 0,target:r,type:e,listener:t},i=aa.bind(n);return i.listener=t,n.wrapFn=i,i}a(li,"_onceW\ -rap");B.prototype.once=a(function(e,t){return dt(t),this.on(e,li(this,e,t)),this},"once");B.prototype. -prependOnceListener=a(function(e,t){return dt(t),this.prependListener(e,li(this,e,t)),this},"prepend\ -OnceListener");B.prototype.removeListener=a(function(e,t){var n,i,s,o,u;if(dt(t),i=this._events,i=== +target):this.listener.apply(this.target,arguments)}a(ua,"onceWrapper");function fi(r,e,t){var n={fired:!1, +wrapFn:void 0,target:r,type:e,listener:t},i=ua.bind(n);return i.listener=t,n.wrapFn=i,i}a(fi,"_onceW\ +rap");L.prototype.once=a(function(e,t){return yt(t),this.on(e,fi(this,e,t)),this},"once");L.prototype. +prependOnceListener=a(function(e,t){return yt(t),this.prependListener(e,fi(this,e,t)),this},"prepend\ +OnceListener");L.prototype.removeListener=a(function(e,t){var n,i,s,o,u;if(yt(t),i=this._events,i=== void 0)return this;if(n=i[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0? this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener|| t));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){u=n[o]. -listener,s=o;break}if(s<0)return this;s===0?n.shift():ua(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!== -void 0&&this.emit("removeListener",e,u||t)}return this},"removeListener");B.prototype.off=B.prototype. -removeListener;B.prototype.removeAllListeners=a(function(e){var t,n,i;if(n=this._events,n===void 0)return this; +listener,s=o;break}if(s<0)return this;s===0?n.shift():ca(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!== +void 0&&this.emit("removeListener",e,u||t)}return this},"removeListener");L.prototype.off=L.prototype. +removeListener;L.prototype.removeAllListeners=a(function(e){var t,n,i;if(n=this._events,n===void 0)return this; if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount= 0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments. length===0){var s=Object.keys(n),o;for(i=0;i= -0;i--)this.removeListener(e,t[i]);return this},"removeAllListeners");function fi(r,e,t){var n=r._events; +0;i--)this.removeListener(e,t[i]);return this},"removeAllListeners");function hi(r,e,t){var n=r._events; if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?t?[i.listener||i]:[i]:t? -ca(i):pi(i,i.length)}a(fi,"_listeners");B.prototype.listeners=a(function(e){return fi(this,e,!0)},"l\ -isteners");B.prototype.rawListeners=a(function(e){return fi(this,e,!1)},"rawListeners");B.listenerCount= -function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):hi.call(r,e)};B.prototype. -listenerCount=hi;function hi(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function") -return 1;if(t!==void 0)return t.length}return 0}a(hi,"listenerCount");B.prototype.eventNames=a(function(){ +la(i):pi(i,i.length)}a(hi,"_listeners");L.prototype.listeners=a(function(e){return hi(this,e,!0)},"l\ +isteners");L.prototype.rawListeners=a(function(e){return hi(this,e,!1)},"rawListeners");L.listenerCount= +function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):di.call(r,e)};L.prototype. +listenerCount=di;function di(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function") +return 1;if(t!==void 0)return t.length}return 0}a(di,"listenerCount");L.prototype.eventNames=a(function(){ return this._eventsCount>0?pt(this._events):[]},"eventNames");function pi(r,e){for(var t=new Array(e), -n=0;nce,isIP:()=>ha});function ha(r){return 0}var mi,yi,S,ce,Fe=G(()=>{"use s\ -trict";p();mi=Se(ge(),1);a(ha,"isIP");yi=/^[^.]+\./,S=class S extends mi.EventEmitter{constructor(){ -super(...arguments);E(this,"opts",{});E(this,"connecting",!1);E(this,"pending",!0);E(this,"writable", -!0);E(this,"encrypted",!1);E(this,"authorized",!1);E(this,"destroyed",!1);E(this,"ws",null);E(this,"\ -writeBuffer");E(this,"tlsState",0);E(this,"tlsRead");E(this,"tlsWrite")}static get poolQueryViaFetch(){ -return S.opts.poolQueryViaFetch??S.defaults.poolQueryViaFetch}static set poolQueryViaFetch(t){S.opts. -poolQueryViaFetch=t}static get fetchEndpoint(){return S.opts.fetchEndpoint??S.defaults.fetchEndpoint}static set fetchEndpoint(t){ -S.opts.fetchEndpoint=t}static get fetchConnectionCache(){return!0}static set fetchConnectionCache(t){ -console.warn("The `fetchConnectionCache` option is deprecated (now always `true`)")}static get fetchFunction(){ -return S.opts.fetchFunction??S.defaults.fetchFunction}static set fetchFunction(t){S.opts.fetchFunction= -t}static get webSocketConstructor(){return S.opts.webSocketConstructor??S.defaults.webSocketConstructor}static set webSocketConstructor(t){ -S.opts.webSocketConstructor=t}get webSocketConstructor(){return this.opts.webSocketConstructor??S.webSocketConstructor}set webSocketConstructor(t){ -this.opts.webSocketConstructor=t}static get wsProxy(){return S.opts.wsProxy??S.defaults.wsProxy}static set wsProxy(t){ -S.opts.wsProxy=t}get wsProxy(){return this.opts.wsProxy??S.wsProxy}set wsProxy(t){this.opts.wsProxy= -t}static get coalesceWrites(){return S.opts.coalesceWrites??S.defaults.coalesceWrites}static set coalesceWrites(t){ -S.opts.coalesceWrites=t}get coalesceWrites(){return this.opts.coalesceWrites??S.coalesceWrites}set coalesceWrites(t){ -this.opts.coalesceWrites=t}static get useSecureWebSocket(){return S.opts.useSecureWebSocket??S.defaults. -useSecureWebSocket}static set useSecureWebSocket(t){S.opts.useSecureWebSocket=t}get useSecureWebSocket(){ -return this.opts.useSecureWebSocket??S.useSecureWebSocket}set useSecureWebSocket(t){this.opts.useSecureWebSocket= -t}static get forceDisablePgSSL(){return S.opts.forceDisablePgSSL??S.defaults.forceDisablePgSSL}static set forceDisablePgSSL(t){ -S.opts.forceDisablePgSSL=t}get forceDisablePgSSL(){return this.opts.forceDisablePgSSL??S.forceDisablePgSSL}set forceDisablePgSSL(t){ -this.opts.forceDisablePgSSL=t}static get disableSNI(){return S.opts.disableSNI??S.defaults.disableSNI}static set disableSNI(t){ -S.opts.disableSNI=t}get disableSNI(){return this.opts.disableSNI??S.disableSNI}set disableSNI(t){this. -opts.disableSNI=t}static get disableWarningInBrowsers(){return S.opts.disableWarningInBrowsers??S.defaults. -disableWarningInBrowsers}static set disableWarningInBrowsers(t){S.opts.disableWarningInBrowsers=t}get disableWarningInBrowsers(){ -return this.opts.disableWarningInBrowsers??S.disableWarningInBrowsers}set disableWarningInBrowsers(t){ -this.opts.disableWarningInBrowsers=t}static get pipelineConnect(){return S.opts.pipelineConnect??S.defaults. -pipelineConnect}static set pipelineConnect(t){S.opts.pipelineConnect=t}get pipelineConnect(){return this. -opts.pipelineConnect??S.pipelineConnect}set pipelineConnect(t){this.opts.pipelineConnect=t}static get subtls(){ -return S.opts.subtls??S.defaults.subtls}static set subtls(t){S.opts.subtls=t}get subtls(){return this. -opts.subtls??S.subtls}set subtls(t){this.opts.subtls=t}static get pipelineTLS(){return S.opts.pipelineTLS?? -S.defaults.pipelineTLS}static set pipelineTLS(t){S.opts.pipelineTLS=t}get pipelineTLS(){return this. -opts.pipelineTLS??S.pipelineTLS}set pipelineTLS(t){this.opts.pipelineTLS=t}static get rootCerts(){return S. -opts.rootCerts??S.defaults.rootCerts}static set rootCerts(t){S.opts.rootCerts=t}get rootCerts(){return this. -opts.rootCerts??S.rootCerts}set rootCerts(t){this.opts.rootCerts=t}wsProxyAddrForHost(t,n){let i=this. -wsProxy;if(i===void 0)throw new Error("No WebSocket proxy is configured. Please see https://github.c\ -om/neondatabase/serverless/blob/main/CONFIG.md#wsproxy-string--host-string-port-number--string--stri\ -ng");return typeof i=="function"?i(t,n):`${i}?address=${t}:${n}`}setNoDelay(){return this}setKeepAlive(){ +ust be of type EventEmitter. Received type '+typeof r)}a(yi,"eventTargetAgnosticAddListener")});var gi={};ie(gi,{Socket:()=>le,isIP:()=>da});function da(r){return 0}var wi,mi,b,le,je=G(()=>{"use s\ +trict";d();wi=xe(we(),1);a(da,"isIP");mi=/^[^.]+\./,b=class b extends wi.EventEmitter{constructor(){ +super(...arguments);A(this,"opts",{});A(this,"connectionCredentials");A(this,"connecting",!1);A(this, +"pending",!0);A(this,"writable",!0);A(this,"encrypted",!1);A(this,"authorized",!1);A(this,"destroyed", +!1);A(this,"ws",null);A(this,"writeBuffer");A(this,"tlsState",0);A(this,"tlsRead");A(this,"tlsWrite")}setConnectionCredentials(t){ +this.connectionCredentials=t}static get poolQueryViaFetch(){return b.opts.poolQueryViaFetch??b.defaults. +poolQueryViaFetch}static set poolQueryViaFetch(t){b.opts.poolQueryViaFetch=t}static get fetchEndpoint(){ +return b.opts.fetchEndpoint??b.defaults.fetchEndpoint}static set fetchEndpoint(t){b.opts.fetchEndpoint= +t}static get fetchConnectionCache(){return!0}static set fetchConnectionCache(t){console.warn("The `f\ +etchConnectionCache` option is deprecated (now always `true`)")}static get fetchFunction(){return b. +opts.fetchFunction??b.defaults.fetchFunction}static set fetchFunction(t){b.opts.fetchFunction=t}static get webSocketConstructor(){ +return b.opts.webSocketConstructor??b.defaults.webSocketConstructor}static set webSocketConstructor(t){ +b.opts.webSocketConstructor=t}get webSocketConstructor(){return this.opts.webSocketConstructor??b.webSocketConstructor}set webSocketConstructor(t){ +this.opts.webSocketConstructor=t}static get wsProxy(){return b.opts.wsProxy??b.defaults.wsProxy}static set wsProxy(t){ +b.opts.wsProxy=t}get wsProxy(){return this.opts.wsProxy??b.wsProxy}set wsProxy(t){this.opts.wsProxy= +t}static get coalesceWrites(){return b.opts.coalesceWrites??b.defaults.coalesceWrites}static set coalesceWrites(t){ +b.opts.coalesceWrites=t}get coalesceWrites(){return this.opts.coalesceWrites??b.coalesceWrites}set coalesceWrites(t){ +this.opts.coalesceWrites=t}static get useSecureWebSocket(){return b.isNeonLocal?!1:b.opts.useSecureWebSocket?? +b.defaults.useSecureWebSocket}static set useSecureWebSocket(t){b.opts.useSecureWebSocket=t}get useSecureWebSocket(){ +return b.isNeonLocal||this.isNeonLocal?!1:this.opts.useSecureWebSocket??b.useSecureWebSocket}set useSecureWebSocket(t){ +this.opts.useSecureWebSocket=t}static get forceDisablePgSSL(){return b.opts.forceDisablePgSSL??b.defaults. +forceDisablePgSSL}static set forceDisablePgSSL(t){b.opts.forceDisablePgSSL=t}get forceDisablePgSSL(){ +return this.opts.forceDisablePgSSL??b.forceDisablePgSSL}set forceDisablePgSSL(t){this.opts.forceDisablePgSSL= +t}static get disableSNI(){return b.opts.disableSNI??b.defaults.disableSNI}static set disableSNI(t){b. +opts.disableSNI=t}get disableSNI(){return this.opts.disableSNI??b.disableSNI}set disableSNI(t){this. +opts.disableSNI=t}static get disableWarningInBrowsers(){return b.opts.disableWarningInBrowsers??b.defaults. +disableWarningInBrowsers}static set disableWarningInBrowsers(t){b.opts.disableWarningInBrowsers=t}get disableWarningInBrowsers(){ +return this.opts.disableWarningInBrowsers??b.disableWarningInBrowsers}set disableWarningInBrowsers(t){ +this.opts.disableWarningInBrowsers=t}static get pipelineConnect(){return b.opts.pipelineConnect??b.defaults. +pipelineConnect}static set pipelineConnect(t){b.opts.pipelineConnect=t}get pipelineConnect(){return this. +opts.pipelineConnect??b.pipelineConnect}set pipelineConnect(t){this.opts.pipelineConnect=t}static get subtls(){ +return b.opts.subtls??b.defaults.subtls}static set subtls(t){b.opts.subtls=t}get subtls(){return this. +opts.subtls??b.subtls}set subtls(t){this.opts.subtls=t}static get pipelineTLS(){return b.opts.pipelineTLS?? +b.defaults.pipelineTLS}static set pipelineTLS(t){b.opts.pipelineTLS=t}get pipelineTLS(){return this. +opts.pipelineTLS??b.pipelineTLS}set pipelineTLS(t){this.opts.pipelineTLS=t}static get rootCerts(){return b. +opts.rootCerts??b.defaults.rootCerts}static set rootCerts(t){b.opts.rootCerts=t}get rootCerts(){return this. +opts.rootCerts??b.rootCerts}set rootCerts(t){this.opts.rootCerts=t}static get isNeonLocal(){return b. +opts.isNeonLocal??b.defaults.isNeonLocal}static set isNeonLocal(t){b.opts.isNeonLocal=t}get isNeonLocal(){ +return this.opts.isNeonLocal??b.isNeonLocal}set isNeonLocal(t){this.opts.isNeonLocal=t}wsProxyAddrForHost(t,n){ +let i=this.wsProxy;if(i===void 0)throw new Error("No WebSocket proxy is configured. Please see https\ +://github.com/neondatabase/serverless/blob/main/CONFIG.md#wsproxy-string--host-string-port-number--s\ +tring--string");return typeof i=="function"?i(t,n):`${i}?address=${t}:${n}`}setNoDelay(){return this}setKeepAlive(){ return this}ref(){return this}unref(){return this}connect(t,n,i){this.connecting=!0,i&&this.once("co\ nnect",i);let s=a(()=>{this.connecting=!1,this.pending=!1,this.emit("connect"),this.emit("ready")},"\ -handleWebSocketOpen"),o=a((c,l=!1)=>{c.binaryType="arraybuffer",c.addEventListener("error",f=>{this. -emit("error",f),this.emit("close")}),c.addEventListener("message",f=>{if(this.tlsState===0){let y=d. -from(f.data);this.emit("data",y)}}),c.addEventListener("close",()=>{this.emit("close")}),l?s():c.addEventListener( -"open",s)},"configureWebSocket"),u;try{u=this.wsProxyAddrForHost(n,typeof t=="string"?parseInt(t,10): -t)}catch(c){this.emit("error",c),this.emit("close");return}try{let l=(this.useSecureWebSocket?"wss:": -"ws:")+"//"+u;if(this.webSocketConstructor!==void 0)this.ws=new this.webSocketConstructor(l),o(this. -ws);else try{this.ws=new WebSocket(l),o(this.ws)}catch{this.ws=new __unstable_WebSocket(l),o(this.ws)}}catch(c){ -let f=(this.useSecureWebSocket?"https:":"http:")+"//"+u;fetch(f,{headers:{Upgrade:"websocket"}}).then( -y=>{if(this.ws=y.webSocket,this.ws==null)throw c;this.ws.accept(),o(this.ws,!0)}).catch(y=>{this.emit( -"error",new Error(`All attempts to open a WebSocket to connect to the database failed. Please refer \ -to https://github.com/neondatabase/serverless/blob/main/CONFIG.md#websocketconstructor-typeof-websoc\ -ket--undefined. Details: ${y}`)),this.emit("close")})}}async startTls(t){if(this.subtls===void 0)throw new Error( -"For Postgres SSL connections, you must set `neonConfig.subtls` to the subtls library. See https://g\ -ithub.com/neondatabase/serverless/blob/main/CONFIG.md for more information.");this.tlsState=1;let n=await this. -subtls.TrustedCert.databaseFromPEM(this.rootCerts),i=new this.subtls.WebSocketReadQueue(this.ws),s=i. -read.bind(i),o=this.rawWrite.bind(this),{read:u,write:c}=await this.subtls.startTls(t,n,s,o,{useSNI:!this. -disableSNI,expectPreData:this.pipelineTLS?new Uint8Array([83]):void 0});this.tlsRead=u,this.tlsWrite= -c,this.tlsState=2,this.encrypted=!0,this.authorized=!0,this.emit("secureConnection",this),this.tlsReadLoop()}async tlsReadLoop(){ -for(;;){let t=await this.tlsRead();if(t===void 0)break;{let n=d.from(t);this.emit("data",n)}}}rawWrite(t){ +handleWebSocketOpen"),o=a((u,c=!1)=>{u.binaryType="arraybuffer",u.addEventListener("error",l=>{this. +emit("error",l),this.emit("close")}),u.addEventListener("message",l=>{if(this.tlsState===0){let f=y. +from(l.data);this.emit("data",f)}}),u.addEventListener("close",()=>{this.emit("close")}),c?s():u.addEventListener( +"open",s)},"configureWebSocket");try{if(b.isNeonLocal){let c="ws:",l=t&&t!=="443"&&t!=="80"?`:${t}`: +"",f=`${c}//${n}${l}/sql`,p={headers:{Upgrade:"websocket",Connection:"Upgrade"}};if(this.connectionCredentials){ +let E=this.connectionCredentials;E.user&&(p.headers["X-Neon-User"]=E.user),E.password&&(p.headers["X\ +-Neon-Password"]=E.password),E.database&&(p.headers["X-Neon-Database"]=E.database)}let g=this.webSocketConstructor|| +(typeof WebSocket<"u"?WebSocket:void 0);if(!g)throw new Error("No WebSocket implementation available\ +. Please provide a webSocketConstructor.");this.ws=new g(f,p),this.ws&&o(this.ws);return}let u;try{u= +this.wsProxyAddrForHost(n,typeof t=="string"?parseInt(t,10):t)}catch(c){this.emit("error",c),this.emit( +"close");return}try{let l=(this.useSecureWebSocket?"wss:":"ws:")+"//"+u;if(this.webSocketConstructor!== +void 0)this.ws=new this.webSocketConstructor(l),o(this.ws);else try{this.ws=new WebSocket(l),o(this. +ws)}catch{this.ws=new __unstable_WebSocket(l),o(this.ws)}}catch(c){let f=(this.useSecureWebSocket?"h\ +ttps:":"http:")+"//"+u;fetch(f,{headers:{Upgrade:"websocket"}}).then(p=>{if(this.ws=p.webSocket,this. +ws==null)throw c;this.ws.accept(),o(this.ws,!0)}).catch(p=>{this.emit("error",new Error(`All attempt\ +s to open a WebSocket to connect to the database failed. Please refer to https://github.com/neondata\ +base/serverless/blob/main/CONFIG.md#websocketconstructor-typeof-websocket--undefined. Details: ${p}`)), +this.emit("close")})}}catch(u){this.emit("error",new Error(`Failed to establish WebSocket connection\ +. ${u}`)),this.emit("close")}}async startTls(t){if(this.subtls===void 0)throw new Error("For Postgre\ +s SSL connections, you must set `neonConfig.subtls` to the subtls library. See https://github.com/ne\ +ondatabase/serverless/blob/main/CONFIG.md for more information.");this.tlsState=1;let n=await this.subtls. +TrustedCert.databaseFromPEM(this.rootCerts),i=new this.subtls.WebSocketReadQueue(this.ws),s=i.read.bind( +i),o=this.rawWrite.bind(this),{read:u,write:c}=await this.subtls.startTls(t,n,s,o,{useSNI:!this.disableSNI, +expectPreData:this.pipelineTLS?new Uint8Array([83]):void 0});this.tlsRead=u,this.tlsWrite=c,this.tlsState= +2,this.encrypted=!0,this.authorized=!0,this.emit("secureConnection",this),this.tlsReadLoop()}async tlsReadLoop(){ +for(;;){let t=await this.tlsRead();if(t===void 0)break;{let n=y.from(t);this.emit("data",n)}}}rawWrite(t){ if(!this.coalesceWrites){this.ws&&this.ws.send(t);return}if(this.writeBuffer===void 0)this.writeBuffer= t,setTimeout(()=>{this.ws&&this.ws.send(this.writeBuffer),this.writeBuffer=void 0},0);else{let n=new Uint8Array( this.writeBuffer.length+t.length);n.set(this.writeBuffer),n.set(t,this.writeBuffer.length),this.writeBuffer= -n}}write(t,n="utf8",i=s=>{}){return t.length===0?(i(),!0):(typeof t=="string"&&(t=d.from(t,n)),this. +n}}write(t,n="utf8",i=s=>{}){return t.length===0?(i(),!0):(typeof t=="string"&&(t=y.from(t,n)),this. tlsState===0?(this.rawWrite(t),i()):this.tlsState===1?this.once("secureConnection",()=>{this.write(t, -n,i)}):(this.tlsWrite(t),i()),!0)}end(t=d.alloc(0),n="utf8",i=()=>{}){return this.write(t,n,()=>{this. -ws.close(),i()}),this}destroy(){return this.destroyed=!0,this.end()}};a(S,"Socket"),E(S,"defaults",{ -poolQueryViaFetch:!1,fetchEndpoint:a((t,n,i)=>{let s;return i?.jwtAuth?s=t.replace(yi,"apiauth."):s= -t.replace(yi,"api."),"https://"+s+"/sql"},"fetchEndpoint"),fetchConnectionCache:!0,fetchFunction:void 0, -webSocketConstructor:void 0,wsProxy:a(t=>t+"/v2","wsProxy"),useSecureWebSocket:!0,forceDisablePgSSL:!0, -coalesceWrites:!0,pipelineConnect:"password",subtls:void 0,rootCerts:"",pipelineTLS:!1,disableSNI:!1, -disableWarningInBrowsers:!1}),E(S,"opts",{});ce=S});var gi={};ie(gi,{parse:()=>Yt});function Yt(r,e=!1){let{protocol:t}=new URL(r),n="http:"+r.substring( -t.length),{username:i,password:s,host:o,hostname:u,port:c,pathname:l,search:f,searchParams:y,hash:g}=new URL( -n);s=decodeURIComponent(s),i=decodeURIComponent(i),l=decodeURIComponent(l);let A=i+":"+s,C=e?Object. -fromEntries(y.entries()):f;return{href:r,protocol:t,auth:A,username:i,password:s,host:o,hostname:u,port:c, -pathname:l,search:f,query:C,hash:g}}var Zt=G(()=>{"use strict";p();a(Yt,"parse")});var tr=T(Ai=>{"use strict";p();Ai.parse=function(r,e){return new er(r,e).parse()};var vt=class vt{constructor(e,t){ -this.source=e,this.transform=t||Ca,this.position=0,this.entries=[],this.recorded=[],this.dimension=0}isEof(){ +n,i)}):(this.tlsWrite(t),i()),!0)}end(t=y.alloc(0),n="utf8",i=()=>{}){return this.write(t,n,()=>{this. +ws.close(),i()}),this}destroy(){return this.destroyed=!0,this.end()}};a(b,"Socket"),A(b,"defaults",{ +poolQueryViaFetch:!1,fetchEndpoint:a((t,n,i)=>{if(b.isNeonLocal){let o="http",u=n&&n!=="443"&&n!=="8\ +0"?`:${n}`:"";return`${o}://${t}${u}/sql`}let s;return i?.jwtAuth?s=t.replace(mi,"apiauth."):s=t.replace( +mi,"api."),"https://"+s+"/sql"},"fetchEndpoint"),fetchConnectionCache:!0,fetchFunction:void 0,webSocketConstructor:void 0, +wsProxy:a(t=>t+"/v2","wsProxy"),useSecureWebSocket:!0,forceDisablePgSSL:!0,coalesceWrites:!0,pipelineConnect:"\ +password",subtls:void 0,rootCerts:"",pipelineTLS:!1,disableSNI:!1,disableWarningInBrowsers:!1,isNeonLocal:!1}), +A(b,"opts",{});le=b});var bi={};ie(bi,{parse:()=>Xt});function Xt(r,e=!1){let{protocol:t}=new URL(r),n="http:"+r.substring( +t.length),{username:i,password:s,host:o,hostname:u,port:c,pathname:l,search:f,searchParams:p,hash:g}=new URL( +n);s=decodeURIComponent(s),i=decodeURIComponent(i),l=decodeURIComponent(l);let E=i+":"+s,C=e?Object. +fromEntries(p.entries()):f;return{href:r,protocol:t,auth:E,username:i,password:s,host:o,hostname:u,port:c, +pathname:l,search:f,query:C,hash:g}}var Zt=G(()=>{"use strict";d();a(Xt,"parse")});var rr=T(Ci=>{"use strict";d();Ci.parse=function(r,e){return new tr(r,e).parse()};var St=class St{constructor(e,t){ +this.source=e,this.transform=t||_a,this.position=0,this.entries=[],this.recorded=[],this.dimension=0}isEof(){ return this.position>=this.source.length}nextCharacter(){var e=this.source[this.position++];return e=== "\\"?{value:this.source[this.position++],escaped:!0}:{value:e,escaped:!1}}record(e){this.recorded.push( e)}newEntry(e){var t;(this.recorded.length>0||e)&&(t=this.recorded.join(""),t==="NULL"&&!e&&(t=null), t!==null&&(t=this.transform(t)),this.entries.push(t),this.recorded=[])}consumeDimensions(){if(this.source[0]=== "[")for(;!this.isEof();){var e=this.nextCharacter();if(e.value==="=")break}}parse(e){var t,n,i;for(this. consumeDimensions();!this.isEof();)if(t=this.nextCharacter(),t.value==="{"&&!i)this.dimension++,this. -dimension>1&&(n=new vt(this.source.substr(this.position-1),this.transform),this.entries.push(n.parse( +dimension>1&&(n=new St(this.source.substr(this.position-1),this.transform),this.entries.push(n.parse( !0)),this.position+=n.position-2);else if(t.value==="}"&&!i){if(this.dimension--,!this.dimension&&(this. newEntry(),e))return this.entries}else t.value==='"'&&!t.escaped?(i&&this.newEntry(!0),i=!i):t.value=== ","&&!i?this.newEntry():this.record(t.value);if(this.dimension!==0)throw new Error("array dimension \ -not balanced");return this.entries}};a(vt,"ArrayParser");var er=vt;function Ca(r){return r}a(Ca,"ide\ -ntity")});var rr=T((Zl,Ci)=>{p();var _a=tr();Ci.exports={create:a(function(r,e){return{parse:a(function(){return _a. -parse(r,e)},"parse")}},"create")}});var Ti=T((ef,Ii)=>{"use strict";p();var Ia=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/, -Ta=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,Pa=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,Ba=/^-?infinity$/;Ii. -exports=a(function(e){if(Ba.test(e))return Number(e.replace("i","I"));var t=Ia.exec(e);if(!t)return Ra( -e)||null;var n=!!t[8],i=parseInt(t[1],10);n&&(i=_i(i));var s=parseInt(t[2],10)-1,o=t[3],u=parseInt(t[4], -10),c=parseInt(t[5],10),l=parseInt(t[6],10),f=t[7];f=f?1e3*parseFloat(f):0;var y,g=La(e);return g!=null? -(y=new Date(Date.UTC(i,s,o,u,c,l,f)),nr(i)&&y.setUTCFullYear(i),g!==0&&y.setTime(y.getTime()-g)):(y= -new Date(i,s,o,u,c,l,f),nr(i)&&y.setFullYear(i)),y},"parseDate");function Ra(r){var e=Ta.exec(r);if(e){ -var t=parseInt(e[1],10),n=!!e[4];n&&(t=_i(t));var i=parseInt(e[2],10)-1,s=e[3],o=new Date(t,i,s);return nr( -t)&&o.setFullYear(t),o}}a(Ra,"getDate");function La(r){if(r.endsWith("+00"))return 0;var e=Pa.exec(r. +not balanced");return this.entries}};a(St,"ArrayParser");var tr=St;function _a(r){return r}a(_a,"ide\ +ntity")});var nr=T((Zl,_i)=>{d();var Ia=rr();_i.exports={create:a(function(r,e){return{parse:a(function(){return Ia. +parse(r,e)},"parse")}},"create")}});var Pi=T((tf,Ti)=>{"use strict";d();var Ta=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/, +Pa=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,La=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,Ba=/^-?infinity$/;Ti. +exports=a(function(e){if(Ba.test(e))return Number(e.replace("i","I"));var t=Ta.exec(e);if(!t)return Ra( +e)||null;var n=!!t[8],i=parseInt(t[1],10);n&&(i=Ii(i));var s=parseInt(t[2],10)-1,o=t[3],u=parseInt(t[4], +10),c=parseInt(t[5],10),l=parseInt(t[6],10),f=t[7];f=f?1e3*parseFloat(f):0;var p,g=ka(e);return g!=null? +(p=new Date(Date.UTC(i,s,o,u,c,l,f)),ir(i)&&p.setUTCFullYear(i),g!==0&&p.setTime(p.getTime()-g)):(p= +new Date(i,s,o,u,c,l,f),ir(i)&&p.setFullYear(i)),p},"parseDate");function Ra(r){var e=Pa.exec(r);if(e){ +var t=parseInt(e[1],10),n=!!e[4];n&&(t=Ii(t));var i=parseInt(e[2],10)-1,s=e[3],o=new Date(t,i,s);return ir( +t)&&o.setFullYear(t),o}}a(Ra,"getDate");function ka(r){if(r.endsWith("+00"))return 0;var e=La.exec(r. split(" ")[1]);if(e){var t=e[1];if(t==="Z")return 0;var n=t==="-"?-1:1,i=parseInt(e[2],10)*3600+parseInt( -e[3]||0,10)*60+parseInt(e[4]||0,10);return i*n*1e3}}a(La,"timeZoneOffset");function _i(r){return-(r- -1)}a(_i,"bcYearToNegativeYear");function nr(r){return r>=0&&r<100}a(nr,"is0To99")});var Bi=T((nf,Pi)=>{p();Pi.exports=ka;var Fa=Object.prototype.hasOwnProperty;function ka(r){for(var e=1;e< -arguments.length;e++){var t=arguments[e];for(var n in t)Fa.call(t,n)&&(r[n]=t[n])}return r}a(ka,"ext\ -end")});var Fi=T((af,Li)=>{"use strict";p();var Ma=Bi();Li.exports=ke;function ke(r){if(!(this instanceof ke)) -return new ke(r);Ma(this,Va(r))}a(ke,"PostgresInterval");var Ua=["seconds","minutes","hours","days", -"months","years"];ke.prototype.toPostgres=function(){var r=Ua.filter(this.hasOwnProperty,this);return this. +e[3]||0,10)*60+parseInt(e[4]||0,10);return i*n*1e3}}a(ka,"timeZoneOffset");function Ii(r){return-(r- +1)}a(Ii,"bcYearToNegativeYear");function ir(r){return r>=0&&r<100}a(ir,"is0To99")});var Bi=T((sf,Li)=>{d();Li.exports=Ma;var Fa=Object.prototype.hasOwnProperty;function Ma(r){for(var e=1;e< +arguments.length;e++){var t=arguments[e];for(var n in t)Fa.call(t,n)&&(r[n]=t[n])}return r}a(Ma,"ext\ +end")});var Fi=T((uf,ki)=>{"use strict";d();var Ua=Bi();ki.exports=ke;function ke(r){if(!(this instanceof ke)) +return new ke(r);Ua(this,za(r))}a(ke,"PostgresInterval");var Da=["seconds","minutes","hours","days", +"months","years"];ke.prototype.toPostgres=function(){var r=Da.filter(this.hasOwnProperty,this);return this. milliseconds&&r.indexOf("seconds")<0&&r.push("seconds"),r.length===0?"0":r.map(function(e){var t=this[e]|| 0;return e==="seconds"&&this.milliseconds&&(t=(t+this.milliseconds/1e3).toFixed(6).replace(/\.?0+$/, -"")),t+" "+e},this).join(" ")};var Da={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"\ -S"},Oa=["years","months","days"],qa=["hours","minutes","seconds"];ke.prototype.toISOString=ke.prototype. -toISO=function(){var r=Oa.map(t,this).join(""),e=qa.map(t,this).join("");return"P"+r+"T"+e;function t(n){ +"")),t+" "+e},this).join(" ")};var Oa={years:"Y",months:"M",days:"D",hours:"H",minutes:"M",seconds:"\ +S"},Na=["years","months","days"],qa=["hours","minutes","seconds"];ke.prototype.toISOString=ke.prototype. +toISO=function(){var r=Na.map(t,this).join(""),e=qa.map(t,this).join("");return"P"+r+"T"+e;function t(n){ var i=this[n]||0;return n==="seconds"&&this.milliseconds&&(i=(i+this.milliseconds/1e3).toFixed(6).replace( -/0+$/,"")),i+Da[n]}};var ir="([+-]?\\d+)",Qa=ir+"\\s+years?",Na=ir+"\\s+mons?",Wa=ir+"\\s+days?",ja="\ -([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",Ha=new RegExp([Qa,Na,Wa,ja].map(function(r){return"\ +/0+$/,"")),i+Oa[n]}};var sr="([+-]?\\d+)",Qa=sr+"\\s+years?",Wa=sr+"\\s+mons?",ja=sr+"\\s+days?",Ha="\ +([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?",$a=new RegExp([Qa,Wa,ja,Ha].map(function(r){return"\ ("+r+")?"}).join("\\s*")),Ri={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12}, -$a=["hours","minutes","seconds","milliseconds"];function Ga(r){var e=r+"000000".slice(r.length);return parseInt( -e,10)/1e3}a(Ga,"parseMilliseconds");function Va(r){if(!r)return{};var e=Ha.exec(r),t=e[8]==="-";return Object. -keys(Ri).reduce(function(n,i){var s=Ri[i],o=e[s];return!o||(o=i==="milliseconds"?Ga(o):parseInt(o,10), -!o)||(t&&~$a.indexOf(i)&&(o*=-1),n[i]=o),n},{})}a(Va,"parse")});var Mi=T((lf,ki)=>{"use strict";p();ki.exports=a(function(e){if(/^\\x/.test(e))return new d(e.substr( +Ga=["hours","minutes","seconds","milliseconds"];function Va(r){var e=r+"000000".slice(r.length);return parseInt( +e,10)/1e3}a(Va,"parseMilliseconds");function za(r){if(!r)return{};var e=$a.exec(r),t=e[8]==="-";return Object. +keys(Ri).reduce(function(n,i){var s=Ri[i],o=e[s];return!o||(o=i==="milliseconds"?Va(o):parseInt(o,10), +!o)||(t&&~Ga.indexOf(i)&&(o*=-1),n[i]=o),n},{})}a(za,"parse")});var Ui=T((ff,Mi)=>{"use strict";d();Mi.exports=a(function(e){if(/^\\x/.test(e))return new y(e.substr( 2),"hex");for(var t="",n=0;n{p();var Ve=tr(),ze=rr(),xt=Ti(),Di=Fi(),Oi=Mi();function St(r){return a(function(t){ -return t===null?t:r(t)},"nullAllowed")}a(St,"allowNull");function qi(r){return r===null?r:r==="TRUE"|| -r==="t"||r==="true"||r==="y"||r==="yes"||r==="on"||r==="1"}a(qi,"parseBool");function za(r){return r? -Ve.parse(r,qi):null}a(za,"parseBoolArray");function Ka(r){return parseInt(r,10)}a(Ka,"parseBaseTenIn\ -t");function sr(r){return r?Ve.parse(r,St(Ka)):null}a(sr,"parseIntegerArray");function Ya(r){return r? -Ve.parse(r,St(function(e){return Qi(e).trim()})):null}a(Ya,"parseBigIntegerArray");var Za=a(function(r){ -if(!r)return null;var e=ze.create(r,function(t){return t!==null&&(t=cr(t)),t});return e.parse()},"pa\ -rsePointArray"),or=a(function(r){if(!r)return null;var e=ze.create(r,function(t){return t!==null&&(t= +"\\";)i++;for(var s=0;s{d();var Ve=rr(),ze=nr(),xt=Pi(),Oi=Fi(),Ni=Ui();function Et(r){return a(function(t){ +return t===null?t:r(t)},"nullAllowed")}a(Et,"allowNull");function qi(r){return r===null?r:r==="TRUE"|| +r==="t"||r==="true"||r==="y"||r==="yes"||r==="on"||r==="1"}a(qi,"parseBool");function Ka(r){return r? +Ve.parse(r,qi):null}a(Ka,"parseBoolArray");function Ya(r){return parseInt(r,10)}a(Ya,"parseBaseTenIn\ +t");function or(r){return r?Ve.parse(r,Et(Ya)):null}a(or,"parseIntegerArray");function Xa(r){return r? +Ve.parse(r,Et(function(e){return Qi(e).trim()})):null}a(Xa,"parseBigIntegerArray");var Za=a(function(r){ +if(!r)return null;var e=ze.create(r,function(t){return t!==null&&(t=lr(t)),t});return e.parse()},"pa\ +rsePointArray"),ar=a(function(r){if(!r)return null;var e=ze.create(r,function(t){return t!==null&&(t= parseFloat(t)),t});return e.parse()},"parseFloatArray"),re=a(function(r){if(!r)return null;var e=ze. -create(r);return e.parse()},"parseStringArray"),ar=a(function(r){if(!r)return null;var e=ze.create(r, +create(r);return e.parse()},"parseStringArray"),ur=a(function(r){if(!r)return null;var e=ze.create(r, function(t){return t!==null&&(t=xt(t)),t});return e.parse()},"parseDateArray"),Ja=a(function(r){if(!r) -return null;var e=ze.create(r,function(t){return t!==null&&(t=Di(t)),t});return e.parse()},"parseInt\ -ervalArray"),Xa=a(function(r){return r?Ve.parse(r,St(Oi)):null},"parseByteAArray"),ur=a(function(r){ +return null;var e=ze.create(r,function(t){return t!==null&&(t=Oi(t)),t});return e.parse()},"parseInt\ +ervalArray"),eu=a(function(r){return r?Ve.parse(r,Et(Ni)):null},"parseByteAArray"),cr=a(function(r){ return parseInt(r,10)},"parseInteger"),Qi=a(function(r){var e=String(r);return/^\d+$/.test(e)?e:r},"\ -parseBigInteger"),Ui=a(function(r){return r?Ve.parse(r,St(JSON.parse)):null},"parseJsonArray"),cr=a( +parseBigInteger"),Di=a(function(r){return r?Ve.parse(r,Et(JSON.parse)):null},"parseJsonArray"),lr=a( function(r){return r[0]!=="("?null:(r=r.substring(1,r.length-1).split(","),{x:parseFloat(r[0]),y:parseFloat( -r[1])})},"parsePoint"),eu=a(function(r){if(r[0]!=="<"&&r[1]!=="(")return null;for(var e="(",t="",n=!1, +r[1])})},"parsePoint"),tu=a(function(r){if(r[0]!=="<"&&r[1]!=="(")return null;for(var e="(",t="",n=!1, i=2;i{"use strict";p();var z=1e6;function ru(r){var e=r.readInt32BE(0),t=r.readUInt32BE( +r[i])}var s=lr(e);return s.radius=parseFloat(t),s},"parseCircle"),ru=a(function(r){r(20,Qi),r(21,cr), +r(23,cr),r(26,cr),r(700,parseFloat),r(701,parseFloat),r(16,qi),r(1082,xt),r(1114,xt),r(1184,xt),r(600, +lr),r(651,re),r(718,tu),r(1e3,Ka),r(1001,eu),r(1005,or),r(1007,or),r(1028,or),r(1016,Xa),r(1017,Za), +r(1021,ar),r(1022,ar),r(1231,ar),r(1014,re),r(1015,re),r(1008,re),r(1009,re),r(1040,re),r(1041,re),r( +1115,ur),r(1182,ur),r(1185,ur),r(1186,Oi),r(1187,Ja),r(17,Ni),r(114,JSON.parse.bind(JSON)),r(3802,JSON. +parse.bind(JSON)),r(199,Di),r(3807,Di),r(3907,re),r(2951,re),r(791,re),r(1183,re),r(1270,re)},"init"); +Wi.exports={init:ru}});var $i=T((wf,Hi)=>{"use strict";d();var z=1e6;function nu(r){var e=r.readInt32BE(0),t=r.readUInt32BE( 4),n="";e<0&&(e=~e+(t===0),t=~t+1>>>0,n="-");var i="",s,o,u,c,l,f;{if(s=e%z,e=e/z>>>0,o=4294967296*s+ t,t=o/z>>>0,u=""+(o-z*t),t===0&&e===0)return n+u+i;for(c="",l=6-u.length,f=0;f>>0,o=4294967296*s+t,t=o/z>>>0,u=""+(o-z*t),t===0&&e===0)return n+u+i;for(c="",l=6-u. length,f=0;f>>0,o=4294967296*s+t,t=o/z>>>0,u=""+(o-z*t),t===0&& e===0)return n+u+i;for(c="",l=6-u.length,f=0;f{p();var nu=Hi(),L=a(function(r,e,t,n,i){t=t||0,n=n||!1,i=i||function(A,C,D){return A* -Math.pow(2,D)+C};var s=t>>3,o=a(function(A){return n?~A&255:A},"inv"),u=255,c=8-t%8;e>t%8);var l=0;t%8+e>=8&&(l=i(0,o(r[s])&u,c));for(var f=e+t>>3,y=s+1;y0&&(l=i(l,o(r[f])>>8-g,g)),l},"parseBits"),Vi=a(function(r,e,t){var n=Math. -pow(2,t-1)-1,i=L(r,1),s=L(r,t,1);if(s===0)return 0;var o=1,u=a(function(l,f,y){l===0&&(l=1);for(var g=1;g<= -y;g++)o/=2,(f&1<0&&(l+=o);return l},"parsePrecisionBits"),c=L(r,e,t+1,!1,u);return s==Math.pow( -2,t+1)-1?c===0?i===0?1/0:-1/0:NaN:(i===0?1:-1)*Math.pow(2,s-n)*c},"parseFloatFromBits"),iu=a(function(r){ -return L(r,1)==1?-1*(L(r,15,1,!0)+1):L(r,15,1)},"parseInt16"),$i=a(function(r){return L(r,1)==1?-1*(L( -r,31,1,!0)+1):L(r,31,1)},"parseInt32"),su=a(function(r){return Vi(r,23,8)},"parseFloat32"),ou=a(function(r){ -return Vi(r,52,11)},"parseFloat64"),au=a(function(r){var e=L(r,16,32);if(e==49152)return NaN;for(var t=Math. -pow(1e4,L(r,16,16)),n=0,i=[],s=L(r,16),o=0;o{d();var iu=$i(),R=a(function(r,e,t,n,i){t=t||0,n=n||!1,i=i||function(E,C,D){return E* +Math.pow(2,D)+C};var s=t>>3,o=a(function(E){return n?~E&255:E},"inv"),u=255,c=8-t%8;e>t%8);var l=0;t%8+e>=8&&(l=i(0,o(r[s])&u,c));for(var f=e+t>>3,p=s+1;p0&&(l=i(l,o(r[f])>>8-g,g)),l},"parseBits"),zi=a(function(r,e,t){var n=Math. +pow(2,t-1)-1,i=R(r,1),s=R(r,t,1);if(s===0)return 0;var o=1,u=a(function(l,f,p){l===0&&(l=1);for(var g=1;g<= +p;g++)o/=2,(f&1<0&&(l+=o);return l},"parsePrecisionBits"),c=R(r,e,t+1,!1,u);return s==Math.pow( +2,t+1)-1?c===0?i===0?1/0:-1/0:NaN:(i===0?1:-1)*Math.pow(2,s-n)*c},"parseFloatFromBits"),su=a(function(r){ +return R(r,1)==1?-1*(R(r,15,1,!0)+1):R(r,15,1)},"parseInt16"),Gi=a(function(r){return R(r,1)==1?-1*(R( +r,31,1,!0)+1):R(r,31,1)},"parseInt32"),ou=a(function(r){return zi(r,23,8)},"parseFloat32"),au=a(function(r){ +return zi(r,52,11)},"parseFloat64"),uu=a(function(r){var e=R(r,16,32);if(e==49152)return NaN;for(var t=Math. +pow(1e4,R(r,16,16)),n=0,i=[],s=R(r,16),o=0;o>3,(i+=f<<3)>>3),y;console.log("ERROR: ElementType no\ -t implemented: "+l)},"parseElement"),c=a(function(l,f){var y=[],g;if(l.length>1){var A=l.shift();for(g= -0;g0},"parseBool"),lu=a(function(r){r(20,nu),r(21,iu),r(23,$i),r(26,$i),r(1700,au),r(700,su), -r(701,ou),r(16,cu),r(1114,Gi.bind(null,!1)),r(1184,Gi.bind(null,!0)),r(1e3,Ke),r(1007,Ke),r(1016,Ke), -r(1008,Ke),r(1009,Ke),r(25,uu)},"init");zi.exports={init:lu}});var Zi=T((Sf,Yi)=>{p();Yi.exports={BOOL:16,BYTEA:17,CHAR:18,INT8:20,INT2:21,INT4:23,REGPROC:24,TEXT:25, +usec=s},i.getUTCMicroSeconds=function(){return this.usec},i},"parseDate"),Ke=a(function(r){for(var e=R( +r,32),t=R(r,32,32),n=R(r,32,64),i=96,s=[],o=0;o>3,(i+=f<<3)>>3),p;console.log("ERROR: ElementType no\ +t implemented: "+l)},"parseElement"),c=a(function(l,f){var p=[],g;if(l.length>1){var E=l.shift();for(g= +0;g0},"parseBool"),fu=a(function(r){r(20,iu),r(21,su),r(23,Gi),r(26,Gi),r(1700,uu),r(700,ou), +r(701,au),r(16,lu),r(1114,Vi.bind(null,!1)),r(1184,Vi.bind(null,!0)),r(1e3,Ke),r(1007,Ke),r(1016,Ke), +r(1008,Ke),r(1009,Ke),r(25,cu)},"init");Ki.exports={init:fu}});var Zi=T((Ef,Xi)=>{d();Xi.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 Je=T(Ze=>{p();var fu=Wi(),hu=Ki(),pu=rr(),du=Zi();Ze.getTypeParser=yu;Ze.setTypeParser=mu;Ze.arrayParser= -pu;Ze.builtins=du;var Ye={text:{},binary:{}};function Ji(r){return String(r)}a(Ji,"noParse");function yu(r,e){ -return e=e||"text",Ye[e]&&Ye[e][r]||Ji}a(yu,"getTypeParser");function mu(r,e,t){typeof e=="function"&& -(t=e,e="text"),Ye[e][r]=t}a(mu,"setTypeParser");fu.init(function(r,e){Ye.text[r]=e});hu.init(function(r,e){ -Ye.binary[r]=e})});var At=T((If,Xi)=>{"use strict";p();var wu=Je();function Et(r){this._types=r||wu,this.text={},this.binary= -{}}a(Et,"TypeOverrides");Et.prototype.getOverrides=function(r){switch(r){case"text":return this.text;case"\ -binary":return this.binary;default:return{}}};Et.prototype.setTypeParser=function(r,e,t){typeof e=="\ -function"&&(t=e,e="text"),this.getOverrides(e)[r]=t};Et.prototype.getTypeParser=function(r,e){return e= -e||"text",this.getOverrides(e)[r]||this._types.getTypeParser(r,e)};Xi.exports=Et});function Xe(r){let e=1779033703,t=3144134277,n=1013904242,i=2773480762,s=1359893119,o=2600822924,u=528734635, -c=1541459225,l=0,f=0,y=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748, +REGROLE:4096}});var Ze=T(Xe=>{d();var hu=ji(),du=Yi(),pu=nr(),yu=Zi();Xe.getTypeParser=mu;Xe.setTypeParser=wu;Xe.arrayParser= +pu;Xe.builtins=yu;var Ye={text:{},binary:{}};function Ji(r){return String(r)}a(Ji,"noParse");function mu(r,e){ +return e=e||"text",Ye[e]&&Ye[e][r]||Ji}a(mu,"getTypeParser");function wu(r,e,t){typeof e=="function"&& +(t=e,e="text"),Ye[e][r]=t}a(wu,"setTypeParser");hu.init(function(r,e){Ye.text[r]=e});du.init(function(r,e){ +Ye.binary[r]=e})});var Ct=T((Tf,es)=>{"use strict";d();var gu=Ze();function At(r){this._types=r||gu,this.text={},this.binary= +{}}a(At,"TypeOverrides");At.prototype.getOverrides=function(r){switch(r){case"text":return this.text;case"\ +binary":return this.binary;default:return{}}};At.prototype.setTypeParser=function(r,e,t){typeof e=="\ +function"&&(t=e,e="text"),this.getOverrides(e)[r]=t};At.prototype.getTypeParser=function(r,e){return e= +e||"text",this.getOverrides(e)[r]||this._types.getTypeParser(r,e)};es.exports=At});function Je(r){let e=1779033703,t=3144134277,n=1013904242,i=2773480762,s=1359893119,o=2600822924,u=528734635, +c=1541459225,l=0,f=0,p=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748, 2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401, 4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808, 3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700, 1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909, 275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222, 2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],g=a((I,w)=>I>>>w|I<<32- -w,"rrot"),A=new Uint32Array(64),C=new Uint8Array(64),D=a(()=>{for(let R=0,j=0;R<16;R++,j+=4)A[R]=C[j]<< -24|C[j+1]<<16|C[j+2]<<8|C[j+3];for(let R=16;R<64;R++){let j=g(A[R-15],7)^g(A[R-15],18)^A[R-15]>>>3,le=g( -A[R-2],17)^g(A[R-2],19)^A[R-2]>>>10;A[R]=A[R-16]+j+A[R-7]+le|0}let I=e,w=t,Z=n,W=i,J=s,X=o,se=u,oe=c; -for(let R=0;R<64;R++){let j=g(J,6)^g(J,11)^g(J,25),le=J&X^~J&se,de=oe+j+le+y[R]+A[R]|0,We=g(I,2)^g(I, -13)^g(I,22),fe=I&w^I&Z^w&Z,_e=We+fe|0;oe=se,se=X,X=J,J=W+de|0,W=Z,Z=w,w=I,I=de+_e|0}e=e+I|0,t=t+w|0, -n=n+Z|0,i=i+W|0,s=s+J|0,o=o+X|0,u=u+se|0,c=c+oe|0,f=0},"process"),Y=a(I=>{typeof I=="string"&&(I=new TextEncoder(). +w,"rrot"),E=new Uint32Array(64),C=new Uint8Array(64),D=a(()=>{for(let B=0,H=0;B<16;B++,H+=4)E[B]=C[H]<< +24|C[H+1]<<16|C[H+2]<<8|C[H+3];for(let B=16;B<64;B++){let H=g(E[B-15],7)^g(E[B-15],18)^E[B-15]>>>3,ue=g( +E[B-2],17)^g(E[B-2],19)^E[B-2]>>>10;E[B]=E[B-16]+H+E[B-7]+ue|0}let I=e,w=t,X=n,j=i,Z=s,he=o,J=u,se=c; +for(let B=0;B<64;B++){let H=g(Z,6)^g(Z,11)^g(Z,25),ue=Z&he^~Z&J,de=se+H+ue+p[B]+E[B]|0,Se=g(I,2)^g(I, +13)^g(I,22),Qe=I&w^I&X^w&X,ee=Se+Qe|0;se=J,J=he,he=Z,Z=j+de|0,j=X,X=w,w=I,I=de+ee|0}e=e+I|0,t=t+w|0, +n=n+X|0,i=i+j|0,s=s+Z|0,o=o+he|0,u=u+J|0,c=c+se|0,f=0},"process"),Y=a(I=>{typeof I=="string"&&(I=new TextEncoder(). encode(I));for(let w=0;w{if(C[f++]= 128,f==64&&D(),f+8>64){for(;f<64;)C[f++]=0;D()}for(;f<58;)C[f++]=0;let I=l*8;C[f++]=I/1099511627776& 255,C[f++]=I/4294967296&255,C[f++]=I>>>24,C[f++]=I>>>16&255,C[f++]=I>>>8&255,C[f++]=I&255,D();let w=new Uint8Array( @@ -568,9 +580,9 @@ encode(I));for(let w=0;w>>8&255,w[15]=i&255,w[16]=s>>>24,w[17]=s>>>16&255,w[18]=s>>>8&255,w[19]=s&255,w[20]=o>>>24,w[21]= o>>>16&255,w[22]=o>>>8&255,w[23]=o&255,w[24]=u>>>24,w[25]=u>>>16&255,w[26]=u>>>8&255,w[27]=u&255,w[28]= c>>>24,w[29]=c>>>16&255,w[30]=c>>>8&255,w[31]=c&255,w},"digest");return r===void 0?{add:Y,digest:P}: -(Y(r),P())}var es=G(()=>{"use strict";p();a(Xe,"sha256")});var U,et,ts=G(()=>{"use strict";p();U=class U{constructor(){E(this,"_dataLength",0);E(this,"_bufferL\ -ength",0);E(this,"_state",new Int32Array(4));E(this,"_buffer",new ArrayBuffer(68));E(this,"_buffer8"); -E(this,"_buffer32");this._buffer8=new Uint8Array(this._buffer,0,68),this._buffer32=new Uint32Array(this. +(Y(r),P())}var ts=G(()=>{"use strict";d();a(Je,"sha256")});var U,et,rs=G(()=>{"use strict";d();U=class U{constructor(){A(this,"_dataLength",0);A(this,"_bufferL\ +ength",0);A(this,"_state",new Int32Array(4));A(this,"_buffer",new ArrayBuffer(68));A(this,"_buffer8"); +A(this,"_buffer32");this._buffer8=new Uint8Array(this._buffer,0,68),this._buffer32=new Uint32Array(this. _buffer,0,17),this.start()}static hashByteArray(e,t=!1){return this.onePassHasher.start().appendByteArray( e).end(t)}static hashStr(e,t=!1){return this.onePassHasher.start().appendStr(e).end(t)}static hashAsciiStr(e,t=!1){ return this.onePassHasher.start().appendAsciiStr(e).end(t)}static _hex(e){let t=U.hexChars,n=U.hexOut, @@ -628,128 +640,128 @@ _buffer8,i=this._buffer32,s=(t>>2)+1;this._dataLength+=t;let o=this._dataLength* n[t+2]=n[t+3]=0,i.set(U.buffer32Identity.subarray(s),s),t>55&&(U._md5cycle(this._state,i),i.set(U.buffer32Identity)), o<=4294967295)i[14]=o;else{let u=o.toString(16).match(/(.*?)(.{0,8})$/);if(u===null)return;let c=parseInt( u[2],16),l=parseInt(u[1],16)||0;i[14]=c,i[15]=l}return U._md5cycle(this._state,i),e?this._state:U._hex( -this._state)}};a(U,"Md5"),E(U,"stateIdentity",new Int32Array([1732584193,-271733879,-1732584194,271733878])), -E(U,"buffer32Identity",new Int32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])),E(U,"hexChars","0123456789\ -abcdef"),E(U,"hexOut",[]),E(U,"onePassHasher",new U);et=U});var lr={};ie(lr,{createHash:()=>bu,createHmac:()=>vu,randomBytes:()=>gu});function gu(r){return crypto. -getRandomValues(d.alloc(r))}function bu(r){if(r==="sha256")return{update:a(function(e){return{digest:a( -function(){return d.from(Xe(e))},"digest")}},"update")};if(r==="md5")return{update:a(function(e){return{ +this._state)}};a(U,"Md5"),A(U,"stateIdentity",new Int32Array([1732584193,-271733879,-1732584194,271733878])), +A(U,"buffer32Identity",new Int32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])),A(U,"hexChars","0123456789\ +abcdef"),A(U,"hexOut",[]),A(U,"onePassHasher",new U);et=U});var fr={};ie(fr,{createHash:()=>vu,createHmac:()=>Su,randomBytes:()=>bu});function bu(r){return crypto. +getRandomValues(y.alloc(r))}function vu(r){if(r==="sha256")return{update:a(function(e){return{digest:a( +function(){return y.from(Je(e))},"digest")}},"update")};if(r==="md5")return{update:a(function(e){return{ digest:a(function(){return typeof e=="string"?et.hashStr(e):et.hashByteArray(e)},"digest")}},"update")}; -throw new Error(`Hash type '${r}' not supported`)}function vu(r,e){if(r!=="sha256")throw new Error(`\ +throw new Error(`Hash type '${r}' not supported`)}function Su(r,e){if(r!=="sha256")throw new Error(`\ Only sha256 is supported (requested: '${r}')`);return{update:a(function(t){return{digest:a(function(){ typeof e=="string"&&(e=new TextEncoder().encode(e)),typeof t=="string"&&(t=new TextEncoder().encode( -t));let n=e.length;if(n>64)e=Xe(e);else if(n<64){let c=new Uint8Array(64);c.set(e),e=c}let i=new Uint8Array( +t));let n=e.length;if(n>64)e=Je(e);else if(n<64){let c=new Uint8Array(64);c.set(e),e=c}let i=new Uint8Array( 64),s=new Uint8Array(64);for(let c=0;c<64;c++)i[c]=54^e[c],s[c]=92^e[c];let o=new Uint8Array(t.length+ -64);o.set(i,0),o.set(t,64);let u=new Uint8Array(96);return u.set(s,0),u.set(Xe(o),64),d.from(Xe(u))}, -"digest")}},"update")}}var fr=G(()=>{"use strict";p();es();ts();a(gu,"randomBytes");a(bu,"createHash"); -a(vu,"createHmac")});var tt=T((Qf,hr)=>{"use strict";p();hr.exports={host:"localhost",user:m.platform==="win32"?m.env.USERNAME: +64);o.set(i,0),o.set(t,64);let u=new Uint8Array(96);return u.set(s,0),u.set(Je(o),64),y.from(Je(u))}, +"digest")}},"update")}}var hr=G(()=>{"use strict";d();ts();rs();a(bu,"randomBytes");a(vu,"createHash"); +a(Su,"createHmac")});var tt=T((Qf,dr)=>{"use strict";d();dr.exports={host:"localhost",user:m.platform==="win32"?m.env.USERNAME: m.env.USER,database:void 0,password:null,connectionString:void 0,port:5432,rows:0,binary:!1,max:10,idleTimeoutMillis:3e4, 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 Me=Je(),xu=Me.getTypeParser(20,"text"),Su=Me.getTypeParser(1016, -"text");hr.exports.__defineSetter__("parseInt8",function(r){Me.setTypeParser(20,"text",r?Me.getTypeParser( -23,"text"):xu),Me.setTypeParser(1016,"text",r?Me.getTypeParser(1007,"text"):Su)})});var rt=T((Wf,ns)=>{"use strict";p();var Eu=(fr(),O(lr)),Au=tt();function Cu(r){var e=r.replace(/\\/g, -"\\\\").replace(/"/g,'\\"');return'"'+e+'"'}a(Cu,"escapeElement");function rs(r){for(var e="{",t=0;t< -r.length;t++)t>0&&(e=e+","),r[t]===null||typeof r[t]>"u"?e=e+"NULL":Array.isArray(r[t])?e=e+rs(r[t]): -r[t]instanceof d?e+="\\\\x"+r[t].toString("hex"):e+=Cu(Ct(r[t]));return e=e+"}",e}a(rs,"arrayString"); -var Ct=a(function(r,e){if(r==null)return null;if(r instanceof d)return r;if(ArrayBuffer.isView(r)){var t=d. +keepalives:1,keepalives_idle:0};var Fe=Ze(),xu=Fe.getTypeParser(20,"text"),Eu=Fe.getTypeParser(1016, +"text");dr.exports.__defineSetter__("parseInt8",function(r){Fe.setTypeParser(20,"text",r?Fe.getTypeParser( +23,"text"):xu),Fe.setTypeParser(1016,"text",r?Fe.getTypeParser(1007,"text"):Eu)})});var rt=T((jf,is)=>{"use strict";d();var Au=(hr(),O(fr)),Cu=tt();function _u(r){var e=r.replace(/\\/g, +"\\\\").replace(/"/g,'\\"');return'"'+e+'"'}a(_u,"escapeElement");function ns(r){for(var e="{",t=0;t< +r.length;t++)t>0&&(e=e+","),r[t]===null||typeof r[t]>"u"?e=e+"NULL":Array.isArray(r[t])?e=e+ns(r[t]): +r[t]instanceof y?e+="\\\\x"+r[t].toString("hex"):e+=_u(_t(r[t]));return e=e+"}",e}a(ns,"arrayString"); +var _t=a(function(r,e){if(r==null)return null;if(r instanceof y)return r;if(ArrayBuffer.isView(r)){var t=y. from(r.buffer,r.byteOffset,r.byteLength);return t.length===r.byteLength?t:t.slice(r.byteOffset,r.byteOffset+ -r.byteLength)}return r instanceof Date?Au.parseInputDatesAsUTC?Tu(r):Iu(r):Array.isArray(r)?rs(r):typeof r== -"object"?_u(r,e):r.toString()},"prepareValue");function _u(r,e){if(r&&typeof r.toPostgres=="function"){ +r.byteLength)}return r instanceof Date?Cu.parseInputDatesAsUTC?Pu(r):Tu(r):Array.isArray(r)?ns(r):typeof r== +"object"?Iu(r,e):r.toString()},"prepareValue");function Iu(r,e){if(r&&typeof r.toPostgres=="function"){ if(e=e||[],e.indexOf(r)!==-1)throw new Error('circular reference detected while preparing "'+r+'" fo\ -r query');return e.push(r),Ct(r.toPostgres(Ct),e)}return JSON.stringify(r)}a(_u,"prepareObject");function N(r,e){ -for(r=""+r;r.lengthku});var ku,it=G(()=>{"use strict";p();ku={}});var ds=T((th,ps)=>{"use strict";p();var yr=(fr(),O(lr));function Mu(r){if(r.indexOf("SCRAM-SHA-256")=== --1)throw new Error("SASL: Only mechanism SCRAM-SHA-256 is currently supported");let e=yr.randomBytes( +t),r}a(Lu,"normalizeQueryConfig");var pr=a(function(r){return Au.createHash("md5").update(r,"utf-8"). +digest("hex")},"md5"),Bu=a(function(r,e,t){var n=pr(e+r),i=pr(y.concat([y.from(n),t]));return"md5"+i}, +"postgresMd5PasswordHash");is.exports={prepareValue:a(function(e){return _t(e)},"prepareValueWrapper"), +normalizeQueryConfig:Lu,postgresMd5PasswordHash:Bu,md5:pr}});var nt={};ie(nt,{default:()=>Mu});var Mu,it=G(()=>{"use strict";d();Mu={}});var ys=T((th,ps)=>{"use strict";d();var mr=(hr(),O(fr));function Uu(r){if(r.indexOf("SCRAM-SHA-256")=== +-1)throw new Error("SASL: Only mechanism SCRAM-SHA-256 is currently supported");let e=mr.randomBytes( 18).toString("base64");return{mechanism:"SCRAM-SHA-256",clientNonce:e,response:"n,,n=*,r="+e,message:"\ -SASLInitialResponse"}}a(Mu,"startSession");function Uu(r,e,t){if(r.message!=="SASLInitialResponse")throw new Error( +SASLInitialResponse"}}a(Uu,"startSession");function Du(r,e,t){if(r.message!=="SASLInitialResponse")throw new Error( "SASL: Last message was not SASLInitialResponse");if(typeof e!="string")throw new Error("SASL: SCRAM\ -SERVER-FIRST-MESSAGE: client password must be a string");if(typeof t!="string")throw new Error("SAS\ L: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");let n=qu(t);if(n.nonce.startsWith(r.clientNonce)){ if(n.nonce.length===r.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server n\ once is too short")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not st\ -art with client nonce");var i=d.from(n.salt,"base64"),s=Wu(e,i,n.iteration),o=Ue(s,"Client Key"),u=Nu( -o),c="n=*,r="+r.clientNonce,l="r="+n.nonce+",s="+n.salt+",i="+n.iteration,f="c=biws,r="+n.nonce,y=c+ -","+l+","+f,g=Ue(u,y),A=hs(o,g),C=A.toString("base64"),D=Ue(s,"Server Key"),Y=Ue(D,y);r.message="SAS\ -LResponse",r.serverSignature=Y.toString("base64"),r.response=f+",p="+C}a(Uu,"continueSession");function Du(r,e){ +art with client nonce");var i=y.from(n.salt,"base64"),s=ju(e,i,n.iteration),o=Me(s,"Client Key"),u=Wu( +o),c="n=*,r="+r.clientNonce,l="r="+n.nonce+",s="+n.salt+",i="+n.iteration,f="c=biws,r="+n.nonce,p=c+ +","+l+","+f,g=Me(u,p),E=ds(o,g),C=E.toString("base64"),D=Me(s,"Server Key"),Y=Me(D,p);r.message="SAS\ +LResponse",r.serverSignature=Y.toString("base64"),r.response=f+",p="+C}a(Du,"continueSession");function Ou(r,e){ if(r.message!=="SASLResponse")throw new Error("SASL: Last message was not SASLResponse");if(typeof e!= "string")throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string");let{serverSignature:t}=Qu( e);if(t!==r.serverSignature)throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does\ - not match")}a(Du,"finalizeSession");function Ou(r){if(typeof r!="string")throw new TypeError("SASL:\ + not match")}a(Ou,"finalizeSession");function Nu(r){if(typeof r!="string")throw new TypeError("SASL:\ text must be a string");return r.split("").map((e,t)=>r.charCodeAt(t)).every(e=>e>=33&&e<=43||e>=45&& -e<=126)}a(Ou,"isPrintableChars");function ls(r){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/. -test(r)}a(ls,"isBase64");function fs(r){if(typeof r!="string")throw new TypeError("SASL: attribute p\ +e<=126)}a(Nu,"isPrintableChars");function fs(r){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/. +test(r)}a(fs,"isBase64");function hs(r){if(typeof r!="string")throw new TypeError("SASL: attribute p\ airs text must be a string");return new Map(r.split(",").map(e=>{if(!/^.=/.test(e))throw new Error("\ -SASL: Invalid attribute pair entry");let t=e[0],n=e.substring(2);return[t,n]}))}a(fs,"parseAttribute\ -Pairs");function qu(r){let e=fs(r),t=e.get("r");if(t){if(!Ou(t))throw new Error("SASL: SCRAM-SERVER-\ +SASL: Invalid attribute pair entry");let t=e[0],n=e.substring(2);return[t,n]}))}a(hs,"parseAttribute\ +Pairs");function qu(r){let e=hs(r),t=e.get("r");if(t){if(!Nu(t))throw new Error("SASL: SCRAM-SERVER-\ FIRST-MESSAGE: nonce must only contain printable characters")}else throw new Error("SASL: SCRAM-SERV\ -ER-FIRST-MESSAGE: nonce missing");let n=e.get("s");if(n){if(!ls(n))throw new Error("SASL: SCRAM-SERV\ +ER-FIRST-MESSAGE: nonce missing");let n=e.get("s");if(n){if(!fs(n))throw new Error("SASL: SCRAM-SERV\ ER-FIRST-MESSAGE: salt must be base64")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt\ missing");let i=e.get("i");if(i){if(!/^[1-9][0-9]*$/.test(i))throw new Error("SASL: SCRAM-SERVER-FI\ RST-MESSAGE: invalid iteration count")}else throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: itera\ tion missing");let s=parseInt(i,10);return{nonce:t,salt:n,iteration:s}}a(qu,"parseServerFirstMessage"); -function Qu(r){let t=fs(r).get("v");if(t){if(!ls(t))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAG\ +function Qu(r){let t=hs(r).get("v");if(t){if(!fs(t))throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAG\ E: server signature must be base64")}else throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server \ -signature is missing");return{serverSignature:t}}a(Qu,"parseServerFinalMessage");function hs(r,e){if(!d. -isBuffer(r))throw new TypeError("first argument must be a Buffer");if(!d.isBuffer(e))throw new TypeError( +signature is missing");return{serverSignature:t}}a(Qu,"parseServerFinalMessage");function ds(r,e){if(!y. +isBuffer(r))throw new TypeError("first argument must be a Buffer");if(!y.isBuffer(e))throw new TypeError( "second argument must be a Buffer");if(r.length!==e.length)throw new Error("Buffer lengths must matc\ -h");if(r.length===0)throw new Error("Buffers cannot be empty");return d.from(r.map((t,n)=>r[n]^e[n]))} -a(hs,"xorBuffers");function Nu(r){return yr.createHash("sha256").update(r).digest()}a(Nu,"sha256");function Ue(r,e){ -return yr.createHmac("sha256",r).update(e).digest()}a(Ue,"hmacSha256");function Wu(r,e,t){for(var n=Ue( -r,d.concat([e,d.from([0,0,0,1])])),i=n,s=0;sju});function ju(...r){return r.join("/")}var wr=G(()=>{"use strict";p();a( -ju,"join")});var gr={};ie(gr,{stat:()=>Hu});function Hu(r,e){e(new Error("No filesystem"))}var br=G(()=>{"use str\ -ict";p();a(Hu,"stat")});var vr={};ie(vr,{default:()=>$u});var $u,xr=G(()=>{"use strict";p();$u={}});var ys={};ie(ys,{StringDecoder:()=>Sr});var Er,Sr,ms=G(()=>{"use strict";p();Er=class Er{constructor(e){ -E(this,"td");this.td=new TextDecoder(e)}write(e){return this.td.decode(e,{stream:!0})}end(e){return this. -td.decode(e)}};a(Er,"StringDecoder");Sr=Er});var vs=T((fh,bs)=>{"use strict";p();var{Transform:Gu}=(xr(),O(vr)),{StringDecoder:Vu}=(ms(),O(ys)),ve=Symbol( -"last"),It=Symbol("decoder");function zu(r,e,t){let n;if(this.overflow){if(n=this[It].write(r).split( -this.matcher),n.length===1)return t();n.shift(),this.overflow=!1}else this[ve]+=this[It].write(r),n= -this[ve].split(this.matcher);this[ve]=n.pop();for(let i=0;ithis.maxLength,this.overflow&&!this.skipOverflow){t(new Error( -"maximum buffer reached"));return}t()}a(zu,"transform");function Ku(r){if(this[ve]+=this[It].end(),this[ve]) -try{gs(this,this.mapper(this[ve]))}catch(e){return r(e)}r()}a(Ku,"flush");function gs(r,e){e!==void 0&& -r.push(e)}a(gs,"push");function ws(r){return r}a(ws,"noop");function Yu(r,e,t){switch(r=r||/\r?\n/,e= -e||ws,t=t||{},arguments.length){case 1:typeof r=="function"?(e=r,r=/\r?\n/):typeof r=="object"&&!(r instanceof +h");if(r.length===0)throw new Error("Buffers cannot be empty");return y.from(r.map((t,n)=>r[n]^e[n]))} +a(ds,"xorBuffers");function Wu(r){return mr.createHash("sha256").update(r).digest()}a(Wu,"sha256");function Me(r,e){ +return mr.createHmac("sha256",r).update(e).digest()}a(Me,"hmacSha256");function ju(r,e,t){for(var n=Me( +r,y.concat([e,y.from([0,0,0,1])])),i=n,s=0;sHu});function Hu(...r){return r.join("/")}var gr=G(()=>{"use strict";d();a( +Hu,"join")});var br={};ie(br,{stat:()=>$u});function $u(r,e){e(new Error("No filesystem"))}var vr=G(()=>{"use str\ +ict";d();a($u,"stat")});var Sr={};ie(Sr,{default:()=>Gu});var Gu,xr=G(()=>{"use strict";d();Gu={}});var ms={};ie(ms,{StringDecoder:()=>Er});var Ar,Er,ws=G(()=>{"use strict";d();Ar=class Ar{constructor(e){ +A(this,"td");this.td=new TextDecoder(e)}write(e){return this.td.decode(e,{stream:!0})}end(e){return this. +td.decode(e)}};a(Ar,"StringDecoder");Er=Ar});var Ss=T((fh,vs)=>{"use strict";d();var{Transform:Vu}=(xr(),O(Sr)),{StringDecoder:zu}=(ws(),O(ms)),be=Symbol( +"last"),Tt=Symbol("decoder");function Ku(r,e,t){let n;if(this.overflow){if(n=this[Tt].write(r).split( +this.matcher),n.length===1)return t();n.shift(),this.overflow=!1}else this[be]+=this[Tt].write(r),n= +this[be].split(this.matcher);this[be]=n.pop();for(let i=0;ithis.maxLength,this.overflow&&!this.skipOverflow){t(new Error( +"maximum buffer reached"));return}t()}a(Ku,"transform");function Yu(r){if(this[be]+=this[Tt].end(),this[be]) +try{bs(this,this.mapper(this[be]))}catch(e){return r(e)}r()}a(Yu,"flush");function bs(r,e){e!==void 0&& +r.push(e)}a(bs,"push");function gs(r){return r}a(gs,"noop");function Xu(r,e,t){switch(r=r||/\r?\n/,e= +e||gs,t=t||{},arguments.length){case 1:typeof r=="function"?(e=r,r=/\r?\n/):typeof r=="object"&&!(r instanceof RegExp)&&!r[Symbol.split]&&(t=r,r=/\r?\n/);break;case 2:typeof r=="function"?(t=e,e=r,r=/\r?\n/):typeof e== -"object"&&(t=e,e=ws)}t=Object.assign({},t),t.autoDestroy=!0,t.transform=zu,t.flush=Ku,t.readableObjectMode= -!0;let n=new Gu(t);return n[ve]="",n[It]=new Vu("utf8"),n.matcher=r,n.mapper=e,n.maxLength=t.maxLength, +"object"&&(t=e,e=gs)}t=Object.assign({},t),t.autoDestroy=!0,t.transform=Ku,t.flush=Yu,t.readableObjectMode= +!0;let n=new Vu(t);return n[be]="",n[Tt]=new zu("utf8"),n.matcher=r,n.mapper=e,n.maxLength=t.maxLength, n.skipOverflow=t.skipOverflow||!1,n.overflow=!1,n._destroy=function(i,s){this._writableState.errorEmitted= -!1,s(i)},n}a(Yu,"split");bs.exports=Yu});var Es=T((dh,pe)=>{"use strict";p();var xs=(wr(),O(mr)),Zu=(xr(),O(vr)).Stream,Ju=vs(),Ss=(it(),O(nt)), -Xu=5432,Tt=m.platform==="win32",st=m.stderr,ec=56,tc=7,rc=61440,nc=32768;function ic(r){return(r&rc)== -nc}a(ic,"isRegFile");var De=["host","port","database","user","password"],Ar=De.length,sc=De[Ar-1];function Cr(){ +!1,s(i)},n}a(Xu,"split");vs.exports=Xu});var As=T((ph,fe)=>{"use strict";d();var xs=(gr(),O(wr)),Zu=(xr(),O(Sr)).Stream,Ju=Ss(),Es=(it(),O(nt)), +ec=5432,Pt=m.platform==="win32",st=m.stderr,tc=56,rc=7,nc=61440,ic=32768;function sc(r){return(r&nc)== +ic}a(sc,"isRegFile");var Ue=["host","port","database","user","password"],Cr=Ue.length,oc=Ue[Cr-1];function _r(){ var r=st instanceof Zu&&st.writable===!0;if(r){var e=Array.prototype.slice.call(arguments).concat(` -`);st.write(Ss.format.apply(Ss,e))}}a(Cr,"warn");Object.defineProperty(pe.exports,"isWin",{get:a(function(){ -return Tt},"get"),set:a(function(r){Tt=r},"set")});pe.exports.warnTo=function(r){var e=st;return st= -r,e};pe.exports.getFileName=function(r){var e=r||m.env,t=e.PGPASSFILE||(Tt?xs.join(e.APPDATA||"./","\ -postgresql","pgpass.conf"):xs.join(e.HOME||"./",".pgpass"));return t};pe.exports.usePgPass=function(r,e){ -return Object.prototype.hasOwnProperty.call(m.env,"PGPASSWORD")?!1:Tt?!0:(e=e||"",ic(r.mode)?r. -mode&(ec|tc)?(Cr('WARNING: password file "%s" has group or world access; permissions should be u=rw \ -(0600) or less',e),!1):!0:(Cr('WARNING: password file "%s" is not a plain file',e),!1))};var oc=pe.exports. -match=function(r,e){return De.slice(0,-1).reduce(function(t,n,i){return i==1&&Number(r[n]||Xu)===Number( -e[n])?t&&!0:t&&(e[n]==="*"||e[n]===r[n])},!0)};pe.exports.getPassword=function(r,e,t){var n,i=e.pipe( -Ju());function s(c){var l=ac(c);l&&uc(l)&&oc(r,l)&&(n=l[sc],i.end())}a(s,"onLine");var o=a(function(){ -e.destroy(),t(n)},"onEnd"),u=a(function(c){e.destroy(),Cr("WARNING: error on reading file: %s",c),t( -void 0)},"onErr");e.on("error",u),i.on("data",s).on("end",o).on("error",u)};var ac=pe.exports.parseLine= +`);st.write(Es.format.apply(Es,e))}}a(_r,"warn");Object.defineProperty(fe.exports,"isWin",{get:a(function(){ +return Pt},"get"),set:a(function(r){Pt=r},"set")});fe.exports.warnTo=function(r){var e=st;return st= +r,e};fe.exports.getFileName=function(r){var e=r||m.env,t=e.PGPASSFILE||(Pt?xs.join(e.APPDATA||"./","\ +postgresql","pgpass.conf"):xs.join(e.HOME||"./",".pgpass"));return t};fe.exports.usePgPass=function(r,e){ +return Object.prototype.hasOwnProperty.call(m.env,"PGPASSWORD")?!1:Pt?!0:(e=e||"",sc(r.mode)?r. +mode&(tc|rc)?(_r('WARNING: password file "%s" has group or world access; permissions should be u=rw \ +(0600) or less',e),!1):!0:(_r('WARNING: password file "%s" is not a plain file',e),!1))};var ac=fe.exports. +match=function(r,e){return Ue.slice(0,-1).reduce(function(t,n,i){return i==1&&Number(r[n]||ec)===Number( +e[n])?t&&!0:t&&(e[n]==="*"||e[n]===r[n])},!0)};fe.exports.getPassword=function(r,e,t){var n,i=e.pipe( +Ju());function s(c){var l=uc(c);l&&cc(l)&&ac(r,l)&&(n=l[oc],i.end())}a(s,"onLine");var o=a(function(){ +e.destroy(),t(n)},"onEnd"),u=a(function(c){e.destroy(),_r("WARNING: error on reading file: %s",c),t( +void 0)},"onErr");e.on("error",u),i.on("data",s).on("end",o).on("error",u)};var uc=fe.exports.parseLine= function(r){if(r.length<11||r.match(/^\s+#/))return null;for(var e="",t="",n=0,i=0,s=0,o={},u=!1,c=a( -function(f,y,g){var A=r.substring(y,g);Object.hasOwnProperty.call(m.env,"PGPASS_NO_DEESCAPE")||(A=A. -replace(/\\([:\\])/g,"$1")),o[De[f]]=A},"addToObj"),l=0;l=0&&e==":"&&t!=="\\"&&(c(n,i,l+1),i=l+2,n+=1)}return o=Object.keys(o). -length===Ar?o:null,o},uc=pe.exports.isValidEntry=function(r){for(var e={0:function(o){return o.length> +function(f,p,g){var E=r.substring(p,g);Object.hasOwnProperty.call(m.env,"PGPASS_NO_DEESCAPE")||(E=E. +replace(/\\([:\\])/g,"$1")),o[Ue[f]]=E},"addToObj"),l=0;l=0&&e==":"&&t!=="\\"&&(c(n,i,l+1),i=l+2,n+=1)}return o=Object.keys(o). +length===Cr?o:null,o},cc=fe.exports.isValidEntry=function(r){for(var e={0:function(o){return o.length> 0},1:function(o){return o==="*"?!0:(o=Number(o),isFinite(o)&&o>0&&o<9007199254740992&&Math.floor(o)=== o)},2:function(o){return o.length>0},3:function(o){return o.length>0},4:function(o){return o.length> -0}},t=0;t{"use strict";p();var wh=(wr(),O(mr)),As=(br(),O(gr)),Pt=Es();_r.exports=function(r,e){ -var t=Pt.getFileName();As.stat(t,function(n,i){if(n||!Pt.usePgPass(i,t))return e(void 0);var s=As.createReadStream( -t);Pt.getPassword(r,s,e)})};_r.exports.warnTo=Pt.warnTo});var _s={};ie(_s,{default:()=>cc});var cc,Is=G(()=>{"use strict";p();cc={}});var Ps=T((xh,Ts)=>{"use strict";p();var lc=(Zt(),O(gi)),Ir=(br(),O(gr));function Tr(r){if(r.charAt(0)=== -"/"){var t=r.split(" ");return{host:t[0],database:t[1]}}var e=lc.parse(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i. +0}},t=0;t{"use strict";d();var wh=(gr(),O(wr)),Cs=(vr(),O(br)),Lt=As();Ir.exports=function(r,e){ +var t=Lt.getFileName();Cs.stat(t,function(n,i){if(n||!Lt.usePgPass(i,t))return e(void 0);var s=Cs.createReadStream( +t);Lt.getPassword(r,s,e)})};Ir.exports.warnTo=Lt.warnTo});var Is={};ie(Is,{default:()=>lc});var lc,Ts=G(()=>{"use strict";d();lc={}});var Ls=T((Sh,Ps)=>{"use strict";d();var fc=(Zt(),O(bi)),Tr=(vr(),O(br));function Pr(r){if(r.charAt(0)=== +"/"){var t=r.split(" ");return{host:t[0],database:t[1]}}var e=fc.parse(/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i. test(r)?encodeURI(r).replace(/\%25(\d\d)/g,"%$1"):r,!0),t=e.query;for(var n in t)Array.isArray(t[n])&& (t[n]=t[n][t[n].length-1]);var i=(e.auth||":").split(":");if(t.user=i[0],t.password=i.splice(1).join( ":"),t.port=e.port,e.protocol=="socket:")return t.host=decodeURI(e.pathname),t.database=e.query.db,t. @@ -757,37 +769,37 @@ client_encoding=e.query.encoding,t;t.host||(t.host=e.hostname);var s=e.pathname; test(s)){var o=s.split("/");t.host=decodeURIComponent(o[0]),s=o.splice(1).join("/")}switch(s&&s.charAt( 0)==="/"&&(s=s.slice(1)||null),t.database=s&&decodeURI(s),(t.ssl==="true"||t.ssl==="1")&&(t.ssl=!0), t.ssl==="0"&&(t.ssl=!1),(t.sslcert||t.sslkey||t.sslrootcert||t.sslmode)&&(t.ssl={}),t.sslcert&&(t.ssl. -cert=Ir.readFileSync(t.sslcert).toString()),t.sslkey&&(t.ssl.key=Ir.readFileSync(t.sslkey).toString()), -t.sslrootcert&&(t.ssl.ca=Ir.readFileSync(t.sslrootcert).toString()),t.sslmode){case"disable":{t.ssl= +cert=Tr.readFileSync(t.sslcert).toString()),t.sslkey&&(t.ssl.key=Tr.readFileSync(t.sslkey).toString()), +t.sslrootcert&&(t.ssl.ca=Tr.readFileSync(t.sslrootcert).toString()),t.sslmode){case"disable":{t.ssl= !1;break}case"prefer":case"require":case"verify-ca":case"verify-full":break;case"no-verify":{t.ssl.rejectUnauthorized= -!1;break}}return t}a(Tr,"parse");Ts.exports=Tr;Tr.parse=Tr});var Bt=T((Ah,Ls)=>{"use strict";p();var fc=(Is(),O(_s)),Rs=tt(),Bs=Ps().parse,H=a(function(r,e,t){return t=== -void 0?t=m.env["PG"+r.toUpperCase()]:t===!1||(t=m.env[t]),e[r]||t||Rs[r]},"val"),hc=a(function(){switch(m. +!1;break}}return t}a(Pr,"parse");Ps.exports=Pr;Pr.parse=Pr});var Bt=T((Ah,ks)=>{"use strict";d();var hc=(Ts(),O(Is)),Rs=tt(),Bs=Ls().parse,$=a(function(r,e,t){return t=== +void 0?t=m.env["PG"+r.toUpperCase()]:t===!1||(t=m.env[t]),e[r]||t||Rs[r]},"val"),dc=a(function(){switch(m. 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 Rs.ssl},"readSSLConfigFromEnvironment"),Oe=a(function(r){ +no-verify":return{rejectUnauthorized:!1}}return Rs.ssl},"readSSLConfigFromEnvironment"),De=a(function(r){ return"'"+(""+r).replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'"},"quoteParamValue"),ne=a(function(r,e,t){ -var n=e[t];n!=null&&r.push(t+"="+Oe(n))},"add"),Br=class Br{constructor(e){e=typeof e=="string"?Bs(e): -e||{},e.connectionString&&(e=Object.assign({},e,Bs(e.connectionString))),this.user=H("user",e),this. -database=H("database",e),this.database===void 0&&(this.database=this.user),this.port=parseInt(H("por\ -t",e),10),this.host=H("host",e),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1, -writable:!0,value:H("password",e)}),this.binary=H("binary",e),this.options=H("options",e),this.ssl=typeof e. -ssl>"u"?hc():e.ssl,typeof this.ssl=="string"&&this.ssl==="true"&&(this.ssl=!0),this.ssl==="no-verify"&& +var n=e[t];n!=null&&r.push(t+"="+De(n))},"add"),Br=class Br{constructor(e){e=typeof e=="string"?Bs(e): +e||{},e.connectionString&&(e=Object.assign({},e,Bs(e.connectionString))),this.user=$("user",e),this. +database=$("database",e),this.database===void 0&&(this.database=this.user),this.port=parseInt($("por\ +t",e),10),this.host=$("host",e),Object.defineProperty(this,"password",{configurable:!0,enumerable:!1, +writable:!0,value:$("password",e)}),this.binary=$("binary",e),this.options=$("options",e),this.ssl=typeof e. +ssl>"u"?dc():e.ssl,typeof this.ssl=="string"&&this.ssl==="true"&&(this.ssl=!0),this.ssl==="no-verify"&& (this.ssl={rejectUnauthorized:!1}),this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,"key",{enumerable:!1}), -this.client_encoding=H("client_encoding",e),this.replication=H("replication",e),this.isDomainSocket= -!(this.host||"").indexOf("/"),this.application_name=H("application_name",e,"PGAPPNAME"),this.fallback_application_name= -H("fallback_application_name",e,!1),this.statement_timeout=H("statement_timeout",e,!1),this.lock_timeout= -H("lock_timeout",e,!1),this.idle_in_transaction_session_timeout=H("idle_in_transaction_session_timeo\ -ut",e,!1),this.query_timeout=H("query_timeout",e,!1),e.connectionTimeoutMillis===void 0?this.connect_timeout= +this.client_encoding=$("client_encoding",e),this.replication=$("replication",e),this.isDomainSocket= +!(this.host||"").indexOf("/"),this.application_name=$("application_name",e,"PGAPPNAME"),this.fallback_application_name= +$("fallback_application_name",e,!1),this.statement_timeout=$("statement_timeout",e,!1),this.lock_timeout= +$("lock_timeout",e,!1),this.idle_in_transaction_session_timeout=$("idle_in_transaction_session_timeo\ +ut",e,!1),this.query_timeout=$("query_timeout",e,!1),e.connectionTimeoutMillis===void 0?this.connect_timeout= m.env.PGCONNECT_TIMEOUT||0:this.connect_timeout=Math.floor(e.connectionTimeoutMillis/1e3),e.keepAlive=== !1?this.keepalives=0:e.keepAlive===!0&&(this.keepalives=1),typeof e.keepAliveInitialDelayMillis=="nu\ mber"&&(this.keepalives_idle=Math.floor(e.keepAliveInitialDelayMillis/1e3))}getLibpqConnectionString(e){ var t=[];ne(t,this,"user"),ne(t,this,"password"),ne(t,this,"port"),ne(t,this,"application_name"),ne( t,this,"fallback_application_name"),ne(t,this,"connect_timeout"),ne(t,this,"options");var n=typeof this. ssl=="object"?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(ne(t,n,"sslmode"),ne(t,n,"sslca"),ne(t,n,"s\ -slkey"),ne(t,n,"sslcert"),ne(t,n,"sslrootcert"),this.database&&t.push("dbname="+Oe(this.database)),this. -replication&&t.push("replication="+Oe(this.replication)),this.host&&t.push("host="+Oe(this.host)),this. -isDomainSocket)return e(null,t.join(" "));this.client_encoding&&t.push("client_encoding="+Oe(this.client_encoding)), -fc.lookup(this.host,function(i,s){return i?e(i,null):(t.push("hostaddr="+Oe(s)),e(null,t.join(" ")))})}}; -a(Br,"ConnectionParameters");var Pr=Br;Ls.exports=Pr});var Ms=T((Ih,ks)=>{"use strict";p();var pc=Je(),Fs=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/,Lr=class Lr{constructor(e,t){ +slkey"),ne(t,n,"sslcert"),ne(t,n,"sslrootcert"),this.database&&t.push("dbname="+De(this.database)),this. +replication&&t.push("replication="+De(this.replication)),this.host&&t.push("host="+De(this.host)),this. +isDomainSocket)return e(null,t.join(" "));this.client_encoding&&t.push("client_encoding="+De(this.client_encoding)), +hc.lookup(this.host,function(i,s){return i?e(i,null):(t.push("hostaddr="+De(s)),e(null,t.join(" ")))})}}; +a(Br,"ConnectionParameters");var Lr=Br;ks.exports=Lr});var Us=T((Ih,Ms)=>{"use strict";d();var pc=Ze(),Fs=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/,kr=class kr{constructor(e,t){ this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0, this._types=t,this.RowCtor=null,this.rowAsArray=e==="array",this.rowAsArray&&(this.parseRow=this._parseRowAsArray)}addCommandComplete(e){ var t;e.text?t=Fs.exec(e.text):t=Fs.exec(e.command),t&&(this.command=t[1],t[3]?(this.oid=parseInt(t[2], @@ -797,14 +809,14 @@ for(var t={},n=0,i=e.length;n{"use strict";p();var{EventEmitter:dc}=ge(),Us=Ms(),Ds=rt(),kr=class kr extends dc{constructor(e,t,n){ -super(),e=Ds.normalizeQueryConfig(e,t,n),this.text=e.text,this.values=e.values,this.rows=e.rows,this. +format||"text")}}};a(kr,"Result");var Rr=kr;Ms.exports=Rr});var qs=T((Lh,Ns)=>{"use strict";d();var{EventEmitter:yc}=we(),Ds=Us(),Os=rt(),Mr=class Mr extends yc{constructor(e,t,n){ +super(),e=Os.normalizeQueryConfig(e,t,n),this.text=e.text,this.values=e.values,this.rows=e.rows,this. types=e.types,this.name=e.name,this.binary=e.binary,this.portal=e.portal||"",this.callback=e.callback, this._rowMode=e.rowMode,m.domain&&e.callback&&(this.callback=m.domain.bind(e.callback)),this._result= -new Us(this._rowMode,this.types),this._results=this._result,this.isPreparedStatement=!1,this._canceledDueToError= +new Ds(this._rowMode,this.types),this._results=this._result,this.isPreparedStatement=!1,this._canceledDueToError= !1,this._promise=null}requiresPreparation(){return this.name||this.rows?!0:!this.text||!this.values? !1:this.values.length>0}_checkForMultirow(){this._result.command&&(Array.isArray(this._results)||(this. -_results=[this._result]),this._result=new Us(this._rowMode,this.types),this._results.push(this._result))}handleRowDescription(e){ +_results=[this._result]),this._result=new Ds(this._rowMode,this.types),this._results.push(this._result))}handleRowDescription(e){ this._checkForMultirow(),this._result.addFields(e.fields),this._accumulateRows=this.callback||!this. listeners("row").length}handleDataRow(e){let t;if(!this._canceledDueToError){try{t=this._result.parseRow( e.fields)}catch(n){this._canceledDueToError=n;return}this.emit("row",t,this._result),this._accumulateRows&& @@ -821,10 +833,10 @@ ues must be an array"):(this.requiresPreparation()?this.prepare(e):e.query(this. return this.name&&e.parsedStatements[this.name]}handlePortalSuspended(e){this._getRows(e,this.rows)}_getRows(e,t){ e.execute({portal:this.portal,rows:t}),t?e.flush():e.sync()}prepare(e){this.isPreparedStatement=!0,this. hasBeenParsed(e)||e.parse({text:this.text,name:this.name,types:this.types});try{e.bind({portal:this. -portal,statement:this.name,values:this.values,binary:this.binary,valueMapper:Ds.prepareValue})}catch(t){ +portal,statement:this.name,values:this.values,binary:this.binary,valueMapper:Os.prepareValue})}catch(t){ this.handleError(t,e);return}e.describe({type:"P",name:this.portal||""}),this._getRows(e,this.rows)}handleCopyInResponse(e){ -e.sendCopyFail("No source stream defined")}handleCopyData(e,t){}};a(kr,"Query");var Fr=kr;Os.exports= -Fr});var ln=T(_=>{"use strict";p();Object.defineProperty(_,"__esModule",{value:!0});_.NoticeMessage=_.DataRowMessage= +e.sendCopyFail("No source stream defined")}handleCopyData(e,t){}};a(Mr,"Query");var Fr=Mr;Ns.exports= +Fr});var fn=T(_=>{"use strict";d();Object.defineProperty(_,"__esModule",{value:!0});_.NoticeMessage=_.DataRowMessage= _.CommandCompleteMessage=_.ReadyForQueryMessage=_.NotificationResponseMessage=_.BackendKeyDataMessage= _.AuthenticationMD5Password=_.ParameterStatusMessage=_.ParameterDescriptionMessage=_.RowDescriptionMessage= _.Field=_.CopyResponse=_.CopyDataMessage=_.DatabaseError=_.copyDone=_.emptyQuery=_.replicationStart= @@ -832,137 +844,137 @@ _.portalSuspended=_.noData=_.closeComplete=_.bindComplete=_.parseComplete=void 0 parseComplete",length:5};_.bindComplete={name:"bindComplete",length:5};_.closeComplete={name:"closeC\ omplete",length:5};_.noData={name:"noData",length:5};_.portalSuspended={name:"portalSuspended",length:5}; _.replicationStart={name:"replicationStart",length:4};_.emptyQuery={name:"emptyQuery",length:4};_.copyDone= -{name:"copyDone",length:4};var Kr=class Kr extends Error{constructor(e,t,n){super(e),this.length=t,this. -name=n}};a(Kr,"DatabaseError");var Mr=Kr;_.DatabaseError=Mr;var Yr=class Yr{constructor(e,t){this.length= -e,this.chunk=t,this.name="copyData"}};a(Yr,"CopyDataMessage");var Ur=Yr;_.CopyDataMessage=Ur;var Zr=class Zr{constructor(e,t,n,i){ -this.length=e,this.name=t,this.binary=n,this.columnTypes=new Array(i)}};a(Zr,"CopyResponse");var Dr=Zr; -_.CopyResponse=Dr;var Jr=class Jr{constructor(e,t,n,i,s,o,u){this.name=e,this.tableID=t,this.columnID= -n,this.dataTypeID=i,this.dataTypeSize=s,this.dataTypeModifier=o,this.format=u}};a(Jr,"Field");var Or=Jr; -_.Field=Or;var Xr=class Xr{constructor(e,t){this.length=e,this.fieldCount=t,this.name="rowDescriptio\ -n",this.fields=new Array(this.fieldCount)}};a(Xr,"RowDescriptionMessage");var qr=Xr;_.RowDescriptionMessage= -qr;var en=class en{constructor(e,t){this.length=e,this.parameterCount=t,this.name="parameterDescript\ -ion",this.dataTypeIDs=new Array(this.parameterCount)}};a(en,"ParameterDescriptionMessage");var Qr=en; -_.ParameterDescriptionMessage=Qr;var tn=class tn{constructor(e,t,n){this.length=e,this.parameterName= -t,this.parameterValue=n,this.name="parameterStatus"}};a(tn,"ParameterStatusMessage");var Nr=tn;_.ParameterStatusMessage= -Nr;var rn=class rn{constructor(e,t){this.length=e,this.salt=t,this.name="authenticationMD5Password"}}; -a(rn,"AuthenticationMD5Password");var Wr=rn;_.AuthenticationMD5Password=Wr;var nn=class nn{constructor(e,t,n){ -this.length=e,this.processID=t,this.secretKey=n,this.name="backendKeyData"}};a(nn,"BackendKeyDataMes\ -sage");var jr=nn;_.BackendKeyDataMessage=jr;var sn=class sn{constructor(e,t,n,i){this.length=e,this. -processId=t,this.channel=n,this.payload=i,this.name="notification"}};a(sn,"NotificationResponseMessa\ -ge");var Hr=sn;_.NotificationResponseMessage=Hr;var on=class on{constructor(e,t){this.length=e,this. -status=t,this.name="readyForQuery"}};a(on,"ReadyForQueryMessage");var $r=on;_.ReadyForQueryMessage=$r; -var an=class an{constructor(e,t){this.length=e,this.text=t,this.name="commandComplete"}};a(an,"Comma\ -ndCompleteMessage");var Gr=an;_.CommandCompleteMessage=Gr;var un=class un{constructor(e,t){this.length= -e,this.fields=t,this.name="dataRow",this.fieldCount=t.length}};a(un,"DataRowMessage");var Vr=un;_.DataRowMessage= -Vr;var cn=class cn{constructor(e,t){this.length=e,this.message=t,this.name="notice"}};a(cn,"NoticeMe\ -ssage");var zr=cn;_.NoticeMessage=zr});var Qs=T(Rt=>{"use strict";p();Object.defineProperty(Rt,"__esModule",{value:!0});Rt.Writer=void 0;var hn=class hn{constructor(e=256){ -this.size=e,this.offset=5,this.headerPosition=0,this.buffer=d.allocUnsafe(e)}ensure(e){if(this.buffer. -length-this.offset>1)+e;this.buffer=d.allocUnsafe(i),n.copy( +{name:"copyDone",length:4};var Yr=class Yr extends Error{constructor(e,t,n){super(e),this.length=t,this. +name=n}};a(Yr,"DatabaseError");var Ur=Yr;_.DatabaseError=Ur;var Xr=class Xr{constructor(e,t){this.length= +e,this.chunk=t,this.name="copyData"}};a(Xr,"CopyDataMessage");var Dr=Xr;_.CopyDataMessage=Dr;var Zr=class Zr{constructor(e,t,n,i){ +this.length=e,this.name=t,this.binary=n,this.columnTypes=new Array(i)}};a(Zr,"CopyResponse");var Or=Zr; +_.CopyResponse=Or;var Jr=class Jr{constructor(e,t,n,i,s,o,u){this.name=e,this.tableID=t,this.columnID= +n,this.dataTypeID=i,this.dataTypeSize=s,this.dataTypeModifier=o,this.format=u}};a(Jr,"Field");var Nr=Jr; +_.Field=Nr;var en=class en{constructor(e,t){this.length=e,this.fieldCount=t,this.name="rowDescriptio\ +n",this.fields=new Array(this.fieldCount)}};a(en,"RowDescriptionMessage");var qr=en;_.RowDescriptionMessage= +qr;var tn=class tn{constructor(e,t){this.length=e,this.parameterCount=t,this.name="parameterDescript\ +ion",this.dataTypeIDs=new Array(this.parameterCount)}};a(tn,"ParameterDescriptionMessage");var Qr=tn; +_.ParameterDescriptionMessage=Qr;var rn=class rn{constructor(e,t,n){this.length=e,this.parameterName= +t,this.parameterValue=n,this.name="parameterStatus"}};a(rn,"ParameterStatusMessage");var Wr=rn;_.ParameterStatusMessage= +Wr;var nn=class nn{constructor(e,t){this.length=e,this.salt=t,this.name="authenticationMD5Password"}}; +a(nn,"AuthenticationMD5Password");var jr=nn;_.AuthenticationMD5Password=jr;var sn=class sn{constructor(e,t,n){ +this.length=e,this.processID=t,this.secretKey=n,this.name="backendKeyData"}};a(sn,"BackendKeyDataMes\ +sage");var Hr=sn;_.BackendKeyDataMessage=Hr;var on=class on{constructor(e,t,n,i){this.length=e,this. +processId=t,this.channel=n,this.payload=i,this.name="notification"}};a(on,"NotificationResponseMessa\ +ge");var $r=on;_.NotificationResponseMessage=$r;var an=class an{constructor(e,t){this.length=e,this. +status=t,this.name="readyForQuery"}};a(an,"ReadyForQueryMessage");var Gr=an;_.ReadyForQueryMessage=Gr; +var un=class un{constructor(e,t){this.length=e,this.text=t,this.name="commandComplete"}};a(un,"Comma\ +ndCompleteMessage");var Vr=un;_.CommandCompleteMessage=Vr;var cn=class cn{constructor(e,t){this.length= +e,this.fields=t,this.name="dataRow",this.fieldCount=t.length}};a(cn,"DataRowMessage");var zr=cn;_.DataRowMessage= +zr;var ln=class ln{constructor(e,t){this.length=e,this.message=t,this.name="notice"}};a(ln,"NoticeMe\ +ssage");var Kr=ln;_.NoticeMessage=Kr});var Qs=T(Rt=>{"use strict";d();Object.defineProperty(Rt,"__esModule",{value:!0});Rt.Writer=void 0;var dn=class dn{constructor(e=256){ +this.size=e,this.offset=5,this.headerPosition=0,this.buffer=y.allocUnsafe(e)}ensure(e){if(this.buffer. +length-this.offset>1)+e;this.buffer=y.allocUnsafe(i),n.copy( this.buffer)}}addInt32(e){return this.ensure(4),this.buffer[this.offset++]=e>>>24&255,this.buffer[this. offset++]=e>>>16&255,this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addInt16(e){ return this.ensure(2),this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addCString(e){ -if(!e)this.ensure(1);else{let t=d.byteLength(e);this.ensure(t+1),this.buffer.write(e,this.offset,"ut\ -f-8"),this.offset+=t}return this.buffer[this.offset++]=0,this}addString(e=""){let t=d.byteLength(e); +if(!e)this.ensure(1);else{let t=y.byteLength(e);this.ensure(t+1),this.buffer.write(e,this.offset,"ut\ +f-8"),this.offset+=t}return this.buffer[this.offset++]=0,this}addString(e=""){let t=y.byteLength(e); return this.ensure(t),this.buffer.write(e,this.offset),this.offset+=t,this}add(e){return this.ensure( e.length),e.copy(this.buffer,this.offset),this.offset+=e.length,this}join(e){if(e){this.buffer[this. headerPosition]=e;let t=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(t,this.headerPosition+ 1)}return this.buffer.slice(e?0:5,this.offset)}flush(e){let t=this.join(e);return this.offset=5,this. -headerPosition=0,this.buffer=d.allocUnsafe(this.size),t}};a(hn,"Writer");var fn=hn;Rt.Writer=fn});var Ws=T(Ft=>{"use strict";p();Object.defineProperty(Ft,"__esModule",{value:!0});Ft.serialize=void 0; -var pn=Qs(),F=new pn.Writer,yc=a(r=>{F.addInt16(3).addInt16(0);for(let n of Object.keys(r))F.addCString( -n).addCString(r[n]);F.addCString("client_encoding").addCString("UTF8");let e=F.addCString("").flush(), -t=e.length+4;return new pn.Writer().addInt32(t).add(e).flush()},"startup"),mc=a(()=>{let r=d.allocUnsafe( -8);return r.writeInt32BE(8,0),r.writeInt32BE(80877103,4),r},"requestSsl"),wc=a(r=>F.addCString(r).flush( -112),"password"),gc=a(function(r,e){return F.addCString(r).addInt32(d.byteLength(e)).addString(e),F. -flush(112)},"sendSASLInitialResponseMessage"),bc=a(function(r){return F.addString(r).flush(112)},"se\ -ndSCRAMClientFinalMessage"),vc=a(r=>F.addCString(r).flush(81),"query"),Ns=[],xc=a(r=>{let e=r.name|| +headerPosition=0,this.buffer=y.allocUnsafe(this.size),t}};a(dn,"Writer");var hn=dn;Rt.Writer=hn});var js=T(Ft=>{"use strict";d();Object.defineProperty(Ft,"__esModule",{value:!0});Ft.serialize=void 0; +var pn=Qs(),k=new pn.Writer,mc=a(r=>{k.addInt16(3).addInt16(0);for(let n of Object.keys(r))k.addCString( +n).addCString(r[n]);k.addCString("client_encoding").addCString("UTF8");let e=k.addCString("").flush(), +t=e.length+4;return new pn.Writer().addInt32(t).add(e).flush()},"startup"),wc=a(()=>{let r=y.allocUnsafe( +8);return r.writeInt32BE(8,0),r.writeInt32BE(80877103,4),r},"requestSsl"),gc=a(r=>k.addCString(r).flush( +112),"password"),bc=a(function(r,e){return k.addCString(r).addInt32(y.byteLength(e)).addString(e),k. +flush(112)},"sendSASLInitialResponseMessage"),vc=a(function(r){return k.addString(r).flush(112)},"se\ +ndSCRAMClientFinalMessage"),Sc=a(r=>k.addCString(r).flush(81),"query"),Ws=[],xc=a(r=>{let e=r.name|| "";e.length>63&&(console.error("Warning! Postgres only supports 63 characters for query names."),console. error("You supplied %s (%s)",e,e.length),console.error("This can cause conflicts and silent errors e\ -xecuting queries"));let t=r.types||Ns,n=t.length,i=F.addCString(e).addCString(r.text).addInt16(n);for(let s=0;s< -n;s++)i.addInt32(t[s]);return F.flush(80)},"parse"),qe=new pn.Writer,Sc=a(function(r,e){for(let t=0;t< -r.length;t++){let n=e?e(r[t],t):r[t];n==null?(F.addInt16(0),qe.addInt32(-1)):n instanceof d?(F.addInt16( -1),qe.addInt32(n.length),qe.add(n)):(F.addInt16(0),qe.addInt32(d.byteLength(n)),qe.addString(n))}},"\ -writeValues"),Ec=a((r={})=>{let e=r.portal||"",t=r.statement||"",n=r.binary||!1,i=r.values||Ns,s=i.length; -return F.addCString(e).addCString(t),F.addInt16(s),Sc(i,r.valueMapper),F.addInt16(s),F.add(qe.flush()), -F.addInt16(n?1:0),F.flush(66)},"bind"),Ac=d.from([69,0,0,0,9,0,0,0,0,0]),Cc=a(r=>{if(!r||!r.portal&& -!r.rows)return Ac;let e=r.portal||"",t=r.rows||0,n=d.byteLength(e),i=4+n+1+4,s=d.allocUnsafe(1+i);return s[0]= -69,s.writeInt32BE(i,1),s.write(e,5,"utf-8"),s[n+5]=0,s.writeUInt32BE(t,s.length-4),s},"execute"),_c=a( -(r,e)=>{let t=d.allocUnsafe(16);return t.writeInt32BE(16,0),t.writeInt16BE(1234,4),t.writeInt16BE(5678, -6),t.writeInt32BE(r,8),t.writeInt32BE(e,12),t},"cancel"),dn=a((r,e)=>{let n=4+d.byteLength(e)+1,i=d. +xecuting queries"));let t=r.types||Ws,n=t.length,i=k.addCString(e).addCString(r.text).addInt16(n);for(let s=0;s< +n;s++)i.addInt32(t[s]);return k.flush(80)},"parse"),Oe=new pn.Writer,Ec=a(function(r,e){for(let t=0;t< +r.length;t++){let n=e?e(r[t],t):r[t];n==null?(k.addInt16(0),Oe.addInt32(-1)):n instanceof y?(k.addInt16( +1),Oe.addInt32(n.length),Oe.add(n)):(k.addInt16(0),Oe.addInt32(y.byteLength(n)),Oe.addString(n))}},"\ +writeValues"),Ac=a((r={})=>{let e=r.portal||"",t=r.statement||"",n=r.binary||!1,i=r.values||Ws,s=i.length; +return k.addCString(e).addCString(t),k.addInt16(s),Ec(i,r.valueMapper),k.addInt16(s),k.add(Oe.flush()), +k.addInt16(n?1:0),k.flush(66)},"bind"),Cc=y.from([69,0,0,0,9,0,0,0,0,0]),_c=a(r=>{if(!r||!r.portal&& +!r.rows)return Cc;let e=r.portal||"",t=r.rows||0,n=y.byteLength(e),i=4+n+1+4,s=y.allocUnsafe(1+i);return s[0]= +69,s.writeInt32BE(i,1),s.write(e,5,"utf-8"),s[n+5]=0,s.writeUInt32BE(t,s.length-4),s},"execute"),Ic=a( +(r,e)=>{let t=y.allocUnsafe(16);return t.writeInt32BE(16,0),t.writeInt16BE(1234,4),t.writeInt16BE(5678, +6),t.writeInt32BE(r,8),t.writeInt32BE(e,12),t},"cancel"),yn=a((r,e)=>{let n=4+y.byteLength(e)+1,i=y. allocUnsafe(1+n);return i[0]=r,i.writeInt32BE(n,1),i.write(e,5,"utf-8"),i[n]=0,i},"cstringMessage"), -Ic=F.addCString("P").flush(68),Tc=F.addCString("S").flush(68),Pc=a(r=>r.name?dn(68,`${r.type}${r.name|| -""}`):r.type==="P"?Ic:Tc,"describe"),Bc=a(r=>{let e=`${r.type}${r.name||""}`;return dn(67,e)},"close"), -Rc=a(r=>F.add(r).flush(100),"copyData"),Lc=a(r=>dn(102,r),"copyFail"),Lt=a(r=>d.from([r,0,0,0,4]),"c\ -odeOnlyBuffer"),Fc=Lt(72),kc=Lt(83),Mc=Lt(88),Uc=Lt(99),Dc={startup:yc,password:wc,requestSsl:mc,sendSASLInitialResponseMessage:gc, -sendSCRAMClientFinalMessage:bc,query:vc,parse:xc,bind:Ec,execute:Cc,describe:Pc,close:Bc,flush:a(()=>Fc, -"flush"),sync:a(()=>kc,"sync"),end:a(()=>Mc,"end"),copyData:Rc,copyDone:a(()=>Uc,"copyDone"),copyFail:Lc, -cancel:_c};Ft.serialize=Dc});var js=T(kt=>{"use strict";p();Object.defineProperty(kt,"__esModule",{value:!0});kt.BufferReader=void 0; -var Oc=d.allocUnsafe(0),mn=class mn{constructor(e=0){this.offset=e,this.buffer=Oc,this.encoding="utf\ +Tc=k.addCString("P").flush(68),Pc=k.addCString("S").flush(68),Lc=a(r=>r.name?yn(68,`${r.type}${r.name|| +""}`):r.type==="P"?Tc:Pc,"describe"),Bc=a(r=>{let e=`${r.type}${r.name||""}`;return yn(67,e)},"close"), +Rc=a(r=>k.add(r).flush(100),"copyData"),kc=a(r=>yn(102,r),"copyFail"),kt=a(r=>y.from([r,0,0,0,4]),"c\ +odeOnlyBuffer"),Fc=kt(72),Mc=kt(83),Uc=kt(88),Dc=kt(99),Oc={startup:mc,password:gc,requestSsl:wc,sendSASLInitialResponseMessage:bc, +sendSCRAMClientFinalMessage:vc,query:Sc,parse:xc,bind:Ac,execute:_c,describe:Lc,close:Bc,flush:a(()=>Fc, +"flush"),sync:a(()=>Mc,"sync"),end:a(()=>Uc,"end"),copyData:Rc,copyDone:a(()=>Dc,"copyDone"),copyFail:kc, +cancel:Ic};Ft.serialize=Oc});var Hs=T(Mt=>{"use strict";d();Object.defineProperty(Mt,"__esModule",{value:!0});Mt.BufferReader=void 0; +var Nc=y.allocUnsafe(0),wn=class wn{constructor(e=0){this.offset=e,this.buffer=Nc,this.encoding="utf\ -8"}setBuffer(e,t){this.offset=e,this.buffer=t}int16(){let e=this.buffer.readInt16BE(this.offset);return this. offset+=2,e}byte(){let e=this.buffer[this.offset];return this.offset++,e}int32(){let e=this.buffer.readInt32BE( this.offset);return this.offset+=4,e}uint32(){let e=this.buffer.readUInt32BE(this.offset);return this. offset+=4,e}string(e){let t=this.buffer.toString(this.encoding,this.offset,this.offset+e);return this. offset+=e,t}cstring(){let e=this.offset,t=e;for(;this.buffer[t++]!==0;);return this.offset=t,this.buffer. toString(this.encoding,e,t-1)}bytes(e){let t=this.buffer.slice(this.offset,this.offset+e);return this. -offset+=e,t}};a(mn,"BufferReader");var yn=mn;kt.BufferReader=yn});var Gs=T(Mt=>{"use strict";p();Object.defineProperty(Mt,"__esModule",{value:!0});Mt.Parser=void 0;var k=ln(), -qc=js(),wn=1,Qc=4,Hs=wn+Qc,$s=d.allocUnsafe(0),bn=class bn{constructor(e){if(this.buffer=$s,this.bufferLength= +offset+=e,t}};a(wn,"BufferReader");var mn=wn;Mt.BufferReader=mn});var Vs=T(Ut=>{"use strict";d();Object.defineProperty(Ut,"__esModule",{value:!0});Ut.Parser=void 0;var F=fn(), +qc=Hs(),gn=1,Qc=4,$s=gn+Qc,Gs=y.allocUnsafe(0),vn=class vn{constructor(e){if(this.buffer=Gs,this.bufferLength= 0,this.bufferOffset=0,this.reader=new qc.BufferReader,e?.mode==="binary")throw new Error("Binary mod\ e not supported yet");this.mode=e?.mode||"text"}parse(e,t){this.mergeBuffer(e);let n=this.bufferOffset+ -this.bufferLength,i=this.bufferOffset;for(;i+Hs<=n;){let s=this.buffer[i],o=this.buffer.readUInt32BE( -i+wn),u=wn+o;if(u+i<=n){let c=this.handlePacket(i+Hs,s,o,this.buffer);t(c),i+=u}else break}i===n?(this. -buffer=$s,this.bufferLength=0,this.bufferOffset=0):(this.bufferLength=n-i,this.bufferOffset=i)}mergeBuffer(e){ +this.bufferLength,i=this.bufferOffset;for(;i+$s<=n;){let s=this.buffer[i],o=this.buffer.readUInt32BE( +i+gn),u=gn+o;if(u+i<=n){let c=this.handlePacket(i+$s,s,o,this.buffer);t(c),i+=u}else break}i===n?(this. +buffer=Gs,this.bufferLength=0,this.bufferOffset=0):(this.bufferLength=n-i,this.bufferOffset=i)}mergeBuffer(e){ if(this.bufferLength>0){let t=this.bufferLength+e.byteLength;if(t+this.bufferOffset>this.buffer.byteLength){ let i;if(t<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)i=this.buffer;else{let s=this. -buffer.byteLength*2;for(;t>=s;)s*=2;i=d.allocUnsafe(s)}this.buffer.copy(i,0,this.bufferOffset,this.bufferOffset+ +buffer.byteLength*2;for(;t>=s;)s*=2;i=y.allocUnsafe(s)}this.buffer.copy(i,0,this.bufferOffset,this.bufferOffset+ this.bufferLength),this.buffer=i,this.bufferOffset=0}e.copy(this.buffer,this.bufferOffset+this.bufferLength), this.bufferLength=t}else this.buffer=e,this.bufferOffset=0,this.bufferLength=e.byteLength}handlePacket(e,t,n,i){ -switch(t){case 50:return k.bindComplete;case 49:return k.parseComplete;case 51:return k.closeComplete;case 110: -return k.noData;case 115:return k.portalSuspended;case 99:return k.copyDone;case 87:return k.replicationStart;case 73: -return k.emptyQuery;case 68:return this.parseDataRowMessage(e,n,i);case 67:return this.parseCommandCompleteMessage( +switch(t){case 50:return F.bindComplete;case 49:return F.parseComplete;case 51:return F.closeComplete;case 110: +return F.noData;case 115:return F.portalSuspended;case 99:return F.copyDone;case 87:return F.replicationStart;case 73: +return F.emptyQuery;case 68:return this.parseDataRowMessage(e,n,i);case 67:return this.parseCommandCompleteMessage( e,n,i);case 90:return this.parseReadyForQueryMessage(e,n,i);case 65:return this.parseNotificationMessage( e,n,i);case 82:return this.parseAuthenticationResponse(e,n,i);case 83:return this.parseParameterStatusMessage( e,n,i);case 75:return this.parseBackendKeyData(e,n,i);case 69:return this.parseErrorMessage(e,n,i,"e\ rror");case 78:return this.parseErrorMessage(e,n,i,"notice");case 84:return this.parseRowDescriptionMessage( e,n,i);case 116:return this.parseParameterDescriptionMessage(e,n,i);case 71:return this.parseCopyInMessage( e,n,i);case 72:return this.parseCopyOutMessage(e,n,i);case 100:return this.parseCopyData(e,n,i);default: -return new k.DatabaseError("received invalid response: "+t.toString(16),n,"error")}}parseReadyForQueryMessage(e,t,n){ -this.reader.setBuffer(e,n);let i=this.reader.string(1);return new k.ReadyForQueryMessage(t,i)}parseCommandCompleteMessage(e,t,n){ -this.reader.setBuffer(e,n);let i=this.reader.cstring();return new k.CommandCompleteMessage(t,i)}parseCopyData(e,t,n){ -let i=n.slice(e,e+(t-4));return new k.CopyDataMessage(t,i)}parseCopyInMessage(e,t,n){return this.parseCopyMessage( +return new F.DatabaseError("received invalid response: "+t.toString(16),n,"error")}}parseReadyForQueryMessage(e,t,n){ +this.reader.setBuffer(e,n);let i=this.reader.string(1);return new F.ReadyForQueryMessage(t,i)}parseCommandCompleteMessage(e,t,n){ +this.reader.setBuffer(e,n);let i=this.reader.cstring();return new F.CommandCompleteMessage(t,i)}parseCopyData(e,t,n){ +let i=n.slice(e,e+(t-4));return new F.CopyDataMessage(t,i)}parseCopyInMessage(e,t,n){return this.parseCopyMessage( e,t,n,"copyInResponse")}parseCopyOutMessage(e,t,n){return this.parseCopyMessage(e,t,n,"copyOutRespon\ se")}parseCopyMessage(e,t,n,i){this.reader.setBuffer(e,n);let s=this.reader.byte()!==0,o=this.reader. -int16(),u=new k.CopyResponse(t,i,s,o);for(let c=0;c{"use strict";p();Object.defineProperty(xe,"__esModule",{value:!0});xe.DatabaseError=xe. -serialize=xe.parse=void 0;var Nc=ln();Object.defineProperty(xe,"DatabaseError",{enumerable:!0,get:a( -function(){return Nc.DatabaseError},"get")});var Wc=Ws();Object.defineProperty(xe,"serialize",{enumerable:!0, -get:a(function(){return Wc.serialize},"get")});var jc=Gs();function Hc(r,e){let t=new jc.Parser;return r. -on("data",n=>t.parse(n,e)),new Promise(n=>r.on("end",()=>n()))}a(Hc,"parse");xe.parse=Hc});var Vs={};ie(Vs,{connect:()=>$c});function $c({socket:r,servername:e}){return r.startTls(e),r}var zs=G( -()=>{"use strict";p();a($c,"connect")});var En=T((Xh,Zs)=>{"use strict";p();var Ks=(Fe(),O(wi)),Gc=ge().EventEmitter,{parse:Vc,serialize:Q}=vn(), -Ys=Q.flush(),zc=Q.sync(),Kc=Q.end(),Sn=class Sn extends Gc{constructor(e){super(),e=e||{},this.stream= -e.stream||new Ks.Socket,this._keepAlive=e.keepAlive,this._keepAliveInitialDelayMillis=e.keepAliveInitialDelayMillis, +a(vn,"Parser");var bn=vn;Ut.Parser=bn});var Sn=T(ve=>{"use strict";d();Object.defineProperty(ve,"__esModule",{value:!0});ve.DatabaseError=ve. +serialize=ve.parse=void 0;var Wc=fn();Object.defineProperty(ve,"DatabaseError",{enumerable:!0,get:a( +function(){return Wc.DatabaseError},"get")});var jc=js();Object.defineProperty(ve,"serialize",{enumerable:!0, +get:a(function(){return jc.serialize},"get")});var Hc=Vs();function $c(r,e){let t=new Hc.Parser;return r. +on("data",n=>t.parse(n,e)),new Promise(n=>r.on("end",()=>n()))}a($c,"parse");ve.parse=$c});var zs={};ie(zs,{connect:()=>Gc});function Gc({socket:r,servername:e}){return r.startTls(e),r}var Ks=G( +()=>{"use strict";d();a(Gc,"connect")});var An=T((Jh,Zs)=>{"use strict";d();var Ys=(je(),O(gi)),Vc=we().EventEmitter,{parse:zc,serialize:q}=Sn(), +Xs=q.flush(),Kc=q.sync(),Yc=q.end(),En=class En extends Vc{constructor(e){super(),e=e||{},this.stream= +e.stream||new Ys.Socket,this._keepAlive=e.keepAlive,this._keepAliveInitialDelayMillis=e.keepAliveInitialDelayMillis, this.lastBuffer=!1,this.parsedStatements={},this.ssl=e.ssl||!1,this._ending=!1,this._emitMessage=!1; var t=this;this.on("newListener",function(n){n==="message"&&(t._emitMessage=!0)})}connect(e,t){var n=this; this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect(e,t),this.stream.once("connect",function(){ @@ -972,30 +984,30 @@ stream.on("error",i),this.stream.on("close",function(){n.emit("end")}),!this.ssl this.stream);this.stream.once("data",function(s){var o=s.toString("utf8");switch(o){case"S":break;case"\ N":return n.stream.end(),n.emit("error",new Error("The server does not support SSL connections"));default: return n.stream.end(),n.emit("error",new Error("There was an error establishing an SSL connection"))} -var u=(zs(),O(Vs));let c={socket:n.stream};n.ssl!==!0&&(Object.assign(c,n.ssl),"key"in n.ssl&&(c.key= -n.ssl.key)),Ks.isIP(t)===0&&(c.servername=t);try{n.stream=u.connect(c)}catch(l){return n.emit("error", +var u=(Ks(),O(zs));let c={socket:n.stream};n.ssl!==!0&&(Object.assign(c,n.ssl),"key"in n.ssl&&(c.key= +n.ssl.key)),Ys.isIP(t)===0&&(c.servername=t);try{n.stream=u.connect(c)}catch(l){return n.emit("error", l)}n.attachListeners(n.stream),n.stream.on("error",i),n.emit("sslconnect")})}attachListeners(e){e.on( -"end",()=>{this.emit("end")}),Vc(e,t=>{var n=t.name==="error"?"errorMessage":t.name;this._emitMessage&& -this.emit("message",t),this.emit(n,t)})}requestSsl(){this.stream.write(Q.requestSsl())}startup(e){this. -stream.write(Q.startup(e))}cancel(e,t){this._send(Q.cancel(e,t))}password(e){this._send(Q.password(e))}sendSASLInitialResponseMessage(e,t){ -this._send(Q.sendSASLInitialResponseMessage(e,t))}sendSCRAMClientFinalMessage(e){this._send(Q.sendSCRAMClientFinalMessage( -e))}_send(e){return this.stream.writable?this.stream.write(e):!1}query(e){this._send(Q.query(e))}parse(e){ -this._send(Q.parse(e))}bind(e){this._send(Q.bind(e))}execute(e){this._send(Q.execute(e))}flush(){this. -stream.writable&&this.stream.write(Ys)}sync(){this._ending=!0,this._send(Ys),this._send(zc)}ref(){this. +"end",()=>{this.emit("end")}),zc(e,t=>{var n=t.name==="error"?"errorMessage":t.name;this._emitMessage&& +this.emit("message",t),this.emit(n,t)})}requestSsl(){this.stream.write(q.requestSsl())}startup(e){this. +stream.write(q.startup(e))}cancel(e,t){this._send(q.cancel(e,t))}password(e){this._send(q.password(e))}sendSASLInitialResponseMessage(e,t){ +this._send(q.sendSASLInitialResponseMessage(e,t))}sendSCRAMClientFinalMessage(e){this._send(q.sendSCRAMClientFinalMessage( +e))}_send(e){return this.stream.writable?this.stream.write(e):!1}query(e){this._send(q.query(e))}parse(e){ +this._send(q.parse(e))}bind(e){this._send(q.bind(e))}execute(e){this._send(q.execute(e))}flush(){this. +stream.writable&&this.stream.write(Xs)}sync(){this._ending=!0,this._send(Xs),this._send(Kc)}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(Kc,()=>{this.stream.end()})}close(e){this._send(Q. -close(e))}describe(e){this._send(Q.describe(e))}sendCopyFromChunk(e){this._send(Q.copyData(e))}endCopyFrom(){ -this._send(Q.copyDone())}sendCopyFail(e){this._send(Q.copyFail(e))}};a(Sn,"Connection");var xn=Sn;Zs. -exports=xn});var eo=T((np,Xs)=>{"use strict";p();var Yc=ge().EventEmitter,rp=(it(),O(nt)),Zc=rt(),An=ds(),Jc=Cs(), -Xc=At(),el=Bt(),Js=qs(),tl=tt(),rl=En(),Cn=class Cn extends Yc{constructor(e){super(),this.connectionParameters= -new el(e),this.user=this.connectionParameters.user,this.database=this.connectionParameters.database, +this.stream.end();return}return this.stream.write(Yc,()=>{this.stream.end()})}close(e){this._send(q. +close(e))}describe(e){this._send(q.describe(e))}sendCopyFromChunk(e){this._send(q.copyData(e))}endCopyFrom(){ +this._send(q.copyDone())}sendCopyFail(e){this._send(q.copyFail(e))}};a(En,"Connection");var xn=En;Zs. +exports=xn});var to=T((nd,eo)=>{"use strict";d();var Xc=we().EventEmitter,rd=(it(),O(nt)),Zc=rt(),Cn=ys(),Jc=_s(), +el=Ct(),tl=Bt(),Js=qs(),rl=tt(),nl=An(),_n=class _n extends Xc{constructor(e){super(),this.connectionParameters= +new tl(e),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 t=e||{};this._Promise=t.Promise||b.Promise, -this._types=new Xc(t.types),this._ending=!1,this._connecting=!1,this._connected=!1,this._connectionError= -!1,this._queryable=!0,this.connection=t.connection||new rl({stream:t.stream,ssl:this.connectionParameters. +this.replication=this.connectionParameters.replication;var t=e||{};this._Promise=t.Promise||v.Promise, +this._types=new el(t.types),this._ending=!1,this._connecting=!1,this._connected=!1,this._connectionError= +!1,this._queryable=!0,this.connection=t.connection||new nl({stream:t.stream,ssl:this.connectionParameters. ssl,keepAlive:t.keepAlive||!1,keepAliveInitialDelayMillis:t.keepAliveInitialDelayMillis||0,encoding:this. -connectionParameters.client_encoding||"utf8"}),this.queryQueue=[],this.binary=t.binary||tl.binary,this. +connectionParameters.client_encoding||"utf8"}),this.queryQueue=[],this.binary=t.binary||rl.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=t.connectionTimeoutMillis|| 0}_errorAllQueries(e){let t=a(n=>{m.nextTick(()=>{n.handleError(e,this.connection)})},"enqueueError"); @@ -1030,10 +1042,10 @@ password=this.password=null;e()}).catch(n=>{t.emit("error",n)}):this.password!== n=>{n!==void 0&&(this.connectionParameters.password=this.password=n),e()})}_handleAuthCleartextPassword(e){ this._checkPgPass(()=>{this.connection.password(this.password)})}_handleAuthMD5Password(e){this._checkPgPass( ()=>{let t=Zc.postgresMd5PasswordHash(this.user,this.password,e.salt);this.connection.password(t)})}_handleAuthSASL(e){ -this._checkPgPass(()=>{this.saslSession=An.startSession(e.mechanisms),this.connection.sendSASLInitialResponseMessage( -this.saslSession.mechanism,this.saslSession.response)})}_handleAuthSASLContinue(e){An.continueSession( +this._checkPgPass(()=>{this.saslSession=Cn.startSession(e.mechanisms),this.connection.sendSASLInitialResponseMessage( +this.saslSession.mechanism,this.saslSession.response)})}_handleAuthSASLContinue(e){Cn.continueSession( this.saslSession,this.password,e.data),this.connection.sendSCRAMClientFinalMessage(this.saslSession. -response)}_handleAuthSASLFinal(e){An.finalizeSession(this.saslSession,e.data),this.saslSession=null}_handleBackendKeyData(e){ +response)}_handleAuthSASLFinal(e){Cn.finalizeSession(this.saslSession,e.data),this.saslSession=null}_handleBackendKeyData(e){ this.processID=e.processID,this.secretKey=e.secretKey}_handleReadyForQuery(e){this._connecting&&(this. _connecting=!1,this._connected=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback&& (this._connectionCallback(null,this),this._connectionCallback=null),this.emit("connect"));let{activeQuery:t}=this; @@ -1068,7 +1080,7 @@ handleError(e,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}e "Client was passed a null or undefined query");return typeof e.submit=="function"?(o=e.query_timeout|| this.connectionParameters.query_timeout,s=i=e,typeof t=="function"&&(i.callback=i.callback||t)):(o=this. connectionParameters.query_timeout,i=new Js(e,t,n),i.callback||(s=new this._Promise((l,f)=>{i.callback= -(y,g)=>y?f(y):l(g)}))),o&&(c=i.callback,u=setTimeout(()=>{var l=new Error("Query read timeout");m.nextTick( +(p,g)=>p?f(p):l(g)}))),o&&(c=i.callback,u=setTimeout(()=>{var l=new Error("Query read timeout");m.nextTick( ()=>{i.handleError(l,this.connection)}),c(l),i.callback=()=>{};var f=this.queryQueue.indexOf(i);f>-1&& this.queryQueue.splice(f,1),this._pulseQueryQueue()},o),i.callback=(l,f)=>{clearTimeout(u),c(l,f)}), this.binary&&!i.binary&&(i.binary=!0),i._result&&!i._result._types&&(i._result._types=this._types),this. @@ -1078,23 +1090,23 @@ handleError(new Error("Client has encountered a connection error and is not quer s)}ref(){this.connection.ref()}unref(){this.connection.unref()}end(e){if(this._ending=!0,!this.connection. _connecting)if(e)e();else return this._Promise.resolve();if(this.activeQuery||!this._queryable?this. connection.stream.destroy():this.connection.end(),e)this.connection.once("end",e);else return new this. -_Promise(t=>{this.connection.once("end",t)})}};a(Cn,"Client");var Ut=Cn;Ut.Query=Js;Xs.exports=Ut});var io=T((op,no)=>{"use strict";p();var nl=ge().EventEmitter,to=a(function(){},"NOOP"),ro=a((r,e)=>{ -let t=r.findIndex(e);return t===-1?void 0:r.splice(t,1)[0]},"removeWhere"),Tn=class Tn{constructor(e,t,n){ -this.client=e,this.idleListener=t,this.timeoutId=n}};a(Tn,"IdleItem");var _n=Tn,Pn=class Pn{constructor(e){ -this.callback=e}};a(Pn,"PendingItem");var Qe=Pn;function il(){throw new Error("Release called on cli\ -ent which has already been released to the pool.")}a(il,"throwOnDoubleRelease");function Dt(r,e){if(e) +_Promise(t=>{this.connection.once("end",t)})}};a(_n,"Client");var Dt=_n;Dt.Query=Js;eo.exports=Dt});var so=T((od,io)=>{"use strict";d();var il=we().EventEmitter,ro=a(function(){},"NOOP"),no=a((r,e)=>{ +let t=r.findIndex(e);return t===-1?void 0:r.splice(t,1)[0]},"removeWhere"),Pn=class Pn{constructor(e,t,n){ +this.client=e,this.idleListener=t,this.timeoutId=n}};a(Pn,"IdleItem");var In=Pn,Ln=class Ln{constructor(e){ +this.callback=e}};a(Ln,"PendingItem");var Ne=Ln;function sl(){throw new Error("Release called on cli\ +ent which has already been released to the pool.")}a(sl,"throwOnDoubleRelease");function Ot(r,e){if(e) return{callback:e,result:void 0};let t,n,i=a(function(o,u){o?t(o):n(u)},"cb"),s=new r(function(o,u){ -n=o,t=u}).catch(o=>{throw Error.captureStackTrace(o),o});return{callback:i,result:s}}a(Dt,"promisify"); -function sl(r,e){return a(function t(n){n.client=e,e.removeListener("error",t),e.on("error",()=>{r.log( +n=o,t=u}).catch(o=>{throw Error.captureStackTrace(o),o});return{callback:i,result:s}}a(Ot,"promisify"); +function ol(r,e){return a(function t(n){n.client=e,e.removeListener("error",t),e.on("error",()=>{r.log( "additional client error after disconnection due to error",n)}),r._remove(e),r.emit("error",n,e)},"i\ -dleListener")}a(sl,"makeIdleListener");var Bn=class Bn extends nl{constructor(e,t){super(),this.options= +dleListener")}a(ol,"makeIdleListener");var Bn=class Bn extends il{constructor(e,t){super(),this.options= Object.assign({},e),e!=null&&"password"in e&&Object.defineProperty(this.options,"password",{configurable:!0, enumerable:!1,writable:!0,value:e.password}),e!=null&&e.ssl&&e.ssl.key&&Object.defineProperty(this.options. ssl,"key",{enumerable:!1}),this.options.max=this.options.max||this.options.poolSize||10,this.options. min=this.options.min||0,this.options.maxUses=this.options.maxUses||1/0,this.options.allowExitOnIdle= this.options.allowExitOnIdle||!1,this.options.maxLifetimeSeconds=this.options.maxLifetimeSeconds||0, this.log=this.options.log||function(){},this.Client=this.options.Client||t||ot().Client,this.Promise= -this.options.Promise||b.Promise,typeof this.options.idleTimeoutMillis>"u"&&(this.options.idleTimeoutMillis= +this.options.Promise||v.Promise,typeof this.options.idleTimeoutMillis>"u"&&(this.options.idleTimeoutMillis= 1e4),this._clients=[],this._idle=[],this._expired=new WeakSet,this._pendingQueue=[],this._endCallback= void 0,this.ending=!1,this.ended=!1}_isFull(){return this._clients.length>=this.options.max}_isAboveMin(){ return this._clients.length>this.options.min}_pulseQueue(){if(this.log("pulse queue"),this.ended){this. @@ -1103,47 +1115,47 @@ this._idle.slice().map(t=>{this._remove(t.client)}),this._clients.length||(this. return}if(!this._pendingQueue.length){this.log("no queued requests");return}if(!this._idle.length&&this. _isFull())return;let e=this._pendingQueue.shift();if(this._idle.length){let t=this._idle.pop();clearTimeout( t.timeoutId);let n=t.client;n.ref&&n.ref();let i=t.idleListener;return this._acquireClient(n,e,i,!1)} -if(!this._isFull())return this.newClient(e);throw new Error("unexpected condition")}_remove(e){let t=ro( +if(!this._isFull())return this.newClient(e);throw new Error("unexpected condition")}_remove(e){let t=no( this._idle,n=>n.client===e);t!==void 0&&clearTimeout(t.timeoutId),this._clients=this._clients.filter( n=>n!==e),e.end(),this.emit("remove",e)}connect(e){if(this.ending){let i=new Error("Cannot use a poo\ -l after calling end on the pool");return e?e(i):this.Promise.reject(i)}let t=Dt(this.Promise,e),n=t. +l after calling end on the pool");return e?e(i):this.Promise.reject(i)}let t=Ot(this.Promise,e),n=t. result;if(this._isFull()||this._idle.length){if(this._idle.length&&m.nextTick(()=>this._pulseQueue()), -!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new Qe(t.callback)),n;let i=a((u,c,l)=>{ -clearTimeout(o),t.callback(u,c,l)},"queueCallback"),s=new Qe(i),o=setTimeout(()=>{ro(this._pendingQueue, +!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new Ne(t.callback)),n;let i=a((u,c,l)=>{ +clearTimeout(o),t.callback(u,c,l)},"queueCallback"),s=new Ne(i),o=setTimeout(()=>{no(this._pendingQueue, u=>u.callback===i),s.timedOut=!0,t.callback(new Error("timeout exceeded when trying to connect"))},this. options.connectionTimeoutMillis);return o.unref&&o.unref(),this._pendingQueue.push(s),n}return this. -newClient(new Qe(t.callback)),n}newClient(e){let t=new this.Client(this.options);this._clients.push( -t);let n=sl(this,t);this.log("checking client timeout");let i,s=!1;this.options.connectionTimeoutMillis&& +newClient(new Ne(t.callback)),n}newClient(e){let t=new this.Client(this.options);this._clients.push( +t);let n=ol(this,t);this.log("checking client timeout");let i,s=!1;this.options.connectionTimeoutMillis&& (i=setTimeout(()=>{this.log("ending client due to timeout"),s=!0,t.connection?t.connection.stream.destroy(): t.end()},this.options.connectionTimeoutMillis)),this.log("connecting new client"),t.connect(o=>{if(i&& clearTimeout(i),t.on("error",n),o)this.log("client failed to connect",o),this._clients=this._clients. filter(u=>u!==t),s&&(o=new Error("Connection terminated due to connection timeout",{cause:o})),this. -_pulseQueue(),e.timedOut||e.callback(o,void 0,to);else{if(this.log("new client connected"),this.options. +_pulseQueue(),e.timedOut||e.callback(o,void 0,ro);else{if(this.log("new client connected"),this.options. maxLifetimeSeconds!==0){let u=setTimeout(()=>{this.log("ending client due to expired lifetime"),this. -_expired.add(t),this._idle.findIndex(l=>l.client===t)!==-1&&this._acquireClient(t,new Qe((l,f,y)=>y()), +_expired.add(t),this._idle.findIndex(l=>l.client===t)!==-1&&this._acquireClient(t,new Ne((l,f,p)=>p()), n,!1)},this.options.maxLifetimeSeconds*1e3);u.unref(),t.once("end",()=>clearTimeout(u))}return this. _acquireClient(t,e,n,!0)}})}_acquireClient(e,t,n,i){i&&this.emit("connect",e),this.emit("acquire",e), e.release=this._releaseOnce(e,n),e.removeListener("error",n),t.timedOut?i&&this.options.verify?this. options.verify(e,e.release):e.release():i&&this.options.verify?this.options.verify(e,s=>{if(s)return e. -release(s),t.callback(s,void 0,to);t.callback(void 0,e,e.release)}):t.callback(void 0,e,e.release)}_releaseOnce(e,t){ -let n=!1;return i=>{n&&il(),n=!0,this._release(e,t,i)}}_release(e,t,n){if(e.on("error",t),e._poolUseCount= +release(s),t.callback(s,void 0,ro);t.callback(void 0,e,e.release)}):t.callback(void 0,e,e.release)}_releaseOnce(e,t){ +let n=!1;return i=>{n&&sl(),n=!0,this._release(e,t,i)}}_release(e,t,n){if(e.on("error",t),e._poolUseCount= (e._poolUseCount||0)+1,this.emit("release",n,e),n||this.ending||!e._queryable||e._ending||e._poolUseCount>= this.options.maxUses){e._poolUseCount>=this.options.maxUses&&this.log("remove expended client"),this. _remove(e),this._pulseQueue();return}if(this._expired.has(e)){this.log("remove expired client"),this. _expired.delete(e),this._remove(e),this._pulseQueue();return}let s;this.options.idleTimeoutMillis&&this. _isAboveMin()&&(s=setTimeout(()=>{this.log("remove idle client"),this._remove(e)},this.options.idleTimeoutMillis), -this.options.allowExitOnIdle&&s.unref()),this.options.allowExitOnIdle&&e.unref(),this._idle.push(new _n( -e,t,s)),this._pulseQueue()}query(e,t,n){if(typeof e=="function"){let s=Dt(this.Promise,e);return v(function(){ +this.options.allowExitOnIdle&&s.unref()),this.options.allowExitOnIdle&&e.unref(),this._idle.push(new In( +e,t,s)),this._pulseQueue()}query(e,t,n){if(typeof e=="function"){let s=Ot(this.Promise,e);return S(function(){ return s.callback(new Error("Passing a function as the first parameter to pool.query is not supporte\ -d"))}),s.result}typeof t=="function"&&(n=t,t=void 0);let i=Dt(this.Promise,n);return n=i.callback,this. +d"))}),s.result}typeof t=="function"&&(n=t,t=void 0);let i=Ot(this.Promise,n);return n=i.callback,this. connect((s,o)=>{if(s)return n(s);let u=!1,c=a(l=>{u||(u=!0,o.release(l),n(l))},"onError");o.once("er\ ror",c),this.log("dispatching query");try{o.query(e,t,(l,f)=>{if(this.log("query dispatched"),o.removeListener( "error",c),!u)return u=!0,o.release(l),l?n(l):n(void 0,f)})}catch(l){return o.release(l),n(l)}}),i.result}end(e){ if(this.log("ending"),this.ending){let n=new Error("Called end on pool more than once");return e?e(n): -this.Promise.reject(n)}this.ending=!0;let t=Dt(this.Promise,e);return this._endCallback=t.callback,this. +this.Promise.reject(n)}this.ending=!0;let t=Ot(this.Promise,e);return this._endCallback=t.callback,this. _pulseQueue(),t.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this. _idle.length}get expiredCount(){return this._clients.reduce((e,t)=>e+(this._expired.has(t)?1:0),0)}get totalCount(){ -return this._clients.length}};a(Bn,"Pool");var In=Bn;no.exports=In});var so={};ie(so,{default:()=>ol});var ol,oo=G(()=>{"use strict";p();ol={}});var ao=T((lp,al)=>{al.exports={name:"pg",version:"8.8.0",description:"PostgreSQL client - pure javas\ +return this._clients.length}};a(Bn,"Pool");var Tn=Bn;io.exports=Tn});var oo={};ie(oo,{default:()=>al});var al,ao=G(()=>{"use strict";d();al={}});var uo=T((ld,ul)=>{ul.exports={name:"pg",version:"8.8.0",description:"PostgreSQL client - pure javas\ cript & libpq with the same API",keywords:["database","libpq","pg","postgre","postgres","postgresql", "rdbms"],homepage:"https://github.com/brianc/node-postgres",repository:{type:"git",url:"git://github\ .com/brianc/node-postgres.git",directory:"packages/pg"},author:"Brian Carlson =3.0.1"},peerDependenciesMeta:{"pg-native":{optional:!0}},scripts:{test:"make test-all"},files:["li\ b","SPONSORS.md"],license:"MIT",engines:{node:">= 8.0.0"},gitHead:"c99fb2c127ddf8d712500db2c7b9a5491\ -a178655"}});var lo=T((fp,co)=>{"use strict";p();var uo=ge().EventEmitter,ul=(it(),O(nt)),Rn=rt(),Ne=co.exports=function(r,e,t){ -uo.call(this),r=Rn.normalizeQueryConfig(r,e,t),this.text=r.text,this.values=r.values,this.name=r.name, +a178655"}});var fo=T((fd,lo)=>{"use strict";d();var co=we().EventEmitter,cl=(it(),O(nt)),Rn=rt(),qe=lo.exports=function(r,e,t){ +co.call(this),r=Rn.normalizeQueryConfig(r,e,t),this.text=r.text,this.values=r.values,this.name=r.name, this.callback=r.callback,this.state="new",this._arrayMode=r.rowMode==="array",this._emitRowEvents=!1, -this.on("newListener",function(n){n==="row"&&(this._emitRowEvents=!0)}.bind(this))};ul.inherits(Ne,uo); -var cl={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"\ +this.on("newListener",function(n){n==="row"&&(this._emitRowEvents=!0)}.bind(this))};cl.inherits(qe,co); +var ll={sqlState:"code",statementPosition:"position",messagePrimary:"message",context:"where",schemaName:"\ schema",tableName:"table",columnName:"column",dataTypeName:"dataType",constraintName:"constraint",sourceFile:"\ -file",sourceLine:"line",sourceFunction:"routine"};Ne.prototype.handleError=function(r){var e=this.native. -pq.resultErrorFields();if(e)for(var t in e){var n=cl[t]||t;r[n]=e[t]}this.callback?this.callback(r): -this.emit("error",r),this.state="error"};Ne.prototype.then=function(r,e){return this._getPromise().then( -r,e)};Ne.prototype.catch=function(r){return this._getPromise().catch(r)};Ne.prototype._getPromise=function(){ +file",sourceLine:"line",sourceFunction:"routine"};qe.prototype.handleError=function(r){var e=this.native. +pq.resultErrorFields();if(e)for(var t in e){var n=ll[t]||t;r[n]=e[t]}this.callback?this.callback(r): +this.emit("error",r),this.state="error"};qe.prototype.then=function(r,e){return this._getPromise().then( +r,e)};qe.prototype.catch=function(r){return this._getPromise().catch(r)};qe.prototype._getPromise=function(){ return this._promise?this._promise:(this._promise=new Promise(function(r,e){this._once("end",r),this. -_once("error",e)}.bind(this)),this._promise)};Ne.prototype.submit=function(r){this.state="running";var e=this; +_once("error",e)}.bind(this)),this._promise)};qe.prototype.submit=function(r){this.state="running";var e=this; this.native=r.native,r.native.arrayMode=this._arrayMode;var t=a(function(s,o,u){if(r.native.arrayMode= -!1,v(function(){e.emit("_done")}),s)return e.handleError(s);e._emitRowEvents&&(u.length>1?o.forEach( +!1,S(function(){e.emit("_done")}),s)return e.handleError(s);e._emitRowEvents&&(u.length>1?o.forEach( (c,l)=>{c.forEach(f=>{e.emit("row",f,u[l])})}):o.forEach(function(c){e.emit("row",c,u)})),e.state="e\ nd",e.emit("end",u),e.callback&&e.callback(null,u)},"after");if(m.domain&&(t=m.domain.bind(t)),this. name){this.name.length>63&&(console.error("Warning! Postgres only supports 63 characters for query n\ @@ -1176,13 +1188,13 @@ red statements must be unique - '${this.name}' was used for a different statemen native.execute(this.name,n,t)}return r.native.prepare(this.name,this.text,n.length,function(s){return s? t(s):(r.namedQueries[e.name]=e.text,e.native.execute(e.name,n,t))})}else if(this.values){if(!Array.isArray( this.values)){let s=new Error("Query values must be an array");return t(s)}var i=this.values.map(Rn. -prepareValue);r.native.query(this.text,i,t)}else r.native.query(this.text,t)}});var yo=T((yp,po)=>{"use strict";p();var ll=(oo(),O(so)),fl=At(),dp=ao(),fo=ge().EventEmitter,hl=(it(),O(nt)), -pl=Bt(),ho=lo(),K=po.exports=function(r){fo.call(this),r=r||{},this._Promise=r.Promise||b.Promise,this. -_types=new fl(r.types),this.native=new ll({types:this._types}),this._queryQueue=[],this._ending=!1,this. +prepareValue);r.native.query(this.text,i,t)}else r.native.query(this.text,t)}});var mo=T((yd,yo)=>{"use strict";d();var fl=(ao(),O(oo)),hl=Ct(),pd=uo(),ho=we().EventEmitter,dl=(it(),O(nt)), +pl=Bt(),po=fo(),K=yo.exports=function(r){ho.call(this),r=r||{},this._Promise=r.Promise||v.Promise,this. +_types=new hl(r.types),this.native=new fl({types:this._types}),this._queryQueue=[],this._ending=!1,this. _connecting=!1,this._connected=!1,this._queryable=!0;var e=this.connectionParameters=new pl(r);this. user=e.user,Object.defineProperty(this,"password",{configurable:!0,enumerable:!1,writable:!0,value:e. password}),this.database=e.database,this.host=e.host,this.port=e.port,this.namedQueries={}};K.Query= -ho;hl.inherits(K,fo);K.prototype._errorAllQueries=function(r){let e=a(t=>{m.nextTick(()=>{t.native=this. +po;dl.inherits(K,ho);K.prototype._errorAllQueries=function(r){let e=a(t=>{m.nextTick(()=>{t.native=this. native,t.handleError(r)})},"enqueueError");this._hasActiveQuery()&&(e(this._activeQuery),this._activeQuery= null),this._queryQueue.forEach(e),this._queryQueue.length=0};K.prototype._connect=function(r){var e=this; if(this._connecting){m.nextTick(()=>r(new Error("Client has already been connected. You cannot reuse\ @@ -1194,8 +1206,8 @@ _pulseQueryQueue(!0),r()})})};K.prototype.connect=function(r){if(r){this._connec _Promise((e,t)=>{this._connect(n=>{n?t(n):e()})})};K.prototype.query=function(r,e,t){var n,i,s,o,u;if(r== null)throw new TypeError("Client was passed a null or undefined query");if(typeof r.submit=="functio\ n")s=r.query_timeout||this.connectionParameters.query_timeout,i=n=r,typeof e=="function"&&(r.callback= -e);else if(s=this.connectionParameters.query_timeout,n=new ho(r,e,t),!n.callback){let c,l;i=new this. -_Promise((f,y)=>{c=f,l=y}),n.callback=(f,y)=>f?l(f):c(y)}return s&&(u=n.callback,o=setTimeout(()=>{var c=new Error( +e);else if(s=this.connectionParameters.query_timeout,n=new po(r,e,t),!n.callback){let c,l;i=new this. +_Promise((f,p)=>{c=f,l=p}),n.callback=(f,p)=>f?l(f):c(p)}return s&&(u=n.callback,o=setTimeout(()=>{var c=new Error( "Query read timeout");m.nextTick(()=>{n.handleError(c,this.connection)}),u(c),n.callback=()=>{};var l=this. _queryQueue.indexOf(n);l>-1&&this._queryQueue.splice(l,1),this._pulseQueryQueue()},s),n.callback=(c,l)=>{ clearTimeout(o),u(c,l)}),this._queryable?this._ending?(n.native=this.native,m.nextTick(()=>{n.handleError( @@ -1211,36 +1223,36 @@ in");return}this._activeQuery=e,e.submit(this);var t=this;e.once("_done",functio K.prototype.cancel=function(r){this._activeQuery===r?this.native.cancel(function(){}):this._queryQueue. indexOf(r)!==-1&&this._queryQueue.splice(this._queryQueue.indexOf(r),1)};K.prototype.ref=function(){}; K.prototype.unref=function(){};K.prototype.setTypeParser=function(r,e,t){return this._types.setTypeParser( -r,e,t)};K.prototype.getTypeParser=function(r,e){return this._types.getTypeParser(r,e)}});var Ln=T((gp,mo)=>{"use strict";p();mo.exports=yo()});var ot=T((vp,at)=>{"use strict";p();var dl=eo(),yl=tt(),ml=En(),wl=io(),{DatabaseError:gl}=vn(),bl=a( -r=>{var e;return e=class extends wl{constructor(n){super(n,r)}},a(e,"BoundPool"),e},"poolFactory"),Fn=a( -function(r){this.defaults=yl,this.Client=r,this.Query=this.Client.Query,this.Pool=bl(this.Client),this. -_pools=[],this.Connection=ml,this.types=Je(),this.DatabaseError=gl},"PG");typeof m.env.NODE_PG_FORCE_NATIVE< -"u"?at.exports=new Fn(Ln()):(at.exports=new Fn(dl),Object.defineProperty(at.exports,"native",{configurable:!0, -enumerable:!1,get(){var r=null;try{r=new Fn(Ln())}catch(e){if(e.code!=="MODULE_NOT_FOUND")throw e}return Object. -defineProperty(at.exports,"native",{value:r}),r}}))});p();p();Fe();Zt();p();var pa=Object.defineProperty,da=Object.defineProperties,ya=Object.getOwnPropertyDescriptors,bi=Object. -getOwnPropertySymbols,ma=Object.prototype.hasOwnProperty,wa=Object.prototype.propertyIsEnumerable,vi=a( +r,e,t)};K.prototype.getTypeParser=function(r,e){return this._types.getTypeParser(r,e)}});var kn=T((gd,wo)=>{"use strict";d();wo.exports=mo()});var ot=T((vd,at)=>{"use strict";d();var yl=to(),ml=tt(),wl=An(),gl=so(),{DatabaseError:bl}=Sn(),vl=a( +r=>{var e;return e=class extends gl{constructor(n){super(n,r)}},a(e,"BoundPool"),e},"poolFactory"),Fn=a( +function(r){this.defaults=ml,this.Client=r,this.Query=this.Client.Query,this.Pool=vl(this.Client),this. +_pools=[],this.Connection=wl,this.types=Ze(),this.DatabaseError=bl},"PG");typeof m.env.NODE_PG_FORCE_NATIVE< +"u"?at.exports=new Fn(kn()):(at.exports=new Fn(yl),Object.defineProperty(at.exports,"native",{configurable:!0, +enumerable:!1,get(){var r=null;try{r=new Fn(kn())}catch(e){if(e.code!=="MODULE_NOT_FOUND")throw e}return Object. +defineProperty(at.exports,"native",{value:r}),r}}))});d();d();je();Zt();d();var pa=Object.defineProperty,ya=Object.defineProperties,ma=Object.getOwnPropertyDescriptors,vi=Object. +getOwnPropertySymbols,wa=Object.prototype.hasOwnProperty,ga=Object.prototype.propertyIsEnumerable,Si=a( (r,e,t)=>e in r?pa(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,"__defNormalProp"), -ga=a((r,e)=>{for(var t in e||(e={}))ma.call(e,t)&&vi(r,t,e[t]);if(bi)for(var t of bi(e))wa.call(e,t)&& -vi(r,t,e[t]);return r},"__spreadValues"),ba=a((r,e)=>da(r,ya(e)),"__spreadProps"),va=1008e3,xi=new Uint8Array( -new Uint16Array([258]).buffer)[0]===2,xa=new TextDecoder,Jt=new TextEncoder,yt=Jt.encode("0123456789\ -abcdef"),mt=Jt.encode("0123456789ABCDEF"),Sa=Jt.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr\ -stuvwxyz0123456789+/");var Si=Sa.slice();Si[62]=45;Si[63]=95;var He,wt;function Ea(r,{alphabet:e,scratchArr:t}={}){if(!He)if(He= -new Uint16Array(256),wt=new Uint16Array(256),xi)for(let C=0;C<256;C++)He[C]=yt[C&15]<<8|yt[C>>>4],wt[C]= -mt[C&15]<<8|mt[C>>>4];else for(let C=0;C<256;C++)He[C]=yt[C&15]|yt[C>>>4]<<8,wt[C]=mt[C&15]|mt[C>>>4]<< +ba=a((r,e)=>{for(var t in e||(e={}))wa.call(e,t)&&Si(r,t,e[t]);if(vi)for(var t of vi(e))ga.call(e,t)&& +Si(r,t,e[t]);return r},"__spreadValues"),va=a((r,e)=>ya(r,ma(e)),"__spreadProps"),Sa=1008e3,xi=new Uint8Array( +new Uint16Array([258]).buffer)[0]===2,xa=new TextDecoder,Jt=new TextEncoder,mt=Jt.encode("0123456789\ +abcdef"),wt=Jt.encode("0123456789ABCDEF"),Ea=Jt.encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr\ +stuvwxyz0123456789+/");var Ei=Ea.slice();Ei[62]=45;Ei[63]=95;var He,gt;function Aa(r,{alphabet:e,scratchArr:t}={}){if(!He)if(He= +new Uint16Array(256),gt=new Uint16Array(256),xi)for(let C=0;C<256;C++)He[C]=mt[C&15]<<8|mt[C>>>4],gt[C]= +wt[C&15]<<8|wt[C>>>4];else for(let C=0;C<256;C++)He[C]=mt[C&15]|mt[C>>>4]<<8,gt[C]=wt[C&15]|wt[C>>>4]<< 8;r.byteOffset%4!==0&&(r=new Uint8Array(r));let n=r.length,i=n>>>1,s=n>>>2,o=t||new Uint16Array(n),u=new Uint32Array( -r.buffer,r.byteOffset,s),c=new Uint32Array(o.buffer,o.byteOffset,i),l=e==="upper"?wt:He,f=0,y=0,g;if(xi) -for(;f>>8&255]<<16|l[g&255],c[y++]=l[g>>>24]<<16|l[g>>>16&255];else for(;f>>24]<<16|l[g>>>16&255],c[y++]=l[g>>>8&255]<<16|l[g&255];for(f<<=2;f>>1,s=Math. -ceil(n/i),o=new Uint16Array(s>1?i:n);for(let u=0;u>>8&255]<<16|l[g&255],c[p++]=l[g>>>24]<<16|l[g>>>16&255];else for(;f>>24]<<16|l[g>>>16&255],c[p++]=l[g>>>8&255]<<16|l[g&255];for(f<<=2;f>>1,s=Math. +ceil(n/i),o=new Uint16Array(s>1?i:n);for(let u=0;uLu((0,us.prepareValue)(n)))}}a(ss,"prep\ -areQuery");function cs(r,{arrayMode:e,fullResults:t,fetchOptions:n,isolationLevel:i,readOnly:s,deferrable:o, +ry","where","schema","table","column","dataType","constraint","file","line","routine"];function ku(r){ +return r instanceof y?"\\x"+Ai(r):r}a(ku,"encodeBuffersAsBytea");function os(r){let{query:e,params:t}=r instanceof +$e?r.toParameterizedQuery():r;return{query:e,params:t.map(n=>ku((0,cs.prepareValue)(n)))}}a(os,"prep\ +areQuery");function ls(r,{arrayMode:e,fullResults:t,fetchOptions:n,isolationLevel:i,readOnly:s,deferrable:o, authToken:u,disableWarningInBrowsers:c}={}){if(!r)throw new Error("No database connection string was\ - provided to `neon()`. Perhaps an environment variable has not been set?");let l;try{l=Yt(r)}catch{throw new Error( + provided to `neon()`. Perhaps an environment variable has not been set?");let l;try{l=Xt(r)}catch{throw new Error( "Database connection string provided to `neon()` is not a valid URL. Connection string: "+String(r))} -let{protocol:f,username:y,hostname:g,port:A,pathname:C}=l;if(f!=="postgres:"&&f!=="postgresql:"||!y|| +let{protocol:f,username:p,hostname:g,port:E,pathname:C}=l;if(f!=="postgres:"&&f!=="postgresql:"||!p|| !g||!C)throw new Error("Database connection string format for `neon()` should be: postgresql://user:\ password@host.tld/dbname?option=value");function D(P,...I){if(!(Array.isArray(P)&&Array.isArray(P.raw)&& Array.isArray(I)))throw new Error('This function can now be called only as a tagged-template functio\ n: sql`SELECT ${value}`, not sql("SELECT $1", [value], options). For a conventional function call wi\ th value placeholders ($1, $2, etc.), use sql.query("SELECT $1", [value], options).');return new Ce( Y,new $e(P,I))}a(D,"templateFn"),D.query=(P,I,w)=>new Ce(Y,{query:P,params:I??[]},w),D.unsafe=P=>new Ge( -P),D.transaction=async(P,I)=>{if(typeof P=="function"&&(P=P(D)),!Array.isArray(P))throw new Error(is); -P.forEach(W=>{if(!(W instanceof Ce))throw new Error(is)});let w=P.map(W=>W.queryData),Z=P.map(W=>W.opts?? -{});return Y(w,Z,I)};async function Y(P,I,w){let{fetchEndpoint:Z,fetchFunction:W}=ce,J=Array.isArray( -P)?{queries:P.map(ee=>ss(ee))}:ss(P),X=n??{},se=e??!1,oe=t??!1,R=i,j=s,le=o;w!==void 0&&(w.fetchOptions!== -void 0&&(X={...X,...w.fetchOptions}),w.arrayMode!==void 0&&(se=w.arrayMode),w.fullResults!==void 0&& -(oe=w.fullResults),w.isolationLevel!==void 0&&(R=w.isolationLevel),w.readOnly!==void 0&&(j=w.readOnly), -w.deferrable!==void 0&&(le=w.deferrable)),I!==void 0&&!Array.isArray(I)&&I.fetchOptions!==void 0&&(X= -{...X,...I.fetchOptions});let de=u;!Array.isArray(I)&&I?.authToken!==void 0&&(de=I.authToken);let We=typeof Z== -"function"?Z(g,A,{jwtAuth:de!==void 0}):Z,fe={"Neon-Connection-String":r,"Neon-Raw-Text-Output":"tru\ -e","Neon-Array-Mode":"true"},_e=await Fu(de);_e&&(fe.Authorization=`Bearer ${_e}`),Array.isArray(P)&& -(R!==void 0&&(fe["Neon-Batch-Isolation-Level"]=R),j!==void 0&&(fe["Neon-Batch-Read-Only"]=String(j)), -le!==void 0&&(fe["Neon-Batch-Deferrable"]=String(le))),c||ce.disableWarningInBrowsers||bt();let ye;try{ -ye=await(W??fetch)(We,{method:"POST",body:JSON.stringify(J),headers:fe,...X})}catch(ee){let M=new be( -`Error connecting to database: ${ee}`);throw M.sourceError=ee,M}if(ye.ok){let ee=await ye.json();if(Array. -isArray(P)){let M=ee.results;if(!Array.isArray(M))throw new be("Neon internal error: unexpected resu\ -lt format");return M.map(($,me)=>{let Ot=I[me]??{},vo=Ot.arrayMode??se,xo=Ot.fullResults??oe;return os( -$,{arrayMode:vo,fullResults:xo,types:Ot.types})})}else{let M=I??{},$=M.arrayMode??se,me=M.fullResults?? -oe;return os(ee,{arrayMode:$,fullResults:me,types:M.types})}}else{let{status:ee}=ye;if(ee===400){let M=await ye. -json(),$=new be(M.message);for(let me of Ru)$[me]=M[me]??void 0;throw $}else{let M=await ye.text();throw new be( -`Server error (HTTP status ${ee}): ${M}`)}}}return a(Y,"execute"),D}a(cs,"neon");var dr=class dr{constructor(e,t,n){ +P),D.transaction=async(P,I)=>{if(typeof P=="function"&&(P=P(D)),!Array.isArray(P))throw new Error(ss); +P.forEach(j=>{if(!(j instanceof Ce))throw new Error(ss)});let w=P.map(j=>j.queryData),X=P.map(j=>j.opts?? +{});return Y(w,X,I)};async function Y(P,I,w){let{fetchEndpoint:X,fetchFunction:j,isNeonLocal:Z}=le,he=Array. +isArray(P)?{queries:P.map(Q=>os(Q))}:os(P),J=n??{},se=e??!1,B=t??!1,H=i,ue=s,de=o;w!==void 0&&(w.fetchOptions!== +void 0&&(J={...J,...w.fetchOptions}),w.arrayMode!==void 0&&(se=w.arrayMode),w.fullResults!==void 0&& +(B=w.fullResults),w.isolationLevel!==void 0&&(H=w.isolationLevel),w.readOnly!==void 0&&(ue=w.readOnly), +w.deferrable!==void 0&&(de=w.deferrable)),I!==void 0&&!Array.isArray(I)&&I.fetchOptions!==void 0&&(J= +{...J,...I.fetchOptions});let Se=u;!Array.isArray(I)&&I?.authToken!==void 0&&(Se=I.authToken);let Qe=typeof X== +"function"?X(g,E,{jwtAuth:Se!==void 0}):X,ee={"Neon-Connection-String":r,"Neon-Raw-Text-Output":"tru\ +e","Neon-Array-Mode":"true"};Z&&(ee["X-Neon-User"]=p,ee["X-Neon-Password"]=l.password||"",ee["X-Neon\ +-Database"]=C.slice(1));let lt=await Fu(Se);lt&&(ee.Authorization=`Bearer ${lt}`),Array.isArray(P)&& +(H!==void 0&&(ee["Neon-Batch-Isolation-Level"]=H),ue!==void 0&&(ee["Neon-Batch-Read-Only"]=String(ue)), +de!==void 0&&(ee["Neon-Batch-Deferrable"]=String(de))),c||le.disableWarningInBrowsers||vt();let pe;try{ +pe=await(j??fetch)(Qe,{method:"POST",body:JSON.stringify(he),headers:ee,...J})}catch(Q){let M=new ge( +`Error connecting to database: ${Q}`);throw M.sourceError=Q,M}if(pe.ok){let Q=await pe.json();if(Array. +isArray(P)){let M=Q.results;if(!Array.isArray(M))throw new ge("Neon internal error: unexpected resul\ +t format");return M.map((ye,_e)=>{let Nt=I[_e]??{},So=Nt.arrayMode??se,xo=Nt.fullResults??B;return as( +ye,{arrayMode:So,fullResults:xo,types:Nt.types})})}else{let M=I??{},ye=M.arrayMode??se,_e=M.fullResults?? +B;return as(Q,{arrayMode:ye,fullResults:_e,types:M.types})}}else{let{status:Q}=pe;if(Q===400){let M=await pe. +json(),ye=new ge(M.message);for(let _e of Ru)ye[_e]=M[_e]??void 0;throw ye}else{let M=await pe.text(); +throw new ge(`Server error (HTTP status ${Q}): ${M}`)}}}return a(Y,"execute"),D}a(ls,"neon");var yr=class yr{constructor(e,t,n){ this.execute=e;this.queryData=t;this.opts=n}then(e,t){return this.execute(this.queryData,this.opts). then(e,t)}catch(e){return this.execute(this.queryData,this.opts).catch(e)}finally(e){return this.execute( -this.queryData,this.opts).finally(e)}};a(dr,"NeonQueryPromise");var Ce=dr;function os(r,{arrayMode:e, -fullResults:t,types:n}){let i=new as.default(n),s=r.fields.map(c=>c.name),o=r.fields.map(c=>i.getTypeParser( +this.queryData,this.opts).finally(e)}};a(yr,"NeonQueryPromise");var Ce=yr;function as(r,{arrayMode:e, +fullResults:t,types:n}){let i=new us.default(n),s=r.fields.map(c=>c.name),o=r.fields.map(c=>i.getTypeParser( c.dataTypeID)),u=e===!0?r.rows.map(c=>c.map((l,f)=>l===null?null:o[f](l))):r.rows.map(c=>Object.fromEntries( c.map((l,f)=>[s[f],l===null?null:o[f](l)])));return t?(r.viaNeonFetch=!0,r.rowAsArray=e,r.rows=u,r._parsers= -o,r._types=i,r):u}a(os,"processQueryResult");async function Fu(r){if(typeof r=="string")return r;if(typeof r== -"function")try{return await Promise.resolve(r())}catch(e){let t=new be("Error getting auth token."); -throw e instanceof Error&&(t=new be(`Error getting auth token: ${e.message}`)),t}}a(Fu,"getAuthToken");p();var go=Se(ot());p();var wo=Se(ot());var kn=class kn extends wo.Client{constructor(t){super(t);this.config=t}get neonConfig(){return this. -connection.stream}connect(t){let{neonConfig:n}=this;n.forceDisablePgSSL&&(this.ssl=this.connection.ssl= -!1),this.ssl&&n.useSecureWebSocket&&console.warn("SSL is enabled for both Postgres (e.g. ?sslmode=re\ -quire in the connection string + forceDisablePgSSL = false) and the WebSocket tunnel (useSecureWebSo\ -cket = true). Double encryption will increase latency and CPU usage. It may be appropriate to disabl\ -e SSL in the Postgres connection parameters or set forceDisablePgSSL = true.");let i=typeof this.config!= -"string"&&this.config?.host!==void 0||typeof this.config!="string"&&this.config?.connectionString!== -void 0||m.env.PGHOST!==void 0,s=m.env.USER??m.env.USERNAME;if(!i&&this.host==="localhost"&&this.user=== -s&&this.database===s&&this.password===null)throw new Error(`No database host or connection string wa\ -s set, and key parameters have default values (host: localhost, user: ${s}, db: ${s}, password: null\ -). Is an environment variable missing? Alternatively, if you intended to connect with these paramete\ -rs, please set the host to 'localhost' explicitly.`);let o=super.connect(t),u=n.pipelineTLS&&this.ssl, -c=n.pipelineConnect==="password";if(!u&&!n.pipelineConnect)return o;let l=this.connection;if(u&&l.on( -"connect",()=>l.stream.emit("data","S")),c){l.removeAllListeners("authenticationCleartextPassword"), -l.removeAllListeners("readyForQuery"),l.once("readyForQuery",()=>l.on("readyForQuery",this._handleReadyForQuery. -bind(this)));let f=this.ssl?"sslconnect":"connect";l.on(f,()=>{this.neonConfig.disableWarningInBrowsers|| -bt(),this._handleAuthCleartextPassword(),this._handleReadyForQuery()})}return o}async _handleAuthSASLContinue(t){ -if(typeof crypto>"u"||crypto.subtle===void 0||crypto.subtle.importKey===void 0)throw new Error("Cann\ -ot use SASL auth when `crypto.subtle` is not defined");let n=crypto.subtle,i=this.saslSession,s=this. -password,o=t.data;if(i.message!=="SASLInitialResponse"||typeof s!="string"||typeof o!="string")throw new Error( -"SASL: protocol error");let u=Object.fromEntries(o.split(",").map(M=>{if(!/^.=/.test(M))throw new Error( -"SASL: Invalid attribute pair entry");let $=M[0],me=M.substring(2);return[$,me]})),c=u.r,l=u.s,f=u.i; -if(!c||!/^[!-+--~]+$/.test(c))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing/unpri\ -ntable");if(!l||!/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(l))throw new Error( -"SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing/not base64");if(!f||!/^[1-9][0-9]*$/.test(f))throw new Error( -"SASL: SCRAM-SERVER-FIRST-MESSAGE: missing/invalid iteration count");if(!c.startsWith(i.clientNonce)) -throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce");if(c. -length===i.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too\ - short");let y=parseInt(f,10),g=d.from(l,"base64"),A=new TextEncoder,C=A.encode(s),D=await n.importKey( -"raw",C,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),Y=new Uint8Array(await n.sign("HMAC",D,d.concat( -[g,d.from([0,0,0,1])]))),P=Y;for(var I=0;IP[$]^Y[$]));let w=P,Z=await n.importKey("raw",w,{name:"HMAC",hash:{name:"SHA-256"}},!1, -["sign"]),W=new Uint8Array(await n.sign("HMAC",Z,A.encode("Client Key"))),J=await n.digest("SHA-256", -W),X="n=*,r="+i.clientNonce,se="r="+c+",s="+l+",i="+y,oe="c=biws,r="+c,R=X+","+se+","+oe,j=await n.importKey( -"raw",J,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);var le=new Uint8Array(await n.sign("HMAC",j, -A.encode(R))),de=d.from(W.map((M,$)=>W[$]^le[$])),We=de.toString("base64");let fe=await n.importKey( -"raw",w,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),_e=await n.sign("HMAC",fe,A.encode("Server \ -Key")),ye=await n.importKey("raw",_e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);var ee=d.from( -await n.sign("HMAC",ye,A.encode(R)));i.message="SASLResponse",i.serverSignature=ee.toString("base64"), -i.response=oe+",p="+We,this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}};a(kn, -"NeonClient");var ut=kn;Fe();var bo=Se(Bt());function vl(r,e){if(e)return{callback:e,result:void 0};let t,n,i=a(function(o,u){o?t(o):n(u)},"cb"), -s=new r(function(o,u){n=o,t=u});return{callback:i,result:s}}a(vl,"promisify");var Un=class Un extends go.Pool{constructor(){ -super(...arguments);E(this,"Client",ut);E(this,"hasFetchUnsupportedListeners",!1);E(this,"addListene\ +o,r._types=i,r):u}a(as,"processQueryResult");async function Fu(r){if(typeof r=="string")return r;if(typeof r== +"function")try{return await Promise.resolve(r())}catch(e){let t=new ge("Error getting auth token."); +throw e instanceof Error&&(t=new ge(`Error getting auth token: ${e.message}`)),t}}a(Fu,"getAuthToken");d();var bo=xe(ot());d();var go=xe(ot());var Mn=class Mn extends go.Client{constructor(t){super(t);this.config=t}get neonConfig(){return this. +connection.stream}connect(t){let{neonConfig:n}=this;n.isNeonLocal&&n.setConnectionCredentials({user:this. +user||void 0,password:this.password||void 0,database:this.database||void 0}),n.forceDisablePgSSL&&(this. +ssl=this.connection.ssl=!1),this.ssl&&n.useSecureWebSocket&&console.warn("SSL is enabled for both Po\ +stgres (e.g. ?sslmode=require in the connection string + forceDisablePgSSL = false) and the WebSocke\ +t tunnel (useSecureWebSocket = true). Double encryption will increase latency and CPU usage. It may \ +be appropriate to disable SSL in the Postgres connection parameters or set forceDisablePgSSL = true."); +let i=typeof this.config!="string"&&this.config?.host!==void 0||typeof this.config!="string"&&this.config?. +connectionString!==void 0||m.env.PGHOST!==void 0,s=m.env.USER??m.env.USERNAME;if(!i&&this.host==="lo\ +calhost"&&this.user===s&&this.database===s&&this.password===null)throw new Error(`No database host o\ +r connection string was set, and key parameters have default values (host: localhost, user: ${s}, db\ +: ${s}, password: null). Is an environment variable missing? Alternatively, if you intended to conne\ +ct with these parameters, please set the host to 'localhost' explicitly.`);let o=super.connect(t),u=n. +pipelineTLS&&this.ssl,c=n.pipelineConnect==="password";if(!u&&!n.pipelineConnect)return o;let l=this. +connection;if(u&&l.on("connect",()=>l.stream.emit("data","S")),c){l.removeAllListeners("authenticati\ +onCleartextPassword"),l.removeAllListeners("readyForQuery"),l.once("readyForQuery",()=>l.on("readyFo\ +rQuery",this._handleReadyForQuery.bind(this)));let f=this.ssl?"sslconnect":"connect";l.on(f,()=>{this. +neonConfig.disableWarningInBrowsers||vt(),this._handleAuthCleartextPassword(),this._handleReadyForQuery()})} +return o}async _handleAuthSASLContinue(t){if(typeof crypto>"u"||crypto.subtle===void 0||crypto.subtle. +importKey===void 0)throw new Error("Cannot use SASL auth when `crypto.subtle` is not defined");let n=crypto. +subtle,i=this.saslSession,s=this.password,o=t.data;if(i.message!=="SASLInitialResponse"||typeof s!="\ +string"||typeof o!="string")throw new Error("SASL: protocol error");let u=Object.fromEntries(o.split( +",").map(Q=>{if(!/^.=/.test(Q))throw new Error("SASL: Invalid attribute pair entry");let M=Q[0],ye=Q. +substring(2);return[M,ye]})),c=u.r,l=u.s,f=u.i;if(!c||!/^[!-+--~]+$/.test(c))throw new Error("SASL: \ +SCRAM-SERVER-FIRST-MESSAGE: nonce missing/unprintable");if(!l||!/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/. +test(l))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing/not base64");if(!f||!/^[1-9][0-9]*$/. +test(f))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: missing/invalid iteration count");if(!c.startsWith( +i.clientNonce))throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with c\ +lient nonce");if(c.length===i.clientNonce.length)throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: \ +server nonce is too short");let p=parseInt(f,10),g=y.from(l,"base64"),E=new TextEncoder,C=E.encode(s), +D=await n.importKey("raw",C,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),Y=new Uint8Array(await n. +sign("HMAC",D,y.concat([g,y.from([0,0,0,1])]))),P=Y;for(var I=0;IP[M]^Y[M]));let w=P,X=await n.importKey("raw",w,{name:"HMAC",hash:{ +name:"SHA-256"}},!1,["sign"]),j=new Uint8Array(await n.sign("HMAC",X,E.encode("Client Key"))),Z=await n. +digest("SHA-256",j),he="n=*,r="+i.clientNonce,J="r="+c+",s="+l+",i="+p,se="c=biws,r="+c,B=he+","+J+"\ +,"+se,H=await n.importKey("raw",Z,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);var ue=new Uint8Array( +await n.sign("HMAC",H,E.encode(B))),de=y.from(j.map((Q,M)=>j[M]^ue[M])),Se=de.toString("base64");let Qe=await n. +importKey("raw",w,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),ee=await n.sign("HMAC",Qe,E.encode( +"Server Key")),lt=await n.importKey("raw",ee,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);var pe=y. +from(await n.sign("HMAC",lt,E.encode(B)));i.message="SASLResponse",i.serverSignature=pe.toString("ba\ +se64"),i.response=se+",p="+Se,this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}}; +a(Mn,"NeonClient");var ut=Mn;je();var vo=xe(Bt());function Sl(r,e){if(e)return{callback:e,result:void 0};let t,n,i=a(function(o,u){o?t(o):n(u)},"cb"), +s=new r(function(o,u){n=o,t=u});return{callback:i,result:s}}a(Sl,"promisify");var Dn=class Dn extends bo.Pool{constructor(){ +super(...arguments);A(this,"Client",ut);A(this,"hasFetchUnsupportedListeners",!1);A(this,"addListene\ r",this.on)}on(t,n){return t!=="error"&&(this.hasFetchUnsupportedListeners=!0),super.on(t,n)}query(t,n,i){ -if(!ce.poolQueryViaFetch||this.hasFetchUnsupportedListeners||typeof t=="function")return super.query( -t,n,i);typeof n=="function"&&(i=n,n=void 0);let s=vl(this.Promise,i);i=s.callback;try{let o=new bo.default( +if(!le.poolQueryViaFetch||this.hasFetchUnsupportedListeners||typeof t=="function")return super.query( +t,n,i);typeof n=="function"&&(i=n,n=void 0);let s=Sl(this.Promise,i);i=s.callback;try{let o=new vo.default( this.options),u=encodeURIComponent,c=encodeURI,l=`postgresql://${u(o.user)}:${u(o.password)}@${u(o.host)}\ -/${c(o.database)}`,f=typeof t=="string"?t:t.text,y=n??t.values??[];cs(l,{fullResults:!0,arrayMode:t. -rowMode==="array"}).query(f,y,{types:t.types??this.options?.types}).then(A=>i(void 0,A)).catch(A=>i( -A))}catch(o){i(o)}return s.result}};a(Un,"NeonPool");var Mn=Un;Fe();var ct=Se(ot()),kp="mjs";var export_DatabaseError=ct.DatabaseError;var export_defaults=ct.defaults;var export_escapeIdentifier=ct.escapeIdentifier; +/${c(o.database)}`,f=typeof t=="string"?t:t.text,p=n??t.values??[];ls(l,{fullResults:!0,arrayMode:t. +rowMode==="array"}).query(f,p,{types:t.types??this.options?.types}).then(E=>i(void 0,E)).catch(E=>i( +E))}catch(o){i(o)}return s.result}};a(Dn,"NeonPool");var Un=Dn;je();var ct=xe(ot()),Fd="mjs";var export_DatabaseError=ct.DatabaseError;var export_defaults=ct.defaults;var export_escapeIdentifier=ct.escapeIdentifier; var export_escapeLiteral=ct.escapeLiteral;var export_types=ct.types;export{ut as Client,export_DatabaseError as DatabaseError, -be as NeonDbError,Ce as NeonQueryPromise,Mn as Pool,$e as SqlTemplate,Ge as UnsafeRawSql,kp as _bundleExt, +ge as NeonDbError,Ce as NeonQueryPromise,Un as Pool,$e as SqlTemplate,Ge as UnsafeRawSql,Fd as _bundleExt, export_defaults as defaults,export_escapeIdentifier as escapeIdentifier,export_escapeLiteral as escapeLiteral, -cs as neon,ce as neonConfig,export_types as types,bt as warnIfBrowser}; +ls as neon,le as neonConfig,as as processQueryResult,export_types as types,vt as warnIfBrowser}; /*! Bundled license information: ieee754/index.js: diff --git a/src/client.ts b/src/client.ts index 740b35d..9d1789e 100644 --- a/src/client.ts +++ b/src/client.ts @@ -33,6 +33,15 @@ export class NeonClient extends Client { override connect(callback?: (err?: Error) => void) { const { neonConfig } = this; + // For Neon Local, automatically inject connection string credentials + if (neonConfig.isNeonLocal) { + neonConfig.setConnectionCredentials({ + user: this.user || undefined, + password: this.password || undefined, + database: this.database || undefined, + }); + } + // disable TLS if requested if (neonConfig.forceDisablePgSSL) { this.ssl = this.connection.ssl = false; @@ -62,6 +71,7 @@ export class NeonClient extends Client { throw new Error( `No database host or connection string was set, and key parameters have default values (host: localhost, user: ${defaultUser}, db: ${defaultUser}, password: null). Is an environment variable missing? Alternatively, if you intended to connect with these parameters, please set the host to 'localhost' explicitly.`, ); + // pipelining const result = super.connect(callback as any) as void | Promise; @@ -262,4 +272,4 @@ export class NeonClient extends Client { this.connection.sendSCRAMClientFinalMessage(this.saslSession.response); } -} +} \ No newline at end of file diff --git a/src/httpQuery.ts b/src/httpQuery.ts index 335e951..a245d58 100644 --- a/src/httpQuery.ts +++ b/src/httpQuery.ts @@ -29,8 +29,6 @@ import type { import { SqlTemplate, UnsafeRawSql } from './sqlTemplate'; import { warnIfBrowser } from './utils'; -import { Socket as neonConfig } from './shims/net'; - // @ts-ignore -- this isn't officially exported by pg import TypeOverrides from 'pg/lib/type-overrides'; // @ts-ignore -- this isn't officially exported by pg @@ -205,7 +203,7 @@ export function neon< 'No database connection string was provided to `neon()`. Perhaps an environment variable has not been set?', ); - let db; + let db: ReturnType; try { db = parse(connectionString); } catch { @@ -287,8 +285,9 @@ export function neon< | HTTPQueryOptions[], txnOpts?: HTTPTransactionOptions, ) { - const { fetchEndpoint, fetchFunction } = Socket; + const { fetchEndpoint, fetchFunction, isNeonLocal } = Socket; + // --- set up request body --- const bodyData = Array.isArray(queryData) ? { queries: queryData.map((queryDatum) => prepareQuery(queryDatum)) } : prepareQuery(queryData); @@ -353,6 +352,13 @@ export function neon< 'Neon-Array-Mode': 'true', // this saves data and post-processing even if we return objects, not arrays }; + // For Neon Local, add credential headers + if (isNeonLocal) { + headers['X-Neon-User'] = username; + headers['X-Neon-Password'] = db.password || ''; + headers['X-Neon-Database'] = pathname.slice(1); + } + // --- add auth token to headers --- const validAuthToken = await getAuthToken(resolvedAuthToken); if (validAuthToken) { @@ -369,7 +375,7 @@ export function neon< headers['Neon-Batch-Deferrable'] = String(resolvedDeferrable); } - if (!(disableWarningInBrowsers || neonConfig.disableWarningInBrowsers)) { + if (!(disableWarningInBrowsers || Socket.disableWarningInBrowsers)) { warnIfBrowser(); } @@ -552,3 +558,5 @@ async function getAuthToken( } } } + +export { processQueryResult }; \ No newline at end of file diff --git a/src/shims/net/index.ts b/src/shims/net/index.ts index 1a7c84f..d0b9e65 100644 --- a/src/shims/net/index.ts +++ b/src/shims/net/index.ts @@ -33,6 +33,10 @@ export interface WebSocketLike { listener: (this: WebSocketLike, ev: any) => any, options?: any, ): void; + onopen?: (this: WebSocketLike) => void; + onmessage?: (this: WebSocketLike, ev: { data: any }) => void; + onerror?: (this: WebSocketLike, ev: { error?: any; message?: string }) => void; + onclose?: (this: WebSocketLike, ev: { code: number; reason?: string }) => void; } export interface WebSocketConstructor { @@ -78,6 +82,12 @@ export interface FetchEndpointOptions { jwtAuth?: boolean; } +export interface NeonLocalCredentials { + user?: string; + password?: string; + database?: string; +} + export interface SocketDefaults { // these options relate to the fetch transport and take effect *only* when set globally poolQueryViaFetch: boolean; @@ -103,6 +113,8 @@ export interface SocketDefaults { pipelineTLS: boolean; disableSNI: boolean; disableWarningInBrowsers: boolean; + // Neon Local proxy configuration + isNeonLocal: boolean; } type GlobalOnlyDefaults = | 'poolQueryViaFetch' @@ -116,7 +128,15 @@ export class Socket extends EventEmitter { static defaults: SocketDefaults = { // these options relate to the fetch transport and take effect *only* when set globally poolQueryViaFetch: false, - fetchEndpoint: (host, _port, options) => { + fetchEndpoint: (host, port, options) => { + // If connecting to Neon Local, use the original host:port directly + if (Socket.isNeonLocal) { + const protocol = 'http'; // Always use HTTP for local development + const portSuffix = port && port !== '443' && port !== '80' ? `:${port}` : ''; + return `${protocol}://${host}${portSuffix}/sql`; + } + + // Default Neon cloud behavior let newHost; if (options?.jwtAuth) { // If the caller sends in a JWT, we need to use the Neon Authorize API @@ -144,11 +164,24 @@ export class Socket extends EventEmitter { pipelineTLS: false, disableSNI: false, disableWarningInBrowsers: false, + // Neon Local proxy configuration + isNeonLocal: false, }; static opts: Partial = {}; private opts: Partial> = {}; + // Storage for connection string credentials (for Neon Local auto-injection) + private connectionCredentials: NeonLocalCredentials | undefined = undefined; + + /** + * Set connection string credentials for automatic injection in Neon Local mode. + * This is called automatically by the Client class when isNeonLocal is true. + */ + setConnectionCredentials(credentials: NeonLocalCredentials) { + this.connectionCredentials = credentials; + } + /** * **Experimentally**, when `poolQueryViaFetch` is `true`, and no listeners * for the `"connect"`, `"acquire"`, `"release"` or `"remove"` events are set @@ -289,6 +322,10 @@ export class Socket extends EventEmitter { * Default: `true`. */ static get useSecureWebSocket() { + // Auto-configure for Neon Local: always use insecure WebSocket for local development + if (Socket.isNeonLocal) { + return false; + } return Socket.opts.useSecureWebSocket ?? Socket.defaults.useSecureWebSocket; } static set useSecureWebSocket( @@ -297,6 +334,10 @@ export class Socket extends EventEmitter { Socket.opts.useSecureWebSocket = newValue; } get useSecureWebSocket() { + // Auto-configure for Neon Local: always use insecure WebSocket for local development + if (Socket.isNeonLocal || this.isNeonLocal) { + return false; + } return this.opts.useSecureWebSocket ?? Socket.useSecureWebSocket; } set useSecureWebSocket(newValue: SocketDefaults['useSecureWebSocket']) { @@ -364,6 +405,8 @@ export class Socket extends EventEmitter { ) { Socket.opts.disableWarningInBrowsers = newValue; } + + get disableWarningInBrowsers() { return ( this.opts.disableWarningInBrowsers ?? Socket.disableWarningInBrowsers @@ -460,6 +503,26 @@ export class Socket extends EventEmitter { this.opts.rootCerts = newValue; } + /** + * Set `isNeonLocal` to `true` when connecting to a Neon Local proxy instance. + * This flag can be used by the driver to enable specific optimizations and + * behaviors when working with local development environments. + * + * Default: `false`. + */ + static get isNeonLocal() { + return Socket.opts.isNeonLocal ?? Socket.defaults.isNeonLocal; + } + static set isNeonLocal(newValue: SocketDefaults['isNeonLocal']) { + Socket.opts.isNeonLocal = newValue; + } + get isNeonLocal() { + return this.opts.isNeonLocal ?? Socket.isNeonLocal; + } + set isNeonLocal(newValue: SocketDefaults['isNeonLocal']) { + this.opts.isNeonLocal = newValue; + } + wsProxyAddrForHost(host: string, port: number) { const wsProxy = this.wsProxy; if (wsProxy === undefined) { @@ -479,7 +542,7 @@ export class Socket extends EventEmitter { authorized = false; destroyed = false; - private ws: WebSocketLike | null = null; + private ws: any = null; private writeBuffer: Uint8Array | undefined; // used only if coalesceWrites === true private tlsState = TlsState.None; private tlsRead: undefined | (() => Promise); @@ -541,68 +604,123 @@ export class Socket extends EventEmitter { else ws.addEventListener('open', handleWebSocketOpen); }; - let wsAddr: string; try { - wsAddr = this.wsProxyAddrForHost( - host, - typeof port === 'string' ? parseInt(port, 10) : port, - ); - } catch (err) { - this.emit('error', err); - this.emit('close'); - return; - } + // For Neon Local, always use WebSocket + if (Socket.isNeonLocal) { + // Automatically configure for local development - force insecure WebSocket + const wsProtocol = 'ws:'; // Always use ws:// for local development + const portSuffix = port && port !== '443' && port !== '80' ? `:${port}` : ''; + const wsAddrFull = `${wsProtocol}//${host}${portSuffix}/sql`; + + debug && log('Neon Local: Auto-configured for insecure WebSocket', { wsAddrFull }); + + // Build WebSocket options with headers for Neon Local credential injection + let wsOptions: any = { + headers: { + 'Upgrade': 'websocket', + 'Connection': 'Upgrade' + } + }; + + if (this.connectionCredentials) { + const creds = this.connectionCredentials; + + // Only include non-empty credential values + if (creds.user) wsOptions.headers['X-Neon-User'] = creds.user; + if (creds.password) wsOptions.headers['X-Neon-Password'] = creds.password; + if (creds.database) wsOptions.headers['X-Neon-Database'] = creds.database; + + debug && log('Adding Neon Local credential headers from connection string', { + user: creds.user, + database: creds.database + }); + } - try { - // ordinary/browser path - const wsProtocol = this.useSecureWebSocket ? 'wss:' : 'ws:'; - const wsAddrFull = wsProtocol + '//' + wsAddr; - - // first, use a custom constructor, if supplied - if (this.webSocketConstructor !== undefined) { - this.ws = new this.webSocketConstructor(wsAddrFull); - configureWebSocket(this.ws); - } else { - try { - // second, try a common-or-garden WebSocket, e.g. in a web browser - this.ws = new WebSocket(wsAddrFull) as any; - configureWebSocket(this.ws!); - } catch (err) { - debug && log('new WebSocket() failed'); - - // @ts-ignore -- unknown Vercel-specific object - this.ws = new __unstable_WebSocket(wsAddrFull); - configureWebSocket(this.ws!); + // Use the provided WebSocket constructor or fall back to global WebSocket + const WebSocketImpl = this.webSocketConstructor || (typeof WebSocket !== 'undefined' ? WebSocket : undefined); + + if (!WebSocketImpl) { + throw new Error('No WebSocket implementation available. Please provide a webSocketConstructor.'); } + + this.ws = new WebSocketImpl(wsAddrFull, wsOptions); + if (this.ws) configureWebSocket(this.ws); + return; + } + + // Regular Neon cloud path + let wsAddr: string; + try { + wsAddr = this.wsProxyAddrForHost( + host, + typeof port === 'string' ? parseInt(port, 10) : port, + ); + } catch (err) { + this.emit('error', err); + this.emit('close'); + return; + } + + try { + // ordinary/browser path + const wsProtocol = this.useSecureWebSocket ? 'wss:' : 'ws:'; + const wsAddrFull = wsProtocol + '//' + wsAddr; + + // first, use a custom constructor, if supplied + if (this.webSocketConstructor !== undefined) { + this.ws = new this.webSocketConstructor(wsAddrFull); + configureWebSocket(this.ws); + } else { + try { + // second, try a common-or-garden WebSocket, e.g. in a web browser + this.ws = new WebSocket(wsAddrFull) as any; + configureWebSocket(this.ws!); + } catch (err) { + debug && log('new WebSocket() failed'); + + // @ts-ignore -- unknown Vercel-specific object + this.ws = new __unstable_WebSocket(wsAddrFull); + configureWebSocket(this.ws!); + } + } + } catch (err) { + debug && log('WebSocket constructors failed'); + + // fourth and finally, let's try the Cloudflare Workers method ... + const wsProtocol = this.useSecureWebSocket ? 'https:' : 'http:'; + const fetchAddrFull = wsProtocol + '//' + wsAddr; + + fetch(fetchAddrFull, { headers: { Upgrade: 'websocket' } }) + .then((resp) => { + // @ts-ignore -- unknown Cloudflare-specific property + this.ws = resp.webSocket; + if (this.ws == null) throw err; // deliberate loose equality + + // @ts-ignore -- unknown Cloudflare-specific method + this.ws.accept!(); + configureWebSocket(this.ws, true); + debug && log('Cloudflare WebSocket opened'); + }) + .catch((err) => { + debug && log(`fetch() with { Upgrade: "websocket" } failed`); + this.emit( + 'error', + new Error( + `All attempts to open a WebSocket to connect to the database failed. Please refer to https://github.com/neondatabase/serverless/blob/main/CONFIG.md#websocketconstructor-typeof-websocket--undefined. Details: ${err}`, + ), + ); + this.emit('close'); + }); } } catch (err) { debug && log('WebSocket constructors failed'); - - // fourth and finally, let's try the Cloudflare Workers method ... - const wsProtocol = this.useSecureWebSocket ? 'https:' : 'http:'; - const fetchAddrFull = wsProtocol + '//' + wsAddr; - - fetch(fetchAddrFull, { headers: { Upgrade: 'websocket' } }) - .then((resp) => { - // @ts-ignore -- unknown Cloudflare-specific property - this.ws = resp.webSocket; - if (this.ws == null) throw err; // deliberate loose equality - - // @ts-ignore -- unknown Cloudflare-specific method - this.ws.accept!(); - configureWebSocket(this.ws, true); - debug && log('Cloudflare WebSocket opened'); - }) - .catch((err) => { - debug && log(`fetch() with { Upgrade: "websocket" } failed`); - this.emit( - 'error', - new Error( - `All attempts to open a WebSocket to connect to the database failed. Please refer to https://github.com/neondatabase/serverless/blob/main/CONFIG.md#websocketconstructor-typeof-websocket--undefined. Details: ${err}`, - ), - ); - this.emit('close'); - }); + this.emit( + 'error', + new Error( + `Failed to establish WebSocket connection. ${err}`, + ), + ); + this.emit('close'); } } diff --git a/tests/cloudflare/neon_local/test-all-custom.js b/tests/cloudflare/neon_local/test-all-custom.js new file mode 100644 index 0000000..09528e8 --- /dev/null +++ b/tests/cloudflare/neon_local/test-all-custom.js @@ -0,0 +1,86 @@ +#!/usr/bin/env node + +import { spawn } from 'child_process'; +import { fileURLToPath } from 'url'; +import { dirname, join } from 'path'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const tests = [ + 'test-non-local.js', + 'test-legacy-behavior.js', + 'test-neon-local-behavior.js', + 'test-comprehensive.js' +]; + +async function runTest(testFile) { + return new Promise((resolve, reject) => { + console.log(`\n${'='.repeat(60)}`); + console.log(`๐Ÿš€ Running: ${testFile}`); + console.log(`${'='.repeat(60)}`); + + const testPath = join(__dirname, testFile); + const child = spawn('node', [testPath], { + stdio: 'inherit', + cwd: __dirname + }); + + child.on('close', (code) => { + if (code === 0) { + console.log(`โœ… ${testFile} PASSED`); + resolve(); + } else { + console.log(`โŒ ${testFile} FAILED (exit code: ${code})`); + reject(new Error(`Test ${testFile} failed with exit code ${code}`)); + } + }); + + child.on('error', (err) => { + console.log(`โŒ ${testFile} ERROR: ${err.message}`); + reject(err); + }); + }); +} + +async function runAllTests() { + console.log('๐Ÿงช Running All Custom Serverless Driver Tests'); + console.log('๐Ÿ“‹ Testing both legacy and new isNeonLocal functionality\n'); + + let passed = 0; + let failed = 0; + + for (const test of tests) { + try { + await runTest(test); + passed++; + } catch (error) { + console.error(`\n๐Ÿ’ฅ Test ${test} failed:`, error.message); + failed++; + } + } + + console.log(`\n${'='.repeat(60)}`); + console.log('๐Ÿ“Š FINAL RESULTS'); + console.log(`${'='.repeat(60)}`); + console.log(`โœ… Passed: ${passed}/${tests.length}`); + console.log(`โŒ Failed: ${failed}/${tests.length}`); + + if (failed === 0) { + console.log('\n๐ŸŽ‰ ALL TESTS PASSED!'); + console.log('โœ… Legacy behavior (isNeonLocal = false) works correctly'); + console.log('โœ… New behavior (isNeonLocal = true) works correctly'); + console.log('โœ… Auto-configuration works properly'); + console.log('โœ… No breaking changes detected'); + console.log('\n๐Ÿ“‹ The isNeonLocal feature is ready for production use.'); + } else { + console.log('\n๐Ÿ’ฅ SOME TESTS FAILED!'); + console.log('๐Ÿ” Please review the test output above for details.'); + process.exit(1); + } +} + +runAllTests().catch(error => { + console.error('\nโŒ Test runner failed:', error); + process.exit(1); +}); diff --git a/tests/cloudflare/neon_local/test-cloudflare-http.js b/tests/cloudflare/neon_local/test-cloudflare-http.js new file mode 100644 index 0000000..e6651e0 --- /dev/null +++ b/tests/cloudflare/neon_local/test-cloudflare-http.js @@ -0,0 +1,156 @@ +#!/usr/bin/env node + +// Test: Cloudflare Worker HTTP Pattern with Neon Local +import { neon, neonConfig } from '@neondatabase/serverless'; + +async function testCloudflareHttpPattern() { + console.log('๐Ÿงช Test: Cloudflare Worker HTTP Pattern with Neon Local'); + + try { + // Configure for Neon Local (what you would do in a Cloudflare Worker) + neonConfig.isNeonLocal = true; + + console.log(' ๐Ÿ“‹ Configuration (as in Cloudflare Worker):'); + console.log(' isNeonLocal:', neonConfig.isNeonLocal); + console.log(' useSecureWebSocket:', neonConfig.useSecureWebSocket); + console.log(' Generated endpoint:', neonConfig.fetchEndpoint('localhost', '5432')); + + // Test 1: Basic query (most common Cloudflare Worker pattern) + console.log('\n ๐Ÿ“ก Test 1: Basic SQL query via HTTP'); + const sql = neon('postgresql://neon:npg@localhost:5432/neondb'); + + const result1 = await sql` + SELECT + 'Cloudflare Worker' as platform, + 'Neon Local Proxy' as proxy_type, + 'HTTP Transport' as transport, + NOW() as timestamp + `; + + console.log(' โœ… Basic Query:', result1[0]); + + // Test 2: Query with parameters (common pattern) + console.log('\n ๐Ÿ“ก Test 2: Parameterized query'); + const userId = 42; + const userName = 'CloudflareUser'; + + const result2 = await sql` + SELECT + ${userId} as user_id, + ${userName} as user_name, + 'Parameter injection works' as message, + NOW() as created_at + `; + + console.log(' โœ… Parameterized Query:', result2[0]); + + // Test 3: Multiple queries (transaction-like pattern) + console.log('\n ๐Ÿ“ก Test 3: Multiple queries'); + const results = await Promise.all([ + sql`SELECT 'Query 1' as query_name, 1 as query_id`, + sql`SELECT 'Query 2' as query_name, 2 as query_id`, + sql`SELECT 'Query 3' as query_name, 3 as query_id` + ]); + + console.log(' โœ… Multiple Queries:'); + results.forEach((result, index) => { + console.log(` Query ${index + 1}:`, result[0]); + }); + + // Test 4: Error handling (important for production) + console.log('\n ๐Ÿ“ก Test 4: Error handling'); + try { + await sql`SELECT * FROM nonexistent_table`; + } catch (error) { + console.log(' โœ… Error handling works:', error.message.split('\n')[0]); + } + + console.log('\nโœ… PASS - Cloudflare Worker HTTP Pattern Test'); + console.log(' ๐ŸŽ‰ All HTTP patterns work correctly:'); + console.log(' - Basic queries'); + console.log(' - Parameterized queries'); + console.log(' - Concurrent queries'); + console.log(' - Error handling'); + console.log(' ๐Ÿ“Š Neon Local proxy successfully routes HTTP requests'); + + return true; + + } catch (error) { + console.log('โŒ FAIL - Cloudflare Worker HTTP Pattern Test'); + console.log(' Error:', error.message); + + console.log('\n ๐Ÿ’ก This test requires:'); + console.log(' - Neon Local container running (docker-compose up)'); + console.log(' - Valid NEON_API_KEY and NEON_PROJECT_ID configured'); + return false; + } +} + +async function printCloudflareWorkerExample() { + console.log('\n๐Ÿš€ Production Cloudflare Worker Example:'); + console.log(` +// wrangler.toml (for local development) +name = "my-app" +main = "src/index.js" + +# For local development with Neon Local +[env.development] +compatibility_date = "2023-10-30" + +// src/index.js - Your Cloudflare Worker +import { neon, neonConfig } from '@neondatabase/serverless'; + +export default { + async fetch(request, env, ctx) { + // Only enable for local development + if (env.ENVIRONMENT === 'development') { + neonConfig.isNeonLocal = true; + } + + // Connection string - use localhost for local dev, cloud for prod + const databaseUrl = env.ENVIRONMENT === 'development' + ? 'postgresql://neon:npg@localhost:5432/neondb' + : env.DATABASE_URL; // Cloud connection string from env vars + + const sql = neon(databaseUrl); + + // Your application logic + const users = await sql\` + SELECT id, name, email + FROM users + WHERE active = true + ORDER BY created_at DESC + LIMIT 10 + \`; + + return Response.json({ users }); + } +}; + +// For local development: +// 1. Start Neon Local: docker-compose up +// 2. Run Cloudflare Worker locally: wrangler dev +// 3. Your Worker connects to localhost:5432 (Neon Local) +// 4. Neon Local routes to your cloud database +// 5. No connection string changes needed between environments! + `); +} + +// Run tests if this file is executed directly +if (import.meta.url === `file://${process.argv[1]}`) { + testCloudflareHttpPattern() + .then(success => { + if (success) { + printCloudflareWorkerExample(); + process.exit(0); + } else { + process.exit(1); + } + }) + .catch(error => { + console.error('โŒ Test failed:', error); + process.exit(1); + }); +} + +export { testCloudflareHttpPattern }; diff --git a/tests/cloudflare/neon_local/test-comprehensive.js b/tests/cloudflare/neon_local/test-comprehensive.js new file mode 100644 index 0000000..032ae57 --- /dev/null +++ b/tests/cloudflare/neon_local/test-comprehensive.js @@ -0,0 +1,120 @@ +#!/usr/bin/env node + +import { neon, neonConfig } from '@neondatabase/serverless'; + +async function testComprehensive() { + console.log('๐Ÿงช Test: Comprehensive Behavior Verification'); + + // Mock fetch to avoid actual network calls + const originalFetch = globalThis.fetch; + let fetchCallCount = 0; + + globalThis.fetch = async (url, options) => { + fetchCallCount++; + console.log(`๐Ÿ“ก Fetch call #${fetchCallCount}:`, { + url, + method: options.method, + hasNeonHeaders: Object.keys(options.headers).some(h => h.startsWith('X-Neon-')) + }); + + return { + ok: true, + json: async () => ({ + fields: [{ name: 'test', dataTypeID: 25 }], + command: 'SELECT', + rowCount: 1, + rows: [['test passed']] + }) + }; + }; + + try { + console.log('\n๐Ÿ“ Test 1: Switch from Cloud to Local'); + + // Start with cloud behavior + neonConfig.isNeonLocal = false; + console.log(' ๐Ÿ” isNeonLocal:', neonConfig.isNeonLocal); + console.log(' ๐Ÿ” useSecureWebSocket:', neonConfig.useSecureWebSocket); + + const cloudSql = neon('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname'); + await cloudSql`SELECT 'cloud test' as test`; + + // Switch to local behavior + neonConfig.isNeonLocal = true; + console.log(' ๐Ÿ” After setting isNeonLocal=true:'); + console.log(' ๐Ÿ” isNeonLocal:', neonConfig.isNeonLocal); + console.log(' ๐Ÿ” useSecureWebSocket (auto):', neonConfig.useSecureWebSocket); + + const localSql = neon('postgresql://user:pass@127.0.0.1:5432/dbname'); + await localSql`SELECT 'local test' as test`; + + console.log('\n๐Ÿ“ Test 2: Switch from Local to Cloud'); + + // Switch back to cloud + neonConfig.isNeonLocal = false; + console.log(' ๐Ÿ” After setting isNeonLocal=false:'); + console.log(' ๐Ÿ” isNeonLocal:', neonConfig.isNeonLocal); + console.log(' ๐Ÿ” useSecureWebSocket (restored):', neonConfig.useSecureWebSocket); + + const cloudSql2 = neon('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname'); + await cloudSql2`SELECT 'cloud test 2' as test`; + + console.log('\n๐Ÿ“ Test 3: Multiple instances with different configs'); + + // Test that instance-level config doesn't interfere with global + neonConfig.isNeonLocal = false; // Global setting + + const cloudInstance = neon('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname'); + await cloudInstance`SELECT 'global cloud' as test`; + + // Change global to local + neonConfig.isNeonLocal = true; + + const localInstance = neon('postgresql://user:pass@127.0.0.1:5432/dbname'); + await localInstance`SELECT 'global local' as test`; + + console.log('\n๐Ÿ“ Test 4: Endpoint generation consistency'); + + // Test endpoint generation for both modes + neonConfig.isNeonLocal = false; + const cloudEndpoint = neonConfig.fetchEndpoint('ep-test-123.us-east-2.aws.neon.tech', '5432'); + console.log(' ๐Ÿ” Cloud endpoint:', cloudEndpoint); + + neonConfig.isNeonLocal = true; + const localEndpoint = neonConfig.fetchEndpoint('127.0.0.1', '5432'); + console.log(' ๐Ÿ” Local endpoint:', localEndpoint); + + // Verify they're different and correct + if (cloudEndpoint === localEndpoint) { + throw new Error('Cloud and local endpoints should be different'); + } + + if (!cloudEndpoint.includes('https://api.')) { + throw new Error(`Cloud endpoint should use https://api., got: ${cloudEndpoint}`); + } + + if (!localEndpoint.includes('http://127.0.0.1:5432')) { + throw new Error(`Local endpoint should use http://127.0.0.1:5432, got: ${localEndpoint}`); + } + + console.log('\nโœ… ALL COMPREHENSIVE TESTS PASSED'); + console.log(` - Total fetch calls: ${fetchCallCount}`); + console.log(' - Cloud/Local switching works correctly'); + console.log(' - Auto-configuration works properly'); + console.log(' - Multiple instances handle configs correctly'); + console.log(' - Endpoint generation is consistent'); + + } catch (error) { + console.error('โŒ Comprehensive test failed:', error.message); + process.exit(1); + } finally { + // Restore original fetch and reset config + globalThis.fetch = originalFetch; + neonConfig.isNeonLocal = false; // Reset to default + } +} + +testComprehensive().catch(error => { + console.error('โŒ Test failed:', error); + process.exit(1); +}); diff --git a/tests/cloudflare/neon_local/test-legacy-behavior.js b/tests/cloudflare/neon_local/test-legacy-behavior.js new file mode 100644 index 0000000..75bf693 --- /dev/null +++ b/tests/cloudflare/neon_local/test-legacy-behavior.js @@ -0,0 +1,95 @@ +#!/usr/bin/env node + +import { neon, neonConfig, Client, Pool } from '@neondatabase/serverless'; + +async function testLegacyBehavior() { + console.log('๐Ÿงช Test: Legacy Behavior Verification (isNeonLocal = false)'); + + // Explicitly ensure isNeonLocal is false (default behavior) + neonConfig.isNeonLocal = false; + + // Mock fetch to avoid actual network calls + const originalFetch = globalThis.fetch; + globalThis.fetch = async (url, options) => { + console.log('๐Ÿ“ก Fetch intercepted:', { + url, + method: options.method, + headers: options.headers + }); + + // Verify expected cloud behavior + if (!url.includes('api.') && !url.includes('apiauth.')) { + throw new Error(`Expected cloud URL with api. prefix, got: ${url}`); + } + + return { + ok: true, + json: async () => ({ + fields: [{ name: 'test', dataTypeID: 25 }], + command: 'SELECT', + rowCount: 1, + rows: [['legacy test passed']] + }) + }; + }; + + try { + console.log('\n๐Ÿ“ Test 1: neon() function with isNeonLocal = false'); + + // Test 1: Basic neon function + const sql = neon('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname'); + const result = await sql`SELECT 'legacy test' as test`; + console.log('โœ… Result:', result[0]); + + console.log('\n๐Ÿ“ Test 2: Configuration values'); + + // Test 2: Check that configuration values are as expected + console.log('๐Ÿ” isNeonLocal:', neonConfig.isNeonLocal); + console.log('๐Ÿ” useSecureWebSocket:', neonConfig.useSecureWebSocket); + console.log('๐Ÿ” fetchEndpoint type:', typeof neonConfig.fetchEndpoint); + + // Verify defaults + if (neonConfig.isNeonLocal !== false) { + throw new Error(`Expected isNeonLocal to be false, got: ${neonConfig.isNeonLocal}`); + } + + if (neonConfig.useSecureWebSocket !== true) { + throw new Error(`Expected useSecureWebSocket to be true, got: ${neonConfig.useSecureWebSocket}`); + } + + console.log('\n๐Ÿ“ Test 3: fetchEndpoint behavior'); + + // Test 3: Verify fetchEndpoint behavior for cloud + const endpoint = neonConfig.fetchEndpoint('ep-test-123.us-east-2.aws.neon.tech', '5432'); + console.log('๐Ÿ” Generated endpoint:', endpoint); + + if (!endpoint.includes('https://api.')) { + throw new Error(`Expected https://api. URL, got: ${endpoint}`); + } + + console.log('\n๐Ÿ“ Test 4: Client constructor doesn\'t break'); + + // Test 4: Verify Client and Pool constructors still work + const client = new Client('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname'); + const pool = new Pool({ connectionString: 'postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname' }); + + console.log('โœ… Client and Pool constructors work'); + + console.log('\nโœ… ALL LEGACY BEHAVIOR TESTS PASSED'); + console.log(' - isNeonLocal = false works correctly'); + console.log(' - Cloud URLs are generated properly'); + console.log(' - All existing functionality preserved'); + + } catch (error) { + console.error('โŒ Legacy behavior test failed:', error.message); + process.exit(1); + } finally { + // Restore original fetch + globalThis.fetch = originalFetch; + } +} + +testLegacyBehavior().catch(error => { + console.error('โŒ Test failed:', error); + process.exit(1); +}); diff --git a/tests/cloudflare/neon_local/test-neon-local-behavior.js b/tests/cloudflare/neon_local/test-neon-local-behavior.js new file mode 100644 index 0000000..f4954d5 --- /dev/null +++ b/tests/cloudflare/neon_local/test-neon-local-behavior.js @@ -0,0 +1,145 @@ +#!/usr/bin/env node + +import { neon, neonConfig, Client } from '@neondatabase/serverless'; + +async function testNeonLocalBehavior() { + console.log('๐Ÿงช Test: Neon Local Behavior Verification (isNeonLocal = true)'); + + // Set isNeonLocal to true + neonConfig.isNeonLocal = true; + + // Mock fetch to avoid actual network calls + const originalFetch = globalThis.fetch; + globalThis.fetch = async (url, options) => { + console.log('๐Ÿ“ก Fetch intercepted:', { + url, + method: options.method, + headers: options.headers + }); + + // Verify expected local behavior + if (!url.includes('http://') || url.includes('https://')) { + throw new Error(`Expected local HTTP URL, got: ${url}`); + } + + // Check for X-Neon-* headers + const hasNeonHeaders = Object.keys(options.headers).some(h => h.startsWith('X-Neon-')); + if (!hasNeonHeaders) { + throw new Error('Expected X-Neon-* headers for credential injection'); + } + + return { + ok: true, + json: async () => ({ + fields: [{ name: 'test', dataTypeID: 25 }], + command: 'SELECT', + rowCount: 1, + rows: [['neon local test passed']] + }) + }; + }; + + try { + console.log('\n๐Ÿ“ Test 1: neon() function with isNeonLocal = true'); + + // Test 1: Basic neon function + const sql = neon('postgresql://testuser:testpass@127.0.0.1:5432/testdb'); + const result = await sql`SELECT 'neon local test' as test`; + console.log('โœ… Result:', result[0]); + + console.log('\n๐Ÿ“ Test 2: Configuration values auto-configured'); + + // Test 2: Check that configuration values are auto-configured + console.log('๐Ÿ” isNeonLocal:', neonConfig.isNeonLocal); + console.log('๐Ÿ” useSecureWebSocket (auto-configured):', neonConfig.useSecureWebSocket); + + // Verify auto-configuration + if (neonConfig.isNeonLocal !== true) { + throw new Error(`Expected isNeonLocal to be true, got: ${neonConfig.isNeonLocal}`); + } + + if (neonConfig.useSecureWebSocket !== false) { + throw new Error(`Expected useSecureWebSocket to be auto-configured to false, got: ${neonConfig.useSecureWebSocket}`); + } + + console.log('\n๐Ÿ“ Test 3: fetchEndpoint behavior for local'); + + // Test 3: Verify fetchEndpoint behavior for local + const endpoint = neonConfig.fetchEndpoint('127.0.0.1', '5432'); + console.log('๐Ÿ” Generated endpoint:', endpoint); + + if (!endpoint.includes('http://127.0.0.1:5432/sql')) { + throw new Error(`Expected http://127.0.0.1:5432/sql URL, got: ${endpoint}`); + } + + console.log('\n๐Ÿ“ Test 4: Credential injection in HTTP requests'); + + // Reset fetch mock to capture credential headers + globalThis.fetch = async (url, options) => { + console.log('๐Ÿ“ก Credential test - Headers captured:', options.headers); + + // Verify X-Neon-* headers are present + const requiredHeaders = ['X-Neon-User', 'X-Neon-Password', 'X-Neon-Database']; + for (const header of requiredHeaders) { + if (!options.headers[header]) { + throw new Error(`Missing required header: ${header}`); + } + } + + // Verify header values + if (options.headers['X-Neon-User'] !== 'testuser') { + throw new Error(`Expected X-Neon-User to be 'testuser', got: ${options.headers['X-Neon-User']}`); + } + + if (options.headers['X-Neon-Password'] !== 'testpass') { + throw new Error(`Expected X-Neon-Password to be 'testpass', got: ${options.headers['X-Neon-Password']}`); + } + + if (options.headers['X-Neon-Database'] !== 'testdb') { + throw new Error(`Expected X-Neon-Database to be 'testdb', got: ${options.headers['X-Neon-Database']}`); + } + + return { + ok: true, + json: async () => ({ + fields: [{ name: 'test', dataTypeID: 25 }], + command: 'SELECT', + rowCount: 1, + rows: [['credential injection works']] + }) + }; + }; + + const sqlWithCreds = neon('postgresql://testuser:testpass@127.0.0.1:5432/testdb'); + const credResult = await sqlWithCreds`SELECT 'credential test' as test`; + console.log('โœ… Credential injection result:', credResult[0]); + + console.log('\n๐Ÿ“ Test 5: Client credential injection setup'); + + // Test 5: Verify Client sets up credentials correctly + const client = new Client('postgresql://clientuser:clientpass@127.0.0.1:5432/clientdb'); + + // Client should have set up credentials automatically + console.log('โœ… Client with Neon Local configured successfully'); + + console.log('\nโœ… ALL NEON LOCAL BEHAVIOR TESTS PASSED'); + console.log(' - isNeonLocal = true works correctly'); + console.log(' - useSecureWebSocket auto-configures to false'); + console.log(' - Local HTTP URLs are generated properly'); + console.log(' - X-Neon-* header injection works'); + console.log(' - Client integration works'); + + } catch (error) { + console.error('โŒ Neon Local behavior test failed:', error.message); + process.exit(1); + } finally { + // Restore original fetch and reset config + globalThis.fetch = originalFetch; + neonConfig.isNeonLocal = false; // Reset for other tests + } +} + +testNeonLocalBehavior().catch(error => { + console.error('โŒ Test failed:', error); + process.exit(1); +}); diff --git a/tests/cloudflare/neon_local/test-non-local.js b/tests/cloudflare/neon_local/test-non-local.js new file mode 100644 index 0000000..045473e --- /dev/null +++ b/tests/cloudflare/neon_local/test-non-local.js @@ -0,0 +1,106 @@ +#!/usr/bin/env node + +import { neon, neonConfig } from '@neondatabase/serverless'; +import WebSocket from 'ws'; + +// Custom WebSocket class for debugging +class DebugWebSocket extends WebSocket { + constructor(url, options) { + console.log('๐Ÿ” Creating WebSocket connection:', { + url, + headers: options?.headers + }); + super(url, options); + + this.addEventListener('open', () => { + console.log('๐Ÿ” WebSocket opened'); + }); + + this.addEventListener('error', (error) => { + console.log('๐Ÿ” WebSocket error:', error); + }); + + this.addEventListener('close', (event) => { + console.log('๐Ÿ” WebSocket closed:', { + code: event.code, + reason: event.reason || 'none' + }); + }); + + this.addEventListener('message', (event) => { + console.log('๐Ÿ” WebSocket message:', event.data); + }); + } +} + +async function testNonLocal() { + console.log('๐Ÿงช Test: Non-Neon Local Functionality'); + + // Reset Neon Local config + neonConfig.isNeonLocal = false; + neonConfig.useSecureWebSocket = true; + neonConfig.webSocketConstructor = DebugWebSocket; + + // Mock the fetch function to verify HTTP requests + const originalFetch = globalThis.fetch; + globalThis.fetch = async (url, options) => { + console.log('๐Ÿ“ก HTTP Request:', { + url, + method: options.method, + headers: options.headers + }); + + // Return a mock response + return { + ok: true, + json: async () => ({ + fields: [{ name: 'version', dataTypeID: 25 }], + command: 'SELECT', + rowCount: 1, + rows: [['PostgreSQL 17.5']] + }) + }; + }; + + try { + // Test 1: Regular WebSocket connection + console.log('\n๐Ÿ“ Test 1: Regular WebSocket Connection'); + const sql1 = neon('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname'); + const result1 = await sql1`SELECT version() as version`; + console.log('๐Ÿ“ฅ Result:', result1[0]); + + // Test 2: TLS over WebSocket + console.log('\n๐Ÿ“ Test 2: TLS over WebSocket'); + neonConfig.forceDisablePgSSL = false; + const sql2 = neon('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname?sslmode=require'); + const result2 = await sql2`SELECT version() as version`; + console.log('๐Ÿ“ฅ Result:', result2[0]); + + // Test 3: HTTP queries + console.log('\n๐Ÿ“ Test 3: HTTP Queries'); + neonConfig.poolQueryViaFetch = true; + const sql3 = neon('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname'); + const result3 = await sql3`SELECT version() as version`; + console.log('๐Ÿ“ฅ Result:', result3[0]); + } catch (err) { + console.error('โŒ Error:', err); + if (err.message) { + console.error('Error message:', err.message); + } + if (err.stack) { + console.error('Stack trace:', err.stack); + } + process.exit(1); + } finally { + // Restore original fetch + globalThis.fetch = originalFetch; + } +} + +// Run test if this file is executed directly +if (import.meta.url === `file://${process.argv[1]}`) { + testNonLocal().catch(error => { + console.error('โŒ Test failed:', error); + process.exit(1); + }); +} From 5fbd23c743ce2e4e5c8455972d0e9404bbd25aa7 Mon Sep 17 00:00:00 2001 From: Jeff Christoffersen Date: Wed, 3 Sep 2025 15:25:07 -0600 Subject: [PATCH 2/2] linter update --- CONFIG.md | 4 +- src/client.ts | 2 +- src/httpQuery.ts | 2 +- src/shims/net/index.ts | 69 ++++++++------ .../cloudflare/neon_local/test-all-custom.js | 24 ++--- .../neon_local/test-cloudflare-http.js | 40 ++++---- .../neon_local/test-comprehensive.js | 78 ++++++++++------ .../neon_local/test-legacy-behavior.js | 55 ++++++----- .../neon_local/test-neon-local-behavior.js | 92 ++++++++++++------- tests/cloudflare/neon_local/test-non-local.js | 24 +++-- 10 files changed, 235 insertions(+), 155 deletions(-) diff --git a/CONFIG.md b/CONFIG.md index 1f321ff..febced4 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -361,7 +361,7 @@ Set `isNeonLocal` to `true` when connecting to a Neon Local proxy instance. This For example: -```javascript +````javascript ```javascript import { neonConfig, Client } from '@neondatabase/serverless'; @@ -372,7 +372,7 @@ neonConfig.isNeonLocal = true; const client = new Client('postgresql://postgres:password@localhost:5432/mydb'); await client.connect(); // WebSocket headers: X-Neon-User: postgres, X-Neon-Password: password, X-Neon-Database: mydb -``` +```` **Note**: This feature requires a custom `webSocketConstructor` (like the `ws` library in Node.js) that supports headers. Browser WebSocket APIs don't support custom headers, but Neon Local typically runs in server-side environments. Default: `false`. diff --git a/src/client.ts b/src/client.ts index 9d1789e..b42e986 100644 --- a/src/client.ts +++ b/src/client.ts @@ -272,4 +272,4 @@ export class NeonClient extends Client { this.connection.sendSCRAMClientFinalMessage(this.saslSession.response); } -} \ No newline at end of file +} diff --git a/src/httpQuery.ts b/src/httpQuery.ts index a245d58..a44b291 100644 --- a/src/httpQuery.ts +++ b/src/httpQuery.ts @@ -559,4 +559,4 @@ async function getAuthToken( } } -export { processQueryResult }; \ No newline at end of file +export { processQueryResult }; diff --git a/src/shims/net/index.ts b/src/shims/net/index.ts index d0b9e65..19f0b8d 100644 --- a/src/shims/net/index.ts +++ b/src/shims/net/index.ts @@ -35,8 +35,14 @@ export interface WebSocketLike { ): void; onopen?: (this: WebSocketLike) => void; onmessage?: (this: WebSocketLike, ev: { data: any }) => void; - onerror?: (this: WebSocketLike, ev: { error?: any; message?: string }) => void; - onclose?: (this: WebSocketLike, ev: { code: number; reason?: string }) => void; + onerror?: ( + this: WebSocketLike, + ev: { error?: any; message?: string }, + ) => void; + onclose?: ( + this: WebSocketLike, + ev: { code: number; reason?: string }, + ) => void; } export interface WebSocketConstructor { @@ -132,7 +138,8 @@ export class Socket extends EventEmitter { // If connecting to Neon Local, use the original host:port directly if (Socket.isNeonLocal) { const protocol = 'http'; // Always use HTTP for local development - const portSuffix = port && port !== '443' && port !== '80' ? `:${port}` : ''; + const portSuffix = + port && port !== '443' && port !== '80' ? `:${port}` : ''; return `${protocol}://${host}${portSuffix}/sql`; } @@ -406,7 +413,6 @@ export class Socket extends EventEmitter { Socket.opts.disableWarningInBrowsers = newValue; } - get disableWarningInBrowsers() { return ( this.opts.disableWarningInBrowsers ?? Socket.disableWarningInBrowsers @@ -503,13 +509,13 @@ export class Socket extends EventEmitter { this.opts.rootCerts = newValue; } - /** + /** * Set `isNeonLocal` to `true` when connecting to a Neon Local proxy instance. * This flag can be used by the driver to enable specific optimizations and * behaviors when working with local development environments. * * Default: `false`. - */ + */ static get isNeonLocal() { return Socket.opts.isNeonLocal ?? Socket.defaults.isNeonLocal; } @@ -609,38 +615,49 @@ export class Socket extends EventEmitter { if (Socket.isNeonLocal) { // Automatically configure for local development - force insecure WebSocket const wsProtocol = 'ws:'; // Always use ws:// for local development - const portSuffix = port && port !== '443' && port !== '80' ? `:${port}` : ''; + const portSuffix = + port && port !== '443' && port !== '80' ? `:${port}` : ''; const wsAddrFull = `${wsProtocol}//${host}${portSuffix}/sql`; - - debug && log('Neon Local: Auto-configured for insecure WebSocket', { wsAddrFull }); + + debug && + log('Neon Local: Auto-configured for insecure WebSocket', { + wsAddrFull, + }); // Build WebSocket options with headers for Neon Local credential injection let wsOptions: any = { headers: { - 'Upgrade': 'websocket', - 'Connection': 'Upgrade' - } + Upgrade: 'websocket', + Connection: 'Upgrade', + }, }; - + if (this.connectionCredentials) { const creds = this.connectionCredentials; - + // Only include non-empty credential values if (creds.user) wsOptions.headers['X-Neon-User'] = creds.user; - if (creds.password) wsOptions.headers['X-Neon-Password'] = creds.password; - if (creds.database) wsOptions.headers['X-Neon-Database'] = creds.database; - - debug && log('Adding Neon Local credential headers from connection string', { - user: creds.user, - database: creds.database - }); + if (creds.password) + wsOptions.headers['X-Neon-Password'] = creds.password; + if (creds.database) + wsOptions.headers['X-Neon-Database'] = creds.database; + + debug && + log('Adding Neon Local credential headers from connection string', { + user: creds.user, + database: creds.database, + }); } // Use the provided WebSocket constructor or fall back to global WebSocket - const WebSocketImpl = this.webSocketConstructor || (typeof WebSocket !== 'undefined' ? WebSocket : undefined); - + const WebSocketImpl = + this.webSocketConstructor || + (typeof WebSocket !== 'undefined' ? WebSocket : undefined); + if (!WebSocketImpl) { - throw new Error('No WebSocket implementation available. Please provide a webSocketConstructor.'); + throw new Error( + 'No WebSocket implementation available. Please provide a webSocketConstructor.', + ); } this.ws = new WebSocketImpl(wsAddrFull, wsOptions); @@ -716,9 +733,7 @@ export class Socket extends EventEmitter { debug && log('WebSocket constructors failed'); this.emit( 'error', - new Error( - `Failed to establish WebSocket connection. ${err}`, - ), + new Error(`Failed to establish WebSocket connection. ${err}`), ); this.emit('close'); } diff --git a/tests/cloudflare/neon_local/test-all-custom.js b/tests/cloudflare/neon_local/test-all-custom.js index 09528e8..0e8ee6f 100644 --- a/tests/cloudflare/neon_local/test-all-custom.js +++ b/tests/cloudflare/neon_local/test-all-custom.js @@ -9,9 +9,9 @@ const __dirname = dirname(__filename); const tests = [ 'test-non-local.js', - 'test-legacy-behavior.js', + 'test-legacy-behavior.js', 'test-neon-local-behavior.js', - 'test-comprehensive.js' + 'test-comprehensive.js', ]; async function runTest(testFile) { @@ -19,13 +19,13 @@ async function runTest(testFile) { console.log(`\n${'='.repeat(60)}`); console.log(`๐Ÿš€ Running: ${testFile}`); console.log(`${'='.repeat(60)}`); - + const testPath = join(__dirname, testFile); - const child = spawn('node', [testPath], { + const child = spawn('node', [testPath], { stdio: 'inherit', - cwd: __dirname + cwd: __dirname, }); - + child.on('close', (code) => { if (code === 0) { console.log(`โœ… ${testFile} PASSED`); @@ -35,7 +35,7 @@ async function runTest(testFile) { reject(new Error(`Test ${testFile} failed with exit code ${code}`)); } }); - + child.on('error', (err) => { console.log(`โŒ ${testFile} ERROR: ${err.message}`); reject(err); @@ -46,10 +46,10 @@ async function runTest(testFile) { async function runAllTests() { console.log('๐Ÿงช Running All Custom Serverless Driver Tests'); console.log('๐Ÿ“‹ Testing both legacy and new isNeonLocal functionality\n'); - + let passed = 0; let failed = 0; - + for (const test of tests) { try { await runTest(test); @@ -59,13 +59,13 @@ async function runAllTests() { failed++; } } - + console.log(`\n${'='.repeat(60)}`); console.log('๐Ÿ“Š FINAL RESULTS'); console.log(`${'='.repeat(60)}`); console.log(`โœ… Passed: ${passed}/${tests.length}`); console.log(`โŒ Failed: ${failed}/${tests.length}`); - + if (failed === 0) { console.log('\n๐ŸŽ‰ ALL TESTS PASSED!'); console.log('โœ… Legacy behavior (isNeonLocal = false) works correctly'); @@ -80,7 +80,7 @@ async function runAllTests() { } } -runAllTests().catch(error => { +runAllTests().catch((error) => { console.error('\nโŒ Test runner failed:', error); process.exit(1); }); diff --git a/tests/cloudflare/neon_local/test-cloudflare-http.js b/tests/cloudflare/neon_local/test-cloudflare-http.js index e6651e0..a8fe1ac 100644 --- a/tests/cloudflare/neon_local/test-cloudflare-http.js +++ b/tests/cloudflare/neon_local/test-cloudflare-http.js @@ -9,16 +9,19 @@ async function testCloudflareHttpPattern() { try { // Configure for Neon Local (what you would do in a Cloudflare Worker) neonConfig.isNeonLocal = true; - + console.log(' ๐Ÿ“‹ Configuration (as in Cloudflare Worker):'); console.log(' isNeonLocal:', neonConfig.isNeonLocal); console.log(' useSecureWebSocket:', neonConfig.useSecureWebSocket); - console.log(' Generated endpoint:', neonConfig.fetchEndpoint('localhost', '5432')); - + console.log( + ' Generated endpoint:', + neonConfig.fetchEndpoint('localhost', '5432'), + ); + // Test 1: Basic query (most common Cloudflare Worker pattern) console.log('\n ๐Ÿ“ก Test 1: Basic SQL query via HTTP'); const sql = neon('postgresql://neon:npg@localhost:5432/neondb'); - + const result1 = await sql` SELECT 'Cloudflare Worker' as platform, @@ -26,14 +29,14 @@ async function testCloudflareHttpPattern() { 'HTTP Transport' as transport, NOW() as timestamp `; - + console.log(' โœ… Basic Query:', result1[0]); - + // Test 2: Query with parameters (common pattern) console.log('\n ๐Ÿ“ก Test 2: Parameterized query'); const userId = 42; const userName = 'CloudflareUser'; - + const result2 = await sql` SELECT ${userId} as user_id, @@ -41,22 +44,22 @@ async function testCloudflareHttpPattern() { 'Parameter injection works' as message, NOW() as created_at `; - + console.log(' โœ… Parameterized Query:', result2[0]); - + // Test 3: Multiple queries (transaction-like pattern) console.log('\n ๐Ÿ“ก Test 3: Multiple queries'); const results = await Promise.all([ sql`SELECT 'Query 1' as query_name, 1 as query_id`, sql`SELECT 'Query 2' as query_name, 2 as query_id`, - sql`SELECT 'Query 3' as query_name, 3 as query_id` + sql`SELECT 'Query 3' as query_name, 3 as query_id`, ]); - + console.log(' โœ… Multiple Queries:'); results.forEach((result, index) => { console.log(` Query ${index + 1}:`, result[0]); }); - + // Test 4: Error handling (important for production) console.log('\n ๐Ÿ“ก Test 4: Error handling'); try { @@ -64,21 +67,20 @@ async function testCloudflareHttpPattern() { } catch (error) { console.log(' โœ… Error handling works:', error.message.split('\n')[0]); } - + console.log('\nโœ… PASS - Cloudflare Worker HTTP Pattern Test'); console.log(' ๐ŸŽ‰ All HTTP patterns work correctly:'); console.log(' - Basic queries'); - console.log(' - Parameterized queries'); + console.log(' - Parameterized queries'); console.log(' - Concurrent queries'); console.log(' - Error handling'); console.log(' ๐Ÿ“Š Neon Local proxy successfully routes HTTP requests'); - + return true; - } catch (error) { console.log('โŒ FAIL - Cloudflare Worker HTTP Pattern Test'); console.log(' Error:', error.message); - + console.log('\n ๐Ÿ’ก This test requires:'); console.log(' - Neon Local container running (docker-compose up)'); console.log(' - Valid NEON_API_KEY and NEON_PROJECT_ID configured'); @@ -139,7 +141,7 @@ export default { // Run tests if this file is executed directly if (import.meta.url === `file://${process.argv[1]}`) { testCloudflareHttpPattern() - .then(success => { + .then((success) => { if (success) { printCloudflareWorkerExample(); process.exit(0); @@ -147,7 +149,7 @@ if (import.meta.url === `file://${process.argv[1]}`) { process.exit(1); } }) - .catch(error => { + .catch((error) => { console.error('โŒ Test failed:', error); process.exit(1); }); diff --git a/tests/cloudflare/neon_local/test-comprehensive.js b/tests/cloudflare/neon_local/test-comprehensive.js index 032ae57..d18a0f6 100644 --- a/tests/cloudflare/neon_local/test-comprehensive.js +++ b/tests/cloudflare/neon_local/test-comprehensive.js @@ -8,13 +8,15 @@ async function testComprehensive() { // Mock fetch to avoid actual network calls const originalFetch = globalThis.fetch; let fetchCallCount = 0; - + globalThis.fetch = async (url, options) => { fetchCallCount++; console.log(`๐Ÿ“ก Fetch call #${fetchCallCount}:`, { url, method: options.method, - hasNeonHeaders: Object.keys(options.headers).some(h => h.startsWith('X-Neon-')) + hasNeonHeaders: Object.keys(options.headers).some((h) => + h.startsWith('X-Neon-'), + ), }); return { @@ -23,78 +25,97 @@ async function testComprehensive() { fields: [{ name: 'test', dataTypeID: 25 }], command: 'SELECT', rowCount: 1, - rows: [['test passed']] - }) + rows: [['test passed']], + }), }; }; try { console.log('\n๐Ÿ“ Test 1: Switch from Cloud to Local'); - + // Start with cloud behavior neonConfig.isNeonLocal = false; console.log(' ๐Ÿ” isNeonLocal:', neonConfig.isNeonLocal); console.log(' ๐Ÿ” useSecureWebSocket:', neonConfig.useSecureWebSocket); - - const cloudSql = neon('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname'); + + const cloudSql = neon( + 'postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname', + ); await cloudSql`SELECT 'cloud test' as test`; - + // Switch to local behavior neonConfig.isNeonLocal = true; console.log(' ๐Ÿ” After setting isNeonLocal=true:'); console.log(' ๐Ÿ” isNeonLocal:', neonConfig.isNeonLocal); - console.log(' ๐Ÿ” useSecureWebSocket (auto):', neonConfig.useSecureWebSocket); - + console.log( + ' ๐Ÿ” useSecureWebSocket (auto):', + neonConfig.useSecureWebSocket, + ); + const localSql = neon('postgresql://user:pass@127.0.0.1:5432/dbname'); await localSql`SELECT 'local test' as test`; console.log('\n๐Ÿ“ Test 2: Switch from Local to Cloud'); - + // Switch back to cloud neonConfig.isNeonLocal = false; console.log(' ๐Ÿ” After setting isNeonLocal=false:'); console.log(' ๐Ÿ” isNeonLocal:', neonConfig.isNeonLocal); - console.log(' ๐Ÿ” useSecureWebSocket (restored):', neonConfig.useSecureWebSocket); - - const cloudSql2 = neon('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname'); + console.log( + ' ๐Ÿ” useSecureWebSocket (restored):', + neonConfig.useSecureWebSocket, + ); + + const cloudSql2 = neon( + 'postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname', + ); await cloudSql2`SELECT 'cloud test 2' as test`; console.log('\n๐Ÿ“ Test 3: Multiple instances with different configs'); - + // Test that instance-level config doesn't interfere with global neonConfig.isNeonLocal = false; // Global setting - - const cloudInstance = neon('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname'); + + const cloudInstance = neon( + 'postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname', + ); await cloudInstance`SELECT 'global cloud' as test`; - + // Change global to local neonConfig.isNeonLocal = true; - + const localInstance = neon('postgresql://user:pass@127.0.0.1:5432/dbname'); await localInstance`SELECT 'global local' as test`; console.log('\n๐Ÿ“ Test 4: Endpoint generation consistency'); - + // Test endpoint generation for both modes neonConfig.isNeonLocal = false; - const cloudEndpoint = neonConfig.fetchEndpoint('ep-test-123.us-east-2.aws.neon.tech', '5432'); + const cloudEndpoint = neonConfig.fetchEndpoint( + 'ep-test-123.us-east-2.aws.neon.tech', + '5432', + ); console.log(' ๐Ÿ” Cloud endpoint:', cloudEndpoint); - + neonConfig.isNeonLocal = true; const localEndpoint = neonConfig.fetchEndpoint('127.0.0.1', '5432'); console.log(' ๐Ÿ” Local endpoint:', localEndpoint); - + // Verify they're different and correct if (cloudEndpoint === localEndpoint) { throw new Error('Cloud and local endpoints should be different'); } - + if (!cloudEndpoint.includes('https://api.')) { - throw new Error(`Cloud endpoint should use https://api., got: ${cloudEndpoint}`); + throw new Error( + `Cloud endpoint should use https://api., got: ${cloudEndpoint}`, + ); } - + if (!localEndpoint.includes('http://127.0.0.1:5432')) { - throw new Error(`Local endpoint should use http://127.0.0.1:5432, got: ${localEndpoint}`); + throw new Error( + `Local endpoint should use http://127.0.0.1:5432, got: ${localEndpoint}`, + ); } console.log('\nโœ… ALL COMPREHENSIVE TESTS PASSED'); @@ -103,7 +124,6 @@ async function testComprehensive() { console.log(' - Auto-configuration works properly'); console.log(' - Multiple instances handle configs correctly'); console.log(' - Endpoint generation is consistent'); - } catch (error) { console.error('โŒ Comprehensive test failed:', error.message); process.exit(1); @@ -114,7 +134,7 @@ async function testComprehensive() { } } -testComprehensive().catch(error => { +testComprehensive().catch((error) => { console.error('โŒ Test failed:', error); process.exit(1); }); diff --git a/tests/cloudflare/neon_local/test-legacy-behavior.js b/tests/cloudflare/neon_local/test-legacy-behavior.js index 75bf693..588ba26 100644 --- a/tests/cloudflare/neon_local/test-legacy-behavior.js +++ b/tests/cloudflare/neon_local/test-legacy-behavior.js @@ -7,14 +7,14 @@ async function testLegacyBehavior() { // Explicitly ensure isNeonLocal is false (default behavior) neonConfig.isNeonLocal = false; - + // Mock fetch to avoid actual network calls const originalFetch = globalThis.fetch; globalThis.fetch = async (url, options) => { console.log('๐Ÿ“ก Fetch intercepted:', { url, method: options.method, - headers: options.headers + headers: options.headers, }); // Verify expected cloud behavior @@ -28,58 +28,71 @@ async function testLegacyBehavior() { fields: [{ name: 'test', dataTypeID: 25 }], command: 'SELECT', rowCount: 1, - rows: [['legacy test passed']] - }) + rows: [['legacy test passed']], + }), }; }; try { console.log('\n๐Ÿ“ Test 1: neon() function with isNeonLocal = false'); - + // Test 1: Basic neon function - const sql = neon('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname'); + const sql = neon( + 'postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname', + ); const result = await sql`SELECT 'legacy test' as test`; console.log('โœ… Result:', result[0]); console.log('\n๐Ÿ“ Test 2: Configuration values'); - + // Test 2: Check that configuration values are as expected console.log('๐Ÿ” isNeonLocal:', neonConfig.isNeonLocal); console.log('๐Ÿ” useSecureWebSocket:', neonConfig.useSecureWebSocket); console.log('๐Ÿ” fetchEndpoint type:', typeof neonConfig.fetchEndpoint); - + // Verify defaults if (neonConfig.isNeonLocal !== false) { - throw new Error(`Expected isNeonLocal to be false, got: ${neonConfig.isNeonLocal}`); + throw new Error( + `Expected isNeonLocal to be false, got: ${neonConfig.isNeonLocal}`, + ); } - + if (neonConfig.useSecureWebSocket !== true) { - throw new Error(`Expected useSecureWebSocket to be true, got: ${neonConfig.useSecureWebSocket}`); + throw new Error( + `Expected useSecureWebSocket to be true, got: ${neonConfig.useSecureWebSocket}`, + ); } console.log('\n๐Ÿ“ Test 3: fetchEndpoint behavior'); - + // Test 3: Verify fetchEndpoint behavior for cloud - const endpoint = neonConfig.fetchEndpoint('ep-test-123.us-east-2.aws.neon.tech', '5432'); + const endpoint = neonConfig.fetchEndpoint( + 'ep-test-123.us-east-2.aws.neon.tech', + '5432', + ); console.log('๐Ÿ” Generated endpoint:', endpoint); - + if (!endpoint.includes('https://api.')) { throw new Error(`Expected https://api. URL, got: ${endpoint}`); } - console.log('\n๐Ÿ“ Test 4: Client constructor doesn\'t break'); - + console.log("\n๐Ÿ“ Test 4: Client constructor doesn't break"); + // Test 4: Verify Client and Pool constructors still work - const client = new Client('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname'); - const pool = new Pool({ connectionString: 'postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname' }); - + const client = new Client( + 'postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname', + ); + const pool = new Pool({ + connectionString: + 'postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname', + }); + console.log('โœ… Client and Pool constructors work'); console.log('\nโœ… ALL LEGACY BEHAVIOR TESTS PASSED'); console.log(' - isNeonLocal = false works correctly'); console.log(' - Cloud URLs are generated properly'); console.log(' - All existing functionality preserved'); - } catch (error) { console.error('โŒ Legacy behavior test failed:', error.message); process.exit(1); @@ -89,7 +102,7 @@ async function testLegacyBehavior() { } } -testLegacyBehavior().catch(error => { +testLegacyBehavior().catch((error) => { console.error('โŒ Test failed:', error); process.exit(1); }); diff --git a/tests/cloudflare/neon_local/test-neon-local-behavior.js b/tests/cloudflare/neon_local/test-neon-local-behavior.js index f4954d5..0b08879 100644 --- a/tests/cloudflare/neon_local/test-neon-local-behavior.js +++ b/tests/cloudflare/neon_local/test-neon-local-behavior.js @@ -7,14 +7,14 @@ async function testNeonLocalBehavior() { // Set isNeonLocal to true neonConfig.isNeonLocal = true; - + // Mock fetch to avoid actual network calls const originalFetch = globalThis.fetch; globalThis.fetch = async (url, options) => { console.log('๐Ÿ“ก Fetch intercepted:', { url, method: options.method, - headers: options.headers + headers: options.headers, }); // Verify expected local behavior @@ -23,7 +23,9 @@ async function testNeonLocalBehavior() { } // Check for X-Neon-* headers - const hasNeonHeaders = Object.keys(options.headers).some(h => h.startsWith('X-Neon-')); + const hasNeonHeaders = Object.keys(options.headers).some((h) => + h.startsWith('X-Neon-'), + ); if (!hasNeonHeaders) { throw new Error('Expected X-Neon-* headers for credential injection'); } @@ -34,69 +36,88 @@ async function testNeonLocalBehavior() { fields: [{ name: 'test', dataTypeID: 25 }], command: 'SELECT', rowCount: 1, - rows: [['neon local test passed']] - }) + rows: [['neon local test passed']], + }), }; }; try { console.log('\n๐Ÿ“ Test 1: neon() function with isNeonLocal = true'); - + // Test 1: Basic neon function const sql = neon('postgresql://testuser:testpass@127.0.0.1:5432/testdb'); const result = await sql`SELECT 'neon local test' as test`; console.log('โœ… Result:', result[0]); console.log('\n๐Ÿ“ Test 2: Configuration values auto-configured'); - + // Test 2: Check that configuration values are auto-configured console.log('๐Ÿ” isNeonLocal:', neonConfig.isNeonLocal); - console.log('๐Ÿ” useSecureWebSocket (auto-configured):', neonConfig.useSecureWebSocket); - + console.log( + '๐Ÿ” useSecureWebSocket (auto-configured):', + neonConfig.useSecureWebSocket, + ); + // Verify auto-configuration if (neonConfig.isNeonLocal !== true) { - throw new Error(`Expected isNeonLocal to be true, got: ${neonConfig.isNeonLocal}`); + throw new Error( + `Expected isNeonLocal to be true, got: ${neonConfig.isNeonLocal}`, + ); } - + if (neonConfig.useSecureWebSocket !== false) { - throw new Error(`Expected useSecureWebSocket to be auto-configured to false, got: ${neonConfig.useSecureWebSocket}`); + throw new Error( + `Expected useSecureWebSocket to be auto-configured to false, got: ${neonConfig.useSecureWebSocket}`, + ); } console.log('\n๐Ÿ“ Test 3: fetchEndpoint behavior for local'); - + // Test 3: Verify fetchEndpoint behavior for local const endpoint = neonConfig.fetchEndpoint('127.0.0.1', '5432'); console.log('๐Ÿ” Generated endpoint:', endpoint); - + if (!endpoint.includes('http://127.0.0.1:5432/sql')) { - throw new Error(`Expected http://127.0.0.1:5432/sql URL, got: ${endpoint}`); + throw new Error( + `Expected http://127.0.0.1:5432/sql URL, got: ${endpoint}`, + ); } console.log('\n๐Ÿ“ Test 4: Credential injection in HTTP requests'); - + // Reset fetch mock to capture credential headers globalThis.fetch = async (url, options) => { console.log('๐Ÿ“ก Credential test - Headers captured:', options.headers); - + // Verify X-Neon-* headers are present - const requiredHeaders = ['X-Neon-User', 'X-Neon-Password', 'X-Neon-Database']; + const requiredHeaders = [ + 'X-Neon-User', + 'X-Neon-Password', + 'X-Neon-Database', + ]; for (const header of requiredHeaders) { if (!options.headers[header]) { throw new Error(`Missing required header: ${header}`); } } - + // Verify header values if (options.headers['X-Neon-User'] !== 'testuser') { - throw new Error(`Expected X-Neon-User to be 'testuser', got: ${options.headers['X-Neon-User']}`); + throw new Error( + `Expected X-Neon-User to be 'testuser', got: ${options.headers['X-Neon-User']}`, + ); } - + if (options.headers['X-Neon-Password'] !== 'testpass') { - throw new Error(`Expected X-Neon-Password to be 'testpass', got: ${options.headers['X-Neon-Password']}`); + throw new Error( + `Expected X-Neon-Password to be 'testpass', got: ${options.headers['X-Neon-Password']}`, + ); } - + if (options.headers['X-Neon-Database'] !== 'testdb') { - throw new Error(`Expected X-Neon-Database to be 'testdb', got: ${options.headers['X-Neon-Database']}`); + throw new Error( + `Expected X-Neon-Database to be 'testdb', got: ${options.headers['X-Neon-Database']}`, + ); } return { @@ -105,30 +126,33 @@ async function testNeonLocalBehavior() { fields: [{ name: 'test', dataTypeID: 25 }], command: 'SELECT', rowCount: 1, - rows: [['credential injection works']] - }) + rows: [['credential injection works']], + }), }; }; - - const sqlWithCreds = neon('postgresql://testuser:testpass@127.0.0.1:5432/testdb'); + + const sqlWithCreds = neon( + 'postgresql://testuser:testpass@127.0.0.1:5432/testdb', + ); const credResult = await sqlWithCreds`SELECT 'credential test' as test`; console.log('โœ… Credential injection result:', credResult[0]); console.log('\n๐Ÿ“ Test 5: Client credential injection setup'); - + // Test 5: Verify Client sets up credentials correctly - const client = new Client('postgresql://clientuser:clientpass@127.0.0.1:5432/clientdb'); - + const client = new Client( + 'postgresql://clientuser:clientpass@127.0.0.1:5432/clientdb', + ); + // Client should have set up credentials automatically console.log('โœ… Client with Neon Local configured successfully'); console.log('\nโœ… ALL NEON LOCAL BEHAVIOR TESTS PASSED'); console.log(' - isNeonLocal = true works correctly'); console.log(' - useSecureWebSocket auto-configures to false'); - console.log(' - Local HTTP URLs are generated properly'); + console.log(' - Local HTTP URLs are generated properly'); console.log(' - X-Neon-* header injection works'); console.log(' - Client integration works'); - } catch (error) { console.error('โŒ Neon Local behavior test failed:', error.message); process.exit(1); @@ -139,7 +163,7 @@ async function testNeonLocalBehavior() { } } -testNeonLocalBehavior().catch(error => { +testNeonLocalBehavior().catch((error) => { console.error('โŒ Test failed:', error); process.exit(1); }); diff --git a/tests/cloudflare/neon_local/test-non-local.js b/tests/cloudflare/neon_local/test-non-local.js index 045473e..2062cdb 100644 --- a/tests/cloudflare/neon_local/test-non-local.js +++ b/tests/cloudflare/neon_local/test-non-local.js @@ -8,7 +8,7 @@ class DebugWebSocket extends WebSocket { constructor(url, options) { console.log('๐Ÿ” Creating WebSocket connection:', { url, - headers: options?.headers + headers: options?.headers, }); super(url, options); @@ -23,7 +23,7 @@ class DebugWebSocket extends WebSocket { this.addEventListener('close', (event) => { console.log('๐Ÿ” WebSocket closed:', { code: event.code, - reason: event.reason || 'none' + reason: event.reason || 'none', }); }); @@ -47,7 +47,7 @@ async function testNonLocal() { console.log('๐Ÿ“ก HTTP Request:', { url, method: options.method, - headers: options.headers + headers: options.headers, }); // Return a mock response @@ -57,29 +57,35 @@ async function testNonLocal() { fields: [{ name: 'version', dataTypeID: 25 }], command: 'SELECT', rowCount: 1, - rows: [['PostgreSQL 17.5']] - }) + rows: [['PostgreSQL 17.5']], + }), }; }; try { // Test 1: Regular WebSocket connection console.log('\n๐Ÿ“ Test 1: Regular WebSocket Connection'); - const sql1 = neon('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname'); + const sql1 = neon( + 'postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname', + ); const result1 = await sql1`SELECT version() as version`; console.log('๐Ÿ“ฅ Result:', result1[0]); // Test 2: TLS over WebSocket console.log('\n๐Ÿ“ Test 2: TLS over WebSocket'); neonConfig.forceDisablePgSSL = false; - const sql2 = neon('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname?sslmode=require'); + const sql2 = neon( + 'postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname?sslmode=require', + ); const result2 = await sql2`SELECT version() as version`; console.log('๐Ÿ“ฅ Result:', result2[0]); // Test 3: HTTP queries console.log('\n๐Ÿ“ Test 3: HTTP Queries'); neonConfig.poolQueryViaFetch = true; - const sql3 = neon('postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname'); + const sql3 = neon( + 'postgresql://user:pass@ep-test-123.us-east-2.aws.neon.tech/dbname', + ); const result3 = await sql3`SELECT version() as version`; console.log('๐Ÿ“ฅ Result:', result3[0]); } catch (err) { @@ -99,7 +105,7 @@ async function testNonLocal() { // Run test if this file is executed directly if (import.meta.url === `file://${process.argv[1]}`) { - testNonLocal().catch(error => { + testNonLocal().catch((error) => { console.error('โŒ Test failed:', error); process.exit(1); });