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