@marimo-team/islands 0.14.11-dev2 → 0.14.11-dev21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ConnectedDataExplorerComponent-Dl7Gx8nj.js → ConnectedDataExplorerComponent-B98UAJGl.js} +4 -4
- package/dist/{ImageComparisonComponent-IsA0pccG.js → ImageComparisonComponent-3rx-X1eA.js} +1 -1
- package/dist/{VegaLite-C3jfIIJl.js → VegaLite-bssctYsi.js} +6961 -7180
- package/dist/{_baseUniq-DXGCzwrs.js → _baseUniq-n5nuGCm-.js} +36 -36
- package/dist/{any-language-editor-BbtP_crK.js → any-language-editor-CTuUQiXP.js} +1 -1
- package/dist/{architectureDiagram-IEHRJDOE-B5UTatfK.js → architectureDiagram-NQ2NVSRB-Ghs-gTjF.js} +897 -894
- package/dist/assets/{worker-BcyuOSTi.js → save-worker-fI5ofStJ.js} +1076 -1649
- package/dist/assets/{save-worker-BIDtxCd1.js → worker-Bfk1FrzG.js} +1627 -1747
- package/dist/assets/worker-BldghCZh.js +3752 -0
- package/dist/{blockDiagram-JOT3LUYC-BsdaPVqe.js → blockDiagram-PHRCVELO-BJrdpvE8.js} +534 -522
- package/dist/{c4Diagram-VJAJSXHY-mAt84R4z.js → c4Diagram-6F6E4RAY-C3mvzJPu.js} +4 -4
- package/dist/{channel-BQIWHLpc.js → channel-Dv_KwBSx.js} +1 -1
- package/dist/{chunk-4BMEZGHF-CKIxJWxP.js → chunk-353BL4L5-DE1uUKLI.js} +1 -1
- package/dist/{chunk-D6G4REZN-CgGV16Ao.js → chunk-67H74DCK-BSe-uUSS.js} +1 -1
- package/dist/chunk-6OLS64BW-lmSfyWue.js +1383 -0
- package/dist/{chunk-XZIHB7SX-Bwue5JjE.js → chunk-AACKK3MU-DAmuROVD.js} +1 -1
- package/dist/chunk-BFAMUDN2-D9C6R9UM.js +8 -0
- package/dist/chunk-E2GYISFI-BzFDmP6o.js +19 -0
- package/dist/{chunk-A2AXSNBT-wMvlVMnZ.js → chunk-QEP2MXWD-BILXx23p.js} +30 -27
- package/dist/chunk-SKB7J2MH-CxMkQppY.js +20 -0
- package/dist/{classDiagram-GIVACNV2-DOmcKRwM.js → classDiagram-BGRH5UQR-BbYr5aD9.js} +2 -2
- package/dist/{classDiagram-v2-COTLJTTW-DOmcKRwM.js → classDiagram-v2-O24JOBDK-BbYr5aD9.js} +2 -2
- package/dist/{clone-PHSHUhb-.js → clone-DuBujAk0.js} +1 -1
- package/dist/{dagre-OKDRZEBW-D5HNBllU.js → dagre-FFZHY6LT-DO5nLpLx.js} +8 -8
- package/dist/{data-editor-Coz_zrsX.js → data-editor-C8yM5wyh.js} +213 -201
- package/dist/diagram-3EMPZRKU-B1rYMJMS.js +313 -0
- package/dist/diagram-5UYTHUR4-BUu8PsmE.js +137 -0
- package/dist/{diagram-SSKATNLV-BsO89QJN.js → diagram-ZTM2IBQH-lz_uZrYh.js} +3 -3
- package/dist/{erDiagram-Q7BY3M3F-DWIMKTfS.js → erDiagram-R3QVA2FD-D_A2jrJV.js} +6 -5
- package/dist/{flowDiagram-4HSFHLVR-CnO0wmaL.js → flowDiagram-PKI6S5ZS-Bv6D_bIf.js} +283 -278
- package/dist/{ganttDiagram-APWFNJXF-otclLFL4.js → ganttDiagram-EK5VF46D-CbkaARm4.js} +453 -439
- package/dist/{gitGraphDiagram-7IBYFJ6S-C7F3RAja.js → gitGraphDiagram-GW3U2K7C-B8ZGoOT-.js} +35 -35
- package/dist/{graph-Btsdly6D.js → graph-txVVq_De.js} +3 -3
- package/dist/{index-BreCkhLm.js → index-BI6tloBb.js} +3 -3
- package/dist/{index-CcRF-HlA.js → index-CFJazcU-.js} +4 -4
- package/dist/{index-BGmzdYRo.js → index-OiR0LgXX.js} +6 -3
- package/dist/{index-z8OyYHEh.js → index-fJDj-gSp.js} +1 -1
- package/dist/index-pBmAzQJl.js +235 -0
- package/dist/{infoDiagram-PH2N3AL5-BwcXDzwE.js → infoDiagram-RLU2ROGC-DJw6nWp0.js} +5 -3
- package/dist/journeyDiagram-EWQZEKCU-1oCDdLcB.js +836 -0
- package/dist/{kanban-definition-NDS4AKOZ-3NJYjnpz.js → kanban-definition-ILFWEQ3N-nKJ02Ox0.js} +41 -39
- package/dist/{layout-qfivsCI_.js → layout-CbUwX9d6.js} +49 -49
- package/dist/{linear-D_Kojy5s.js → linear-sn9_bxtB.js} +22 -22
- package/dist/{main-DLuap1gp.js → main-D9-48wlP.js} +45053 -45130
- package/dist/main.js +1 -1
- package/dist/{mermaid-DCIbF0Rd.js → mermaid-CRRCnedu.js} +4925 -4853
- package/dist/min-CYaGuxZ4.js +80 -0
- package/dist/{mindmap-definition-ALO5MXBD-BtSBR7-c.js → mindmap-definition-CZNETY7S-CV62GMPJ.js} +3 -3
- package/dist/{pieDiagram-IB7DONF6-TiB_3g9z.js → pieDiagram-NIOCPIFQ-Bcs4p6kX.js} +3 -3
- package/dist/{quadrantDiagram-7GDLP6J5-B0DPjp7Z.js → quadrantDiagram-2OG54O6I-BlY5yea6.js} +2 -2
- package/dist/{react-plotly-BXWB3UQ5.js → react-plotly-B1SKP2B-.js} +1 -1
- package/dist/{requirementDiagram-KVF5MWMF-D_IlbRr_.js → requirementDiagram-SO3GGRV7-rmiJc5mh.js} +5 -4
- package/dist/{sankeyDiagram-QLVOVGJD-BHm9uvp_.js → sankeyDiagram-4UZDY2LN-TVzOLFCA.js} +11 -11
- package/dist/{sequenceDiagram-X6HHIX6F-3wcWWNtl.js → sequenceDiagram-ZIKVLSP4-POBNIgPB.js} +151 -149
- package/dist/{slides-component-JEGZbKgL.js → slides-component-5Y9DQzeV.js} +969 -962
- package/dist/stateDiagram-XX37X6EN-lR-7TG5f.js +264 -0
- package/dist/{stateDiagram-v2-YXO3MK2T-DTdt4vFc.js → stateDiagram-v2-GD6S3NHB-CYV2YCSY.js} +2 -2
- package/dist/style.css +1 -1
- package/dist/{time-DyZM4tB4.js → time-BytuUgXk.js} +2 -2
- package/dist/{timeline-definition-BDJGKUSR-Of4cvbYH.js → timeline-definition-RI47OAVP-DOrNrVHk.js} +99 -102
- package/dist/{radar-MK3ICKWK-BMSp8zaN.js → treemap-FKARHQ26-BOli4yXg.js} +2469 -2330
- package/dist/{vega-component-Dwc_9OTG.js → vega-component-KZ-3GH6H.js} +21 -21
- package/dist/{xychartDiagram-VJFVF3MP-5Jc993Va.js → xychartDiagram-H2YORKM3-CUOFDcIy.js} +409 -375
- package/package.json +37 -37
- package/dist/assets/worker-Dz6PPEGc.js +0 -4115
- package/dist/chunk-AEK57VVT-BAi7QtEw.js +0 -1416
- package/dist/chunk-RZ5BOZE2-D7Ag0UF8.js +0 -24
- package/dist/diagram-VNBRO52H-CA8VTm7L.js +0 -126
- package/dist/journeyDiagram-U35MCT3I-Co4hTdu9.js +0 -809
- package/dist/min-CQBZldos.js +0 -80
- package/dist/stateDiagram-DGXRK772-DbH3Rdz4.js +0 -271
|
@@ -0,0 +1,3752 @@
|
|
|
1
|
+
var tr = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports);
|
|
2
|
+
var ds = tr((fs, ze) => {
|
|
3
|
+
const rr = 1e10, sr = 1e3;
|
|
4
|
+
function ge(t, e) {
|
|
5
|
+
const r = t.map((s) => `"${s}"`).join(", ");
|
|
6
|
+
return new Error(`This RPC instance cannot ${e} because the transport did not provide one or more of these methods: ${r}`);
|
|
7
|
+
}
|
|
8
|
+
function nr(t = {}) {
|
|
9
|
+
let e = {};
|
|
10
|
+
function r(m) {
|
|
11
|
+
e = m;
|
|
12
|
+
}
|
|
13
|
+
let s = {};
|
|
14
|
+
function n(m) {
|
|
15
|
+
s.unregisterHandler && s.unregisterHandler(), s = m, s.registerHandler?.(er);
|
|
16
|
+
}
|
|
17
|
+
let a;
|
|
18
|
+
function i(m) {
|
|
19
|
+
if (typeof m == "function") {
|
|
20
|
+
a = m;
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
a = (b, E) => {
|
|
24
|
+
const N = m[b];
|
|
25
|
+
if (N)
|
|
26
|
+
return N(E);
|
|
27
|
+
const I = m._;
|
|
28
|
+
if (!I)
|
|
29
|
+
throw new Error(`The requested method has no handler: ${b}`);
|
|
30
|
+
return I(b, E);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const { maxRequestTime: o = sr } = t;
|
|
34
|
+
t.transport && n(t.transport), t.requestHandler && i(t.requestHandler), t._debugHooks && r(t._debugHooks);
|
|
35
|
+
let c = 0;
|
|
36
|
+
function l() {
|
|
37
|
+
return c <= rr ? ++c : c = 0;
|
|
38
|
+
}
|
|
39
|
+
const p = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
|
|
40
|
+
function S(m, ...b) {
|
|
41
|
+
const E = b[0];
|
|
42
|
+
return new Promise((N, I) => {
|
|
43
|
+
if (!s.send)
|
|
44
|
+
throw ge(["send"], "make requests");
|
|
45
|
+
const D = l(), Xe = {
|
|
46
|
+
type: "request",
|
|
47
|
+
id: D,
|
|
48
|
+
method: m,
|
|
49
|
+
params: E
|
|
50
|
+
};
|
|
51
|
+
p.set(D, { resolve: N, reject: I }), o !== 1 / 0 && x.set(D, setTimeout(() => {
|
|
52
|
+
x.delete(D), I(new Error("RPC request timed out."));
|
|
53
|
+
}, o)), e.onSend?.(Xe), s.send(Xe);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const P = new Proxy(S, {
|
|
57
|
+
get: (m, b, E) => b in m ? Reflect.get(m, b, E) : (N) => S(b, N)
|
|
58
|
+
}), Z = P;
|
|
59
|
+
function ye(m, ...b) {
|
|
60
|
+
const E = b[0];
|
|
61
|
+
if (!s.send)
|
|
62
|
+
throw ge(["send"], "send messages");
|
|
63
|
+
const N = {
|
|
64
|
+
type: "message",
|
|
65
|
+
id: m,
|
|
66
|
+
payload: E
|
|
67
|
+
};
|
|
68
|
+
e.onSend?.(N), s.send(N);
|
|
69
|
+
}
|
|
70
|
+
const Je = new Proxy(ye, {
|
|
71
|
+
get: (m, b, E) => b in m ? Reflect.get(m, b, E) : (N) => ye(b, N)
|
|
72
|
+
}), Ye = Je, J = /* @__PURE__ */ new Map(), Re = /* @__PURE__ */ new Set();
|
|
73
|
+
function Kt(m, b) {
|
|
74
|
+
if (!s.registerHandler)
|
|
75
|
+
throw ge(["registerHandler"], "register message listeners");
|
|
76
|
+
if (m === "*") {
|
|
77
|
+
Re.add(b);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
J.has(m) || J.set(m, /* @__PURE__ */ new Set()), J.get(m)?.add(b);
|
|
81
|
+
}
|
|
82
|
+
function Qt(m, b) {
|
|
83
|
+
if (m === "*") {
|
|
84
|
+
Re.delete(b);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
J.get(m)?.delete(b), J.get(m)?.size === 0 && J.delete(m);
|
|
88
|
+
}
|
|
89
|
+
async function er(m) {
|
|
90
|
+
if (e.onReceive?.(m), !("type" in m))
|
|
91
|
+
throw new Error("Message does not contain a type.");
|
|
92
|
+
if (m.type === "request") {
|
|
93
|
+
if (!s.send || !a)
|
|
94
|
+
throw ge(["send", "requestHandler"], "handle requests");
|
|
95
|
+
const { id: b, method: E, params: N } = m;
|
|
96
|
+
let I;
|
|
97
|
+
try {
|
|
98
|
+
I = {
|
|
99
|
+
type: "response",
|
|
100
|
+
id: b,
|
|
101
|
+
success: !0,
|
|
102
|
+
payload: await a(E, N)
|
|
103
|
+
};
|
|
104
|
+
} catch (D) {
|
|
105
|
+
if (!(D instanceof Error))
|
|
106
|
+
throw D;
|
|
107
|
+
I = {
|
|
108
|
+
type: "response",
|
|
109
|
+
id: b,
|
|
110
|
+
success: !1,
|
|
111
|
+
error: D.message
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
e.onSend?.(I), s.send(I);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (m.type === "response") {
|
|
118
|
+
const b = x.get(m.id);
|
|
119
|
+
b != null && clearTimeout(b);
|
|
120
|
+
const { resolve: E, reject: N } = p.get(m.id) ?? {};
|
|
121
|
+
m.success ? E?.(m.payload) : N?.(new Error(m.error));
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (m.type === "message") {
|
|
125
|
+
for (const E of Re)
|
|
126
|
+
E(m.id, m.payload);
|
|
127
|
+
const b = J.get(m.id);
|
|
128
|
+
if (!b)
|
|
129
|
+
return;
|
|
130
|
+
for (const E of b)
|
|
131
|
+
E(m.payload);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
throw new Error(`Unexpected RPC message type: ${m.type}`);
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
setTransport: n,
|
|
138
|
+
setRequestHandler: i,
|
|
139
|
+
request: P,
|
|
140
|
+
requestProxy: Z,
|
|
141
|
+
send: Je,
|
|
142
|
+
sendProxy: Ye,
|
|
143
|
+
addMessageListener: Kt,
|
|
144
|
+
removeMessageListener: Qt,
|
|
145
|
+
proxy: { send: Ye, request: Z },
|
|
146
|
+
_setDebugHooks: r
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function ar(t) {
|
|
150
|
+
return nr(t);
|
|
151
|
+
}
|
|
152
|
+
const vt = "[transport-id]";
|
|
153
|
+
function ir(t, e) {
|
|
154
|
+
const { transportId: r } = e;
|
|
155
|
+
return r != null ? { [vt]: r, data: t } : t;
|
|
156
|
+
}
|
|
157
|
+
function or(t, e) {
|
|
158
|
+
const { transportId: r, filter: s } = e, n = s?.();
|
|
159
|
+
if (r != null && n != null)
|
|
160
|
+
throw new Error("Cannot use both `transportId` and `filter` at the same time");
|
|
161
|
+
let a = t;
|
|
162
|
+
if (r) {
|
|
163
|
+
if (t[vt] !== r)
|
|
164
|
+
return [!0];
|
|
165
|
+
a = t.data;
|
|
166
|
+
}
|
|
167
|
+
return n === !1 ? [!0] : [!1, a];
|
|
168
|
+
}
|
|
169
|
+
function cr(t, e = {}) {
|
|
170
|
+
const { transportId: r, filter: s, remotePort: n } = e, a = t, i = n ?? t;
|
|
171
|
+
let o;
|
|
172
|
+
return {
|
|
173
|
+
send(c) {
|
|
174
|
+
i.postMessage(ir(c, { transportId: r }));
|
|
175
|
+
},
|
|
176
|
+
registerHandler(c) {
|
|
177
|
+
o = (l) => {
|
|
178
|
+
const p = l.data, [x, S] = or(p, {
|
|
179
|
+
transportId: r,
|
|
180
|
+
filter: () => s?.(l)
|
|
181
|
+
});
|
|
182
|
+
x || c(S);
|
|
183
|
+
}, a.addEventListener("message", o);
|
|
184
|
+
},
|
|
185
|
+
unregisterHandler() {
|
|
186
|
+
o && a.removeEventListener("message", o);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function dr(t) {
|
|
191
|
+
return cr(self, t);
|
|
192
|
+
}
|
|
193
|
+
function lr(t) {
|
|
194
|
+
let e, r = !1;
|
|
195
|
+
return function(...s) {
|
|
196
|
+
return r || (r = !0, e = t.apply(this, s)), e;
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
const ce = {
|
|
200
|
+
NOOP: () => {
|
|
201
|
+
}
|
|
202
|
+
}, _t = (t, e) => {
|
|
203
|
+
const r = `[${t}]`;
|
|
204
|
+
return {
|
|
205
|
+
debug: (...s) => e.debug(r, ...s),
|
|
206
|
+
log: (...s) => e.log(r, ...s),
|
|
207
|
+
warn: (...s) => e.warn(r, ...s),
|
|
208
|
+
error: (...s) => e.error(r, ...s),
|
|
209
|
+
trace: (...s) => e.trace(r, ...s),
|
|
210
|
+
get: (s) => _t(`${t}.${s}`, e),
|
|
211
|
+
disabled: (s = !0) => s ? we : e
|
|
212
|
+
};
|
|
213
|
+
}, ke = {
|
|
214
|
+
debug: (...t) => {
|
|
215
|
+
console.debug(...t);
|
|
216
|
+
},
|
|
217
|
+
log: (...t) => {
|
|
218
|
+
console.log(...t);
|
|
219
|
+
},
|
|
220
|
+
warn: (...t) => {
|
|
221
|
+
console.warn(...t);
|
|
222
|
+
},
|
|
223
|
+
error: (...t) => {
|
|
224
|
+
console.error(...t);
|
|
225
|
+
},
|
|
226
|
+
trace: (...t) => {
|
|
227
|
+
console.trace(...t);
|
|
228
|
+
},
|
|
229
|
+
get: (t) => _t(t, ke),
|
|
230
|
+
disabled: (t = !0) => t ? we : ke
|
|
231
|
+
}, we = {
|
|
232
|
+
debug: () => ce.NOOP,
|
|
233
|
+
log: () => ce.NOOP,
|
|
234
|
+
warn: () => ce.NOOP,
|
|
235
|
+
error: () => ce.NOOP,
|
|
236
|
+
trace: () => ce.NOOP,
|
|
237
|
+
get: () => we,
|
|
238
|
+
disabled: () => we
|
|
239
|
+
};
|
|
240
|
+
function ur() {
|
|
241
|
+
return typeof window < "u" && window.Logger || ke;
|
|
242
|
+
}
|
|
243
|
+
const q = ur(), Pe = (t) => new TextDecoder().decode(t);
|
|
244
|
+
class fr {
|
|
245
|
+
promise;
|
|
246
|
+
resolve;
|
|
247
|
+
reject;
|
|
248
|
+
status = "pending";
|
|
249
|
+
constructor() {
|
|
250
|
+
this.promise = new Promise((e, r) => {
|
|
251
|
+
this.reject = (s) => {
|
|
252
|
+
this.status = "rejected", r(s);
|
|
253
|
+
}, this.resolve = (s) => {
|
|
254
|
+
this.status = "resolved", e(s);
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
var w;
|
|
260
|
+
(function(t) {
|
|
261
|
+
t.assertEqual = (n) => {
|
|
262
|
+
};
|
|
263
|
+
function e(n) {
|
|
264
|
+
}
|
|
265
|
+
t.assertIs = e;
|
|
266
|
+
function r(n) {
|
|
267
|
+
throw new Error();
|
|
268
|
+
}
|
|
269
|
+
t.assertNever = r, t.arrayToEnum = (n) => {
|
|
270
|
+
const a = {};
|
|
271
|
+
for (const i of n)
|
|
272
|
+
a[i] = i;
|
|
273
|
+
return a;
|
|
274
|
+
}, t.getValidEnumValues = (n) => {
|
|
275
|
+
const a = t.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), i = {};
|
|
276
|
+
for (const o of a)
|
|
277
|
+
i[o] = n[o];
|
|
278
|
+
return t.objectValues(i);
|
|
279
|
+
}, t.objectValues = (n) => t.objectKeys(n).map(function(a) {
|
|
280
|
+
return n[a];
|
|
281
|
+
}), t.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
|
|
282
|
+
const a = [];
|
|
283
|
+
for (const i in n)
|
|
284
|
+
Object.prototype.hasOwnProperty.call(n, i) && a.push(i);
|
|
285
|
+
return a;
|
|
286
|
+
}, t.find = (n, a) => {
|
|
287
|
+
for (const i of n)
|
|
288
|
+
if (a(i))
|
|
289
|
+
return i;
|
|
290
|
+
}, t.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && Number.isFinite(n) && Math.floor(n) === n;
|
|
291
|
+
function s(n, a = " | ") {
|
|
292
|
+
return n.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
293
|
+
}
|
|
294
|
+
t.joinValues = s, t.jsonStringifyReplacer = (n, a) => typeof a == "bigint" ? a.toString() : a;
|
|
295
|
+
})(w || (w = {}));
|
|
296
|
+
var Ge;
|
|
297
|
+
(function(t) {
|
|
298
|
+
t.mergeShapes = (e, r) => ({
|
|
299
|
+
...e,
|
|
300
|
+
...r
|
|
301
|
+
// second overwrites first
|
|
302
|
+
});
|
|
303
|
+
})(Ge || (Ge = {}));
|
|
304
|
+
const f = w.arrayToEnum([
|
|
305
|
+
"string",
|
|
306
|
+
"nan",
|
|
307
|
+
"number",
|
|
308
|
+
"integer",
|
|
309
|
+
"float",
|
|
310
|
+
"boolean",
|
|
311
|
+
"date",
|
|
312
|
+
"bigint",
|
|
313
|
+
"symbol",
|
|
314
|
+
"function",
|
|
315
|
+
"undefined",
|
|
316
|
+
"null",
|
|
317
|
+
"array",
|
|
318
|
+
"object",
|
|
319
|
+
"unknown",
|
|
320
|
+
"promise",
|
|
321
|
+
"void",
|
|
322
|
+
"never",
|
|
323
|
+
"map",
|
|
324
|
+
"set"
|
|
325
|
+
]), V = (t) => {
|
|
326
|
+
switch (typeof t) {
|
|
327
|
+
case "undefined":
|
|
328
|
+
return f.undefined;
|
|
329
|
+
case "string":
|
|
330
|
+
return f.string;
|
|
331
|
+
case "number":
|
|
332
|
+
return Number.isNaN(t) ? f.nan : f.number;
|
|
333
|
+
case "boolean":
|
|
334
|
+
return f.boolean;
|
|
335
|
+
case "function":
|
|
336
|
+
return f.function;
|
|
337
|
+
case "bigint":
|
|
338
|
+
return f.bigint;
|
|
339
|
+
case "symbol":
|
|
340
|
+
return f.symbol;
|
|
341
|
+
case "object":
|
|
342
|
+
return Array.isArray(t) ? f.array : t === null ? f.null : t.then && typeof t.then == "function" && t.catch && typeof t.catch == "function" ? f.promise : typeof Map < "u" && t instanceof Map ? f.map : typeof Set < "u" && t instanceof Set ? f.set : typeof Date < "u" && t instanceof Date ? f.date : f.object;
|
|
343
|
+
default:
|
|
344
|
+
return f.unknown;
|
|
345
|
+
}
|
|
346
|
+
}, d = w.arrayToEnum([
|
|
347
|
+
"invalid_type",
|
|
348
|
+
"invalid_literal",
|
|
349
|
+
"custom",
|
|
350
|
+
"invalid_union",
|
|
351
|
+
"invalid_union_discriminator",
|
|
352
|
+
"invalid_enum_value",
|
|
353
|
+
"unrecognized_keys",
|
|
354
|
+
"invalid_arguments",
|
|
355
|
+
"invalid_return_type",
|
|
356
|
+
"invalid_date",
|
|
357
|
+
"invalid_string",
|
|
358
|
+
"too_small",
|
|
359
|
+
"too_big",
|
|
360
|
+
"invalid_intersection_types",
|
|
361
|
+
"not_multiple_of",
|
|
362
|
+
"not_finite"
|
|
363
|
+
]);
|
|
364
|
+
class M extends Error {
|
|
365
|
+
get errors() {
|
|
366
|
+
return this.issues;
|
|
367
|
+
}
|
|
368
|
+
constructor(e) {
|
|
369
|
+
super(), this.issues = [], this.addIssue = (s) => {
|
|
370
|
+
this.issues = [...this.issues, s];
|
|
371
|
+
}, this.addIssues = (s = []) => {
|
|
372
|
+
this.issues = [...this.issues, ...s];
|
|
373
|
+
};
|
|
374
|
+
const r = new.target.prototype;
|
|
375
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, r) : this.__proto__ = r, this.name = "ZodError", this.issues = e;
|
|
376
|
+
}
|
|
377
|
+
format(e) {
|
|
378
|
+
const r = e || function(a) {
|
|
379
|
+
return a.message;
|
|
380
|
+
}, s = { _errors: [] }, n = (a) => {
|
|
381
|
+
for (const i of a.issues)
|
|
382
|
+
if (i.code === "invalid_union")
|
|
383
|
+
i.unionErrors.map(n);
|
|
384
|
+
else if (i.code === "invalid_return_type")
|
|
385
|
+
n(i.returnTypeError);
|
|
386
|
+
else if (i.code === "invalid_arguments")
|
|
387
|
+
n(i.argumentsError);
|
|
388
|
+
else if (i.path.length === 0)
|
|
389
|
+
s._errors.push(r(i));
|
|
390
|
+
else {
|
|
391
|
+
let o = s, c = 0;
|
|
392
|
+
for (; c < i.path.length; ) {
|
|
393
|
+
const l = i.path[c];
|
|
394
|
+
c === i.path.length - 1 ? (o[l] = o[l] || { _errors: [] }, o[l]._errors.push(r(i))) : o[l] = o[l] || { _errors: [] }, o = o[l], c++;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
return n(this), s;
|
|
399
|
+
}
|
|
400
|
+
static assert(e) {
|
|
401
|
+
if (!(e instanceof M))
|
|
402
|
+
throw new Error(`Not a ZodError: ${e}`);
|
|
403
|
+
}
|
|
404
|
+
toString() {
|
|
405
|
+
return this.message;
|
|
406
|
+
}
|
|
407
|
+
get message() {
|
|
408
|
+
return JSON.stringify(this.issues, w.jsonStringifyReplacer, 2);
|
|
409
|
+
}
|
|
410
|
+
get isEmpty() {
|
|
411
|
+
return this.issues.length === 0;
|
|
412
|
+
}
|
|
413
|
+
flatten(e = (r) => r.message) {
|
|
414
|
+
const r = {}, s = [];
|
|
415
|
+
for (const n of this.issues)
|
|
416
|
+
if (n.path.length > 0) {
|
|
417
|
+
const a = n.path[0];
|
|
418
|
+
r[a] = r[a] || [], r[a].push(e(n));
|
|
419
|
+
} else
|
|
420
|
+
s.push(e(n));
|
|
421
|
+
return { formErrors: s, fieldErrors: r };
|
|
422
|
+
}
|
|
423
|
+
get formErrors() {
|
|
424
|
+
return this.flatten();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
M.create = (t) => new M(t);
|
|
428
|
+
const Ie = (t, e) => {
|
|
429
|
+
let r;
|
|
430
|
+
switch (t.code) {
|
|
431
|
+
case d.invalid_type:
|
|
432
|
+
t.received === f.undefined ? r = "Required" : r = `Expected ${t.expected}, received ${t.received}`;
|
|
433
|
+
break;
|
|
434
|
+
case d.invalid_literal:
|
|
435
|
+
r = `Invalid literal value, expected ${JSON.stringify(t.expected, w.jsonStringifyReplacer)}`;
|
|
436
|
+
break;
|
|
437
|
+
case d.unrecognized_keys:
|
|
438
|
+
r = `Unrecognized key(s) in object: ${w.joinValues(t.keys, ", ")}`;
|
|
439
|
+
break;
|
|
440
|
+
case d.invalid_union:
|
|
441
|
+
r = "Invalid input";
|
|
442
|
+
break;
|
|
443
|
+
case d.invalid_union_discriminator:
|
|
444
|
+
r = `Invalid discriminator value. Expected ${w.joinValues(t.options)}`;
|
|
445
|
+
break;
|
|
446
|
+
case d.invalid_enum_value:
|
|
447
|
+
r = `Invalid enum value. Expected ${w.joinValues(t.options)}, received '${t.received}'`;
|
|
448
|
+
break;
|
|
449
|
+
case d.invalid_arguments:
|
|
450
|
+
r = "Invalid function arguments";
|
|
451
|
+
break;
|
|
452
|
+
case d.invalid_return_type:
|
|
453
|
+
r = "Invalid function return type";
|
|
454
|
+
break;
|
|
455
|
+
case d.invalid_date:
|
|
456
|
+
r = "Invalid date";
|
|
457
|
+
break;
|
|
458
|
+
case d.invalid_string:
|
|
459
|
+
typeof t.validation == "object" ? "includes" in t.validation ? (r = `Invalid input: must include "${t.validation.includes}"`, typeof t.validation.position == "number" && (r = `${r} at one or more positions greater than or equal to ${t.validation.position}`)) : "startsWith" in t.validation ? r = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? r = `Invalid input: must end with "${t.validation.endsWith}"` : w.assertNever(t.validation) : t.validation !== "regex" ? r = `Invalid ${t.validation}` : r = "Invalid";
|
|
460
|
+
break;
|
|
461
|
+
case d.too_small:
|
|
462
|
+
t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` : t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` : t.type === "number" ? r = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "bigint" ? r = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(t.minimum))}` : r = "Invalid input";
|
|
463
|
+
break;
|
|
464
|
+
case d.too_big:
|
|
465
|
+
t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` : t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` : t.type === "number" ? r = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "bigint" ? r = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(t.maximum))}` : r = "Invalid input";
|
|
466
|
+
break;
|
|
467
|
+
case d.custom:
|
|
468
|
+
r = "Invalid input";
|
|
469
|
+
break;
|
|
470
|
+
case d.invalid_intersection_types:
|
|
471
|
+
r = "Intersection results could not be merged";
|
|
472
|
+
break;
|
|
473
|
+
case d.not_multiple_of:
|
|
474
|
+
r = `Number must be a multiple of ${t.multipleOf}`;
|
|
475
|
+
break;
|
|
476
|
+
case d.not_finite:
|
|
477
|
+
r = "Number must be finite";
|
|
478
|
+
break;
|
|
479
|
+
default:
|
|
480
|
+
r = e.defaultError, w.assertNever(t);
|
|
481
|
+
}
|
|
482
|
+
return { message: r };
|
|
483
|
+
};
|
|
484
|
+
let pr = Ie;
|
|
485
|
+
function hr() {
|
|
486
|
+
return pr;
|
|
487
|
+
}
|
|
488
|
+
const mr = (t) => {
|
|
489
|
+
const { data: e, path: r, errorMaps: s, issueData: n } = t, a = [...r, ...n.path || []], i = {
|
|
490
|
+
...n,
|
|
491
|
+
path: a
|
|
492
|
+
};
|
|
493
|
+
if (n.message !== void 0)
|
|
494
|
+
return {
|
|
495
|
+
...n,
|
|
496
|
+
path: a,
|
|
497
|
+
message: n.message
|
|
498
|
+
};
|
|
499
|
+
let o = "";
|
|
500
|
+
const c = s.filter((l) => !!l).slice().reverse();
|
|
501
|
+
for (const l of c)
|
|
502
|
+
o = l(i, { data: e, defaultError: o }).message;
|
|
503
|
+
return {
|
|
504
|
+
...n,
|
|
505
|
+
path: a,
|
|
506
|
+
message: o
|
|
507
|
+
};
|
|
508
|
+
};
|
|
509
|
+
function u(t, e) {
|
|
510
|
+
const r = hr(), s = mr({
|
|
511
|
+
issueData: e,
|
|
512
|
+
data: t.data,
|
|
513
|
+
path: t.path,
|
|
514
|
+
errorMaps: [
|
|
515
|
+
t.common.contextualErrorMap,
|
|
516
|
+
// contextual error map is first priority
|
|
517
|
+
t.schemaErrorMap,
|
|
518
|
+
// then schema-bound map if available
|
|
519
|
+
r,
|
|
520
|
+
// then global override map
|
|
521
|
+
r === Ie ? void 0 : Ie
|
|
522
|
+
// then global default map
|
|
523
|
+
].filter((n) => !!n)
|
|
524
|
+
});
|
|
525
|
+
t.common.issues.push(s);
|
|
526
|
+
}
|
|
527
|
+
class C {
|
|
528
|
+
constructor() {
|
|
529
|
+
this.value = "valid";
|
|
530
|
+
}
|
|
531
|
+
dirty() {
|
|
532
|
+
this.value === "valid" && (this.value = "dirty");
|
|
533
|
+
}
|
|
534
|
+
abort() {
|
|
535
|
+
this.value !== "aborted" && (this.value = "aborted");
|
|
536
|
+
}
|
|
537
|
+
static mergeArray(e, r) {
|
|
538
|
+
const s = [];
|
|
539
|
+
for (const n of r) {
|
|
540
|
+
if (n.status === "aborted")
|
|
541
|
+
return y;
|
|
542
|
+
n.status === "dirty" && e.dirty(), s.push(n.value);
|
|
543
|
+
}
|
|
544
|
+
return { status: e.value, value: s };
|
|
545
|
+
}
|
|
546
|
+
static async mergeObjectAsync(e, r) {
|
|
547
|
+
const s = [];
|
|
548
|
+
for (const n of r) {
|
|
549
|
+
const a = await n.key, i = await n.value;
|
|
550
|
+
s.push({
|
|
551
|
+
key: a,
|
|
552
|
+
value: i
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
return C.mergeObjectSync(e, s);
|
|
556
|
+
}
|
|
557
|
+
static mergeObjectSync(e, r) {
|
|
558
|
+
const s = {};
|
|
559
|
+
for (const n of r) {
|
|
560
|
+
const { key: a, value: i } = n;
|
|
561
|
+
if (a.status === "aborted" || i.status === "aborted")
|
|
562
|
+
return y;
|
|
563
|
+
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || n.alwaysSet) && (s[a.value] = i.value);
|
|
564
|
+
}
|
|
565
|
+
return { status: e.value, value: s };
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
const y = Object.freeze({
|
|
569
|
+
status: "aborted"
|
|
570
|
+
}), ue = (t) => ({ status: "dirty", value: t }), A = (t) => ({ status: "valid", value: t }), Ke = (t) => t.status === "aborted", Qe = (t) => t.status === "dirty", ne = (t) => t.status === "valid", be = (t) => typeof Promise < "u" && t instanceof Promise;
|
|
571
|
+
var h;
|
|
572
|
+
(function(t) {
|
|
573
|
+
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
574
|
+
})(h || (h = {}));
|
|
575
|
+
class B {
|
|
576
|
+
constructor(e, r, s, n) {
|
|
577
|
+
this._cachedPath = [], this.parent = e, this.data = r, this._path = s, this._key = n;
|
|
578
|
+
}
|
|
579
|
+
get path() {
|
|
580
|
+
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
const et = (t, e) => {
|
|
584
|
+
if (ne(e))
|
|
585
|
+
return { success: !0, data: e.value };
|
|
586
|
+
if (!t.common.issues.length)
|
|
587
|
+
throw new Error("Validation failed but no issues detected.");
|
|
588
|
+
return {
|
|
589
|
+
success: !1,
|
|
590
|
+
get error() {
|
|
591
|
+
if (this._error)
|
|
592
|
+
return this._error;
|
|
593
|
+
const r = new M(t.common.issues);
|
|
594
|
+
return this._error = r, this._error;
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
};
|
|
598
|
+
function v(t) {
|
|
599
|
+
if (!t)
|
|
600
|
+
return {};
|
|
601
|
+
const { errorMap: e, invalid_type_error: r, required_error: s, description: n } = t;
|
|
602
|
+
if (e && (r || s))
|
|
603
|
+
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
604
|
+
return e ? { errorMap: e, description: n } : { errorMap: (i, o) => {
|
|
605
|
+
const { message: c } = t;
|
|
606
|
+
return i.code === "invalid_enum_value" ? { message: c ?? o.defaultError } : typeof o.data > "u" ? { message: c ?? s ?? o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: c ?? r ?? o.defaultError };
|
|
607
|
+
}, description: n };
|
|
608
|
+
}
|
|
609
|
+
class k {
|
|
610
|
+
get description() {
|
|
611
|
+
return this._def.description;
|
|
612
|
+
}
|
|
613
|
+
_getType(e) {
|
|
614
|
+
return V(e.data);
|
|
615
|
+
}
|
|
616
|
+
_getOrReturnCtx(e, r) {
|
|
617
|
+
return r || {
|
|
618
|
+
common: e.parent.common,
|
|
619
|
+
data: e.data,
|
|
620
|
+
parsedType: V(e.data),
|
|
621
|
+
schemaErrorMap: this._def.errorMap,
|
|
622
|
+
path: e.path,
|
|
623
|
+
parent: e.parent
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
_processInputParams(e) {
|
|
627
|
+
return {
|
|
628
|
+
status: new C(),
|
|
629
|
+
ctx: {
|
|
630
|
+
common: e.parent.common,
|
|
631
|
+
data: e.data,
|
|
632
|
+
parsedType: V(e.data),
|
|
633
|
+
schemaErrorMap: this._def.errorMap,
|
|
634
|
+
path: e.path,
|
|
635
|
+
parent: e.parent
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
_parseSync(e) {
|
|
640
|
+
const r = this._parse(e);
|
|
641
|
+
if (be(r))
|
|
642
|
+
throw new Error("Synchronous parse encountered promise.");
|
|
643
|
+
return r;
|
|
644
|
+
}
|
|
645
|
+
_parseAsync(e) {
|
|
646
|
+
const r = this._parse(e);
|
|
647
|
+
return Promise.resolve(r);
|
|
648
|
+
}
|
|
649
|
+
parse(e, r) {
|
|
650
|
+
const s = this.safeParse(e, r);
|
|
651
|
+
if (s.success)
|
|
652
|
+
return s.data;
|
|
653
|
+
throw s.error;
|
|
654
|
+
}
|
|
655
|
+
safeParse(e, r) {
|
|
656
|
+
const s = {
|
|
657
|
+
common: {
|
|
658
|
+
issues: [],
|
|
659
|
+
async: r?.async ?? !1,
|
|
660
|
+
contextualErrorMap: r?.errorMap
|
|
661
|
+
},
|
|
662
|
+
path: r?.path || [],
|
|
663
|
+
schemaErrorMap: this._def.errorMap,
|
|
664
|
+
parent: null,
|
|
665
|
+
data: e,
|
|
666
|
+
parsedType: V(e)
|
|
667
|
+
}, n = this._parseSync({ data: e, path: s.path, parent: s });
|
|
668
|
+
return et(s, n);
|
|
669
|
+
}
|
|
670
|
+
"~validate"(e) {
|
|
671
|
+
const r = {
|
|
672
|
+
common: {
|
|
673
|
+
issues: [],
|
|
674
|
+
async: !!this["~standard"].async
|
|
675
|
+
},
|
|
676
|
+
path: [],
|
|
677
|
+
schemaErrorMap: this._def.errorMap,
|
|
678
|
+
parent: null,
|
|
679
|
+
data: e,
|
|
680
|
+
parsedType: V(e)
|
|
681
|
+
};
|
|
682
|
+
if (!this["~standard"].async)
|
|
683
|
+
try {
|
|
684
|
+
const s = this._parseSync({ data: e, path: [], parent: r });
|
|
685
|
+
return ne(s) ? {
|
|
686
|
+
value: s.value
|
|
687
|
+
} : {
|
|
688
|
+
issues: r.common.issues
|
|
689
|
+
};
|
|
690
|
+
} catch (s) {
|
|
691
|
+
s?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0), r.common = {
|
|
692
|
+
issues: [],
|
|
693
|
+
async: !0
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
return this._parseAsync({ data: e, path: [], parent: r }).then((s) => ne(s) ? {
|
|
697
|
+
value: s.value
|
|
698
|
+
} : {
|
|
699
|
+
issues: r.common.issues
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
async parseAsync(e, r) {
|
|
703
|
+
const s = await this.safeParseAsync(e, r);
|
|
704
|
+
if (s.success)
|
|
705
|
+
return s.data;
|
|
706
|
+
throw s.error;
|
|
707
|
+
}
|
|
708
|
+
async safeParseAsync(e, r) {
|
|
709
|
+
const s = {
|
|
710
|
+
common: {
|
|
711
|
+
issues: [],
|
|
712
|
+
contextualErrorMap: r?.errorMap,
|
|
713
|
+
async: !0
|
|
714
|
+
},
|
|
715
|
+
path: r?.path || [],
|
|
716
|
+
schemaErrorMap: this._def.errorMap,
|
|
717
|
+
parent: null,
|
|
718
|
+
data: e,
|
|
719
|
+
parsedType: V(e)
|
|
720
|
+
}, n = this._parse({ data: e, path: s.path, parent: s }), a = await (be(n) ? n : Promise.resolve(n));
|
|
721
|
+
return et(s, a);
|
|
722
|
+
}
|
|
723
|
+
refine(e, r) {
|
|
724
|
+
const s = (n) => typeof r == "string" || typeof r > "u" ? { message: r } : typeof r == "function" ? r(n) : r;
|
|
725
|
+
return this._refinement((n, a) => {
|
|
726
|
+
const i = e(n), o = () => a.addIssue({
|
|
727
|
+
code: d.custom,
|
|
728
|
+
...s(n)
|
|
729
|
+
});
|
|
730
|
+
return typeof Promise < "u" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
refinement(e, r) {
|
|
734
|
+
return this._refinement((s, n) => e(s) ? !0 : (n.addIssue(typeof r == "function" ? r(s, n) : r), !1));
|
|
735
|
+
}
|
|
736
|
+
_refinement(e) {
|
|
737
|
+
return new ie({
|
|
738
|
+
schema: this,
|
|
739
|
+
typeName: g.ZodEffects,
|
|
740
|
+
effect: { type: "refinement", refinement: e }
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
superRefine(e) {
|
|
744
|
+
return this._refinement(e);
|
|
745
|
+
}
|
|
746
|
+
constructor(e) {
|
|
747
|
+
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
|
|
748
|
+
version: 1,
|
|
749
|
+
vendor: "zod",
|
|
750
|
+
validate: (r) => this["~validate"](r)
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
optional() {
|
|
754
|
+
return U.create(this, this._def);
|
|
755
|
+
}
|
|
756
|
+
nullable() {
|
|
757
|
+
return oe.create(this, this._def);
|
|
758
|
+
}
|
|
759
|
+
nullish() {
|
|
760
|
+
return this.nullable().optional();
|
|
761
|
+
}
|
|
762
|
+
array() {
|
|
763
|
+
return $.create(this);
|
|
764
|
+
}
|
|
765
|
+
promise() {
|
|
766
|
+
return Ee.create(this, this._def);
|
|
767
|
+
}
|
|
768
|
+
or(e) {
|
|
769
|
+
return Se.create([this, e], this._def);
|
|
770
|
+
}
|
|
771
|
+
and(e) {
|
|
772
|
+
return Oe.create(this, e, this._def);
|
|
773
|
+
}
|
|
774
|
+
transform(e) {
|
|
775
|
+
return new ie({
|
|
776
|
+
...v(this._def),
|
|
777
|
+
schema: this,
|
|
778
|
+
typeName: g.ZodEffects,
|
|
779
|
+
effect: { type: "transform", transform: e }
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
default(e) {
|
|
783
|
+
const r = typeof e == "function" ? e : () => e;
|
|
784
|
+
return new $e({
|
|
785
|
+
...v(this._def),
|
|
786
|
+
innerType: this,
|
|
787
|
+
defaultValue: r,
|
|
788
|
+
typeName: g.ZodDefault
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
brand() {
|
|
792
|
+
return new Lr({
|
|
793
|
+
typeName: g.ZodBranded,
|
|
794
|
+
type: this,
|
|
795
|
+
...v(this._def)
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
catch(e) {
|
|
799
|
+
const r = typeof e == "function" ? e : () => e;
|
|
800
|
+
return new Fe({
|
|
801
|
+
...v(this._def),
|
|
802
|
+
innerType: this,
|
|
803
|
+
catchValue: r,
|
|
804
|
+
typeName: g.ZodCatch
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
describe(e) {
|
|
808
|
+
const r = this.constructor;
|
|
809
|
+
return new r({
|
|
810
|
+
...this._def,
|
|
811
|
+
description: e
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
pipe(e) {
|
|
815
|
+
return Ue.create(this, e);
|
|
816
|
+
}
|
|
817
|
+
readonly() {
|
|
818
|
+
return Ze.create(this);
|
|
819
|
+
}
|
|
820
|
+
isOptional() {
|
|
821
|
+
return this.safeParse(void 0).success;
|
|
822
|
+
}
|
|
823
|
+
isNullable() {
|
|
824
|
+
return this.safeParse(null).success;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
const yr = /^c[^\s-]{8,}$/i, gr = /^[0-9a-z]+$/, vr = /^[0-9A-HJKMNP-TV-Z]{26}$/i, _r = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, kr = /^[a-z0-9_-]{21}$/i, wr = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, br = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, xr = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Sr = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
828
|
+
let Ce;
|
|
829
|
+
const Or = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Er = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, Nr = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, Tr = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Rr = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Cr = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, kt = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", Ar = new RegExp(`^${kt}$`);
|
|
830
|
+
function wt(t) {
|
|
831
|
+
let e = "[0-5]\\d";
|
|
832
|
+
t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
833
|
+
const r = t.precision ? "+" : "?";
|
|
834
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`;
|
|
835
|
+
}
|
|
836
|
+
function Pr(t) {
|
|
837
|
+
return new RegExp(`^${wt(t)}$`);
|
|
838
|
+
}
|
|
839
|
+
function Ir(t) {
|
|
840
|
+
let e = `${kt}T${wt(t)}`;
|
|
841
|
+
const r = [];
|
|
842
|
+
return r.push(t.local ? "Z?" : "Z"), t.offset && r.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${r.join("|")})`, new RegExp(`^${e}$`);
|
|
843
|
+
}
|
|
844
|
+
function jr(t, e) {
|
|
845
|
+
return !!((e === "v4" || !e) && Or.test(t) || (e === "v6" || !e) && Nr.test(t));
|
|
846
|
+
}
|
|
847
|
+
function $r(t, e) {
|
|
848
|
+
if (!wr.test(t))
|
|
849
|
+
return !1;
|
|
850
|
+
try {
|
|
851
|
+
const [r] = t.split(".");
|
|
852
|
+
if (!r)
|
|
853
|
+
return !1;
|
|
854
|
+
const s = r.replace(/-/g, "+").replace(/_/g, "/").padEnd(r.length + (4 - r.length % 4) % 4, "="), n = JSON.parse(atob(s));
|
|
855
|
+
return !(typeof n != "object" || n === null || "typ" in n && n?.typ !== "JWT" || !n.alg || e && n.alg !== e);
|
|
856
|
+
} catch {
|
|
857
|
+
return !1;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
function Fr(t, e) {
|
|
861
|
+
return !!((e === "v4" || !e) && Er.test(t) || (e === "v6" || !e) && Tr.test(t));
|
|
862
|
+
}
|
|
863
|
+
class z extends k {
|
|
864
|
+
_parse(e) {
|
|
865
|
+
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
|
|
866
|
+
const a = this._getOrReturnCtx(e);
|
|
867
|
+
return u(a, {
|
|
868
|
+
code: d.invalid_type,
|
|
869
|
+
expected: f.string,
|
|
870
|
+
received: a.parsedType
|
|
871
|
+
}), y;
|
|
872
|
+
}
|
|
873
|
+
const s = new C();
|
|
874
|
+
let n;
|
|
875
|
+
for (const a of this._def.checks)
|
|
876
|
+
if (a.kind === "min")
|
|
877
|
+
e.data.length < a.value && (n = this._getOrReturnCtx(e, n), u(n, {
|
|
878
|
+
code: d.too_small,
|
|
879
|
+
minimum: a.value,
|
|
880
|
+
type: "string",
|
|
881
|
+
inclusive: !0,
|
|
882
|
+
exact: !1,
|
|
883
|
+
message: a.message
|
|
884
|
+
}), s.dirty());
|
|
885
|
+
else if (a.kind === "max")
|
|
886
|
+
e.data.length > a.value && (n = this._getOrReturnCtx(e, n), u(n, {
|
|
887
|
+
code: d.too_big,
|
|
888
|
+
maximum: a.value,
|
|
889
|
+
type: "string",
|
|
890
|
+
inclusive: !0,
|
|
891
|
+
exact: !1,
|
|
892
|
+
message: a.message
|
|
893
|
+
}), s.dirty());
|
|
894
|
+
else if (a.kind === "length") {
|
|
895
|
+
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
896
|
+
(i || o) && (n = this._getOrReturnCtx(e, n), i ? u(n, {
|
|
897
|
+
code: d.too_big,
|
|
898
|
+
maximum: a.value,
|
|
899
|
+
type: "string",
|
|
900
|
+
inclusive: !0,
|
|
901
|
+
exact: !0,
|
|
902
|
+
message: a.message
|
|
903
|
+
}) : o && u(n, {
|
|
904
|
+
code: d.too_small,
|
|
905
|
+
minimum: a.value,
|
|
906
|
+
type: "string",
|
|
907
|
+
inclusive: !0,
|
|
908
|
+
exact: !0,
|
|
909
|
+
message: a.message
|
|
910
|
+
}), s.dirty());
|
|
911
|
+
} else if (a.kind === "email")
|
|
912
|
+
xr.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
913
|
+
validation: "email",
|
|
914
|
+
code: d.invalid_string,
|
|
915
|
+
message: a.message
|
|
916
|
+
}), s.dirty());
|
|
917
|
+
else if (a.kind === "emoji")
|
|
918
|
+
Ce || (Ce = new RegExp(Sr, "u")), Ce.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
919
|
+
validation: "emoji",
|
|
920
|
+
code: d.invalid_string,
|
|
921
|
+
message: a.message
|
|
922
|
+
}), s.dirty());
|
|
923
|
+
else if (a.kind === "uuid")
|
|
924
|
+
_r.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
925
|
+
validation: "uuid",
|
|
926
|
+
code: d.invalid_string,
|
|
927
|
+
message: a.message
|
|
928
|
+
}), s.dirty());
|
|
929
|
+
else if (a.kind === "nanoid")
|
|
930
|
+
kr.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
931
|
+
validation: "nanoid",
|
|
932
|
+
code: d.invalid_string,
|
|
933
|
+
message: a.message
|
|
934
|
+
}), s.dirty());
|
|
935
|
+
else if (a.kind === "cuid")
|
|
936
|
+
yr.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
937
|
+
validation: "cuid",
|
|
938
|
+
code: d.invalid_string,
|
|
939
|
+
message: a.message
|
|
940
|
+
}), s.dirty());
|
|
941
|
+
else if (a.kind === "cuid2")
|
|
942
|
+
gr.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
943
|
+
validation: "cuid2",
|
|
944
|
+
code: d.invalid_string,
|
|
945
|
+
message: a.message
|
|
946
|
+
}), s.dirty());
|
|
947
|
+
else if (a.kind === "ulid")
|
|
948
|
+
vr.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
949
|
+
validation: "ulid",
|
|
950
|
+
code: d.invalid_string,
|
|
951
|
+
message: a.message
|
|
952
|
+
}), s.dirty());
|
|
953
|
+
else if (a.kind === "url")
|
|
954
|
+
try {
|
|
955
|
+
new URL(e.data);
|
|
956
|
+
} catch {
|
|
957
|
+
n = this._getOrReturnCtx(e, n), u(n, {
|
|
958
|
+
validation: "url",
|
|
959
|
+
code: d.invalid_string,
|
|
960
|
+
message: a.message
|
|
961
|
+
}), s.dirty();
|
|
962
|
+
}
|
|
963
|
+
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
964
|
+
validation: "regex",
|
|
965
|
+
code: d.invalid_string,
|
|
966
|
+
message: a.message
|
|
967
|
+
}), s.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
968
|
+
code: d.invalid_string,
|
|
969
|
+
validation: { includes: a.value, position: a.position },
|
|
970
|
+
message: a.message
|
|
971
|
+
}), s.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
972
|
+
code: d.invalid_string,
|
|
973
|
+
validation: { startsWith: a.value },
|
|
974
|
+
message: a.message
|
|
975
|
+
}), s.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
976
|
+
code: d.invalid_string,
|
|
977
|
+
validation: { endsWith: a.value },
|
|
978
|
+
message: a.message
|
|
979
|
+
}), s.dirty()) : a.kind === "datetime" ? Ir(a).test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
980
|
+
code: d.invalid_string,
|
|
981
|
+
validation: "datetime",
|
|
982
|
+
message: a.message
|
|
983
|
+
}), s.dirty()) : a.kind === "date" ? Ar.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
984
|
+
code: d.invalid_string,
|
|
985
|
+
validation: "date",
|
|
986
|
+
message: a.message
|
|
987
|
+
}), s.dirty()) : a.kind === "time" ? Pr(a).test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
988
|
+
code: d.invalid_string,
|
|
989
|
+
validation: "time",
|
|
990
|
+
message: a.message
|
|
991
|
+
}), s.dirty()) : a.kind === "duration" ? br.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
992
|
+
validation: "duration",
|
|
993
|
+
code: d.invalid_string,
|
|
994
|
+
message: a.message
|
|
995
|
+
}), s.dirty()) : a.kind === "ip" ? jr(e.data, a.version) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
996
|
+
validation: "ip",
|
|
997
|
+
code: d.invalid_string,
|
|
998
|
+
message: a.message
|
|
999
|
+
}), s.dirty()) : a.kind === "jwt" ? $r(e.data, a.alg) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
1000
|
+
validation: "jwt",
|
|
1001
|
+
code: d.invalid_string,
|
|
1002
|
+
message: a.message
|
|
1003
|
+
}), s.dirty()) : a.kind === "cidr" ? Fr(e.data, a.version) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
1004
|
+
validation: "cidr",
|
|
1005
|
+
code: d.invalid_string,
|
|
1006
|
+
message: a.message
|
|
1007
|
+
}), s.dirty()) : a.kind === "base64" ? Rr.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
1008
|
+
validation: "base64",
|
|
1009
|
+
code: d.invalid_string,
|
|
1010
|
+
message: a.message
|
|
1011
|
+
}), s.dirty()) : a.kind === "base64url" ? Cr.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
|
|
1012
|
+
validation: "base64url",
|
|
1013
|
+
code: d.invalid_string,
|
|
1014
|
+
message: a.message
|
|
1015
|
+
}), s.dirty()) : w.assertNever(a);
|
|
1016
|
+
return { status: s.value, value: e.data };
|
|
1017
|
+
}
|
|
1018
|
+
_regex(e, r, s) {
|
|
1019
|
+
return this.refinement((n) => e.test(n), {
|
|
1020
|
+
validation: r,
|
|
1021
|
+
code: d.invalid_string,
|
|
1022
|
+
...h.errToObj(s)
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
_addCheck(e) {
|
|
1026
|
+
return new z({
|
|
1027
|
+
...this._def,
|
|
1028
|
+
checks: [...this._def.checks, e]
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
email(e) {
|
|
1032
|
+
return this._addCheck({ kind: "email", ...h.errToObj(e) });
|
|
1033
|
+
}
|
|
1034
|
+
url(e) {
|
|
1035
|
+
return this._addCheck({ kind: "url", ...h.errToObj(e) });
|
|
1036
|
+
}
|
|
1037
|
+
emoji(e) {
|
|
1038
|
+
return this._addCheck({ kind: "emoji", ...h.errToObj(e) });
|
|
1039
|
+
}
|
|
1040
|
+
uuid(e) {
|
|
1041
|
+
return this._addCheck({ kind: "uuid", ...h.errToObj(e) });
|
|
1042
|
+
}
|
|
1043
|
+
nanoid(e) {
|
|
1044
|
+
return this._addCheck({ kind: "nanoid", ...h.errToObj(e) });
|
|
1045
|
+
}
|
|
1046
|
+
cuid(e) {
|
|
1047
|
+
return this._addCheck({ kind: "cuid", ...h.errToObj(e) });
|
|
1048
|
+
}
|
|
1049
|
+
cuid2(e) {
|
|
1050
|
+
return this._addCheck({ kind: "cuid2", ...h.errToObj(e) });
|
|
1051
|
+
}
|
|
1052
|
+
ulid(e) {
|
|
1053
|
+
return this._addCheck({ kind: "ulid", ...h.errToObj(e) });
|
|
1054
|
+
}
|
|
1055
|
+
base64(e) {
|
|
1056
|
+
return this._addCheck({ kind: "base64", ...h.errToObj(e) });
|
|
1057
|
+
}
|
|
1058
|
+
base64url(e) {
|
|
1059
|
+
return this._addCheck({
|
|
1060
|
+
kind: "base64url",
|
|
1061
|
+
...h.errToObj(e)
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
jwt(e) {
|
|
1065
|
+
return this._addCheck({ kind: "jwt", ...h.errToObj(e) });
|
|
1066
|
+
}
|
|
1067
|
+
ip(e) {
|
|
1068
|
+
return this._addCheck({ kind: "ip", ...h.errToObj(e) });
|
|
1069
|
+
}
|
|
1070
|
+
cidr(e) {
|
|
1071
|
+
return this._addCheck({ kind: "cidr", ...h.errToObj(e) });
|
|
1072
|
+
}
|
|
1073
|
+
datetime(e) {
|
|
1074
|
+
return typeof e == "string" ? this._addCheck({
|
|
1075
|
+
kind: "datetime",
|
|
1076
|
+
precision: null,
|
|
1077
|
+
offset: !1,
|
|
1078
|
+
local: !1,
|
|
1079
|
+
message: e
|
|
1080
|
+
}) : this._addCheck({
|
|
1081
|
+
kind: "datetime",
|
|
1082
|
+
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
1083
|
+
offset: e?.offset ?? !1,
|
|
1084
|
+
local: e?.local ?? !1,
|
|
1085
|
+
...h.errToObj(e?.message)
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
date(e) {
|
|
1089
|
+
return this._addCheck({ kind: "date", message: e });
|
|
1090
|
+
}
|
|
1091
|
+
time(e) {
|
|
1092
|
+
return typeof e == "string" ? this._addCheck({
|
|
1093
|
+
kind: "time",
|
|
1094
|
+
precision: null,
|
|
1095
|
+
message: e
|
|
1096
|
+
}) : this._addCheck({
|
|
1097
|
+
kind: "time",
|
|
1098
|
+
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
1099
|
+
...h.errToObj(e?.message)
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
duration(e) {
|
|
1103
|
+
return this._addCheck({ kind: "duration", ...h.errToObj(e) });
|
|
1104
|
+
}
|
|
1105
|
+
regex(e, r) {
|
|
1106
|
+
return this._addCheck({
|
|
1107
|
+
kind: "regex",
|
|
1108
|
+
regex: e,
|
|
1109
|
+
...h.errToObj(r)
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
includes(e, r) {
|
|
1113
|
+
return this._addCheck({
|
|
1114
|
+
kind: "includes",
|
|
1115
|
+
value: e,
|
|
1116
|
+
position: r?.position,
|
|
1117
|
+
...h.errToObj(r?.message)
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
startsWith(e, r) {
|
|
1121
|
+
return this._addCheck({
|
|
1122
|
+
kind: "startsWith",
|
|
1123
|
+
value: e,
|
|
1124
|
+
...h.errToObj(r)
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
endsWith(e, r) {
|
|
1128
|
+
return this._addCheck({
|
|
1129
|
+
kind: "endsWith",
|
|
1130
|
+
value: e,
|
|
1131
|
+
...h.errToObj(r)
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
min(e, r) {
|
|
1135
|
+
return this._addCheck({
|
|
1136
|
+
kind: "min",
|
|
1137
|
+
value: e,
|
|
1138
|
+
...h.errToObj(r)
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
max(e, r) {
|
|
1142
|
+
return this._addCheck({
|
|
1143
|
+
kind: "max",
|
|
1144
|
+
value: e,
|
|
1145
|
+
...h.errToObj(r)
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
length(e, r) {
|
|
1149
|
+
return this._addCheck({
|
|
1150
|
+
kind: "length",
|
|
1151
|
+
value: e,
|
|
1152
|
+
...h.errToObj(r)
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Equivalent to `.min(1)`
|
|
1157
|
+
*/
|
|
1158
|
+
nonempty(e) {
|
|
1159
|
+
return this.min(1, h.errToObj(e));
|
|
1160
|
+
}
|
|
1161
|
+
trim() {
|
|
1162
|
+
return new z({
|
|
1163
|
+
...this._def,
|
|
1164
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
toLowerCase() {
|
|
1168
|
+
return new z({
|
|
1169
|
+
...this._def,
|
|
1170
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
toUpperCase() {
|
|
1174
|
+
return new z({
|
|
1175
|
+
...this._def,
|
|
1176
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
get isDatetime() {
|
|
1180
|
+
return !!this._def.checks.find((e) => e.kind === "datetime");
|
|
1181
|
+
}
|
|
1182
|
+
get isDate() {
|
|
1183
|
+
return !!this._def.checks.find((e) => e.kind === "date");
|
|
1184
|
+
}
|
|
1185
|
+
get isTime() {
|
|
1186
|
+
return !!this._def.checks.find((e) => e.kind === "time");
|
|
1187
|
+
}
|
|
1188
|
+
get isDuration() {
|
|
1189
|
+
return !!this._def.checks.find((e) => e.kind === "duration");
|
|
1190
|
+
}
|
|
1191
|
+
get isEmail() {
|
|
1192
|
+
return !!this._def.checks.find((e) => e.kind === "email");
|
|
1193
|
+
}
|
|
1194
|
+
get isURL() {
|
|
1195
|
+
return !!this._def.checks.find((e) => e.kind === "url");
|
|
1196
|
+
}
|
|
1197
|
+
get isEmoji() {
|
|
1198
|
+
return !!this._def.checks.find((e) => e.kind === "emoji");
|
|
1199
|
+
}
|
|
1200
|
+
get isUUID() {
|
|
1201
|
+
return !!this._def.checks.find((e) => e.kind === "uuid");
|
|
1202
|
+
}
|
|
1203
|
+
get isNANOID() {
|
|
1204
|
+
return !!this._def.checks.find((e) => e.kind === "nanoid");
|
|
1205
|
+
}
|
|
1206
|
+
get isCUID() {
|
|
1207
|
+
return !!this._def.checks.find((e) => e.kind === "cuid");
|
|
1208
|
+
}
|
|
1209
|
+
get isCUID2() {
|
|
1210
|
+
return !!this._def.checks.find((e) => e.kind === "cuid2");
|
|
1211
|
+
}
|
|
1212
|
+
get isULID() {
|
|
1213
|
+
return !!this._def.checks.find((e) => e.kind === "ulid");
|
|
1214
|
+
}
|
|
1215
|
+
get isIP() {
|
|
1216
|
+
return !!this._def.checks.find((e) => e.kind === "ip");
|
|
1217
|
+
}
|
|
1218
|
+
get isCIDR() {
|
|
1219
|
+
return !!this._def.checks.find((e) => e.kind === "cidr");
|
|
1220
|
+
}
|
|
1221
|
+
get isBase64() {
|
|
1222
|
+
return !!this._def.checks.find((e) => e.kind === "base64");
|
|
1223
|
+
}
|
|
1224
|
+
get isBase64url() {
|
|
1225
|
+
return !!this._def.checks.find((e) => e.kind === "base64url");
|
|
1226
|
+
}
|
|
1227
|
+
get minLength() {
|
|
1228
|
+
let e = null;
|
|
1229
|
+
for (const r of this._def.checks)
|
|
1230
|
+
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
1231
|
+
return e;
|
|
1232
|
+
}
|
|
1233
|
+
get maxLength() {
|
|
1234
|
+
let e = null;
|
|
1235
|
+
for (const r of this._def.checks)
|
|
1236
|
+
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1237
|
+
return e;
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
z.create = (t) => new z({
|
|
1241
|
+
checks: [],
|
|
1242
|
+
typeName: g.ZodString,
|
|
1243
|
+
coerce: t?.coerce ?? !1,
|
|
1244
|
+
...v(t)
|
|
1245
|
+
});
|
|
1246
|
+
function Zr(t, e) {
|
|
1247
|
+
const r = (t.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, n = r > s ? r : s, a = Number.parseInt(t.toFixed(n).replace(".", "")), i = Number.parseInt(e.toFixed(n).replace(".", ""));
|
|
1248
|
+
return a % i / 10 ** n;
|
|
1249
|
+
}
|
|
1250
|
+
class pe extends k {
|
|
1251
|
+
constructor() {
|
|
1252
|
+
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1253
|
+
}
|
|
1254
|
+
_parse(e) {
|
|
1255
|
+
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== f.number) {
|
|
1256
|
+
const a = this._getOrReturnCtx(e);
|
|
1257
|
+
return u(a, {
|
|
1258
|
+
code: d.invalid_type,
|
|
1259
|
+
expected: f.number,
|
|
1260
|
+
received: a.parsedType
|
|
1261
|
+
}), y;
|
|
1262
|
+
}
|
|
1263
|
+
let s;
|
|
1264
|
+
const n = new C();
|
|
1265
|
+
for (const a of this._def.checks)
|
|
1266
|
+
a.kind === "int" ? w.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1267
|
+
code: d.invalid_type,
|
|
1268
|
+
expected: "integer",
|
|
1269
|
+
received: "float",
|
|
1270
|
+
message: a.message
|
|
1271
|
+
}), n.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1272
|
+
code: d.too_small,
|
|
1273
|
+
minimum: a.value,
|
|
1274
|
+
type: "number",
|
|
1275
|
+
inclusive: a.inclusive,
|
|
1276
|
+
exact: !1,
|
|
1277
|
+
message: a.message
|
|
1278
|
+
}), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1279
|
+
code: d.too_big,
|
|
1280
|
+
maximum: a.value,
|
|
1281
|
+
type: "number",
|
|
1282
|
+
inclusive: a.inclusive,
|
|
1283
|
+
exact: !1,
|
|
1284
|
+
message: a.message
|
|
1285
|
+
}), n.dirty()) : a.kind === "multipleOf" ? Zr(e.data, a.value) !== 0 && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1286
|
+
code: d.not_multiple_of,
|
|
1287
|
+
multipleOf: a.value,
|
|
1288
|
+
message: a.message
|
|
1289
|
+
}), n.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1290
|
+
code: d.not_finite,
|
|
1291
|
+
message: a.message
|
|
1292
|
+
}), n.dirty()) : w.assertNever(a);
|
|
1293
|
+
return { status: n.value, value: e.data };
|
|
1294
|
+
}
|
|
1295
|
+
gte(e, r) {
|
|
1296
|
+
return this.setLimit("min", e, !0, h.toString(r));
|
|
1297
|
+
}
|
|
1298
|
+
gt(e, r) {
|
|
1299
|
+
return this.setLimit("min", e, !1, h.toString(r));
|
|
1300
|
+
}
|
|
1301
|
+
lte(e, r) {
|
|
1302
|
+
return this.setLimit("max", e, !0, h.toString(r));
|
|
1303
|
+
}
|
|
1304
|
+
lt(e, r) {
|
|
1305
|
+
return this.setLimit("max", e, !1, h.toString(r));
|
|
1306
|
+
}
|
|
1307
|
+
setLimit(e, r, s, n) {
|
|
1308
|
+
return new pe({
|
|
1309
|
+
...this._def,
|
|
1310
|
+
checks: [
|
|
1311
|
+
...this._def.checks,
|
|
1312
|
+
{
|
|
1313
|
+
kind: e,
|
|
1314
|
+
value: r,
|
|
1315
|
+
inclusive: s,
|
|
1316
|
+
message: h.toString(n)
|
|
1317
|
+
}
|
|
1318
|
+
]
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
_addCheck(e) {
|
|
1322
|
+
return new pe({
|
|
1323
|
+
...this._def,
|
|
1324
|
+
checks: [...this._def.checks, e]
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
int(e) {
|
|
1328
|
+
return this._addCheck({
|
|
1329
|
+
kind: "int",
|
|
1330
|
+
message: h.toString(e)
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
positive(e) {
|
|
1334
|
+
return this._addCheck({
|
|
1335
|
+
kind: "min",
|
|
1336
|
+
value: 0,
|
|
1337
|
+
inclusive: !1,
|
|
1338
|
+
message: h.toString(e)
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
negative(e) {
|
|
1342
|
+
return this._addCheck({
|
|
1343
|
+
kind: "max",
|
|
1344
|
+
value: 0,
|
|
1345
|
+
inclusive: !1,
|
|
1346
|
+
message: h.toString(e)
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
nonpositive(e) {
|
|
1350
|
+
return this._addCheck({
|
|
1351
|
+
kind: "max",
|
|
1352
|
+
value: 0,
|
|
1353
|
+
inclusive: !0,
|
|
1354
|
+
message: h.toString(e)
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
nonnegative(e) {
|
|
1358
|
+
return this._addCheck({
|
|
1359
|
+
kind: "min",
|
|
1360
|
+
value: 0,
|
|
1361
|
+
inclusive: !0,
|
|
1362
|
+
message: h.toString(e)
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
multipleOf(e, r) {
|
|
1366
|
+
return this._addCheck({
|
|
1367
|
+
kind: "multipleOf",
|
|
1368
|
+
value: e,
|
|
1369
|
+
message: h.toString(r)
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
finite(e) {
|
|
1373
|
+
return this._addCheck({
|
|
1374
|
+
kind: "finite",
|
|
1375
|
+
message: h.toString(e)
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
safe(e) {
|
|
1379
|
+
return this._addCheck({
|
|
1380
|
+
kind: "min",
|
|
1381
|
+
inclusive: !0,
|
|
1382
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
1383
|
+
message: h.toString(e)
|
|
1384
|
+
})._addCheck({
|
|
1385
|
+
kind: "max",
|
|
1386
|
+
inclusive: !0,
|
|
1387
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
1388
|
+
message: h.toString(e)
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
get minValue() {
|
|
1392
|
+
let e = null;
|
|
1393
|
+
for (const r of this._def.checks)
|
|
1394
|
+
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
1395
|
+
return e;
|
|
1396
|
+
}
|
|
1397
|
+
get maxValue() {
|
|
1398
|
+
let e = null;
|
|
1399
|
+
for (const r of this._def.checks)
|
|
1400
|
+
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1401
|
+
return e;
|
|
1402
|
+
}
|
|
1403
|
+
get isInt() {
|
|
1404
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && w.isInteger(e.value));
|
|
1405
|
+
}
|
|
1406
|
+
get isFinite() {
|
|
1407
|
+
let e = null, r = null;
|
|
1408
|
+
for (const s of this._def.checks) {
|
|
1409
|
+
if (s.kind === "finite" || s.kind === "int" || s.kind === "multipleOf")
|
|
1410
|
+
return !0;
|
|
1411
|
+
s.kind === "min" ? (r === null || s.value > r) && (r = s.value) : s.kind === "max" && (e === null || s.value < e) && (e = s.value);
|
|
1412
|
+
}
|
|
1413
|
+
return Number.isFinite(r) && Number.isFinite(e);
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
pe.create = (t) => new pe({
|
|
1417
|
+
checks: [],
|
|
1418
|
+
typeName: g.ZodNumber,
|
|
1419
|
+
coerce: t?.coerce || !1,
|
|
1420
|
+
...v(t)
|
|
1421
|
+
});
|
|
1422
|
+
class he extends k {
|
|
1423
|
+
constructor() {
|
|
1424
|
+
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1425
|
+
}
|
|
1426
|
+
_parse(e) {
|
|
1427
|
+
if (this._def.coerce)
|
|
1428
|
+
try {
|
|
1429
|
+
e.data = BigInt(e.data);
|
|
1430
|
+
} catch {
|
|
1431
|
+
return this._getInvalidInput(e);
|
|
1432
|
+
}
|
|
1433
|
+
if (this._getType(e) !== f.bigint)
|
|
1434
|
+
return this._getInvalidInput(e);
|
|
1435
|
+
let s;
|
|
1436
|
+
const n = new C();
|
|
1437
|
+
for (const a of this._def.checks)
|
|
1438
|
+
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1439
|
+
code: d.too_small,
|
|
1440
|
+
type: "bigint",
|
|
1441
|
+
minimum: a.value,
|
|
1442
|
+
inclusive: a.inclusive,
|
|
1443
|
+
message: a.message
|
|
1444
|
+
}), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1445
|
+
code: d.too_big,
|
|
1446
|
+
type: "bigint",
|
|
1447
|
+
maximum: a.value,
|
|
1448
|
+
inclusive: a.inclusive,
|
|
1449
|
+
message: a.message
|
|
1450
|
+
}), n.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1451
|
+
code: d.not_multiple_of,
|
|
1452
|
+
multipleOf: a.value,
|
|
1453
|
+
message: a.message
|
|
1454
|
+
}), n.dirty()) : w.assertNever(a);
|
|
1455
|
+
return { status: n.value, value: e.data };
|
|
1456
|
+
}
|
|
1457
|
+
_getInvalidInput(e) {
|
|
1458
|
+
const r = this._getOrReturnCtx(e);
|
|
1459
|
+
return u(r, {
|
|
1460
|
+
code: d.invalid_type,
|
|
1461
|
+
expected: f.bigint,
|
|
1462
|
+
received: r.parsedType
|
|
1463
|
+
}), y;
|
|
1464
|
+
}
|
|
1465
|
+
gte(e, r) {
|
|
1466
|
+
return this.setLimit("min", e, !0, h.toString(r));
|
|
1467
|
+
}
|
|
1468
|
+
gt(e, r) {
|
|
1469
|
+
return this.setLimit("min", e, !1, h.toString(r));
|
|
1470
|
+
}
|
|
1471
|
+
lte(e, r) {
|
|
1472
|
+
return this.setLimit("max", e, !0, h.toString(r));
|
|
1473
|
+
}
|
|
1474
|
+
lt(e, r) {
|
|
1475
|
+
return this.setLimit("max", e, !1, h.toString(r));
|
|
1476
|
+
}
|
|
1477
|
+
setLimit(e, r, s, n) {
|
|
1478
|
+
return new he({
|
|
1479
|
+
...this._def,
|
|
1480
|
+
checks: [
|
|
1481
|
+
...this._def.checks,
|
|
1482
|
+
{
|
|
1483
|
+
kind: e,
|
|
1484
|
+
value: r,
|
|
1485
|
+
inclusive: s,
|
|
1486
|
+
message: h.toString(n)
|
|
1487
|
+
}
|
|
1488
|
+
]
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
_addCheck(e) {
|
|
1492
|
+
return new he({
|
|
1493
|
+
...this._def,
|
|
1494
|
+
checks: [...this._def.checks, e]
|
|
1495
|
+
});
|
|
1496
|
+
}
|
|
1497
|
+
positive(e) {
|
|
1498
|
+
return this._addCheck({
|
|
1499
|
+
kind: "min",
|
|
1500
|
+
value: BigInt(0),
|
|
1501
|
+
inclusive: !1,
|
|
1502
|
+
message: h.toString(e)
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
negative(e) {
|
|
1506
|
+
return this._addCheck({
|
|
1507
|
+
kind: "max",
|
|
1508
|
+
value: BigInt(0),
|
|
1509
|
+
inclusive: !1,
|
|
1510
|
+
message: h.toString(e)
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
nonpositive(e) {
|
|
1514
|
+
return this._addCheck({
|
|
1515
|
+
kind: "max",
|
|
1516
|
+
value: BigInt(0),
|
|
1517
|
+
inclusive: !0,
|
|
1518
|
+
message: h.toString(e)
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
nonnegative(e) {
|
|
1522
|
+
return this._addCheck({
|
|
1523
|
+
kind: "min",
|
|
1524
|
+
value: BigInt(0),
|
|
1525
|
+
inclusive: !0,
|
|
1526
|
+
message: h.toString(e)
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
multipleOf(e, r) {
|
|
1530
|
+
return this._addCheck({
|
|
1531
|
+
kind: "multipleOf",
|
|
1532
|
+
value: e,
|
|
1533
|
+
message: h.toString(r)
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
get minValue() {
|
|
1537
|
+
let e = null;
|
|
1538
|
+
for (const r of this._def.checks)
|
|
1539
|
+
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
1540
|
+
return e;
|
|
1541
|
+
}
|
|
1542
|
+
get maxValue() {
|
|
1543
|
+
let e = null;
|
|
1544
|
+
for (const r of this._def.checks)
|
|
1545
|
+
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1546
|
+
return e;
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
he.create = (t) => new he({
|
|
1550
|
+
checks: [],
|
|
1551
|
+
typeName: g.ZodBigInt,
|
|
1552
|
+
coerce: t?.coerce ?? !1,
|
|
1553
|
+
...v(t)
|
|
1554
|
+
});
|
|
1555
|
+
class tt extends k {
|
|
1556
|
+
_parse(e) {
|
|
1557
|
+
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
|
|
1558
|
+
const s = this._getOrReturnCtx(e);
|
|
1559
|
+
return u(s, {
|
|
1560
|
+
code: d.invalid_type,
|
|
1561
|
+
expected: f.boolean,
|
|
1562
|
+
received: s.parsedType
|
|
1563
|
+
}), y;
|
|
1564
|
+
}
|
|
1565
|
+
return A(e.data);
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
tt.create = (t) => new tt({
|
|
1569
|
+
typeName: g.ZodBoolean,
|
|
1570
|
+
coerce: t?.coerce || !1,
|
|
1571
|
+
...v(t)
|
|
1572
|
+
});
|
|
1573
|
+
class xe extends k {
|
|
1574
|
+
_parse(e) {
|
|
1575
|
+
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
|
|
1576
|
+
const a = this._getOrReturnCtx(e);
|
|
1577
|
+
return u(a, {
|
|
1578
|
+
code: d.invalid_type,
|
|
1579
|
+
expected: f.date,
|
|
1580
|
+
received: a.parsedType
|
|
1581
|
+
}), y;
|
|
1582
|
+
}
|
|
1583
|
+
if (Number.isNaN(e.data.getTime())) {
|
|
1584
|
+
const a = this._getOrReturnCtx(e);
|
|
1585
|
+
return u(a, {
|
|
1586
|
+
code: d.invalid_date
|
|
1587
|
+
}), y;
|
|
1588
|
+
}
|
|
1589
|
+
const s = new C();
|
|
1590
|
+
let n;
|
|
1591
|
+
for (const a of this._def.checks)
|
|
1592
|
+
a.kind === "min" ? e.data.getTime() < a.value && (n = this._getOrReturnCtx(e, n), u(n, {
|
|
1593
|
+
code: d.too_small,
|
|
1594
|
+
message: a.message,
|
|
1595
|
+
inclusive: !0,
|
|
1596
|
+
exact: !1,
|
|
1597
|
+
minimum: a.value,
|
|
1598
|
+
type: "date"
|
|
1599
|
+
}), s.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (n = this._getOrReturnCtx(e, n), u(n, {
|
|
1600
|
+
code: d.too_big,
|
|
1601
|
+
message: a.message,
|
|
1602
|
+
inclusive: !0,
|
|
1603
|
+
exact: !1,
|
|
1604
|
+
maximum: a.value,
|
|
1605
|
+
type: "date"
|
|
1606
|
+
}), s.dirty()) : w.assertNever(a);
|
|
1607
|
+
return {
|
|
1608
|
+
status: s.value,
|
|
1609
|
+
value: new Date(e.data.getTime())
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
_addCheck(e) {
|
|
1613
|
+
return new xe({
|
|
1614
|
+
...this._def,
|
|
1615
|
+
checks: [...this._def.checks, e]
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
min(e, r) {
|
|
1619
|
+
return this._addCheck({
|
|
1620
|
+
kind: "min",
|
|
1621
|
+
value: e.getTime(),
|
|
1622
|
+
message: h.toString(r)
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
max(e, r) {
|
|
1626
|
+
return this._addCheck({
|
|
1627
|
+
kind: "max",
|
|
1628
|
+
value: e.getTime(),
|
|
1629
|
+
message: h.toString(r)
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
get minDate() {
|
|
1633
|
+
let e = null;
|
|
1634
|
+
for (const r of this._def.checks)
|
|
1635
|
+
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
1636
|
+
return e != null ? new Date(e) : null;
|
|
1637
|
+
}
|
|
1638
|
+
get maxDate() {
|
|
1639
|
+
let e = null;
|
|
1640
|
+
for (const r of this._def.checks)
|
|
1641
|
+
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1642
|
+
return e != null ? new Date(e) : null;
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
xe.create = (t) => new xe({
|
|
1646
|
+
checks: [],
|
|
1647
|
+
coerce: t?.coerce || !1,
|
|
1648
|
+
typeName: g.ZodDate,
|
|
1649
|
+
...v(t)
|
|
1650
|
+
});
|
|
1651
|
+
class rt extends k {
|
|
1652
|
+
_parse(e) {
|
|
1653
|
+
if (this._getType(e) !== f.symbol) {
|
|
1654
|
+
const s = this._getOrReturnCtx(e);
|
|
1655
|
+
return u(s, {
|
|
1656
|
+
code: d.invalid_type,
|
|
1657
|
+
expected: f.symbol,
|
|
1658
|
+
received: s.parsedType
|
|
1659
|
+
}), y;
|
|
1660
|
+
}
|
|
1661
|
+
return A(e.data);
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
rt.create = (t) => new rt({
|
|
1665
|
+
typeName: g.ZodSymbol,
|
|
1666
|
+
...v(t)
|
|
1667
|
+
});
|
|
1668
|
+
class st extends k {
|
|
1669
|
+
_parse(e) {
|
|
1670
|
+
if (this._getType(e) !== f.undefined) {
|
|
1671
|
+
const s = this._getOrReturnCtx(e);
|
|
1672
|
+
return u(s, {
|
|
1673
|
+
code: d.invalid_type,
|
|
1674
|
+
expected: f.undefined,
|
|
1675
|
+
received: s.parsedType
|
|
1676
|
+
}), y;
|
|
1677
|
+
}
|
|
1678
|
+
return A(e.data);
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
st.create = (t) => new st({
|
|
1682
|
+
typeName: g.ZodUndefined,
|
|
1683
|
+
...v(t)
|
|
1684
|
+
});
|
|
1685
|
+
class nt extends k {
|
|
1686
|
+
_parse(e) {
|
|
1687
|
+
if (this._getType(e) !== f.null) {
|
|
1688
|
+
const s = this._getOrReturnCtx(e);
|
|
1689
|
+
return u(s, {
|
|
1690
|
+
code: d.invalid_type,
|
|
1691
|
+
expected: f.null,
|
|
1692
|
+
received: s.parsedType
|
|
1693
|
+
}), y;
|
|
1694
|
+
}
|
|
1695
|
+
return A(e.data);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
nt.create = (t) => new nt({
|
|
1699
|
+
typeName: g.ZodNull,
|
|
1700
|
+
...v(t)
|
|
1701
|
+
});
|
|
1702
|
+
class at extends k {
|
|
1703
|
+
constructor() {
|
|
1704
|
+
super(...arguments), this._any = !0;
|
|
1705
|
+
}
|
|
1706
|
+
_parse(e) {
|
|
1707
|
+
return A(e.data);
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
at.create = (t) => new at({
|
|
1711
|
+
typeName: g.ZodAny,
|
|
1712
|
+
...v(t)
|
|
1713
|
+
});
|
|
1714
|
+
class it extends k {
|
|
1715
|
+
constructor() {
|
|
1716
|
+
super(...arguments), this._unknown = !0;
|
|
1717
|
+
}
|
|
1718
|
+
_parse(e) {
|
|
1719
|
+
return A(e.data);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
it.create = (t) => new it({
|
|
1723
|
+
typeName: g.ZodUnknown,
|
|
1724
|
+
...v(t)
|
|
1725
|
+
});
|
|
1726
|
+
class H extends k {
|
|
1727
|
+
_parse(e) {
|
|
1728
|
+
const r = this._getOrReturnCtx(e);
|
|
1729
|
+
return u(r, {
|
|
1730
|
+
code: d.invalid_type,
|
|
1731
|
+
expected: f.never,
|
|
1732
|
+
received: r.parsedType
|
|
1733
|
+
}), y;
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
H.create = (t) => new H({
|
|
1737
|
+
typeName: g.ZodNever,
|
|
1738
|
+
...v(t)
|
|
1739
|
+
});
|
|
1740
|
+
class ot extends k {
|
|
1741
|
+
_parse(e) {
|
|
1742
|
+
if (this._getType(e) !== f.undefined) {
|
|
1743
|
+
const s = this._getOrReturnCtx(e);
|
|
1744
|
+
return u(s, {
|
|
1745
|
+
code: d.invalid_type,
|
|
1746
|
+
expected: f.void,
|
|
1747
|
+
received: s.parsedType
|
|
1748
|
+
}), y;
|
|
1749
|
+
}
|
|
1750
|
+
return A(e.data);
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
ot.create = (t) => new ot({
|
|
1754
|
+
typeName: g.ZodVoid,
|
|
1755
|
+
...v(t)
|
|
1756
|
+
});
|
|
1757
|
+
class $ extends k {
|
|
1758
|
+
_parse(e) {
|
|
1759
|
+
const { ctx: r, status: s } = this._processInputParams(e), n = this._def;
|
|
1760
|
+
if (r.parsedType !== f.array)
|
|
1761
|
+
return u(r, {
|
|
1762
|
+
code: d.invalid_type,
|
|
1763
|
+
expected: f.array,
|
|
1764
|
+
received: r.parsedType
|
|
1765
|
+
}), y;
|
|
1766
|
+
if (n.exactLength !== null) {
|
|
1767
|
+
const i = r.data.length > n.exactLength.value, o = r.data.length < n.exactLength.value;
|
|
1768
|
+
(i || o) && (u(r, {
|
|
1769
|
+
code: i ? d.too_big : d.too_small,
|
|
1770
|
+
minimum: o ? n.exactLength.value : void 0,
|
|
1771
|
+
maximum: i ? n.exactLength.value : void 0,
|
|
1772
|
+
type: "array",
|
|
1773
|
+
inclusive: !0,
|
|
1774
|
+
exact: !0,
|
|
1775
|
+
message: n.exactLength.message
|
|
1776
|
+
}), s.dirty());
|
|
1777
|
+
}
|
|
1778
|
+
if (n.minLength !== null && r.data.length < n.minLength.value && (u(r, {
|
|
1779
|
+
code: d.too_small,
|
|
1780
|
+
minimum: n.minLength.value,
|
|
1781
|
+
type: "array",
|
|
1782
|
+
inclusive: !0,
|
|
1783
|
+
exact: !1,
|
|
1784
|
+
message: n.minLength.message
|
|
1785
|
+
}), s.dirty()), n.maxLength !== null && r.data.length > n.maxLength.value && (u(r, {
|
|
1786
|
+
code: d.too_big,
|
|
1787
|
+
maximum: n.maxLength.value,
|
|
1788
|
+
type: "array",
|
|
1789
|
+
inclusive: !0,
|
|
1790
|
+
exact: !1,
|
|
1791
|
+
message: n.maxLength.message
|
|
1792
|
+
}), s.dirty()), r.common.async)
|
|
1793
|
+
return Promise.all([...r.data].map((i, o) => n.type._parseAsync(new B(r, i, r.path, o)))).then((i) => C.mergeArray(s, i));
|
|
1794
|
+
const a = [...r.data].map((i, o) => n.type._parseSync(new B(r, i, r.path, o)));
|
|
1795
|
+
return C.mergeArray(s, a);
|
|
1796
|
+
}
|
|
1797
|
+
get element() {
|
|
1798
|
+
return this._def.type;
|
|
1799
|
+
}
|
|
1800
|
+
min(e, r) {
|
|
1801
|
+
return new $({
|
|
1802
|
+
...this._def,
|
|
1803
|
+
minLength: { value: e, message: h.toString(r) }
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
max(e, r) {
|
|
1807
|
+
return new $({
|
|
1808
|
+
...this._def,
|
|
1809
|
+
maxLength: { value: e, message: h.toString(r) }
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
length(e, r) {
|
|
1813
|
+
return new $({
|
|
1814
|
+
...this._def,
|
|
1815
|
+
exactLength: { value: e, message: h.toString(r) }
|
|
1816
|
+
});
|
|
1817
|
+
}
|
|
1818
|
+
nonempty(e) {
|
|
1819
|
+
return this.min(1, e);
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
$.create = (t, e) => new $({
|
|
1823
|
+
type: t,
|
|
1824
|
+
minLength: null,
|
|
1825
|
+
maxLength: null,
|
|
1826
|
+
exactLength: null,
|
|
1827
|
+
typeName: g.ZodArray,
|
|
1828
|
+
...v(e)
|
|
1829
|
+
});
|
|
1830
|
+
function ee(t) {
|
|
1831
|
+
if (t instanceof O) {
|
|
1832
|
+
const e = {};
|
|
1833
|
+
for (const r in t.shape) {
|
|
1834
|
+
const s = t.shape[r];
|
|
1835
|
+
e[r] = U.create(ee(s));
|
|
1836
|
+
}
|
|
1837
|
+
return new O({
|
|
1838
|
+
...t._def,
|
|
1839
|
+
shape: () => e
|
|
1840
|
+
});
|
|
1841
|
+
} else return t instanceof $ ? new $({
|
|
1842
|
+
...t._def,
|
|
1843
|
+
type: ee(t.element)
|
|
1844
|
+
}) : t instanceof U ? U.create(ee(t.unwrap())) : t instanceof oe ? oe.create(ee(t.unwrap())) : t instanceof Q ? Q.create(t.items.map((e) => ee(e))) : t;
|
|
1845
|
+
}
|
|
1846
|
+
class O extends k {
|
|
1847
|
+
constructor() {
|
|
1848
|
+
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1849
|
+
}
|
|
1850
|
+
_getCached() {
|
|
1851
|
+
if (this._cached !== null)
|
|
1852
|
+
return this._cached;
|
|
1853
|
+
const e = this._def.shape(), r = w.objectKeys(e);
|
|
1854
|
+
return this._cached = { shape: e, keys: r }, this._cached;
|
|
1855
|
+
}
|
|
1856
|
+
_parse(e) {
|
|
1857
|
+
if (this._getType(e) !== f.object) {
|
|
1858
|
+
const l = this._getOrReturnCtx(e);
|
|
1859
|
+
return u(l, {
|
|
1860
|
+
code: d.invalid_type,
|
|
1861
|
+
expected: f.object,
|
|
1862
|
+
received: l.parsedType
|
|
1863
|
+
}), y;
|
|
1864
|
+
}
|
|
1865
|
+
const { status: s, ctx: n } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1866
|
+
if (!(this._def.catchall instanceof H && this._def.unknownKeys === "strip"))
|
|
1867
|
+
for (const l in n.data)
|
|
1868
|
+
i.includes(l) || o.push(l);
|
|
1869
|
+
const c = [];
|
|
1870
|
+
for (const l of i) {
|
|
1871
|
+
const p = a[l], x = n.data[l];
|
|
1872
|
+
c.push({
|
|
1873
|
+
key: { status: "valid", value: l },
|
|
1874
|
+
value: p._parse(new B(n, x, n.path, l)),
|
|
1875
|
+
alwaysSet: l in n.data
|
|
1876
|
+
});
|
|
1877
|
+
}
|
|
1878
|
+
if (this._def.catchall instanceof H) {
|
|
1879
|
+
const l = this._def.unknownKeys;
|
|
1880
|
+
if (l === "passthrough")
|
|
1881
|
+
for (const p of o)
|
|
1882
|
+
c.push({
|
|
1883
|
+
key: { status: "valid", value: p },
|
|
1884
|
+
value: { status: "valid", value: n.data[p] }
|
|
1885
|
+
});
|
|
1886
|
+
else if (l === "strict")
|
|
1887
|
+
o.length > 0 && (u(n, {
|
|
1888
|
+
code: d.unrecognized_keys,
|
|
1889
|
+
keys: o
|
|
1890
|
+
}), s.dirty());
|
|
1891
|
+
else if (l !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1892
|
+
} else {
|
|
1893
|
+
const l = this._def.catchall;
|
|
1894
|
+
for (const p of o) {
|
|
1895
|
+
const x = n.data[p];
|
|
1896
|
+
c.push({
|
|
1897
|
+
key: { status: "valid", value: p },
|
|
1898
|
+
value: l._parse(
|
|
1899
|
+
new B(n, x, n.path, p)
|
|
1900
|
+
//, ctx.child(key), value, getParsedType(value)
|
|
1901
|
+
),
|
|
1902
|
+
alwaysSet: p in n.data
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
return n.common.async ? Promise.resolve().then(async () => {
|
|
1907
|
+
const l = [];
|
|
1908
|
+
for (const p of c) {
|
|
1909
|
+
const x = await p.key, S = await p.value;
|
|
1910
|
+
l.push({
|
|
1911
|
+
key: x,
|
|
1912
|
+
value: S,
|
|
1913
|
+
alwaysSet: p.alwaysSet
|
|
1914
|
+
});
|
|
1915
|
+
}
|
|
1916
|
+
return l;
|
|
1917
|
+
}).then((l) => C.mergeObjectSync(s, l)) : C.mergeObjectSync(s, c);
|
|
1918
|
+
}
|
|
1919
|
+
get shape() {
|
|
1920
|
+
return this._def.shape();
|
|
1921
|
+
}
|
|
1922
|
+
strict(e) {
|
|
1923
|
+
return h.errToObj, new O({
|
|
1924
|
+
...this._def,
|
|
1925
|
+
unknownKeys: "strict",
|
|
1926
|
+
...e !== void 0 ? {
|
|
1927
|
+
errorMap: (r, s) => {
|
|
1928
|
+
const n = this._def.errorMap?.(r, s).message ?? s.defaultError;
|
|
1929
|
+
return r.code === "unrecognized_keys" ? {
|
|
1930
|
+
message: h.errToObj(e).message ?? n
|
|
1931
|
+
} : {
|
|
1932
|
+
message: n
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
} : {}
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
1938
|
+
strip() {
|
|
1939
|
+
return new O({
|
|
1940
|
+
...this._def,
|
|
1941
|
+
unknownKeys: "strip"
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
passthrough() {
|
|
1945
|
+
return new O({
|
|
1946
|
+
...this._def,
|
|
1947
|
+
unknownKeys: "passthrough"
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
// const AugmentFactory =
|
|
1951
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
|
1952
|
+
// <Augmentation extends ZodRawShape>(
|
|
1953
|
+
// augmentation: Augmentation
|
|
1954
|
+
// ): ZodObject<
|
|
1955
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
1956
|
+
// Def["unknownKeys"],
|
|
1957
|
+
// Def["catchall"]
|
|
1958
|
+
// > => {
|
|
1959
|
+
// return new ZodObject({
|
|
1960
|
+
// ...def,
|
|
1961
|
+
// shape: () => ({
|
|
1962
|
+
// ...def.shape(),
|
|
1963
|
+
// ...augmentation,
|
|
1964
|
+
// }),
|
|
1965
|
+
// }) as any;
|
|
1966
|
+
// };
|
|
1967
|
+
extend(e) {
|
|
1968
|
+
return new O({
|
|
1969
|
+
...this._def,
|
|
1970
|
+
shape: () => ({
|
|
1971
|
+
...this._def.shape(),
|
|
1972
|
+
...e
|
|
1973
|
+
})
|
|
1974
|
+
});
|
|
1975
|
+
}
|
|
1976
|
+
/**
|
|
1977
|
+
* Prior to zod@1.0.12 there was a bug in the
|
|
1978
|
+
* inferred type of merged objects. Please
|
|
1979
|
+
* upgrade if you are experiencing issues.
|
|
1980
|
+
*/
|
|
1981
|
+
merge(e) {
|
|
1982
|
+
return new O({
|
|
1983
|
+
unknownKeys: e._def.unknownKeys,
|
|
1984
|
+
catchall: e._def.catchall,
|
|
1985
|
+
shape: () => ({
|
|
1986
|
+
...this._def.shape(),
|
|
1987
|
+
...e._def.shape()
|
|
1988
|
+
}),
|
|
1989
|
+
typeName: g.ZodObject
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1992
|
+
// merge<
|
|
1993
|
+
// Incoming extends AnyZodObject,
|
|
1994
|
+
// Augmentation extends Incoming["shape"],
|
|
1995
|
+
// NewOutput extends {
|
|
1996
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
1997
|
+
// ? Augmentation[k]["_output"]
|
|
1998
|
+
// : k extends keyof Output
|
|
1999
|
+
// ? Output[k]
|
|
2000
|
+
// : never;
|
|
2001
|
+
// },
|
|
2002
|
+
// NewInput extends {
|
|
2003
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
2004
|
+
// ? Augmentation[k]["_input"]
|
|
2005
|
+
// : k extends keyof Input
|
|
2006
|
+
// ? Input[k]
|
|
2007
|
+
// : never;
|
|
2008
|
+
// }
|
|
2009
|
+
// >(
|
|
2010
|
+
// merging: Incoming
|
|
2011
|
+
// ): ZodObject<
|
|
2012
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
2013
|
+
// Incoming["_def"]["unknownKeys"],
|
|
2014
|
+
// Incoming["_def"]["catchall"],
|
|
2015
|
+
// NewOutput,
|
|
2016
|
+
// NewInput
|
|
2017
|
+
// > {
|
|
2018
|
+
// const merged: any = new ZodObject({
|
|
2019
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
2020
|
+
// catchall: merging._def.catchall,
|
|
2021
|
+
// shape: () =>
|
|
2022
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
2023
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
2024
|
+
// }) as any;
|
|
2025
|
+
// return merged;
|
|
2026
|
+
// }
|
|
2027
|
+
setKey(e, r) {
|
|
2028
|
+
return this.augment({ [e]: r });
|
|
2029
|
+
}
|
|
2030
|
+
// merge<Incoming extends AnyZodObject>(
|
|
2031
|
+
// merging: Incoming
|
|
2032
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
2033
|
+
// ZodObject<
|
|
2034
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
2035
|
+
// Incoming["_def"]["unknownKeys"],
|
|
2036
|
+
// Incoming["_def"]["catchall"]
|
|
2037
|
+
// > {
|
|
2038
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
|
2039
|
+
// // this._def.shape(),
|
|
2040
|
+
// // merging._def.shape()
|
|
2041
|
+
// // );
|
|
2042
|
+
// const merged: any = new ZodObject({
|
|
2043
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
2044
|
+
// catchall: merging._def.catchall,
|
|
2045
|
+
// shape: () =>
|
|
2046
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
2047
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
2048
|
+
// }) as any;
|
|
2049
|
+
// return merged;
|
|
2050
|
+
// }
|
|
2051
|
+
catchall(e) {
|
|
2052
|
+
return new O({
|
|
2053
|
+
...this._def,
|
|
2054
|
+
catchall: e
|
|
2055
|
+
});
|
|
2056
|
+
}
|
|
2057
|
+
pick(e) {
|
|
2058
|
+
const r = {};
|
|
2059
|
+
for (const s of w.objectKeys(e))
|
|
2060
|
+
e[s] && this.shape[s] && (r[s] = this.shape[s]);
|
|
2061
|
+
return new O({
|
|
2062
|
+
...this._def,
|
|
2063
|
+
shape: () => r
|
|
2064
|
+
});
|
|
2065
|
+
}
|
|
2066
|
+
omit(e) {
|
|
2067
|
+
const r = {};
|
|
2068
|
+
for (const s of w.objectKeys(this.shape))
|
|
2069
|
+
e[s] || (r[s] = this.shape[s]);
|
|
2070
|
+
return new O({
|
|
2071
|
+
...this._def,
|
|
2072
|
+
shape: () => r
|
|
2073
|
+
});
|
|
2074
|
+
}
|
|
2075
|
+
/**
|
|
2076
|
+
* @deprecated
|
|
2077
|
+
*/
|
|
2078
|
+
deepPartial() {
|
|
2079
|
+
return ee(this);
|
|
2080
|
+
}
|
|
2081
|
+
partial(e) {
|
|
2082
|
+
const r = {};
|
|
2083
|
+
for (const s of w.objectKeys(this.shape)) {
|
|
2084
|
+
const n = this.shape[s];
|
|
2085
|
+
e && !e[s] ? r[s] = n : r[s] = n.optional();
|
|
2086
|
+
}
|
|
2087
|
+
return new O({
|
|
2088
|
+
...this._def,
|
|
2089
|
+
shape: () => r
|
|
2090
|
+
});
|
|
2091
|
+
}
|
|
2092
|
+
required(e) {
|
|
2093
|
+
const r = {};
|
|
2094
|
+
for (const s of w.objectKeys(this.shape))
|
|
2095
|
+
if (e && !e[s])
|
|
2096
|
+
r[s] = this.shape[s];
|
|
2097
|
+
else {
|
|
2098
|
+
let a = this.shape[s];
|
|
2099
|
+
for (; a instanceof U; )
|
|
2100
|
+
a = a._def.innerType;
|
|
2101
|
+
r[s] = a;
|
|
2102
|
+
}
|
|
2103
|
+
return new O({
|
|
2104
|
+
...this._def,
|
|
2105
|
+
shape: () => r
|
|
2106
|
+
});
|
|
2107
|
+
}
|
|
2108
|
+
keyof() {
|
|
2109
|
+
return bt(w.objectKeys(this.shape));
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
O.create = (t, e) => new O({
|
|
2113
|
+
shape: () => t,
|
|
2114
|
+
unknownKeys: "strip",
|
|
2115
|
+
catchall: H.create(),
|
|
2116
|
+
typeName: g.ZodObject,
|
|
2117
|
+
...v(e)
|
|
2118
|
+
});
|
|
2119
|
+
O.strictCreate = (t, e) => new O({
|
|
2120
|
+
shape: () => t,
|
|
2121
|
+
unknownKeys: "strict",
|
|
2122
|
+
catchall: H.create(),
|
|
2123
|
+
typeName: g.ZodObject,
|
|
2124
|
+
...v(e)
|
|
2125
|
+
});
|
|
2126
|
+
O.lazycreate = (t, e) => new O({
|
|
2127
|
+
shape: t,
|
|
2128
|
+
unknownKeys: "strip",
|
|
2129
|
+
catchall: H.create(),
|
|
2130
|
+
typeName: g.ZodObject,
|
|
2131
|
+
...v(e)
|
|
2132
|
+
});
|
|
2133
|
+
class Se extends k {
|
|
2134
|
+
_parse(e) {
|
|
2135
|
+
const { ctx: r } = this._processInputParams(e), s = this._def.options;
|
|
2136
|
+
function n(a) {
|
|
2137
|
+
for (const o of a)
|
|
2138
|
+
if (o.result.status === "valid")
|
|
2139
|
+
return o.result;
|
|
2140
|
+
for (const o of a)
|
|
2141
|
+
if (o.result.status === "dirty")
|
|
2142
|
+
return r.common.issues.push(...o.ctx.common.issues), o.result;
|
|
2143
|
+
const i = a.map((o) => new M(o.ctx.common.issues));
|
|
2144
|
+
return u(r, {
|
|
2145
|
+
code: d.invalid_union,
|
|
2146
|
+
unionErrors: i
|
|
2147
|
+
}), y;
|
|
2148
|
+
}
|
|
2149
|
+
if (r.common.async)
|
|
2150
|
+
return Promise.all(s.map(async (a) => {
|
|
2151
|
+
const i = {
|
|
2152
|
+
...r,
|
|
2153
|
+
common: {
|
|
2154
|
+
...r.common,
|
|
2155
|
+
issues: []
|
|
2156
|
+
},
|
|
2157
|
+
parent: null
|
|
2158
|
+
};
|
|
2159
|
+
return {
|
|
2160
|
+
result: await a._parseAsync({
|
|
2161
|
+
data: r.data,
|
|
2162
|
+
path: r.path,
|
|
2163
|
+
parent: i
|
|
2164
|
+
}),
|
|
2165
|
+
ctx: i
|
|
2166
|
+
};
|
|
2167
|
+
})).then(n);
|
|
2168
|
+
{
|
|
2169
|
+
let a;
|
|
2170
|
+
const i = [];
|
|
2171
|
+
for (const c of s) {
|
|
2172
|
+
const l = {
|
|
2173
|
+
...r,
|
|
2174
|
+
common: {
|
|
2175
|
+
...r.common,
|
|
2176
|
+
issues: []
|
|
2177
|
+
},
|
|
2178
|
+
parent: null
|
|
2179
|
+
}, p = c._parseSync({
|
|
2180
|
+
data: r.data,
|
|
2181
|
+
path: r.path,
|
|
2182
|
+
parent: l
|
|
2183
|
+
});
|
|
2184
|
+
if (p.status === "valid")
|
|
2185
|
+
return p;
|
|
2186
|
+
p.status === "dirty" && !a && (a = { result: p, ctx: l }), l.common.issues.length && i.push(l.common.issues);
|
|
2187
|
+
}
|
|
2188
|
+
if (a)
|
|
2189
|
+
return r.common.issues.push(...a.ctx.common.issues), a.result;
|
|
2190
|
+
const o = i.map((c) => new M(c));
|
|
2191
|
+
return u(r, {
|
|
2192
|
+
code: d.invalid_union,
|
|
2193
|
+
unionErrors: o
|
|
2194
|
+
}), y;
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
get options() {
|
|
2198
|
+
return this._def.options;
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
Se.create = (t, e) => new Se({
|
|
2202
|
+
options: t,
|
|
2203
|
+
typeName: g.ZodUnion,
|
|
2204
|
+
...v(e)
|
|
2205
|
+
});
|
|
2206
|
+
function je(t, e) {
|
|
2207
|
+
const r = V(t), s = V(e);
|
|
2208
|
+
if (t === e)
|
|
2209
|
+
return { valid: !0, data: t };
|
|
2210
|
+
if (r === f.object && s === f.object) {
|
|
2211
|
+
const n = w.objectKeys(e), a = w.objectKeys(t).filter((o) => n.indexOf(o) !== -1), i = { ...t, ...e };
|
|
2212
|
+
for (const o of a) {
|
|
2213
|
+
const c = je(t[o], e[o]);
|
|
2214
|
+
if (!c.valid)
|
|
2215
|
+
return { valid: !1 };
|
|
2216
|
+
i[o] = c.data;
|
|
2217
|
+
}
|
|
2218
|
+
return { valid: !0, data: i };
|
|
2219
|
+
} else if (r === f.array && s === f.array) {
|
|
2220
|
+
if (t.length !== e.length)
|
|
2221
|
+
return { valid: !1 };
|
|
2222
|
+
const n = [];
|
|
2223
|
+
for (let a = 0; a < t.length; a++) {
|
|
2224
|
+
const i = t[a], o = e[a], c = je(i, o);
|
|
2225
|
+
if (!c.valid)
|
|
2226
|
+
return { valid: !1 };
|
|
2227
|
+
n.push(c.data);
|
|
2228
|
+
}
|
|
2229
|
+
return { valid: !0, data: n };
|
|
2230
|
+
} else return r === f.date && s === f.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
2231
|
+
}
|
|
2232
|
+
class Oe extends k {
|
|
2233
|
+
_parse(e) {
|
|
2234
|
+
const { status: r, ctx: s } = this._processInputParams(e), n = (a, i) => {
|
|
2235
|
+
if (Ke(a) || Ke(i))
|
|
2236
|
+
return y;
|
|
2237
|
+
const o = je(a.value, i.value);
|
|
2238
|
+
return o.valid ? ((Qe(a) || Qe(i)) && r.dirty(), { status: r.value, value: o.data }) : (u(s, {
|
|
2239
|
+
code: d.invalid_intersection_types
|
|
2240
|
+
}), y);
|
|
2241
|
+
};
|
|
2242
|
+
return s.common.async ? Promise.all([
|
|
2243
|
+
this._def.left._parseAsync({
|
|
2244
|
+
data: s.data,
|
|
2245
|
+
path: s.path,
|
|
2246
|
+
parent: s
|
|
2247
|
+
}),
|
|
2248
|
+
this._def.right._parseAsync({
|
|
2249
|
+
data: s.data,
|
|
2250
|
+
path: s.path,
|
|
2251
|
+
parent: s
|
|
2252
|
+
})
|
|
2253
|
+
]).then(([a, i]) => n(a, i)) : n(this._def.left._parseSync({
|
|
2254
|
+
data: s.data,
|
|
2255
|
+
path: s.path,
|
|
2256
|
+
parent: s
|
|
2257
|
+
}), this._def.right._parseSync({
|
|
2258
|
+
data: s.data,
|
|
2259
|
+
path: s.path,
|
|
2260
|
+
parent: s
|
|
2261
|
+
}));
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
Oe.create = (t, e, r) => new Oe({
|
|
2265
|
+
left: t,
|
|
2266
|
+
right: e,
|
|
2267
|
+
typeName: g.ZodIntersection,
|
|
2268
|
+
...v(r)
|
|
2269
|
+
});
|
|
2270
|
+
class Q extends k {
|
|
2271
|
+
_parse(e) {
|
|
2272
|
+
const { status: r, ctx: s } = this._processInputParams(e);
|
|
2273
|
+
if (s.parsedType !== f.array)
|
|
2274
|
+
return u(s, {
|
|
2275
|
+
code: d.invalid_type,
|
|
2276
|
+
expected: f.array,
|
|
2277
|
+
received: s.parsedType
|
|
2278
|
+
}), y;
|
|
2279
|
+
if (s.data.length < this._def.items.length)
|
|
2280
|
+
return u(s, {
|
|
2281
|
+
code: d.too_small,
|
|
2282
|
+
minimum: this._def.items.length,
|
|
2283
|
+
inclusive: !0,
|
|
2284
|
+
exact: !1,
|
|
2285
|
+
type: "array"
|
|
2286
|
+
}), y;
|
|
2287
|
+
!this._def.rest && s.data.length > this._def.items.length && (u(s, {
|
|
2288
|
+
code: d.too_big,
|
|
2289
|
+
maximum: this._def.items.length,
|
|
2290
|
+
inclusive: !0,
|
|
2291
|
+
exact: !1,
|
|
2292
|
+
type: "array"
|
|
2293
|
+
}), r.dirty());
|
|
2294
|
+
const a = [...s.data].map((i, o) => {
|
|
2295
|
+
const c = this._def.items[o] || this._def.rest;
|
|
2296
|
+
return c ? c._parse(new B(s, i, s.path, o)) : null;
|
|
2297
|
+
}).filter((i) => !!i);
|
|
2298
|
+
return s.common.async ? Promise.all(a).then((i) => C.mergeArray(r, i)) : C.mergeArray(r, a);
|
|
2299
|
+
}
|
|
2300
|
+
get items() {
|
|
2301
|
+
return this._def.items;
|
|
2302
|
+
}
|
|
2303
|
+
rest(e) {
|
|
2304
|
+
return new Q({
|
|
2305
|
+
...this._def,
|
|
2306
|
+
rest: e
|
|
2307
|
+
});
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
Q.create = (t, e) => {
|
|
2311
|
+
if (!Array.isArray(t))
|
|
2312
|
+
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2313
|
+
return new Q({
|
|
2314
|
+
items: t,
|
|
2315
|
+
typeName: g.ZodTuple,
|
|
2316
|
+
rest: null,
|
|
2317
|
+
...v(e)
|
|
2318
|
+
});
|
|
2319
|
+
};
|
|
2320
|
+
class ct extends k {
|
|
2321
|
+
get keySchema() {
|
|
2322
|
+
return this._def.keyType;
|
|
2323
|
+
}
|
|
2324
|
+
get valueSchema() {
|
|
2325
|
+
return this._def.valueType;
|
|
2326
|
+
}
|
|
2327
|
+
_parse(e) {
|
|
2328
|
+
const { status: r, ctx: s } = this._processInputParams(e);
|
|
2329
|
+
if (s.parsedType !== f.map)
|
|
2330
|
+
return u(s, {
|
|
2331
|
+
code: d.invalid_type,
|
|
2332
|
+
expected: f.map,
|
|
2333
|
+
received: s.parsedType
|
|
2334
|
+
}), y;
|
|
2335
|
+
const n = this._def.keyType, a = this._def.valueType, i = [...s.data.entries()].map(([o, c], l) => ({
|
|
2336
|
+
key: n._parse(new B(s, o, s.path, [l, "key"])),
|
|
2337
|
+
value: a._parse(new B(s, c, s.path, [l, "value"]))
|
|
2338
|
+
}));
|
|
2339
|
+
if (s.common.async) {
|
|
2340
|
+
const o = /* @__PURE__ */ new Map();
|
|
2341
|
+
return Promise.resolve().then(async () => {
|
|
2342
|
+
for (const c of i) {
|
|
2343
|
+
const l = await c.key, p = await c.value;
|
|
2344
|
+
if (l.status === "aborted" || p.status === "aborted")
|
|
2345
|
+
return y;
|
|
2346
|
+
(l.status === "dirty" || p.status === "dirty") && r.dirty(), o.set(l.value, p.value);
|
|
2347
|
+
}
|
|
2348
|
+
return { status: r.value, value: o };
|
|
2349
|
+
});
|
|
2350
|
+
} else {
|
|
2351
|
+
const o = /* @__PURE__ */ new Map();
|
|
2352
|
+
for (const c of i) {
|
|
2353
|
+
const l = c.key, p = c.value;
|
|
2354
|
+
if (l.status === "aborted" || p.status === "aborted")
|
|
2355
|
+
return y;
|
|
2356
|
+
(l.status === "dirty" || p.status === "dirty") && r.dirty(), o.set(l.value, p.value);
|
|
2357
|
+
}
|
|
2358
|
+
return { status: r.value, value: o };
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
ct.create = (t, e, r) => new ct({
|
|
2363
|
+
valueType: e,
|
|
2364
|
+
keyType: t,
|
|
2365
|
+
typeName: g.ZodMap,
|
|
2366
|
+
...v(r)
|
|
2367
|
+
});
|
|
2368
|
+
class me extends k {
|
|
2369
|
+
_parse(e) {
|
|
2370
|
+
const { status: r, ctx: s } = this._processInputParams(e);
|
|
2371
|
+
if (s.parsedType !== f.set)
|
|
2372
|
+
return u(s, {
|
|
2373
|
+
code: d.invalid_type,
|
|
2374
|
+
expected: f.set,
|
|
2375
|
+
received: s.parsedType
|
|
2376
|
+
}), y;
|
|
2377
|
+
const n = this._def;
|
|
2378
|
+
n.minSize !== null && s.data.size < n.minSize.value && (u(s, {
|
|
2379
|
+
code: d.too_small,
|
|
2380
|
+
minimum: n.minSize.value,
|
|
2381
|
+
type: "set",
|
|
2382
|
+
inclusive: !0,
|
|
2383
|
+
exact: !1,
|
|
2384
|
+
message: n.minSize.message
|
|
2385
|
+
}), r.dirty()), n.maxSize !== null && s.data.size > n.maxSize.value && (u(s, {
|
|
2386
|
+
code: d.too_big,
|
|
2387
|
+
maximum: n.maxSize.value,
|
|
2388
|
+
type: "set",
|
|
2389
|
+
inclusive: !0,
|
|
2390
|
+
exact: !1,
|
|
2391
|
+
message: n.maxSize.message
|
|
2392
|
+
}), r.dirty());
|
|
2393
|
+
const a = this._def.valueType;
|
|
2394
|
+
function i(c) {
|
|
2395
|
+
const l = /* @__PURE__ */ new Set();
|
|
2396
|
+
for (const p of c) {
|
|
2397
|
+
if (p.status === "aborted")
|
|
2398
|
+
return y;
|
|
2399
|
+
p.status === "dirty" && r.dirty(), l.add(p.value);
|
|
2400
|
+
}
|
|
2401
|
+
return { status: r.value, value: l };
|
|
2402
|
+
}
|
|
2403
|
+
const o = [...s.data.values()].map((c, l) => a._parse(new B(s, c, s.path, l)));
|
|
2404
|
+
return s.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
2405
|
+
}
|
|
2406
|
+
min(e, r) {
|
|
2407
|
+
return new me({
|
|
2408
|
+
...this._def,
|
|
2409
|
+
minSize: { value: e, message: h.toString(r) }
|
|
2410
|
+
});
|
|
2411
|
+
}
|
|
2412
|
+
max(e, r) {
|
|
2413
|
+
return new me({
|
|
2414
|
+
...this._def,
|
|
2415
|
+
maxSize: { value: e, message: h.toString(r) }
|
|
2416
|
+
});
|
|
2417
|
+
}
|
|
2418
|
+
size(e, r) {
|
|
2419
|
+
return this.min(e, r).max(e, r);
|
|
2420
|
+
}
|
|
2421
|
+
nonempty(e) {
|
|
2422
|
+
return this.min(1, e);
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
me.create = (t, e) => new me({
|
|
2426
|
+
valueType: t,
|
|
2427
|
+
minSize: null,
|
|
2428
|
+
maxSize: null,
|
|
2429
|
+
typeName: g.ZodSet,
|
|
2430
|
+
...v(e)
|
|
2431
|
+
});
|
|
2432
|
+
class dt extends k {
|
|
2433
|
+
get schema() {
|
|
2434
|
+
return this._def.getter();
|
|
2435
|
+
}
|
|
2436
|
+
_parse(e) {
|
|
2437
|
+
const { ctx: r } = this._processInputParams(e);
|
|
2438
|
+
return this._def.getter()._parse({ data: r.data, path: r.path, parent: r });
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
dt.create = (t, e) => new dt({
|
|
2442
|
+
getter: t,
|
|
2443
|
+
typeName: g.ZodLazy,
|
|
2444
|
+
...v(e)
|
|
2445
|
+
});
|
|
2446
|
+
class lt extends k {
|
|
2447
|
+
_parse(e) {
|
|
2448
|
+
if (e.data !== this._def.value) {
|
|
2449
|
+
const r = this._getOrReturnCtx(e);
|
|
2450
|
+
return u(r, {
|
|
2451
|
+
received: r.data,
|
|
2452
|
+
code: d.invalid_literal,
|
|
2453
|
+
expected: this._def.value
|
|
2454
|
+
}), y;
|
|
2455
|
+
}
|
|
2456
|
+
return { status: "valid", value: e.data };
|
|
2457
|
+
}
|
|
2458
|
+
get value() {
|
|
2459
|
+
return this._def.value;
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
lt.create = (t, e) => new lt({
|
|
2463
|
+
value: t,
|
|
2464
|
+
typeName: g.ZodLiteral,
|
|
2465
|
+
...v(e)
|
|
2466
|
+
});
|
|
2467
|
+
function bt(t, e) {
|
|
2468
|
+
return new ae({
|
|
2469
|
+
values: t,
|
|
2470
|
+
typeName: g.ZodEnum,
|
|
2471
|
+
...v(e)
|
|
2472
|
+
});
|
|
2473
|
+
}
|
|
2474
|
+
class ae extends k {
|
|
2475
|
+
_parse(e) {
|
|
2476
|
+
if (typeof e.data != "string") {
|
|
2477
|
+
const r = this._getOrReturnCtx(e), s = this._def.values;
|
|
2478
|
+
return u(r, {
|
|
2479
|
+
expected: w.joinValues(s),
|
|
2480
|
+
received: r.parsedType,
|
|
2481
|
+
code: d.invalid_type
|
|
2482
|
+
}), y;
|
|
2483
|
+
}
|
|
2484
|
+
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
2485
|
+
const r = this._getOrReturnCtx(e), s = this._def.values;
|
|
2486
|
+
return u(r, {
|
|
2487
|
+
received: r.data,
|
|
2488
|
+
code: d.invalid_enum_value,
|
|
2489
|
+
options: s
|
|
2490
|
+
}), y;
|
|
2491
|
+
}
|
|
2492
|
+
return A(e.data);
|
|
2493
|
+
}
|
|
2494
|
+
get options() {
|
|
2495
|
+
return this._def.values;
|
|
2496
|
+
}
|
|
2497
|
+
get enum() {
|
|
2498
|
+
const e = {};
|
|
2499
|
+
for (const r of this._def.values)
|
|
2500
|
+
e[r] = r;
|
|
2501
|
+
return e;
|
|
2502
|
+
}
|
|
2503
|
+
get Values() {
|
|
2504
|
+
const e = {};
|
|
2505
|
+
for (const r of this._def.values)
|
|
2506
|
+
e[r] = r;
|
|
2507
|
+
return e;
|
|
2508
|
+
}
|
|
2509
|
+
get Enum() {
|
|
2510
|
+
const e = {};
|
|
2511
|
+
for (const r of this._def.values)
|
|
2512
|
+
e[r] = r;
|
|
2513
|
+
return e;
|
|
2514
|
+
}
|
|
2515
|
+
extract(e, r = this._def) {
|
|
2516
|
+
return ae.create(e, {
|
|
2517
|
+
...this._def,
|
|
2518
|
+
...r
|
|
2519
|
+
});
|
|
2520
|
+
}
|
|
2521
|
+
exclude(e, r = this._def) {
|
|
2522
|
+
return ae.create(this.options.filter((s) => !e.includes(s)), {
|
|
2523
|
+
...this._def,
|
|
2524
|
+
...r
|
|
2525
|
+
});
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
ae.create = bt;
|
|
2529
|
+
class ut extends k {
|
|
2530
|
+
_parse(e) {
|
|
2531
|
+
const r = w.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
2532
|
+
if (s.parsedType !== f.string && s.parsedType !== f.number) {
|
|
2533
|
+
const n = w.objectValues(r);
|
|
2534
|
+
return u(s, {
|
|
2535
|
+
expected: w.joinValues(n),
|
|
2536
|
+
received: s.parsedType,
|
|
2537
|
+
code: d.invalid_type
|
|
2538
|
+
}), y;
|
|
2539
|
+
}
|
|
2540
|
+
if (this._cache || (this._cache = new Set(w.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
2541
|
+
const n = w.objectValues(r);
|
|
2542
|
+
return u(s, {
|
|
2543
|
+
received: s.data,
|
|
2544
|
+
code: d.invalid_enum_value,
|
|
2545
|
+
options: n
|
|
2546
|
+
}), y;
|
|
2547
|
+
}
|
|
2548
|
+
return A(e.data);
|
|
2549
|
+
}
|
|
2550
|
+
get enum() {
|
|
2551
|
+
return this._def.values;
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
ut.create = (t, e) => new ut({
|
|
2555
|
+
values: t,
|
|
2556
|
+
typeName: g.ZodNativeEnum,
|
|
2557
|
+
...v(e)
|
|
2558
|
+
});
|
|
2559
|
+
class Ee extends k {
|
|
2560
|
+
unwrap() {
|
|
2561
|
+
return this._def.type;
|
|
2562
|
+
}
|
|
2563
|
+
_parse(e) {
|
|
2564
|
+
const { ctx: r } = this._processInputParams(e);
|
|
2565
|
+
if (r.parsedType !== f.promise && r.common.async === !1)
|
|
2566
|
+
return u(r, {
|
|
2567
|
+
code: d.invalid_type,
|
|
2568
|
+
expected: f.promise,
|
|
2569
|
+
received: r.parsedType
|
|
2570
|
+
}), y;
|
|
2571
|
+
const s = r.parsedType === f.promise ? r.data : Promise.resolve(r.data);
|
|
2572
|
+
return A(s.then((n) => this._def.type.parseAsync(n, {
|
|
2573
|
+
path: r.path,
|
|
2574
|
+
errorMap: r.common.contextualErrorMap
|
|
2575
|
+
})));
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
Ee.create = (t, e) => new Ee({
|
|
2579
|
+
type: t,
|
|
2580
|
+
typeName: g.ZodPromise,
|
|
2581
|
+
...v(e)
|
|
2582
|
+
});
|
|
2583
|
+
class ie extends k {
|
|
2584
|
+
innerType() {
|
|
2585
|
+
return this._def.schema;
|
|
2586
|
+
}
|
|
2587
|
+
sourceType() {
|
|
2588
|
+
return this._def.schema._def.typeName === g.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2589
|
+
}
|
|
2590
|
+
_parse(e) {
|
|
2591
|
+
const { status: r, ctx: s } = this._processInputParams(e), n = this._def.effect || null, a = {
|
|
2592
|
+
addIssue: (i) => {
|
|
2593
|
+
u(s, i), i.fatal ? r.abort() : r.dirty();
|
|
2594
|
+
},
|
|
2595
|
+
get path() {
|
|
2596
|
+
return s.path;
|
|
2597
|
+
}
|
|
2598
|
+
};
|
|
2599
|
+
if (a.addIssue = a.addIssue.bind(a), n.type === "preprocess") {
|
|
2600
|
+
const i = n.transform(s.data, a);
|
|
2601
|
+
if (s.common.async)
|
|
2602
|
+
return Promise.resolve(i).then(async (o) => {
|
|
2603
|
+
if (r.value === "aborted")
|
|
2604
|
+
return y;
|
|
2605
|
+
const c = await this._def.schema._parseAsync({
|
|
2606
|
+
data: o,
|
|
2607
|
+
path: s.path,
|
|
2608
|
+
parent: s
|
|
2609
|
+
});
|
|
2610
|
+
return c.status === "aborted" ? y : c.status === "dirty" || r.value === "dirty" ? ue(c.value) : c;
|
|
2611
|
+
});
|
|
2612
|
+
{
|
|
2613
|
+
if (r.value === "aborted")
|
|
2614
|
+
return y;
|
|
2615
|
+
const o = this._def.schema._parseSync({
|
|
2616
|
+
data: i,
|
|
2617
|
+
path: s.path,
|
|
2618
|
+
parent: s
|
|
2619
|
+
});
|
|
2620
|
+
return o.status === "aborted" ? y : o.status === "dirty" || r.value === "dirty" ? ue(o.value) : o;
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2623
|
+
if (n.type === "refinement") {
|
|
2624
|
+
const i = (o) => {
|
|
2625
|
+
const c = n.refinement(o, a);
|
|
2626
|
+
if (s.common.async)
|
|
2627
|
+
return Promise.resolve(c);
|
|
2628
|
+
if (c instanceof Promise)
|
|
2629
|
+
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2630
|
+
return o;
|
|
2631
|
+
};
|
|
2632
|
+
if (s.common.async === !1) {
|
|
2633
|
+
const o = this._def.schema._parseSync({
|
|
2634
|
+
data: s.data,
|
|
2635
|
+
path: s.path,
|
|
2636
|
+
parent: s
|
|
2637
|
+
});
|
|
2638
|
+
return o.status === "aborted" ? y : (o.status === "dirty" && r.dirty(), i(o.value), { status: r.value, value: o.value });
|
|
2639
|
+
} else
|
|
2640
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? y : (o.status === "dirty" && r.dirty(), i(o.value).then(() => ({ status: r.value, value: o.value }))));
|
|
2641
|
+
}
|
|
2642
|
+
if (n.type === "transform")
|
|
2643
|
+
if (s.common.async === !1) {
|
|
2644
|
+
const i = this._def.schema._parseSync({
|
|
2645
|
+
data: s.data,
|
|
2646
|
+
path: s.path,
|
|
2647
|
+
parent: s
|
|
2648
|
+
});
|
|
2649
|
+
if (!ne(i))
|
|
2650
|
+
return y;
|
|
2651
|
+
const o = n.transform(i.value, a);
|
|
2652
|
+
if (o instanceof Promise)
|
|
2653
|
+
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2654
|
+
return { status: r.value, value: o };
|
|
2655
|
+
} else
|
|
2656
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => ne(i) ? Promise.resolve(n.transform(i.value, a)).then((o) => ({
|
|
2657
|
+
status: r.value,
|
|
2658
|
+
value: o
|
|
2659
|
+
})) : y);
|
|
2660
|
+
w.assertNever(n);
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
ie.create = (t, e, r) => new ie({
|
|
2664
|
+
schema: t,
|
|
2665
|
+
typeName: g.ZodEffects,
|
|
2666
|
+
effect: e,
|
|
2667
|
+
...v(r)
|
|
2668
|
+
});
|
|
2669
|
+
ie.createWithPreprocess = (t, e, r) => new ie({
|
|
2670
|
+
schema: e,
|
|
2671
|
+
effect: { type: "preprocess", transform: t },
|
|
2672
|
+
typeName: g.ZodEffects,
|
|
2673
|
+
...v(r)
|
|
2674
|
+
});
|
|
2675
|
+
class U extends k {
|
|
2676
|
+
_parse(e) {
|
|
2677
|
+
return this._getType(e) === f.undefined ? A(void 0) : this._def.innerType._parse(e);
|
|
2678
|
+
}
|
|
2679
|
+
unwrap() {
|
|
2680
|
+
return this._def.innerType;
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
U.create = (t, e) => new U({
|
|
2684
|
+
innerType: t,
|
|
2685
|
+
typeName: g.ZodOptional,
|
|
2686
|
+
...v(e)
|
|
2687
|
+
});
|
|
2688
|
+
class oe extends k {
|
|
2689
|
+
_parse(e) {
|
|
2690
|
+
return this._getType(e) === f.null ? A(null) : this._def.innerType._parse(e);
|
|
2691
|
+
}
|
|
2692
|
+
unwrap() {
|
|
2693
|
+
return this._def.innerType;
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
oe.create = (t, e) => new oe({
|
|
2697
|
+
innerType: t,
|
|
2698
|
+
typeName: g.ZodNullable,
|
|
2699
|
+
...v(e)
|
|
2700
|
+
});
|
|
2701
|
+
class $e extends k {
|
|
2702
|
+
_parse(e) {
|
|
2703
|
+
const { ctx: r } = this._processInputParams(e);
|
|
2704
|
+
let s = r.data;
|
|
2705
|
+
return r.parsedType === f.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
|
|
2706
|
+
data: s,
|
|
2707
|
+
path: r.path,
|
|
2708
|
+
parent: r
|
|
2709
|
+
});
|
|
2710
|
+
}
|
|
2711
|
+
removeDefault() {
|
|
2712
|
+
return this._def.innerType;
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
$e.create = (t, e) => new $e({
|
|
2716
|
+
innerType: t,
|
|
2717
|
+
typeName: g.ZodDefault,
|
|
2718
|
+
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2719
|
+
...v(e)
|
|
2720
|
+
});
|
|
2721
|
+
class Fe extends k {
|
|
2722
|
+
_parse(e) {
|
|
2723
|
+
const { ctx: r } = this._processInputParams(e), s = {
|
|
2724
|
+
...r,
|
|
2725
|
+
common: {
|
|
2726
|
+
...r.common,
|
|
2727
|
+
issues: []
|
|
2728
|
+
}
|
|
2729
|
+
}, n = this._def.innerType._parse({
|
|
2730
|
+
data: s.data,
|
|
2731
|
+
path: s.path,
|
|
2732
|
+
parent: {
|
|
2733
|
+
...s
|
|
2734
|
+
}
|
|
2735
|
+
});
|
|
2736
|
+
return be(n) ? n.then((a) => ({
|
|
2737
|
+
status: "valid",
|
|
2738
|
+
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2739
|
+
get error() {
|
|
2740
|
+
return new M(s.common.issues);
|
|
2741
|
+
},
|
|
2742
|
+
input: s.data
|
|
2743
|
+
})
|
|
2744
|
+
})) : {
|
|
2745
|
+
status: "valid",
|
|
2746
|
+
value: n.status === "valid" ? n.value : this._def.catchValue({
|
|
2747
|
+
get error() {
|
|
2748
|
+
return new M(s.common.issues);
|
|
2749
|
+
},
|
|
2750
|
+
input: s.data
|
|
2751
|
+
})
|
|
2752
|
+
};
|
|
2753
|
+
}
|
|
2754
|
+
removeCatch() {
|
|
2755
|
+
return this._def.innerType;
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
Fe.create = (t, e) => new Fe({
|
|
2759
|
+
innerType: t,
|
|
2760
|
+
typeName: g.ZodCatch,
|
|
2761
|
+
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2762
|
+
...v(e)
|
|
2763
|
+
});
|
|
2764
|
+
class ft extends k {
|
|
2765
|
+
_parse(e) {
|
|
2766
|
+
if (this._getType(e) !== f.nan) {
|
|
2767
|
+
const s = this._getOrReturnCtx(e);
|
|
2768
|
+
return u(s, {
|
|
2769
|
+
code: d.invalid_type,
|
|
2770
|
+
expected: f.nan,
|
|
2771
|
+
received: s.parsedType
|
|
2772
|
+
}), y;
|
|
2773
|
+
}
|
|
2774
|
+
return { status: "valid", value: e.data };
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
ft.create = (t) => new ft({
|
|
2778
|
+
typeName: g.ZodNaN,
|
|
2779
|
+
...v(t)
|
|
2780
|
+
});
|
|
2781
|
+
class Lr extends k {
|
|
2782
|
+
_parse(e) {
|
|
2783
|
+
const { ctx: r } = this._processInputParams(e), s = r.data;
|
|
2784
|
+
return this._def.type._parse({
|
|
2785
|
+
data: s,
|
|
2786
|
+
path: r.path,
|
|
2787
|
+
parent: r
|
|
2788
|
+
});
|
|
2789
|
+
}
|
|
2790
|
+
unwrap() {
|
|
2791
|
+
return this._def.type;
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
class Ue extends k {
|
|
2795
|
+
_parse(e) {
|
|
2796
|
+
const { status: r, ctx: s } = this._processInputParams(e);
|
|
2797
|
+
if (s.common.async)
|
|
2798
|
+
return (async () => {
|
|
2799
|
+
const a = await this._def.in._parseAsync({
|
|
2800
|
+
data: s.data,
|
|
2801
|
+
path: s.path,
|
|
2802
|
+
parent: s
|
|
2803
|
+
});
|
|
2804
|
+
return a.status === "aborted" ? y : a.status === "dirty" ? (r.dirty(), ue(a.value)) : this._def.out._parseAsync({
|
|
2805
|
+
data: a.value,
|
|
2806
|
+
path: s.path,
|
|
2807
|
+
parent: s
|
|
2808
|
+
});
|
|
2809
|
+
})();
|
|
2810
|
+
{
|
|
2811
|
+
const n = this._def.in._parseSync({
|
|
2812
|
+
data: s.data,
|
|
2813
|
+
path: s.path,
|
|
2814
|
+
parent: s
|
|
2815
|
+
});
|
|
2816
|
+
return n.status === "aborted" ? y : n.status === "dirty" ? (r.dirty(), {
|
|
2817
|
+
status: "dirty",
|
|
2818
|
+
value: n.value
|
|
2819
|
+
}) : this._def.out._parseSync({
|
|
2820
|
+
data: n.value,
|
|
2821
|
+
path: s.path,
|
|
2822
|
+
parent: s
|
|
2823
|
+
});
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
static create(e, r) {
|
|
2827
|
+
return new Ue({
|
|
2828
|
+
in: e,
|
|
2829
|
+
out: r,
|
|
2830
|
+
typeName: g.ZodPipeline
|
|
2831
|
+
});
|
|
2832
|
+
}
|
|
2833
|
+
}
|
|
2834
|
+
class Ze extends k {
|
|
2835
|
+
_parse(e) {
|
|
2836
|
+
const r = this._def.innerType._parse(e), s = (n) => (ne(n) && (n.value = Object.freeze(n.value)), n);
|
|
2837
|
+
return be(r) ? r.then((n) => s(n)) : s(r);
|
|
2838
|
+
}
|
|
2839
|
+
unwrap() {
|
|
2840
|
+
return this._def.innerType;
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
Ze.create = (t, e) => new Ze({
|
|
2844
|
+
innerType: t,
|
|
2845
|
+
typeName: g.ZodReadonly,
|
|
2846
|
+
...v(e)
|
|
2847
|
+
});
|
|
2848
|
+
var g;
|
|
2849
|
+
(function(t) {
|
|
2850
|
+
t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline", t.ZodReadonly = "ZodReadonly";
|
|
2851
|
+
})(g || (g = {}));
|
|
2852
|
+
const xt = z.create;
|
|
2853
|
+
H.create;
|
|
2854
|
+
$.create;
|
|
2855
|
+
const St = O.create;
|
|
2856
|
+
Se.create;
|
|
2857
|
+
Oe.create;
|
|
2858
|
+
Q.create;
|
|
2859
|
+
ae.create;
|
|
2860
|
+
Ee.create;
|
|
2861
|
+
U.create;
|
|
2862
|
+
oe.create;
|
|
2863
|
+
const Le = St({
|
|
2864
|
+
detail: xt()
|
|
2865
|
+
}), Ot = St({
|
|
2866
|
+
error: xt()
|
|
2867
|
+
});
|
|
2868
|
+
function Et(t) {
|
|
2869
|
+
if (!t)
|
|
2870
|
+
return "Unknown error";
|
|
2871
|
+
if (t instanceof Error) {
|
|
2872
|
+
const e = Le.safeParse(t.cause);
|
|
2873
|
+
return e.success ? e.data.detail : Mr(t.message);
|
|
2874
|
+
}
|
|
2875
|
+
if (typeof t == "object") {
|
|
2876
|
+
const e = Le.safeParse(t);
|
|
2877
|
+
if (e.success)
|
|
2878
|
+
return e.data.detail;
|
|
2879
|
+
const r = Ot.safeParse(t);
|
|
2880
|
+
if (r.success)
|
|
2881
|
+
return r.data.error;
|
|
2882
|
+
}
|
|
2883
|
+
try {
|
|
2884
|
+
return JSON.stringify(t);
|
|
2885
|
+
} catch {
|
|
2886
|
+
return String(t);
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
function Mr(t) {
|
|
2890
|
+
const e = Dr(t);
|
|
2891
|
+
if (!e)
|
|
2892
|
+
return t;
|
|
2893
|
+
const r = Le.safeParse(e);
|
|
2894
|
+
if (r.success)
|
|
2895
|
+
return r.data.detail;
|
|
2896
|
+
const s = Ot.safeParse(e);
|
|
2897
|
+
return s.success ? s.data.error : t;
|
|
2898
|
+
}
|
|
2899
|
+
function Dr(t) {
|
|
2900
|
+
try {
|
|
2901
|
+
return JSON.parse(t);
|
|
2902
|
+
} catch {
|
|
2903
|
+
return t;
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
function Nt(t, e) {
|
|
2907
|
+
if (!t)
|
|
2908
|
+
throw new Error(e);
|
|
2909
|
+
}
|
|
2910
|
+
const Vr = "marimo-transport";
|
|
2911
|
+
function fe(t) {
|
|
2912
|
+
return t.FS;
|
|
2913
|
+
}
|
|
2914
|
+
const de = "notebook.py", le = "/marimo", K = {
|
|
2915
|
+
NOTEBOOK_FILENAME: de,
|
|
2916
|
+
HOME_DIR: le,
|
|
2917
|
+
createHomeDir: (t) => {
|
|
2918
|
+
const e = fe(t);
|
|
2919
|
+
try {
|
|
2920
|
+
e.mkdirTree(le);
|
|
2921
|
+
} catch {
|
|
2922
|
+
}
|
|
2923
|
+
e.chdir(le);
|
|
2924
|
+
},
|
|
2925
|
+
mountFS: (t) => {
|
|
2926
|
+
fe(t).mount(t.FS.filesystems.IDBFS, { root: "." }, le);
|
|
2927
|
+
},
|
|
2928
|
+
populateFilesToMemory: async (t) => {
|
|
2929
|
+
await pt(t, !0);
|
|
2930
|
+
},
|
|
2931
|
+
persistFilesToRemote: async (t) => {
|
|
2932
|
+
await pt(t, !1);
|
|
2933
|
+
},
|
|
2934
|
+
readNotebook: (t) => {
|
|
2935
|
+
const e = fe(t), r = `${le}/${de}`;
|
|
2936
|
+
return Pe(e.readFile(r));
|
|
2937
|
+
},
|
|
2938
|
+
initNotebookCode: (t) => {
|
|
2939
|
+
const { pyodide: e, filename: r, code: s } = t, n = fe(e), a = (i) => {
|
|
2940
|
+
try {
|
|
2941
|
+
return Pe(n.readFile(i));
|
|
2942
|
+
} catch {
|
|
2943
|
+
return null;
|
|
2944
|
+
}
|
|
2945
|
+
};
|
|
2946
|
+
if (r && r !== de) {
|
|
2947
|
+
const i = a(r);
|
|
2948
|
+
if (i)
|
|
2949
|
+
return {
|
|
2950
|
+
code: i,
|
|
2951
|
+
filename: r
|
|
2952
|
+
};
|
|
2953
|
+
}
|
|
2954
|
+
return n.writeFile(de, s), {
|
|
2955
|
+
code: s,
|
|
2956
|
+
filename: de
|
|
2957
|
+
};
|
|
2958
|
+
}
|
|
2959
|
+
};
|
|
2960
|
+
function pt(t, e) {
|
|
2961
|
+
return new Promise((r, s) => {
|
|
2962
|
+
fe(t).syncfs(e, (n) => {
|
|
2963
|
+
if (n instanceof Error) {
|
|
2964
|
+
s(n);
|
|
2965
|
+
return;
|
|
2966
|
+
}
|
|
2967
|
+
r();
|
|
2968
|
+
});
|
|
2969
|
+
});
|
|
2970
|
+
}
|
|
2971
|
+
var qr = Object.defineProperty, _ = (t, e) => qr(t, "name", { value: e, configurable: !0 }), Tt = ((t) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(t, { get: (e, r) => (typeof require < "u" ? require : e)[r] }) : t)(function(t) {
|
|
2972
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
2973
|
+
throw new Error('Dynamic require of "' + t + '" is not supported');
|
|
2974
|
+
});
|
|
2975
|
+
function Rt(t) {
|
|
2976
|
+
return !isNaN(parseFloat(t)) && isFinite(t);
|
|
2977
|
+
}
|
|
2978
|
+
_(Rt, "_isNumber");
|
|
2979
|
+
function W(t) {
|
|
2980
|
+
return t.charAt(0).toUpperCase() + t.substring(1);
|
|
2981
|
+
}
|
|
2982
|
+
_(W, "_capitalize");
|
|
2983
|
+
function Te(t) {
|
|
2984
|
+
return function() {
|
|
2985
|
+
return this[t];
|
|
2986
|
+
};
|
|
2987
|
+
}
|
|
2988
|
+
_(Te, "_getter");
|
|
2989
|
+
var te = ["isConstructor", "isEval", "isNative", "isToplevel"], re = ["columnNumber", "lineNumber"], se = ["fileName", "functionName", "source"], zr = ["args"], Ur = ["evalOrigin"], ve = te.concat(re, se, zr, Ur);
|
|
2990
|
+
function R(t) {
|
|
2991
|
+
if (t) for (var e = 0; e < ve.length; e++) t[ve[e]] !== void 0 && this["set" + W(ve[e])](t[ve[e]]);
|
|
2992
|
+
}
|
|
2993
|
+
_(R, "StackFrame");
|
|
2994
|
+
R.prototype = { getArgs: function() {
|
|
2995
|
+
return this.args;
|
|
2996
|
+
}, setArgs: function(t) {
|
|
2997
|
+
if (Object.prototype.toString.call(t) !== "[object Array]") throw new TypeError("Args must be an Array");
|
|
2998
|
+
this.args = t;
|
|
2999
|
+
}, getEvalOrigin: function() {
|
|
3000
|
+
return this.evalOrigin;
|
|
3001
|
+
}, setEvalOrigin: function(t) {
|
|
3002
|
+
if (t instanceof R) this.evalOrigin = t;
|
|
3003
|
+
else if (t instanceof Object) this.evalOrigin = new R(t);
|
|
3004
|
+
else throw new TypeError("Eval Origin must be an Object or StackFrame");
|
|
3005
|
+
}, toString: function() {
|
|
3006
|
+
var t = this.getFileName() || "", e = this.getLineNumber() || "", r = this.getColumnNumber() || "", s = this.getFunctionName() || "";
|
|
3007
|
+
return this.getIsEval() ? t ? "[eval] (" + t + ":" + e + ":" + r + ")" : "[eval]:" + e + ":" + r : s ? s + " (" + t + ":" + e + ":" + r + ")" : t + ":" + e + ":" + r;
|
|
3008
|
+
} };
|
|
3009
|
+
R.fromString = _(function(t) {
|
|
3010
|
+
var e = t.indexOf("("), r = t.lastIndexOf(")"), s = t.substring(0, e), n = t.substring(e + 1, r).split(","), a = t.substring(r + 1);
|
|
3011
|
+
if (a.indexOf("@") === 0) var i = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(a, ""), o = i[1], c = i[2], l = i[3];
|
|
3012
|
+
return new R({ functionName: s, args: n || void 0, fileName: o, lineNumber: c || void 0, columnNumber: l || void 0 });
|
|
3013
|
+
}, "StackFrame$$fromString");
|
|
3014
|
+
for (Y = 0; Y < te.length; Y++) R.prototype["get" + W(te[Y])] = Te(te[Y]), R.prototype["set" + W(te[Y])] = /* @__PURE__ */ function(t) {
|
|
3015
|
+
return function(e) {
|
|
3016
|
+
this[t] = !!e;
|
|
3017
|
+
};
|
|
3018
|
+
}(te[Y]);
|
|
3019
|
+
var Y;
|
|
3020
|
+
for (X = 0; X < re.length; X++) R.prototype["get" + W(re[X])] = Te(re[X]), R.prototype["set" + W(re[X])] = /* @__PURE__ */ function(t) {
|
|
3021
|
+
return function(e) {
|
|
3022
|
+
if (!Rt(e)) throw new TypeError(t + " must be a Number");
|
|
3023
|
+
this[t] = Number(e);
|
|
3024
|
+
};
|
|
3025
|
+
}(re[X]);
|
|
3026
|
+
var X;
|
|
3027
|
+
for (G = 0; G < se.length; G++) R.prototype["get" + W(se[G])] = Te(se[G]), R.prototype["set" + W(se[G])] = /* @__PURE__ */ function(t) {
|
|
3028
|
+
return function(e) {
|
|
3029
|
+
this[t] = String(e);
|
|
3030
|
+
};
|
|
3031
|
+
}(se[G]);
|
|
3032
|
+
var G, Ae = R;
|
|
3033
|
+
function Ct() {
|
|
3034
|
+
var t = /^\s*at .*(\S+:\d+|\(native\))/m, e = /^(eval@)?(\[native code])?$/;
|
|
3035
|
+
return { parse: _(function(r) {
|
|
3036
|
+
if (r.stack && r.stack.match(t)) return this.parseV8OrIE(r);
|
|
3037
|
+
if (r.stack) return this.parseFFOrSafari(r);
|
|
3038
|
+
throw new Error("Cannot parse given Error object");
|
|
3039
|
+
}, "ErrorStackParser$$parse"), extractLocation: _(function(r) {
|
|
3040
|
+
if (r.indexOf(":") === -1) return [r];
|
|
3041
|
+
var s = /(.+?)(?::(\d+))?(?::(\d+))?$/, n = s.exec(r.replace(/[()]/g, ""));
|
|
3042
|
+
return [n[1], n[2] || void 0, n[3] || void 0];
|
|
3043
|
+
}, "ErrorStackParser$$extractLocation"), parseV8OrIE: _(function(r) {
|
|
3044
|
+
var s = r.stack.split(`
|
|
3045
|
+
`).filter(function(n) {
|
|
3046
|
+
return !!n.match(t);
|
|
3047
|
+
}, this);
|
|
3048
|
+
return s.map(function(n) {
|
|
3049
|
+
n.indexOf("(eval ") > -1 && (n = n.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""));
|
|
3050
|
+
var a = n.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), i = a.match(/ (\(.+\)$)/);
|
|
3051
|
+
a = i ? a.replace(i[0], "") : a;
|
|
3052
|
+
var o = this.extractLocation(i ? i[1] : a), c = i && a || void 0, l = ["eval", "<anonymous>"].indexOf(o[0]) > -1 ? void 0 : o[0];
|
|
3053
|
+
return new Ae({ functionName: c, fileName: l, lineNumber: o[1], columnNumber: o[2], source: n });
|
|
3054
|
+
}, this);
|
|
3055
|
+
}, "ErrorStackParser$$parseV8OrIE"), parseFFOrSafari: _(function(r) {
|
|
3056
|
+
var s = r.stack.split(`
|
|
3057
|
+
`).filter(function(n) {
|
|
3058
|
+
return !n.match(e);
|
|
3059
|
+
}, this);
|
|
3060
|
+
return s.map(function(n) {
|
|
3061
|
+
if (n.indexOf(" > eval") > -1 && (n = n.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1")), n.indexOf("@") === -1 && n.indexOf(":") === -1) return new Ae({ functionName: n });
|
|
3062
|
+
var a = /((.*".+"[^@]*)?[^@]*)(?:@)/, i = n.match(a), o = i && i[1] ? i[1] : void 0, c = this.extractLocation(n.replace(a, ""));
|
|
3063
|
+
return new Ae({ functionName: o, fileName: c[0], lineNumber: c[1], columnNumber: c[2], source: n });
|
|
3064
|
+
}, this);
|
|
3065
|
+
}, "ErrorStackParser$$parseFFOrSafari") };
|
|
3066
|
+
}
|
|
3067
|
+
_(Ct, "ErrorStackParser");
|
|
3068
|
+
var Br = new Ct(), Hr = Br, F = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string" && !process.browser, At = F && typeof ze < "u" && typeof ze.exports < "u" && typeof Tt < "u" && typeof __dirname < "u", Wr = F && !At, Jr = typeof Deno < "u", Pt = !F && !Jr, Yr = Pt && typeof window == "object" && typeof document == "object" && typeof document.createElement == "function" && "sessionStorage" in window && typeof importScripts != "function", Xr = Pt && typeof importScripts == "function" && typeof self == "object";
|
|
3069
|
+
typeof navigator == "object" && typeof navigator.userAgent == "string" && navigator.userAgent.indexOf("Chrome") == -1 && navigator.userAgent.indexOf("Safari") > -1;
|
|
3070
|
+
var It, Me, jt, ht, Be;
|
|
3071
|
+
async function He() {
|
|
3072
|
+
if (!F || (It = (await import("./__vite-browser-external-CPvbk0mb.js")).default, ht = await import("./__vite-browser-external-CPvbk0mb.js"), Be = await import("./__vite-browser-external-CPvbk0mb.js"), jt = (await import("./__vite-browser-external-CPvbk0mb.js")).default, Me = await import("./__vite-browser-external-CPvbk0mb.js"), We = Me.sep, typeof Tt < "u")) return;
|
|
3073
|
+
let t = ht, e = await import("./__vite-browser-external-CPvbk0mb.js"), r = await import("./__vite-browser-external-CPvbk0mb.js"), s = await import("./__vite-browser-external-CPvbk0mb.js"), n = { fs: t, crypto: e, ws: r, child_process: s };
|
|
3074
|
+
globalThis.require = function(a) {
|
|
3075
|
+
return n[a];
|
|
3076
|
+
};
|
|
3077
|
+
}
|
|
3078
|
+
_(He, "initNodeModules");
|
|
3079
|
+
function $t(t, e) {
|
|
3080
|
+
return Me.resolve(e || ".", t);
|
|
3081
|
+
}
|
|
3082
|
+
_($t, "node_resolvePath");
|
|
3083
|
+
function Ft(t, e) {
|
|
3084
|
+
return e === void 0 && (e = location), new URL(t, e).toString();
|
|
3085
|
+
}
|
|
3086
|
+
_(Ft, "browser_resolvePath");
|
|
3087
|
+
var De;
|
|
3088
|
+
F ? De = $t : De = Ft;
|
|
3089
|
+
var We;
|
|
3090
|
+
F || (We = "/");
|
|
3091
|
+
function Zt(t, e) {
|
|
3092
|
+
return t.startsWith("file://") && (t = t.slice(7)), t.includes("://") ? { response: fetch(t) } : { binary: Be.readFile(t).then((r) => new Uint8Array(r.buffer, r.byteOffset, r.byteLength)) };
|
|
3093
|
+
}
|
|
3094
|
+
_(Zt, "node_getBinaryResponse");
|
|
3095
|
+
function Lt(t, e) {
|
|
3096
|
+
let r = new URL(t, location);
|
|
3097
|
+
return { response: fetch(r, e ? { integrity: e } : {}) };
|
|
3098
|
+
}
|
|
3099
|
+
_(Lt, "browser_getBinaryResponse");
|
|
3100
|
+
var Ne;
|
|
3101
|
+
F ? Ne = Zt : Ne = Lt;
|
|
3102
|
+
async function Mt(t, e) {
|
|
3103
|
+
let { response: r, binary: s } = Ne(t, e);
|
|
3104
|
+
if (s) return s;
|
|
3105
|
+
let n = await r;
|
|
3106
|
+
if (!n.ok) throw new Error(`Failed to load '${t}': request failed.`);
|
|
3107
|
+
return new Uint8Array(await n.arrayBuffer());
|
|
3108
|
+
}
|
|
3109
|
+
_(Mt, "loadBinaryFile");
|
|
3110
|
+
var _e;
|
|
3111
|
+
if (Yr) _e = _(async (t) => await import(t), "loadScript");
|
|
3112
|
+
else if (Xr) _e = _(async (t) => {
|
|
3113
|
+
try {
|
|
3114
|
+
globalThis.importScripts(t);
|
|
3115
|
+
} catch (e) {
|
|
3116
|
+
if (e instanceof TypeError) await import(t);
|
|
3117
|
+
else throw e;
|
|
3118
|
+
}
|
|
3119
|
+
}, "loadScript");
|
|
3120
|
+
else if (F) _e = Dt;
|
|
3121
|
+
else throw new Error("Cannot determine runtime environment");
|
|
3122
|
+
async function Dt(t) {
|
|
3123
|
+
t.startsWith("file://") && (t = t.slice(7)), t.includes("://") ? jt.runInThisContext(await (await fetch(t)).text()) : await import(It.pathToFileURL(t).href);
|
|
3124
|
+
}
|
|
3125
|
+
_(Dt, "nodeLoadScript");
|
|
3126
|
+
async function Vt(t) {
|
|
3127
|
+
if (F) {
|
|
3128
|
+
await He();
|
|
3129
|
+
let e = await Be.readFile(t, { encoding: "utf8" });
|
|
3130
|
+
return JSON.parse(e);
|
|
3131
|
+
} else return await (await fetch(t)).json();
|
|
3132
|
+
}
|
|
3133
|
+
_(Vt, "loadLockFile");
|
|
3134
|
+
async function qt() {
|
|
3135
|
+
if (At) return __dirname;
|
|
3136
|
+
let t;
|
|
3137
|
+
try {
|
|
3138
|
+
throw new Error();
|
|
3139
|
+
} catch (s) {
|
|
3140
|
+
t = s;
|
|
3141
|
+
}
|
|
3142
|
+
let e = Hr.parse(t)[0].fileName;
|
|
3143
|
+
if (F && !e.startsWith("file://") && (e = `file://${e}`), Wr) {
|
|
3144
|
+
let s = await import("./__vite-browser-external-CPvbk0mb.js");
|
|
3145
|
+
return (await import("./__vite-browser-external-CPvbk0mb.js")).fileURLToPath(s.dirname(e));
|
|
3146
|
+
}
|
|
3147
|
+
let r = e.lastIndexOf(We);
|
|
3148
|
+
if (r === -1) throw new Error("Could not extract indexURL path from pyodide module location");
|
|
3149
|
+
return e.slice(0, r);
|
|
3150
|
+
}
|
|
3151
|
+
_(qt, "calculateDirname");
|
|
3152
|
+
function zt(t) {
|
|
3153
|
+
let e = t.FS, r = t.FS.filesystems.MEMFS, s = t.PATH, n = { DIR_MODE: 16895, FILE_MODE: 33279, mount: function(a) {
|
|
3154
|
+
if (!a.opts.fileSystemHandle) throw new Error("opts.fileSystemHandle is required");
|
|
3155
|
+
return r.mount.apply(null, arguments);
|
|
3156
|
+
}, syncfs: async (a, i, o) => {
|
|
3157
|
+
try {
|
|
3158
|
+
let c = n.getLocalSet(a), l = await n.getRemoteSet(a), p = i ? l : c, x = i ? c : l;
|
|
3159
|
+
await n.reconcile(a, p, x), o(null);
|
|
3160
|
+
} catch (c) {
|
|
3161
|
+
o(c);
|
|
3162
|
+
}
|
|
3163
|
+
}, getLocalSet: (a) => {
|
|
3164
|
+
let i = /* @__PURE__ */ Object.create(null);
|
|
3165
|
+
function o(p) {
|
|
3166
|
+
return p !== "." && p !== "..";
|
|
3167
|
+
}
|
|
3168
|
+
_(o, "isRealDir");
|
|
3169
|
+
function c(p) {
|
|
3170
|
+
return (x) => s.join2(p, x);
|
|
3171
|
+
}
|
|
3172
|
+
_(c, "toAbsolute");
|
|
3173
|
+
let l = e.readdir(a.mountpoint).filter(o).map(c(a.mountpoint));
|
|
3174
|
+
for (; l.length; ) {
|
|
3175
|
+
let p = l.pop(), x = e.stat(p);
|
|
3176
|
+
e.isDir(x.mode) && l.push.apply(l, e.readdir(p).filter(o).map(c(p))), i[p] = { timestamp: x.mtime, mode: x.mode };
|
|
3177
|
+
}
|
|
3178
|
+
return { type: "local", entries: i };
|
|
3179
|
+
}, getRemoteSet: async (a) => {
|
|
3180
|
+
let i = /* @__PURE__ */ Object.create(null), o = await Gr(a.opts.fileSystemHandle);
|
|
3181
|
+
for (let [c, l] of o) c !== "." && (i[s.join2(a.mountpoint, c)] = { timestamp: l.kind === "file" ? new Date((await l.getFile()).lastModified) : /* @__PURE__ */ new Date(), mode: l.kind === "file" ? n.FILE_MODE : n.DIR_MODE });
|
|
3182
|
+
return { type: "remote", entries: i, handles: o };
|
|
3183
|
+
}, loadLocalEntry: (a) => {
|
|
3184
|
+
let i = e.lookupPath(a).node, o = e.stat(a);
|
|
3185
|
+
if (e.isDir(o.mode)) return { timestamp: o.mtime, mode: o.mode };
|
|
3186
|
+
if (e.isFile(o.mode)) return i.contents = r.getFileDataAsTypedArray(i), { timestamp: o.mtime, mode: o.mode, contents: i.contents };
|
|
3187
|
+
throw new Error("node type not supported");
|
|
3188
|
+
}, storeLocalEntry: (a, i) => {
|
|
3189
|
+
if (e.isDir(i.mode)) e.mkdirTree(a, i.mode);
|
|
3190
|
+
else if (e.isFile(i.mode)) e.writeFile(a, i.contents, { canOwn: !0 });
|
|
3191
|
+
else throw new Error("node type not supported");
|
|
3192
|
+
e.chmod(a, i.mode), e.utime(a, i.timestamp, i.timestamp);
|
|
3193
|
+
}, removeLocalEntry: (a) => {
|
|
3194
|
+
var i = e.stat(a);
|
|
3195
|
+
e.isDir(i.mode) ? e.rmdir(a) : e.isFile(i.mode) && e.unlink(a);
|
|
3196
|
+
}, loadRemoteEntry: async (a) => {
|
|
3197
|
+
if (a.kind === "file") {
|
|
3198
|
+
let i = await a.getFile();
|
|
3199
|
+
return { contents: new Uint8Array(await i.arrayBuffer()), mode: n.FILE_MODE, timestamp: new Date(i.lastModified) };
|
|
3200
|
+
} else {
|
|
3201
|
+
if (a.kind === "directory") return { mode: n.DIR_MODE, timestamp: /* @__PURE__ */ new Date() };
|
|
3202
|
+
throw new Error("unknown kind: " + a.kind);
|
|
3203
|
+
}
|
|
3204
|
+
}, storeRemoteEntry: async (a, i, o) => {
|
|
3205
|
+
let c = a.get(s.dirname(i)), l = e.isFile(o.mode) ? await c.getFileHandle(s.basename(i), { create: !0 }) : await c.getDirectoryHandle(s.basename(i), { create: !0 });
|
|
3206
|
+
if (l.kind === "file") {
|
|
3207
|
+
let p = await l.createWritable();
|
|
3208
|
+
await p.write(o.contents), await p.close();
|
|
3209
|
+
}
|
|
3210
|
+
a.set(i, l);
|
|
3211
|
+
}, removeRemoteEntry: async (a, i) => {
|
|
3212
|
+
await a.get(s.dirname(i)).removeEntry(s.basename(i)), a.delete(i);
|
|
3213
|
+
}, reconcile: async (a, i, o) => {
|
|
3214
|
+
let c = 0, l = [];
|
|
3215
|
+
Object.keys(i.entries).forEach(function(S) {
|
|
3216
|
+
let P = i.entries[S], Z = o.entries[S];
|
|
3217
|
+
(!Z || e.isFile(P.mode) && P.timestamp.getTime() > Z.timestamp.getTime()) && (l.push(S), c++);
|
|
3218
|
+
}), l.sort();
|
|
3219
|
+
let p = [];
|
|
3220
|
+
if (Object.keys(o.entries).forEach(function(S) {
|
|
3221
|
+
i.entries[S] || (p.push(S), c++);
|
|
3222
|
+
}), p.sort().reverse(), !c) return;
|
|
3223
|
+
let x = i.type === "remote" ? i.handles : o.handles;
|
|
3224
|
+
for (let S of l) {
|
|
3225
|
+
let P = s.normalize(S.replace(a.mountpoint, "/")).substring(1);
|
|
3226
|
+
if (o.type === "local") {
|
|
3227
|
+
let Z = x.get(P), ye = await n.loadRemoteEntry(Z);
|
|
3228
|
+
n.storeLocalEntry(S, ye);
|
|
3229
|
+
} else {
|
|
3230
|
+
let Z = n.loadLocalEntry(S);
|
|
3231
|
+
await n.storeRemoteEntry(x, P, Z);
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
for (let S of p) if (o.type === "local") n.removeLocalEntry(S);
|
|
3235
|
+
else {
|
|
3236
|
+
let P = s.normalize(S.replace(a.mountpoint, "/")).substring(1);
|
|
3237
|
+
await n.removeRemoteEntry(x, P);
|
|
3238
|
+
}
|
|
3239
|
+
} };
|
|
3240
|
+
t.FS.filesystems.NATIVEFS_ASYNC = n;
|
|
3241
|
+
}
|
|
3242
|
+
_(zt, "initializeNativeFS");
|
|
3243
|
+
var Gr = _(async (t) => {
|
|
3244
|
+
let e = [];
|
|
3245
|
+
async function r(n) {
|
|
3246
|
+
for await (let a of n.values()) e.push(a), a.kind === "directory" && await r(a);
|
|
3247
|
+
}
|
|
3248
|
+
_(r, "collect"), await r(t);
|
|
3249
|
+
let s = /* @__PURE__ */ new Map();
|
|
3250
|
+
s.set(".", t);
|
|
3251
|
+
for (let n of e) {
|
|
3252
|
+
let a = (await t.resolve(n)).join("/");
|
|
3253
|
+
s.set(a, n);
|
|
3254
|
+
}
|
|
3255
|
+
return s;
|
|
3256
|
+
}, "getFsHandles");
|
|
3257
|
+
function Ut(t) {
|
|
3258
|
+
let e = { noImageDecoding: !0, noAudioDecoding: !0, noWasmDecoding: !1, preRun: Yt(t), quit(r, s) {
|
|
3259
|
+
throw e.exited = { status: r, toThrow: s }, s;
|
|
3260
|
+
}, print: t.stdout, printErr: t.stderr, thisProgram: t._sysExecutable, arguments: t.args, API: { config: t }, locateFile: (r) => t.indexURL + r, instantiateWasm: Xt(t.indexURL) };
|
|
3261
|
+
return e;
|
|
3262
|
+
}
|
|
3263
|
+
_(Ut, "createSettings");
|
|
3264
|
+
function Bt(t) {
|
|
3265
|
+
return function(e) {
|
|
3266
|
+
let r = "/";
|
|
3267
|
+
try {
|
|
3268
|
+
e.FS.mkdirTree(t);
|
|
3269
|
+
} catch (s) {
|
|
3270
|
+
console.error(`Error occurred while making a home directory '${t}':`), console.error(s), console.error(`Using '${r}' for a home directory instead`), t = r;
|
|
3271
|
+
}
|
|
3272
|
+
e.FS.chdir(t);
|
|
3273
|
+
};
|
|
3274
|
+
}
|
|
3275
|
+
_(Bt, "createHomeDirectory");
|
|
3276
|
+
function Ht(t) {
|
|
3277
|
+
return function(e) {
|
|
3278
|
+
Object.assign(e.ENV, t);
|
|
3279
|
+
};
|
|
3280
|
+
}
|
|
3281
|
+
_(Ht, "setEnvironment");
|
|
3282
|
+
function Wt(t) {
|
|
3283
|
+
return t ? [async (e) => {
|
|
3284
|
+
e.addRunDependency("fsInitHook");
|
|
3285
|
+
try {
|
|
3286
|
+
await t(e.FS, { sitePackages: e.API.sitePackages });
|
|
3287
|
+
} finally {
|
|
3288
|
+
e.removeRunDependency("fsInitHook");
|
|
3289
|
+
}
|
|
3290
|
+
}] : [];
|
|
3291
|
+
}
|
|
3292
|
+
_(Wt, "callFsInitHook");
|
|
3293
|
+
function Jt(t) {
|
|
3294
|
+
let e = Mt(t);
|
|
3295
|
+
return async (r) => {
|
|
3296
|
+
let s = r._py_version_major(), n = r._py_version_minor();
|
|
3297
|
+
r.FS.mkdirTree("/lib"), r.API.sitePackages = `/lib/python${s}.${n}/site-packages`, r.FS.mkdirTree(r.API.sitePackages), r.addRunDependency("install-stdlib");
|
|
3298
|
+
try {
|
|
3299
|
+
let a = await e;
|
|
3300
|
+
r.FS.writeFile(`/lib/python${s}${n}.zip`, a);
|
|
3301
|
+
} catch (a) {
|
|
3302
|
+
console.error("Error occurred while installing the standard library:"), console.error(a);
|
|
3303
|
+
} finally {
|
|
3304
|
+
r.removeRunDependency("install-stdlib");
|
|
3305
|
+
}
|
|
3306
|
+
};
|
|
3307
|
+
}
|
|
3308
|
+
_(Jt, "installStdlib");
|
|
3309
|
+
function Yt(t) {
|
|
3310
|
+
let e;
|
|
3311
|
+
return t.stdLibURL != null ? e = t.stdLibURL : e = t.indexURL + "python_stdlib.zip", [...Wt(t.fsInit), Jt(e), Bt(t.env.HOME), Ht(t.env), zt];
|
|
3312
|
+
}
|
|
3313
|
+
_(Yt, "getFileSystemInitializationFuncs");
|
|
3314
|
+
function Xt(t) {
|
|
3315
|
+
if (typeof WasmOffsetConverter < "u") return;
|
|
3316
|
+
let { binary: e, response: r } = Ne(t + "pyodide.asm.wasm");
|
|
3317
|
+
return function(s, n) {
|
|
3318
|
+
return async function() {
|
|
3319
|
+
try {
|
|
3320
|
+
let a;
|
|
3321
|
+
r ? a = await WebAssembly.instantiateStreaming(r, s) : a = await WebAssembly.instantiate(await e, s);
|
|
3322
|
+
let { instance: i, module: o } = a;
|
|
3323
|
+
n(i, o);
|
|
3324
|
+
} catch (a) {
|
|
3325
|
+
console.warn("wasm instantiation failed!"), console.warn(a);
|
|
3326
|
+
}
|
|
3327
|
+
}(), {};
|
|
3328
|
+
};
|
|
3329
|
+
}
|
|
3330
|
+
_(Xt, "getInstantiateWasmFunc");
|
|
3331
|
+
var Ve = "0.27.7";
|
|
3332
|
+
async function qe(t = {}) {
|
|
3333
|
+
var e, r;
|
|
3334
|
+
await He();
|
|
3335
|
+
let s = t.indexURL || await qt();
|
|
3336
|
+
s = De(s), s.endsWith("/") || (s += "/"), t.indexURL = s;
|
|
3337
|
+
let n = { fullStdLib: !1, jsglobals: globalThis, stdin: globalThis.prompt ? globalThis.prompt : void 0, lockFileURL: s + "pyodide-lock.json", args: [], env: {}, packageCacheDir: s, packages: [], enableRunUntilComplete: !0, checkAPIVersion: !0, BUILD_ID: "e94377f5ce7dcf67e0417b69a0016733c2cfb6b4622ee8c490a6f17eb58e863b" }, a = Object.assign(n, t);
|
|
3338
|
+
(e = a.env).HOME ?? (e.HOME = "/home/pyodide"), (r = a.env).PYTHONINSPECT ?? (r.PYTHONINSPECT = "1");
|
|
3339
|
+
let i = Ut(a), o = i.API;
|
|
3340
|
+
if (o.lockFilePromise = Vt(a.lockFileURL), typeof _createPyodideModule != "function") {
|
|
3341
|
+
let S = `${a.indexURL}pyodide.asm.js`;
|
|
3342
|
+
await _e(S);
|
|
3343
|
+
}
|
|
3344
|
+
let c;
|
|
3345
|
+
if (t._loadSnapshot) {
|
|
3346
|
+
let S = await t._loadSnapshot;
|
|
3347
|
+
ArrayBuffer.isView(S) ? c = S : c = new Uint8Array(S), i.noInitialRun = !0, i.INITIAL_MEMORY = c.length;
|
|
3348
|
+
}
|
|
3349
|
+
let l = await _createPyodideModule(i);
|
|
3350
|
+
if (i.exited) throw i.exited.toThrow;
|
|
3351
|
+
if (t.pyproxyToStringRepr && o.setPyProxyToStringMethod(!0), o.version !== Ve && a.checkAPIVersion) throw new Error(`Pyodide version does not match: '${Ve}' <==> '${o.version}'. If you updated the Pyodide version, make sure you also updated the 'indexURL' parameter passed to loadPyodide.`);
|
|
3352
|
+
l.locateFile = (S) => {
|
|
3353
|
+
throw new Error("Didn't expect to load any more file_packager files!");
|
|
3354
|
+
};
|
|
3355
|
+
let p;
|
|
3356
|
+
c && (p = o.restoreSnapshot(c));
|
|
3357
|
+
let x = o.finalizeBootstrap(p, t._snapshotDeserializer);
|
|
3358
|
+
return o.sys.path.insert(0, ""), x.version.includes("dev") || o.setCdnUrl(`https://cdn.jsdelivr.net/pyodide/v${x.version}/full/`), o._pyodide.set_excepthook(), await o.packageIndexReady, o.initializeStreams(a.stdin, a.stdout, a.stderr), x;
|
|
3359
|
+
}
|
|
3360
|
+
_(qe, "loadPyodide");
|
|
3361
|
+
class Kr {
|
|
3362
|
+
spans = [];
|
|
3363
|
+
startSpan(e, r = {}) {
|
|
3364
|
+
const s = {
|
|
3365
|
+
name: e,
|
|
3366
|
+
startTime: Date.now(),
|
|
3367
|
+
attributes: r,
|
|
3368
|
+
end: (n = "ok") => this.endSpan(s, n)
|
|
3369
|
+
};
|
|
3370
|
+
return this.spans.push(s), s;
|
|
3371
|
+
}
|
|
3372
|
+
endSpan(e, r = "ok") {
|
|
3373
|
+
e.endTime = Date.now(), e.status = r;
|
|
3374
|
+
}
|
|
3375
|
+
getSpans() {
|
|
3376
|
+
return this.spans;
|
|
3377
|
+
}
|
|
3378
|
+
wrap(e, r, s = {}) {
|
|
3379
|
+
const n = this.startSpan(r || e.name, s);
|
|
3380
|
+
try {
|
|
3381
|
+
const a = e();
|
|
3382
|
+
return this.endSpan(n), a;
|
|
3383
|
+
} catch (a) {
|
|
3384
|
+
throw this.endSpan(n, "error"), a;
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
wrapAsync(e, r, s = {}) {
|
|
3388
|
+
return async (...n) => {
|
|
3389
|
+
const a = this.startSpan(r || e.name, s);
|
|
3390
|
+
try {
|
|
3391
|
+
const i = await e(...n);
|
|
3392
|
+
return this.endSpan(a), i;
|
|
3393
|
+
} catch (i) {
|
|
3394
|
+
throw this.endSpan(a, "error"), i;
|
|
3395
|
+
}
|
|
3396
|
+
};
|
|
3397
|
+
}
|
|
3398
|
+
logSpans() {
|
|
3399
|
+
}
|
|
3400
|
+
}
|
|
3401
|
+
const T = new Kr();
|
|
3402
|
+
globalThis.t = T;
|
|
3403
|
+
const Qr = !1;
|
|
3404
|
+
class es {
|
|
3405
|
+
pyodide = null;
|
|
3406
|
+
get requirePyodide() {
|
|
3407
|
+
return Nt(this.pyodide, "Pyodide not loaded"), this.pyodide;
|
|
3408
|
+
}
|
|
3409
|
+
async bootstrap(e) {
|
|
3410
|
+
return await this.loadPyodideAndPackages(e);
|
|
3411
|
+
}
|
|
3412
|
+
async loadPyodideAndPackages(e) {
|
|
3413
|
+
if (!qe)
|
|
3414
|
+
throw new Error("loadPyodide is not defined");
|
|
3415
|
+
const r = T.startSpan("loadPyodide");
|
|
3416
|
+
try {
|
|
3417
|
+
const s = await qe({
|
|
3418
|
+
// Perf: These get loaded while pyodide is being bootstrapped
|
|
3419
|
+
packages: [
|
|
3420
|
+
"micropip",
|
|
3421
|
+
"marimo-base",
|
|
3422
|
+
"Markdown",
|
|
3423
|
+
"pymdown-extensions",
|
|
3424
|
+
"narwhals",
|
|
3425
|
+
"packaging"
|
|
3426
|
+
],
|
|
3427
|
+
_makeSnapshot: Qr,
|
|
3428
|
+
lockFileURL: `https://wasm.marimo.app/pyodide-lock.json?v=${e.version}&pyodide=${e.pyodideVersion}`,
|
|
3429
|
+
// Without this, this fails in Firefox with
|
|
3430
|
+
// `Could not extract indexURL path from pyodide module`
|
|
3431
|
+
// This fixes for Firefox and does not break Chrome/others
|
|
3432
|
+
indexURL: `https://cdn.jsdelivr.net/pyodide/${e.pyodideVersion}/full/`
|
|
3433
|
+
});
|
|
3434
|
+
return this.pyodide = s, r.end("ok"), s;
|
|
3435
|
+
} catch (s) {
|
|
3436
|
+
throw q.error("Failed to load Pyodide", s), s;
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3439
|
+
async mountFilesystem(e) {
|
|
3440
|
+
const r = T.startSpan("mountFilesystem");
|
|
3441
|
+
return K.createHomeDir(this.requirePyodide), K.mountFS(this.requirePyodide), await K.populateFilesToMemory(this.requirePyodide), r.end("ok"), K.initNotebookCode({
|
|
3442
|
+
pyodide: this.requirePyodide,
|
|
3443
|
+
code: e.code,
|
|
3444
|
+
filename: e.filename
|
|
3445
|
+
});
|
|
3446
|
+
}
|
|
3447
|
+
async startSession(e) {
|
|
3448
|
+
const { code: r, filename: s, onMessage: n, queryParameters: a, userConfig: i } = e;
|
|
3449
|
+
self.messenger = {
|
|
3450
|
+
callback: n
|
|
3451
|
+
}, self.query_params = a, self.user_config = i;
|
|
3452
|
+
const o = T.startSpan("startSession.runPython"), c = s || K.NOTEBOOK_FILENAME, [l, p, x] = this.requirePyodide.runPython(
|
|
3453
|
+
`
|
|
3454
|
+
print("[py] Starting marimo...")
|
|
3455
|
+
import asyncio
|
|
3456
|
+
import js
|
|
3457
|
+
from marimo._pyodide.bootstrap import create_session, instantiate
|
|
3458
|
+
|
|
3459
|
+
assert js.messenger, "messenger is not defined"
|
|
3460
|
+
assert js.query_params, "query_params is not defined"
|
|
3461
|
+
|
|
3462
|
+
session, bridge = create_session(
|
|
3463
|
+
filename="${c}",
|
|
3464
|
+
query_params=js.query_params.to_py(),
|
|
3465
|
+
message_callback=js.messenger.callback,
|
|
3466
|
+
user_config=js.user_config.to_py(),
|
|
3467
|
+
)
|
|
3468
|
+
|
|
3469
|
+
def init(auto_instantiate=True):
|
|
3470
|
+
instantiate(session, auto_instantiate)
|
|
3471
|
+
asyncio.create_task(session.start())
|
|
3472
|
+
|
|
3473
|
+
# Find the packages to install
|
|
3474
|
+
with open("${c}", "r") as f:
|
|
3475
|
+
packages = session.find_packages(f.read())
|
|
3476
|
+
|
|
3477
|
+
bridge, init, packages`
|
|
3478
|
+
);
|
|
3479
|
+
o.end();
|
|
3480
|
+
const S = new Set(x.toJs());
|
|
3481
|
+
return this.loadNotebookDeps(r, S).then(() => p(i.runtime.auto_instantiate)), l;
|
|
3482
|
+
}
|
|
3483
|
+
async loadNotebookDeps(e, r) {
|
|
3484
|
+
const s = this.requirePyodide;
|
|
3485
|
+
e.includes("mo.sql") && (e = `import pandas
|
|
3486
|
+
${e}`, e = `import duckdb
|
|
3487
|
+
${e}`, e = `import sqlglot
|
|
3488
|
+
${e}`, e.includes("polars") && (e = `import pyarrow
|
|
3489
|
+
${e}`)), e = `import docutils
|
|
3490
|
+
${e}`, e = `import pygments
|
|
3491
|
+
${e}`, e = `import jedi
|
|
3492
|
+
${e}`, e = `import pyodide_http
|
|
3493
|
+
${e}`;
|
|
3494
|
+
const n = [...r];
|
|
3495
|
+
let a = T.startSpan("pyodide.loadPackage");
|
|
3496
|
+
await s.loadPackagesFromImports(e, {
|
|
3497
|
+
errorCallback: q.error,
|
|
3498
|
+
messageCallback: q.log
|
|
3499
|
+
}), a.end(), a = T.startSpan("micropip.install");
|
|
3500
|
+
const i = n.filter(
|
|
3501
|
+
(o) => !s.loadedPackages[o]
|
|
3502
|
+
);
|
|
3503
|
+
i.length > 0 && await s.runPythonAsync(`
|
|
3504
|
+
import micropip
|
|
3505
|
+
import sys
|
|
3506
|
+
# Filter out builtins
|
|
3507
|
+
missing = [p for p in ${JSON.stringify(i)} if p not in sys.modules]
|
|
3508
|
+
if len(missing) > 0:
|
|
3509
|
+
print("Loading from micropip:", missing)
|
|
3510
|
+
await micropip.install(missing)
|
|
3511
|
+
`).catch((o) => {
|
|
3512
|
+
q.error("Failed to load packages from micropip", o);
|
|
3513
|
+
}), a.end();
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
async function ts(t) {
|
|
3517
|
+
try {
|
|
3518
|
+
return await import(
|
|
3519
|
+
/* @vite-ignore */
|
|
3520
|
+
`/wasm/controller.js?version=${t}`
|
|
3521
|
+
);
|
|
3522
|
+
} catch {
|
|
3523
|
+
return new es();
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
const rs = !1;
|
|
3527
|
+
function ss(t) {
|
|
3528
|
+
return t.includes("dev") && rs ? "dev" : `v${Ve}`;
|
|
3529
|
+
}
|
|
3530
|
+
class ns {
|
|
3531
|
+
constructor(e) {
|
|
3532
|
+
this.onMessage = e, this.buffer = [];
|
|
3533
|
+
}
|
|
3534
|
+
buffer;
|
|
3535
|
+
started = !1;
|
|
3536
|
+
push = (e) => {
|
|
3537
|
+
this.started ? this.onMessage(e) : this.buffer.push(e);
|
|
3538
|
+
};
|
|
3539
|
+
/**
|
|
3540
|
+
* Start processing messages
|
|
3541
|
+
*/
|
|
3542
|
+
start = () => {
|
|
3543
|
+
this.started = !0, this.buffer.forEach((e) => this.onMessage(e)), this.buffer = [];
|
|
3544
|
+
};
|
|
3545
|
+
}
|
|
3546
|
+
const mt = T.startSpan("worker:init");
|
|
3547
|
+
async function as() {
|
|
3548
|
+
try {
|
|
3549
|
+
const t = cs(), e = ss(t), r = await T.wrapAsync(ts)(t);
|
|
3550
|
+
self.controller = r, L.send.initializingMessage({
|
|
3551
|
+
message: "Loading marimo..."
|
|
3552
|
+
}), self.pyodide = await T.wrapAsync(r.bootstrap.bind(r))({
|
|
3553
|
+
version: t,
|
|
3554
|
+
pyodideVersion: e
|
|
3555
|
+
});
|
|
3556
|
+
} catch (t) {
|
|
3557
|
+
q.error("Error bootstrapping", t), L.send.initializedError({
|
|
3558
|
+
error: Et(t)
|
|
3559
|
+
});
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
const Gt = new ns(
|
|
3563
|
+
(t) => {
|
|
3564
|
+
L.send.kernelMessage({ message: t });
|
|
3565
|
+
}
|
|
3566
|
+
), yt = new fr();
|
|
3567
|
+
let gt = !1;
|
|
3568
|
+
const is = {
|
|
3569
|
+
/**
|
|
3570
|
+
* Start the session
|
|
3571
|
+
*/
|
|
3572
|
+
startSession: async (t) => {
|
|
3573
|
+
if (await j, gt) {
|
|
3574
|
+
q.warn("Session already started");
|
|
3575
|
+
return;
|
|
3576
|
+
}
|
|
3577
|
+
gt = !0;
|
|
3578
|
+
try {
|
|
3579
|
+
Nt(self.controller, "Controller not loaded"), await self.controller.mountFilesystem?.({
|
|
3580
|
+
code: t.code,
|
|
3581
|
+
filename: t.filename
|
|
3582
|
+
});
|
|
3583
|
+
const e = T.wrapAsync(
|
|
3584
|
+
self.controller.startSession.bind(self.controller)
|
|
3585
|
+
), r = lr(() => {
|
|
3586
|
+
L.send.initializingMessage({
|
|
3587
|
+
message: "Initializing notebook..."
|
|
3588
|
+
}), L.send.initialized({});
|
|
3589
|
+
});
|
|
3590
|
+
L.send.initializingMessage({
|
|
3591
|
+
message: "Loading notebook and dependencies..."
|
|
3592
|
+
});
|
|
3593
|
+
const s = await e({
|
|
3594
|
+
code: t.code,
|
|
3595
|
+
filename: t.filename,
|
|
3596
|
+
queryParameters: t.queryParameters,
|
|
3597
|
+
userConfig: t.userConfig,
|
|
3598
|
+
onMessage: (n) => {
|
|
3599
|
+
r(), Gt.push(n);
|
|
3600
|
+
}
|
|
3601
|
+
});
|
|
3602
|
+
yt.resolve(s), mt.end("ok");
|
|
3603
|
+
} catch (e) {
|
|
3604
|
+
L.send.initializedError({
|
|
3605
|
+
error: Et(e)
|
|
3606
|
+
}), mt.end("error");
|
|
3607
|
+
}
|
|
3608
|
+
},
|
|
3609
|
+
/**
|
|
3610
|
+
* Load packages
|
|
3611
|
+
*/
|
|
3612
|
+
loadPackages: async (t) => {
|
|
3613
|
+
const e = T.startSpan("loadPackages");
|
|
3614
|
+
await j, t.includes("mo.sql") && (t = `import pandas
|
|
3615
|
+
${t}`, t = `import duckdb
|
|
3616
|
+
${t}`, t = `import sqlglot
|
|
3617
|
+
${t}`, t.includes("polars") && (t = `import pyarrow
|
|
3618
|
+
${t}`)), await self.pyodide.loadPackagesFromImports(t, {
|
|
3619
|
+
messageCallback: q.log,
|
|
3620
|
+
errorCallback: q.error
|
|
3621
|
+
}), e.end();
|
|
3622
|
+
},
|
|
3623
|
+
/**
|
|
3624
|
+
* Read a file
|
|
3625
|
+
*/
|
|
3626
|
+
readFile: async (t) => {
|
|
3627
|
+
const e = T.startSpan("readFile");
|
|
3628
|
+
await j;
|
|
3629
|
+
const r = Pe(self.pyodide.FS.readFile(t));
|
|
3630
|
+
return e.end(), r;
|
|
3631
|
+
},
|
|
3632
|
+
/**
|
|
3633
|
+
* Set the interrupt buffer
|
|
3634
|
+
*/
|
|
3635
|
+
setInterruptBuffer: async (t) => {
|
|
3636
|
+
await j, self.pyodide.setInterruptBuffer(t);
|
|
3637
|
+
},
|
|
3638
|
+
addPackage: async (t) => {
|
|
3639
|
+
await j;
|
|
3640
|
+
const { package: e } = t, r = e.split(" ").map((n) => n.trim()), s = await self.pyodide.runPythonAsync(`
|
|
3641
|
+
import micropip
|
|
3642
|
+
import json
|
|
3643
|
+
response = None
|
|
3644
|
+
try:
|
|
3645
|
+
await micropip.install(${JSON.stringify(r)})
|
|
3646
|
+
response = {"success": True}
|
|
3647
|
+
except Exception as e:
|
|
3648
|
+
response = {"success": False, "error": str(e)}
|
|
3649
|
+
json.dumps(response)
|
|
3650
|
+
`);
|
|
3651
|
+
return JSON.parse(s);
|
|
3652
|
+
},
|
|
3653
|
+
removePackage: async (t) => {
|
|
3654
|
+
await j;
|
|
3655
|
+
const { package: e } = t, r = await self.pyodide.runPythonAsync(`
|
|
3656
|
+
import micropip
|
|
3657
|
+
import json
|
|
3658
|
+
response = None
|
|
3659
|
+
try:
|
|
3660
|
+
micropip.uninstall("${e}")
|
|
3661
|
+
response = {"success": True}
|
|
3662
|
+
except Exception as e:
|
|
3663
|
+
response = {"success": False, "error": str(e)}
|
|
3664
|
+
json.dumps(response)
|
|
3665
|
+
`);
|
|
3666
|
+
return JSON.parse(r);
|
|
3667
|
+
},
|
|
3668
|
+
listPackages: async () => {
|
|
3669
|
+
const t = T.startSpan("listPackages");
|
|
3670
|
+
await j;
|
|
3671
|
+
const e = await self.pyodide.runPythonAsync(`
|
|
3672
|
+
import json
|
|
3673
|
+
import micropip
|
|
3674
|
+
|
|
3675
|
+
packages = micropip.list()
|
|
3676
|
+
packages = [
|
|
3677
|
+
{"name": p.name, "version": p.version}
|
|
3678
|
+
for p in packages.values()
|
|
3679
|
+
]
|
|
3680
|
+
json.dumps(sorted(packages, key=lambda pkg: pkg["name"]))
|
|
3681
|
+
`);
|
|
3682
|
+
return t.end(), {
|
|
3683
|
+
packages: JSON.parse(e)
|
|
3684
|
+
};
|
|
3685
|
+
},
|
|
3686
|
+
/**
|
|
3687
|
+
* Save the notebook
|
|
3688
|
+
*/
|
|
3689
|
+
saveNotebook: async (t) => {
|
|
3690
|
+
await j, await self.pyodide.runPython(`
|
|
3691
|
+
from marimo._pyodide.bootstrap import save_file
|
|
3692
|
+
save_file
|
|
3693
|
+
`)(JSON.stringify(t), K.NOTEBOOK_FILENAME);
|
|
3694
|
+
},
|
|
3695
|
+
/**
|
|
3696
|
+
* Call a function on the bridge
|
|
3697
|
+
*/
|
|
3698
|
+
bridge: async (t) => {
|
|
3699
|
+
const e = T.startSpan("bridge", {
|
|
3700
|
+
functionName: t.functionName
|
|
3701
|
+
});
|
|
3702
|
+
await j;
|
|
3703
|
+
const { functionName: r, payload: s } = t;
|
|
3704
|
+
r === "format" && await self.pyodide.runPythonAsync(`
|
|
3705
|
+
import micropip
|
|
3706
|
+
|
|
3707
|
+
try:
|
|
3708
|
+
import black
|
|
3709
|
+
except ModuleNotFoundError:
|
|
3710
|
+
await micropip.install("black")
|
|
3711
|
+
`), r === "export_markdown" && await self.pyodide.runPythonAsync(`
|
|
3712
|
+
import micropip
|
|
3713
|
+
|
|
3714
|
+
try:
|
|
3715
|
+
import yaml
|
|
3716
|
+
except ModuleNotFoundError:
|
|
3717
|
+
await micropip.install("pyyaml")
|
|
3718
|
+
`);
|
|
3719
|
+
const n = await yt.promise, a = s == null ? null : typeof s == "string" ? s : JSON.stringify(s), i = a == null ? (
|
|
3720
|
+
// @ts-expect-error ehh TypeScript
|
|
3721
|
+
await n[r]()
|
|
3722
|
+
) : (
|
|
3723
|
+
// @ts-expect-error ehh TypeScript
|
|
3724
|
+
await n[r](a)
|
|
3725
|
+
);
|
|
3726
|
+
return os.has(r) && K.persistFilesToRemote(self.pyodide), e.end(), typeof i == "string" ? JSON.parse(i) : i;
|
|
3727
|
+
}
|
|
3728
|
+
}, L = ar({
|
|
3729
|
+
transport: dr({
|
|
3730
|
+
transportId: Vr
|
|
3731
|
+
}),
|
|
3732
|
+
requestHandler: is
|
|
3733
|
+
});
|
|
3734
|
+
L.send("ready", {});
|
|
3735
|
+
L.addMessageListener("consumerReady", async () => {
|
|
3736
|
+
await j, Gt.start();
|
|
3737
|
+
});
|
|
3738
|
+
const os = /* @__PURE__ */ new Set([
|
|
3739
|
+
"save",
|
|
3740
|
+
"save_app_config",
|
|
3741
|
+
"rename_file",
|
|
3742
|
+
"create_file_or_directory",
|
|
3743
|
+
"delete_file_or_directory",
|
|
3744
|
+
"move_file_or_directory",
|
|
3745
|
+
"update_file"
|
|
3746
|
+
]);
|
|
3747
|
+
function cs() {
|
|
3748
|
+
return self.name;
|
|
3749
|
+
}
|
|
3750
|
+
const j = T.wrapAsync(as)();
|
|
3751
|
+
});
|
|
3752
|
+
export default ds();
|