@busymango/fetch-driver
Version:
1,871 lines • 56.7 kB
JavaScript
import { clone as e, concat as t, filter as n, hasAtLeast as r, isArray as i, isFunction as a, isNullish as o, isObjectType as s, isPlainObject as c, isString as l, join as u, map as d, mapValues as f, omitBy as p, pipe as m } from "remeda";
import ee from "mime";
import h from "wildcard-match";
//#region src/compose.ts
function te(e) {
return function(t, n) {
let r = { offset: -1 };
function i(a) {
if (r.offset = a, a === e.length) return Promise.resolve(n == null ? void 0 : n());
let o = e[a];
return Promise.resolve(o(t, i.bind(null, a + 1)));
}
return i(0);
};
}
Object.freeze({ status: "aborted" });
function g(e, t, n) {
var r;
function i(n, r) {
if (n._zod || Object.defineProperty(n, "_zod", {
value: {
def: r,
constr: s,
traits: /* @__PURE__ */ new Set()
},
enumerable: !1
}), n._zod.traits.has(e)) return;
n._zod.traits.add(e), t(n, r);
let i = s.prototype, a = Object.keys(i);
for (let e = 0; e < a.length; e++) {
let t = a[e];
t in n || (n[t] = i[t].bind(n));
}
}
let a = (r = n == null ? void 0 : n.Parent) == null ? Object : r;
class o extends a {}
Object.defineProperty(o, "name", { value: e });
function s(e) {
var t;
let r = n != null && n.Parent ? new o() : this;
i(r, e), (t = r._zod).deferred != null || (t.deferred = []);
for (let e of r._zod.deferred) e();
return r;
}
return Object.defineProperty(s, "init", { value: i }), Object.defineProperty(s, Symbol.hasInstance, { value: (t) => {
var r;
return n != null && n.Parent && t instanceof n.Parent ? !0 : t == null || (r = t._zod) == null || (r = r.traits) == null ? void 0 : r.has(e);
} }), Object.defineProperty(s, "name", { value: e }), s;
}
var _ = class extends Error {
constructor() {
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
}
}, ne = class extends Error {
constructor(e) {
super(`Encountered unidirectional transform during encode: ${e}`), this.name = "ZodEncodeError";
}
}, v = {};
function y(e) {
return e && Object.assign(v, e), v;
}
//#endregion
//#region node_modules/zod/v4/core/util.js
function re(e) {
let t = Object.values(e).filter((e) => typeof e == "number");
return Object.entries(e).filter(([e, n]) => t.indexOf(+e) === -1).map(([e, t]) => t);
}
function b(e, t) {
return typeof t == "bigint" ? t.toString() : t;
}
function ie(e) {
return { get value() {
{
let t = e();
return Object.defineProperty(this, "value", { value: t }), t;
}
throw Error("cached value already set");
} };
}
function x(e) {
return e == null;
}
function S(e) {
let t = +!!e.startsWith("^"), n = e.endsWith("$") ? e.length - 1 : e.length;
return e.slice(t, n);
}
function ae(e, t) {
let n = (e.toString().split(".")[1] || "").length, r = t.toString(), i = (r.split(".")[1] || "").length;
if (i === 0 && /\d?e-\d?/.test(r)) {
let e = r.match(/\d?e-(\d?)/);
e != null && e[1] && (i = Number.parseInt(e[1]));
}
let a = n > i ? n : i;
return Number.parseInt(e.toFixed(a).replace(".", "")) % Number.parseInt(t.toFixed(a).replace(".", "")) / 10 ** a;
}
var oe = Symbol("evaluating");
function C(e, t, n) {
let r;
Object.defineProperty(e, t, {
get() {
if (r !== oe) return r === void 0 && (r = oe, r = n()), r;
},
set(n) {
Object.defineProperty(e, t, { value: n });
},
configurable: !0
});
}
function w(e, t, n) {
Object.defineProperty(e, t, {
value: n,
writable: !0,
enumerable: !0,
configurable: !0
});
}
function T(...e) {
let t = {};
for (let n of e) Object.assign(t, Object.getOwnPropertyDescriptors(n));
return Object.defineProperties({}, t);
}
function se(e) {
return JSON.stringify(e);
}
var ce = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {};
function E(e) {
return typeof e == "object" && !!e && !Array.isArray(e);
}
var le = ie(() => {
var e;
if (typeof navigator < "u" && !((e = navigator) == null || (e = e.userAgent) == null) && e.includes("Cloudflare")) return !1;
try {
return Function(""), !0;
} catch {
return !1;
}
});
function D(e) {
if (E(e) === !1) return !1;
let t = e.constructor;
if (t === void 0 || typeof t != "function") return !0;
let n = t.prototype;
return !(E(n) === !1 || Object.prototype.hasOwnProperty.call(n, "isPrototypeOf") === !1);
}
function ue(e) {
return D(e) ? { ...e } : Array.isArray(e) ? [...e] : e;
}
var de = new Set([
"string",
"number",
"symbol"
]);
function fe(e) {
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function O(e, t, n) {
let r = new e._zod.constr(t == null ? e._zod.def : t);
return (!t || n != null && n.parent) && (r._zod.parent = e), r;
}
function k(e) {
let t = e;
if (!t) return {};
if (typeof t == "string") return { error: () => t };
if ((t == null ? void 0 : t.message) !== void 0) {
if ((t == null ? void 0 : t.error) !== void 0) throw Error("Cannot specify both `message` and `error` params");
t.error = t.message;
}
return delete t.message, typeof t.error == "string" ? {
...t,
error: () => t.error
} : t;
}
function pe(e) {
return Object.keys(e).filter((t) => e[t]._zod.optin === "optional" && e[t]._zod.optout === "optional");
}
var me = {
safeint: [-(2 ** 53 - 1), 2 ** 53 - 1],
int32: [-2147483648, 2147483647],
uint32: [0, 4294967295],
float32: [-34028234663852886e22, 34028234663852886e22],
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
};
function he(e, t) {
let n = e._zod.def;
return O(e, T(e._zod.def, {
get shape() {
let e = {};
for (let r in t) {
if (!(r in n.shape)) throw Error(`Unrecognized key: "${r}"`);
t[r] && (e[r] = n.shape[r]);
}
return w(this, "shape", e), e;
},
checks: []
}));
}
function ge(e, t) {
let n = e._zod.def;
return O(e, T(e._zod.def, {
get shape() {
let r = { ...e._zod.def.shape };
for (let e in t) {
if (!(e in n.shape)) throw Error(`Unrecognized key: "${e}"`);
t[e] && delete r[e];
}
return w(this, "shape", r), r;
},
checks: []
}));
}
function _e(e, t) {
if (!D(t)) throw Error("Invalid input to extend: expected a plain object");
let n = e._zod.def.checks;
if (n && n.length > 0) throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
return O(e, T(e._zod.def, {
get shape() {
let n = {
...e._zod.def.shape,
...t
};
return w(this, "shape", n), n;
},
checks: []
}));
}
function ve(e, t) {
if (!D(t)) throw Error("Invalid input to safeExtend: expected a plain object");
return O(e, {
...e._zod.def,
get shape() {
let n = {
...e._zod.def.shape,
...t
};
return w(this, "shape", n), n;
},
checks: e._zod.def.checks
});
}
function ye(e, t) {
return O(e, T(e._zod.def, {
get shape() {
let n = {
...e._zod.def.shape,
...t._zod.def.shape
};
return w(this, "shape", n), n;
},
get catchall() {
return t._zod.def.catchall;
},
checks: []
}));
}
function be(e, t, n) {
return O(t, T(t._zod.def, {
get shape() {
let r = t._zod.def.shape, i = { ...r };
if (n) for (let t in n) {
if (!(t in r)) throw Error(`Unrecognized key: "${t}"`);
n[t] && (i[t] = e ? new e({
type: "optional",
innerType: r[t]
}) : r[t]);
}
else for (let t in r) i[t] = e ? new e({
type: "optional",
innerType: r[t]
}) : r[t];
return w(this, "shape", i), i;
},
checks: []
}));
}
function xe(e, t, n) {
return O(t, T(t._zod.def, {
get shape() {
let r = t._zod.def.shape, i = { ...r };
if (n) for (let t in n) {
if (!(t in i)) throw Error(`Unrecognized key: "${t}"`);
n[t] && (i[t] = new e({
type: "nonoptional",
innerType: r[t]
}));
}
else for (let t in r) i[t] = new e({
type: "nonoptional",
innerType: r[t]
});
return w(this, "shape", i), i;
},
checks: []
}));
}
function A(e, t = 0) {
if (e.aborted === !0) return !0;
for (let r = t; r < e.issues.length; r++) {
var n;
if (((n = e.issues[r]) == null ? void 0 : n.continue) !== !0) return !0;
}
return !1;
}
function Se(e, t) {
return t.map((t) => {
var n;
return (n = t).path != null || (n.path = []), t.path.unshift(e), t;
});
}
function j(e) {
return typeof e == "string" ? e : e == null ? void 0 : e.message;
}
function M(e, t, n) {
var r;
let i = {
...e,
path: (r = e.path) == null ? [] : r
};
if (!e.message) {
var a, o, s, c, l, u, d, f, p;
i.message = (a = (o = (s = (c = j((l = e.inst) == null || (l = l._zod.def) == null || (u = l.error) == null ? void 0 : u.call(l, e))) == null ? j(t == null || (d = t.error) == null ? void 0 : d.call(t, e)) : c) == null ? j((f = n.customError) == null ? void 0 : f.call(n, e)) : s) == null ? j((p = n.localeError) == null ? void 0 : p.call(n, e)) : o) == null ? "Invalid input" : a;
}
return delete i.inst, delete i.continue, t != null && t.reportInput || delete i.input, i;
}
function N(e) {
return Array.isArray(e) ? "array" : typeof e == "string" ? "string" : "unknown";
}
function P(...e) {
let [t, n, r] = e;
return typeof t == "string" ? {
message: t,
code: "custom",
input: n,
inst: r
} : { ...t };
}
//#endregion
//#region node_modules/zod/v4/core/errors.js
var Ce = (e, t) => {
e.name = "$ZodError", Object.defineProperty(e, "_zod", {
value: e._zod,
enumerable: !1
}), Object.defineProperty(e, "issues", {
value: t,
enumerable: !1
}), e.message = JSON.stringify(t, b, 2), Object.defineProperty(e, "toString", {
value: () => e.message,
enumerable: !1
});
}, we = g("$ZodError", Ce), Te = g("$ZodError", Ce, { Parent: Error });
function Ee(e, t = (e) => e.message) {
let n = {}, r = [];
for (let i of e.issues) i.path.length > 0 ? (n[i.path[0]] = n[i.path[0]] || [], n[i.path[0]].push(t(i))) : r.push(t(i));
return {
formErrors: r,
fieldErrors: n
};
}
function De(e, t = (e) => e.message) {
let n = { _errors: [] }, r = (e) => {
for (let i of e.issues) if (i.code === "invalid_union" && i.errors.length) i.errors.map((e) => r({ issues: e }));
else if (i.code === "invalid_key") r({ issues: i.issues });
else if (i.code === "invalid_element") r({ issues: i.issues });
else if (i.path.length === 0) n._errors.push(t(i));
else {
let e = n, r = 0;
for (; r < i.path.length;) {
let n = i.path[r];
r === i.path.length - 1 ? (e[n] = e[n] || { _errors: [] }, e[n]._errors.push(t(i))) : e[n] = e[n] || { _errors: [] }, e = e[n], r++;
}
}
};
return r(e), n;
}
//#endregion
//#region node_modules/zod/v4/core/parse.js
var F = (e) => (t, n, r, i) => {
let a = r ? Object.assign(r, { async: !1 }) : { async: !1 }, o = t._zod.run({
value: n,
issues: []
}, a);
if (o instanceof Promise) throw new _();
if (o.issues.length) {
var s;
let t = new ((s = i == null ? void 0 : i.Err) == null ? e : s)(o.issues.map((e) => M(e, a, y())));
throw ce(t, i == null ? void 0 : i.callee), t;
}
return o.value;
}, I = (e) => async (t, n, r, i) => {
let a = r ? Object.assign(r, { async: !0 }) : { async: !0 }, o = t._zod.run({
value: n,
issues: []
}, a);
if (o instanceof Promise && (o = await o), o.issues.length) {
var s;
let t = new ((s = i == null ? void 0 : i.Err) == null ? e : s)(o.issues.map((e) => M(e, a, y())));
throw ce(t, i == null ? void 0 : i.callee), t;
}
return o.value;
}, L = (e) => (t, n, r) => {
let i = r ? {
...r,
async: !1
} : { async: !1 }, a = t._zod.run({
value: n,
issues: []
}, i);
if (a instanceof Promise) throw new _();
return a.issues.length ? {
success: !1,
error: new (e == null ? we : e)(a.issues.map((e) => M(e, i, y())))
} : {
success: !0,
data: a.value
};
}, Oe = /* @__PURE__ */ L(Te), R = (e) => async (t, n, r) => {
let i = r ? Object.assign(r, { async: !0 }) : { async: !0 }, a = t._zod.run({
value: n,
issues: []
}, i);
return a instanceof Promise && (a = await a), a.issues.length ? {
success: !1,
error: new e(a.issues.map((e) => M(e, i, y())))
} : {
success: !0,
data: a.value
};
}, ke = /* @__PURE__ */ R(Te), Ae = (e) => (t, n, r) => {
let i = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
return F(e)(t, n, i);
}, je = (e) => (t, n, r) => F(e)(t, n, r), Me = (e) => async (t, n, r) => {
let i = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
return I(e)(t, n, i);
}, Ne = (e) => async (t, n, r) => I(e)(t, n, r), Pe = (e) => (t, n, r) => {
let i = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
return L(e)(t, n, i);
}, Fe = (e) => (t, n, r) => L(e)(t, n, r), Ie = (e) => async (t, n, r) => {
let i = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
return R(e)(t, n, i);
}, Le = (e) => async (t, n, r) => R(e)(t, n, r), Re = /^-?\d+$/, ze = /^-?\d+(?:\.\d+)?/, z = /* @__PURE__ */ g("$ZodCheck", (e, t) => {
var n;
e._zod != null || (e._zod = {}), e._zod.def = t, (n = e._zod).onattach != null || (n.onattach = []);
}), Be = {
number: "number",
bigint: "bigint",
object: "date"
}, Ve = /* @__PURE__ */ g("$ZodCheckLessThan", (e, t) => {
z.init(e, t);
let n = Be[typeof t.value];
e._zod.onattach.push((e) => {
var n;
let r = e._zod.bag, i = (n = t.inclusive ? r.maximum : r.exclusiveMaximum) == null ? Infinity : n;
t.value < i && (t.inclusive ? r.maximum = t.value : r.exclusiveMaximum = t.value);
}), e._zod.check = (r) => {
(t.inclusive ? r.value <= t.value : r.value < t.value) || r.issues.push({
origin: n,
code: "too_big",
maximum: t.value,
input: r.value,
inclusive: t.inclusive,
inst: e,
continue: !t.abort
});
};
}), He = /* @__PURE__ */ g("$ZodCheckGreaterThan", (e, t) => {
z.init(e, t);
let n = Be[typeof t.value];
e._zod.onattach.push((e) => {
var n;
let r = e._zod.bag, i = (n = t.inclusive ? r.minimum : r.exclusiveMinimum) == null ? -Infinity : n;
t.value > i && (t.inclusive ? r.minimum = t.value : r.exclusiveMinimum = t.value);
}), e._zod.check = (r) => {
(t.inclusive ? r.value >= t.value : r.value > t.value) || r.issues.push({
origin: n,
code: "too_small",
minimum: t.value,
input: r.value,
inclusive: t.inclusive,
inst: e,
continue: !t.abort
});
};
}), Ue = /* @__PURE__ */ g("$ZodCheckMultipleOf", (e, t) => {
z.init(e, t), e._zod.onattach.push((e) => {
var n;
(n = e._zod.bag).multipleOf != null || (n.multipleOf = t.value);
}), e._zod.check = (n) => {
if (typeof n.value != typeof t.value) throw Error("Cannot mix number and bigint in multiple_of check.");
(typeof n.value == "bigint" ? n.value % t.value === BigInt(0) : ae(n.value, t.value) === 0) || n.issues.push({
origin: typeof n.value,
code: "not_multiple_of",
divisor: t.value,
input: n.value,
inst: e,
continue: !t.abort
});
};
}), We = /* @__PURE__ */ g("$ZodCheckNumberFormat", (e, t) => {
var n;
z.init(e, t), t.format = t.format || "float64";
let r = (n = t.format) == null ? void 0 : n.includes("int"), i = r ? "int" : "number", [a, o] = me[t.format];
e._zod.onattach.push((e) => {
let n = e._zod.bag;
n.format = t.format, n.minimum = a, n.maximum = o, r && (n.pattern = Re);
}), e._zod.check = (n) => {
let s = n.value;
if (r) {
if (!Number.isInteger(s)) {
n.issues.push({
expected: i,
format: t.format,
code: "invalid_type",
continue: !1,
input: s,
inst: e
});
return;
}
if (!Number.isSafeInteger(s)) {
s > 0 ? n.issues.push({
input: s,
code: "too_big",
maximum: 2 ** 53 - 1,
note: "Integers must be within the safe integer range.",
inst: e,
origin: i,
continue: !t.abort
}) : n.issues.push({
input: s,
code: "too_small",
minimum: -(2 ** 53 - 1),
note: "Integers must be within the safe integer range.",
inst: e,
origin: i,
continue: !t.abort
});
return;
}
}
s < a && n.issues.push({
origin: "number",
input: s,
code: "too_small",
minimum: a,
inclusive: !0,
inst: e,
continue: !t.abort
}), s > o && n.issues.push({
origin: "number",
input: s,
code: "too_big",
maximum: o,
inst: e
});
};
}), Ge = /* @__PURE__ */ g("$ZodCheckMaxLength", (e, t) => {
var n;
z.init(e, t), (n = e._zod.def).when != null || (n.when = (e) => {
let t = e.value;
return !x(t) && t.length !== void 0;
}), e._zod.onattach.push((e) => {
var n;
let r = (n = e._zod.bag.maximum) == null ? Infinity : n;
t.maximum < r && (e._zod.bag.maximum = t.maximum);
}), e._zod.check = (n) => {
let r = n.value;
if (r.length <= t.maximum) return;
let i = N(r);
n.issues.push({
origin: i,
code: "too_big",
maximum: t.maximum,
inclusive: !0,
input: r,
inst: e,
continue: !t.abort
});
};
}), Ke = /* @__PURE__ */ g("$ZodCheckMinLength", (e, t) => {
var n;
z.init(e, t), (n = e._zod.def).when != null || (n.when = (e) => {
let t = e.value;
return !x(t) && t.length !== void 0;
}), e._zod.onattach.push((e) => {
var n;
let r = (n = e._zod.bag.minimum) == null ? -Infinity : n;
t.minimum > r && (e._zod.bag.minimum = t.minimum);
}), e._zod.check = (n) => {
let r = n.value;
if (r.length >= t.minimum) return;
let i = N(r);
n.issues.push({
origin: i,
code: "too_small",
minimum: t.minimum,
inclusive: !0,
input: r,
inst: e,
continue: !t.abort
});
};
}), qe = /* @__PURE__ */ g("$ZodCheckLengthEquals", (e, t) => {
var n;
z.init(e, t), (n = e._zod.def).when != null || (n.when = (e) => {
let t = e.value;
return !x(t) && t.length !== void 0;
}), e._zod.onattach.push((e) => {
let n = e._zod.bag;
n.minimum = t.length, n.maximum = t.length, n.length = t.length;
}), e._zod.check = (n) => {
let r = n.value, i = r.length;
if (i === t.length) return;
let a = N(r), o = i > t.length;
n.issues.push({
origin: a,
...o ? {
code: "too_big",
maximum: t.length
} : {
code: "too_small",
minimum: t.length
},
inclusive: !0,
exact: !0,
input: n.value,
inst: e,
continue: !t.abort
});
};
}), Je = /* @__PURE__ */ g("$ZodCheckOverwrite", (e, t) => {
z.init(e, t), e._zod.check = (e) => {
e.value = t.tx(e.value);
};
}), Ye = class {
constructor(e = []) {
this.content = [], this.indent = 0, this && (this.args = e);
}
indented(e) {
this.indent += 1, e(this), --this.indent;
}
write(e) {
if (typeof e == "function") {
e(this, { execution: "sync" }), e(this, { execution: "async" });
return;
}
let t = e.split("\n").filter((e) => e), n = Math.min(...t.map((e) => e.length - e.trimStart().length)), r = t.map((e) => e.slice(n)).map((e) => " ".repeat(this.indent * 2) + e);
for (let e of r) this.content.push(e);
}
compile() {
var e, t, n;
let r = Function, i = (e = this) == null ? void 0 : e.args, a = [...((t = (n = this) == null ? void 0 : n.content) == null ? [""] : t).map((e) => ` ${e}`)];
return new r(...i, a.join("\n"));
}
}, Xe = {
major: 4,
minor: 1,
patch: 13
}, B = /* @__PURE__ */ g("$ZodType", (e, t) => {
var n, r;
e != null || (e = {}), e._zod.def = t, e._zod.bag = e._zod.bag || {}, e._zod.version = Xe;
let i = [...(n = e._zod.def.checks) == null ? [] : n];
e._zod.traits.has("$ZodCheck") && i.unshift(e);
for (let t of i) for (let n of t._zod.onattach) n(e);
if (i.length === 0) {
var a;
(r = e._zod).deferred != null || (r.deferred = []), (a = e._zod.deferred) == null || a.push(() => {
e._zod.run = e._zod.parse;
});
} else {
let t = (e, t, n) => {
let r = A(e), i;
for (let o of t) {
if (o._zod.def.when) {
if (!o._zod.def.when(e)) continue;
} else if (r) continue;
let t = e.issues.length, s = o._zod.check(e);
if (s instanceof Promise && (n == null ? void 0 : n.async) === !1) throw new _();
if (i || s instanceof Promise) {
var a;
i = ((a = i) == null ? Promise.resolve() : a).then(async () => {
await s, e.issues.length !== t && (r || (r = A(e, t)));
});
} else {
if (e.issues.length === t) continue;
r || (r = A(e, t));
}
}
return i ? i.then(() => e) : e;
}, n = (n, r, a) => {
if (A(n)) return n.aborted = !0, n;
let o = t(r, i, a);
if (o instanceof Promise) {
if (a.async === !1) throw new _();
return o.then((t) => e._zod.parse(t, a));
}
return e._zod.parse(o, a);
};
e._zod.run = (r, a) => {
if (a.skipChecks) return e._zod.parse(r, a);
if (a.direction === "backward") {
let t = e._zod.parse({
value: r.value,
issues: []
}, {
...a,
skipChecks: !0
});
return t instanceof Promise ? t.then((e) => n(e, r, a)) : n(t, r, a);
}
let o = e._zod.parse(r, a);
if (o instanceof Promise) {
if (a.async === !1) throw new _();
return o.then((e) => t(e, i, a));
}
return t(o, i, a);
};
}
e["~standard"] = {
validate: (t) => {
try {
var n;
let r = Oe(e, t);
return r.success ? { value: r.data } : { issues: (n = r.error) == null ? void 0 : n.issues };
} catch {
return ke(e, t).then((e) => {
var t;
return e.success ? { value: e.data } : { issues: (t = e.error) == null ? void 0 : t.issues };
});
}
},
vendor: "zod",
version: 1
};
}), Ze = /* @__PURE__ */ g("$ZodNumber", (e, t) => {
var n;
B.init(e, t), e._zod.pattern = (n = e._zod.bag.pattern) == null ? ze : n, e._zod.parse = (n, r) => {
if (t.coerce) try {
n.value = Number(n.value);
} catch {}
let i = n.value;
if (typeof i == "number" && !Number.isNaN(i) && Number.isFinite(i)) return n;
let a = typeof i == "number" ? Number.isNaN(i) ? "NaN" : Number.isFinite(i) ? void 0 : "Infinity" : void 0;
return n.issues.push({
expected: "number",
code: "invalid_type",
input: i,
inst: e,
...a ? { received: a } : {}
}), n;
};
}), Qe = /* @__PURE__ */ g("$ZodNumberFormat", (e, t) => {
We.init(e, t), Ze.init(e, t);
}), $e = /* @__PURE__ */ g("$ZodUnknown", (e, t) => {
B.init(e, t), e._zod.parse = (e) => e;
}), et = /* @__PURE__ */ g("$ZodNever", (e, t) => {
B.init(e, t), e._zod.parse = (t, n) => (t.issues.push({
expected: "never",
code: "invalid_type",
input: t.value,
inst: e
}), t);
});
function tt(e, t, n) {
e.issues.length && t.issues.push(...Se(n, e.issues)), t.value[n] = e.value;
}
var nt = /* @__PURE__ */ g("$ZodArray", (e, t) => {
B.init(e, t), e._zod.parse = (n, r) => {
let i = n.value;
if (!Array.isArray(i)) return n.issues.push({
expected: "array",
code: "invalid_type",
input: i,
inst: e
}), n;
n.value = Array(i.length);
let a = [];
for (let e = 0; e < i.length; e++) {
let o = i[e], s = t.element._zod.run({
value: o,
issues: []
}, r);
s instanceof Promise ? a.push(s.then((t) => tt(t, n, e))) : tt(s, n, e);
}
return a.length ? Promise.all(a).then(() => n) : n;
};
});
function V(e, t, n, r) {
e.issues.length && t.issues.push(...Se(n, e.issues)), e.value === void 0 ? n in r && (t.value[n] = void 0) : t.value[n] = e.value;
}
function rt(e) {
let t = Object.keys(e.shape);
for (let r of t) {
var n;
if (!(!((n = e.shape) == null || (n = n[r]) == null || (n = n._zod) == null || (n = n.traits) == null) && n.has("$ZodType"))) throw Error(`Invalid element at key "${r}": expected a Zod schema`);
}
let r = pe(e.shape);
return {
...e,
keys: t,
keySet: new Set(t),
numKeys: t.length,
optionalKeys: new Set(r)
};
}
function it(e, t, n, r, i, a) {
let o = [], s = i.keySet, c = i.catchall._zod, l = c.def.type;
for (let i in t) {
if (s.has(i)) continue;
if (l === "never") {
o.push(i);
continue;
}
let a = c.run({
value: t[i],
issues: []
}, r);
a instanceof Promise ? e.push(a.then((e) => V(e, n, i, t))) : V(a, n, i, t);
}
return o.length && n.issues.push({
code: "unrecognized_keys",
keys: o,
input: t,
inst: a
}), e.length ? Promise.all(e).then(() => n) : n;
}
var at = /* @__PURE__ */ g("$ZodObject", (e, t) => {
B.init(e, t);
let n = Object.getOwnPropertyDescriptor(t, "shape");
if (!(n != null && n.get)) {
let e = t.shape;
Object.defineProperty(t, "shape", { get: () => {
let n = { ...e };
return Object.defineProperty(t, "shape", { value: n }), n;
} });
}
let r = ie(() => rt(t));
C(e._zod, "propValues", () => {
let e = t.shape, n = {};
for (let t in e) {
let r = e[t]._zod;
if (r.values) {
n[t] != null || (n[t] = /* @__PURE__ */ new Set());
for (let e of r.values) n[t].add(e);
}
}
return n;
});
let i = E, a = t.catchall, o;
e._zod.parse = (t, n) => {
o != null || (o = r.value);
let s = t.value;
if (!i(s)) return t.issues.push({
expected: "object",
code: "invalid_type",
input: s,
inst: e
}), t;
t.value = {};
let c = [], l = o.shape;
for (let e of o.keys) {
let r = l[e]._zod.run({
value: s[e],
issues: []
}, n);
r instanceof Promise ? c.push(r.then((n) => V(n, t, e, s))) : V(r, t, e, s);
}
return a ? it(c, s, t, n, r.value, e) : c.length ? Promise.all(c).then(() => t) : t;
};
}), ot = /* @__PURE__ */ g("$ZodObjectJIT", (e, t) => {
at.init(e, t);
let n = e._zod.parse, r = ie(() => rt(t)), i = (e) => {
let t = new Ye([
"shape",
"payload",
"ctx"
]), n = r.value, i = (e) => {
let t = se(e);
return `shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`;
};
t.write("const input = payload.value;");
let a = Object.create(null), o = 0;
for (let e of n.keys) a[e] = `key_${o++}`;
t.write("const newResult = {};");
for (let e of n.keys) {
let n = a[e], r = se(e);
t.write(`const ${n} = ${i(e)};`), t.write(`
if (${n}.issues.length) {
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
...iss,
path: iss.path ? [${r}, ...iss.path] : [${r}]
})));
}
if (${n}.value === undefined) {
if (${r} in input) {
newResult[${r}] = undefined;
}
} else {
newResult[${r}] = ${n}.value;
}
`);
}
t.write("payload.value = newResult;"), t.write("return payload;");
let s = t.compile();
return (t, n) => s(e, t, n);
}, a, o = E, s = !v.jitless, c = s && le.value, l = t.catchall, u;
e._zod.parse = (d, f) => {
u != null || (u = r.value);
let p = d.value;
return o(p) ? s && c && (f == null ? void 0 : f.async) === !1 && f.jitless !== !0 ? (a || (a = i(t.shape)), d = a(d, f), l ? it([], p, d, f, u, e) : d) : n(d, f) : (d.issues.push({
expected: "object",
code: "invalid_type",
input: p,
inst: e
}), d);
};
});
function st(e, t, n, r) {
for (let n of e) if (n.issues.length === 0) return t.value = n.value, t;
let i = e.filter((e) => !A(e));
return i.length === 1 ? (t.value = i[0].value, i[0]) : (t.issues.push({
code: "invalid_union",
input: t.value,
inst: n,
errors: e.map((e) => e.issues.map((e) => M(e, r, y())))
}), t);
}
var ct = /* @__PURE__ */ g("$ZodUnion", (e, t) => {
B.init(e, t), C(e._zod, "optin", () => t.options.some((e) => e._zod.optin === "optional") ? "optional" : void 0), C(e._zod, "optout", () => t.options.some((e) => e._zod.optout === "optional") ? "optional" : void 0), C(e._zod, "values", () => {
if (t.options.every((e) => e._zod.values)) return new Set(t.options.flatMap((e) => Array.from(e._zod.values)));
}), C(e._zod, "pattern", () => {
if (t.options.every((e) => e._zod.pattern)) {
let e = t.options.map((e) => e._zod.pattern);
return RegExp(`^(${e.map((e) => S(e.source)).join("|")})$`);
}
});
let n = t.options.length === 1, r = t.options[0]._zod.run;
e._zod.parse = (i, a) => {
if (n) return r(i, a);
let o = !1, s = [];
for (let e of t.options) {
let t = e._zod.run({
value: i.value,
issues: []
}, a);
if (t instanceof Promise) s.push(t), o = !0;
else {
if (t.issues.length === 0) return t;
s.push(t);
}
}
return o ? Promise.all(s).then((t) => st(t, i, e, a)) : st(s, i, e, a);
};
}), lt = /* @__PURE__ */ g("$ZodIntersection", (e, t) => {
B.init(e, t), e._zod.parse = (e, n) => {
let r = e.value, i = t.left._zod.run({
value: r,
issues: []
}, n), a = t.right._zod.run({
value: r,
issues: []
}, n);
return i instanceof Promise || a instanceof Promise ? Promise.all([i, a]).then(([t, n]) => ut(e, t, n)) : ut(e, i, a);
};
});
function H(e, t) {
if (e === t || e instanceof Date && t instanceof Date && +e == +t) return {
valid: !0,
data: e
};
if (D(e) && D(t)) {
let n = Object.keys(t), r = Object.keys(e).filter((e) => n.indexOf(e) !== -1), i = {
...e,
...t
};
for (let n of r) {
let r = H(e[n], t[n]);
if (!r.valid) return {
valid: !1,
mergeErrorPath: [n, ...r.mergeErrorPath]
};
i[n] = r.data;
}
return {
valid: !0,
data: i
};
}
if (Array.isArray(e) && Array.isArray(t)) {
if (e.length !== t.length) return {
valid: !1,
mergeErrorPath: []
};
let n = [];
for (let r = 0; r < e.length; r++) {
let i = e[r], a = t[r], o = H(i, a);
if (!o.valid) return {
valid: !1,
mergeErrorPath: [r, ...o.mergeErrorPath]
};
n.push(o.data);
}
return {
valid: !0,
data: n
};
}
return {
valid: !1,
mergeErrorPath: []
};
}
function ut(e, t, n) {
if (t.issues.length && e.issues.push(...t.issues), n.issues.length && e.issues.push(...n.issues), A(e)) return e;
let r = H(t.value, n.value);
if (!r.valid) throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);
return e.value = r.data, e;
}
var dt = /* @__PURE__ */ g("$ZodEnum", (e, t) => {
B.init(e, t);
let n = re(t.entries), r = new Set(n);
e._zod.values = r, e._zod.pattern = RegExp(`^(${n.filter((e) => de.has(typeof e)).map((e) => typeof e == "string" ? fe(e) : e.toString()).join("|")})$`), e._zod.parse = (t, i) => {
let a = t.value;
return r.has(a) || t.issues.push({
code: "invalid_value",
values: n,
input: a,
inst: e
}), t;
};
}), ft = /* @__PURE__ */ g("$ZodTransform", (e, t) => {
B.init(e, t), e._zod.parse = (n, r) => {
if (r.direction === "backward") throw new ne(e.constructor.name);
let i = t.transform(n.value, n);
if (r.async) return (i instanceof Promise ? i : Promise.resolve(i)).then((e) => (n.value = e, n));
if (i instanceof Promise) throw new _();
return n.value = i, n;
};
});
function pt(e, t) {
return e.issues.length && t === void 0 ? {
issues: [],
value: void 0
} : e;
}
var mt = /* @__PURE__ */ g("$ZodOptional", (e, t) => {
B.init(e, t), e._zod.optin = "optional", e._zod.optout = "optional", C(e._zod, "values", () => t.innerType._zod.values ? new Set([...t.innerType._zod.values, void 0]) : void 0), C(e._zod, "pattern", () => {
let e = t.innerType._zod.pattern;
return e ? RegExp(`^(${S(e.source)})?$`) : void 0;
}), e._zod.parse = (e, n) => {
if (t.innerType._zod.optin === "optional") {
let r = t.innerType._zod.run(e, n);
return r instanceof Promise ? r.then((t) => pt(t, e.value)) : pt(r, e.value);
}
return e.value === void 0 ? e : t.innerType._zod.run(e, n);
};
}), ht = /* @__PURE__ */ g("$ZodNullable", (e, t) => {
B.init(e, t), C(e._zod, "optin", () => t.innerType._zod.optin), C(e._zod, "optout", () => t.innerType._zod.optout), C(e._zod, "pattern", () => {
let e = t.innerType._zod.pattern;
return e ? RegExp(`^(${S(e.source)}|null)$`) : void 0;
}), C(e._zod, "values", () => t.innerType._zod.values ? new Set([...t.innerType._zod.values, null]) : void 0), e._zod.parse = (e, n) => e.value === null ? e : t.innerType._zod.run(e, n);
}), gt = /* @__PURE__ */ g("$ZodDefault", (e, t) => {
B.init(e, t), e._zod.optin = "optional", C(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (e, n) => {
if (n.direction === "backward") return t.innerType._zod.run(e, n);
if (e.value === void 0) return e.value = t.defaultValue, e;
let r = t.innerType._zod.run(e, n);
return r instanceof Promise ? r.then((e) => _t(e, t)) : _t(r, t);
};
});
function _t(e, t) {
return e.value === void 0 && (e.value = t.defaultValue), e;
}
var vt = /* @__PURE__ */ g("$ZodPrefault", (e, t) => {
B.init(e, t), e._zod.optin = "optional", C(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (e, n) => (n.direction === "backward" || e.value === void 0 && (e.value = t.defaultValue), t.innerType._zod.run(e, n));
}), yt = /* @__PURE__ */ g("$ZodNonOptional", (e, t) => {
B.init(e, t), C(e._zod, "values", () => {
let e = t.innerType._zod.values;
return e ? new Set([...e].filter((e) => e !== void 0)) : void 0;
}), e._zod.parse = (n, r) => {
let i = t.innerType._zod.run(n, r);
return i instanceof Promise ? i.then((t) => bt(t, e)) : bt(i, e);
};
});
function bt(e, t) {
return !e.issues.length && e.value === void 0 && e.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: e.value,
inst: t
}), e;
}
var xt = /* @__PURE__ */ g("$ZodCatch", (e, t) => {
B.init(e, t), C(e._zod, "optin", () => t.innerType._zod.optin), C(e._zod, "optout", () => t.innerType._zod.optout), C(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (e, n) => {
if (n.direction === "backward") return t.innerType._zod.run(e, n);
let r = t.innerType._zod.run(e, n);
return r instanceof Promise ? r.then((r) => (e.value = r.value, r.issues.length && (e.value = t.catchValue({
...e,
error: { issues: r.issues.map((e) => M(e, n, y())) },
input: e.value
}), e.issues = []), e)) : (e.value = r.value, r.issues.length && (e.value = t.catchValue({
...e,
error: { issues: r.issues.map((e) => M(e, n, y())) },
input: e.value
}), e.issues = []), e);
};
}), St = /* @__PURE__ */ g("$ZodPipe", (e, t) => {
B.init(e, t), C(e._zod, "values", () => t.in._zod.values), C(e._zod, "optin", () => t.in._zod.optin), C(e._zod, "optout", () => t.out._zod.optout), C(e._zod, "propValues", () => t.in._zod.propValues), e._zod.parse = (e, n) => {
if (n.direction === "backward") {
let r = t.out._zod.run(e, n);
return r instanceof Promise ? r.then((e) => U(e, t.in, n)) : U(r, t.in, n);
}
let r = t.in._zod.run(e, n);
return r instanceof Promise ? r.then((e) => U(e, t.out, n)) : U(r, t.out, n);
};
});
function U(e, t, n) {
return e.issues.length ? (e.aborted = !0, e) : t._zod.run({
value: e.value,
issues: e.issues
}, n);
}
var Ct = /* @__PURE__ */ g("$ZodReadonly", (e, t) => {
B.init(e, t), C(e._zod, "propValues", () => t.innerType._zod.propValues), C(e._zod, "values", () => t.innerType._zod.values), C(e._zod, "optin", () => {
var e;
return (e = t.innerType) == null || (e = e._zod) == null ? void 0 : e.optin;
}), C(e._zod, "optout", () => {
var e;
return (e = t.innerType) == null || (e = e._zod) == null ? void 0 : e.optout;
}), e._zod.parse = (e, n) => {
if (n.direction === "backward") return t.innerType._zod.run(e, n);
let r = t.innerType._zod.run(e, n);
return r instanceof Promise ? r.then(wt) : wt(r);
};
});
function wt(e) {
return e.value = Object.freeze(e.value), e;
}
var Tt = /* @__PURE__ */ g("$ZodCustom", (e, t) => {
z.init(e, t), B.init(e, t), e._zod.parse = (e, t) => e, e._zod.check = (n) => {
let r = n.value, i = t.fn(r);
if (i instanceof Promise) return i.then((t) => Et(t, n, r, e));
Et(i, n, r, e);
};
});
function Et(e, t, n, r) {
if (!e) {
var i;
let e = {
code: "custom",
input: n,
inst: r,
path: [...(i = r._zod.def.path) == null ? [] : i],
continue: !r._zod.def.abort
};
r._zod.def.params && (e.params = r._zod.def.params), t.issues.push(P(e));
}
}
//#endregion
//#region node_modules/zod/v4/core/registries.js
var Dt, Ot = class {
constructor() {
this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map();
}
add(e, ...t) {
let n = t[0];
if (this._map.set(e, n), n && typeof n == "object" && "id" in n) {
if (this._idmap.has(n.id)) throw Error(`ID ${n.id} already exists in the registry`);
this._idmap.set(n.id, e);
}
return this;
}
clear() {
return this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map(), this;
}
remove(e) {
let t = this._map.get(e);
return t && typeof t == "object" && "id" in t && this._idmap.delete(t.id), this._map.delete(e), this;
}
get(e) {
let t = e._zod.parent;
if (t) {
var n;
let r = { ...(n = this.get(t)) == null ? {} : n };
delete r.id;
let i = {
...r,
...this._map.get(e)
};
return Object.keys(i).length ? i : void 0;
}
return this._map.get(e);
}
has(e) {
return this._map.has(e);
}
};
function kt() {
return new Ot();
}
(Dt = globalThis).__zod_globalRegistry != null || (Dt.__zod_globalRegistry = kt());
var W = globalThis.__zod_globalRegistry;
//#endregion
//#region node_modules/zod/v4/core/api.js
function At(e, t) {
return new e({
type: "number",
checks: [],
...k(t)
});
}
function jt(e, t) {
return new e({
type: "number",
check: "number_format",
abort: !1,
format: "safeint",
...k(t)
});
}
function Mt(e) {
return new e({ type: "unknown" });
}
function Nt(e, t) {
return new e({
type: "never",
...k(t)
});
}
function Pt(e, t) {
return new Ve({
check: "less_than",
...k(t),
value: e,
inclusive: !1
});
}
function G(e, t) {
return new Ve({
check: "less_than",
...k(t),
value: e,
inclusive: !0
});
}
function Ft(e, t) {
return new He({
check: "greater_than",
...k(t),
value: e,
inclusive: !1
});
}
function K(e, t) {
return new He({
check: "greater_than",
...k(t),
value: e,
inclusive: !0
});
}
function It(e, t) {
return new Ue({
check: "multiple_of",
...k(t),
value: e
});
}
function Lt(e, t) {
return new Ge({
check: "max_length",
...k(t),
maximum: e
});
}
function Rt(e, t) {
return new Ke({
check: "min_length",
...k(t),
minimum: e
});
}
function zt(e, t) {
return new qe({
check: "length_equals",
...k(t),
length: e
});
}
function Bt(e) {
return new Je({
check: "overwrite",
tx: e
});
}
function Vt(e, t, n) {
return new e({
type: "array",
element: t,
...k(n)
});
}
function Ht(e, t, n) {
return new e({
type: "custom",
check: "custom",
fn: t,
...k(n)
});
}
function Ut(e) {
let t = Wt((n) => (n.addIssue = (e) => {
if (typeof e == "string") n.issues.push(P(e, n.value, t._zod.def));
else {
let r = e;
r.fatal && (r.continue = !1), r.code != null || (r.code = "custom"), r.input != null || (r.input = n.value), r.inst != null || (r.inst = t), r.continue != null || (r.continue = !t._zod.def.abort), n.issues.push(P(r));
}
}, e(n.value, n)));
return t;
}
function Wt(e, t) {
let n = new z({
check: "custom",
...k(t)
});
return n._zod.check = e, n;
}
//#endregion
//#region node_modules/zod/v4/classic/errors.js
var Gt = (e, t) => {
we.init(e, t), e.name = "ZodError", Object.defineProperties(e, {
format: { value: (t) => De(e, t) },
flatten: { value: (t) => Ee(e, t) },
addIssue: { value: (t) => {
e.issues.push(t), e.message = JSON.stringify(e.issues, b, 2);
} },
addIssues: { value: (t) => {
e.issues.push(...t), e.message = JSON.stringify(e.issues, b, 2);
} },
isEmpty: { get() {
return e.issues.length === 0;
} }
});
};
g("ZodError", Gt);
var q = g("ZodError", Gt, { Parent: Error }), Kt = /* @__PURE__ */ F(q), qt = /* @__PURE__ */ I(q), Jt = /* @__PURE__ */ L(q), Yt = /* @__PURE__ */ R(q), Xt = /* @__PURE__ */ Ae(q), Zt = /* @__PURE__ */ je(q), Qt = /* @__PURE__ */ Me(q), $t = /* @__PURE__ */ Ne(q), en = /* @__PURE__ */ Pe(q), tn = /* @__PURE__ */ Fe(q), nn = /* @__PURE__ */ Ie(q), rn = /* @__PURE__ */ Le(q), J = /* @__PURE__ */ g("ZodType", (e, t) => (B.init(e, t), e.def = t, e.type = t.type, Object.defineProperty(e, "_def", { value: t }), e.check = (...n) => {
var r;
return e.clone(T(t, { checks: [...(r = t.checks) == null ? [] : r, ...n.map((e) => typeof e == "function" ? { _zod: {
check: e,
def: { check: "custom" },
onattach: []
} } : e)] }));
}, e.clone = (t, n) => O(e, t, n), e.brand = () => e, e.register = ((t, n) => (t.add(e, n), e)), e.parse = (t, n) => Kt(e, t, n, { callee: e.parse }), e.safeParse = (t, n) => Jt(e, t, n), e.parseAsync = async (t, n) => qt(e, t, n, { callee: e.parseAsync }), e.safeParseAsync = async (t, n) => Yt(e, t, n), e.spa = e.safeParseAsync, e.encode = (t, n) => Xt(e, t, n), e.decode = (t, n) => Zt(e, t, n), e.encodeAsync = async (t, n) => Qt(e, t, n), e.decodeAsync = async (t, n) => $t(e, t, n), e.safeEncode = (t, n) => en(e, t, n), e.safeDecode = (t, n) => tn(e, t, n), e.safeEncodeAsync = async (t, n) => nn(e, t, n), e.safeDecodeAsync = async (t, n) => rn(e, t, n), e.refine = (t, n) => e.check(Vn(t, n)), e.superRefine = (t) => e.check(Hn(t)), e.overwrite = (t) => e.check(Bt(t)), e.optional = () => Tn(e), e.nullable = () => Dn(e), e.nullish = () => Tn(Dn(e)), e.nonoptional = (t) => Nn(e, t), e.array = () => mn(e), e.or = (t) => vn([e, t]), e.and = (t) => bn(e, t), e.transform = (t) => Ln(e, Cn(t)), e.default = (t) => kn(e, t), e.prefault = (t) => jn(e, t), e.catch = (t) => Fn(e, t), e.pipe = (t) => Ln(e, t), e.readonly = () => zn(e), e.describe = (t) => {
let n = e.clone();
return W.add(n, { description: t }), n;
}, Object.defineProperty(e, "description", {
get() {
var t;
return (t = W.get(e)) == null ? void 0 : t.description;
},
configurable: !0
}), e.meta = (...t) => {
if (t.length === 0) return W.get(e);
let n = e.clone();
return W.add(n, t[0]), n;
}, e.isOptional = () => e.safeParse(void 0).success, e.isNullable = () => e.safeParse(null).success, e)), an = /* @__PURE__ */ g("ZodNumber", (e, t) => {
var n, r, i, a, o, s, c, l, u;
Ze.init(e, t), J.init(e, t), e.gt = (t, n) => e.check(Ft(t, n)), e.gte = (t, n) => e.check(K(t, n)), e.min = (t, n) => e.check(K(t, n)), e.lt = (t, n) => e.check(Pt(t, n)), e.lte = (t, n) => e.check(G(t, n)), e.max = (t, n) => e.check(G(t, n)), e.int = (t) => e.check(cn(t)), e.safe = (t) => e.check(cn(t)), e.positive = (t) => e.check(Ft(0, t)), e.nonnegative = (t) => e.check(K(0, t)), e.negative = (t) => e.check(Pt(0, t)), e.nonpositive = (t) => e.check(G(0, t)), e.multipleOf = (t, n) => e.check(It(t, n)), e.step = (t, n) => e.check(It(t, n)), e.finite = () => e;
let d = e._zod.bag;
e.minValue = (n = Math.max((r = d.minimum) == null ? -Infinity : r, (i = d.exclusiveMinimum) == null ? -Infinity : i)) == null ? null : n, e.maxValue = (a = Math.min((o = d.maximum) == null ? Infinity : o, (s = d.exclusiveMaximum) == null ? Infinity : s)) == null ? null : a, e.isInt = ((c = d.format) == null ? "" : c).includes("int") || Number.isSafeInteger((l = d.multipleOf) == null ? .5 : l), e.isFinite = !0, e.format = (u = d.format) == null ? null : u;
});
function on(e) {
return At(an, e);
}
var sn = /* @__PURE__ */ g("ZodNumberFormat", (e, t) => {
Qe.init(e, t), an.init(e, t);
});
function cn(e) {
return jt(sn, e);
}
var ln = /* @__PURE__ */ g("ZodUnknown", (e, t) => {
$e.init(e, t), J.init(e, t);
});
function un() {
return Mt(ln);
}
var dn = /* @__PURE__ */ g("ZodNever", (e, t) => {
et.init(e, t), J.init(e, t);
});
function fn(e) {
return Nt(dn, e);
}
var pn = /* @__PURE__ */ g("ZodArray", (e, t) => {
nt.init(e, t), J.init(e, t), e.element = t.element, e.min = (t, n) => e.check(Rt(t, n)), e.nonempty = (t) => e.check(Rt(1, t)), e.max = (t, n) => e.check(Lt(t, n)), e.length = (t, n) => e.check(zt(t, n)), e.unwrap = () => e.element;
});
function mn(e, t) {
return Vt(pn, e, t);
}
var hn = /* @__PURE__ */ g("ZodObject", (e, t) => {
ot.init(e, t), J.init(e, t), C(e, "shape", () => t.shape), e.keyof = () => xn(Object.keys(e._zod.def.shape)), e.catchall = (t) => e.clone({
...e._zod.def,
catchall: t
}), e.passthrough = () => e.clone({
...e._zod.def,
catchall: un()
}), e.loose = () => e.clone({
...e._zod.def,
catchall: un()
}), e.strict = () => e.clone({
...e._zod.def,
catchall: fn()
}), e.strip = () => e.clone({
...e._zod.def,
catchall: void 0
}), e.extend = (t) => _e(e, t), e.safeExtend = (t) => ve(e, t), e.merge = (t) => ye(e, t), e.pick = (t) => he(e, t), e.omit = (t) => ge(e, t), e.partial = (...t) => be(wn, e, t[0]), e.required = (...t) => xe(Mn, e, t[0]);
});
function gn(e, t) {
return new hn({
type: "object",
shape: e == null ? {} : e,
...k(t)
});
}
var _n = /* @__PURE__ */ g("ZodUnion", (e, t) => {
ct.init(e, t), J.init(e, t), e.options = t.options;
});
function vn(e, t) {
return new _n({
type: "union",
options: e,
...k(t)
});
}
var yn = /* @__PURE__ */ g("ZodIntersection", (e, t) => {
lt.init(e, t), J.init(e, t);
});
function bn(e, t) {
return new yn({
type: "intersection",
left: e,
right: t
});
}
var Y = /* @__PURE__ */ g("ZodEnum", (e, t) => {
dt.init(e, t), J.init(e, t), e.enum = t.entries, e.options = Object.values(t.entries);
let n = new Set(Object.keys(t.entries));
e.extract = (e, r) => {
let i = {};
for (let r of e) if (n.has(r)) i[r] = t.entries[r];
else throw Error(`Key ${r} not found in enum`);
return new Y({
...t,
checks: [],
...k(r),
entries: i
});
}, e.exclude = (e, r) => {
let i = { ...t.entries };
for (let t of e) if (n.has(t)) delete i[t];
else throw Error(`Key ${t} not found in enum`);
return new Y({
...t,
checks: [],
...k(r),
entries: i
});
};
});
function xn(e, t) {
return new Y({
type: "enum",
entries: Array.isArray(e) ? Object.fromEntries(e.map((e) => [e, e])) : e,
...k(t)
});
}
var Sn = /* @__PURE__ */ g("ZodTransform", (e, t) => {
ft.init(e, t), J.init(e, t), e._zod.parse = (n, r) => {
if (r.direction === "backward") throw new ne(e.constructor.name);
n.addIssue = (r) => {
if (typeof r == "string") n.issues.push(P(r, n.value, t));
else {
let t = r;
t.fatal && (t.continue = !1), t.code != null || (t.code = "custom"), t.input != null || (t.input = n.value), t.inst != null || (t.inst = e), n.issues.push(P(t));
}
};
let i = t.transform(n.value, n);
return i instanceof Promise ? i.then((e) => (n.value = e, n)) : (n.value = i, n);
};
});
function Cn(e) {
return new Sn({
type: "transform",
transform: e
});
}
var wn = /* @__PURE__ */ g("ZodOptional", (e, t) => {
mt.init(e, t), J.init(e, t), e.unwrap = () => e._zod.def.innerType;
});
function Tn(e) {
return new wn({
type: "optional",
innerType: e
});
}
var En = /* @__PURE__ */ g("ZodNullable", (e, t) => {
ht.init(e, t), J.init(e, t), e.unwrap = () => e._zod.def.innerType;
});
function Dn(e) {
return new En({
type: "nullable",
innerType: e
});
}
var On = /* @__PURE__ */ g("ZodDefault", (e, t) => {
gt.init(e, t), J.init(e, t), e.unwrap = () => e._zod.def.innerType, e.removeDefault = e.unwrap;
});
function kn(e, t) {
return new On({
type: "default",
innerType: e,
get defaultValue() {
return typeof t == "function" ? t() : ue(t);
}
});
}
var An = /* @__PURE__ */ g("ZodPrefault", (e, t) => {
vt.init(e, t), J.init(e, t), e.unwrap = () => e._zod.def.innerType;
});
function jn(e, t) {
return new An({
type: "prefault",
innerType: e,
get defaultValue() {
return typeof t == "function" ? t() : ue(t);
}
});
}
var Mn = /* @__PURE__ */ g("ZodNonOptional", (e, t) => {
yt.init(e, t), J.init(e, t), e.unwrap = () => e._zod.def.innerType;
});
function Nn(e, t) {
return new Mn({
type: "nonoptional",
innerType: e,
...k(t)
});
}
var Pn = /* @__PURE__ */ g("ZodCatch", (e, t) => {
xt.init(e, t), J.init(e, t), e.unwrap = () => e._zod.def.innerType, e.removeCatch = e.unwrap;
});
function Fn(e, t) {
return new Pn({
type: "catch",
innerType: e,
catchValue: typeof t == "function" ? t : () => t
});
}
var In = /* @__PURE__ */ g("ZodPipe", (e, t) => {
St.init(e, t), J.init(e, t), e.in = t.in, e.out = t.out;
});
function Ln(e, t) {
return new In({
type: "pipe",
in: e,
out: t
});
}
var Rn = /* @__PURE__ */ g("ZodReadonly", (e, t) => {
Ct.init(e, t), J.init(e, t), e.unwrap = () => e._zod.def.innerType;
});
function zn(e) {
return new Rn({
type: "readonly",
innerType: e
});
}
var Bn = /* @__PURE__ */ g("ZodCustom", (e, t) => {
Tt.init(e, t), J.init(e, t);
});
function Vn(e, t = {}) {
return Ht(Bn, e, t);
}
function Hn(e) {
return Ut(e);
}
function Un(e, t = { error: `Input not instance of ${e.name}` }) {
let n = new Bn({
type: "custom",
check: "custom",
fn: (t) => t instanceof e,
abort: !0,
...k(t)
});
return n._zod.bag.Class = e, n;
}
//#endregion
//#region src/shared.ts
function Wn(e) {
return Number.isFinite(e);
}
function Gn(e) {
return l(e) && e.trim() !== "";
}
function Kn(e) {
return e instanceof Blob;
}
function qn(e) {
return e instanceof FormData;
}
function Jn(e) {
return e instanceof Uint8Array;
}
function Yn(e) {
return X(e) || Jn(e) || s(e) && "ArrayBuffer" in e && X(e.ArrayBuffer);
}
function Xn(e) {
return Jt(gn({
byteLength: on(),
byteOffset: on(),
buffer: Un(ArrayBuffer)
}), e).success;
}
function X(e) {
return e instanceof ArrayBuffer;
}
function Zn(e) {
return ArrayBuffer.isView(e) || Yn(e) || Xn(e) || X(e);
}
function Qn(e) {
return e instanceof ReadableStream;
}
function $n(e) {
return Kn(e) || qn(e) || Zn(e) || Qn(e);
}
function er(e) {
return e instanceof URLSearchParams;
}
var tr = (e) => i(e) && r(e, 1);
function nr(e) {
return tr(e) && e.every(l);
}
function rr(e) {
if (er(e)) return e;
if (l(e)) return new URLSearchParams(e);
if (nr(e)) return new URLSearchParams(m(e, n((e) => e.includes("=")), d((e) => e.trim()), u("&")));
if (c(e)) return new URLSearchParams(m(e, f((e) => e == null ? void 0 : e.toString()), p(o)));
}
//#endregion
//#region node_modules/nanoid/index.browser.js
var ir = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((e, t) => (t &= 63, t < 36 ? e += t.toString(36) : t < 62 ? e += (t - 26).toString(36).toUpperCase() : t > 62 ? e += "-" : e += "_", e), "");
//#endregion
//#region \0@oxc-project+runtime@0.127.0/helpers/typeof.js
function Z(e) {
"@babel/helpers - typeof";
return Z = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
return typeof e;
} : function(e) {
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
}, Z(e);
}
//#endregion
//#region \0@oxc-project+runtime@0.127.0/helpers/toPrimitive.js
function ar(e, t) {
if (Z(e) != "object" || !e) return e;
var n = e[Symbol.toPrimitive];
if (n !== void 0) {
var r = n.call(e, t || "default");
if (Z(r) != "object") return r;
throw TypeError("@@toPrimitive must return a primitive value.");
}
return (t === "string" ? String : Number)(e);
}
//#endregion
//#region \0@oxc-project+runtime@0.127.0/helpers/toPropertyKey.js
function or(e) {
var t = ar(e, "string");
return Z(t) == "symbol" ? t : t + "";
}
//#endregion
//#region \0@oxc-project+runtime@0.127.0/helpers/defineProperty.js
function Q(e, t, n) {
return (t = or(t)) in e ? Object.defineProperty(e, t, {
value: n,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[t] = n, e;
}
//#endregion
//#region src/context.ts
var $ = class t {
constructor(n, r) {
var s, u;
Q(this, "api", void 0), Q(this, "url", void 0), Q(this, "path", void 0), Q(this, "req", void 0), Q(this, "data", void 0), Q(this, "res", {}), Q(this, "initApi", (e) => {
let { api: t, data: n } = this;
if (er(n)) {
let [e, ...r] = t.split("?"), i = r.join("?"), a = `${n.toString()}&${i}`;
this.api = `${e}?${new URLSearchParams(a).toString()}`;
}
}), Q(this, "initBody", ({ stringify: e }) => {
let { body: t, headers: n } = this.req;
if (o(t)) {
let { data: t } = this;
if ($n(t) && (this.req.body = t), i(t) || c(t)) {
let r = "Content-Type";
this.req.body = e(t), n.has(r) || n.set(r, "application/json");
}
}
}), Q(this, "initMethod", (e) => {
if (!this.req.method) {
let { body: e } = this.req;
this.req.method = o(e) ? "GET" : "POST";
}
}), Q(this, "init", ({ stringify: e = JSON.stringify } = {}) => (this.initApi({ stringify: e }), this.initBody({ stringify: e }), this.initMethod({ stringify: e }), this)), Q(this, "initAbort", (e) => {
if (a(AbortController) && Wn(e)) {
let t = new AbortController();
this.req.signal = t.signal, setTimeout(() => t.abort(), e);
}
}), Q(this, "decodeHeader", (e) => {
let { res: t } = this, { headers: n } = e, r = n.get("Content-Type");
if (t) if (Gn(r)) {
let e = r.split(";"), n = rr(e), i = n == null ? void 0 : n.get("charset");
l(i) && (t.charset = i);
for (let n of e) {
let e = ee.getExtension(n);
l(e) && !l(t.type) && (t.type = e);
}
} else l(t.type) || (t.type = "txt");
}), Q(this, "clone", () => {
let { api: t, url: n, path: r, req: i, data: a, res: o } = this, { headers: s, ...c } = i;
return {
api: t,
url: n,
path: r,
req: {
headers: new Headers(s),
...e(c)
},
res: e(o),
data: e(a)
};
});
let { id: d = t.randomId(), data: f, headers: p, ...m } = r == null ? {} : r;
this.api = n, this.data = f, this.url = t.toURL(n), this.path = (s = (u = this.url) == null ? void 0 : u.pathname) == null ? n : s, this.req = {
id: d,
...m,
headers: new Headers(p)
};
}
};
Q($, "toURL", (e) => {
try {
return URL.parse(e);
} catch {
return null;
}
}), Q($, "randomId", () => ir().replace(/-/g, "").slice(0, 8));
//#endregion
//#region src/match.ts
var sr = (e, t) => t === "*" ? !0 : t.startsWith("!") ? !h(t.slice(1))(e) : h(t)(e);
//#endregion
//#region src/parser.ts
async function cr(e, t, n) {
let r = await e.read();
r.done ? t.close() : (n == null || n(r), t.enqueue(r.value), await cr(e, t, n));
}
function lr(e) {
switch (e) {
case "txt":
case "css":
case "xml":
case "html":
case "plain":
case "richtext":
case "javascript": return !0;
}
return !1;
}
var ur = () => async (e, t, n = {}) => {
let { res: r } = t, { attchment: i = !1 } = n, { body: o, ok: s, headers: c, status: l } = e;
t.res.status = l, t.res.headers = c;
let u = c.get("Content-Disposition"), d = i || (u == null ? void 0 : u.includes("attachment"));
if (s) {
let { receiver: e } = n, r = Number(c.get("Content-Length")), i = Wn(r) && a(e);
if (o && i && r > 0) {
let n = { bytes: 0 }, i = o.getReader(), a = new ReadableStream({ async start(a) {
await cr(i, a, ({ value: a, done: o }) => {
n.bytes += a.length;
let s = 100 * n.bytes / r;
e({
size: r,
value: a,
reader: i,
context: t,
percentage: s,
done: s === 100 || o
});
});
} });
t.res.raw = new Response(a);
return;
}
}
if (d || r.type === "xlsx") {
t.res.body = await e.blob();
return;
}
if (r.type === "json") {
t.res.body = await e.json();
return;
}
if (!r.type || lr(r.type)) {
t.res.body = await e.text();
return;
}
}, dr = [
"GET",
"PUT",
"POST",
"HEAD",
"TRACE",
"PATCH",
"DELETE",
"CONNECT",
"OPTIONS"
];
//#endregion
//#region src/core.ts
function fr(e, t, n) {
return s(e) ? e : {
api: e,
data: t,
...n
};
}
var pr = class {
constructor(e = {}) {
var r, a, o;
Q(this, "hooks", void 0), Q(this, "randomId", void 0), Q(this, "stringify", JSON.stringify), Q(this, "parser", void 0), Q(this, "middlewares", void 0), Q(this, "use", (e, t) => (this.middlewares.push([e, t]), this)), Q(this, "request", async ({ api: e, use: r, data: i, timeout: a, attchment: o, receiver: s, parse: c = this.parser(), stringify: u = this.stringify, ...f }) => {
let { middlewares: p, randomId: ee } = this, h = new $(e, {
...f,
data: i,
id: ee()
});
return await te(m(p, n(([e]) => l(e) ? sr(h.path, e) : e(h.clone())), d(([, e]) => e), t(r == null ? [] : r)))(h, async () => {
var e, t, n, r, i, l;
let { hooks: u } = this;
await (u == null || (e = u.beforeInit) == null ? void 0 : e.call(u, h)), h.init(), await (u == null || (t = u.afterInit) == null ? void 0 : t.call(u, h)), h.initAbort(a);
let { api: d, req: f } = h;
await (u == null || (n = u.beforeFetch) == null ? void 0 : n.call(u, h));
let p = await fetch(d, f);
await (u == null || (r = u.afterFetch) == null ? void 0 : r.call(u, h)), h.res.raw = p, h.decodeHeader(p), await (u == null || (i = u.beforeParse) == null ? void 0 : i.call(u, h)), await c(p, h, {
attchment: o,
receiver: s
}), await (u == null || (l = u.afterParse) == null ? void 0 : l.call(u, h));
}), h;
}), Q(this, "drive", (async (...e) => (await this.request(fr(...e))).res.body));
let s = i(e) ? { use: e } : e;
this.hooks = s.hooks, this.middlewares = (r = s.use) == null ? [] : r, this.parser = (a = s.parser) == null ? ur : a, this.randomId = (o = s.randomId) == null ? $.randomId : o, s.stringify && (this.stringify = s.stringify), dr.forEach((e) => {
let t = e.toLowerCase();
this.drive[t] = async (...t) => (await this.request({
...fr(...t),
method: e
})).res.body;
});
}
};
//#endregion
export { $ as DriveContext, pr as Driver, te as compose, lr as isRawTextBody, ur as parser };
//# sourceMappingURL=index.js.map