@mdocui/react 0.1.1

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/index.js ADDED
@@ -0,0 +1,5033 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/renderer.tsx
8
+ import { useMemo } from "react";
9
+
10
+ // src/context.ts
11
+ import { createContext, useContext } from "react";
12
+ var MdocUIContext = createContext(null);
13
+ var MdocUIProvider = MdocUIContext.Provider;
14
+ function useMdocUI() {
15
+ const ctx = useContext(MdocUIContext);
16
+ if (!ctx) throw new Error("useMdocUI must be used inside <Renderer />");
17
+ return ctx;
18
+ }
19
+
20
+ // src/renderer.tsx
21
+ import { jsx } from "react/jsx-runtime";
22
+ function Renderer({
23
+ nodes,
24
+ components,
25
+ onAction = noop,
26
+ isStreaming = false,
27
+ renderProse
28
+ }) {
29
+ const ctx = useMemo(
30
+ () => ({ components, onAction, isStreaming }),
31
+ [components, onAction, isStreaming]
32
+ );
33
+ return /* @__PURE__ */ jsx(MdocUIProvider, { value: ctx, children: /* @__PURE__ */ jsx("div", { "data-mdocui": true, children: nodes.map((node, i) => renderNode(node, `n-${i}`, ctx, renderProse)) }) });
34
+ }
35
+ function renderNode(node, key, ctx, renderProse) {
36
+ if (node.type === "prose") return renderProseNode(node, key, renderProse);
37
+ return renderComponentNode(node, key, ctx, renderProse);
38
+ }
39
+ function renderProseNode(node, key, renderProse) {
40
+ if (renderProse) return renderProse(node.content, key);
41
+ return /* @__PURE__ */ jsx("span", { "data-mdocui-prose": true, children: node.content }, key);
42
+ }
43
+ function renderComponentNode(node, key, ctx, renderProse) {
44
+ const Component = ctx.components[node.name];
45
+ if (!Component) return null;
46
+ const children = node.children.length > 0 ? node.children.map((child, i) => renderNode(child, `${key}-${i}`, ctx, renderProse)) : void 0;
47
+ return /* @__PURE__ */ jsx(
48
+ Component,
49
+ {
50
+ name: node.name,
51
+ props: node.props,
52
+ onAction: ctx.onAction,
53
+ isStreaming: ctx.isStreaming,
54
+ children
55
+ },
56
+ key
57
+ );
58
+ }
59
+ function noop() {
60
+ }
61
+
62
+ // src/use-renderer.ts
63
+ import { StreamingParser } from "@mdocui/core";
64
+ import { useCallback, useRef, useState } from "react";
65
+ function useRenderer({ registry }) {
66
+ const parserRef = useRef(null);
67
+ const registryRef = useRef(registry);
68
+ registryRef.current = registry;
69
+ const streamingRef = useRef(false);
70
+ const [nodes, setNodes] = useState([]);
71
+ const [meta, setMeta] = useState({ errors: [], nodeCount: 0, isComplete: true });
72
+ const [isStreaming, setIsStreaming] = useState(false);
73
+ const getParser = useCallback(() => {
74
+ if (!parserRef.current) {
75
+ parserRef.current = new StreamingParser({
76
+ knownTags: registryRef.current.knownTags()
77
+ });
78
+ }
79
+ return parserRef.current;
80
+ }, []);
81
+ const push = useCallback(
82
+ (chunk) => {
83
+ if (!streamingRef.current) {
84
+ streamingRef.current = true;
85
+ setIsStreaming(true);
86
+ }
87
+ const parser = getParser();
88
+ parser.write(chunk);
89
+ setNodes([...parser.getNodes()]);
90
+ setMeta(parser.getMeta());
91
+ },
92
+ [getParser]
93
+ );
94
+ const done = useCallback(() => {
95
+ const parser = getParser();
96
+ parser.flush();
97
+ setNodes([...parser.getNodes()]);
98
+ setMeta(parser.getMeta());
99
+ streamingRef.current = false;
100
+ setIsStreaming(false);
101
+ }, [getParser]);
102
+ const reset = useCallback(() => {
103
+ parserRef.current?.reset();
104
+ parserRef.current = null;
105
+ setNodes([]);
106
+ setMeta({ errors: [], nodeCount: 0, isComplete: true });
107
+ streamingRef.current = false;
108
+ setIsStreaming(false);
109
+ }, []);
110
+ return { nodes, meta, isStreaming, push, done, reset };
111
+ }
112
+
113
+ // src/defaults.ts
114
+ import { ComponentRegistry } from "@mdocui/core";
115
+
116
+ // src/components/content.tsx
117
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
118
+ var calloutColors = {
119
+ info: { bg: "#eff6ff", border: "#3b82f6" },
120
+ warning: { bg: "#fffbeb", border: "#f59e0b" },
121
+ error: { bg: "#fef2f2", border: "#ef4444" },
122
+ success: { bg: "#f0fdf4", border: "#22c55e" }
123
+ };
124
+ function Callout({ props, children }) {
125
+ const type = props.type ?? "info";
126
+ const title = props.title;
127
+ const colors = calloutColors[type] ?? calloutColors.info;
128
+ return /* @__PURE__ */ jsxs(
129
+ "div",
130
+ {
131
+ "data-mdocui-callout": true,
132
+ "data-type": type,
133
+ role: "alert",
134
+ style: {
135
+ padding: "12px 16px",
136
+ borderLeft: `4px solid ${colors.border}`,
137
+ background: colors.bg,
138
+ borderRadius: "0 6px 6px 0"
139
+ },
140
+ children: [
141
+ title && /* @__PURE__ */ jsx2("div", { style: { fontWeight: 600, marginBottom: "4px" }, children: title }),
142
+ /* @__PURE__ */ jsx2("div", { children })
143
+ ]
144
+ }
145
+ );
146
+ }
147
+ var badgeColors = {
148
+ default: { bg: "#f1f5f9", color: "#475569" },
149
+ success: { bg: "#dcfce7", color: "#166534" },
150
+ warning: { bg: "#fef3c7", color: "#92400e" },
151
+ error: { bg: "#fee2e2", color: "#991b1b" },
152
+ info: { bg: "#dbeafe", color: "#1e40af" }
153
+ };
154
+ function Badge({ props }) {
155
+ const label = props.label;
156
+ const variant = props.variant ?? "default";
157
+ const colors = badgeColors[variant] ?? badgeColors.default;
158
+ return /* @__PURE__ */ jsx2(
159
+ "span",
160
+ {
161
+ "data-mdocui-badge": true,
162
+ "data-variant": variant,
163
+ style: {
164
+ display: "inline-block",
165
+ padding: "2px 8px",
166
+ borderRadius: "9999px",
167
+ fontSize: "12px",
168
+ fontWeight: 500,
169
+ background: colors.bg,
170
+ color: colors.color
171
+ },
172
+ children: label
173
+ }
174
+ );
175
+ }
176
+ function Image({ props }) {
177
+ const src = props.src;
178
+ const alt = props.alt;
179
+ const width = props.width;
180
+ const height = props.height;
181
+ return /* @__PURE__ */ jsx2(
182
+ "img",
183
+ {
184
+ "data-mdocui-image": true,
185
+ src,
186
+ alt,
187
+ width,
188
+ height,
189
+ style: { maxWidth: "100%", borderRadius: "6px" }
190
+ }
191
+ );
192
+ }
193
+ function CodeBlock({ props }) {
194
+ const code = props.code;
195
+ const language = props.language;
196
+ const title = props.title;
197
+ return /* @__PURE__ */ jsxs("div", { "data-mdocui-code-block": true, children: [
198
+ title && /* @__PURE__ */ jsx2(
199
+ "div",
200
+ {
201
+ style: {
202
+ padding: "6px 12px",
203
+ background: "#1e293b",
204
+ color: "#94a3b8",
205
+ fontSize: "12px",
206
+ borderRadius: "6px 6px 0 0"
207
+ },
208
+ children: title
209
+ }
210
+ ),
211
+ /* @__PURE__ */ jsx2(
212
+ "pre",
213
+ {
214
+ style: {
215
+ margin: 0,
216
+ padding: "12px",
217
+ background: "#0f172a",
218
+ color: "#e2e8f0",
219
+ borderRadius: title ? "0 0 6px 6px" : "6px",
220
+ overflow: "auto",
221
+ fontSize: "13px"
222
+ },
223
+ children: /* @__PURE__ */ jsx2("code", { "data-language": language, children: code })
224
+ }
225
+ )
226
+ ] });
227
+ }
228
+ function Link({ props, onAction, isStreaming }) {
229
+ const action = props.action;
230
+ const label = props.label;
231
+ const rawUrl = props.url;
232
+ const url = rawUrl && /^https?:\/\//i.test(rawUrl) ? rawUrl : void 0;
233
+ const handleClick = (e) => {
234
+ e.preventDefault();
235
+ if (isStreaming) return;
236
+ const event = {
237
+ type: "link_click",
238
+ action,
239
+ label,
240
+ tagName: "link",
241
+ params: url ? { url } : void 0
242
+ };
243
+ onAction(event);
244
+ };
245
+ return /* @__PURE__ */ jsx2(
246
+ "a",
247
+ {
248
+ "data-mdocui-link": true,
249
+ href: url ?? "#",
250
+ onClick: handleClick,
251
+ style: { color: "#3b82f6", textDecoration: "underline", cursor: "pointer" },
252
+ children: label
253
+ }
254
+ );
255
+ }
256
+
257
+ // src/components/data.tsx
258
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
259
+ function Chart({ props }) {
260
+ const type = props.type;
261
+ const labels = props.labels ?? [];
262
+ const values = props.values ?? [];
263
+ const title = props.title;
264
+ const max = values.reduce((a, b) => Math.max(a, b), 1);
265
+ return /* @__PURE__ */ jsxs2("div", { "data-mdocui-chart": true, "data-type": type, children: [
266
+ title && /* @__PURE__ */ jsx3("div", { style: { fontWeight: 600, marginBottom: "8px" }, children: title }),
267
+ (type === "bar" || type === "line") && /* @__PURE__ */ jsx3("div", { style: { display: "flex", alignItems: "flex-end", gap: "4px", height: "120px" }, children: values.map((val, i) => /* @__PURE__ */ jsxs2("div", { style: { flex: 1, textAlign: "center" }, children: [
268
+ /* @__PURE__ */ jsx3(
269
+ "div",
270
+ {
271
+ style: {
272
+ height: `${val / max * 100}%`,
273
+ background: "#3b82f6",
274
+ borderRadius: "4px 4px 0 0",
275
+ minHeight: "2px"
276
+ }
277
+ }
278
+ ),
279
+ /* @__PURE__ */ jsx3("div", { style: { fontSize: "11px", marginTop: "4px", color: "#64748b" }, children: labels[i] })
280
+ ] }, labels[i] ?? i)) }),
281
+ (type === "pie" || type === "donut") && /* @__PURE__ */ jsx3("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: labels.map((label, i) => /* @__PURE__ */ jsxs2("span", { style: { fontSize: "13px" }, children: [
282
+ label,
283
+ ": ",
284
+ values[i]
285
+ ] }, label)) })
286
+ ] });
287
+ }
288
+ function Table({ props }) {
289
+ const headers = props.headers ?? [];
290
+ const rows = props.rows ?? [];
291
+ const caption = props.caption;
292
+ return /* @__PURE__ */ jsxs2("table", { "data-mdocui-table": true, style: { width: "100%", borderCollapse: "collapse" }, children: [
293
+ caption && /* @__PURE__ */ jsx3("caption", { style: { textAlign: "left", fontWeight: 600, marginBottom: "8px" }, children: caption }),
294
+ /* @__PURE__ */ jsx3("thead", { children: /* @__PURE__ */ jsx3("tr", { children: headers.map((h) => /* @__PURE__ */ jsx3(
295
+ "th",
296
+ {
297
+ style: {
298
+ textAlign: "left",
299
+ padding: "8px",
300
+ borderBottom: "2px solid #e2e8f0",
301
+ fontWeight: 600
302
+ },
303
+ children: h
304
+ },
305
+ h
306
+ )) }) }),
307
+ /* @__PURE__ */ jsx3("tbody", { children: rows.map((row) => /* @__PURE__ */ jsx3("tr", { children: row.map((cell, _ci) => {
308
+ const cellKey = `${row[0]}-${cell}`;
309
+ return /* @__PURE__ */ jsx3("td", { style: { padding: "8px", borderBottom: "1px solid #f1f5f9" }, children: cell }, cellKey);
310
+ }) }, row.join(" "))) })
311
+ ] });
312
+ }
313
+ function Stat({ props }) {
314
+ const label = props.label;
315
+ const value = props.value;
316
+ const change = props.change;
317
+ const trend = props.trend ?? "neutral";
318
+ const trendColor = trend === "up" ? "#16a34a" : trend === "down" ? "#dc2626" : "#64748b";
319
+ return /* @__PURE__ */ jsxs2("div", { "data-mdocui-stat": true, children: [
320
+ /* @__PURE__ */ jsx3("div", { style: { fontSize: "13px", color: "#64748b" }, children: label }),
321
+ /* @__PURE__ */ jsx3("div", { style: { fontSize: "24px", fontWeight: 700 }, children: value }),
322
+ change && /* @__PURE__ */ jsx3("div", { style: { fontSize: "13px", color: trendColor }, children: change })
323
+ ] });
324
+ }
325
+ function Progress({ props }) {
326
+ const value = props.value;
327
+ const label = props.label;
328
+ const max = props.max ?? 100;
329
+ const pct = Math.min(100, Math.max(0, value / max * 100));
330
+ return /* @__PURE__ */ jsxs2("div", { "data-mdocui-progress": true, children: [
331
+ label && /* @__PURE__ */ jsx3("div", { style: { fontSize: "13px", marginBottom: "4px" }, children: label }),
332
+ /* @__PURE__ */ jsx3(
333
+ "div",
334
+ {
335
+ style: { height: "8px", background: "#e2e8f0", borderRadius: "4px", overflow: "hidden" },
336
+ children: /* @__PURE__ */ jsx3(
337
+ "div",
338
+ {
339
+ style: {
340
+ height: "100%",
341
+ width: `${pct}%`,
342
+ background: "#3b82f6",
343
+ borderRadius: "4px",
344
+ transition: "width 0.3s"
345
+ }
346
+ }
347
+ )
348
+ }
349
+ )
350
+ ] });
351
+ }
352
+
353
+ // src/components/interactive.tsx
354
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
355
+ function Button({ props, onAction, isStreaming }) {
356
+ const action = props.action;
357
+ const label = props.label;
358
+ const variant = props.variant ?? "primary";
359
+ const disabled = props.disabled ?? false;
360
+ const handleClick = () => {
361
+ if (isStreaming || disabled) return;
362
+ const event = {
363
+ type: "button_click",
364
+ action,
365
+ label,
366
+ tagName: "button"
367
+ };
368
+ onAction(event);
369
+ };
370
+ return /* @__PURE__ */ jsx4(
371
+ "button",
372
+ {
373
+ type: "button",
374
+ "data-mdocui-button": true,
375
+ "data-variant": variant,
376
+ disabled: isStreaming || disabled,
377
+ onClick: handleClick,
378
+ style: {
379
+ padding: "8px 16px",
380
+ borderRadius: "6px",
381
+ cursor: isStreaming || disabled ? "not-allowed" : "pointer",
382
+ opacity: isStreaming || disabled ? 0.6 : 1,
383
+ border: variant === "outline" ? "1px solid currentColor" : "none",
384
+ background: variant === "primary" ? "#0f172a" : variant === "ghost" ? "transparent" : "#e2e8f0",
385
+ color: variant === "primary" ? "#fff" : "inherit"
386
+ },
387
+ children: label
388
+ }
389
+ );
390
+ }
391
+ function ButtonGroup({ props, children }) {
392
+ const direction = props.direction ?? "horizontal";
393
+ return /* @__PURE__ */ jsx4(
394
+ "div",
395
+ {
396
+ "data-mdocui-button-group": true,
397
+ style: {
398
+ display: "flex",
399
+ flexDirection: direction === "vertical" ? "column" : "row",
400
+ gap: "8px"
401
+ },
402
+ children
403
+ }
404
+ );
405
+ }
406
+ function Input({ props }) {
407
+ const name = props.name;
408
+ const label = props.label;
409
+ const placeholder = props.placeholder ?? "";
410
+ const type = props.type ?? "text";
411
+ const required = props.required ?? false;
412
+ const id = `mdocui-${name}`;
413
+ return /* @__PURE__ */ jsxs3("div", { "data-mdocui-input": true, children: [
414
+ label && /* @__PURE__ */ jsx4("label", { htmlFor: id, style: { display: "block", marginBottom: "4px", fontWeight: 500 }, children: label }),
415
+ /* @__PURE__ */ jsx4(
416
+ "input",
417
+ {
418
+ id,
419
+ name,
420
+ type,
421
+ placeholder,
422
+ required,
423
+ style: {
424
+ width: "100%",
425
+ padding: "8px 12px",
426
+ border: "1px solid #e2e8f0",
427
+ borderRadius: "6px",
428
+ boxSizing: "border-box"
429
+ }
430
+ }
431
+ )
432
+ ] });
433
+ }
434
+ function Select({ props, onAction, isStreaming }) {
435
+ const name = props.name;
436
+ const label = props.label;
437
+ const options = props.options ?? [];
438
+ const placeholder = props.placeholder;
439
+ const required = props.required ?? false;
440
+ const id = `mdocui-${name}`;
441
+ const handleChange = (e) => {
442
+ if (isStreaming) return;
443
+ onAction({
444
+ type: "select_change",
445
+ action: `change:${name}`,
446
+ tagName: "select",
447
+ params: { name, value: e.target.value }
448
+ });
449
+ };
450
+ return /* @__PURE__ */ jsxs3("div", { "data-mdocui-select": true, children: [
451
+ label && /* @__PURE__ */ jsx4("label", { htmlFor: id, style: { display: "block", marginBottom: "4px", fontWeight: 500 }, children: label }),
452
+ /* @__PURE__ */ jsxs3(
453
+ "select",
454
+ {
455
+ id,
456
+ name,
457
+ required,
458
+ onChange: handleChange,
459
+ style: {
460
+ width: "100%",
461
+ padding: "8px 12px",
462
+ border: "1px solid #e2e8f0",
463
+ borderRadius: "6px"
464
+ },
465
+ children: [
466
+ placeholder && /* @__PURE__ */ jsx4("option", { value: "", children: placeholder }),
467
+ options.map((opt) => /* @__PURE__ */ jsx4("option", { value: opt, children: opt }, opt))
468
+ ]
469
+ }
470
+ )
471
+ ] });
472
+ }
473
+ function Checkbox({ props, onAction, isStreaming }) {
474
+ const name = props.name;
475
+ const label = props.label;
476
+ const checked = props.checked ?? false;
477
+ const handleChange = (e) => {
478
+ if (isStreaming) return;
479
+ onAction({
480
+ type: "select_change",
481
+ action: `change:${name}`,
482
+ tagName: "checkbox",
483
+ params: { name, value: e.target.checked }
484
+ });
485
+ };
486
+ return /* @__PURE__ */ jsxs3(
487
+ "label",
488
+ {
489
+ "data-mdocui-checkbox": true,
490
+ style: { display: "flex", alignItems: "center", gap: "8px", cursor: "pointer" },
491
+ children: [
492
+ /* @__PURE__ */ jsx4("input", { type: "checkbox", name, defaultChecked: checked, onChange: handleChange }),
493
+ /* @__PURE__ */ jsx4("span", { children: label })
494
+ ]
495
+ }
496
+ );
497
+ }
498
+ function Form({ props, children, onAction, isStreaming }) {
499
+ const formName = props.name;
500
+ const action = props.action ?? `submit:${formName}`;
501
+ const handleSubmit = (e) => {
502
+ e.preventDefault();
503
+ if (isStreaming) return;
504
+ const formData = new FormData(e.currentTarget);
505
+ const state = {};
506
+ formData.forEach((value, key) => {
507
+ state[key] = value;
508
+ });
509
+ const event = {
510
+ type: "form_submit",
511
+ action,
512
+ formName,
513
+ formState: state,
514
+ tagName: "form"
515
+ };
516
+ onAction(event);
517
+ };
518
+ return /* @__PURE__ */ jsx4(
519
+ "form",
520
+ {
521
+ "data-mdocui-form": true,
522
+ "data-name": formName,
523
+ onSubmit: handleSubmit,
524
+ style: { display: "flex", flexDirection: "column", gap: "12px" },
525
+ children
526
+ }
527
+ );
528
+ }
529
+
530
+ // src/components/layout.tsx
531
+ import React, { useState as useState2 } from "react";
532
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
533
+ function Stack({ props, children }) {
534
+ const direction = props.direction ?? "vertical";
535
+ const gap = props.gap ?? "md";
536
+ const align = props.align ?? "stretch";
537
+ return /* @__PURE__ */ jsx5(
538
+ "div",
539
+ {
540
+ "data-mdocui-stack": true,
541
+ "data-direction": direction,
542
+ "data-gap": gap,
543
+ "data-align": align,
544
+ style: {
545
+ display: "flex",
546
+ flexDirection: direction === "horizontal" ? "row" : "column",
547
+ gap: gapValue(gap),
548
+ alignItems: alignValue(align)
549
+ },
550
+ children
551
+ }
552
+ );
553
+ }
554
+ function Grid({ props, children }) {
555
+ const cols = props.cols ?? 2;
556
+ const gap = props.gap ?? "md";
557
+ return /* @__PURE__ */ jsx5(
558
+ "div",
559
+ {
560
+ "data-mdocui-grid": true,
561
+ style: {
562
+ display: "grid",
563
+ gridTemplateColumns: `repeat(${cols}, 1fr)`,
564
+ gap: gapValue(gap)
565
+ },
566
+ children
567
+ }
568
+ );
569
+ }
570
+ function Card({ props, children }) {
571
+ const title = props.title;
572
+ return /* @__PURE__ */ jsxs4(
573
+ "div",
574
+ {
575
+ "data-mdocui-card": true,
576
+ "data-variant": props.variant ?? "default",
577
+ style: { border: "1px solid #e2e8f0", borderRadius: "8px", padding: "16px" },
578
+ children: [
579
+ title && /* @__PURE__ */ jsx5("div", { "data-mdocui-card-title": true, style: { fontWeight: 600, marginBottom: "8px" }, children: title }),
580
+ /* @__PURE__ */ jsx5("div", { "data-mdocui-card-body": true, children })
581
+ ]
582
+ }
583
+ );
584
+ }
585
+ function Divider(_) {
586
+ return /* @__PURE__ */ jsx5(
587
+ "hr",
588
+ {
589
+ "data-mdocui-divider": true,
590
+ style: { border: "none", borderTop: "1px solid #e2e8f0", margin: "8px 0" }
591
+ }
592
+ );
593
+ }
594
+ function Accordion({ props, children }) {
595
+ const title = props.title;
596
+ const open = props.open ?? false;
597
+ return /* @__PURE__ */ jsxs4("details", { "data-mdocui-accordion": true, open: open || void 0, children: [
598
+ /* @__PURE__ */ jsx5("summary", { style: { cursor: "pointer", fontWeight: 500 }, children: title }),
599
+ /* @__PURE__ */ jsx5("div", { style: { paddingTop: "8px" }, children })
600
+ ] });
601
+ }
602
+ function Tabs({ props, children }) {
603
+ const labels = props.labels ?? [];
604
+ const initialActive = props.active ?? 0;
605
+ const [active, setActive] = useState2(initialActive);
606
+ const childArray = React.Children.toArray(children);
607
+ return /* @__PURE__ */ jsxs4("div", { "data-mdocui-tabs": true, children: [
608
+ /* @__PURE__ */ jsx5(
609
+ "div",
610
+ {
611
+ role: "tablist",
612
+ style: { display: "flex", gap: "4px", borderBottom: "1px solid #e2e8f0" },
613
+ children: labels.map((label, i) => /* @__PURE__ */ jsx5(
614
+ "button",
615
+ {
616
+ type: "button",
617
+ role: "tab",
618
+ "aria-selected": i === active,
619
+ onClick: () => setActive(i),
620
+ style: {
621
+ padding: "8px 16px",
622
+ background: "none",
623
+ border: "none",
624
+ borderBottom: i === active ? "2px solid currentColor" : "2px solid transparent",
625
+ cursor: "pointer",
626
+ fontWeight: i === active ? 600 : 400
627
+ },
628
+ children: label
629
+ },
630
+ `${i}-${label}`
631
+ ))
632
+ }
633
+ ),
634
+ /* @__PURE__ */ jsx5("div", { role: "tabpanel", style: { paddingTop: "8px" }, children: childArray[active] ?? childArray[0] })
635
+ ] });
636
+ }
637
+ function Tab({ props, children }) {
638
+ return /* @__PURE__ */ jsx5("div", { "data-mdocui-tab": true, "data-label": props.label, children });
639
+ }
640
+ function gapValue(gap) {
641
+ switch (gap) {
642
+ case "none":
643
+ return "0";
644
+ case "sm":
645
+ return "4px";
646
+ case "lg":
647
+ return "24px";
648
+ default:
649
+ return "12px";
650
+ }
651
+ }
652
+ function alignValue(align) {
653
+ switch (align) {
654
+ case "start":
655
+ return "flex-start";
656
+ case "center":
657
+ return "center";
658
+ case "end":
659
+ return "flex-end";
660
+ default:
661
+ return "stretch";
662
+ }
663
+ }
664
+
665
+ // src/definitions.ts
666
+ import { defineComponent } from "@mdocui/core";
667
+
668
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
669
+ var external_exports = {};
670
+ __export(external_exports, {
671
+ BRAND: () => BRAND,
672
+ DIRTY: () => DIRTY,
673
+ EMPTY_PATH: () => EMPTY_PATH,
674
+ INVALID: () => INVALID,
675
+ NEVER: () => NEVER,
676
+ OK: () => OK,
677
+ ParseStatus: () => ParseStatus,
678
+ Schema: () => ZodType,
679
+ ZodAny: () => ZodAny,
680
+ ZodArray: () => ZodArray,
681
+ ZodBigInt: () => ZodBigInt,
682
+ ZodBoolean: () => ZodBoolean,
683
+ ZodBranded: () => ZodBranded,
684
+ ZodCatch: () => ZodCatch,
685
+ ZodDate: () => ZodDate,
686
+ ZodDefault: () => ZodDefault,
687
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
688
+ ZodEffects: () => ZodEffects,
689
+ ZodEnum: () => ZodEnum,
690
+ ZodError: () => ZodError,
691
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
692
+ ZodFunction: () => ZodFunction,
693
+ ZodIntersection: () => ZodIntersection,
694
+ ZodIssueCode: () => ZodIssueCode,
695
+ ZodLazy: () => ZodLazy,
696
+ ZodLiteral: () => ZodLiteral,
697
+ ZodMap: () => ZodMap,
698
+ ZodNaN: () => ZodNaN,
699
+ ZodNativeEnum: () => ZodNativeEnum,
700
+ ZodNever: () => ZodNever,
701
+ ZodNull: () => ZodNull,
702
+ ZodNullable: () => ZodNullable,
703
+ ZodNumber: () => ZodNumber,
704
+ ZodObject: () => ZodObject,
705
+ ZodOptional: () => ZodOptional,
706
+ ZodParsedType: () => ZodParsedType,
707
+ ZodPipeline: () => ZodPipeline,
708
+ ZodPromise: () => ZodPromise,
709
+ ZodReadonly: () => ZodReadonly,
710
+ ZodRecord: () => ZodRecord,
711
+ ZodSchema: () => ZodType,
712
+ ZodSet: () => ZodSet,
713
+ ZodString: () => ZodString,
714
+ ZodSymbol: () => ZodSymbol,
715
+ ZodTransformer: () => ZodEffects,
716
+ ZodTuple: () => ZodTuple,
717
+ ZodType: () => ZodType,
718
+ ZodUndefined: () => ZodUndefined,
719
+ ZodUnion: () => ZodUnion,
720
+ ZodUnknown: () => ZodUnknown,
721
+ ZodVoid: () => ZodVoid,
722
+ addIssueToContext: () => addIssueToContext,
723
+ any: () => anyType,
724
+ array: () => arrayType,
725
+ bigint: () => bigIntType,
726
+ boolean: () => booleanType,
727
+ coerce: () => coerce,
728
+ custom: () => custom,
729
+ date: () => dateType,
730
+ datetimeRegex: () => datetimeRegex,
731
+ defaultErrorMap: () => en_default,
732
+ discriminatedUnion: () => discriminatedUnionType,
733
+ effect: () => effectsType,
734
+ enum: () => enumType,
735
+ function: () => functionType,
736
+ getErrorMap: () => getErrorMap,
737
+ getParsedType: () => getParsedType,
738
+ instanceof: () => instanceOfType,
739
+ intersection: () => intersectionType,
740
+ isAborted: () => isAborted,
741
+ isAsync: () => isAsync,
742
+ isDirty: () => isDirty,
743
+ isValid: () => isValid,
744
+ late: () => late,
745
+ lazy: () => lazyType,
746
+ literal: () => literalType,
747
+ makeIssue: () => makeIssue,
748
+ map: () => mapType,
749
+ nan: () => nanType,
750
+ nativeEnum: () => nativeEnumType,
751
+ never: () => neverType,
752
+ null: () => nullType,
753
+ nullable: () => nullableType,
754
+ number: () => numberType,
755
+ object: () => objectType,
756
+ objectUtil: () => objectUtil,
757
+ oboolean: () => oboolean,
758
+ onumber: () => onumber,
759
+ optional: () => optionalType,
760
+ ostring: () => ostring,
761
+ pipeline: () => pipelineType,
762
+ preprocess: () => preprocessType,
763
+ promise: () => promiseType,
764
+ quotelessJson: () => quotelessJson,
765
+ record: () => recordType,
766
+ set: () => setType,
767
+ setErrorMap: () => setErrorMap,
768
+ strictObject: () => strictObjectType,
769
+ string: () => stringType,
770
+ symbol: () => symbolType,
771
+ transformer: () => effectsType,
772
+ tuple: () => tupleType,
773
+ undefined: () => undefinedType,
774
+ union: () => unionType,
775
+ unknown: () => unknownType,
776
+ util: () => util,
777
+ void: () => voidType
778
+ });
779
+
780
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
781
+ var util;
782
+ (function(util2) {
783
+ util2.assertEqual = (_) => {
784
+ };
785
+ function assertIs(_arg) {
786
+ }
787
+ util2.assertIs = assertIs;
788
+ function assertNever(_x) {
789
+ throw new Error();
790
+ }
791
+ util2.assertNever = assertNever;
792
+ util2.arrayToEnum = (items) => {
793
+ const obj = {};
794
+ for (const item of items) {
795
+ obj[item] = item;
796
+ }
797
+ return obj;
798
+ };
799
+ util2.getValidEnumValues = (obj) => {
800
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
801
+ const filtered = {};
802
+ for (const k of validKeys) {
803
+ filtered[k] = obj[k];
804
+ }
805
+ return util2.objectValues(filtered);
806
+ };
807
+ util2.objectValues = (obj) => {
808
+ return util2.objectKeys(obj).map(function(e) {
809
+ return obj[e];
810
+ });
811
+ };
812
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
813
+ const keys = [];
814
+ for (const key in object) {
815
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
816
+ keys.push(key);
817
+ }
818
+ }
819
+ return keys;
820
+ };
821
+ util2.find = (arr, checker) => {
822
+ for (const item of arr) {
823
+ if (checker(item))
824
+ return item;
825
+ }
826
+ return void 0;
827
+ };
828
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
829
+ function joinValues(array, separator = " | ") {
830
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
831
+ }
832
+ util2.joinValues = joinValues;
833
+ util2.jsonStringifyReplacer = (_, value) => {
834
+ if (typeof value === "bigint") {
835
+ return value.toString();
836
+ }
837
+ return value;
838
+ };
839
+ })(util || (util = {}));
840
+ var objectUtil;
841
+ (function(objectUtil2) {
842
+ objectUtil2.mergeShapes = (first, second) => {
843
+ return {
844
+ ...first,
845
+ ...second
846
+ // second overwrites first
847
+ };
848
+ };
849
+ })(objectUtil || (objectUtil = {}));
850
+ var ZodParsedType = util.arrayToEnum([
851
+ "string",
852
+ "nan",
853
+ "number",
854
+ "integer",
855
+ "float",
856
+ "boolean",
857
+ "date",
858
+ "bigint",
859
+ "symbol",
860
+ "function",
861
+ "undefined",
862
+ "null",
863
+ "array",
864
+ "object",
865
+ "unknown",
866
+ "promise",
867
+ "void",
868
+ "never",
869
+ "map",
870
+ "set"
871
+ ]);
872
+ var getParsedType = (data) => {
873
+ const t = typeof data;
874
+ switch (t) {
875
+ case "undefined":
876
+ return ZodParsedType.undefined;
877
+ case "string":
878
+ return ZodParsedType.string;
879
+ case "number":
880
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
881
+ case "boolean":
882
+ return ZodParsedType.boolean;
883
+ case "function":
884
+ return ZodParsedType.function;
885
+ case "bigint":
886
+ return ZodParsedType.bigint;
887
+ case "symbol":
888
+ return ZodParsedType.symbol;
889
+ case "object":
890
+ if (Array.isArray(data)) {
891
+ return ZodParsedType.array;
892
+ }
893
+ if (data === null) {
894
+ return ZodParsedType.null;
895
+ }
896
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
897
+ return ZodParsedType.promise;
898
+ }
899
+ if (typeof Map !== "undefined" && data instanceof Map) {
900
+ return ZodParsedType.map;
901
+ }
902
+ if (typeof Set !== "undefined" && data instanceof Set) {
903
+ return ZodParsedType.set;
904
+ }
905
+ if (typeof Date !== "undefined" && data instanceof Date) {
906
+ return ZodParsedType.date;
907
+ }
908
+ return ZodParsedType.object;
909
+ default:
910
+ return ZodParsedType.unknown;
911
+ }
912
+ };
913
+
914
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
915
+ var ZodIssueCode = util.arrayToEnum([
916
+ "invalid_type",
917
+ "invalid_literal",
918
+ "custom",
919
+ "invalid_union",
920
+ "invalid_union_discriminator",
921
+ "invalid_enum_value",
922
+ "unrecognized_keys",
923
+ "invalid_arguments",
924
+ "invalid_return_type",
925
+ "invalid_date",
926
+ "invalid_string",
927
+ "too_small",
928
+ "too_big",
929
+ "invalid_intersection_types",
930
+ "not_multiple_of",
931
+ "not_finite"
932
+ ]);
933
+ var quotelessJson = (obj) => {
934
+ const json = JSON.stringify(obj, null, 2);
935
+ return json.replace(/"([^"]+)":/g, "$1:");
936
+ };
937
+ var ZodError = class _ZodError extends Error {
938
+ get errors() {
939
+ return this.issues;
940
+ }
941
+ constructor(issues) {
942
+ super();
943
+ this.issues = [];
944
+ this.addIssue = (sub) => {
945
+ this.issues = [...this.issues, sub];
946
+ };
947
+ this.addIssues = (subs = []) => {
948
+ this.issues = [...this.issues, ...subs];
949
+ };
950
+ const actualProto = new.target.prototype;
951
+ if (Object.setPrototypeOf) {
952
+ Object.setPrototypeOf(this, actualProto);
953
+ } else {
954
+ this.__proto__ = actualProto;
955
+ }
956
+ this.name = "ZodError";
957
+ this.issues = issues;
958
+ }
959
+ format(_mapper) {
960
+ const mapper = _mapper || function(issue) {
961
+ return issue.message;
962
+ };
963
+ const fieldErrors = { _errors: [] };
964
+ const processError = (error) => {
965
+ for (const issue of error.issues) {
966
+ if (issue.code === "invalid_union") {
967
+ issue.unionErrors.map(processError);
968
+ } else if (issue.code === "invalid_return_type") {
969
+ processError(issue.returnTypeError);
970
+ } else if (issue.code === "invalid_arguments") {
971
+ processError(issue.argumentsError);
972
+ } else if (issue.path.length === 0) {
973
+ fieldErrors._errors.push(mapper(issue));
974
+ } else {
975
+ let curr = fieldErrors;
976
+ let i = 0;
977
+ while (i < issue.path.length) {
978
+ const el = issue.path[i];
979
+ const terminal = i === issue.path.length - 1;
980
+ if (!terminal) {
981
+ curr[el] = curr[el] || { _errors: [] };
982
+ } else {
983
+ curr[el] = curr[el] || { _errors: [] };
984
+ curr[el]._errors.push(mapper(issue));
985
+ }
986
+ curr = curr[el];
987
+ i++;
988
+ }
989
+ }
990
+ }
991
+ };
992
+ processError(this);
993
+ return fieldErrors;
994
+ }
995
+ static assert(value) {
996
+ if (!(value instanceof _ZodError)) {
997
+ throw new Error(`Not a ZodError: ${value}`);
998
+ }
999
+ }
1000
+ toString() {
1001
+ return this.message;
1002
+ }
1003
+ get message() {
1004
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
1005
+ }
1006
+ get isEmpty() {
1007
+ return this.issues.length === 0;
1008
+ }
1009
+ flatten(mapper = (issue) => issue.message) {
1010
+ const fieldErrors = {};
1011
+ const formErrors = [];
1012
+ for (const sub of this.issues) {
1013
+ if (sub.path.length > 0) {
1014
+ const firstEl = sub.path[0];
1015
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
1016
+ fieldErrors[firstEl].push(mapper(sub));
1017
+ } else {
1018
+ formErrors.push(mapper(sub));
1019
+ }
1020
+ }
1021
+ return { formErrors, fieldErrors };
1022
+ }
1023
+ get formErrors() {
1024
+ return this.flatten();
1025
+ }
1026
+ };
1027
+ ZodError.create = (issues) => {
1028
+ const error = new ZodError(issues);
1029
+ return error;
1030
+ };
1031
+
1032
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
1033
+ var errorMap = (issue, _ctx) => {
1034
+ let message;
1035
+ switch (issue.code) {
1036
+ case ZodIssueCode.invalid_type:
1037
+ if (issue.received === ZodParsedType.undefined) {
1038
+ message = "Required";
1039
+ } else {
1040
+ message = `Expected ${issue.expected}, received ${issue.received}`;
1041
+ }
1042
+ break;
1043
+ case ZodIssueCode.invalid_literal:
1044
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
1045
+ break;
1046
+ case ZodIssueCode.unrecognized_keys:
1047
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
1048
+ break;
1049
+ case ZodIssueCode.invalid_union:
1050
+ message = `Invalid input`;
1051
+ break;
1052
+ case ZodIssueCode.invalid_union_discriminator:
1053
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
1054
+ break;
1055
+ case ZodIssueCode.invalid_enum_value:
1056
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
1057
+ break;
1058
+ case ZodIssueCode.invalid_arguments:
1059
+ message = `Invalid function arguments`;
1060
+ break;
1061
+ case ZodIssueCode.invalid_return_type:
1062
+ message = `Invalid function return type`;
1063
+ break;
1064
+ case ZodIssueCode.invalid_date:
1065
+ message = `Invalid date`;
1066
+ break;
1067
+ case ZodIssueCode.invalid_string:
1068
+ if (typeof issue.validation === "object") {
1069
+ if ("includes" in issue.validation) {
1070
+ message = `Invalid input: must include "${issue.validation.includes}"`;
1071
+ if (typeof issue.validation.position === "number") {
1072
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
1073
+ }
1074
+ } else if ("startsWith" in issue.validation) {
1075
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
1076
+ } else if ("endsWith" in issue.validation) {
1077
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
1078
+ } else {
1079
+ util.assertNever(issue.validation);
1080
+ }
1081
+ } else if (issue.validation !== "regex") {
1082
+ message = `Invalid ${issue.validation}`;
1083
+ } else {
1084
+ message = "Invalid";
1085
+ }
1086
+ break;
1087
+ case ZodIssueCode.too_small:
1088
+ if (issue.type === "array")
1089
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
1090
+ else if (issue.type === "string")
1091
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
1092
+ else if (issue.type === "number")
1093
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
1094
+ else if (issue.type === "bigint")
1095
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
1096
+ else if (issue.type === "date")
1097
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
1098
+ else
1099
+ message = "Invalid input";
1100
+ break;
1101
+ case ZodIssueCode.too_big:
1102
+ if (issue.type === "array")
1103
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
1104
+ else if (issue.type === "string")
1105
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
1106
+ else if (issue.type === "number")
1107
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1108
+ else if (issue.type === "bigint")
1109
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1110
+ else if (issue.type === "date")
1111
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
1112
+ else
1113
+ message = "Invalid input";
1114
+ break;
1115
+ case ZodIssueCode.custom:
1116
+ message = `Invalid input`;
1117
+ break;
1118
+ case ZodIssueCode.invalid_intersection_types:
1119
+ message = `Intersection results could not be merged`;
1120
+ break;
1121
+ case ZodIssueCode.not_multiple_of:
1122
+ message = `Number must be a multiple of ${issue.multipleOf}`;
1123
+ break;
1124
+ case ZodIssueCode.not_finite:
1125
+ message = "Number must be finite";
1126
+ break;
1127
+ default:
1128
+ message = _ctx.defaultError;
1129
+ util.assertNever(issue);
1130
+ }
1131
+ return { message };
1132
+ };
1133
+ var en_default = errorMap;
1134
+
1135
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js
1136
+ var overrideErrorMap = en_default;
1137
+ function setErrorMap(map) {
1138
+ overrideErrorMap = map;
1139
+ }
1140
+ function getErrorMap() {
1141
+ return overrideErrorMap;
1142
+ }
1143
+
1144
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
1145
+ var makeIssue = (params) => {
1146
+ const { data, path, errorMaps, issueData } = params;
1147
+ const fullPath = [...path, ...issueData.path || []];
1148
+ const fullIssue = {
1149
+ ...issueData,
1150
+ path: fullPath
1151
+ };
1152
+ if (issueData.message !== void 0) {
1153
+ return {
1154
+ ...issueData,
1155
+ path: fullPath,
1156
+ message: issueData.message
1157
+ };
1158
+ }
1159
+ let errorMessage = "";
1160
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
1161
+ for (const map of maps) {
1162
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
1163
+ }
1164
+ return {
1165
+ ...issueData,
1166
+ path: fullPath,
1167
+ message: errorMessage
1168
+ };
1169
+ };
1170
+ var EMPTY_PATH = [];
1171
+ function addIssueToContext(ctx, issueData) {
1172
+ const overrideMap = getErrorMap();
1173
+ const issue = makeIssue({
1174
+ issueData,
1175
+ data: ctx.data,
1176
+ path: ctx.path,
1177
+ errorMaps: [
1178
+ ctx.common.contextualErrorMap,
1179
+ // contextual error map is first priority
1180
+ ctx.schemaErrorMap,
1181
+ // then schema-bound map if available
1182
+ overrideMap,
1183
+ // then global override map
1184
+ overrideMap === en_default ? void 0 : en_default
1185
+ // then global default map
1186
+ ].filter((x) => !!x)
1187
+ });
1188
+ ctx.common.issues.push(issue);
1189
+ }
1190
+ var ParseStatus = class _ParseStatus {
1191
+ constructor() {
1192
+ this.value = "valid";
1193
+ }
1194
+ dirty() {
1195
+ if (this.value === "valid")
1196
+ this.value = "dirty";
1197
+ }
1198
+ abort() {
1199
+ if (this.value !== "aborted")
1200
+ this.value = "aborted";
1201
+ }
1202
+ static mergeArray(status, results) {
1203
+ const arrayValue = [];
1204
+ for (const s of results) {
1205
+ if (s.status === "aborted")
1206
+ return INVALID;
1207
+ if (s.status === "dirty")
1208
+ status.dirty();
1209
+ arrayValue.push(s.value);
1210
+ }
1211
+ return { status: status.value, value: arrayValue };
1212
+ }
1213
+ static async mergeObjectAsync(status, pairs) {
1214
+ const syncPairs = [];
1215
+ for (const pair of pairs) {
1216
+ const key = await pair.key;
1217
+ const value = await pair.value;
1218
+ syncPairs.push({
1219
+ key,
1220
+ value
1221
+ });
1222
+ }
1223
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
1224
+ }
1225
+ static mergeObjectSync(status, pairs) {
1226
+ const finalObject = {};
1227
+ for (const pair of pairs) {
1228
+ const { key, value } = pair;
1229
+ if (key.status === "aborted")
1230
+ return INVALID;
1231
+ if (value.status === "aborted")
1232
+ return INVALID;
1233
+ if (key.status === "dirty")
1234
+ status.dirty();
1235
+ if (value.status === "dirty")
1236
+ status.dirty();
1237
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
1238
+ finalObject[key.value] = value.value;
1239
+ }
1240
+ }
1241
+ return { status: status.value, value: finalObject };
1242
+ }
1243
+ };
1244
+ var INVALID = Object.freeze({
1245
+ status: "aborted"
1246
+ });
1247
+ var DIRTY = (value) => ({ status: "dirty", value });
1248
+ var OK = (value) => ({ status: "valid", value });
1249
+ var isAborted = (x) => x.status === "aborted";
1250
+ var isDirty = (x) => x.status === "dirty";
1251
+ var isValid = (x) => x.status === "valid";
1252
+ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
1253
+
1254
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
1255
+ var errorUtil;
1256
+ (function(errorUtil2) {
1257
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
1258
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
1259
+ })(errorUtil || (errorUtil = {}));
1260
+
1261
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
1262
+ var ParseInputLazyPath = class {
1263
+ constructor(parent, value, path, key) {
1264
+ this._cachedPath = [];
1265
+ this.parent = parent;
1266
+ this.data = value;
1267
+ this._path = path;
1268
+ this._key = key;
1269
+ }
1270
+ get path() {
1271
+ if (!this._cachedPath.length) {
1272
+ if (Array.isArray(this._key)) {
1273
+ this._cachedPath.push(...this._path, ...this._key);
1274
+ } else {
1275
+ this._cachedPath.push(...this._path, this._key);
1276
+ }
1277
+ }
1278
+ return this._cachedPath;
1279
+ }
1280
+ };
1281
+ var handleResult = (ctx, result) => {
1282
+ if (isValid(result)) {
1283
+ return { success: true, data: result.value };
1284
+ } else {
1285
+ if (!ctx.common.issues.length) {
1286
+ throw new Error("Validation failed but no issues detected.");
1287
+ }
1288
+ return {
1289
+ success: false,
1290
+ get error() {
1291
+ if (this._error)
1292
+ return this._error;
1293
+ const error = new ZodError(ctx.common.issues);
1294
+ this._error = error;
1295
+ return this._error;
1296
+ }
1297
+ };
1298
+ }
1299
+ };
1300
+ function processCreateParams(params) {
1301
+ if (!params)
1302
+ return {};
1303
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
1304
+ if (errorMap2 && (invalid_type_error || required_error)) {
1305
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
1306
+ }
1307
+ if (errorMap2)
1308
+ return { errorMap: errorMap2, description };
1309
+ const customMap = (iss, ctx) => {
1310
+ const { message } = params;
1311
+ if (iss.code === "invalid_enum_value") {
1312
+ return { message: message ?? ctx.defaultError };
1313
+ }
1314
+ if (typeof ctx.data === "undefined") {
1315
+ return { message: message ?? required_error ?? ctx.defaultError };
1316
+ }
1317
+ if (iss.code !== "invalid_type")
1318
+ return { message: ctx.defaultError };
1319
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
1320
+ };
1321
+ return { errorMap: customMap, description };
1322
+ }
1323
+ var ZodType = class {
1324
+ get description() {
1325
+ return this._def.description;
1326
+ }
1327
+ _getType(input2) {
1328
+ return getParsedType(input2.data);
1329
+ }
1330
+ _getOrReturnCtx(input2, ctx) {
1331
+ return ctx || {
1332
+ common: input2.parent.common,
1333
+ data: input2.data,
1334
+ parsedType: getParsedType(input2.data),
1335
+ schemaErrorMap: this._def.errorMap,
1336
+ path: input2.path,
1337
+ parent: input2.parent
1338
+ };
1339
+ }
1340
+ _processInputParams(input2) {
1341
+ return {
1342
+ status: new ParseStatus(),
1343
+ ctx: {
1344
+ common: input2.parent.common,
1345
+ data: input2.data,
1346
+ parsedType: getParsedType(input2.data),
1347
+ schemaErrorMap: this._def.errorMap,
1348
+ path: input2.path,
1349
+ parent: input2.parent
1350
+ }
1351
+ };
1352
+ }
1353
+ _parseSync(input2) {
1354
+ const result = this._parse(input2);
1355
+ if (isAsync(result)) {
1356
+ throw new Error("Synchronous parse encountered promise.");
1357
+ }
1358
+ return result;
1359
+ }
1360
+ _parseAsync(input2) {
1361
+ const result = this._parse(input2);
1362
+ return Promise.resolve(result);
1363
+ }
1364
+ parse(data, params) {
1365
+ const result = this.safeParse(data, params);
1366
+ if (result.success)
1367
+ return result.data;
1368
+ throw result.error;
1369
+ }
1370
+ safeParse(data, params) {
1371
+ const ctx = {
1372
+ common: {
1373
+ issues: [],
1374
+ async: params?.async ?? false,
1375
+ contextualErrorMap: params?.errorMap
1376
+ },
1377
+ path: params?.path || [],
1378
+ schemaErrorMap: this._def.errorMap,
1379
+ parent: null,
1380
+ data,
1381
+ parsedType: getParsedType(data)
1382
+ };
1383
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
1384
+ return handleResult(ctx, result);
1385
+ }
1386
+ "~validate"(data) {
1387
+ const ctx = {
1388
+ common: {
1389
+ issues: [],
1390
+ async: !!this["~standard"].async
1391
+ },
1392
+ path: [],
1393
+ schemaErrorMap: this._def.errorMap,
1394
+ parent: null,
1395
+ data,
1396
+ parsedType: getParsedType(data)
1397
+ };
1398
+ if (!this["~standard"].async) {
1399
+ try {
1400
+ const result = this._parseSync({ data, path: [], parent: ctx });
1401
+ return isValid(result) ? {
1402
+ value: result.value
1403
+ } : {
1404
+ issues: ctx.common.issues
1405
+ };
1406
+ } catch (err) {
1407
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
1408
+ this["~standard"].async = true;
1409
+ }
1410
+ ctx.common = {
1411
+ issues: [],
1412
+ async: true
1413
+ };
1414
+ }
1415
+ }
1416
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
1417
+ value: result.value
1418
+ } : {
1419
+ issues: ctx.common.issues
1420
+ });
1421
+ }
1422
+ async parseAsync(data, params) {
1423
+ const result = await this.safeParseAsync(data, params);
1424
+ if (result.success)
1425
+ return result.data;
1426
+ throw result.error;
1427
+ }
1428
+ async safeParseAsync(data, params) {
1429
+ const ctx = {
1430
+ common: {
1431
+ issues: [],
1432
+ contextualErrorMap: params?.errorMap,
1433
+ async: true
1434
+ },
1435
+ path: params?.path || [],
1436
+ schemaErrorMap: this._def.errorMap,
1437
+ parent: null,
1438
+ data,
1439
+ parsedType: getParsedType(data)
1440
+ };
1441
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
1442
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
1443
+ return handleResult(ctx, result);
1444
+ }
1445
+ refine(check, message) {
1446
+ const getIssueProperties = (val) => {
1447
+ if (typeof message === "string" || typeof message === "undefined") {
1448
+ return { message };
1449
+ } else if (typeof message === "function") {
1450
+ return message(val);
1451
+ } else {
1452
+ return message;
1453
+ }
1454
+ };
1455
+ return this._refinement((val, ctx) => {
1456
+ const result = check(val);
1457
+ const setError = () => ctx.addIssue({
1458
+ code: ZodIssueCode.custom,
1459
+ ...getIssueProperties(val)
1460
+ });
1461
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
1462
+ return result.then((data) => {
1463
+ if (!data) {
1464
+ setError();
1465
+ return false;
1466
+ } else {
1467
+ return true;
1468
+ }
1469
+ });
1470
+ }
1471
+ if (!result) {
1472
+ setError();
1473
+ return false;
1474
+ } else {
1475
+ return true;
1476
+ }
1477
+ });
1478
+ }
1479
+ refinement(check, refinementData) {
1480
+ return this._refinement((val, ctx) => {
1481
+ if (!check(val)) {
1482
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
1483
+ return false;
1484
+ } else {
1485
+ return true;
1486
+ }
1487
+ });
1488
+ }
1489
+ _refinement(refinement) {
1490
+ return new ZodEffects({
1491
+ schema: this,
1492
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
1493
+ effect: { type: "refinement", refinement }
1494
+ });
1495
+ }
1496
+ superRefine(refinement) {
1497
+ return this._refinement(refinement);
1498
+ }
1499
+ constructor(def) {
1500
+ this.spa = this.safeParseAsync;
1501
+ this._def = def;
1502
+ this.parse = this.parse.bind(this);
1503
+ this.safeParse = this.safeParse.bind(this);
1504
+ this.parseAsync = this.parseAsync.bind(this);
1505
+ this.safeParseAsync = this.safeParseAsync.bind(this);
1506
+ this.spa = this.spa.bind(this);
1507
+ this.refine = this.refine.bind(this);
1508
+ this.refinement = this.refinement.bind(this);
1509
+ this.superRefine = this.superRefine.bind(this);
1510
+ this.optional = this.optional.bind(this);
1511
+ this.nullable = this.nullable.bind(this);
1512
+ this.nullish = this.nullish.bind(this);
1513
+ this.array = this.array.bind(this);
1514
+ this.promise = this.promise.bind(this);
1515
+ this.or = this.or.bind(this);
1516
+ this.and = this.and.bind(this);
1517
+ this.transform = this.transform.bind(this);
1518
+ this.brand = this.brand.bind(this);
1519
+ this.default = this.default.bind(this);
1520
+ this.catch = this.catch.bind(this);
1521
+ this.describe = this.describe.bind(this);
1522
+ this.pipe = this.pipe.bind(this);
1523
+ this.readonly = this.readonly.bind(this);
1524
+ this.isNullable = this.isNullable.bind(this);
1525
+ this.isOptional = this.isOptional.bind(this);
1526
+ this["~standard"] = {
1527
+ version: 1,
1528
+ vendor: "zod",
1529
+ validate: (data) => this["~validate"](data)
1530
+ };
1531
+ }
1532
+ optional() {
1533
+ return ZodOptional.create(this, this._def);
1534
+ }
1535
+ nullable() {
1536
+ return ZodNullable.create(this, this._def);
1537
+ }
1538
+ nullish() {
1539
+ return this.nullable().optional();
1540
+ }
1541
+ array() {
1542
+ return ZodArray.create(this);
1543
+ }
1544
+ promise() {
1545
+ return ZodPromise.create(this, this._def);
1546
+ }
1547
+ or(option) {
1548
+ return ZodUnion.create([this, option], this._def);
1549
+ }
1550
+ and(incoming) {
1551
+ return ZodIntersection.create(this, incoming, this._def);
1552
+ }
1553
+ transform(transform) {
1554
+ return new ZodEffects({
1555
+ ...processCreateParams(this._def),
1556
+ schema: this,
1557
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
1558
+ effect: { type: "transform", transform }
1559
+ });
1560
+ }
1561
+ default(def) {
1562
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
1563
+ return new ZodDefault({
1564
+ ...processCreateParams(this._def),
1565
+ innerType: this,
1566
+ defaultValue: defaultValueFunc,
1567
+ typeName: ZodFirstPartyTypeKind.ZodDefault
1568
+ });
1569
+ }
1570
+ brand() {
1571
+ return new ZodBranded({
1572
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
1573
+ type: this,
1574
+ ...processCreateParams(this._def)
1575
+ });
1576
+ }
1577
+ catch(def) {
1578
+ const catchValueFunc = typeof def === "function" ? def : () => def;
1579
+ return new ZodCatch({
1580
+ ...processCreateParams(this._def),
1581
+ innerType: this,
1582
+ catchValue: catchValueFunc,
1583
+ typeName: ZodFirstPartyTypeKind.ZodCatch
1584
+ });
1585
+ }
1586
+ describe(description) {
1587
+ const This = this.constructor;
1588
+ return new This({
1589
+ ...this._def,
1590
+ description
1591
+ });
1592
+ }
1593
+ pipe(target) {
1594
+ return ZodPipeline.create(this, target);
1595
+ }
1596
+ readonly() {
1597
+ return ZodReadonly.create(this);
1598
+ }
1599
+ isOptional() {
1600
+ return this.safeParse(void 0).success;
1601
+ }
1602
+ isNullable() {
1603
+ return this.safeParse(null).success;
1604
+ }
1605
+ };
1606
+ var cuidRegex = /^c[^\s-]{8,}$/i;
1607
+ var cuid2Regex = /^[0-9a-z]+$/;
1608
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
1609
+ var uuidRegex = /^[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;
1610
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
1611
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
1612
+ var durationRegex = /^[-+]?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)?)??$/;
1613
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
1614
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1615
+ var emojiRegex;
1616
+ var ipv4Regex = /^(?:(?: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])$/;
1617
+ var ipv4CidrRegex = /^(?:(?: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])$/;
1618
+ var ipv6Regex = /^(([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]))$/;
1619
+ var ipv6CidrRegex = /^(([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])$/;
1620
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
1621
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
1622
+ var dateRegexSource = `((\\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])))`;
1623
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
1624
+ function timeRegexSource(args) {
1625
+ let secondsRegexSource = `[0-5]\\d`;
1626
+ if (args.precision) {
1627
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
1628
+ } else if (args.precision == null) {
1629
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
1630
+ }
1631
+ const secondsQuantifier = args.precision ? "+" : "?";
1632
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
1633
+ }
1634
+ function timeRegex(args) {
1635
+ return new RegExp(`^${timeRegexSource(args)}$`);
1636
+ }
1637
+ function datetimeRegex(args) {
1638
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
1639
+ const opts = [];
1640
+ opts.push(args.local ? `Z?` : `Z`);
1641
+ if (args.offset)
1642
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
1643
+ regex = `${regex}(${opts.join("|")})`;
1644
+ return new RegExp(`^${regex}$`);
1645
+ }
1646
+ function isValidIP(ip, version) {
1647
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
1648
+ return true;
1649
+ }
1650
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
1651
+ return true;
1652
+ }
1653
+ return false;
1654
+ }
1655
+ function isValidJWT(jwt, alg) {
1656
+ if (!jwtRegex.test(jwt))
1657
+ return false;
1658
+ try {
1659
+ const [header] = jwt.split(".");
1660
+ if (!header)
1661
+ return false;
1662
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
1663
+ const decoded = JSON.parse(atob(base64));
1664
+ if (typeof decoded !== "object" || decoded === null)
1665
+ return false;
1666
+ if ("typ" in decoded && decoded?.typ !== "JWT")
1667
+ return false;
1668
+ if (!decoded.alg)
1669
+ return false;
1670
+ if (alg && decoded.alg !== alg)
1671
+ return false;
1672
+ return true;
1673
+ } catch {
1674
+ return false;
1675
+ }
1676
+ }
1677
+ function isValidCidr(ip, version) {
1678
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
1679
+ return true;
1680
+ }
1681
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
1682
+ return true;
1683
+ }
1684
+ return false;
1685
+ }
1686
+ var ZodString = class _ZodString extends ZodType {
1687
+ _parse(input2) {
1688
+ if (this._def.coerce) {
1689
+ input2.data = String(input2.data);
1690
+ }
1691
+ const parsedType = this._getType(input2);
1692
+ if (parsedType !== ZodParsedType.string) {
1693
+ const ctx2 = this._getOrReturnCtx(input2);
1694
+ addIssueToContext(ctx2, {
1695
+ code: ZodIssueCode.invalid_type,
1696
+ expected: ZodParsedType.string,
1697
+ received: ctx2.parsedType
1698
+ });
1699
+ return INVALID;
1700
+ }
1701
+ const status = new ParseStatus();
1702
+ let ctx = void 0;
1703
+ for (const check of this._def.checks) {
1704
+ if (check.kind === "min") {
1705
+ if (input2.data.length < check.value) {
1706
+ ctx = this._getOrReturnCtx(input2, ctx);
1707
+ addIssueToContext(ctx, {
1708
+ code: ZodIssueCode.too_small,
1709
+ minimum: check.value,
1710
+ type: "string",
1711
+ inclusive: true,
1712
+ exact: false,
1713
+ message: check.message
1714
+ });
1715
+ status.dirty();
1716
+ }
1717
+ } else if (check.kind === "max") {
1718
+ if (input2.data.length > check.value) {
1719
+ ctx = this._getOrReturnCtx(input2, ctx);
1720
+ addIssueToContext(ctx, {
1721
+ code: ZodIssueCode.too_big,
1722
+ maximum: check.value,
1723
+ type: "string",
1724
+ inclusive: true,
1725
+ exact: false,
1726
+ message: check.message
1727
+ });
1728
+ status.dirty();
1729
+ }
1730
+ } else if (check.kind === "length") {
1731
+ const tooBig = input2.data.length > check.value;
1732
+ const tooSmall = input2.data.length < check.value;
1733
+ if (tooBig || tooSmall) {
1734
+ ctx = this._getOrReturnCtx(input2, ctx);
1735
+ if (tooBig) {
1736
+ addIssueToContext(ctx, {
1737
+ code: ZodIssueCode.too_big,
1738
+ maximum: check.value,
1739
+ type: "string",
1740
+ inclusive: true,
1741
+ exact: true,
1742
+ message: check.message
1743
+ });
1744
+ } else if (tooSmall) {
1745
+ addIssueToContext(ctx, {
1746
+ code: ZodIssueCode.too_small,
1747
+ minimum: check.value,
1748
+ type: "string",
1749
+ inclusive: true,
1750
+ exact: true,
1751
+ message: check.message
1752
+ });
1753
+ }
1754
+ status.dirty();
1755
+ }
1756
+ } else if (check.kind === "email") {
1757
+ if (!emailRegex.test(input2.data)) {
1758
+ ctx = this._getOrReturnCtx(input2, ctx);
1759
+ addIssueToContext(ctx, {
1760
+ validation: "email",
1761
+ code: ZodIssueCode.invalid_string,
1762
+ message: check.message
1763
+ });
1764
+ status.dirty();
1765
+ }
1766
+ } else if (check.kind === "emoji") {
1767
+ if (!emojiRegex) {
1768
+ emojiRegex = new RegExp(_emojiRegex, "u");
1769
+ }
1770
+ if (!emojiRegex.test(input2.data)) {
1771
+ ctx = this._getOrReturnCtx(input2, ctx);
1772
+ addIssueToContext(ctx, {
1773
+ validation: "emoji",
1774
+ code: ZodIssueCode.invalid_string,
1775
+ message: check.message
1776
+ });
1777
+ status.dirty();
1778
+ }
1779
+ } else if (check.kind === "uuid") {
1780
+ if (!uuidRegex.test(input2.data)) {
1781
+ ctx = this._getOrReturnCtx(input2, ctx);
1782
+ addIssueToContext(ctx, {
1783
+ validation: "uuid",
1784
+ code: ZodIssueCode.invalid_string,
1785
+ message: check.message
1786
+ });
1787
+ status.dirty();
1788
+ }
1789
+ } else if (check.kind === "nanoid") {
1790
+ if (!nanoidRegex.test(input2.data)) {
1791
+ ctx = this._getOrReturnCtx(input2, ctx);
1792
+ addIssueToContext(ctx, {
1793
+ validation: "nanoid",
1794
+ code: ZodIssueCode.invalid_string,
1795
+ message: check.message
1796
+ });
1797
+ status.dirty();
1798
+ }
1799
+ } else if (check.kind === "cuid") {
1800
+ if (!cuidRegex.test(input2.data)) {
1801
+ ctx = this._getOrReturnCtx(input2, ctx);
1802
+ addIssueToContext(ctx, {
1803
+ validation: "cuid",
1804
+ code: ZodIssueCode.invalid_string,
1805
+ message: check.message
1806
+ });
1807
+ status.dirty();
1808
+ }
1809
+ } else if (check.kind === "cuid2") {
1810
+ if (!cuid2Regex.test(input2.data)) {
1811
+ ctx = this._getOrReturnCtx(input2, ctx);
1812
+ addIssueToContext(ctx, {
1813
+ validation: "cuid2",
1814
+ code: ZodIssueCode.invalid_string,
1815
+ message: check.message
1816
+ });
1817
+ status.dirty();
1818
+ }
1819
+ } else if (check.kind === "ulid") {
1820
+ if (!ulidRegex.test(input2.data)) {
1821
+ ctx = this._getOrReturnCtx(input2, ctx);
1822
+ addIssueToContext(ctx, {
1823
+ validation: "ulid",
1824
+ code: ZodIssueCode.invalid_string,
1825
+ message: check.message
1826
+ });
1827
+ status.dirty();
1828
+ }
1829
+ } else if (check.kind === "url") {
1830
+ try {
1831
+ new URL(input2.data);
1832
+ } catch {
1833
+ ctx = this._getOrReturnCtx(input2, ctx);
1834
+ addIssueToContext(ctx, {
1835
+ validation: "url",
1836
+ code: ZodIssueCode.invalid_string,
1837
+ message: check.message
1838
+ });
1839
+ status.dirty();
1840
+ }
1841
+ } else if (check.kind === "regex") {
1842
+ check.regex.lastIndex = 0;
1843
+ const testResult = check.regex.test(input2.data);
1844
+ if (!testResult) {
1845
+ ctx = this._getOrReturnCtx(input2, ctx);
1846
+ addIssueToContext(ctx, {
1847
+ validation: "regex",
1848
+ code: ZodIssueCode.invalid_string,
1849
+ message: check.message
1850
+ });
1851
+ status.dirty();
1852
+ }
1853
+ } else if (check.kind === "trim") {
1854
+ input2.data = input2.data.trim();
1855
+ } else if (check.kind === "includes") {
1856
+ if (!input2.data.includes(check.value, check.position)) {
1857
+ ctx = this._getOrReturnCtx(input2, ctx);
1858
+ addIssueToContext(ctx, {
1859
+ code: ZodIssueCode.invalid_string,
1860
+ validation: { includes: check.value, position: check.position },
1861
+ message: check.message
1862
+ });
1863
+ status.dirty();
1864
+ }
1865
+ } else if (check.kind === "toLowerCase") {
1866
+ input2.data = input2.data.toLowerCase();
1867
+ } else if (check.kind === "toUpperCase") {
1868
+ input2.data = input2.data.toUpperCase();
1869
+ } else if (check.kind === "startsWith") {
1870
+ if (!input2.data.startsWith(check.value)) {
1871
+ ctx = this._getOrReturnCtx(input2, ctx);
1872
+ addIssueToContext(ctx, {
1873
+ code: ZodIssueCode.invalid_string,
1874
+ validation: { startsWith: check.value },
1875
+ message: check.message
1876
+ });
1877
+ status.dirty();
1878
+ }
1879
+ } else if (check.kind === "endsWith") {
1880
+ if (!input2.data.endsWith(check.value)) {
1881
+ ctx = this._getOrReturnCtx(input2, ctx);
1882
+ addIssueToContext(ctx, {
1883
+ code: ZodIssueCode.invalid_string,
1884
+ validation: { endsWith: check.value },
1885
+ message: check.message
1886
+ });
1887
+ status.dirty();
1888
+ }
1889
+ } else if (check.kind === "datetime") {
1890
+ const regex = datetimeRegex(check);
1891
+ if (!regex.test(input2.data)) {
1892
+ ctx = this._getOrReturnCtx(input2, ctx);
1893
+ addIssueToContext(ctx, {
1894
+ code: ZodIssueCode.invalid_string,
1895
+ validation: "datetime",
1896
+ message: check.message
1897
+ });
1898
+ status.dirty();
1899
+ }
1900
+ } else if (check.kind === "date") {
1901
+ const regex = dateRegex;
1902
+ if (!regex.test(input2.data)) {
1903
+ ctx = this._getOrReturnCtx(input2, ctx);
1904
+ addIssueToContext(ctx, {
1905
+ code: ZodIssueCode.invalid_string,
1906
+ validation: "date",
1907
+ message: check.message
1908
+ });
1909
+ status.dirty();
1910
+ }
1911
+ } else if (check.kind === "time") {
1912
+ const regex = timeRegex(check);
1913
+ if (!regex.test(input2.data)) {
1914
+ ctx = this._getOrReturnCtx(input2, ctx);
1915
+ addIssueToContext(ctx, {
1916
+ code: ZodIssueCode.invalid_string,
1917
+ validation: "time",
1918
+ message: check.message
1919
+ });
1920
+ status.dirty();
1921
+ }
1922
+ } else if (check.kind === "duration") {
1923
+ if (!durationRegex.test(input2.data)) {
1924
+ ctx = this._getOrReturnCtx(input2, ctx);
1925
+ addIssueToContext(ctx, {
1926
+ validation: "duration",
1927
+ code: ZodIssueCode.invalid_string,
1928
+ message: check.message
1929
+ });
1930
+ status.dirty();
1931
+ }
1932
+ } else if (check.kind === "ip") {
1933
+ if (!isValidIP(input2.data, check.version)) {
1934
+ ctx = this._getOrReturnCtx(input2, ctx);
1935
+ addIssueToContext(ctx, {
1936
+ validation: "ip",
1937
+ code: ZodIssueCode.invalid_string,
1938
+ message: check.message
1939
+ });
1940
+ status.dirty();
1941
+ }
1942
+ } else if (check.kind === "jwt") {
1943
+ if (!isValidJWT(input2.data, check.alg)) {
1944
+ ctx = this._getOrReturnCtx(input2, ctx);
1945
+ addIssueToContext(ctx, {
1946
+ validation: "jwt",
1947
+ code: ZodIssueCode.invalid_string,
1948
+ message: check.message
1949
+ });
1950
+ status.dirty();
1951
+ }
1952
+ } else if (check.kind === "cidr") {
1953
+ if (!isValidCidr(input2.data, check.version)) {
1954
+ ctx = this._getOrReturnCtx(input2, ctx);
1955
+ addIssueToContext(ctx, {
1956
+ validation: "cidr",
1957
+ code: ZodIssueCode.invalid_string,
1958
+ message: check.message
1959
+ });
1960
+ status.dirty();
1961
+ }
1962
+ } else if (check.kind === "base64") {
1963
+ if (!base64Regex.test(input2.data)) {
1964
+ ctx = this._getOrReturnCtx(input2, ctx);
1965
+ addIssueToContext(ctx, {
1966
+ validation: "base64",
1967
+ code: ZodIssueCode.invalid_string,
1968
+ message: check.message
1969
+ });
1970
+ status.dirty();
1971
+ }
1972
+ } else if (check.kind === "base64url") {
1973
+ if (!base64urlRegex.test(input2.data)) {
1974
+ ctx = this._getOrReturnCtx(input2, ctx);
1975
+ addIssueToContext(ctx, {
1976
+ validation: "base64url",
1977
+ code: ZodIssueCode.invalid_string,
1978
+ message: check.message
1979
+ });
1980
+ status.dirty();
1981
+ }
1982
+ } else {
1983
+ util.assertNever(check);
1984
+ }
1985
+ }
1986
+ return { status: status.value, value: input2.data };
1987
+ }
1988
+ _regex(regex, validation, message) {
1989
+ return this.refinement((data) => regex.test(data), {
1990
+ validation,
1991
+ code: ZodIssueCode.invalid_string,
1992
+ ...errorUtil.errToObj(message)
1993
+ });
1994
+ }
1995
+ _addCheck(check) {
1996
+ return new _ZodString({
1997
+ ...this._def,
1998
+ checks: [...this._def.checks, check]
1999
+ });
2000
+ }
2001
+ email(message) {
2002
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
2003
+ }
2004
+ url(message) {
2005
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
2006
+ }
2007
+ emoji(message) {
2008
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
2009
+ }
2010
+ uuid(message) {
2011
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
2012
+ }
2013
+ nanoid(message) {
2014
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
2015
+ }
2016
+ cuid(message) {
2017
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
2018
+ }
2019
+ cuid2(message) {
2020
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
2021
+ }
2022
+ ulid(message) {
2023
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
2024
+ }
2025
+ base64(message) {
2026
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
2027
+ }
2028
+ base64url(message) {
2029
+ return this._addCheck({
2030
+ kind: "base64url",
2031
+ ...errorUtil.errToObj(message)
2032
+ });
2033
+ }
2034
+ jwt(options) {
2035
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
2036
+ }
2037
+ ip(options) {
2038
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
2039
+ }
2040
+ cidr(options) {
2041
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
2042
+ }
2043
+ datetime(options) {
2044
+ if (typeof options === "string") {
2045
+ return this._addCheck({
2046
+ kind: "datetime",
2047
+ precision: null,
2048
+ offset: false,
2049
+ local: false,
2050
+ message: options
2051
+ });
2052
+ }
2053
+ return this._addCheck({
2054
+ kind: "datetime",
2055
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
2056
+ offset: options?.offset ?? false,
2057
+ local: options?.local ?? false,
2058
+ ...errorUtil.errToObj(options?.message)
2059
+ });
2060
+ }
2061
+ date(message) {
2062
+ return this._addCheck({ kind: "date", message });
2063
+ }
2064
+ time(options) {
2065
+ if (typeof options === "string") {
2066
+ return this._addCheck({
2067
+ kind: "time",
2068
+ precision: null,
2069
+ message: options
2070
+ });
2071
+ }
2072
+ return this._addCheck({
2073
+ kind: "time",
2074
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
2075
+ ...errorUtil.errToObj(options?.message)
2076
+ });
2077
+ }
2078
+ duration(message) {
2079
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
2080
+ }
2081
+ regex(regex, message) {
2082
+ return this._addCheck({
2083
+ kind: "regex",
2084
+ regex,
2085
+ ...errorUtil.errToObj(message)
2086
+ });
2087
+ }
2088
+ includes(value, options) {
2089
+ return this._addCheck({
2090
+ kind: "includes",
2091
+ value,
2092
+ position: options?.position,
2093
+ ...errorUtil.errToObj(options?.message)
2094
+ });
2095
+ }
2096
+ startsWith(value, message) {
2097
+ return this._addCheck({
2098
+ kind: "startsWith",
2099
+ value,
2100
+ ...errorUtil.errToObj(message)
2101
+ });
2102
+ }
2103
+ endsWith(value, message) {
2104
+ return this._addCheck({
2105
+ kind: "endsWith",
2106
+ value,
2107
+ ...errorUtil.errToObj(message)
2108
+ });
2109
+ }
2110
+ min(minLength, message) {
2111
+ return this._addCheck({
2112
+ kind: "min",
2113
+ value: minLength,
2114
+ ...errorUtil.errToObj(message)
2115
+ });
2116
+ }
2117
+ max(maxLength, message) {
2118
+ return this._addCheck({
2119
+ kind: "max",
2120
+ value: maxLength,
2121
+ ...errorUtil.errToObj(message)
2122
+ });
2123
+ }
2124
+ length(len, message) {
2125
+ return this._addCheck({
2126
+ kind: "length",
2127
+ value: len,
2128
+ ...errorUtil.errToObj(message)
2129
+ });
2130
+ }
2131
+ /**
2132
+ * Equivalent to `.min(1)`
2133
+ */
2134
+ nonempty(message) {
2135
+ return this.min(1, errorUtil.errToObj(message));
2136
+ }
2137
+ trim() {
2138
+ return new _ZodString({
2139
+ ...this._def,
2140
+ checks: [...this._def.checks, { kind: "trim" }]
2141
+ });
2142
+ }
2143
+ toLowerCase() {
2144
+ return new _ZodString({
2145
+ ...this._def,
2146
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
2147
+ });
2148
+ }
2149
+ toUpperCase() {
2150
+ return new _ZodString({
2151
+ ...this._def,
2152
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
2153
+ });
2154
+ }
2155
+ get isDatetime() {
2156
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
2157
+ }
2158
+ get isDate() {
2159
+ return !!this._def.checks.find((ch) => ch.kind === "date");
2160
+ }
2161
+ get isTime() {
2162
+ return !!this._def.checks.find((ch) => ch.kind === "time");
2163
+ }
2164
+ get isDuration() {
2165
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
2166
+ }
2167
+ get isEmail() {
2168
+ return !!this._def.checks.find((ch) => ch.kind === "email");
2169
+ }
2170
+ get isURL() {
2171
+ return !!this._def.checks.find((ch) => ch.kind === "url");
2172
+ }
2173
+ get isEmoji() {
2174
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
2175
+ }
2176
+ get isUUID() {
2177
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
2178
+ }
2179
+ get isNANOID() {
2180
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
2181
+ }
2182
+ get isCUID() {
2183
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
2184
+ }
2185
+ get isCUID2() {
2186
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
2187
+ }
2188
+ get isULID() {
2189
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
2190
+ }
2191
+ get isIP() {
2192
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
2193
+ }
2194
+ get isCIDR() {
2195
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
2196
+ }
2197
+ get isBase64() {
2198
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
2199
+ }
2200
+ get isBase64url() {
2201
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
2202
+ }
2203
+ get minLength() {
2204
+ let min = null;
2205
+ for (const ch of this._def.checks) {
2206
+ if (ch.kind === "min") {
2207
+ if (min === null || ch.value > min)
2208
+ min = ch.value;
2209
+ }
2210
+ }
2211
+ return min;
2212
+ }
2213
+ get maxLength() {
2214
+ let max = null;
2215
+ for (const ch of this._def.checks) {
2216
+ if (ch.kind === "max") {
2217
+ if (max === null || ch.value < max)
2218
+ max = ch.value;
2219
+ }
2220
+ }
2221
+ return max;
2222
+ }
2223
+ };
2224
+ ZodString.create = (params) => {
2225
+ return new ZodString({
2226
+ checks: [],
2227
+ typeName: ZodFirstPartyTypeKind.ZodString,
2228
+ coerce: params?.coerce ?? false,
2229
+ ...processCreateParams(params)
2230
+ });
2231
+ };
2232
+ function floatSafeRemainder(val, step) {
2233
+ const valDecCount = (val.toString().split(".")[1] || "").length;
2234
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
2235
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
2236
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
2237
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
2238
+ return valInt % stepInt / 10 ** decCount;
2239
+ }
2240
+ var ZodNumber = class _ZodNumber extends ZodType {
2241
+ constructor() {
2242
+ super(...arguments);
2243
+ this.min = this.gte;
2244
+ this.max = this.lte;
2245
+ this.step = this.multipleOf;
2246
+ }
2247
+ _parse(input2) {
2248
+ if (this._def.coerce) {
2249
+ input2.data = Number(input2.data);
2250
+ }
2251
+ const parsedType = this._getType(input2);
2252
+ if (parsedType !== ZodParsedType.number) {
2253
+ const ctx2 = this._getOrReturnCtx(input2);
2254
+ addIssueToContext(ctx2, {
2255
+ code: ZodIssueCode.invalid_type,
2256
+ expected: ZodParsedType.number,
2257
+ received: ctx2.parsedType
2258
+ });
2259
+ return INVALID;
2260
+ }
2261
+ let ctx = void 0;
2262
+ const status = new ParseStatus();
2263
+ for (const check of this._def.checks) {
2264
+ if (check.kind === "int") {
2265
+ if (!util.isInteger(input2.data)) {
2266
+ ctx = this._getOrReturnCtx(input2, ctx);
2267
+ addIssueToContext(ctx, {
2268
+ code: ZodIssueCode.invalid_type,
2269
+ expected: "integer",
2270
+ received: "float",
2271
+ message: check.message
2272
+ });
2273
+ status.dirty();
2274
+ }
2275
+ } else if (check.kind === "min") {
2276
+ const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
2277
+ if (tooSmall) {
2278
+ ctx = this._getOrReturnCtx(input2, ctx);
2279
+ addIssueToContext(ctx, {
2280
+ code: ZodIssueCode.too_small,
2281
+ minimum: check.value,
2282
+ type: "number",
2283
+ inclusive: check.inclusive,
2284
+ exact: false,
2285
+ message: check.message
2286
+ });
2287
+ status.dirty();
2288
+ }
2289
+ } else if (check.kind === "max") {
2290
+ const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
2291
+ if (tooBig) {
2292
+ ctx = this._getOrReturnCtx(input2, ctx);
2293
+ addIssueToContext(ctx, {
2294
+ code: ZodIssueCode.too_big,
2295
+ maximum: check.value,
2296
+ type: "number",
2297
+ inclusive: check.inclusive,
2298
+ exact: false,
2299
+ message: check.message
2300
+ });
2301
+ status.dirty();
2302
+ }
2303
+ } else if (check.kind === "multipleOf") {
2304
+ if (floatSafeRemainder(input2.data, check.value) !== 0) {
2305
+ ctx = this._getOrReturnCtx(input2, ctx);
2306
+ addIssueToContext(ctx, {
2307
+ code: ZodIssueCode.not_multiple_of,
2308
+ multipleOf: check.value,
2309
+ message: check.message
2310
+ });
2311
+ status.dirty();
2312
+ }
2313
+ } else if (check.kind === "finite") {
2314
+ if (!Number.isFinite(input2.data)) {
2315
+ ctx = this._getOrReturnCtx(input2, ctx);
2316
+ addIssueToContext(ctx, {
2317
+ code: ZodIssueCode.not_finite,
2318
+ message: check.message
2319
+ });
2320
+ status.dirty();
2321
+ }
2322
+ } else {
2323
+ util.assertNever(check);
2324
+ }
2325
+ }
2326
+ return { status: status.value, value: input2.data };
2327
+ }
2328
+ gte(value, message) {
2329
+ return this.setLimit("min", value, true, errorUtil.toString(message));
2330
+ }
2331
+ gt(value, message) {
2332
+ return this.setLimit("min", value, false, errorUtil.toString(message));
2333
+ }
2334
+ lte(value, message) {
2335
+ return this.setLimit("max", value, true, errorUtil.toString(message));
2336
+ }
2337
+ lt(value, message) {
2338
+ return this.setLimit("max", value, false, errorUtil.toString(message));
2339
+ }
2340
+ setLimit(kind, value, inclusive, message) {
2341
+ return new _ZodNumber({
2342
+ ...this._def,
2343
+ checks: [
2344
+ ...this._def.checks,
2345
+ {
2346
+ kind,
2347
+ value,
2348
+ inclusive,
2349
+ message: errorUtil.toString(message)
2350
+ }
2351
+ ]
2352
+ });
2353
+ }
2354
+ _addCheck(check) {
2355
+ return new _ZodNumber({
2356
+ ...this._def,
2357
+ checks: [...this._def.checks, check]
2358
+ });
2359
+ }
2360
+ int(message) {
2361
+ return this._addCheck({
2362
+ kind: "int",
2363
+ message: errorUtil.toString(message)
2364
+ });
2365
+ }
2366
+ positive(message) {
2367
+ return this._addCheck({
2368
+ kind: "min",
2369
+ value: 0,
2370
+ inclusive: false,
2371
+ message: errorUtil.toString(message)
2372
+ });
2373
+ }
2374
+ negative(message) {
2375
+ return this._addCheck({
2376
+ kind: "max",
2377
+ value: 0,
2378
+ inclusive: false,
2379
+ message: errorUtil.toString(message)
2380
+ });
2381
+ }
2382
+ nonpositive(message) {
2383
+ return this._addCheck({
2384
+ kind: "max",
2385
+ value: 0,
2386
+ inclusive: true,
2387
+ message: errorUtil.toString(message)
2388
+ });
2389
+ }
2390
+ nonnegative(message) {
2391
+ return this._addCheck({
2392
+ kind: "min",
2393
+ value: 0,
2394
+ inclusive: true,
2395
+ message: errorUtil.toString(message)
2396
+ });
2397
+ }
2398
+ multipleOf(value, message) {
2399
+ return this._addCheck({
2400
+ kind: "multipleOf",
2401
+ value,
2402
+ message: errorUtil.toString(message)
2403
+ });
2404
+ }
2405
+ finite(message) {
2406
+ return this._addCheck({
2407
+ kind: "finite",
2408
+ message: errorUtil.toString(message)
2409
+ });
2410
+ }
2411
+ safe(message) {
2412
+ return this._addCheck({
2413
+ kind: "min",
2414
+ inclusive: true,
2415
+ value: Number.MIN_SAFE_INTEGER,
2416
+ message: errorUtil.toString(message)
2417
+ })._addCheck({
2418
+ kind: "max",
2419
+ inclusive: true,
2420
+ value: Number.MAX_SAFE_INTEGER,
2421
+ message: errorUtil.toString(message)
2422
+ });
2423
+ }
2424
+ get minValue() {
2425
+ let min = null;
2426
+ for (const ch of this._def.checks) {
2427
+ if (ch.kind === "min") {
2428
+ if (min === null || ch.value > min)
2429
+ min = ch.value;
2430
+ }
2431
+ }
2432
+ return min;
2433
+ }
2434
+ get maxValue() {
2435
+ let max = null;
2436
+ for (const ch of this._def.checks) {
2437
+ if (ch.kind === "max") {
2438
+ if (max === null || ch.value < max)
2439
+ max = ch.value;
2440
+ }
2441
+ }
2442
+ return max;
2443
+ }
2444
+ get isInt() {
2445
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
2446
+ }
2447
+ get isFinite() {
2448
+ let max = null;
2449
+ let min = null;
2450
+ for (const ch of this._def.checks) {
2451
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
2452
+ return true;
2453
+ } else if (ch.kind === "min") {
2454
+ if (min === null || ch.value > min)
2455
+ min = ch.value;
2456
+ } else if (ch.kind === "max") {
2457
+ if (max === null || ch.value < max)
2458
+ max = ch.value;
2459
+ }
2460
+ }
2461
+ return Number.isFinite(min) && Number.isFinite(max);
2462
+ }
2463
+ };
2464
+ ZodNumber.create = (params) => {
2465
+ return new ZodNumber({
2466
+ checks: [],
2467
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
2468
+ coerce: params?.coerce || false,
2469
+ ...processCreateParams(params)
2470
+ });
2471
+ };
2472
+ var ZodBigInt = class _ZodBigInt extends ZodType {
2473
+ constructor() {
2474
+ super(...arguments);
2475
+ this.min = this.gte;
2476
+ this.max = this.lte;
2477
+ }
2478
+ _parse(input2) {
2479
+ if (this._def.coerce) {
2480
+ try {
2481
+ input2.data = BigInt(input2.data);
2482
+ } catch {
2483
+ return this._getInvalidInput(input2);
2484
+ }
2485
+ }
2486
+ const parsedType = this._getType(input2);
2487
+ if (parsedType !== ZodParsedType.bigint) {
2488
+ return this._getInvalidInput(input2);
2489
+ }
2490
+ let ctx = void 0;
2491
+ const status = new ParseStatus();
2492
+ for (const check of this._def.checks) {
2493
+ if (check.kind === "min") {
2494
+ const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
2495
+ if (tooSmall) {
2496
+ ctx = this._getOrReturnCtx(input2, ctx);
2497
+ addIssueToContext(ctx, {
2498
+ code: ZodIssueCode.too_small,
2499
+ type: "bigint",
2500
+ minimum: check.value,
2501
+ inclusive: check.inclusive,
2502
+ message: check.message
2503
+ });
2504
+ status.dirty();
2505
+ }
2506
+ } else if (check.kind === "max") {
2507
+ const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
2508
+ if (tooBig) {
2509
+ ctx = this._getOrReturnCtx(input2, ctx);
2510
+ addIssueToContext(ctx, {
2511
+ code: ZodIssueCode.too_big,
2512
+ type: "bigint",
2513
+ maximum: check.value,
2514
+ inclusive: check.inclusive,
2515
+ message: check.message
2516
+ });
2517
+ status.dirty();
2518
+ }
2519
+ } else if (check.kind === "multipleOf") {
2520
+ if (input2.data % check.value !== BigInt(0)) {
2521
+ ctx = this._getOrReturnCtx(input2, ctx);
2522
+ addIssueToContext(ctx, {
2523
+ code: ZodIssueCode.not_multiple_of,
2524
+ multipleOf: check.value,
2525
+ message: check.message
2526
+ });
2527
+ status.dirty();
2528
+ }
2529
+ } else {
2530
+ util.assertNever(check);
2531
+ }
2532
+ }
2533
+ return { status: status.value, value: input2.data };
2534
+ }
2535
+ _getInvalidInput(input2) {
2536
+ const ctx = this._getOrReturnCtx(input2);
2537
+ addIssueToContext(ctx, {
2538
+ code: ZodIssueCode.invalid_type,
2539
+ expected: ZodParsedType.bigint,
2540
+ received: ctx.parsedType
2541
+ });
2542
+ return INVALID;
2543
+ }
2544
+ gte(value, message) {
2545
+ return this.setLimit("min", value, true, errorUtil.toString(message));
2546
+ }
2547
+ gt(value, message) {
2548
+ return this.setLimit("min", value, false, errorUtil.toString(message));
2549
+ }
2550
+ lte(value, message) {
2551
+ return this.setLimit("max", value, true, errorUtil.toString(message));
2552
+ }
2553
+ lt(value, message) {
2554
+ return this.setLimit("max", value, false, errorUtil.toString(message));
2555
+ }
2556
+ setLimit(kind, value, inclusive, message) {
2557
+ return new _ZodBigInt({
2558
+ ...this._def,
2559
+ checks: [
2560
+ ...this._def.checks,
2561
+ {
2562
+ kind,
2563
+ value,
2564
+ inclusive,
2565
+ message: errorUtil.toString(message)
2566
+ }
2567
+ ]
2568
+ });
2569
+ }
2570
+ _addCheck(check) {
2571
+ return new _ZodBigInt({
2572
+ ...this._def,
2573
+ checks: [...this._def.checks, check]
2574
+ });
2575
+ }
2576
+ positive(message) {
2577
+ return this._addCheck({
2578
+ kind: "min",
2579
+ value: BigInt(0),
2580
+ inclusive: false,
2581
+ message: errorUtil.toString(message)
2582
+ });
2583
+ }
2584
+ negative(message) {
2585
+ return this._addCheck({
2586
+ kind: "max",
2587
+ value: BigInt(0),
2588
+ inclusive: false,
2589
+ message: errorUtil.toString(message)
2590
+ });
2591
+ }
2592
+ nonpositive(message) {
2593
+ return this._addCheck({
2594
+ kind: "max",
2595
+ value: BigInt(0),
2596
+ inclusive: true,
2597
+ message: errorUtil.toString(message)
2598
+ });
2599
+ }
2600
+ nonnegative(message) {
2601
+ return this._addCheck({
2602
+ kind: "min",
2603
+ value: BigInt(0),
2604
+ inclusive: true,
2605
+ message: errorUtil.toString(message)
2606
+ });
2607
+ }
2608
+ multipleOf(value, message) {
2609
+ return this._addCheck({
2610
+ kind: "multipleOf",
2611
+ value,
2612
+ message: errorUtil.toString(message)
2613
+ });
2614
+ }
2615
+ get minValue() {
2616
+ let min = null;
2617
+ for (const ch of this._def.checks) {
2618
+ if (ch.kind === "min") {
2619
+ if (min === null || ch.value > min)
2620
+ min = ch.value;
2621
+ }
2622
+ }
2623
+ return min;
2624
+ }
2625
+ get maxValue() {
2626
+ let max = null;
2627
+ for (const ch of this._def.checks) {
2628
+ if (ch.kind === "max") {
2629
+ if (max === null || ch.value < max)
2630
+ max = ch.value;
2631
+ }
2632
+ }
2633
+ return max;
2634
+ }
2635
+ };
2636
+ ZodBigInt.create = (params) => {
2637
+ return new ZodBigInt({
2638
+ checks: [],
2639
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
2640
+ coerce: params?.coerce ?? false,
2641
+ ...processCreateParams(params)
2642
+ });
2643
+ };
2644
+ var ZodBoolean = class extends ZodType {
2645
+ _parse(input2) {
2646
+ if (this._def.coerce) {
2647
+ input2.data = Boolean(input2.data);
2648
+ }
2649
+ const parsedType = this._getType(input2);
2650
+ if (parsedType !== ZodParsedType.boolean) {
2651
+ const ctx = this._getOrReturnCtx(input2);
2652
+ addIssueToContext(ctx, {
2653
+ code: ZodIssueCode.invalid_type,
2654
+ expected: ZodParsedType.boolean,
2655
+ received: ctx.parsedType
2656
+ });
2657
+ return INVALID;
2658
+ }
2659
+ return OK(input2.data);
2660
+ }
2661
+ };
2662
+ ZodBoolean.create = (params) => {
2663
+ return new ZodBoolean({
2664
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
2665
+ coerce: params?.coerce || false,
2666
+ ...processCreateParams(params)
2667
+ });
2668
+ };
2669
+ var ZodDate = class _ZodDate extends ZodType {
2670
+ _parse(input2) {
2671
+ if (this._def.coerce) {
2672
+ input2.data = new Date(input2.data);
2673
+ }
2674
+ const parsedType = this._getType(input2);
2675
+ if (parsedType !== ZodParsedType.date) {
2676
+ const ctx2 = this._getOrReturnCtx(input2);
2677
+ addIssueToContext(ctx2, {
2678
+ code: ZodIssueCode.invalid_type,
2679
+ expected: ZodParsedType.date,
2680
+ received: ctx2.parsedType
2681
+ });
2682
+ return INVALID;
2683
+ }
2684
+ if (Number.isNaN(input2.data.getTime())) {
2685
+ const ctx2 = this._getOrReturnCtx(input2);
2686
+ addIssueToContext(ctx2, {
2687
+ code: ZodIssueCode.invalid_date
2688
+ });
2689
+ return INVALID;
2690
+ }
2691
+ const status = new ParseStatus();
2692
+ let ctx = void 0;
2693
+ for (const check of this._def.checks) {
2694
+ if (check.kind === "min") {
2695
+ if (input2.data.getTime() < check.value) {
2696
+ ctx = this._getOrReturnCtx(input2, ctx);
2697
+ addIssueToContext(ctx, {
2698
+ code: ZodIssueCode.too_small,
2699
+ message: check.message,
2700
+ inclusive: true,
2701
+ exact: false,
2702
+ minimum: check.value,
2703
+ type: "date"
2704
+ });
2705
+ status.dirty();
2706
+ }
2707
+ } else if (check.kind === "max") {
2708
+ if (input2.data.getTime() > check.value) {
2709
+ ctx = this._getOrReturnCtx(input2, ctx);
2710
+ addIssueToContext(ctx, {
2711
+ code: ZodIssueCode.too_big,
2712
+ message: check.message,
2713
+ inclusive: true,
2714
+ exact: false,
2715
+ maximum: check.value,
2716
+ type: "date"
2717
+ });
2718
+ status.dirty();
2719
+ }
2720
+ } else {
2721
+ util.assertNever(check);
2722
+ }
2723
+ }
2724
+ return {
2725
+ status: status.value,
2726
+ value: new Date(input2.data.getTime())
2727
+ };
2728
+ }
2729
+ _addCheck(check) {
2730
+ return new _ZodDate({
2731
+ ...this._def,
2732
+ checks: [...this._def.checks, check]
2733
+ });
2734
+ }
2735
+ min(minDate, message) {
2736
+ return this._addCheck({
2737
+ kind: "min",
2738
+ value: minDate.getTime(),
2739
+ message: errorUtil.toString(message)
2740
+ });
2741
+ }
2742
+ max(maxDate, message) {
2743
+ return this._addCheck({
2744
+ kind: "max",
2745
+ value: maxDate.getTime(),
2746
+ message: errorUtil.toString(message)
2747
+ });
2748
+ }
2749
+ get minDate() {
2750
+ let min = null;
2751
+ for (const ch of this._def.checks) {
2752
+ if (ch.kind === "min") {
2753
+ if (min === null || ch.value > min)
2754
+ min = ch.value;
2755
+ }
2756
+ }
2757
+ return min != null ? new Date(min) : null;
2758
+ }
2759
+ get maxDate() {
2760
+ let max = null;
2761
+ for (const ch of this._def.checks) {
2762
+ if (ch.kind === "max") {
2763
+ if (max === null || ch.value < max)
2764
+ max = ch.value;
2765
+ }
2766
+ }
2767
+ return max != null ? new Date(max) : null;
2768
+ }
2769
+ };
2770
+ ZodDate.create = (params) => {
2771
+ return new ZodDate({
2772
+ checks: [],
2773
+ coerce: params?.coerce || false,
2774
+ typeName: ZodFirstPartyTypeKind.ZodDate,
2775
+ ...processCreateParams(params)
2776
+ });
2777
+ };
2778
+ var ZodSymbol = class extends ZodType {
2779
+ _parse(input2) {
2780
+ const parsedType = this._getType(input2);
2781
+ if (parsedType !== ZodParsedType.symbol) {
2782
+ const ctx = this._getOrReturnCtx(input2);
2783
+ addIssueToContext(ctx, {
2784
+ code: ZodIssueCode.invalid_type,
2785
+ expected: ZodParsedType.symbol,
2786
+ received: ctx.parsedType
2787
+ });
2788
+ return INVALID;
2789
+ }
2790
+ return OK(input2.data);
2791
+ }
2792
+ };
2793
+ ZodSymbol.create = (params) => {
2794
+ return new ZodSymbol({
2795
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
2796
+ ...processCreateParams(params)
2797
+ });
2798
+ };
2799
+ var ZodUndefined = class extends ZodType {
2800
+ _parse(input2) {
2801
+ const parsedType = this._getType(input2);
2802
+ if (parsedType !== ZodParsedType.undefined) {
2803
+ const ctx = this._getOrReturnCtx(input2);
2804
+ addIssueToContext(ctx, {
2805
+ code: ZodIssueCode.invalid_type,
2806
+ expected: ZodParsedType.undefined,
2807
+ received: ctx.parsedType
2808
+ });
2809
+ return INVALID;
2810
+ }
2811
+ return OK(input2.data);
2812
+ }
2813
+ };
2814
+ ZodUndefined.create = (params) => {
2815
+ return new ZodUndefined({
2816
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
2817
+ ...processCreateParams(params)
2818
+ });
2819
+ };
2820
+ var ZodNull = class extends ZodType {
2821
+ _parse(input2) {
2822
+ const parsedType = this._getType(input2);
2823
+ if (parsedType !== ZodParsedType.null) {
2824
+ const ctx = this._getOrReturnCtx(input2);
2825
+ addIssueToContext(ctx, {
2826
+ code: ZodIssueCode.invalid_type,
2827
+ expected: ZodParsedType.null,
2828
+ received: ctx.parsedType
2829
+ });
2830
+ return INVALID;
2831
+ }
2832
+ return OK(input2.data);
2833
+ }
2834
+ };
2835
+ ZodNull.create = (params) => {
2836
+ return new ZodNull({
2837
+ typeName: ZodFirstPartyTypeKind.ZodNull,
2838
+ ...processCreateParams(params)
2839
+ });
2840
+ };
2841
+ var ZodAny = class extends ZodType {
2842
+ constructor() {
2843
+ super(...arguments);
2844
+ this._any = true;
2845
+ }
2846
+ _parse(input2) {
2847
+ return OK(input2.data);
2848
+ }
2849
+ };
2850
+ ZodAny.create = (params) => {
2851
+ return new ZodAny({
2852
+ typeName: ZodFirstPartyTypeKind.ZodAny,
2853
+ ...processCreateParams(params)
2854
+ });
2855
+ };
2856
+ var ZodUnknown = class extends ZodType {
2857
+ constructor() {
2858
+ super(...arguments);
2859
+ this._unknown = true;
2860
+ }
2861
+ _parse(input2) {
2862
+ return OK(input2.data);
2863
+ }
2864
+ };
2865
+ ZodUnknown.create = (params) => {
2866
+ return new ZodUnknown({
2867
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
2868
+ ...processCreateParams(params)
2869
+ });
2870
+ };
2871
+ var ZodNever = class extends ZodType {
2872
+ _parse(input2) {
2873
+ const ctx = this._getOrReturnCtx(input2);
2874
+ addIssueToContext(ctx, {
2875
+ code: ZodIssueCode.invalid_type,
2876
+ expected: ZodParsedType.never,
2877
+ received: ctx.parsedType
2878
+ });
2879
+ return INVALID;
2880
+ }
2881
+ };
2882
+ ZodNever.create = (params) => {
2883
+ return new ZodNever({
2884
+ typeName: ZodFirstPartyTypeKind.ZodNever,
2885
+ ...processCreateParams(params)
2886
+ });
2887
+ };
2888
+ var ZodVoid = class extends ZodType {
2889
+ _parse(input2) {
2890
+ const parsedType = this._getType(input2);
2891
+ if (parsedType !== ZodParsedType.undefined) {
2892
+ const ctx = this._getOrReturnCtx(input2);
2893
+ addIssueToContext(ctx, {
2894
+ code: ZodIssueCode.invalid_type,
2895
+ expected: ZodParsedType.void,
2896
+ received: ctx.parsedType
2897
+ });
2898
+ return INVALID;
2899
+ }
2900
+ return OK(input2.data);
2901
+ }
2902
+ };
2903
+ ZodVoid.create = (params) => {
2904
+ return new ZodVoid({
2905
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
2906
+ ...processCreateParams(params)
2907
+ });
2908
+ };
2909
+ var ZodArray = class _ZodArray extends ZodType {
2910
+ _parse(input2) {
2911
+ const { ctx, status } = this._processInputParams(input2);
2912
+ const def = this._def;
2913
+ if (ctx.parsedType !== ZodParsedType.array) {
2914
+ addIssueToContext(ctx, {
2915
+ code: ZodIssueCode.invalid_type,
2916
+ expected: ZodParsedType.array,
2917
+ received: ctx.parsedType
2918
+ });
2919
+ return INVALID;
2920
+ }
2921
+ if (def.exactLength !== null) {
2922
+ const tooBig = ctx.data.length > def.exactLength.value;
2923
+ const tooSmall = ctx.data.length < def.exactLength.value;
2924
+ if (tooBig || tooSmall) {
2925
+ addIssueToContext(ctx, {
2926
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
2927
+ minimum: tooSmall ? def.exactLength.value : void 0,
2928
+ maximum: tooBig ? def.exactLength.value : void 0,
2929
+ type: "array",
2930
+ inclusive: true,
2931
+ exact: true,
2932
+ message: def.exactLength.message
2933
+ });
2934
+ status.dirty();
2935
+ }
2936
+ }
2937
+ if (def.minLength !== null) {
2938
+ if (ctx.data.length < def.minLength.value) {
2939
+ addIssueToContext(ctx, {
2940
+ code: ZodIssueCode.too_small,
2941
+ minimum: def.minLength.value,
2942
+ type: "array",
2943
+ inclusive: true,
2944
+ exact: false,
2945
+ message: def.minLength.message
2946
+ });
2947
+ status.dirty();
2948
+ }
2949
+ }
2950
+ if (def.maxLength !== null) {
2951
+ if (ctx.data.length > def.maxLength.value) {
2952
+ addIssueToContext(ctx, {
2953
+ code: ZodIssueCode.too_big,
2954
+ maximum: def.maxLength.value,
2955
+ type: "array",
2956
+ inclusive: true,
2957
+ exact: false,
2958
+ message: def.maxLength.message
2959
+ });
2960
+ status.dirty();
2961
+ }
2962
+ }
2963
+ if (ctx.common.async) {
2964
+ return Promise.all([...ctx.data].map((item, i) => {
2965
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2966
+ })).then((result2) => {
2967
+ return ParseStatus.mergeArray(status, result2);
2968
+ });
2969
+ }
2970
+ const result = [...ctx.data].map((item, i) => {
2971
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2972
+ });
2973
+ return ParseStatus.mergeArray(status, result);
2974
+ }
2975
+ get element() {
2976
+ return this._def.type;
2977
+ }
2978
+ min(minLength, message) {
2979
+ return new _ZodArray({
2980
+ ...this._def,
2981
+ minLength: { value: minLength, message: errorUtil.toString(message) }
2982
+ });
2983
+ }
2984
+ max(maxLength, message) {
2985
+ return new _ZodArray({
2986
+ ...this._def,
2987
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
2988
+ });
2989
+ }
2990
+ length(len, message) {
2991
+ return new _ZodArray({
2992
+ ...this._def,
2993
+ exactLength: { value: len, message: errorUtil.toString(message) }
2994
+ });
2995
+ }
2996
+ nonempty(message) {
2997
+ return this.min(1, message);
2998
+ }
2999
+ };
3000
+ ZodArray.create = (schema, params) => {
3001
+ return new ZodArray({
3002
+ type: schema,
3003
+ minLength: null,
3004
+ maxLength: null,
3005
+ exactLength: null,
3006
+ typeName: ZodFirstPartyTypeKind.ZodArray,
3007
+ ...processCreateParams(params)
3008
+ });
3009
+ };
3010
+ function deepPartialify(schema) {
3011
+ if (schema instanceof ZodObject) {
3012
+ const newShape = {};
3013
+ for (const key in schema.shape) {
3014
+ const fieldSchema = schema.shape[key];
3015
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
3016
+ }
3017
+ return new ZodObject({
3018
+ ...schema._def,
3019
+ shape: () => newShape
3020
+ });
3021
+ } else if (schema instanceof ZodArray) {
3022
+ return new ZodArray({
3023
+ ...schema._def,
3024
+ type: deepPartialify(schema.element)
3025
+ });
3026
+ } else if (schema instanceof ZodOptional) {
3027
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
3028
+ } else if (schema instanceof ZodNullable) {
3029
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
3030
+ } else if (schema instanceof ZodTuple) {
3031
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
3032
+ } else {
3033
+ return schema;
3034
+ }
3035
+ }
3036
+ var ZodObject = class _ZodObject extends ZodType {
3037
+ constructor() {
3038
+ super(...arguments);
3039
+ this._cached = null;
3040
+ this.nonstrict = this.passthrough;
3041
+ this.augment = this.extend;
3042
+ }
3043
+ _getCached() {
3044
+ if (this._cached !== null)
3045
+ return this._cached;
3046
+ const shape = this._def.shape();
3047
+ const keys = util.objectKeys(shape);
3048
+ this._cached = { shape, keys };
3049
+ return this._cached;
3050
+ }
3051
+ _parse(input2) {
3052
+ const parsedType = this._getType(input2);
3053
+ if (parsedType !== ZodParsedType.object) {
3054
+ const ctx2 = this._getOrReturnCtx(input2);
3055
+ addIssueToContext(ctx2, {
3056
+ code: ZodIssueCode.invalid_type,
3057
+ expected: ZodParsedType.object,
3058
+ received: ctx2.parsedType
3059
+ });
3060
+ return INVALID;
3061
+ }
3062
+ const { status, ctx } = this._processInputParams(input2);
3063
+ const { shape, keys: shapeKeys } = this._getCached();
3064
+ const extraKeys = [];
3065
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
3066
+ for (const key in ctx.data) {
3067
+ if (!shapeKeys.includes(key)) {
3068
+ extraKeys.push(key);
3069
+ }
3070
+ }
3071
+ }
3072
+ const pairs = [];
3073
+ for (const key of shapeKeys) {
3074
+ const keyValidator = shape[key];
3075
+ const value = ctx.data[key];
3076
+ pairs.push({
3077
+ key: { status: "valid", value: key },
3078
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
3079
+ alwaysSet: key in ctx.data
3080
+ });
3081
+ }
3082
+ if (this._def.catchall instanceof ZodNever) {
3083
+ const unknownKeys = this._def.unknownKeys;
3084
+ if (unknownKeys === "passthrough") {
3085
+ for (const key of extraKeys) {
3086
+ pairs.push({
3087
+ key: { status: "valid", value: key },
3088
+ value: { status: "valid", value: ctx.data[key] }
3089
+ });
3090
+ }
3091
+ } else if (unknownKeys === "strict") {
3092
+ if (extraKeys.length > 0) {
3093
+ addIssueToContext(ctx, {
3094
+ code: ZodIssueCode.unrecognized_keys,
3095
+ keys: extraKeys
3096
+ });
3097
+ status.dirty();
3098
+ }
3099
+ } else if (unknownKeys === "strip") {
3100
+ } else {
3101
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
3102
+ }
3103
+ } else {
3104
+ const catchall = this._def.catchall;
3105
+ for (const key of extraKeys) {
3106
+ const value = ctx.data[key];
3107
+ pairs.push({
3108
+ key: { status: "valid", value: key },
3109
+ value: catchall._parse(
3110
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
3111
+ //, ctx.child(key), value, getParsedType(value)
3112
+ ),
3113
+ alwaysSet: key in ctx.data
3114
+ });
3115
+ }
3116
+ }
3117
+ if (ctx.common.async) {
3118
+ return Promise.resolve().then(async () => {
3119
+ const syncPairs = [];
3120
+ for (const pair of pairs) {
3121
+ const key = await pair.key;
3122
+ const value = await pair.value;
3123
+ syncPairs.push({
3124
+ key,
3125
+ value,
3126
+ alwaysSet: pair.alwaysSet
3127
+ });
3128
+ }
3129
+ return syncPairs;
3130
+ }).then((syncPairs) => {
3131
+ return ParseStatus.mergeObjectSync(status, syncPairs);
3132
+ });
3133
+ } else {
3134
+ return ParseStatus.mergeObjectSync(status, pairs);
3135
+ }
3136
+ }
3137
+ get shape() {
3138
+ return this._def.shape();
3139
+ }
3140
+ strict(message) {
3141
+ errorUtil.errToObj;
3142
+ return new _ZodObject({
3143
+ ...this._def,
3144
+ unknownKeys: "strict",
3145
+ ...message !== void 0 ? {
3146
+ errorMap: (issue, ctx) => {
3147
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
3148
+ if (issue.code === "unrecognized_keys")
3149
+ return {
3150
+ message: errorUtil.errToObj(message).message ?? defaultError
3151
+ };
3152
+ return {
3153
+ message: defaultError
3154
+ };
3155
+ }
3156
+ } : {}
3157
+ });
3158
+ }
3159
+ strip() {
3160
+ return new _ZodObject({
3161
+ ...this._def,
3162
+ unknownKeys: "strip"
3163
+ });
3164
+ }
3165
+ passthrough() {
3166
+ return new _ZodObject({
3167
+ ...this._def,
3168
+ unknownKeys: "passthrough"
3169
+ });
3170
+ }
3171
+ // const AugmentFactory =
3172
+ // <Def extends ZodObjectDef>(def: Def) =>
3173
+ // <Augmentation extends ZodRawShape>(
3174
+ // augmentation: Augmentation
3175
+ // ): ZodObject<
3176
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
3177
+ // Def["unknownKeys"],
3178
+ // Def["catchall"]
3179
+ // > => {
3180
+ // return new ZodObject({
3181
+ // ...def,
3182
+ // shape: () => ({
3183
+ // ...def.shape(),
3184
+ // ...augmentation,
3185
+ // }),
3186
+ // }) as any;
3187
+ // };
3188
+ extend(augmentation) {
3189
+ return new _ZodObject({
3190
+ ...this._def,
3191
+ shape: () => ({
3192
+ ...this._def.shape(),
3193
+ ...augmentation
3194
+ })
3195
+ });
3196
+ }
3197
+ /**
3198
+ * Prior to zod@1.0.12 there was a bug in the
3199
+ * inferred type of merged objects. Please
3200
+ * upgrade if you are experiencing issues.
3201
+ */
3202
+ merge(merging) {
3203
+ const merged = new _ZodObject({
3204
+ unknownKeys: merging._def.unknownKeys,
3205
+ catchall: merging._def.catchall,
3206
+ shape: () => ({
3207
+ ...this._def.shape(),
3208
+ ...merging._def.shape()
3209
+ }),
3210
+ typeName: ZodFirstPartyTypeKind.ZodObject
3211
+ });
3212
+ return merged;
3213
+ }
3214
+ // merge<
3215
+ // Incoming extends AnyZodObject,
3216
+ // Augmentation extends Incoming["shape"],
3217
+ // NewOutput extends {
3218
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
3219
+ // ? Augmentation[k]["_output"]
3220
+ // : k extends keyof Output
3221
+ // ? Output[k]
3222
+ // : never;
3223
+ // },
3224
+ // NewInput extends {
3225
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
3226
+ // ? Augmentation[k]["_input"]
3227
+ // : k extends keyof Input
3228
+ // ? Input[k]
3229
+ // : never;
3230
+ // }
3231
+ // >(
3232
+ // merging: Incoming
3233
+ // ): ZodObject<
3234
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3235
+ // Incoming["_def"]["unknownKeys"],
3236
+ // Incoming["_def"]["catchall"],
3237
+ // NewOutput,
3238
+ // NewInput
3239
+ // > {
3240
+ // const merged: any = new ZodObject({
3241
+ // unknownKeys: merging._def.unknownKeys,
3242
+ // catchall: merging._def.catchall,
3243
+ // shape: () =>
3244
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3245
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
3246
+ // }) as any;
3247
+ // return merged;
3248
+ // }
3249
+ setKey(key, schema) {
3250
+ return this.augment({ [key]: schema });
3251
+ }
3252
+ // merge<Incoming extends AnyZodObject>(
3253
+ // merging: Incoming
3254
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
3255
+ // ZodObject<
3256
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3257
+ // Incoming["_def"]["unknownKeys"],
3258
+ // Incoming["_def"]["catchall"]
3259
+ // > {
3260
+ // // const mergedShape = objectUtil.mergeShapes(
3261
+ // // this._def.shape(),
3262
+ // // merging._def.shape()
3263
+ // // );
3264
+ // const merged: any = new ZodObject({
3265
+ // unknownKeys: merging._def.unknownKeys,
3266
+ // catchall: merging._def.catchall,
3267
+ // shape: () =>
3268
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3269
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
3270
+ // }) as any;
3271
+ // return merged;
3272
+ // }
3273
+ catchall(index) {
3274
+ return new _ZodObject({
3275
+ ...this._def,
3276
+ catchall: index
3277
+ });
3278
+ }
3279
+ pick(mask) {
3280
+ const shape = {};
3281
+ for (const key of util.objectKeys(mask)) {
3282
+ if (mask[key] && this.shape[key]) {
3283
+ shape[key] = this.shape[key];
3284
+ }
3285
+ }
3286
+ return new _ZodObject({
3287
+ ...this._def,
3288
+ shape: () => shape
3289
+ });
3290
+ }
3291
+ omit(mask) {
3292
+ const shape = {};
3293
+ for (const key of util.objectKeys(this.shape)) {
3294
+ if (!mask[key]) {
3295
+ shape[key] = this.shape[key];
3296
+ }
3297
+ }
3298
+ return new _ZodObject({
3299
+ ...this._def,
3300
+ shape: () => shape
3301
+ });
3302
+ }
3303
+ /**
3304
+ * @deprecated
3305
+ */
3306
+ deepPartial() {
3307
+ return deepPartialify(this);
3308
+ }
3309
+ partial(mask) {
3310
+ const newShape = {};
3311
+ for (const key of util.objectKeys(this.shape)) {
3312
+ const fieldSchema = this.shape[key];
3313
+ if (mask && !mask[key]) {
3314
+ newShape[key] = fieldSchema;
3315
+ } else {
3316
+ newShape[key] = fieldSchema.optional();
3317
+ }
3318
+ }
3319
+ return new _ZodObject({
3320
+ ...this._def,
3321
+ shape: () => newShape
3322
+ });
3323
+ }
3324
+ required(mask) {
3325
+ const newShape = {};
3326
+ for (const key of util.objectKeys(this.shape)) {
3327
+ if (mask && !mask[key]) {
3328
+ newShape[key] = this.shape[key];
3329
+ } else {
3330
+ const fieldSchema = this.shape[key];
3331
+ let newField = fieldSchema;
3332
+ while (newField instanceof ZodOptional) {
3333
+ newField = newField._def.innerType;
3334
+ }
3335
+ newShape[key] = newField;
3336
+ }
3337
+ }
3338
+ return new _ZodObject({
3339
+ ...this._def,
3340
+ shape: () => newShape
3341
+ });
3342
+ }
3343
+ keyof() {
3344
+ return createZodEnum(util.objectKeys(this.shape));
3345
+ }
3346
+ };
3347
+ ZodObject.create = (shape, params) => {
3348
+ return new ZodObject({
3349
+ shape: () => shape,
3350
+ unknownKeys: "strip",
3351
+ catchall: ZodNever.create(),
3352
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3353
+ ...processCreateParams(params)
3354
+ });
3355
+ };
3356
+ ZodObject.strictCreate = (shape, params) => {
3357
+ return new ZodObject({
3358
+ shape: () => shape,
3359
+ unknownKeys: "strict",
3360
+ catchall: ZodNever.create(),
3361
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3362
+ ...processCreateParams(params)
3363
+ });
3364
+ };
3365
+ ZodObject.lazycreate = (shape, params) => {
3366
+ return new ZodObject({
3367
+ shape,
3368
+ unknownKeys: "strip",
3369
+ catchall: ZodNever.create(),
3370
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3371
+ ...processCreateParams(params)
3372
+ });
3373
+ };
3374
+ var ZodUnion = class extends ZodType {
3375
+ _parse(input2) {
3376
+ const { ctx } = this._processInputParams(input2);
3377
+ const options = this._def.options;
3378
+ function handleResults(results) {
3379
+ for (const result of results) {
3380
+ if (result.result.status === "valid") {
3381
+ return result.result;
3382
+ }
3383
+ }
3384
+ for (const result of results) {
3385
+ if (result.result.status === "dirty") {
3386
+ ctx.common.issues.push(...result.ctx.common.issues);
3387
+ return result.result;
3388
+ }
3389
+ }
3390
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
3391
+ addIssueToContext(ctx, {
3392
+ code: ZodIssueCode.invalid_union,
3393
+ unionErrors
3394
+ });
3395
+ return INVALID;
3396
+ }
3397
+ if (ctx.common.async) {
3398
+ return Promise.all(options.map(async (option) => {
3399
+ const childCtx = {
3400
+ ...ctx,
3401
+ common: {
3402
+ ...ctx.common,
3403
+ issues: []
3404
+ },
3405
+ parent: null
3406
+ };
3407
+ return {
3408
+ result: await option._parseAsync({
3409
+ data: ctx.data,
3410
+ path: ctx.path,
3411
+ parent: childCtx
3412
+ }),
3413
+ ctx: childCtx
3414
+ };
3415
+ })).then(handleResults);
3416
+ } else {
3417
+ let dirty = void 0;
3418
+ const issues = [];
3419
+ for (const option of options) {
3420
+ const childCtx = {
3421
+ ...ctx,
3422
+ common: {
3423
+ ...ctx.common,
3424
+ issues: []
3425
+ },
3426
+ parent: null
3427
+ };
3428
+ const result = option._parseSync({
3429
+ data: ctx.data,
3430
+ path: ctx.path,
3431
+ parent: childCtx
3432
+ });
3433
+ if (result.status === "valid") {
3434
+ return result;
3435
+ } else if (result.status === "dirty" && !dirty) {
3436
+ dirty = { result, ctx: childCtx };
3437
+ }
3438
+ if (childCtx.common.issues.length) {
3439
+ issues.push(childCtx.common.issues);
3440
+ }
3441
+ }
3442
+ if (dirty) {
3443
+ ctx.common.issues.push(...dirty.ctx.common.issues);
3444
+ return dirty.result;
3445
+ }
3446
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
3447
+ addIssueToContext(ctx, {
3448
+ code: ZodIssueCode.invalid_union,
3449
+ unionErrors
3450
+ });
3451
+ return INVALID;
3452
+ }
3453
+ }
3454
+ get options() {
3455
+ return this._def.options;
3456
+ }
3457
+ };
3458
+ ZodUnion.create = (types, params) => {
3459
+ return new ZodUnion({
3460
+ options: types,
3461
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
3462
+ ...processCreateParams(params)
3463
+ });
3464
+ };
3465
+ var getDiscriminator = (type) => {
3466
+ if (type instanceof ZodLazy) {
3467
+ return getDiscriminator(type.schema);
3468
+ } else if (type instanceof ZodEffects) {
3469
+ return getDiscriminator(type.innerType());
3470
+ } else if (type instanceof ZodLiteral) {
3471
+ return [type.value];
3472
+ } else if (type instanceof ZodEnum) {
3473
+ return type.options;
3474
+ } else if (type instanceof ZodNativeEnum) {
3475
+ return util.objectValues(type.enum);
3476
+ } else if (type instanceof ZodDefault) {
3477
+ return getDiscriminator(type._def.innerType);
3478
+ } else if (type instanceof ZodUndefined) {
3479
+ return [void 0];
3480
+ } else if (type instanceof ZodNull) {
3481
+ return [null];
3482
+ } else if (type instanceof ZodOptional) {
3483
+ return [void 0, ...getDiscriminator(type.unwrap())];
3484
+ } else if (type instanceof ZodNullable) {
3485
+ return [null, ...getDiscriminator(type.unwrap())];
3486
+ } else if (type instanceof ZodBranded) {
3487
+ return getDiscriminator(type.unwrap());
3488
+ } else if (type instanceof ZodReadonly) {
3489
+ return getDiscriminator(type.unwrap());
3490
+ } else if (type instanceof ZodCatch) {
3491
+ return getDiscriminator(type._def.innerType);
3492
+ } else {
3493
+ return [];
3494
+ }
3495
+ };
3496
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
3497
+ _parse(input2) {
3498
+ const { ctx } = this._processInputParams(input2);
3499
+ if (ctx.parsedType !== ZodParsedType.object) {
3500
+ addIssueToContext(ctx, {
3501
+ code: ZodIssueCode.invalid_type,
3502
+ expected: ZodParsedType.object,
3503
+ received: ctx.parsedType
3504
+ });
3505
+ return INVALID;
3506
+ }
3507
+ const discriminator = this.discriminator;
3508
+ const discriminatorValue = ctx.data[discriminator];
3509
+ const option = this.optionsMap.get(discriminatorValue);
3510
+ if (!option) {
3511
+ addIssueToContext(ctx, {
3512
+ code: ZodIssueCode.invalid_union_discriminator,
3513
+ options: Array.from(this.optionsMap.keys()),
3514
+ path: [discriminator]
3515
+ });
3516
+ return INVALID;
3517
+ }
3518
+ if (ctx.common.async) {
3519
+ return option._parseAsync({
3520
+ data: ctx.data,
3521
+ path: ctx.path,
3522
+ parent: ctx
3523
+ });
3524
+ } else {
3525
+ return option._parseSync({
3526
+ data: ctx.data,
3527
+ path: ctx.path,
3528
+ parent: ctx
3529
+ });
3530
+ }
3531
+ }
3532
+ get discriminator() {
3533
+ return this._def.discriminator;
3534
+ }
3535
+ get options() {
3536
+ return this._def.options;
3537
+ }
3538
+ get optionsMap() {
3539
+ return this._def.optionsMap;
3540
+ }
3541
+ /**
3542
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
3543
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
3544
+ * have a different value for each object in the union.
3545
+ * @param discriminator the name of the discriminator property
3546
+ * @param types an array of object schemas
3547
+ * @param params
3548
+ */
3549
+ static create(discriminator, options, params) {
3550
+ const optionsMap = /* @__PURE__ */ new Map();
3551
+ for (const type of options) {
3552
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
3553
+ if (!discriminatorValues.length) {
3554
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3555
+ }
3556
+ for (const value of discriminatorValues) {
3557
+ if (optionsMap.has(value)) {
3558
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
3559
+ }
3560
+ optionsMap.set(value, type);
3561
+ }
3562
+ }
3563
+ return new _ZodDiscriminatedUnion({
3564
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
3565
+ discriminator,
3566
+ options,
3567
+ optionsMap,
3568
+ ...processCreateParams(params)
3569
+ });
3570
+ }
3571
+ };
3572
+ function mergeValues(a, b) {
3573
+ const aType = getParsedType(a);
3574
+ const bType = getParsedType(b);
3575
+ if (a === b) {
3576
+ return { valid: true, data: a };
3577
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
3578
+ const bKeys = util.objectKeys(b);
3579
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
3580
+ const newObj = { ...a, ...b };
3581
+ for (const key of sharedKeys) {
3582
+ const sharedValue = mergeValues(a[key], b[key]);
3583
+ if (!sharedValue.valid) {
3584
+ return { valid: false };
3585
+ }
3586
+ newObj[key] = sharedValue.data;
3587
+ }
3588
+ return { valid: true, data: newObj };
3589
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
3590
+ if (a.length !== b.length) {
3591
+ return { valid: false };
3592
+ }
3593
+ const newArray = [];
3594
+ for (let index = 0; index < a.length; index++) {
3595
+ const itemA = a[index];
3596
+ const itemB = b[index];
3597
+ const sharedValue = mergeValues(itemA, itemB);
3598
+ if (!sharedValue.valid) {
3599
+ return { valid: false };
3600
+ }
3601
+ newArray.push(sharedValue.data);
3602
+ }
3603
+ return { valid: true, data: newArray };
3604
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
3605
+ return { valid: true, data: a };
3606
+ } else {
3607
+ return { valid: false };
3608
+ }
3609
+ }
3610
+ var ZodIntersection = class extends ZodType {
3611
+ _parse(input2) {
3612
+ const { status, ctx } = this._processInputParams(input2);
3613
+ const handleParsed = (parsedLeft, parsedRight) => {
3614
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
3615
+ return INVALID;
3616
+ }
3617
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
3618
+ if (!merged.valid) {
3619
+ addIssueToContext(ctx, {
3620
+ code: ZodIssueCode.invalid_intersection_types
3621
+ });
3622
+ return INVALID;
3623
+ }
3624
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
3625
+ status.dirty();
3626
+ }
3627
+ return { status: status.value, value: merged.data };
3628
+ };
3629
+ if (ctx.common.async) {
3630
+ return Promise.all([
3631
+ this._def.left._parseAsync({
3632
+ data: ctx.data,
3633
+ path: ctx.path,
3634
+ parent: ctx
3635
+ }),
3636
+ this._def.right._parseAsync({
3637
+ data: ctx.data,
3638
+ path: ctx.path,
3639
+ parent: ctx
3640
+ })
3641
+ ]).then(([left, right]) => handleParsed(left, right));
3642
+ } else {
3643
+ return handleParsed(this._def.left._parseSync({
3644
+ data: ctx.data,
3645
+ path: ctx.path,
3646
+ parent: ctx
3647
+ }), this._def.right._parseSync({
3648
+ data: ctx.data,
3649
+ path: ctx.path,
3650
+ parent: ctx
3651
+ }));
3652
+ }
3653
+ }
3654
+ };
3655
+ ZodIntersection.create = (left, right, params) => {
3656
+ return new ZodIntersection({
3657
+ left,
3658
+ right,
3659
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
3660
+ ...processCreateParams(params)
3661
+ });
3662
+ };
3663
+ var ZodTuple = class _ZodTuple extends ZodType {
3664
+ _parse(input2) {
3665
+ const { status, ctx } = this._processInputParams(input2);
3666
+ if (ctx.parsedType !== ZodParsedType.array) {
3667
+ addIssueToContext(ctx, {
3668
+ code: ZodIssueCode.invalid_type,
3669
+ expected: ZodParsedType.array,
3670
+ received: ctx.parsedType
3671
+ });
3672
+ return INVALID;
3673
+ }
3674
+ if (ctx.data.length < this._def.items.length) {
3675
+ addIssueToContext(ctx, {
3676
+ code: ZodIssueCode.too_small,
3677
+ minimum: this._def.items.length,
3678
+ inclusive: true,
3679
+ exact: false,
3680
+ type: "array"
3681
+ });
3682
+ return INVALID;
3683
+ }
3684
+ const rest = this._def.rest;
3685
+ if (!rest && ctx.data.length > this._def.items.length) {
3686
+ addIssueToContext(ctx, {
3687
+ code: ZodIssueCode.too_big,
3688
+ maximum: this._def.items.length,
3689
+ inclusive: true,
3690
+ exact: false,
3691
+ type: "array"
3692
+ });
3693
+ status.dirty();
3694
+ }
3695
+ const items = [...ctx.data].map((item, itemIndex) => {
3696
+ const schema = this._def.items[itemIndex] || this._def.rest;
3697
+ if (!schema)
3698
+ return null;
3699
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3700
+ }).filter((x) => !!x);
3701
+ if (ctx.common.async) {
3702
+ return Promise.all(items).then((results) => {
3703
+ return ParseStatus.mergeArray(status, results);
3704
+ });
3705
+ } else {
3706
+ return ParseStatus.mergeArray(status, items);
3707
+ }
3708
+ }
3709
+ get items() {
3710
+ return this._def.items;
3711
+ }
3712
+ rest(rest) {
3713
+ return new _ZodTuple({
3714
+ ...this._def,
3715
+ rest
3716
+ });
3717
+ }
3718
+ };
3719
+ ZodTuple.create = (schemas, params) => {
3720
+ if (!Array.isArray(schemas)) {
3721
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3722
+ }
3723
+ return new ZodTuple({
3724
+ items: schemas,
3725
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
3726
+ rest: null,
3727
+ ...processCreateParams(params)
3728
+ });
3729
+ };
3730
+ var ZodRecord = class _ZodRecord extends ZodType {
3731
+ get keySchema() {
3732
+ return this._def.keyType;
3733
+ }
3734
+ get valueSchema() {
3735
+ return this._def.valueType;
3736
+ }
3737
+ _parse(input2) {
3738
+ const { status, ctx } = this._processInputParams(input2);
3739
+ if (ctx.parsedType !== ZodParsedType.object) {
3740
+ addIssueToContext(ctx, {
3741
+ code: ZodIssueCode.invalid_type,
3742
+ expected: ZodParsedType.object,
3743
+ received: ctx.parsedType
3744
+ });
3745
+ return INVALID;
3746
+ }
3747
+ const pairs = [];
3748
+ const keyType = this._def.keyType;
3749
+ const valueType = this._def.valueType;
3750
+ for (const key in ctx.data) {
3751
+ pairs.push({
3752
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3753
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3754
+ alwaysSet: key in ctx.data
3755
+ });
3756
+ }
3757
+ if (ctx.common.async) {
3758
+ return ParseStatus.mergeObjectAsync(status, pairs);
3759
+ } else {
3760
+ return ParseStatus.mergeObjectSync(status, pairs);
3761
+ }
3762
+ }
3763
+ get element() {
3764
+ return this._def.valueType;
3765
+ }
3766
+ static create(first, second, third) {
3767
+ if (second instanceof ZodType) {
3768
+ return new _ZodRecord({
3769
+ keyType: first,
3770
+ valueType: second,
3771
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3772
+ ...processCreateParams(third)
3773
+ });
3774
+ }
3775
+ return new _ZodRecord({
3776
+ keyType: ZodString.create(),
3777
+ valueType: first,
3778
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3779
+ ...processCreateParams(second)
3780
+ });
3781
+ }
3782
+ };
3783
+ var ZodMap = class extends ZodType {
3784
+ get keySchema() {
3785
+ return this._def.keyType;
3786
+ }
3787
+ get valueSchema() {
3788
+ return this._def.valueType;
3789
+ }
3790
+ _parse(input2) {
3791
+ const { status, ctx } = this._processInputParams(input2);
3792
+ if (ctx.parsedType !== ZodParsedType.map) {
3793
+ addIssueToContext(ctx, {
3794
+ code: ZodIssueCode.invalid_type,
3795
+ expected: ZodParsedType.map,
3796
+ received: ctx.parsedType
3797
+ });
3798
+ return INVALID;
3799
+ }
3800
+ const keyType = this._def.keyType;
3801
+ const valueType = this._def.valueType;
3802
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
3803
+ return {
3804
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
3805
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
3806
+ };
3807
+ });
3808
+ if (ctx.common.async) {
3809
+ const finalMap = /* @__PURE__ */ new Map();
3810
+ return Promise.resolve().then(async () => {
3811
+ for (const pair of pairs) {
3812
+ const key = await pair.key;
3813
+ const value = await pair.value;
3814
+ if (key.status === "aborted" || value.status === "aborted") {
3815
+ return INVALID;
3816
+ }
3817
+ if (key.status === "dirty" || value.status === "dirty") {
3818
+ status.dirty();
3819
+ }
3820
+ finalMap.set(key.value, value.value);
3821
+ }
3822
+ return { status: status.value, value: finalMap };
3823
+ });
3824
+ } else {
3825
+ const finalMap = /* @__PURE__ */ new Map();
3826
+ for (const pair of pairs) {
3827
+ const key = pair.key;
3828
+ const value = pair.value;
3829
+ if (key.status === "aborted" || value.status === "aborted") {
3830
+ return INVALID;
3831
+ }
3832
+ if (key.status === "dirty" || value.status === "dirty") {
3833
+ status.dirty();
3834
+ }
3835
+ finalMap.set(key.value, value.value);
3836
+ }
3837
+ return { status: status.value, value: finalMap };
3838
+ }
3839
+ }
3840
+ };
3841
+ ZodMap.create = (keyType, valueType, params) => {
3842
+ return new ZodMap({
3843
+ valueType,
3844
+ keyType,
3845
+ typeName: ZodFirstPartyTypeKind.ZodMap,
3846
+ ...processCreateParams(params)
3847
+ });
3848
+ };
3849
+ var ZodSet = class _ZodSet extends ZodType {
3850
+ _parse(input2) {
3851
+ const { status, ctx } = this._processInputParams(input2);
3852
+ if (ctx.parsedType !== ZodParsedType.set) {
3853
+ addIssueToContext(ctx, {
3854
+ code: ZodIssueCode.invalid_type,
3855
+ expected: ZodParsedType.set,
3856
+ received: ctx.parsedType
3857
+ });
3858
+ return INVALID;
3859
+ }
3860
+ const def = this._def;
3861
+ if (def.minSize !== null) {
3862
+ if (ctx.data.size < def.minSize.value) {
3863
+ addIssueToContext(ctx, {
3864
+ code: ZodIssueCode.too_small,
3865
+ minimum: def.minSize.value,
3866
+ type: "set",
3867
+ inclusive: true,
3868
+ exact: false,
3869
+ message: def.minSize.message
3870
+ });
3871
+ status.dirty();
3872
+ }
3873
+ }
3874
+ if (def.maxSize !== null) {
3875
+ if (ctx.data.size > def.maxSize.value) {
3876
+ addIssueToContext(ctx, {
3877
+ code: ZodIssueCode.too_big,
3878
+ maximum: def.maxSize.value,
3879
+ type: "set",
3880
+ inclusive: true,
3881
+ exact: false,
3882
+ message: def.maxSize.message
3883
+ });
3884
+ status.dirty();
3885
+ }
3886
+ }
3887
+ const valueType = this._def.valueType;
3888
+ function finalizeSet(elements2) {
3889
+ const parsedSet = /* @__PURE__ */ new Set();
3890
+ for (const element of elements2) {
3891
+ if (element.status === "aborted")
3892
+ return INVALID;
3893
+ if (element.status === "dirty")
3894
+ status.dirty();
3895
+ parsedSet.add(element.value);
3896
+ }
3897
+ return { status: status.value, value: parsedSet };
3898
+ }
3899
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
3900
+ if (ctx.common.async) {
3901
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
3902
+ } else {
3903
+ return finalizeSet(elements);
3904
+ }
3905
+ }
3906
+ min(minSize, message) {
3907
+ return new _ZodSet({
3908
+ ...this._def,
3909
+ minSize: { value: minSize, message: errorUtil.toString(message) }
3910
+ });
3911
+ }
3912
+ max(maxSize, message) {
3913
+ return new _ZodSet({
3914
+ ...this._def,
3915
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
3916
+ });
3917
+ }
3918
+ size(size, message) {
3919
+ return this.min(size, message).max(size, message);
3920
+ }
3921
+ nonempty(message) {
3922
+ return this.min(1, message);
3923
+ }
3924
+ };
3925
+ ZodSet.create = (valueType, params) => {
3926
+ return new ZodSet({
3927
+ valueType,
3928
+ minSize: null,
3929
+ maxSize: null,
3930
+ typeName: ZodFirstPartyTypeKind.ZodSet,
3931
+ ...processCreateParams(params)
3932
+ });
3933
+ };
3934
+ var ZodFunction = class _ZodFunction extends ZodType {
3935
+ constructor() {
3936
+ super(...arguments);
3937
+ this.validate = this.implement;
3938
+ }
3939
+ _parse(input2) {
3940
+ const { ctx } = this._processInputParams(input2);
3941
+ if (ctx.parsedType !== ZodParsedType.function) {
3942
+ addIssueToContext(ctx, {
3943
+ code: ZodIssueCode.invalid_type,
3944
+ expected: ZodParsedType.function,
3945
+ received: ctx.parsedType
3946
+ });
3947
+ return INVALID;
3948
+ }
3949
+ function makeArgsIssue(args, error) {
3950
+ return makeIssue({
3951
+ data: args,
3952
+ path: ctx.path,
3953
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3954
+ issueData: {
3955
+ code: ZodIssueCode.invalid_arguments,
3956
+ argumentsError: error
3957
+ }
3958
+ });
3959
+ }
3960
+ function makeReturnsIssue(returns, error) {
3961
+ return makeIssue({
3962
+ data: returns,
3963
+ path: ctx.path,
3964
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3965
+ issueData: {
3966
+ code: ZodIssueCode.invalid_return_type,
3967
+ returnTypeError: error
3968
+ }
3969
+ });
3970
+ }
3971
+ const params = { errorMap: ctx.common.contextualErrorMap };
3972
+ const fn = ctx.data;
3973
+ if (this._def.returns instanceof ZodPromise) {
3974
+ const me = this;
3975
+ return OK(async function(...args) {
3976
+ const error = new ZodError([]);
3977
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3978
+ error.addIssue(makeArgsIssue(args, e));
3979
+ throw error;
3980
+ });
3981
+ const result = await Reflect.apply(fn, this, parsedArgs);
3982
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3983
+ error.addIssue(makeReturnsIssue(result, e));
3984
+ throw error;
3985
+ });
3986
+ return parsedReturns;
3987
+ });
3988
+ } else {
3989
+ const me = this;
3990
+ return OK(function(...args) {
3991
+ const parsedArgs = me._def.args.safeParse(args, params);
3992
+ if (!parsedArgs.success) {
3993
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3994
+ }
3995
+ const result = Reflect.apply(fn, this, parsedArgs.data);
3996
+ const parsedReturns = me._def.returns.safeParse(result, params);
3997
+ if (!parsedReturns.success) {
3998
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3999
+ }
4000
+ return parsedReturns.data;
4001
+ });
4002
+ }
4003
+ }
4004
+ parameters() {
4005
+ return this._def.args;
4006
+ }
4007
+ returnType() {
4008
+ return this._def.returns;
4009
+ }
4010
+ args(...items) {
4011
+ return new _ZodFunction({
4012
+ ...this._def,
4013
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
4014
+ });
4015
+ }
4016
+ returns(returnType) {
4017
+ return new _ZodFunction({
4018
+ ...this._def,
4019
+ returns: returnType
4020
+ });
4021
+ }
4022
+ implement(func) {
4023
+ const validatedFunc = this.parse(func);
4024
+ return validatedFunc;
4025
+ }
4026
+ strictImplement(func) {
4027
+ const validatedFunc = this.parse(func);
4028
+ return validatedFunc;
4029
+ }
4030
+ static create(args, returns, params) {
4031
+ return new _ZodFunction({
4032
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
4033
+ returns: returns || ZodUnknown.create(),
4034
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
4035
+ ...processCreateParams(params)
4036
+ });
4037
+ }
4038
+ };
4039
+ var ZodLazy = class extends ZodType {
4040
+ get schema() {
4041
+ return this._def.getter();
4042
+ }
4043
+ _parse(input2) {
4044
+ const { ctx } = this._processInputParams(input2);
4045
+ const lazySchema = this._def.getter();
4046
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
4047
+ }
4048
+ };
4049
+ ZodLazy.create = (getter, params) => {
4050
+ return new ZodLazy({
4051
+ getter,
4052
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
4053
+ ...processCreateParams(params)
4054
+ });
4055
+ };
4056
+ var ZodLiteral = class extends ZodType {
4057
+ _parse(input2) {
4058
+ if (input2.data !== this._def.value) {
4059
+ const ctx = this._getOrReturnCtx(input2);
4060
+ addIssueToContext(ctx, {
4061
+ received: ctx.data,
4062
+ code: ZodIssueCode.invalid_literal,
4063
+ expected: this._def.value
4064
+ });
4065
+ return INVALID;
4066
+ }
4067
+ return { status: "valid", value: input2.data };
4068
+ }
4069
+ get value() {
4070
+ return this._def.value;
4071
+ }
4072
+ };
4073
+ ZodLiteral.create = (value, params) => {
4074
+ return new ZodLiteral({
4075
+ value,
4076
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
4077
+ ...processCreateParams(params)
4078
+ });
4079
+ };
4080
+ function createZodEnum(values, params) {
4081
+ return new ZodEnum({
4082
+ values,
4083
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
4084
+ ...processCreateParams(params)
4085
+ });
4086
+ }
4087
+ var ZodEnum = class _ZodEnum extends ZodType {
4088
+ _parse(input2) {
4089
+ if (typeof input2.data !== "string") {
4090
+ const ctx = this._getOrReturnCtx(input2);
4091
+ const expectedValues = this._def.values;
4092
+ addIssueToContext(ctx, {
4093
+ expected: util.joinValues(expectedValues),
4094
+ received: ctx.parsedType,
4095
+ code: ZodIssueCode.invalid_type
4096
+ });
4097
+ return INVALID;
4098
+ }
4099
+ if (!this._cache) {
4100
+ this._cache = new Set(this._def.values);
4101
+ }
4102
+ if (!this._cache.has(input2.data)) {
4103
+ const ctx = this._getOrReturnCtx(input2);
4104
+ const expectedValues = this._def.values;
4105
+ addIssueToContext(ctx, {
4106
+ received: ctx.data,
4107
+ code: ZodIssueCode.invalid_enum_value,
4108
+ options: expectedValues
4109
+ });
4110
+ return INVALID;
4111
+ }
4112
+ return OK(input2.data);
4113
+ }
4114
+ get options() {
4115
+ return this._def.values;
4116
+ }
4117
+ get enum() {
4118
+ const enumValues = {};
4119
+ for (const val of this._def.values) {
4120
+ enumValues[val] = val;
4121
+ }
4122
+ return enumValues;
4123
+ }
4124
+ get Values() {
4125
+ const enumValues = {};
4126
+ for (const val of this._def.values) {
4127
+ enumValues[val] = val;
4128
+ }
4129
+ return enumValues;
4130
+ }
4131
+ get Enum() {
4132
+ const enumValues = {};
4133
+ for (const val of this._def.values) {
4134
+ enumValues[val] = val;
4135
+ }
4136
+ return enumValues;
4137
+ }
4138
+ extract(values, newDef = this._def) {
4139
+ return _ZodEnum.create(values, {
4140
+ ...this._def,
4141
+ ...newDef
4142
+ });
4143
+ }
4144
+ exclude(values, newDef = this._def) {
4145
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
4146
+ ...this._def,
4147
+ ...newDef
4148
+ });
4149
+ }
4150
+ };
4151
+ ZodEnum.create = createZodEnum;
4152
+ var ZodNativeEnum = class extends ZodType {
4153
+ _parse(input2) {
4154
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
4155
+ const ctx = this._getOrReturnCtx(input2);
4156
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
4157
+ const expectedValues = util.objectValues(nativeEnumValues);
4158
+ addIssueToContext(ctx, {
4159
+ expected: util.joinValues(expectedValues),
4160
+ received: ctx.parsedType,
4161
+ code: ZodIssueCode.invalid_type
4162
+ });
4163
+ return INVALID;
4164
+ }
4165
+ if (!this._cache) {
4166
+ this._cache = new Set(util.getValidEnumValues(this._def.values));
4167
+ }
4168
+ if (!this._cache.has(input2.data)) {
4169
+ const expectedValues = util.objectValues(nativeEnumValues);
4170
+ addIssueToContext(ctx, {
4171
+ received: ctx.data,
4172
+ code: ZodIssueCode.invalid_enum_value,
4173
+ options: expectedValues
4174
+ });
4175
+ return INVALID;
4176
+ }
4177
+ return OK(input2.data);
4178
+ }
4179
+ get enum() {
4180
+ return this._def.values;
4181
+ }
4182
+ };
4183
+ ZodNativeEnum.create = (values, params) => {
4184
+ return new ZodNativeEnum({
4185
+ values,
4186
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
4187
+ ...processCreateParams(params)
4188
+ });
4189
+ };
4190
+ var ZodPromise = class extends ZodType {
4191
+ unwrap() {
4192
+ return this._def.type;
4193
+ }
4194
+ _parse(input2) {
4195
+ const { ctx } = this._processInputParams(input2);
4196
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
4197
+ addIssueToContext(ctx, {
4198
+ code: ZodIssueCode.invalid_type,
4199
+ expected: ZodParsedType.promise,
4200
+ received: ctx.parsedType
4201
+ });
4202
+ return INVALID;
4203
+ }
4204
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
4205
+ return OK(promisified.then((data) => {
4206
+ return this._def.type.parseAsync(data, {
4207
+ path: ctx.path,
4208
+ errorMap: ctx.common.contextualErrorMap
4209
+ });
4210
+ }));
4211
+ }
4212
+ };
4213
+ ZodPromise.create = (schema, params) => {
4214
+ return new ZodPromise({
4215
+ type: schema,
4216
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
4217
+ ...processCreateParams(params)
4218
+ });
4219
+ };
4220
+ var ZodEffects = class extends ZodType {
4221
+ innerType() {
4222
+ return this._def.schema;
4223
+ }
4224
+ sourceType() {
4225
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
4226
+ }
4227
+ _parse(input2) {
4228
+ const { status, ctx } = this._processInputParams(input2);
4229
+ const effect = this._def.effect || null;
4230
+ const checkCtx = {
4231
+ addIssue: (arg) => {
4232
+ addIssueToContext(ctx, arg);
4233
+ if (arg.fatal) {
4234
+ status.abort();
4235
+ } else {
4236
+ status.dirty();
4237
+ }
4238
+ },
4239
+ get path() {
4240
+ return ctx.path;
4241
+ }
4242
+ };
4243
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
4244
+ if (effect.type === "preprocess") {
4245
+ const processed = effect.transform(ctx.data, checkCtx);
4246
+ if (ctx.common.async) {
4247
+ return Promise.resolve(processed).then(async (processed2) => {
4248
+ if (status.value === "aborted")
4249
+ return INVALID;
4250
+ const result = await this._def.schema._parseAsync({
4251
+ data: processed2,
4252
+ path: ctx.path,
4253
+ parent: ctx
4254
+ });
4255
+ if (result.status === "aborted")
4256
+ return INVALID;
4257
+ if (result.status === "dirty")
4258
+ return DIRTY(result.value);
4259
+ if (status.value === "dirty")
4260
+ return DIRTY(result.value);
4261
+ return result;
4262
+ });
4263
+ } else {
4264
+ if (status.value === "aborted")
4265
+ return INVALID;
4266
+ const result = this._def.schema._parseSync({
4267
+ data: processed,
4268
+ path: ctx.path,
4269
+ parent: ctx
4270
+ });
4271
+ if (result.status === "aborted")
4272
+ return INVALID;
4273
+ if (result.status === "dirty")
4274
+ return DIRTY(result.value);
4275
+ if (status.value === "dirty")
4276
+ return DIRTY(result.value);
4277
+ return result;
4278
+ }
4279
+ }
4280
+ if (effect.type === "refinement") {
4281
+ const executeRefinement = (acc) => {
4282
+ const result = effect.refinement(acc, checkCtx);
4283
+ if (ctx.common.async) {
4284
+ return Promise.resolve(result);
4285
+ }
4286
+ if (result instanceof Promise) {
4287
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
4288
+ }
4289
+ return acc;
4290
+ };
4291
+ if (ctx.common.async === false) {
4292
+ const inner = this._def.schema._parseSync({
4293
+ data: ctx.data,
4294
+ path: ctx.path,
4295
+ parent: ctx
4296
+ });
4297
+ if (inner.status === "aborted")
4298
+ return INVALID;
4299
+ if (inner.status === "dirty")
4300
+ status.dirty();
4301
+ executeRefinement(inner.value);
4302
+ return { status: status.value, value: inner.value };
4303
+ } else {
4304
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
4305
+ if (inner.status === "aborted")
4306
+ return INVALID;
4307
+ if (inner.status === "dirty")
4308
+ status.dirty();
4309
+ return executeRefinement(inner.value).then(() => {
4310
+ return { status: status.value, value: inner.value };
4311
+ });
4312
+ });
4313
+ }
4314
+ }
4315
+ if (effect.type === "transform") {
4316
+ if (ctx.common.async === false) {
4317
+ const base = this._def.schema._parseSync({
4318
+ data: ctx.data,
4319
+ path: ctx.path,
4320
+ parent: ctx
4321
+ });
4322
+ if (!isValid(base))
4323
+ return INVALID;
4324
+ const result = effect.transform(base.value, checkCtx);
4325
+ if (result instanceof Promise) {
4326
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
4327
+ }
4328
+ return { status: status.value, value: result };
4329
+ } else {
4330
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
4331
+ if (!isValid(base))
4332
+ return INVALID;
4333
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
4334
+ status: status.value,
4335
+ value: result
4336
+ }));
4337
+ });
4338
+ }
4339
+ }
4340
+ util.assertNever(effect);
4341
+ }
4342
+ };
4343
+ ZodEffects.create = (schema, effect, params) => {
4344
+ return new ZodEffects({
4345
+ schema,
4346
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
4347
+ effect,
4348
+ ...processCreateParams(params)
4349
+ });
4350
+ };
4351
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
4352
+ return new ZodEffects({
4353
+ schema,
4354
+ effect: { type: "preprocess", transform: preprocess },
4355
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
4356
+ ...processCreateParams(params)
4357
+ });
4358
+ };
4359
+ var ZodOptional = class extends ZodType {
4360
+ _parse(input2) {
4361
+ const parsedType = this._getType(input2);
4362
+ if (parsedType === ZodParsedType.undefined) {
4363
+ return OK(void 0);
4364
+ }
4365
+ return this._def.innerType._parse(input2);
4366
+ }
4367
+ unwrap() {
4368
+ return this._def.innerType;
4369
+ }
4370
+ };
4371
+ ZodOptional.create = (type, params) => {
4372
+ return new ZodOptional({
4373
+ innerType: type,
4374
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
4375
+ ...processCreateParams(params)
4376
+ });
4377
+ };
4378
+ var ZodNullable = class extends ZodType {
4379
+ _parse(input2) {
4380
+ const parsedType = this._getType(input2);
4381
+ if (parsedType === ZodParsedType.null) {
4382
+ return OK(null);
4383
+ }
4384
+ return this._def.innerType._parse(input2);
4385
+ }
4386
+ unwrap() {
4387
+ return this._def.innerType;
4388
+ }
4389
+ };
4390
+ ZodNullable.create = (type, params) => {
4391
+ return new ZodNullable({
4392
+ innerType: type,
4393
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
4394
+ ...processCreateParams(params)
4395
+ });
4396
+ };
4397
+ var ZodDefault = class extends ZodType {
4398
+ _parse(input2) {
4399
+ const { ctx } = this._processInputParams(input2);
4400
+ let data = ctx.data;
4401
+ if (ctx.parsedType === ZodParsedType.undefined) {
4402
+ data = this._def.defaultValue();
4403
+ }
4404
+ return this._def.innerType._parse({
4405
+ data,
4406
+ path: ctx.path,
4407
+ parent: ctx
4408
+ });
4409
+ }
4410
+ removeDefault() {
4411
+ return this._def.innerType;
4412
+ }
4413
+ };
4414
+ ZodDefault.create = (type, params) => {
4415
+ return new ZodDefault({
4416
+ innerType: type,
4417
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
4418
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
4419
+ ...processCreateParams(params)
4420
+ });
4421
+ };
4422
+ var ZodCatch = class extends ZodType {
4423
+ _parse(input2) {
4424
+ const { ctx } = this._processInputParams(input2);
4425
+ const newCtx = {
4426
+ ...ctx,
4427
+ common: {
4428
+ ...ctx.common,
4429
+ issues: []
4430
+ }
4431
+ };
4432
+ const result = this._def.innerType._parse({
4433
+ data: newCtx.data,
4434
+ path: newCtx.path,
4435
+ parent: {
4436
+ ...newCtx
4437
+ }
4438
+ });
4439
+ if (isAsync(result)) {
4440
+ return result.then((result2) => {
4441
+ return {
4442
+ status: "valid",
4443
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
4444
+ get error() {
4445
+ return new ZodError(newCtx.common.issues);
4446
+ },
4447
+ input: newCtx.data
4448
+ })
4449
+ };
4450
+ });
4451
+ } else {
4452
+ return {
4453
+ status: "valid",
4454
+ value: result.status === "valid" ? result.value : this._def.catchValue({
4455
+ get error() {
4456
+ return new ZodError(newCtx.common.issues);
4457
+ },
4458
+ input: newCtx.data
4459
+ })
4460
+ };
4461
+ }
4462
+ }
4463
+ removeCatch() {
4464
+ return this._def.innerType;
4465
+ }
4466
+ };
4467
+ ZodCatch.create = (type, params) => {
4468
+ return new ZodCatch({
4469
+ innerType: type,
4470
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
4471
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
4472
+ ...processCreateParams(params)
4473
+ });
4474
+ };
4475
+ var ZodNaN = class extends ZodType {
4476
+ _parse(input2) {
4477
+ const parsedType = this._getType(input2);
4478
+ if (parsedType !== ZodParsedType.nan) {
4479
+ const ctx = this._getOrReturnCtx(input2);
4480
+ addIssueToContext(ctx, {
4481
+ code: ZodIssueCode.invalid_type,
4482
+ expected: ZodParsedType.nan,
4483
+ received: ctx.parsedType
4484
+ });
4485
+ return INVALID;
4486
+ }
4487
+ return { status: "valid", value: input2.data };
4488
+ }
4489
+ };
4490
+ ZodNaN.create = (params) => {
4491
+ return new ZodNaN({
4492
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
4493
+ ...processCreateParams(params)
4494
+ });
4495
+ };
4496
+ var BRAND = /* @__PURE__ */ Symbol("zod_brand");
4497
+ var ZodBranded = class extends ZodType {
4498
+ _parse(input2) {
4499
+ const { ctx } = this._processInputParams(input2);
4500
+ const data = ctx.data;
4501
+ return this._def.type._parse({
4502
+ data,
4503
+ path: ctx.path,
4504
+ parent: ctx
4505
+ });
4506
+ }
4507
+ unwrap() {
4508
+ return this._def.type;
4509
+ }
4510
+ };
4511
+ var ZodPipeline = class _ZodPipeline extends ZodType {
4512
+ _parse(input2) {
4513
+ const { status, ctx } = this._processInputParams(input2);
4514
+ if (ctx.common.async) {
4515
+ const handleAsync = async () => {
4516
+ const inResult = await this._def.in._parseAsync({
4517
+ data: ctx.data,
4518
+ path: ctx.path,
4519
+ parent: ctx
4520
+ });
4521
+ if (inResult.status === "aborted")
4522
+ return INVALID;
4523
+ if (inResult.status === "dirty") {
4524
+ status.dirty();
4525
+ return DIRTY(inResult.value);
4526
+ } else {
4527
+ return this._def.out._parseAsync({
4528
+ data: inResult.value,
4529
+ path: ctx.path,
4530
+ parent: ctx
4531
+ });
4532
+ }
4533
+ };
4534
+ return handleAsync();
4535
+ } else {
4536
+ const inResult = this._def.in._parseSync({
4537
+ data: ctx.data,
4538
+ path: ctx.path,
4539
+ parent: ctx
4540
+ });
4541
+ if (inResult.status === "aborted")
4542
+ return INVALID;
4543
+ if (inResult.status === "dirty") {
4544
+ status.dirty();
4545
+ return {
4546
+ status: "dirty",
4547
+ value: inResult.value
4548
+ };
4549
+ } else {
4550
+ return this._def.out._parseSync({
4551
+ data: inResult.value,
4552
+ path: ctx.path,
4553
+ parent: ctx
4554
+ });
4555
+ }
4556
+ }
4557
+ }
4558
+ static create(a, b) {
4559
+ return new _ZodPipeline({
4560
+ in: a,
4561
+ out: b,
4562
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
4563
+ });
4564
+ }
4565
+ };
4566
+ var ZodReadonly = class extends ZodType {
4567
+ _parse(input2) {
4568
+ const result = this._def.innerType._parse(input2);
4569
+ const freeze = (data) => {
4570
+ if (isValid(data)) {
4571
+ data.value = Object.freeze(data.value);
4572
+ }
4573
+ return data;
4574
+ };
4575
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
4576
+ }
4577
+ unwrap() {
4578
+ return this._def.innerType;
4579
+ }
4580
+ };
4581
+ ZodReadonly.create = (type, params) => {
4582
+ return new ZodReadonly({
4583
+ innerType: type,
4584
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
4585
+ ...processCreateParams(params)
4586
+ });
4587
+ };
4588
+ function cleanParams(params, data) {
4589
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
4590
+ const p2 = typeof p === "string" ? { message: p } : p;
4591
+ return p2;
4592
+ }
4593
+ function custom(check, _params = {}, fatal) {
4594
+ if (check)
4595
+ return ZodAny.create().superRefine((data, ctx) => {
4596
+ const r = check(data);
4597
+ if (r instanceof Promise) {
4598
+ return r.then((r2) => {
4599
+ if (!r2) {
4600
+ const params = cleanParams(_params, data);
4601
+ const _fatal = params.fatal ?? fatal ?? true;
4602
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
4603
+ }
4604
+ });
4605
+ }
4606
+ if (!r) {
4607
+ const params = cleanParams(_params, data);
4608
+ const _fatal = params.fatal ?? fatal ?? true;
4609
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
4610
+ }
4611
+ return;
4612
+ });
4613
+ return ZodAny.create();
4614
+ }
4615
+ var late = {
4616
+ object: ZodObject.lazycreate
4617
+ };
4618
+ var ZodFirstPartyTypeKind;
4619
+ (function(ZodFirstPartyTypeKind2) {
4620
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
4621
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
4622
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
4623
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
4624
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
4625
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
4626
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
4627
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
4628
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
4629
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
4630
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
4631
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
4632
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
4633
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
4634
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
4635
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
4636
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
4637
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
4638
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
4639
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
4640
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
4641
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
4642
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
4643
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
4644
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
4645
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
4646
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
4647
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
4648
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
4649
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
4650
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
4651
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
4652
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
4653
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
4654
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
4655
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
4656
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
4657
+ var instanceOfType = (cls, params = {
4658
+ message: `Input not instance of ${cls.name}`
4659
+ }) => custom((data) => data instanceof cls, params);
4660
+ var stringType = ZodString.create;
4661
+ var numberType = ZodNumber.create;
4662
+ var nanType = ZodNaN.create;
4663
+ var bigIntType = ZodBigInt.create;
4664
+ var booleanType = ZodBoolean.create;
4665
+ var dateType = ZodDate.create;
4666
+ var symbolType = ZodSymbol.create;
4667
+ var undefinedType = ZodUndefined.create;
4668
+ var nullType = ZodNull.create;
4669
+ var anyType = ZodAny.create;
4670
+ var unknownType = ZodUnknown.create;
4671
+ var neverType = ZodNever.create;
4672
+ var voidType = ZodVoid.create;
4673
+ var arrayType = ZodArray.create;
4674
+ var objectType = ZodObject.create;
4675
+ var strictObjectType = ZodObject.strictCreate;
4676
+ var unionType = ZodUnion.create;
4677
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
4678
+ var intersectionType = ZodIntersection.create;
4679
+ var tupleType = ZodTuple.create;
4680
+ var recordType = ZodRecord.create;
4681
+ var mapType = ZodMap.create;
4682
+ var setType = ZodSet.create;
4683
+ var functionType = ZodFunction.create;
4684
+ var lazyType = ZodLazy.create;
4685
+ var literalType = ZodLiteral.create;
4686
+ var enumType = ZodEnum.create;
4687
+ var nativeEnumType = ZodNativeEnum.create;
4688
+ var promiseType = ZodPromise.create;
4689
+ var effectsType = ZodEffects.create;
4690
+ var optionalType = ZodOptional.create;
4691
+ var nullableType = ZodNullable.create;
4692
+ var preprocessType = ZodEffects.createWithPreprocess;
4693
+ var pipelineType = ZodPipeline.create;
4694
+ var ostring = () => stringType().optional();
4695
+ var onumber = () => numberType().optional();
4696
+ var oboolean = () => booleanType().optional();
4697
+ var coerce = {
4698
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
4699
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
4700
+ boolean: ((arg) => ZodBoolean.create({
4701
+ ...arg,
4702
+ coerce: true
4703
+ })),
4704
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
4705
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
4706
+ };
4707
+ var NEVER = INVALID;
4708
+
4709
+ // src/definitions.ts
4710
+ var stack = defineComponent({
4711
+ name: "stack",
4712
+ description: "Vertical or horizontal flex container",
4713
+ props: external_exports.object({
4714
+ direction: external_exports.enum(["vertical", "horizontal"]).optional().describe("Stack direction"),
4715
+ gap: external_exports.enum(["none", "sm", "md", "lg"]).optional().describe("Spacing between children"),
4716
+ align: external_exports.enum(["start", "center", "end", "stretch"]).optional().describe("Cross-axis alignment")
4717
+ }),
4718
+ children: "any"
4719
+ });
4720
+ var grid = defineComponent({
4721
+ name: "grid",
4722
+ description: "CSS grid layout with configurable columns",
4723
+ props: external_exports.object({
4724
+ cols: external_exports.number().optional().describe("Number of columns"),
4725
+ gap: external_exports.enum(["none", "sm", "md", "lg"]).optional().describe("Grid gap")
4726
+ }),
4727
+ children: "any"
4728
+ });
4729
+ var card = defineComponent({
4730
+ name: "card",
4731
+ description: "Bordered content container with optional title",
4732
+ props: external_exports.object({
4733
+ title: external_exports.string().optional().describe("Card heading"),
4734
+ variant: external_exports.enum(["default", "outlined", "elevated"]).optional().describe("Card style")
4735
+ }),
4736
+ children: "any"
4737
+ });
4738
+ var divider = defineComponent({
4739
+ name: "divider",
4740
+ description: "Horizontal separator line",
4741
+ props: external_exports.object({}),
4742
+ children: "none"
4743
+ });
4744
+ var accordion = defineComponent({
4745
+ name: "accordion",
4746
+ description: "Collapsible content section",
4747
+ props: external_exports.object({
4748
+ title: external_exports.string().describe("Accordion header text"),
4749
+ open: external_exports.boolean().optional().describe("Whether expanded by default")
4750
+ }),
4751
+ children: "any"
4752
+ });
4753
+ var tabs = defineComponent({
4754
+ name: "tabs",
4755
+ description: "Tabbed content container \u2014 each child tab has a label",
4756
+ props: external_exports.object({
4757
+ labels: external_exports.array(external_exports.string()).describe("Tab labels in order"),
4758
+ active: external_exports.number().optional().describe("Zero-based index of active tab")
4759
+ }),
4760
+ children: "any"
4761
+ });
4762
+ var tab = defineComponent({
4763
+ name: "tab",
4764
+ description: "Single tab panel inside a tabs container",
4765
+ props: external_exports.object({
4766
+ label: external_exports.string().describe("Tab label")
4767
+ }),
4768
+ children: "any"
4769
+ });
4770
+ var button = defineComponent({
4771
+ name: "button",
4772
+ description: "Clickable action button",
4773
+ props: external_exports.object({
4774
+ action: external_exports.string().describe('Action identifier \u2014 "continue" sends label as new message'),
4775
+ label: external_exports.string().describe("Button text"),
4776
+ variant: external_exports.enum(["primary", "secondary", "outline", "ghost"]).optional().describe("Visual style"),
4777
+ disabled: external_exports.boolean().optional().describe("Whether button is disabled")
4778
+ }),
4779
+ children: "none"
4780
+ });
4781
+ var buttonGroup = defineComponent({
4782
+ name: "button-group",
4783
+ description: "Row of related buttons",
4784
+ props: external_exports.object({
4785
+ direction: external_exports.enum(["horizontal", "vertical"]).optional().describe("Layout direction")
4786
+ }),
4787
+ children: ["button"]
4788
+ });
4789
+ var input = defineComponent({
4790
+ name: "input",
4791
+ description: "Text input field",
4792
+ props: external_exports.object({
4793
+ name: external_exports.string().describe("Field name for form state"),
4794
+ label: external_exports.string().optional().describe("Input label"),
4795
+ placeholder: external_exports.string().optional().describe("Placeholder text"),
4796
+ type: external_exports.enum(["text", "email", "password", "number", "url"]).optional().describe("Input type"),
4797
+ required: external_exports.boolean().optional().describe("Whether field is required")
4798
+ }),
4799
+ children: "none"
4800
+ });
4801
+ var select = defineComponent({
4802
+ name: "select",
4803
+ description: "Dropdown select menu",
4804
+ props: external_exports.object({
4805
+ name: external_exports.string().describe("Field name for form state"),
4806
+ label: external_exports.string().optional().describe("Select label"),
4807
+ options: external_exports.array(external_exports.string()).describe("List of option values"),
4808
+ placeholder: external_exports.string().optional().describe("Placeholder text"),
4809
+ required: external_exports.boolean().optional().describe("Whether selection is required")
4810
+ }),
4811
+ children: "none"
4812
+ });
4813
+ var checkbox = defineComponent({
4814
+ name: "checkbox",
4815
+ description: "Toggle checkbox",
4816
+ props: external_exports.object({
4817
+ name: external_exports.string().describe("Field name for form state"),
4818
+ label: external_exports.string().describe("Checkbox label text"),
4819
+ checked: external_exports.boolean().optional().describe("Default checked state")
4820
+ }),
4821
+ children: "none"
4822
+ });
4823
+ var form = defineComponent({
4824
+ name: "form",
4825
+ description: "Form container that groups inputs and submits their state",
4826
+ props: external_exports.object({
4827
+ name: external_exports.string().describe("Form identifier for action events"),
4828
+ action: external_exports.string().optional().describe('Submit action \u2014 defaults to "submit:<name>"')
4829
+ }),
4830
+ children: "any"
4831
+ });
4832
+ var chart = defineComponent({
4833
+ name: "chart",
4834
+ description: "Data visualization",
4835
+ props: external_exports.object({
4836
+ type: external_exports.enum(["bar", "line", "pie", "donut"]).describe("Chart type"),
4837
+ labels: external_exports.array(external_exports.string()).describe("Category labels"),
4838
+ values: external_exports.array(external_exports.number()).describe("Data values"),
4839
+ title: external_exports.string().optional().describe("Chart title")
4840
+ }),
4841
+ children: "none"
4842
+ });
4843
+ var table = defineComponent({
4844
+ name: "table",
4845
+ description: "Data table with headers and rows",
4846
+ props: external_exports.object({
4847
+ headers: external_exports.array(external_exports.string()).describe("Column header labels"),
4848
+ rows: external_exports.array(external_exports.array(external_exports.string())).describe("Row data as string arrays"),
4849
+ caption: external_exports.string().optional().describe("Table caption")
4850
+ }),
4851
+ children: "none"
4852
+ });
4853
+ var stat = defineComponent({
4854
+ name: "stat",
4855
+ description: "Key metric display with label and value",
4856
+ props: external_exports.object({
4857
+ label: external_exports.string().describe("Metric name"),
4858
+ value: external_exports.string().describe("Metric value"),
4859
+ change: external_exports.string().optional().describe('Change indicator like "+12%" or "-3%"'),
4860
+ trend: external_exports.enum(["up", "down", "neutral"]).optional().describe("Trend direction")
4861
+ }),
4862
+ children: "none"
4863
+ });
4864
+ var progress = defineComponent({
4865
+ name: "progress",
4866
+ description: "Progress bar",
4867
+ props: external_exports.object({
4868
+ value: external_exports.number().describe("Current value (0-100)"),
4869
+ label: external_exports.string().optional().describe("Progress label"),
4870
+ max: external_exports.number().optional().describe("Maximum value \u2014 defaults to 100")
4871
+ }),
4872
+ children: "none"
4873
+ });
4874
+ var callout = defineComponent({
4875
+ name: "callout",
4876
+ description: "Highlighted message block for alerts and notices",
4877
+ props: external_exports.object({
4878
+ type: external_exports.enum(["info", "warning", "error", "success"]).describe("Callout severity"),
4879
+ title: external_exports.string().optional().describe("Callout heading")
4880
+ }),
4881
+ children: "any"
4882
+ });
4883
+ var badge = defineComponent({
4884
+ name: "badge",
4885
+ description: "Inline label or tag",
4886
+ props: external_exports.object({
4887
+ label: external_exports.string().describe("Badge text"),
4888
+ variant: external_exports.enum(["default", "success", "warning", "error", "info"]).optional().describe("Color variant")
4889
+ }),
4890
+ children: "none"
4891
+ });
4892
+ var image = defineComponent({
4893
+ name: "image",
4894
+ description: "Inline image",
4895
+ props: external_exports.object({
4896
+ src: external_exports.string().describe("Image URL"),
4897
+ alt: external_exports.string().describe("Alt text for accessibility"),
4898
+ width: external_exports.number().optional().describe("Width in pixels"),
4899
+ height: external_exports.number().optional().describe("Height in pixels")
4900
+ }),
4901
+ children: "none"
4902
+ });
4903
+ var codeBlock = defineComponent({
4904
+ name: "code-block",
4905
+ description: "Syntax-highlighted code block",
4906
+ props: external_exports.object({
4907
+ language: external_exports.string().optional().describe("Programming language"),
4908
+ title: external_exports.string().optional().describe("Code block title or filename"),
4909
+ code: external_exports.string().describe("The source code")
4910
+ }),
4911
+ children: "none"
4912
+ });
4913
+ var link = defineComponent({
4914
+ name: "link",
4915
+ description: "Clickable link that triggers an action or opens a URL",
4916
+ props: external_exports.object({
4917
+ action: external_exports.string().describe('Action identifier \u2014 "open_url" opens params.url'),
4918
+ label: external_exports.string().describe("Link text"),
4919
+ url: external_exports.string().optional().describe('Target URL when action is "open_url"')
4920
+ }),
4921
+ children: "none"
4922
+ });
4923
+ var allDefinitions = [
4924
+ stack,
4925
+ grid,
4926
+ card,
4927
+ divider,
4928
+ accordion,
4929
+ tabs,
4930
+ tab,
4931
+ button,
4932
+ buttonGroup,
4933
+ input,
4934
+ select,
4935
+ checkbox,
4936
+ form,
4937
+ chart,
4938
+ table,
4939
+ stat,
4940
+ progress,
4941
+ callout,
4942
+ badge,
4943
+ image,
4944
+ codeBlock,
4945
+ link
4946
+ ];
4947
+ var defaultGroups = [
4948
+ {
4949
+ name: "Layout",
4950
+ components: ["stack", "grid", "card", "divider", "accordion", "tabs", "tab"],
4951
+ notes: ["Use stack for vertical/horizontal layouts", "Nest tabs with tab children"]
4952
+ },
4953
+ {
4954
+ name: "Interactive",
4955
+ components: ["button", "button-group", "input", "select", "checkbox", "form"],
4956
+ notes: [
4957
+ "Wrap inputs in a form for state collection",
4958
+ 'button action="continue" sends label as message'
4959
+ ]
4960
+ },
4961
+ {
4962
+ name: "Data",
4963
+ components: ["chart", "table", "stat", "progress"]
4964
+ },
4965
+ {
4966
+ name: "Content",
4967
+ components: ["callout", "badge", "image", "code-block", "link"]
4968
+ }
4969
+ ];
4970
+
4971
+ // src/defaults.ts
4972
+ var defaultComponents = {
4973
+ stack: Stack,
4974
+ grid: Grid,
4975
+ card: Card,
4976
+ divider: Divider,
4977
+ accordion: Accordion,
4978
+ tabs: Tabs,
4979
+ tab: Tab,
4980
+ button: Button,
4981
+ "button-group": ButtonGroup,
4982
+ input: Input,
4983
+ select: Select,
4984
+ checkbox: Checkbox,
4985
+ form: Form,
4986
+ chart: Chart,
4987
+ table: Table,
4988
+ stat: Stat,
4989
+ progress: Progress,
4990
+ callout: Callout,
4991
+ badge: Badge,
4992
+ image: Image,
4993
+ "code-block": CodeBlock,
4994
+ link: Link
4995
+ };
4996
+ function createDefaultRegistry() {
4997
+ const registry = new ComponentRegistry();
4998
+ registry.registerAll(allDefinitions);
4999
+ return registry;
5000
+ }
5001
+ export {
5002
+ MdocUIProvider,
5003
+ Renderer,
5004
+ accordion,
5005
+ allDefinitions,
5006
+ badge,
5007
+ button,
5008
+ buttonGroup,
5009
+ callout,
5010
+ card,
5011
+ chart,
5012
+ checkbox,
5013
+ codeBlock,
5014
+ createDefaultRegistry,
5015
+ defaultComponents,
5016
+ defaultGroups,
5017
+ divider,
5018
+ form,
5019
+ grid,
5020
+ image,
5021
+ input,
5022
+ link,
5023
+ progress,
5024
+ select,
5025
+ stack,
5026
+ stat,
5027
+ tab,
5028
+ table,
5029
+ tabs,
5030
+ useMdocUI,
5031
+ useRenderer
5032
+ };
5033
+ //# sourceMappingURL=index.js.map