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