@marimo-team/islands 0.14.11-dev49 → 0.14.11-dev5

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