orange-orm
Version:
Object Relational Mapper
1,527 lines • 474 kB
JavaScript
import { n as __toESM } from "./orange-orm.js";
import { a as or, c as F$2, d as R$1, f as T, g as x$2, h as u, l as L$1, m as h, n as Vr, p as U$1, r as ce$1, s as ur, t as C$2, u as P$1 } from "./chunk-VBDAOXYI-DoAeWiRV.js";
//#region ../../node_modules/@electric-sql/pglite/dist/chunk-CICTNUP7.js
var hn = {};
F$2(hn, {
ABSTIME: () => Et,
ACLITEM: () => Vt,
BIT: () => jt,
BOOL: () => be,
BPCHAR: () => _e,
BYTEA: () => ge,
CHAR: () => gt,
CID: () => St,
CIDR: () => Tt,
CIRCLE: () => Ut,
DATE: () => He,
FLOAT4: () => Qe$1,
FLOAT8: () => We,
GTSVECTOR: () => rn,
INET: () => kt,
INT2: () => ve,
INT4: () => Ge,
INT8: () => we,
INTERVAL: () => vt,
JSON: () => Ae$1,
JSONB: () => Ye$1,
MACADDR: () => Ot,
MACADDR8: () => Nt,
MONEY: () => Lt,
NUMERIC: () => Wt,
OID: () => je,
PATH: () => Mt,
PG_DEPENDENCIES: () => en,
PG_LSN: () => Xt,
PG_NDISTINCT: () => Zt,
PG_NODE_TREE: () => Bt,
POLYGON: () => Rt,
REFCURSOR: () => _t,
REGCLASS: () => Yt,
REGCONFIG: () => sn,
REGDICTIONARY: () => an,
REGNAMESPACE: () => on,
REGOPER: () => Ht,
REGOPERATOR: () => qt,
REGPROC: () => wt,
REGPROCEDURE: () => zt,
REGROLE: () => un,
REGTYPE: () => $t,
RELTIME: () => Ct,
SMGR: () => It,
TEXT: () => V$1,
TID: () => At,
TIME: () => Ft,
TIMESTAMP: () => qe$1,
TIMESTAMPTZ: () => xe,
TIMETZ: () => Gt,
TINTERVAL: () => Pt,
TSQUERY: () => nn,
TSVECTOR: () => tn,
TXID_SNAPSHOT: () => Jt,
UUID: () => Kt,
VARBIT: () => Qt,
VARCHAR: () => ze$1,
XID: () => xt,
XML: () => Dt,
arrayParser: () => yn,
arraySerializer: () => Ke$1,
parseType: () => ue$1,
parsers: () => ln,
serializers: () => cn,
types: () => $e$1
});
u();
var ht = globalThis.JSON.parse, bt = globalThis.JSON.stringify, be = 16, ge = 17, gt = 18, we = 20, ve = 21, Ge = 23, wt = 24, V$1 = 25, je = 26, At = 27, xt = 28, St = 29, Ae$1 = 114, Dt = 142, Bt = 194, It = 210, Mt = 602, Rt = 604, Tt = 650, Qe$1 = 700, We = 701, Et = 702, Ct = 703, Pt = 704, Ut = 718, Nt = 774, Lt = 790, Ot = 829, kt = 869, Vt = 1033, _e = 1042, ze$1 = 1043, He = 1082, Ft = 1083, qe$1 = 1114, xe = 1184, vt = 1186, Gt = 1266, jt = 1560, Qt = 1562, Wt = 1700, _t = 1790, zt = 2202, Ht = 2203, qt = 2204, Yt = 2205, $t = 2206, Kt = 2950, Jt = 2970, Xt = 3220, Zt = 3361, en = 3402, tn = 3614, nn = 3615, rn = 3642, sn = 3734, an = 3769, Ye$1 = 3802, on = 4089, un = 4096, $e$1 = {
string: {
to: V$1,
from: [
V$1,
ze$1,
_e
],
serialize: (e) => {
if (typeof e == "string") return e;
if (typeof e == "number") return e.toString();
throw new Error("Invalid input for string type");
},
parse: (e) => e
},
number: {
to: 0,
from: [
ve,
Ge,
je,
Qe$1,
We
],
serialize: (e) => e.toString(),
parse: (e) => +e
},
bigint: {
to: we,
from: [we],
serialize: (e) => e.toString(),
parse: (e) => {
let t = BigInt(e);
return t < Number.MIN_SAFE_INTEGER || t > Number.MAX_SAFE_INTEGER ? t : Number(t);
}
},
json: {
to: Ae$1,
from: [Ae$1, Ye$1],
serialize: (e) => typeof e == "string" ? e : bt(e),
parse: (e) => ht(e)
},
boolean: {
to: be,
from: [be],
serialize: (e) => {
if (typeof e != "boolean") throw new Error("Invalid input for boolean type");
return e ? "t" : "f";
},
parse: (e) => e === "t"
},
date: {
to: xe,
from: [
He,
qe$1,
xe
],
serialize: (e) => {
if (typeof e == "string") return e;
if (typeof e == "number") return new Date(e).toISOString();
if (e instanceof Date) return e.toISOString();
throw new Error("Invalid input for date type");
},
parse: (e) => new Date(e)
},
bytea: {
to: ge,
from: [ge],
serialize: (e) => {
if (!(e instanceof Uint8Array)) throw new Error("Invalid input for bytea type");
return "\\x" + Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
},
parse: (e) => {
let t = e.slice(2);
return Uint8Array.from({ length: t.length / 2 }, (n, r) => parseInt(t.substring(r * 2, (r + 1) * 2), 16));
}
}
}, Se = pn($e$1), ln = Se.parsers, cn = Se.serializers;
function ue$1(e, t, n) {
if (e === null) return null;
let r = n?.[t] ?? Se.parsers[t];
return r ? r(e, t) : e;
}
function pn(e) {
return Object.keys(e).reduce(({ parsers: t, serializers: n }, r) => {
let { to: i, from: a, serialize: u, parse: d } = e[r];
return n[i] = u, n[r] = u, t[r] = d, Array.isArray(a) ? a.forEach((c) => {
t[c] = d, n[c] = u;
}) : (t[a] = d, n[a] = u), {
parsers: t,
serializers: n
};
}, {
parsers: {},
serializers: {}
});
}
var dn = /\\/g, fn = /"/g;
function mn(e) {
return e.replace(dn, "\\\\").replace(fn, "\\\"");
}
function Ke$1(e, t, n) {
if (Array.isArray(e) === !1) return e;
if (!e.length) return "{}";
let r = e[0], i = n === 1020 ? ";" : ",";
return Array.isArray(r) ? `{${e.map((a) => Ke$1(a, t, n)).join(i)}}` : `{${e.map((a) => (a === void 0 && (a = null), a === null ? "null" : "\"" + mn(t ? t(a) : a.toString()) + "\"")).join(i)}}`;
}
var he$1 = {
i: 0,
char: null,
str: "",
quoted: !1,
last: 0,
p: null
};
function yn(e, t, n) {
return he$1.i = he$1.last = 0, Je$1(he$1, e, t, n)[0];
}
function Je$1(e, t, n, r) {
let i = [], a = r === 1020 ? ";" : ",";
for (; e.i < t.length; e.i++) {
if (e.char = t[e.i], e.quoted) e.char === "\\" ? e.str += t[++e.i] : e.char === "\"" ? (i.push(n ? n(e.str) : e.str), e.str = "", e.quoted = t[e.i + 1] === "\"", e.last = e.i + 2) : e.str += e.char;
else if (e.char === "\"") e.quoted = !0;
else if (e.char === "{") e.last = ++e.i, i.push(Je$1(e, t, n, r));
else if (e.char === "}") {
e.quoted = !1, e.last < e.i && i.push(n ? n(t.slice(e.last, e.i)) : t.slice(e.last, e.i)), e.last = e.i + 1;
break;
} else e.char === a && e.p !== "}" && e.p !== "\"" && (i.push(n ? n(t.slice(e.last, e.i)) : t.slice(e.last, e.i)), e.last = e.i + 1);
e.p = e.char;
}
return e.last < e.i && i.push(n ? n(t.slice(e.last, e.i + 1)) : t.slice(e.last, e.i + 1)), i;
}
var wn = {};
F$2(wn, {
parseDescribeStatementResults: () => De$1,
parseResults: () => bn
});
u();
function bn(e, t, n, r) {
let i = [], a = {
rows: [],
fields: []
}, u = 0, d = {
...t,
...n?.parsers
};
return e.forEach((c) => {
switch (c.name) {
case "rowDescription":
a.fields = c.fields.map((T) => ({
name: T.name,
dataTypeID: T.dataTypeID
}));
break;
case "dataRow": {
if (!a) break;
let k = c;
n?.rowMode === "array" ? a.rows.push(k.fields.map((T, ie) => ue$1(T, a.fields[ie].dataTypeID, d))) : a.rows.push(Object.fromEntries(k.fields.map((T, ie) => [a.fields[ie].name, ue$1(T, a.fields[ie].dataTypeID, d)])));
break;
}
case "commandComplete":
u += gn(c), i.push({
...a,
affectedRows: u,
...r ? { blob: r } : {}
}), a = {
rows: [],
fields: []
};
break;
}
}), i.length === 0 && i.push({
affectedRows: 0,
rows: [],
fields: []
}), i;
}
function gn(e) {
let t = e.text.split(" ");
switch (t[0]) {
case "INSERT": return parseInt(t[2], 10);
case "UPDATE":
case "DELETE":
case "COPY":
case "MERGE": return parseInt(t[1], 10);
default: return 0;
}
}
function De$1(e) {
let t = e.find((n) => n.name === "parameterDescription");
return t ? t.dataTypeIDs : [];
}
var Ue = {};
F$2(Ue, {
AuthenticationCleartextPassword: () => v,
AuthenticationMD5Password: () => G,
AuthenticationOk: () => F$1,
AuthenticationSASL: () => j$1,
AuthenticationSASLContinue: () => Q$1,
AuthenticationSASLFinal: () => W,
BackendKeyDataMessage: () => K$1,
CommandCompleteMessage: () => Z$1,
CopyDataMessage: () => _,
CopyResponse: () => z,
DataRowMessage: () => ee$1,
DatabaseError: () => E$1,
Field: () => H$1,
NoticeMessage: () => te$1,
NotificationResponseMessage: () => J$1,
ParameterDescriptionMessage: () => Y$1,
ParameterStatusMessage: () => $$1,
ReadyForQueryMessage: () => X$1,
RowDescriptionMessage: () => q,
bindComplete: () => Ie$1,
closeComplete: () => Me,
copyDone: () => Pe,
emptyQuery: () => Ce$1,
noData: () => Re$1,
parseComplete: () => Be,
portalSuspended: () => Te$1,
replicationStart: () => Ee
});
u();
var Be = {
name: "parseComplete",
length: 5
}, Ie$1 = {
name: "bindComplete",
length: 5
}, Me = {
name: "closeComplete",
length: 5
}, Re$1 = {
name: "noData",
length: 5
}, Te$1 = {
name: "portalSuspended",
length: 5
}, Ee = {
name: "replicationStart",
length: 4
}, Ce$1 = {
name: "emptyQuery",
length: 4
}, Pe = {
name: "copyDone",
length: 4
}, F$1 = class {
constructor(t) {
this.length = t;
this.name = "authenticationOk";
}
}, v = class {
constructor(t) {
this.length = t;
this.name = "authenticationCleartextPassword";
}
}, G = class {
constructor(t, n) {
this.length = t;
this.salt = n;
this.name = "authenticationMD5Password";
}
}, j$1 = class {
constructor(t, n) {
this.length = t;
this.mechanisms = n;
this.name = "authenticationSASL";
}
}, Q$1 = class {
constructor(t, n) {
this.length = t;
this.data = n;
this.name = "authenticationSASLContinue";
}
}, W = class {
constructor(t, n) {
this.length = t;
this.data = n;
this.name = "authenticationSASLFinal";
}
}, E$1 = class extends Error {
constructor(n, r, i) {
super(n);
this.length = r;
this.name = i;
}
}, _ = class {
constructor(t, n) {
this.length = t;
this.chunk = n;
this.name = "copyData";
}
}, z = class {
constructor(t, n, r, i) {
this.length = t;
this.name = n;
this.binary = r;
this.columnTypes = new Array(i);
}
}, H$1 = class {
constructor(t, n, r, i, a, u, d) {
this.name = t;
this.tableID = n;
this.columnID = r;
this.dataTypeID = i;
this.dataTypeSize = a;
this.dataTypeModifier = u;
this.format = d;
}
}, q = class {
constructor(t, n) {
this.length = t;
this.fieldCount = n;
this.name = "rowDescription";
this.fields = new Array(this.fieldCount);
}
}, Y$1 = class {
constructor(t, n) {
this.length = t;
this.parameterCount = n;
this.name = "parameterDescription";
this.dataTypeIDs = new Array(this.parameterCount);
}
}, $$1 = class {
constructor(t, n, r) {
this.length = t;
this.parameterName = n;
this.parameterValue = r;
this.name = "parameterStatus";
}
}, K$1 = class {
constructor(t, n, r) {
this.length = t;
this.processID = n;
this.secretKey = r;
this.name = "backendKeyData";
}
}, J$1 = class {
constructor(t, n, r, i) {
this.length = t;
this.processId = n;
this.channel = r;
this.payload = i;
this.name = "notification";
}
}, X$1 = class {
constructor(t, n) {
this.length = t;
this.status = n;
this.name = "readyForQuery";
}
}, Z$1 = class {
constructor(t, n) {
this.length = t;
this.text = n;
this.name = "commandComplete";
}
}, ee$1 = class {
constructor(t, n) {
this.length = t;
this.fields = n;
this.name = "dataRow";
this.fieldCount = n.length;
}
}, te$1 = class {
constructor(t, n) {
this.length = t;
this.message = n;
this.name = "notice";
}
};
var zn = {};
F$2(zn, {
Parser: () => ye,
messages: () => Ue,
serialize: () => O$1
});
u();
u();
u();
u();
function C$1(e) {
let t = e.length;
for (let n = e.length - 1; n >= 0; n--) {
let r = e.charCodeAt(n);
r > 127 && r <= 2047 ? t++ : r > 2047 && r <= 65535 && (t += 2), r >= 56320 && r <= 57343 && n--;
}
return t;
}
var b, g$1, U, ce, N, x$1, le$1, P, Xe, R = class {
constructor(t = 256) {
this.size = t;
R$1(this, x$1);
R$1(this, b);
R$1(this, g$1, 5);
R$1(this, U, !1);
R$1(this, ce, new TextEncoder());
R$1(this, N, 0);
x$2(this, b, T(this, x$1, le$1).call(this, t));
}
addInt32(t) {
return T(this, x$1, P).call(this, 4), h(this, b).setInt32(h(this, g$1), t, h(this, U)), x$2(this, g$1, h(this, g$1) + 4), this;
}
addInt16(t) {
return T(this, x$1, P).call(this, 2), h(this, b).setInt16(h(this, g$1), t, h(this, U)), x$2(this, g$1, h(this, g$1) + 2), this;
}
addCString(t) {
return t && this.addString(t), T(this, x$1, P).call(this, 1), h(this, b).setUint8(h(this, g$1), 0), U$1(this, g$1)._++, this;
}
addString(t = "") {
let n = C$1(t);
return T(this, x$1, P).call(this, n), h(this, ce).encodeInto(t, new Uint8Array(h(this, b).buffer, h(this, g$1))), x$2(this, g$1, h(this, g$1) + n), this;
}
add(t) {
return T(this, x$1, P).call(this, t.byteLength), new Uint8Array(h(this, b).buffer).set(new Uint8Array(t), h(this, g$1)), x$2(this, g$1, h(this, g$1) + t.byteLength), this;
}
flush(t) {
let n = T(this, x$1, Xe).call(this, t);
return x$2(this, g$1, 5), x$2(this, b, T(this, x$1, le$1).call(this, this.size)), new Uint8Array(n);
}
};
b = /* @__PURE__ */ new WeakMap(), g$1 = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap(), ce = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap(), x$1 = /* @__PURE__ */ new WeakSet(), le$1 = function(t) {
return new DataView(new ArrayBuffer(t));
}, P = function(t) {
if (h(this, b).byteLength - h(this, g$1) < t) {
let r = h(this, b).buffer, i = r.byteLength + (r.byteLength >> 1) + t;
x$2(this, b, T(this, x$1, le$1).call(this, i)), new Uint8Array(h(this, b).buffer).set(new Uint8Array(r));
}
}, Xe = function(t) {
if (t) {
h(this, b).setUint8(h(this, N), t);
let n = h(this, g$1) - (h(this, N) + 1);
h(this, b).setInt32(h(this, N) + 1, n, h(this, U));
}
return h(this, b).buffer.slice(t ? 0 : 5, h(this, g$1));
};
var m$1 = new R(), An = (e) => {
m$1.addInt16(3).addInt16(0);
for (let r of Object.keys(e)) m$1.addCString(r).addCString(e[r]);
m$1.addCString("client_encoding").addCString("UTF8");
let t = m$1.addCString("").flush(), n = t.byteLength + 4;
return new R().addInt32(n).add(t).flush();
}, xn = () => {
let e = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
return e.setInt32(0, 8, !1), e.setInt32(4, 80877103, !1), new Uint8Array(e.buffer);
}, Sn = (e) => m$1.addCString(e).flush(112), Dn = (e, t) => (m$1.addCString(e).addInt32(C$1(t)).addString(t), m$1.flush(112)), Bn = (e) => m$1.addString(e).flush(112), In = (e) => m$1.addCString(e).flush(81), Mn = [], Rn = (e) => {
let t = e.name ?? "";
t.length > 63 && (console.error("Warning! Postgres only supports 63 characters for query names."), console.error("You supplied %s (%s)", t, t.length), console.error("This can cause conflicts and silent errors executing queries"));
let n = m$1.addCString(t).addCString(e.text).addInt16(e.types?.length ?? 0);
return e.types?.forEach((r) => n.addInt32(r)), m$1.flush(80);
}, L = new R();
var Tn = (e, t) => {
for (let n = 0; n < e.length; n++) {
let r = t ? t(e[n], n) : e[n];
if (r === null) m$1.addInt16(0), L.addInt32(-1);
else if (r instanceof ArrayBuffer || ArrayBuffer.isView(r)) {
let i = ArrayBuffer.isView(r) ? r.buffer.slice(r.byteOffset, r.byteOffset + r.byteLength) : r;
m$1.addInt16(1), L.addInt32(i.byteLength), L.add(i);
} else m$1.addInt16(0), L.addInt32(C$1(r)), L.addString(r);
}
}, En = (e = {}) => {
let t = e.portal ?? "", n = e.statement ?? "", r = e.binary ?? !1, i = e.values ?? Mn, a = i.length;
return m$1.addCString(t).addCString(n), m$1.addInt16(a), Tn(i, e.valueMapper), m$1.addInt16(a), m$1.add(L.flush()), m$1.addInt16(r ? 1 : 0), m$1.flush(66);
}, Cn = new Uint8Array([
69,
0,
0,
0,
9,
0,
0,
0,
0,
0
]), Pn = (e) => {
if (!e || !e.portal && !e.rows) return Cn;
let t = e.portal ?? "", n = e.rows ?? 0, r = C$1(t), i = 4 + r + 1 + 4, a = new DataView(new ArrayBuffer(1 + i));
return a.setUint8(0, 69), a.setInt32(1, i, !1), new TextEncoder().encodeInto(t, new Uint8Array(a.buffer, 5)), a.setUint8(r + 5, 0), a.setUint32(a.byteLength - 4, n, !1), new Uint8Array(a.buffer);
}, Un = (e, t) => {
let n = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(16));
return n.setInt32(0, 16, !1), n.setInt16(4, 1234, !1), n.setInt16(6, 5678, !1), n.setInt32(8, e, !1), n.setInt32(12, t, !1), new Uint8Array(n.buffer);
}, Ne$1 = (e, t) => {
let n = new R();
return n.addCString(t), n.flush(e);
}, Nn = m$1.addCString("P").flush(68), Ln = m$1.addCString("S").flush(68), On = (e) => e.name ? Ne$1(68, `${e.type}${e.name ?? ""}`) : e.type === "P" ? Nn : Ln, kn = (e) => {
return Ne$1(67, `${e.type}${e.name ?? ""}`);
}, Vn = (e) => m$1.add(e).flush(100), Fn = (e) => Ne$1(102, e), pe$1 = (e) => new Uint8Array([
e,
0,
0,
0,
4
]), vn = pe$1(72), Gn = pe$1(83), jn = pe$1(88), Qn = pe$1(99), O$1 = {
startup: An,
password: Sn,
requestSsl: xn,
sendSASLInitialResponseMessage: Dn,
sendSCRAMClientFinalMessage: Bn,
query: In,
parse: Rn,
bind: En,
execute: Pn,
describe: On,
close: kn,
flush: () => vn,
sync: () => Gn,
end: () => jn,
copyData: Vn,
copyDone: () => Qn,
copyFail: Fn,
cancel: Un
};
u();
u();
var Le = {
text: 0,
binary: 1
};
u();
var Wn = /* @__PURE__ */ new ArrayBuffer(0), M, w, fe$1, me$1, ne$1, de$1 = class {
constructor(t = 0) {
R$1(this, M, new DataView(Wn));
R$1(this, w);
R$1(this, fe$1, "utf-8");
R$1(this, me$1, new TextDecoder(h(this, fe$1)));
R$1(this, ne$1, !1);
x$2(this, w, t);
}
setBuffer(t, n) {
x$2(this, w, t), x$2(this, M, new DataView(n));
}
int16() {
let t = h(this, M).getInt16(h(this, w), h(this, ne$1));
return x$2(this, w, h(this, w) + 2), t;
}
byte() {
let t = h(this, M).getUint8(h(this, w));
return U$1(this, w)._++, t;
}
int32() {
let t = h(this, M).getInt32(h(this, w), h(this, ne$1));
return x$2(this, w, h(this, w) + 4), t;
}
string(t) {
return h(this, me$1).decode(this.bytes(t));
}
cstring() {
let t = h(this, w), n = t;
for (; h(this, M).getUint8(n++) !== 0;);
let r = this.string(n - t - 1);
return x$2(this, w, n), r;
}
bytes(t) {
let n = h(this, M).buffer.slice(h(this, w), h(this, w) + t);
return x$2(this, w, h(this, w) + t), new Uint8Array(n);
}
};
M = /* @__PURE__ */ new WeakMap(), w = /* @__PURE__ */ new WeakMap(), fe$1 = /* @__PURE__ */ new WeakMap(), me$1 = /* @__PURE__ */ new WeakMap(), ne$1 = /* @__PURE__ */ new WeakMap();
var Oe$1 = 1, Ze$1 = Oe$1 + 4, et$1 = /* @__PURE__ */ new ArrayBuffer(0);
var A, S, D, o$1, l, tt$1, nt, rt, st, it, at, ot, ke, ut, lt, ct, pt, dt, ft, mt, yt, Ve, ye = class {
constructor() {
R$1(this, l);
R$1(this, A, new DataView(et$1));
R$1(this, S, 0);
R$1(this, D, 0);
R$1(this, o$1, new de$1());
}
parse(t, n) {
T(this, l, tt$1).call(this, ArrayBuffer.isView(t) ? t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength) : t);
let r = h(this, D) + h(this, S), i = h(this, D);
for (; i + Ze$1 <= r;) {
let a = h(this, A).getUint8(i), u = h(this, A).getUint32(i + Oe$1, !1), d = Oe$1 + u;
if (d + i <= r && u > 0) n(T(this, l, nt).call(this, i + Ze$1, a, u, h(this, A).buffer)), i += d;
else break;
}
i === r ? (x$2(this, A, new DataView(et$1)), x$2(this, S, 0), x$2(this, D, 0)) : (x$2(this, S, r - i), x$2(this, D, i));
}
};
A = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), o$1 = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakSet(), tt$1 = function(t) {
if (h(this, S) > 0) {
let n = h(this, S) + t.byteLength;
if (n + h(this, D) > h(this, A).byteLength) {
let i;
if (n <= h(this, A).byteLength && h(this, D) >= h(this, S)) i = h(this, A).buffer;
else {
let a = h(this, A).byteLength * 2;
for (; n >= a;) a *= 2;
i = new ArrayBuffer(a);
}
new Uint8Array(i).set(new Uint8Array(h(this, A).buffer, h(this, D), h(this, S))), x$2(this, A, new DataView(i)), x$2(this, D, 0);
}
new Uint8Array(h(this, A).buffer).set(new Uint8Array(t), h(this, D) + h(this, S)), x$2(this, S, n);
} else x$2(this, A, new DataView(t)), x$2(this, D, 0), x$2(this, S, t.byteLength);
}, nt = function(t, n, r, i) {
switch (n) {
case 50: return Ie$1;
case 49: return Be;
case 51: return Me;
case 110: return Re$1;
case 115: return Te$1;
case 99: return Pe;
case 87: return Ee;
case 73: return Ce$1;
case 68: return T(this, l, dt).call(this, t, r, i);
case 67: return T(this, l, st).call(this, t, r, i);
case 90: return T(this, l, rt).call(this, t, r, i);
case 65: return T(this, l, ut).call(this, t, r, i);
case 82: return T(this, l, yt).call(this, t, r, i);
case 83: return T(this, l, ft).call(this, t, r, i);
case 75: return T(this, l, mt).call(this, t, r, i);
case 69: return T(this, l, Ve).call(this, t, r, i, "error");
case 78: return T(this, l, Ve).call(this, t, r, i, "notice");
case 84: return T(this, l, lt).call(this, t, r, i);
case 116: return T(this, l, pt).call(this, t, r, i);
case 71: return T(this, l, at).call(this, t, r, i);
case 72: return T(this, l, ot).call(this, t, r, i);
case 100: return T(this, l, it).call(this, t, r, i);
default: return new E$1("received invalid response: " + n.toString(16), r, "error");
}
}, rt = function(t, n, r) {
h(this, o$1).setBuffer(t, r);
return new X$1(n, h(this, o$1).string(1));
}, st = function(t, n, r) {
h(this, o$1).setBuffer(t, r);
return new Z$1(n, h(this, o$1).cstring());
}, it = function(t, n, r) {
let i = r.slice(t, t + (n - 4));
return new _(n, new Uint8Array(i));
}, at = function(t, n, r) {
return T(this, l, ke).call(this, t, n, r, "copyInResponse");
}, ot = function(t, n, r) {
return T(this, l, ke).call(this, t, n, r, "copyOutResponse");
}, ke = function(t, n, r, i) {
h(this, o$1).setBuffer(t, r);
let a = h(this, o$1).byte() !== 0, u = h(this, o$1).int16(), d = new z(n, i, a, u);
for (let c = 0; c < u; c++) d.columnTypes[c] = h(this, o$1).int16();
return d;
}, ut = function(t, n, r) {
h(this, o$1).setBuffer(t, r);
return new J$1(n, h(this, o$1).int32(), h(this, o$1).cstring(), h(this, o$1).cstring());
}, lt = function(t, n, r) {
h(this, o$1).setBuffer(t, r);
let i = h(this, o$1).int16(), a = new q(n, i);
for (let u = 0; u < i; u++) a.fields[u] = T(this, l, ct).call(this);
return a;
}, ct = function() {
return new H$1(h(this, o$1).cstring(), h(this, o$1).int32(), h(this, o$1).int16(), h(this, o$1).int32(), h(this, o$1).int16(), h(this, o$1).int32(), h(this, o$1).int16() === 0 ? Le.text : Le.binary);
}, pt = function(t, n, r) {
h(this, o$1).setBuffer(t, r);
let i = h(this, o$1).int16(), a = new Y$1(n, i);
for (let u = 0; u < i; u++) a.dataTypeIDs[u] = h(this, o$1).int32();
return a;
}, dt = function(t, n, r) {
h(this, o$1).setBuffer(t, r);
let i = h(this, o$1).int16(), a = new Array(i);
for (let u = 0; u < i; u++) {
let d = h(this, o$1).int32();
a[u] = d === -1 ? null : h(this, o$1).string(d);
}
return new ee$1(n, a);
}, ft = function(t, n, r) {
h(this, o$1).setBuffer(t, r);
return new $$1(n, h(this, o$1).cstring(), h(this, o$1).cstring());
}, mt = function(t, n, r) {
h(this, o$1).setBuffer(t, r);
return new K$1(n, h(this, o$1).int32(), h(this, o$1).int32());
}, yt = function(t, n, r) {
h(this, o$1).setBuffer(t, r);
let i = h(this, o$1).int32();
switch (i) {
case 0: return new F$1(n);
case 3: return new v(n);
case 5: return new G(n, h(this, o$1).bytes(4));
case 10: {
let a = [];
for (;;) {
let u = h(this, o$1).cstring();
if (u.length === 0) return new j$1(n, a);
a.push(u);
}
}
case 11: return new Q$1(n, h(this, o$1).string(n - 8));
case 12: return new W(n, h(this, o$1).string(n - 8));
default: throw new Error("Unknown authenticationOk message type " + i);
}
}, Ve = function(t, n, r, i) {
h(this, o$1).setBuffer(t, r);
let a = {}, u = h(this, o$1).string(1);
for (; u !== "\0";) a[u] = h(this, o$1).cstring(), u = h(this, o$1).string(1);
let d = a.M, c = i === "notice" ? new te$1(n, d) : new E$1(d, n, i);
return c.severity = a.S, c.code = a.C, c.detail = a.D, c.hint = a.H, c.position = a.P, c.internalPosition = a.p, c.internalQuery = a.q, c.where = a.W, c.schema = a.s, c.table = a.t, c.column = a.c, c.dataType = a.d, c.constraint = a.n, c.file = a.F, c.line = a.L, c.routine = a.R, c;
};
u();
var Fe = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", se$1;
async function Rr() {
if (Fe || se$1) return;
let e = new URL("../../../../../node_modules/@electric-sql/pglite/dist/pglite.wasm", import.meta.url);
se$1 = fetch(e);
}
var re$1;
async function Tr(e, t) {
if (t || re$1) return {
instance: await WebAssembly.instantiate(t || re$1, e),
module: t || re$1
};
let n = new URL("../../../../../node_modules/@electric-sql/pglite/dist/pglite.wasm", import.meta.url);
if (Fe) {
let i = await (await import("./promises-BDybx7_F.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))).readFile(n), { module: a, instance: u } = await WebAssembly.instantiate(i, e);
return re$1 = a, {
instance: u,
module: a
};
} else {
se$1 || (se$1 = fetch(n));
let r = await se$1, { module: i, instance: a } = await WebAssembly.instantiateStreaming(r, e);
return re$1 = i, {
instance: a,
module: i
};
}
}
async function Er() {
let e = new URL("../../../../../node_modules/@electric-sql/pglite/dist/pglite.data", import.meta.url);
return Fe ? (await (await import("./promises-BDybx7_F.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1))).readFile(e)).buffer : (await fetch(e)).arrayBuffer();
}
var Cr = () => {
if (globalThis.crypto?.randomUUID) return globalThis.crypto.randomUUID();
let e = new Uint8Array(16);
if (globalThis.crypto?.getRandomValues) globalThis.crypto.getRandomValues(e);
else for (let n = 0; n < e.length; n++) e[n] = Math.floor(Math.random() * 256);
e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
let t = [];
return e.forEach((n) => {
t.push(n.toString(16).padStart(2, "0"));
}), t.slice(0, 4).join("") + "-" + t.slice(4, 6).join("") + "-" + t.slice(6, 8).join("") + "-" + t.slice(8, 10).join("") + "-" + t.slice(10).join("");
};
async function Pr(e, t, n, r) {
if (!n || n.length === 0) return t;
r = r ?? e;
let i;
try {
await e.execProtocol(O$1.parse({ text: t }), { syncToFs: !1 }), i = De$1((await e.execProtocol(O$1.describe({ type: "S" }), { syncToFs: !1 })).messages);
} finally {
await e.execProtocol(O$1.sync(), { syncToFs: !1 });
}
let a = t.replace(/\$([0-9]+)/g, (d, c) => "%" + c + "L");
return (await r.query(`SELECT format($1, ${n.map((d, c) => `$${c + 2}`).join(", ")}) as query`, [a, ...n], { paramTypes: [V$1, ...i] })).rows[0].query;
}
function Nr(e) {
let t;
return e.startsWith("\"") && e.endsWith("\"") ? t = e.substring(1, e.length - 1) : t = e.toLowerCase(), t;
}
//#endregion
//#region ../../node_modules/@electric-sql/pglite/dist/chunk-F4GETNPB.js
u();
var o = {
part: "part",
container: "container"
};
function s(t, r, ...e) {
let a = t.length - 1, p = e.length - 1;
if (p !== -1) {
if (p === 0) {
t[a] = t[a] + e[0] + r;
return;
}
t[a] = t[a] + e[0], t.push(...e.slice(1, p)), t.push(e[p] + r);
}
}
function y$1(t, ...r) {
let e = [t[0]];
e.raw = [t.raw[0]];
let a = [];
for (let p = 0; p < r.length; p++) {
let n = r[p], i = p + 1;
if (n?._templateType === o.part) {
s(e, t[i], n.str), s(e.raw, t.raw[i], n.str);
continue;
}
if (n?._templateType === o.container) {
s(e, t[i], ...n.strings), s(e.raw, t.raw[i], ...n.strings.raw), a.push(...n.values);
continue;
}
e.push(t[i]), e.raw.push(t.raw[i]), a.push(n);
}
return {
_templateType: "container",
strings: e,
values: a
};
}
function g(t, ...r) {
let { strings: e, values: a } = y$1(t, ...r);
return {
query: [e[0], ...a.flatMap((p, n) => [`$${n + 1}`, e[n + 1]])].join(""),
params: a
};
}
//#endregion
//#region ../../node_modules/@electric-sql/pglite/dist/chunk-TLRJB2R7.js
u();
u();
function E(h) {
let s = h.e;
return s.query = h.query, s.params = h.params, s.queryOptions = h.options, s;
}
var d, p, t, y, x, m, O, F = class {
constructor() {
R$1(this, t);
this.serializers = { ...cn };
this.parsers = { ...ln };
R$1(this, d, !1);
R$1(this, p, !1);
}
async _initArrayTypes({ force: s = !1 } = {}) {
if (h(this, d) && !s) return;
x$2(this, d, !0);
let e = await this.query(`
SELECT b.oid, b.typarray
FROM pg_catalog.pg_type a
LEFT JOIN pg_catalog.pg_type b ON b.oid = a.typelem
WHERE a.typcategory = 'A'
GROUP BY b.oid, b.typarray
ORDER BY b.oid
`);
for (let r of e.rows) this.serializers[r.typarray] = (n) => Ke$1(n, this.serializers[r.oid], r.typarray), this.parsers[r.typarray] = (n) => yn(n, this.parsers[r.oid], r.typarray);
}
async refreshArrayTypes() {
await this._initArrayTypes({ force: !0 });
}
async query(s, e, r) {
return await this._checkReady(), await this._runExclusiveTransaction(async () => await T(this, t, x).call(this, s, e, r));
}
async sql(s, ...e) {
let { query: r, params: n } = g(s, ...e);
return await this.query(r, n);
}
async exec(s, e) {
return await this._checkReady(), await this._runExclusiveTransaction(async () => await T(this, t, m).call(this, s, e));
}
async describeQuery(s, e) {
try {
await T(this, t, y).call(this, O$1.parse({
text: s,
types: e?.paramTypes
}), e);
let r = await T(this, t, y).call(this, O$1.describe({ type: "S" }), e), n = r.messages.find((c) => c.name === "parameterDescription"), i = r.messages.find((c) => c.name === "rowDescription");
return {
queryParams: n?.dataTypeIDs.map((c) => ({
dataTypeID: c,
serializer: this.serializers[c]
})) ?? [],
resultFields: i?.fields.map((c) => ({
name: c.name,
dataTypeID: c.dataTypeID,
parser: this.parsers[c.dataTypeID]
})) ?? []
};
} catch (r) {
throw r instanceof E$1 ? E({
e: r,
options: e,
params: void 0,
query: s
}) : r;
} finally {
await T(this, t, y).call(this, O$1.sync(), e);
}
}
async transaction(s) {
return await this._checkReady(), await this._runExclusiveTransaction(async () => {
await T(this, t, m).call(this, "BEGIN"), x$2(this, p, !0);
let e = !1, r = () => {
if (e) throw new Error("Transaction is closed");
}, n = {
query: async (i, o, u) => (r(), await T(this, t, x).call(this, i, o, u)),
sql: async (i, ...o) => {
let { query: u, params: c } = g(i, ...o);
return await T(this, t, x).call(this, u, c);
},
exec: async (i, o) => (r(), await T(this, t, m).call(this, i, o)),
rollback: async () => {
r(), await T(this, t, m).call(this, "ROLLBACK"), e = !0;
},
listen: async (i, o) => (r(), await this.listen(i, o, n)),
get closed() {
return e;
}
};
try {
let i = await s(n);
return e || (e = !0, await T(this, t, m).call(this, "COMMIT")), x$2(this, p, !1), i;
} catch (i) {
throw e || await T(this, t, m).call(this, "ROLLBACK"), x$2(this, p, !1), i;
}
});
}
async runExclusive(s) {
return await this._runExclusiveQuery(s);
}
};
d = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakSet(), y = async function(s, e = {}) {
return await this.execProtocol(s, {
...e,
syncToFs: !1
});
}, x = async function(s, e = [], r) {
return await this._runExclusiveQuery(async () => {
T(this, t, O).call(this, "runQuery", s, e, r), await this._handleBlob(r?.blob);
let n;
try {
let { messages: o } = await T(this, t, y).call(this, O$1.parse({
text: s,
types: r?.paramTypes
}), r), u = De$1((await T(this, t, y).call(this, O$1.describe({ type: "S" }), r)).messages), c = e.map((g, S) => {
let D = u[S];
if (g == null) return null;
let Q = r?.serializers?.[D] ?? this.serializers[D];
return Q ? Q(g) : g.toString();
});
n = [
...o,
...(await T(this, t, y).call(this, O$1.bind({ values: c }), r)).messages,
...(await T(this, t, y).call(this, O$1.describe({ type: "P" }), r)).messages,
...(await T(this, t, y).call(this, O$1.execute({}), r)).messages
];
} catch (o) {
throw o instanceof E$1 ? E({
e: o,
options: r,
params: e,
query: s
}) : o;
} finally {
await T(this, t, y).call(this, O$1.sync(), r);
}
await this._cleanupBlob(), h(this, p) || await this.syncToFs();
let i = await this._getWrittenBlob();
return bn(n, this.parsers, r, i)[0];
});
}, m = async function(s, e) {
return await this._runExclusiveQuery(async () => {
T(this, t, O).call(this, "runExec", s, e), await this._handleBlob(e?.blob);
let r;
try {
r = (await T(this, t, y).call(this, O$1.query(s), e)).messages;
} catch (i) {
throw i instanceof E$1 ? E({
e: i,
options: e,
params: void 0,
query: s
}) : i;
} finally {
await T(this, t, y).call(this, O$1.sync(), e);
}
this._cleanupBlob(), h(this, p) || await this.syncToFs();
let n = await this._getWrittenBlob();
return bn(r, this.parsers, e, n);
});
}, O = function(...s) {
this.debug > 0 && console.log(...s);
};
//#endregion
//#region ../../node_modules/@electric-sql/pglite/dist/index.js
u();
u();
u();
var et = /* @__PURE__ */ new Error("timeout while waiting for mutex to become available"), tt = /* @__PURE__ */ new Error("mutex already locked"), Ke = /* @__PURE__ */ new Error("request for lock canceled"), Ye = function(e, t, r, a) {
function o(s) {
return s instanceof r ? s : new r(function(n) {
n(s);
});
}
return new (r || (r = Promise))(function(s, n) {
function _(d) {
try {
p(a.next(d));
} catch (m) {
n(m);
}
}
function l(d) {
try {
p(a.throw(d));
} catch (m) {
n(m);
}
}
function p(d) {
d.done ? s(d.value) : o(d.value).then(_, l);
}
p((a = a.apply(e, t || [])).next());
});
}, fe = class {
constructor(t, r = Ke) {
this._value = t, this._cancelError = r, this._weightedQueues = [], this._weightedWaiters = [];
}
acquire(t = 1) {
if (t <= 0) throw new Error(`invalid weight ${t}: must be positive`);
return new Promise((r, a) => {
this._weightedQueues[t - 1] || (this._weightedQueues[t - 1] = []), this._weightedQueues[t - 1].push({
resolve: r,
reject: a
}), this._dispatch();
});
}
runExclusive(t, r = 1) {
return Ye(this, void 0, void 0, function* () {
let [a, o] = yield this.acquire(r);
try {
return yield t(a);
} finally {
o();
}
});
}
waitForUnlock(t = 1) {
if (t <= 0) throw new Error(`invalid weight ${t}: must be positive`);
return new Promise((r) => {
this._weightedWaiters[t - 1] || (this._weightedWaiters[t - 1] = []), this._weightedWaiters[t - 1].push(r), this._dispatch();
});
}
isLocked() {
return this._value <= 0;
}
getValue() {
return this._value;
}
setValue(t) {
this._value = t, this._dispatch();
}
release(t = 1) {
if (t <= 0) throw new Error(`invalid weight ${t}: must be positive`);
this._value += t, this._dispatch();
}
cancel() {
this._weightedQueues.forEach((t) => t.forEach((r) => r.reject(this._cancelError))), this._weightedQueues = [];
}
_dispatch() {
var t;
for (let r = this._value; r > 0; r--) {
let a = (t = this._weightedQueues[r - 1]) === null || t === void 0 ? void 0 : t.shift();
if (!a) continue;
let o = this._value, s = r;
this._value -= r, r = this._value + 1, a.resolve([o, this._newReleaser(s)]);
}
this._drainUnlockWaiters();
}
_newReleaser(t) {
let r = !1;
return () => {
r || (r = !0, this.release(t));
};
}
_drainUnlockWaiters() {
for (let t = this._value; t > 0; t--) this._weightedWaiters[t - 1] && (this._weightedWaiters[t - 1].forEach((r) => r()), this._weightedWaiters[t - 1] = []);
}
}, Qe = function(e, t, r, a) {
function o(s) {
return s instanceof r ? s : new r(function(n) {
n(s);
});
}
return new (r || (r = Promise))(function(s, n) {
function _(d) {
try {
p(a.next(d));
} catch (m) {
n(m);
}
}
function l(d) {
try {
p(a.throw(d));
} catch (m) {
n(m);
}
}
function p(d) {
d.done ? s(d.value) : o(d.value).then(_, l);
}
p((a = a.apply(e, t || [])).next());
});
}, H = class {
constructor(t) {
this._semaphore = new fe(1, t);
}
acquire() {
return Qe(this, void 0, void 0, function* () {
let [, t] = yield this._semaphore.acquire();
return t;
});
}
runExclusive(t) {
return this._semaphore.runExclusive(() => t());
}
isLocked() {
return this._semaphore.isLocked();
}
waitForUnlock() {
return this._semaphore.waitForUnlock();
}
release() {
this._semaphore.isLocked() && this._semaphore.release();
}
cancel() {
return this._semaphore.cancel();
}
};
u();
var Ae = L$1(or(), 1);
async function he(e) {
if (Fe) {
let t = await import("./browser-external_fs-BjtkIK-z.js").then((n) => /* @__PURE__ */ __toESM(n.t())), r = await import("./browser-external_zlib-S2gRdW-P.js").then((m) => /* @__PURE__ */ __toESM(m.default)), { Writable: a } = await import("./browser-external_stream-BvvXfaxo.js").then((n) => /* @__PURE__ */ __toESM(n.t())), { pipeline: o } = await import("./promises-CQhiJhkd.js").then((m) => /* @__PURE__ */ __toESM(m.default));
if (!t.existsSync(e)) throw new Error(`Extension bundle not found: ${e}`);
let s = r.createGunzip(), n = [];
return await o(t.createReadStream(e), s, new a({ write(_, l, p) {
n.push(_), p();
} })), new Blob(n);
} else {
let t = await fetch(e.toString());
if (!t.ok || !t.body) return null;
if (t.headers.get("Content-Encoding") === "gzip") return t.blob();
{
let r = new DecompressionStream("gzip");
return new Response(t.body.pipeThrough(r)).blob();
}
}
}
async function Te(e, t) {
for (let r in e.pg_extensions) {
let a;
try {
a = await e.pg_extensions[r];
} catch (o) {
console.error("Failed to fetch extension:", r, o);
continue;
}
if (a) $e(e, r, new Uint8Array(await a.arrayBuffer()), t);
else console.error("Could not get binary data for extension:", r);
}
}
function $e(e, t, r, a) {
Ae.default.untar(r).forEach((s) => {
if (!s.name.startsWith(".")) {
let n = e.WASM_PREFIX + "/" + s.name;
if (s.name.endsWith(".so")) {
let _ = (...p) => {
a("pgfs:ext OK", n, p);
}, l = (...p) => {
a("pgfs:ext FAIL", n, p);
};
e.FS.createPreloadedFile(Je(n), s.name.split("/").pop().slice(0, -3), s.data, !0, !0, _, l, !1);
} else try {
let _ = n.substring(0, n.lastIndexOf("/"));
e.FS.analyzePath(_).exists === !1 && e.FS.mkdirTree(_), e.FS.writeFile(n, s.data);
} catch (_) {
console.error(`Error writing file ${n}`, _);
}
}
});
}
function Je(e) {
let t = e.lastIndexOf("/");
return t > 0 ? e.slice(0, t) : e;
}
u();
u();
var ee = class extends ur {
async init(t, r) {
return this.pg = t, { emscriptenOpts: {
...r,
preRun: [...r.preRun || [], (o) => {
let s = o.FS.filesystems.IDBFS;
o.FS.mkdir("/pglite"), o.FS.mkdir(`/pglite/${this.dataDir}`), o.FS.mount(s, {}, `/pglite/${this.dataDir}`), o.FS.symlink(`/pglite/${this.dataDir}`, C$2);
}]
} };
}
initialSyncFs() {
return new Promise((t, r) => {
this.pg.Module.FS.syncfs(!0, (a) => {
a ? r(a) : t();
});
});
}
syncToFs(t) {
return new Promise((r, a) => {
this.pg.Module.FS.syncfs(!1, (o) => {
o ? a(o) : r();
});
});
}
async closeFs() {
let t = this.pg.Module.FS.filesystems.IDBFS.dbs[this.dataDir];
t && t.close(), this.pg.Module.FS.quit();
}
};
u();
var te = class extends ur {
async closeFs() {
this.pg.Module.FS.quit();
}
};
function Ce(e) {
let t;
if (e?.startsWith("file://")) {
if (e = e.slice(7), !e) throw new Error("Invalid dataDir, must be a valid path");
t = "nodefs";
} else e?.startsWith("idb://") ? (e = e.slice(6), t = "idbfs") : e?.startsWith("opfs-ahp://") ? (e = e.slice(11), t = "opfs-ahp") : !e || e?.startsWith("memory://") ? t = "memoryfs" : t = "nodefs";
return {
dataDir: e,
fsType: t
};
}
async function Ie(e, t) {
let r;
if (e && t === "nodefs") {
let { NodeFS: a } = await import("./nodefs-CesrTPF2.js");
r = new a(e);
} else if (e && t === "idbfs") r = new ee(e);
else if (e && t === "opfs-ahp") {
let { OpfsAhpFS: a } = await import("./opfs-ahp-D364XUHJ.js");
r = new a(e);
} else r = new te();
return r;
}
u();
u();
var Ze = (() => {
var _scriptName = import.meta.url;
return async function(moduleArg = {}) {
var moduleRtn, Module = moduleArg, readyPromiseResolve, readyPromiseReject, readyPromise = new Promise((e, t) => {
readyPromiseResolve = e, readyPromiseReject = t;
}), ENVIRONMENT_IS_WEB = typeof window == "object", ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope < "u", ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string" && process.type != "renderer";
if (ENVIRONMENT_IS_NODE) {
let { createRequire: e } = await import("./browser-external_module-5FV7DdNN.js").then((m) => /* @__PURE__ */ __toESM(m.default)), t = import.meta.url;
t.startsWith("data:") && (t = "/");
var require = e(t);
}
Module.expectedDataFileDownloads ?? (Module.expectedDataFileDownloads = 0), Module.expectedDataFileDownloads++, (() => {
if (typeof ENVIRONMENT_IS_PTHREAD < "u" && ENVIRONMENT_IS_PTHREAD || typeof ENVIRONMENT_IS_WASM_WORKER < "u" && ENVIRONMENT_IS_WASM_WORKER) return;
var r = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string";
function a(o) {
var s = "";
typeof window == "object" ? window.encodeURIComponent(window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/")) + "/") : typeof process > "u" && typeof location < "u" && encodeURIComponent(location.pathname.substring(0, location.pathname.lastIndexOf("/")) + "/");
var n = "pglite.data", _ = "pglite.data", l = Module.locateFile ? Module.locateFile(_, "") : _, p = o.remote_package_size;
function d(c, S, M, x) {
if (r) {
require("fs").readFile(c, (h, y) => {
h ? x(h) : M(y.buffer);
});
return;
}
Module.dataFileDownloads ?? (Module.dataFileDownloads = {}), fetch(c).catch((h) => Promise.reject(new Error(`Network Error: ${c}`, { cause: h }))).then((h) => {
if (!h.ok) return Promise.reject(/* @__PURE__ */ new Error(`${h.status}: ${h.url}`));
if (!h.body && h.arrayBuffer) return h.arrayBuffer().then(M);
let y = h.body.getReader(), v = () => y.read().then(W).catch((z) => Promise.reject(new Error(`Unexpected error while handling : ${h.url} ${z}`, { cause: z }))), w = [], b = h.headers, q = Number(b.get("Content-Length") ?? S), O = 0, W = ({ done: z, value: N }) => {
if (z) {
let A = new Uint8Array(w.map((T) => T.length).reduce((T, Le) => T + Le, 0)), R = 0;
for (let T of w) A.set(T, R), R += T.length;
M(A.buffer);
} else {
w.push(N), O += N.length, Module.dataFileDownloads[c] = {
loaded: O,
total: q
};
let A = 0, R = 0;
for (let T of Object.values(Module.dataFileDownloads)) A += T.loaded, R += T.total;
return Module.setStatus?.(`Downloading data... (${A}/${R})`), v();
}
};
return Module.setStatus?.("Downloading data..."), v();
});
}
function m(c) {
console.error("package error:", c);
}
var g = null, u = Module.getPreloadedPackage ? Module.getPreloadedPackage(l, p) : null;
u || d(l, p, (c) => {
g ? (g(c), g = null) : u = c;
}, m);
function f(c) {
function S(v, w) {
if (!v) throw w + (/* @__PURE__ */ new Error()).stack;
}
c.FS_createPath("/", "home", !0, !0), c.FS_createPath("/home", "web_user", !0, !0), c.FS_createPath("/", "tmp", !0, !0), c.FS_createPath("/tmp", "pglite", !0, !0), c.FS_createPath("/tmp/pglite", "bin", !0, !0), c.FS_createPath("/tmp/pglite", "lib", !0, !0), c.FS_createPath("/tmp/pglite/lib", "postgresql", !0, !0), c.FS_createPath("/tmp/pglite/lib/postgresql", "pgxs", !0, !0), c.FS_createPath("/tmp/pglite/lib/postgresql/pgxs", "config", !0, !0), c.FS_createPath("/tmp/pglite/lib/postgresql/pgxs", "src", !0, !0), c.FS_createPath("/tmp/pglite/lib/postgresql/pgxs/src", "makefiles", !0, !0), c.FS_createPath("/tmp/pglite", "share", !0, !0), c.FS_createPath("/tmp/pglite/share", "postgresql", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql", "extension", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql", "timezone", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "Africa", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "America", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone/America", "Argentina", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone/America", "Indiana", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone/America", "Kentucky", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone/America", "North_Dakota", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "Antarctica", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "Arctic", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "Asia", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "Atlantic", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "Australia", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "Brazil", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "Canada", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "Chile", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "Etc", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "Europe", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "Indian", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "Mexico", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "Pacific", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql/timezone", "US", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql", "timezonesets", !0, !0), c.FS_createPath("/tmp/pglite/share/postgresql", "tsearch_data", !0, !0);
function M(v, w, b) {
this.start = v, this.end = w, this.audio = b;
}
M.prototype = {
requests: {},
open: function(v, w) {
this.name = w, this.requests[w] = this, c.addRunDependency(`fp ${this.name}`);
},
send: function() {},
onload: function() {
var v = this.byteArray.subarray(this.start, this.end);
this.finish(v);
},
finish: function(v) {
var w = this;
c.FS_createDataFile(this.name, null, v, !0, !0, !0), c.removeRunDependency(`fp ${w.name}`), this.requests[this.name] = null;
}
};
for (var x = o.files, h = 0; h < x.length; ++h) new M(x[h].start, x[h].end, x[h].audio || 0).open("GET", x[h].filename);
function y(v) {
S(v, "Loading data file failed."), S(v.constructor.name === ArrayBuffer.name, "bad input to processPackageData");
var w = new Uint8Array(v);
M.prototype.byteArray = w;
for (var b = o.files, q = 0; q < b.length; ++q) M.prototype.requests[b[q].filename].onload();
c.removeRunDependency("datafile_pglite.data");
}
c.addRunDependency("datafile_pglite.data"), c.preloadResults ?? (c.preloadResults = {}), c.preloadResults[n] = { fromCache: !1 }, u ? (y(u), u = null) : g = y;
}
Module.calledRun ? f(Module) : (Module.preRun ?? (Module.preRun = [])).push(f);
}
a({
files: [
{
filename: "/home/web_user/.pgpass",
start: 0,
end: 204
},
{
filename: "/tmp/pglite/bin/initdb",
start: 204,
end: 204
},
{
filename: "/tmp/pglite/bin/postgres",
start: 204,
end: 204
},
{
filename: "/tmp/pglite/lib/postgresql/cyrillic_and_mic.so",
start: 204,
end: 4698
},
{
filename: "/tmp/pglite/lib/postgresql/dict_snowball.so",
start: 4698,
end: 577901
},
{
filename: "/tmp/pglite/lib/postgresql/euc2004_sjis2004.so",
start: 577901,
end: 579974
},
{
filename: "/tmp/pglite/lib/postgresql/euc_cn_and_mic.so",
start: 579974,
end: 580915
},
{
filename: "/tmp/pglite/lib/postgresql/euc_jp_and_sjis.so",
start: 580915,
end: 588175
},
{
filename: "/tmp/pglite/lib/postgresql/euc_kr_and_mic.so",
start: 588175,
end: 589126
},
{
filename: "/tmp/pglite/lib/postgresql/euc_tw_and_big5.so",
start: 589126,
end: 593684
},
{
filename: "/tmp/pglite/lib/postgresql/latin2_and_win1250.so",
start: 593684,
end: 595090
},
{
filename: "/tmp/pglite/lib/postgresql/latin_and_mic.so",
start: 595090,
end: 596111
},
{
filename: "/tmp/pglite/lib/postgresql/libpqwalreceiver.so",
start: 596111,
end: 716462
},
{
filename: "/tmp/pglite/lib/postgresql/pgoutput.so",
start: 716462,
end: 729911
},
{
filename: "/tmp/pglite/lib/postgresql/pgxs/config/install-sh",
start: 729911,
end: 743908
},
{
filename: "/tmp/pglite/lib/postgresql/pgxs/config/missing",
start: 743908,
end: 745256
},
{
filename: "/tmp/pglite/lib/postgresql/pgxs/src/Makefile.global",
start: 745256,
end: 781401
},
{
filename: "/tmp/pglite/lib/postgresql/pgxs/src/Makefile.port",
start: 781401,
end: 782254
},
{
filename: "/tmp/pglite/lib/postgresql/pgxs/src/Makefile.shlib",
start: 782254,
end: 797682
},
{
filename: "/tmp/pglite/lib/postgresql/pgxs/src/makefiles/pgxs.mk",
start: 797682,
end: 813647
},
{
filename: "/tmp/pglite/lib/postgresql/pgxs/src/nls-global.mk",
start: 813647,
end: 820515
},
{
filename: "/tmp/pglite/lib/postgresql/plpgsql.so",
start: 820515,
end: 972182
},
{
filename: "/tmp/pglite/lib/postgresql/utf8_and_big5.so",
start: 972182,
end: 1086930
},
{
filename: "/tmp/pglite/lib/postgresql/utf8_and_cyrillic.so",
start: 1086930,
end: 1092904
},
{
filename: "/tmp/pglite/lib/postgresql/utf8_and_euc2004.so",
start: 1092904,
end: 1297836
},
{
filename: "/tmp/pglite/lib/postgresql/utf8_and_euc_cn.so",
start: 1297836,
end: 1373016
},
{
filename: "/tmp/pglite/lib/postgresql/utf8_and_euc_jp.so",
st