dsh-team-rooms 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/ARCHITECTURE.md +127 -0
  2. package/LICENSE +201 -0
  3. package/README-es.md +248 -0
  4. package/README-hi.md +248 -0
  5. package/README-pt.md +248 -0
  6. package/README-zh.md +248 -0
  7. package/README.md +248 -0
  8. package/THIRD_PARTY_NOTICES.md +41 -0
  9. package/cordis.patch.yml +34 -0
  10. package/lib/client.js +4713 -0
  11. package/lib/index.js +6580 -0
  12. package/lib/types/audit.d.ts +80 -0
  13. package/lib/types/client/TeamRoomsSection.d.ts +33 -0
  14. package/lib/types/client/index.d.ts +41 -0
  15. package/lib/types/client/room-locales.d.ts +61 -0
  16. package/lib/types/client/room-presenter.d.ts +67 -0
  17. package/lib/types/facts.d.ts +66 -0
  18. package/lib/types/inbound.d.ts +282 -0
  19. package/lib/types/index.d.ts +125 -0
  20. package/lib/types/room/commands.d.ts +23 -0
  21. package/lib/types/room/domain.d.ts +72 -0
  22. package/lib/types/room/events.d.ts +105 -0
  23. package/lib/types/room/hub.d.ts +243 -0
  24. package/lib/types/room/projection.d.ts +388 -0
  25. package/lib/types/room/schema.d.ts +550 -0
  26. package/lib/types/room/tools.d.ts +34 -0
  27. package/lib/types/vocabulary.d.ts +20 -0
  28. package/package.json +170 -0
  29. package/src/audit.ts +113 -0
  30. package/src/client/TeamRoomsSection.module.css +272 -0
  31. package/src/client/TeamRoomsSection.tsx +369 -0
  32. package/src/client/css-modules.d.ts +5 -0
  33. package/src/client/index.ts +215 -0
  34. package/src/client/room-locales.ts +115 -0
  35. package/src/client/room-presenter.ts +126 -0
  36. package/src/facts.ts +127 -0
  37. package/src/inbound.ts +440 -0
  38. package/src/index.ts +309 -0
  39. package/src/room/commands.ts +278 -0
  40. package/src/room/domain.ts +38 -0
  41. package/src/room/events.ts +116 -0
  42. package/src/room/hub.ts +1022 -0
  43. package/src/room/projection.ts +267 -0
  44. package/src/room/schema.ts +153 -0
  45. package/src/room/tools.ts +603 -0
  46. package/src/vocabulary.ts +20 -0
package/lib/client.js ADDED
@@ -0,0 +1,4713 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "dsh-team-rooms",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ //#region \0rolldown/runtime.js
8
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
+ //#endregion
10
+ let react = require("react");
11
+ let react_jsx_runtime = require("react/jsx-runtime");
12
+ //#region \0dsh-tr-css:src/client/TeamRoomsSection.module.css.mjs
13
+ const css = "._oi3eG_section{flex-direction:column;gap:14px;width:100%;display:flex}._oi3eG_title{margin:0;font-size:16px;font-weight:600}._oi3eG_intro{opacity:.75;margin:0;font-size:12.5px;line-height:1.5}._oi3eG_noSession{opacity:.6;margin:0;font-size:12px}._oi3eG_forms{flex-direction:column;gap:8px;display:flex}._oi3eG_formRow{align-items:center;gap:8px;display:flex}._oi3eG_input{min-width:0;font:inherit;border:1px solid color-mix(in srgb, currentColor 22%, transparent);color:inherit;background:0 0;border-radius:6px;flex:1;padding:5px 8px;font-size:12.5px}._oi3eG_action{font:inherit;border:1px solid color-mix(in srgb, currentColor 22%, transparent);color:inherit;cursor:pointer;white-space:nowrap;background:0 0;border-radius:6px;padding:5px 10px;font-size:12px}._oi3eG_action:disabled{opacity:.45;cursor:default}._oi3eG_error{color:#d92d20;border:1px solid #d92d20;border-radius:6px;margin:0;padding:8px 10px;font-size:12.5px}._oi3eG_empty{opacity:.6;padding:6px 0;font-size:12.5px}._oi3eG_room{border:1px solid color-mix(in srgb, currentColor 16%, transparent);border-radius:10px;flex-direction:column;gap:12px;padding:12px;display:flex}._oi3eG_roomHead{flex-wrap:wrap;align-items:center;gap:8px;display:flex}._oi3eG_roomName{margin:0;font-size:14px;font-weight:600}._oi3eG_roomId{opacity:.55;word-break:break-all;font-size:11px}._oi3eG_blockTitle{text-transform:uppercase;letter-spacing:.04em;opacity:.7;margin:0 0 6px;font-size:12px;font-weight:600}._oi3eG_memberList,._oi3eG_taskList,._oi3eG_timelineList{flex-direction:column;gap:4px;margin:0;padding:0;list-style:none;display:flex}._oi3eG_member{align-items:center;gap:8px;font-size:12.5px;display:flex}._oi3eG_memberDot{border-radius:50%;flex:none;width:8px;height:8px}._oi3eG_memberLive{background:#12b76a}._oi3eG_memberOffline{background:color-mix(in srgb, currentColor 30%, transparent)}._oi3eG_memberId{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}._oi3eG_memberMeta{opacity:.6;white-space:nowrap;font-size:11px}._oi3eG_taskAdd,._oi3eG_composerRow{gap:8px;margin-bottom:8px;display:flex}._oi3eG_task{border:1px solid color-mix(in srgb, currentColor 12%, transparent);border-radius:8px;flex-direction:column;gap:4px;padding:6px 8px;display:flex}._oi3eG_task-todo{border-left:3px solid #f79009}._oi3eG_task-in-progress{border-left:3px solid #2e90fa}._oi3eG_task-done{opacity:.65;border-left:3px solid #12b76a}._oi3eG_taskHead{flex-wrap:wrap;align-items:baseline;gap:8px;display:flex}._oi3eG_taskStatus{text-transform:uppercase;letter-spacing:.04em;opacity:.75;font-size:10.5px;font-weight:600}._oi3eG_taskTitle{flex:1;min-width:0;font-size:12.5px;font-weight:500}._oi3eG_taskAssignee{opacity:.6;word-break:break-all;font-size:11px}._oi3eG_taskDesc{opacity:.75;font-size:12px}._oi3eG_taskActions{flex-wrap:wrap;align-items:center;gap:6px;display:flex}._oi3eG_assignInput{min-width:90px;font:inherit;border:1px solid color-mix(in srgb, currentColor 18%, transparent);color:inherit;background:0 0;border-radius:5px;flex:1;padding:3px 6px;font-size:11.5px}._oi3eG_timelineRow{gap:8px;font-size:11.5px;line-height:1.4;display:flex}._oi3eG_timelineKind{text-transform:uppercase;letter-spacing:.03em;opacity:.6;flex:none;padding-top:1px;font-size:10.5px;font-weight:600}._oi3eG_timelineText{word-break:break-word;min-width:0}._oi3eG_busy{opacity:.7;font-size:11.5px}";
14
+ const tagId = "dsh-team-rooms/TeamRoomsSection.module.css";
15
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
16
+ const tag = document.createElement("style");
17
+ tag.dataset.plugin = "dsh-team-rooms";
18
+ tag.dataset.pluginCss = tagId;
19
+ tag.textContent = css;
20
+ document.head.appendChild(tag);
21
+ }
22
+ var TeamRoomsSection_module_css_default = {
23
+ "action": "_oi3eG_action",
24
+ "assignInput": "_oi3eG_assignInput",
25
+ "blockTitle": "_oi3eG_blockTitle",
26
+ "busy": "_oi3eG_busy",
27
+ "composerRow": "_oi3eG_composerRow",
28
+ "empty": "_oi3eG_empty",
29
+ "error": "_oi3eG_error",
30
+ "formRow": "_oi3eG_formRow",
31
+ "forms": "_oi3eG_forms",
32
+ "input": "_oi3eG_input",
33
+ "intro": "_oi3eG_intro",
34
+ "member": "_oi3eG_member",
35
+ "memberDot": "_oi3eG_memberDot",
36
+ "memberId": "_oi3eG_memberId",
37
+ "memberList": "_oi3eG_memberList",
38
+ "memberLive": "_oi3eG_memberLive",
39
+ "memberMeta": "_oi3eG_memberMeta",
40
+ "memberOffline": "_oi3eG_memberOffline",
41
+ "noSession": "_oi3eG_noSession",
42
+ "room": "_oi3eG_room",
43
+ "roomHead": "_oi3eG_roomHead",
44
+ "roomId": "_oi3eG_roomId",
45
+ "roomName": "_oi3eG_roomName",
46
+ "section": "_oi3eG_section",
47
+ "task": "_oi3eG_task",
48
+ "task-done": "_oi3eG_task-done",
49
+ "task-in-progress": "_oi3eG_task-in-progress",
50
+ "task-todo": "_oi3eG_task-todo",
51
+ "taskActions": "_oi3eG_taskActions",
52
+ "taskAdd": "_oi3eG_taskAdd",
53
+ "taskAssignee": "_oi3eG_taskAssignee",
54
+ "taskDesc": "_oi3eG_taskDesc",
55
+ "taskHead": "_oi3eG_taskHead",
56
+ "taskList": "_oi3eG_taskList",
57
+ "taskStatus": "_oi3eG_taskStatus",
58
+ "taskTitle": "_oi3eG_taskTitle",
59
+ "timelineKind": "_oi3eG_timelineKind",
60
+ "timelineList": "_oi3eG_timelineList",
61
+ "timelineRow": "_oi3eG_timelineRow",
62
+ "timelineText": "_oi3eG_timelineText",
63
+ "title": "_oi3eG_title"
64
+ };
65
+ //#endregion
66
+ //#region src/client/TeamRoomsSection.tsx
67
+ /**
68
+ * The Team Rooms settings page panel: member status, the shared task board,
69
+ * and the timeline of every room this session belongs to. Reads arrive
70
+ * through the `teamRoom` session projection (the same durable fold the host
71
+ * reconstructs on restart); writes go back through the HOST `/room` command
72
+ * (`remote.commands.execute`), so every button keeps the durable command
73
+ * lifecycle (`command/run` / `command/done`) and the host-side ordering
74
+ * guarantees.
75
+ *
76
+ * Return types are inferred (no explicit `ReactNode` annotations): the shell
77
+ * resolves `ReactNode` against its own @types/react, and an explicit
78
+ * annotation would pin the plugin bundle to a mismatched copy.
79
+ */
80
+ /** Localized one-line account of a timeline entry. */
81
+ function timelineLabel(row, t) {
82
+ const str = (value) => typeof value === "string" ? value : "";
83
+ switch (row.kind) {
84
+ case "room-created": return t("timelineRoomCreated", { member: str(row.data.sessionId) });
85
+ case "member-joined": return t("timelineMemberJoined", { member: str(row.data.sessionId) });
86
+ case "member-left": return t("timelineMemberLeft", { member: str(row.data.sessionId) });
87
+ case "message-posted": return t("timelineMessage", {
88
+ sender: str(row.data.senderSessionId),
89
+ text: str(row.data.text)
90
+ });
91
+ case "message-directed": return t("timelineDirected", {
92
+ sender: str(row.data.senderSessionId),
93
+ to: str(row.data.toSessionId),
94
+ text: str(row.data.text)
95
+ });
96
+ case "task-created": return t("timelineTaskCreated", { title: str(row.data.title) });
97
+ case "task-claimed": return t("timelineTaskClaimed", { member: str(row.data.assigneeSessionId) });
98
+ case "task-assigned": return t("timelineTaskAssigned", { member: str(row.data.assigneeSessionId) });
99
+ case "task-completed": return t("timelineTaskCompleted", {});
100
+ default: return t("timelineUnknown", { seq: row.seq });
101
+ }
102
+ }
103
+ /** One task row with its local actions. */
104
+ function TaskRowView({ roomId, task, t, busy, actions }) {
105
+ const [assignee, setAssignee] = (0, react.useState)("");
106
+ const statusLabel = task.status === "todo" ? t("statusTodo") : task.status === "in-progress" ? t("statusInProgress") : t("statusDone");
107
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
108
+ className: `${TeamRoomsSection_module_css_default.task} ${TeamRoomsSection_module_css_default[`task-${task.status}`]}`,
109
+ children: [
110
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
111
+ className: TeamRoomsSection_module_css_default.taskHead,
112
+ children: [
113
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
114
+ className: TeamRoomsSection_module_css_default.taskStatus,
115
+ children: statusLabel
116
+ }),
117
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
118
+ className: TeamRoomsSection_module_css_default.taskTitle,
119
+ children: task.title
120
+ }),
121
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
122
+ className: TeamRoomsSection_module_css_default.taskAssignee,
123
+ children: task.assigneeSessionId === null ? t("unassigned") : task.assigneeSessionId
124
+ })
125
+ ]
126
+ }),
127
+ task.description !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
128
+ className: TeamRoomsSection_module_css_default.taskDesc,
129
+ children: task.description
130
+ }),
131
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
132
+ className: TeamRoomsSection_module_css_default.taskActions,
133
+ children: [
134
+ task.status === "todo" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
135
+ type: "button",
136
+ className: TeamRoomsSection_module_css_default.action,
137
+ disabled: busy,
138
+ onClick: () => {
139
+ actions.claimTask(roomId, task.taskId);
140
+ },
141
+ children: t("claim")
142
+ }),
143
+ task.status !== "done" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
144
+ className: TeamRoomsSection_module_css_default.assignInput,
145
+ value: assignee,
146
+ placeholder: t("assignTo"),
147
+ onChange: (event) => {
148
+ setAssignee(event.target.value);
149
+ }
150
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
151
+ type: "button",
152
+ className: TeamRoomsSection_module_css_default.action,
153
+ disabled: busy || assignee.trim() === "",
154
+ onClick: () => {
155
+ actions.assignTask(roomId, task.taskId, assignee.trim());
156
+ setAssignee("");
157
+ },
158
+ children: t("assignAction")
159
+ })] }),
160
+ task.status !== "done" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
161
+ type: "button",
162
+ className: TeamRoomsSection_module_css_default.action,
163
+ disabled: busy,
164
+ onClick: () => {
165
+ actions.completeTask(roomId, task.taskId);
166
+ },
167
+ children: t("done")
168
+ })
169
+ ]
170
+ })
171
+ ]
172
+ });
173
+ }
174
+ /** One room card: members, task board, message composer, and timeline. */
175
+ function RoomCard({ panel, t, busy, actions }) {
176
+ const [taskTitle, setTaskTitle] = (0, react.useState)("");
177
+ const [message, setMessage] = (0, react.useState)("");
178
+ const [copied, setCopied] = (0, react.useState)(false);
179
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
180
+ className: TeamRoomsSection_module_css_default.room,
181
+ children: [
182
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
183
+ className: TeamRoomsSection_module_css_default.roomHead,
184
+ children: [
185
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
186
+ className: TeamRoomsSection_module_css_default.roomName,
187
+ children: panel.name
188
+ }),
189
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
190
+ className: TeamRoomsSection_module_css_default.roomId,
191
+ children: [
192
+ t("roomId"),
193
+ ": ",
194
+ panel.roomId
195
+ ]
196
+ }),
197
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
198
+ type: "button",
199
+ className: TeamRoomsSection_module_css_default.action,
200
+ disabled: busy,
201
+ onClick: () => {
202
+ navigator.clipboard.writeText(panel.roomId);
203
+ setCopied(true);
204
+ window.setTimeout(() => {
205
+ setCopied(false);
206
+ }, 1500);
207
+ },
208
+ children: copied ? t("copied") : t("copy")
209
+ }),
210
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
211
+ type: "button",
212
+ className: TeamRoomsSection_module_css_default.action,
213
+ disabled: busy,
214
+ onClick: () => {
215
+ actions.leave(panel.roomId);
216
+ },
217
+ children: t("leave")
218
+ })
219
+ ]
220
+ }),
221
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
222
+ className: TeamRoomsSection_module_css_default.members,
223
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
224
+ className: TeamRoomsSection_module_css_default.blockTitle,
225
+ children: t("members")
226
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
227
+ className: TeamRoomsSection_module_css_default.memberList,
228
+ children: panel.members.map((member) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
229
+ className: TeamRoomsSection_module_css_default.member,
230
+ children: [
231
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
232
+ className: `${TeamRoomsSection_module_css_default.memberDot} ${member.live ? TeamRoomsSection_module_css_default.memberLive : TeamRoomsSection_module_css_default.memberOffline}`,
233
+ "aria-hidden": true
234
+ }),
235
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
236
+ className: TeamRoomsSection_module_css_default.memberId,
237
+ title: member.title ?? member.sessionId,
238
+ children: member.title ?? member.sessionId
239
+ }),
240
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
241
+ className: TeamRoomsSection_module_css_default.memberMeta,
242
+ children: [
243
+ member.role === "owner" ? t("owner") : t("member"),
244
+ " · ",
245
+ member.live ? t("live") : t("offline")
246
+ ]
247
+ })
248
+ ]
249
+ }, member.sessionId))
250
+ })]
251
+ }),
252
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
253
+ className: TeamRoomsSection_module_css_default.board,
254
+ children: [
255
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
256
+ className: TeamRoomsSection_module_css_default.blockTitle,
257
+ children: t("tasks")
258
+ }),
259
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
260
+ className: TeamRoomsSection_module_css_default.taskAdd,
261
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
262
+ className: TeamRoomsSection_module_css_default.input,
263
+ value: taskTitle,
264
+ placeholder: t("taskAddPlaceholder"),
265
+ onChange: (event) => {
266
+ setTaskTitle(event.target.value);
267
+ },
268
+ onKeyDown: (event) => {
269
+ if (event.key === "Enter" && taskTitle.trim() !== "" && !busy) {
270
+ actions.addTask(panel.roomId, taskTitle.trim());
271
+ setTaskTitle("");
272
+ }
273
+ }
274
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
275
+ type: "button",
276
+ className: TeamRoomsSection_module_css_default.action,
277
+ disabled: busy || taskTitle.trim() === "",
278
+ onClick: () => {
279
+ actions.addTask(panel.roomId, taskTitle.trim());
280
+ setTaskTitle("");
281
+ },
282
+ children: t("taskAdd")
283
+ })]
284
+ }),
285
+ panel.tasks.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
286
+ className: TeamRoomsSection_module_css_default.empty,
287
+ children: t("tasksEmpty")
288
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
289
+ className: TeamRoomsSection_module_css_default.taskList,
290
+ children: panel.tasks.map((task) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TaskRowView, {
291
+ roomId: panel.roomId,
292
+ task,
293
+ t,
294
+ busy,
295
+ actions
296
+ }, task.taskId))
297
+ })
298
+ ]
299
+ }),
300
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
301
+ className: TeamRoomsSection_module_css_default.composer,
302
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
303
+ className: TeamRoomsSection_module_css_default.blockTitle,
304
+ children: t("message")
305
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
306
+ className: TeamRoomsSection_module_css_default.composerRow,
307
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
308
+ className: TeamRoomsSection_module_css_default.input,
309
+ value: message,
310
+ placeholder: t("messagePlaceholder"),
311
+ onChange: (event) => {
312
+ setMessage(event.target.value);
313
+ },
314
+ onKeyDown: (event) => {
315
+ if (event.key === "Enter" && message.trim() !== "" && !busy) {
316
+ actions.post(panel.roomId, message.trim());
317
+ setMessage("");
318
+ }
319
+ }
320
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
321
+ type: "button",
322
+ className: TeamRoomsSection_module_css_default.action,
323
+ disabled: busy || message.trim() === "",
324
+ onClick: () => {
325
+ actions.post(panel.roomId, message.trim());
326
+ setMessage("");
327
+ },
328
+ children: t("send")
329
+ })]
330
+ })]
331
+ }),
332
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
333
+ className: TeamRoomsSection_module_css_default.timeline,
334
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
335
+ className: TeamRoomsSection_module_css_default.blockTitle,
336
+ children: t("timeline")
337
+ }), panel.timeline.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
338
+ className: TeamRoomsSection_module_css_default.empty,
339
+ children: t("timelineEmpty")
340
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
341
+ className: TeamRoomsSection_module_css_default.timelineList,
342
+ children: panel.timeline.map((event) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
343
+ className: TeamRoomsSection_module_css_default.timelineRow,
344
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
345
+ className: TeamRoomsSection_module_css_default.timelineKind,
346
+ children: event.kind
347
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
348
+ className: TeamRoomsSection_module_css_default.timelineText,
349
+ children: timelineLabel(event, t)
350
+ })]
351
+ }, event.seq))
352
+ })]
353
+ }),
354
+ busy && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
355
+ className: TeamRoomsSection_module_css_default.busy,
356
+ children: t("busy")
357
+ })
358
+ ]
359
+ });
360
+ }
361
+ /** The settings section: room management over the live session's projection. */
362
+ function TeamRoomsSection(props) {
363
+ const { useTeamRooms, t } = props;
364
+ const state = useTeamRooms((snapshot) => snapshot);
365
+ const [createName, setCreateName] = (0, react.useState)("");
366
+ const [joinId, setJoinId] = (0, react.useState)("");
367
+ const [error, setError] = (0, react.useState)(void 0);
368
+ const [busyId, setBusyId] = (0, react.useState)(void 0);
369
+ const run = async (action, mark) => {
370
+ setBusyId(mark);
371
+ setError(void 0);
372
+ try {
373
+ const failure = await action();
374
+ setError(failure);
375
+ } finally {
376
+ setBusyId(void 0);
377
+ }
378
+ };
379
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
380
+ className: TeamRoomsSection_module_css_default.section,
381
+ children: [
382
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
383
+ className: TeamRoomsSection_module_css_default.title,
384
+ children: t("title")
385
+ }),
386
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
387
+ className: TeamRoomsSection_module_css_default.intro,
388
+ children: t("intro")
389
+ }),
390
+ state.sessionId === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
391
+ className: TeamRoomsSection_module_css_default.noSession,
392
+ children: t("noSession")
393
+ }),
394
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
395
+ className: TeamRoomsSection_module_css_default.forms,
396
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
397
+ className: TeamRoomsSection_module_css_default.formRow,
398
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
399
+ className: TeamRoomsSection_module_css_default.input,
400
+ value: createName,
401
+ placeholder: t("createPlaceholder"),
402
+ disabled: state.sessionId === void 0 || busyId !== void 0,
403
+ onChange: (event) => {
404
+ setCreateName(event.target.value);
405
+ },
406
+ onKeyDown: (event) => {
407
+ if (event.key === "Enter" && createName.trim() !== "" && busyId === void 0) run(() => props.create(createName.trim()), "create").then(() => {
408
+ setCreateName("");
409
+ });
410
+ }
411
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
412
+ type: "button",
413
+ className: TeamRoomsSection_module_css_default.action,
414
+ disabled: state.sessionId === void 0 || busyId !== void 0 || createName.trim() === "",
415
+ onClick: () => {
416
+ run(() => props.create(createName.trim()), "create").then(() => {
417
+ setCreateName("");
418
+ });
419
+ },
420
+ children: t("createAction")
421
+ })]
422
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
423
+ className: TeamRoomsSection_module_css_default.formRow,
424
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
425
+ className: TeamRoomsSection_module_css_default.input,
426
+ value: joinId,
427
+ placeholder: t("joinPlaceholder"),
428
+ disabled: state.sessionId === void 0 || busyId !== void 0,
429
+ onChange: (event) => {
430
+ setJoinId(event.target.value);
431
+ },
432
+ onKeyDown: (event) => {
433
+ if (event.key === "Enter" && joinId.trim() !== "" && busyId === void 0) run(() => props.join(joinId.trim()), "join").then(() => {
434
+ setJoinId("");
435
+ });
436
+ }
437
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
438
+ type: "button",
439
+ className: TeamRoomsSection_module_css_default.action,
440
+ disabled: state.sessionId === void 0 || busyId !== void 0 || joinId.trim() === "",
441
+ onClick: () => {
442
+ run(() => props.join(joinId.trim()), "join").then(() => {
443
+ setJoinId("");
444
+ });
445
+ },
446
+ children: t("joinAction")
447
+ })]
448
+ })]
449
+ }),
450
+ error !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
451
+ className: TeamRoomsSection_module_css_default.error,
452
+ role: "alert",
453
+ children: [
454
+ t("error"),
455
+ ": ",
456
+ error
457
+ ]
458
+ }),
459
+ state.rooms.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
460
+ className: TeamRoomsSection_module_css_default.empty,
461
+ children: t("empty")
462
+ }) : state.rooms.map((room) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RoomCard, {
463
+ panel: room,
464
+ t,
465
+ busy: busyId !== void 0,
466
+ actions: props
467
+ }, room.roomId))
468
+ ]
469
+ });
470
+ }
471
+ //#endregion
472
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.cjs
473
+ var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
474
+ Object.defineProperty(exports, "__esModule", { value: true });
475
+ exports.getParsedType = exports.ZodParsedType = exports.objectUtil = exports.util = void 0;
476
+ var util;
477
+ (function(util) {
478
+ util.assertEqual = (_) => {};
479
+ function assertIs(_arg) {}
480
+ util.assertIs = assertIs;
481
+ function assertNever(_x) {
482
+ throw new Error();
483
+ }
484
+ util.assertNever = assertNever;
485
+ util.arrayToEnum = (items) => {
486
+ const obj = {};
487
+ for (const item of items) obj[item] = item;
488
+ return obj;
489
+ };
490
+ util.getValidEnumValues = (obj) => {
491
+ const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
492
+ const filtered = {};
493
+ for (const k of validKeys) filtered[k] = obj[k];
494
+ return util.objectValues(filtered);
495
+ };
496
+ util.objectValues = (obj) => {
497
+ return util.objectKeys(obj).map(function(e) {
498
+ return obj[e];
499
+ });
500
+ };
501
+ util.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
502
+ const keys = [];
503
+ for (const key in object) if (Object.prototype.hasOwnProperty.call(object, key)) keys.push(key);
504
+ return keys;
505
+ };
506
+ util.find = (arr, checker) => {
507
+ for (const item of arr) if (checker(item)) return item;
508
+ };
509
+ util.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
510
+ function joinValues(array, separator = " | ") {
511
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
512
+ }
513
+ util.joinValues = joinValues;
514
+ util.jsonStringifyReplacer = (_, value) => {
515
+ if (typeof value === "bigint") return value.toString();
516
+ return value;
517
+ };
518
+ })(util || (exports.util = util = {}));
519
+ var objectUtil;
520
+ (function(objectUtil) {
521
+ objectUtil.mergeShapes = (first, second) => {
522
+ return {
523
+ ...first,
524
+ ...second
525
+ };
526
+ };
527
+ })(objectUtil || (exports.objectUtil = objectUtil = {}));
528
+ exports.ZodParsedType = util.arrayToEnum([
529
+ "string",
530
+ "nan",
531
+ "number",
532
+ "integer",
533
+ "float",
534
+ "boolean",
535
+ "date",
536
+ "bigint",
537
+ "symbol",
538
+ "function",
539
+ "undefined",
540
+ "null",
541
+ "array",
542
+ "object",
543
+ "unknown",
544
+ "promise",
545
+ "void",
546
+ "never",
547
+ "map",
548
+ "set"
549
+ ]);
550
+ const getParsedType = (data) => {
551
+ switch (typeof data) {
552
+ case "undefined": return exports.ZodParsedType.undefined;
553
+ case "string": return exports.ZodParsedType.string;
554
+ case "number": return Number.isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number;
555
+ case "boolean": return exports.ZodParsedType.boolean;
556
+ case "function": return exports.ZodParsedType.function;
557
+ case "bigint": return exports.ZodParsedType.bigint;
558
+ case "symbol": return exports.ZodParsedType.symbol;
559
+ case "object":
560
+ if (Array.isArray(data)) return exports.ZodParsedType.array;
561
+ if (data === null) return exports.ZodParsedType.null;
562
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") return exports.ZodParsedType.promise;
563
+ if (typeof Map !== "undefined" && data instanceof Map) return exports.ZodParsedType.map;
564
+ if (typeof Set !== "undefined" && data instanceof Set) return exports.ZodParsedType.set;
565
+ if (typeof Date !== "undefined" && data instanceof Date) return exports.ZodParsedType.date;
566
+ return exports.ZodParsedType.object;
567
+ default: return exports.ZodParsedType.unknown;
568
+ }
569
+ };
570
+ exports.getParsedType = getParsedType;
571
+ }));
572
+ //#endregion
573
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.cjs
574
+ var require_ZodError = /* @__PURE__ */ __commonJSMin(((exports) => {
575
+ Object.defineProperty(exports, "__esModule", { value: true });
576
+ exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
577
+ const util_js_1 = require_util();
578
+ exports.ZodIssueCode = util_js_1.util.arrayToEnum([
579
+ "invalid_type",
580
+ "invalid_literal",
581
+ "custom",
582
+ "invalid_union",
583
+ "invalid_union_discriminator",
584
+ "invalid_enum_value",
585
+ "unrecognized_keys",
586
+ "invalid_arguments",
587
+ "invalid_return_type",
588
+ "invalid_date",
589
+ "invalid_string",
590
+ "too_small",
591
+ "too_big",
592
+ "invalid_intersection_types",
593
+ "not_multiple_of",
594
+ "not_finite"
595
+ ]);
596
+ const quotelessJson = (obj) => {
597
+ return JSON.stringify(obj, null, 2).replace(/"([^"]+)":/g, "$1:");
598
+ };
599
+ exports.quotelessJson = quotelessJson;
600
+ var ZodError = class ZodError extends Error {
601
+ get errors() {
602
+ return this.issues;
603
+ }
604
+ constructor(issues) {
605
+ super();
606
+ this.issues = [];
607
+ this.addIssue = (sub) => {
608
+ this.issues = [...this.issues, sub];
609
+ };
610
+ this.addIssues = (subs = []) => {
611
+ this.issues = [...this.issues, ...subs];
612
+ };
613
+ const actualProto = new.target.prototype;
614
+ if (Object.setPrototypeOf) Object.setPrototypeOf(this, actualProto);
615
+ else this.__proto__ = actualProto;
616
+ this.name = "ZodError";
617
+ this.issues = issues;
618
+ }
619
+ format(_mapper) {
620
+ const mapper = _mapper || function(issue) {
621
+ return issue.message;
622
+ };
623
+ const fieldErrors = { _errors: [] };
624
+ const processError = (error) => {
625
+ for (const issue of error.issues) if (issue.code === "invalid_union") issue.unionErrors.map(processError);
626
+ else if (issue.code === "invalid_return_type") processError(issue.returnTypeError);
627
+ else if (issue.code === "invalid_arguments") processError(issue.argumentsError);
628
+ else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
629
+ else {
630
+ let curr = fieldErrors;
631
+ let i = 0;
632
+ while (i < issue.path.length) {
633
+ const el = issue.path[i];
634
+ if (!(i === issue.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
635
+ else {
636
+ curr[el] = curr[el] || { _errors: [] };
637
+ curr[el]._errors.push(mapper(issue));
638
+ }
639
+ curr = curr[el];
640
+ i++;
641
+ }
642
+ }
643
+ };
644
+ processError(this);
645
+ return fieldErrors;
646
+ }
647
+ static assert(value) {
648
+ if (!(value instanceof ZodError)) throw new Error(`Not a ZodError: ${value}`);
649
+ }
650
+ toString() {
651
+ return this.message;
652
+ }
653
+ get message() {
654
+ return JSON.stringify(this.issues, util_js_1.util.jsonStringifyReplacer, 2);
655
+ }
656
+ get isEmpty() {
657
+ return this.issues.length === 0;
658
+ }
659
+ flatten(mapper = (issue) => issue.message) {
660
+ const fieldErrors = {};
661
+ const formErrors = [];
662
+ for (const sub of this.issues) if (sub.path.length > 0) {
663
+ const firstEl = sub.path[0];
664
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
665
+ fieldErrors[firstEl].push(mapper(sub));
666
+ } else formErrors.push(mapper(sub));
667
+ return {
668
+ formErrors,
669
+ fieldErrors
670
+ };
671
+ }
672
+ get formErrors() {
673
+ return this.flatten();
674
+ }
675
+ };
676
+ exports.ZodError = ZodError;
677
+ ZodError.create = (issues) => {
678
+ return new ZodError(issues);
679
+ };
680
+ }));
681
+ //#endregion
682
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.cjs
683
+ var require_en = /* @__PURE__ */ __commonJSMin(((exports) => {
684
+ Object.defineProperty(exports, "__esModule", { value: true });
685
+ const ZodError_js_1 = require_ZodError();
686
+ const util_js_1 = require_util();
687
+ const errorMap = (issue, _ctx) => {
688
+ let message;
689
+ switch (issue.code) {
690
+ case ZodError_js_1.ZodIssueCode.invalid_type:
691
+ if (issue.received === util_js_1.ZodParsedType.undefined) message = "Required";
692
+ else message = `Expected ${issue.expected}, received ${issue.received}`;
693
+ break;
694
+ case ZodError_js_1.ZodIssueCode.invalid_literal:
695
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util_js_1.util.jsonStringifyReplacer)}`;
696
+ break;
697
+ case ZodError_js_1.ZodIssueCode.unrecognized_keys:
698
+ message = `Unrecognized key(s) in object: ${util_js_1.util.joinValues(issue.keys, ", ")}`;
699
+ break;
700
+ case ZodError_js_1.ZodIssueCode.invalid_union:
701
+ message = `Invalid input`;
702
+ break;
703
+ case ZodError_js_1.ZodIssueCode.invalid_union_discriminator:
704
+ message = `Invalid discriminator value. Expected ${util_js_1.util.joinValues(issue.options)}`;
705
+ break;
706
+ case ZodError_js_1.ZodIssueCode.invalid_enum_value:
707
+ message = `Invalid enum value. Expected ${util_js_1.util.joinValues(issue.options)}, received '${issue.received}'`;
708
+ break;
709
+ case ZodError_js_1.ZodIssueCode.invalid_arguments:
710
+ message = `Invalid function arguments`;
711
+ break;
712
+ case ZodError_js_1.ZodIssueCode.invalid_return_type:
713
+ message = `Invalid function return type`;
714
+ break;
715
+ case ZodError_js_1.ZodIssueCode.invalid_date:
716
+ message = `Invalid date`;
717
+ break;
718
+ case ZodError_js_1.ZodIssueCode.invalid_string:
719
+ if (typeof issue.validation === "object") {
720
+ if ("includes" in issue.validation) {
721
+ message = `Invalid input: must include "${issue.validation.includes}"`;
722
+ if (typeof issue.validation.position === "number") message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
723
+ } else if ("startsWith" in issue.validation) message = `Invalid input: must start with "${issue.validation.startsWith}"`;
724
+ else if ("endsWith" in issue.validation) message = `Invalid input: must end with "${issue.validation.endsWith}"`;
725
+ else util_js_1.util.assertNever(issue.validation);
726
+ } else if (issue.validation !== "regex") message = `Invalid ${issue.validation}`;
727
+ else message = "Invalid";
728
+ break;
729
+ case ZodError_js_1.ZodIssueCode.too_small:
730
+ if (issue.type === "array") message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
731
+ else if (issue.type === "string") message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
732
+ else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
733
+ else if (issue.type === "bigint") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
734
+ else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
735
+ else message = "Invalid input";
736
+ break;
737
+ case ZodError_js_1.ZodIssueCode.too_big:
738
+ if (issue.type === "array") message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
739
+ else if (issue.type === "string") message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
740
+ else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
741
+ else if (issue.type === "bigint") message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
742
+ else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
743
+ else message = "Invalid input";
744
+ break;
745
+ case ZodError_js_1.ZodIssueCode.custom:
746
+ message = `Invalid input`;
747
+ break;
748
+ case ZodError_js_1.ZodIssueCode.invalid_intersection_types:
749
+ message = `Intersection results could not be merged`;
750
+ break;
751
+ case ZodError_js_1.ZodIssueCode.not_multiple_of:
752
+ message = `Number must be a multiple of ${issue.multipleOf}`;
753
+ break;
754
+ case ZodError_js_1.ZodIssueCode.not_finite:
755
+ message = "Number must be finite";
756
+ break;
757
+ default:
758
+ message = _ctx.defaultError;
759
+ util_js_1.util.assertNever(issue);
760
+ }
761
+ return { message };
762
+ };
763
+ exports.default = errorMap;
764
+ }));
765
+ //#endregion
766
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.cjs
767
+ var require_errors = /* @__PURE__ */ __commonJSMin(((exports) => {
768
+ var __importDefault = exports && exports.__importDefault || function(mod) {
769
+ return mod && mod.__esModule ? mod : { "default": mod };
770
+ };
771
+ Object.defineProperty(exports, "__esModule", { value: true });
772
+ exports.defaultErrorMap = void 0;
773
+ exports.setErrorMap = setErrorMap;
774
+ exports.getErrorMap = getErrorMap;
775
+ const en_js_1 = __importDefault(require_en());
776
+ exports.defaultErrorMap = en_js_1.default;
777
+ let overrideErrorMap = en_js_1.default;
778
+ function setErrorMap(map) {
779
+ overrideErrorMap = map;
780
+ }
781
+ function getErrorMap() {
782
+ return overrideErrorMap;
783
+ }
784
+ }));
785
+ //#endregion
786
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.cjs
787
+ var require_parseUtil = /* @__PURE__ */ __commonJSMin(((exports) => {
788
+ var __importDefault = exports && exports.__importDefault || function(mod) {
789
+ return mod && mod.__esModule ? mod : { "default": mod };
790
+ };
791
+ Object.defineProperty(exports, "__esModule", { value: true });
792
+ exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.EMPTY_PATH = exports.makeIssue = void 0;
793
+ exports.addIssueToContext = addIssueToContext;
794
+ const errors_js_1 = require_errors();
795
+ const en_js_1 = __importDefault(require_en());
796
+ const makeIssue = (params) => {
797
+ const { data, path, errorMaps, issueData } = params;
798
+ const fullPath = [...path, ...issueData.path || []];
799
+ const fullIssue = {
800
+ ...issueData,
801
+ path: fullPath
802
+ };
803
+ if (issueData.message !== void 0) return {
804
+ ...issueData,
805
+ path: fullPath,
806
+ message: issueData.message
807
+ };
808
+ let errorMessage = "";
809
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
810
+ for (const map of maps) errorMessage = map(fullIssue, {
811
+ data,
812
+ defaultError: errorMessage
813
+ }).message;
814
+ return {
815
+ ...issueData,
816
+ path: fullPath,
817
+ message: errorMessage
818
+ };
819
+ };
820
+ exports.makeIssue = makeIssue;
821
+ exports.EMPTY_PATH = [];
822
+ function addIssueToContext(ctx, issueData) {
823
+ const overrideMap = (0, errors_js_1.getErrorMap)();
824
+ const issue = (0, exports.makeIssue)({
825
+ issueData,
826
+ data: ctx.data,
827
+ path: ctx.path,
828
+ errorMaps: [
829
+ ctx.common.contextualErrorMap,
830
+ ctx.schemaErrorMap,
831
+ overrideMap,
832
+ overrideMap === en_js_1.default ? void 0 : en_js_1.default
833
+ ].filter((x) => !!x)
834
+ });
835
+ ctx.common.issues.push(issue);
836
+ }
837
+ exports.ParseStatus = class ParseStatus {
838
+ constructor() {
839
+ this.value = "valid";
840
+ }
841
+ dirty() {
842
+ if (this.value === "valid") this.value = "dirty";
843
+ }
844
+ abort() {
845
+ if (this.value !== "aborted") this.value = "aborted";
846
+ }
847
+ static mergeArray(status, results) {
848
+ const arrayValue = [];
849
+ for (const s of results) {
850
+ if (s.status === "aborted") return exports.INVALID;
851
+ if (s.status === "dirty") status.dirty();
852
+ arrayValue.push(s.value);
853
+ }
854
+ return {
855
+ status: status.value,
856
+ value: arrayValue
857
+ };
858
+ }
859
+ static async mergeObjectAsync(status, pairs) {
860
+ const syncPairs = [];
861
+ for (const pair of pairs) {
862
+ const key = await pair.key;
863
+ const value = await pair.value;
864
+ syncPairs.push({
865
+ key,
866
+ value
867
+ });
868
+ }
869
+ return ParseStatus.mergeObjectSync(status, syncPairs);
870
+ }
871
+ static mergeObjectSync(status, pairs) {
872
+ const finalObject = {};
873
+ for (const pair of pairs) {
874
+ const { key, value } = pair;
875
+ if (key.status === "aborted") return exports.INVALID;
876
+ if (value.status === "aborted") return exports.INVALID;
877
+ if (key.status === "dirty") status.dirty();
878
+ if (value.status === "dirty") status.dirty();
879
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) finalObject[key.value] = value.value;
880
+ }
881
+ return {
882
+ status: status.value,
883
+ value: finalObject
884
+ };
885
+ }
886
+ };
887
+ exports.INVALID = Object.freeze({ status: "aborted" });
888
+ const DIRTY = (value) => ({
889
+ status: "dirty",
890
+ value
891
+ });
892
+ exports.DIRTY = DIRTY;
893
+ const OK = (value) => ({
894
+ status: "valid",
895
+ value
896
+ });
897
+ exports.OK = OK;
898
+ const isAborted = (x) => x.status === "aborted";
899
+ exports.isAborted = isAborted;
900
+ const isDirty = (x) => x.status === "dirty";
901
+ exports.isDirty = isDirty;
902
+ const isValid = (x) => x.status === "valid";
903
+ exports.isValid = isValid;
904
+ const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
905
+ exports.isAsync = isAsync;
906
+ }));
907
+ //#endregion
908
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/typeAliases.cjs
909
+ var require_typeAliases = /* @__PURE__ */ __commonJSMin(((exports) => {
910
+ Object.defineProperty(exports, "__esModule", { value: true });
911
+ }));
912
+ //#endregion
913
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.cjs
914
+ var require_errorUtil = /* @__PURE__ */ __commonJSMin(((exports) => {
915
+ Object.defineProperty(exports, "__esModule", { value: true });
916
+ exports.errorUtil = void 0;
917
+ var errorUtil;
918
+ (function(errorUtil) {
919
+ errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
920
+ errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
921
+ })(errorUtil || (exports.errorUtil = errorUtil = {}));
922
+ }));
923
+ //#endregion
924
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.cjs
925
+ var require_types = /* @__PURE__ */ __commonJSMin(((exports) => {
926
+ Object.defineProperty(exports, "__esModule", { value: true });
927
+ exports.discriminatedUnion = exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0;
928
+ exports.NEVER = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.effect = void 0;
929
+ exports.datetimeRegex = datetimeRegex;
930
+ exports.custom = custom;
931
+ const ZodError_js_1 = require_ZodError();
932
+ const errors_js_1 = require_errors();
933
+ const errorUtil_js_1 = require_errorUtil();
934
+ const parseUtil_js_1 = require_parseUtil();
935
+ const util_js_1 = require_util();
936
+ var ParseInputLazyPath = class {
937
+ constructor(parent, value, path, key) {
938
+ this._cachedPath = [];
939
+ this.parent = parent;
940
+ this.data = value;
941
+ this._path = path;
942
+ this._key = key;
943
+ }
944
+ get path() {
945
+ if (!this._cachedPath.length) {
946
+ if (Array.isArray(this._key)) this._cachedPath.push(...this._path, ...this._key);
947
+ else this._cachedPath.push(...this._path, this._key);
948
+ }
949
+ return this._cachedPath;
950
+ }
951
+ };
952
+ const handleResult = (ctx, result) => {
953
+ if ((0, parseUtil_js_1.isValid)(result)) return {
954
+ success: true,
955
+ data: result.value
956
+ };
957
+ else {
958
+ if (!ctx.common.issues.length) throw new Error("Validation failed but no issues detected.");
959
+ return {
960
+ success: false,
961
+ get error() {
962
+ if (this._error) return this._error;
963
+ const error = new ZodError_js_1.ZodError(ctx.common.issues);
964
+ this._error = error;
965
+ return this._error;
966
+ }
967
+ };
968
+ }
969
+ };
970
+ function processCreateParams(params) {
971
+ if (!params) return {};
972
+ const { errorMap, invalid_type_error, required_error, description } = params;
973
+ if (errorMap && (invalid_type_error || required_error)) throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
974
+ if (errorMap) return {
975
+ errorMap,
976
+ description
977
+ };
978
+ const customMap = (iss, ctx) => {
979
+ const { message } = params;
980
+ if (iss.code === "invalid_enum_value") return { message: message ?? ctx.defaultError };
981
+ if (typeof ctx.data === "undefined") return { message: message ?? required_error ?? ctx.defaultError };
982
+ if (iss.code !== "invalid_type") return { message: ctx.defaultError };
983
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
984
+ };
985
+ return {
986
+ errorMap: customMap,
987
+ description
988
+ };
989
+ }
990
+ var ZodType = class {
991
+ get description() {
992
+ return this._def.description;
993
+ }
994
+ _getType(input) {
995
+ return (0, util_js_1.getParsedType)(input.data);
996
+ }
997
+ _getOrReturnCtx(input, ctx) {
998
+ return ctx || {
999
+ common: input.parent.common,
1000
+ data: input.data,
1001
+ parsedType: (0, util_js_1.getParsedType)(input.data),
1002
+ schemaErrorMap: this._def.errorMap,
1003
+ path: input.path,
1004
+ parent: input.parent
1005
+ };
1006
+ }
1007
+ _processInputParams(input) {
1008
+ return {
1009
+ status: new parseUtil_js_1.ParseStatus(),
1010
+ ctx: {
1011
+ common: input.parent.common,
1012
+ data: input.data,
1013
+ parsedType: (0, util_js_1.getParsedType)(input.data),
1014
+ schemaErrorMap: this._def.errorMap,
1015
+ path: input.path,
1016
+ parent: input.parent
1017
+ }
1018
+ };
1019
+ }
1020
+ _parseSync(input) {
1021
+ const result = this._parse(input);
1022
+ if ((0, parseUtil_js_1.isAsync)(result)) throw new Error("Synchronous parse encountered promise.");
1023
+ return result;
1024
+ }
1025
+ _parseAsync(input) {
1026
+ const result = this._parse(input);
1027
+ return Promise.resolve(result);
1028
+ }
1029
+ parse(data, params) {
1030
+ const result = this.safeParse(data, params);
1031
+ if (result.success) return result.data;
1032
+ throw result.error;
1033
+ }
1034
+ safeParse(data, params) {
1035
+ const ctx = {
1036
+ common: {
1037
+ issues: [],
1038
+ async: params?.async ?? false,
1039
+ contextualErrorMap: params?.errorMap
1040
+ },
1041
+ path: params?.path || [],
1042
+ schemaErrorMap: this._def.errorMap,
1043
+ parent: null,
1044
+ data,
1045
+ parsedType: (0, util_js_1.getParsedType)(data)
1046
+ };
1047
+ const result = this._parseSync({
1048
+ data,
1049
+ path: ctx.path,
1050
+ parent: ctx
1051
+ });
1052
+ return handleResult(ctx, result);
1053
+ }
1054
+ "~validate"(data) {
1055
+ const ctx = {
1056
+ common: {
1057
+ issues: [],
1058
+ async: !!this["~standard"].async
1059
+ },
1060
+ path: [],
1061
+ schemaErrorMap: this._def.errorMap,
1062
+ parent: null,
1063
+ data,
1064
+ parsedType: (0, util_js_1.getParsedType)(data)
1065
+ };
1066
+ if (!this["~standard"].async) try {
1067
+ const result = this._parseSync({
1068
+ data,
1069
+ path: [],
1070
+ parent: ctx
1071
+ });
1072
+ return (0, parseUtil_js_1.isValid)(result) ? { value: result.value } : { issues: ctx.common.issues };
1073
+ } catch (err) {
1074
+ if (err?.message?.toLowerCase()?.includes("encountered")) this["~standard"].async = true;
1075
+ ctx.common = {
1076
+ issues: [],
1077
+ async: true
1078
+ };
1079
+ }
1080
+ return this._parseAsync({
1081
+ data,
1082
+ path: [],
1083
+ parent: ctx
1084
+ }).then((result) => (0, parseUtil_js_1.isValid)(result) ? { value: result.value } : { issues: ctx.common.issues });
1085
+ }
1086
+ async parseAsync(data, params) {
1087
+ const result = await this.safeParseAsync(data, params);
1088
+ if (result.success) return result.data;
1089
+ throw result.error;
1090
+ }
1091
+ async safeParseAsync(data, params) {
1092
+ const ctx = {
1093
+ common: {
1094
+ issues: [],
1095
+ contextualErrorMap: params?.errorMap,
1096
+ async: true
1097
+ },
1098
+ path: params?.path || [],
1099
+ schemaErrorMap: this._def.errorMap,
1100
+ parent: null,
1101
+ data,
1102
+ parsedType: (0, util_js_1.getParsedType)(data)
1103
+ };
1104
+ const maybeAsyncResult = this._parse({
1105
+ data,
1106
+ path: ctx.path,
1107
+ parent: ctx
1108
+ });
1109
+ const result = await ((0, parseUtil_js_1.isAsync)(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
1110
+ return handleResult(ctx, result);
1111
+ }
1112
+ refine(check, message) {
1113
+ const getIssueProperties = (val) => {
1114
+ if (typeof message === "string" || typeof message === "undefined") return { message };
1115
+ else if (typeof message === "function") return message(val);
1116
+ else return message;
1117
+ };
1118
+ return this._refinement((val, ctx) => {
1119
+ const result = check(val);
1120
+ const setError = () => ctx.addIssue({
1121
+ code: ZodError_js_1.ZodIssueCode.custom,
1122
+ ...getIssueProperties(val)
1123
+ });
1124
+ if (typeof Promise !== "undefined" && result instanceof Promise) return result.then((data) => {
1125
+ if (!data) {
1126
+ setError();
1127
+ return false;
1128
+ } else return true;
1129
+ });
1130
+ if (!result) {
1131
+ setError();
1132
+ return false;
1133
+ } else return true;
1134
+ });
1135
+ }
1136
+ refinement(check, refinementData) {
1137
+ return this._refinement((val, ctx) => {
1138
+ if (!check(val)) {
1139
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
1140
+ return false;
1141
+ } else return true;
1142
+ });
1143
+ }
1144
+ _refinement(refinement) {
1145
+ return new ZodEffects({
1146
+ schema: this,
1147
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
1148
+ effect: {
1149
+ type: "refinement",
1150
+ refinement
1151
+ }
1152
+ });
1153
+ }
1154
+ superRefine(refinement) {
1155
+ return this._refinement(refinement);
1156
+ }
1157
+ constructor(def) {
1158
+ /** Alias of safeParseAsync */
1159
+ this.spa = this.safeParseAsync;
1160
+ this._def = def;
1161
+ this.parse = this.parse.bind(this);
1162
+ this.safeParse = this.safeParse.bind(this);
1163
+ this.parseAsync = this.parseAsync.bind(this);
1164
+ this.safeParseAsync = this.safeParseAsync.bind(this);
1165
+ this.spa = this.spa.bind(this);
1166
+ this.refine = this.refine.bind(this);
1167
+ this.refinement = this.refinement.bind(this);
1168
+ this.superRefine = this.superRefine.bind(this);
1169
+ this.optional = this.optional.bind(this);
1170
+ this.nullable = this.nullable.bind(this);
1171
+ this.nullish = this.nullish.bind(this);
1172
+ this.array = this.array.bind(this);
1173
+ this.promise = this.promise.bind(this);
1174
+ this.or = this.or.bind(this);
1175
+ this.and = this.and.bind(this);
1176
+ this.transform = this.transform.bind(this);
1177
+ this.brand = this.brand.bind(this);
1178
+ this.default = this.default.bind(this);
1179
+ this.catch = this.catch.bind(this);
1180
+ this.describe = this.describe.bind(this);
1181
+ this.pipe = this.pipe.bind(this);
1182
+ this.readonly = this.readonly.bind(this);
1183
+ this.isNullable = this.isNullable.bind(this);
1184
+ this.isOptional = this.isOptional.bind(this);
1185
+ this["~standard"] = {
1186
+ version: 1,
1187
+ vendor: "zod",
1188
+ validate: (data) => this["~validate"](data)
1189
+ };
1190
+ }
1191
+ optional() {
1192
+ return ZodOptional.create(this, this._def);
1193
+ }
1194
+ nullable() {
1195
+ return ZodNullable.create(this, this._def);
1196
+ }
1197
+ nullish() {
1198
+ return this.nullable().optional();
1199
+ }
1200
+ array() {
1201
+ return ZodArray.create(this);
1202
+ }
1203
+ promise() {
1204
+ return ZodPromise.create(this, this._def);
1205
+ }
1206
+ or(option) {
1207
+ return ZodUnion.create([this, option], this._def);
1208
+ }
1209
+ and(incoming) {
1210
+ return ZodIntersection.create(this, incoming, this._def);
1211
+ }
1212
+ transform(transform) {
1213
+ return new ZodEffects({
1214
+ ...processCreateParams(this._def),
1215
+ schema: this,
1216
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
1217
+ effect: {
1218
+ type: "transform",
1219
+ transform
1220
+ }
1221
+ });
1222
+ }
1223
+ default(def) {
1224
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
1225
+ return new ZodDefault({
1226
+ ...processCreateParams(this._def),
1227
+ innerType: this,
1228
+ defaultValue: defaultValueFunc,
1229
+ typeName: ZodFirstPartyTypeKind.ZodDefault
1230
+ });
1231
+ }
1232
+ brand() {
1233
+ return new ZodBranded({
1234
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
1235
+ type: this,
1236
+ ...processCreateParams(this._def)
1237
+ });
1238
+ }
1239
+ catch(def) {
1240
+ const catchValueFunc = typeof def === "function" ? def : () => def;
1241
+ return new ZodCatch({
1242
+ ...processCreateParams(this._def),
1243
+ innerType: this,
1244
+ catchValue: catchValueFunc,
1245
+ typeName: ZodFirstPartyTypeKind.ZodCatch
1246
+ });
1247
+ }
1248
+ describe(description) {
1249
+ const This = this.constructor;
1250
+ return new This({
1251
+ ...this._def,
1252
+ description
1253
+ });
1254
+ }
1255
+ pipe(target) {
1256
+ return ZodPipeline.create(this, target);
1257
+ }
1258
+ readonly() {
1259
+ return ZodReadonly.create(this);
1260
+ }
1261
+ isOptional() {
1262
+ return this.safeParse(void 0).success;
1263
+ }
1264
+ isNullable() {
1265
+ return this.safeParse(null).success;
1266
+ }
1267
+ };
1268
+ exports.ZodType = ZodType;
1269
+ exports.Schema = ZodType;
1270
+ exports.ZodSchema = ZodType;
1271
+ const cuidRegex = /^c[^\s-]{8,}$/i;
1272
+ const cuid2Regex = /^[0-9a-z]+$/;
1273
+ const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
1274
+ const 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;
1275
+ const nanoidRegex = /^[a-z0-9_-]{21}$/i;
1276
+ const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
1277
+ const 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)?)??$/;
1278
+ const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
1279
+ const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1280
+ let emojiRegex;
1281
+ const 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])$/;
1282
+ const 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])$/;
1283
+ const 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]))$/;
1284
+ const 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])$/;
1285
+ const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
1286
+ const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
1287
+ const 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])))`;
1288
+ const dateRegex = new RegExp(`^${dateRegexSource}$`);
1289
+ function timeRegexSource(args) {
1290
+ let secondsRegexSource = `[0-5]\\d`;
1291
+ if (args.precision) secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
1292
+ else if (args.precision == null) secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
1293
+ const secondsQuantifier = args.precision ? "+" : "?";
1294
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
1295
+ }
1296
+ function timeRegex(args) {
1297
+ return new RegExp(`^${timeRegexSource(args)}$`);
1298
+ }
1299
+ function datetimeRegex(args) {
1300
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
1301
+ const opts = [];
1302
+ opts.push(args.local ? `Z?` : `Z`);
1303
+ if (args.offset) opts.push(`([+-]\\d{2}:?\\d{2})`);
1304
+ regex = `${regex}(${opts.join("|")})`;
1305
+ return new RegExp(`^${regex}$`);
1306
+ }
1307
+ function isValidIP(ip, version) {
1308
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) return true;
1309
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) return true;
1310
+ return false;
1311
+ }
1312
+ function isValidJWT(jwt, alg) {
1313
+ if (!jwtRegex.test(jwt)) return false;
1314
+ try {
1315
+ const [header] = jwt.split(".");
1316
+ if (!header) return false;
1317
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
1318
+ const decoded = JSON.parse(atob(base64));
1319
+ if (typeof decoded !== "object" || decoded === null) return false;
1320
+ if ("typ" in decoded && decoded?.typ !== "JWT") return false;
1321
+ if (!decoded.alg) return false;
1322
+ if (alg && decoded.alg !== alg) return false;
1323
+ return true;
1324
+ } catch {
1325
+ return false;
1326
+ }
1327
+ }
1328
+ function isValidCidr(ip, version) {
1329
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) return true;
1330
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) return true;
1331
+ return false;
1332
+ }
1333
+ var ZodString = class ZodString extends ZodType {
1334
+ _parse(input) {
1335
+ if (this._def.coerce) input.data = String(input.data);
1336
+ if (this._getType(input) !== util_js_1.ZodParsedType.string) {
1337
+ const ctx = this._getOrReturnCtx(input);
1338
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1339
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
1340
+ expected: util_js_1.ZodParsedType.string,
1341
+ received: ctx.parsedType
1342
+ });
1343
+ return parseUtil_js_1.INVALID;
1344
+ }
1345
+ const status = new parseUtil_js_1.ParseStatus();
1346
+ let ctx = void 0;
1347
+ for (const check of this._def.checks) if (check.kind === "min") {
1348
+ if (input.data.length < check.value) {
1349
+ ctx = this._getOrReturnCtx(input, ctx);
1350
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1351
+ code: ZodError_js_1.ZodIssueCode.too_small,
1352
+ minimum: check.value,
1353
+ type: "string",
1354
+ inclusive: true,
1355
+ exact: false,
1356
+ message: check.message
1357
+ });
1358
+ status.dirty();
1359
+ }
1360
+ } else if (check.kind === "max") {
1361
+ if (input.data.length > check.value) {
1362
+ ctx = this._getOrReturnCtx(input, ctx);
1363
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1364
+ code: ZodError_js_1.ZodIssueCode.too_big,
1365
+ maximum: check.value,
1366
+ type: "string",
1367
+ inclusive: true,
1368
+ exact: false,
1369
+ message: check.message
1370
+ });
1371
+ status.dirty();
1372
+ }
1373
+ } else if (check.kind === "length") {
1374
+ const tooBig = input.data.length > check.value;
1375
+ const tooSmall = input.data.length < check.value;
1376
+ if (tooBig || tooSmall) {
1377
+ ctx = this._getOrReturnCtx(input, ctx);
1378
+ if (tooBig) (0, parseUtil_js_1.addIssueToContext)(ctx, {
1379
+ code: ZodError_js_1.ZodIssueCode.too_big,
1380
+ maximum: check.value,
1381
+ type: "string",
1382
+ inclusive: true,
1383
+ exact: true,
1384
+ message: check.message
1385
+ });
1386
+ else if (tooSmall) (0, parseUtil_js_1.addIssueToContext)(ctx, {
1387
+ code: ZodError_js_1.ZodIssueCode.too_small,
1388
+ minimum: check.value,
1389
+ type: "string",
1390
+ inclusive: true,
1391
+ exact: true,
1392
+ message: check.message
1393
+ });
1394
+ status.dirty();
1395
+ }
1396
+ } else if (check.kind === "email") {
1397
+ if (!emailRegex.test(input.data)) {
1398
+ ctx = this._getOrReturnCtx(input, ctx);
1399
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1400
+ validation: "email",
1401
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1402
+ message: check.message
1403
+ });
1404
+ status.dirty();
1405
+ }
1406
+ } else if (check.kind === "emoji") {
1407
+ if (!emojiRegex) emojiRegex = new RegExp(_emojiRegex, "u");
1408
+ if (!emojiRegex.test(input.data)) {
1409
+ ctx = this._getOrReturnCtx(input, ctx);
1410
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1411
+ validation: "emoji",
1412
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1413
+ message: check.message
1414
+ });
1415
+ status.dirty();
1416
+ }
1417
+ } else if (check.kind === "uuid") {
1418
+ if (!uuidRegex.test(input.data)) {
1419
+ ctx = this._getOrReturnCtx(input, ctx);
1420
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1421
+ validation: "uuid",
1422
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1423
+ message: check.message
1424
+ });
1425
+ status.dirty();
1426
+ }
1427
+ } else if (check.kind === "nanoid") {
1428
+ if (!nanoidRegex.test(input.data)) {
1429
+ ctx = this._getOrReturnCtx(input, ctx);
1430
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1431
+ validation: "nanoid",
1432
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1433
+ message: check.message
1434
+ });
1435
+ status.dirty();
1436
+ }
1437
+ } else if (check.kind === "cuid") {
1438
+ if (!cuidRegex.test(input.data)) {
1439
+ ctx = this._getOrReturnCtx(input, ctx);
1440
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1441
+ validation: "cuid",
1442
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1443
+ message: check.message
1444
+ });
1445
+ status.dirty();
1446
+ }
1447
+ } else if (check.kind === "cuid2") {
1448
+ if (!cuid2Regex.test(input.data)) {
1449
+ ctx = this._getOrReturnCtx(input, ctx);
1450
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1451
+ validation: "cuid2",
1452
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1453
+ message: check.message
1454
+ });
1455
+ status.dirty();
1456
+ }
1457
+ } else if (check.kind === "ulid") {
1458
+ if (!ulidRegex.test(input.data)) {
1459
+ ctx = this._getOrReturnCtx(input, ctx);
1460
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1461
+ validation: "ulid",
1462
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1463
+ message: check.message
1464
+ });
1465
+ status.dirty();
1466
+ }
1467
+ } else if (check.kind === "url") try {
1468
+ new URL(input.data);
1469
+ } catch {
1470
+ ctx = this._getOrReturnCtx(input, ctx);
1471
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1472
+ validation: "url",
1473
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1474
+ message: check.message
1475
+ });
1476
+ status.dirty();
1477
+ }
1478
+ else if (check.kind === "regex") {
1479
+ check.regex.lastIndex = 0;
1480
+ if (!check.regex.test(input.data)) {
1481
+ ctx = this._getOrReturnCtx(input, ctx);
1482
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1483
+ validation: "regex",
1484
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1485
+ message: check.message
1486
+ });
1487
+ status.dirty();
1488
+ }
1489
+ } else if (check.kind === "trim") input.data = input.data.trim();
1490
+ else if (check.kind === "includes") {
1491
+ if (!input.data.includes(check.value, check.position)) {
1492
+ ctx = this._getOrReturnCtx(input, ctx);
1493
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1494
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1495
+ validation: {
1496
+ includes: check.value,
1497
+ position: check.position
1498
+ },
1499
+ message: check.message
1500
+ });
1501
+ status.dirty();
1502
+ }
1503
+ } else if (check.kind === "toLowerCase") input.data = input.data.toLowerCase();
1504
+ else if (check.kind === "toUpperCase") input.data = input.data.toUpperCase();
1505
+ else if (check.kind === "startsWith") {
1506
+ if (!input.data.startsWith(check.value)) {
1507
+ ctx = this._getOrReturnCtx(input, ctx);
1508
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1509
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1510
+ validation: { startsWith: check.value },
1511
+ message: check.message
1512
+ });
1513
+ status.dirty();
1514
+ }
1515
+ } else if (check.kind === "endsWith") {
1516
+ if (!input.data.endsWith(check.value)) {
1517
+ ctx = this._getOrReturnCtx(input, ctx);
1518
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1519
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1520
+ validation: { endsWith: check.value },
1521
+ message: check.message
1522
+ });
1523
+ status.dirty();
1524
+ }
1525
+ } else if (check.kind === "datetime") {
1526
+ if (!datetimeRegex(check).test(input.data)) {
1527
+ ctx = this._getOrReturnCtx(input, ctx);
1528
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1529
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1530
+ validation: "datetime",
1531
+ message: check.message
1532
+ });
1533
+ status.dirty();
1534
+ }
1535
+ } else if (check.kind === "date") {
1536
+ if (!dateRegex.test(input.data)) {
1537
+ ctx = this._getOrReturnCtx(input, ctx);
1538
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1539
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1540
+ validation: "date",
1541
+ message: check.message
1542
+ });
1543
+ status.dirty();
1544
+ }
1545
+ } else if (check.kind === "time") {
1546
+ if (!timeRegex(check).test(input.data)) {
1547
+ ctx = this._getOrReturnCtx(input, ctx);
1548
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1549
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1550
+ validation: "time",
1551
+ message: check.message
1552
+ });
1553
+ status.dirty();
1554
+ }
1555
+ } else if (check.kind === "duration") {
1556
+ if (!durationRegex.test(input.data)) {
1557
+ ctx = this._getOrReturnCtx(input, ctx);
1558
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1559
+ validation: "duration",
1560
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1561
+ message: check.message
1562
+ });
1563
+ status.dirty();
1564
+ }
1565
+ } else if (check.kind === "ip") {
1566
+ if (!isValidIP(input.data, check.version)) {
1567
+ ctx = this._getOrReturnCtx(input, ctx);
1568
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1569
+ validation: "ip",
1570
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1571
+ message: check.message
1572
+ });
1573
+ status.dirty();
1574
+ }
1575
+ } else if (check.kind === "jwt") {
1576
+ if (!isValidJWT(input.data, check.alg)) {
1577
+ ctx = this._getOrReturnCtx(input, ctx);
1578
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1579
+ validation: "jwt",
1580
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1581
+ message: check.message
1582
+ });
1583
+ status.dirty();
1584
+ }
1585
+ } else if (check.kind === "cidr") {
1586
+ if (!isValidCidr(input.data, check.version)) {
1587
+ ctx = this._getOrReturnCtx(input, ctx);
1588
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1589
+ validation: "cidr",
1590
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1591
+ message: check.message
1592
+ });
1593
+ status.dirty();
1594
+ }
1595
+ } else if (check.kind === "base64") {
1596
+ if (!base64Regex.test(input.data)) {
1597
+ ctx = this._getOrReturnCtx(input, ctx);
1598
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1599
+ validation: "base64",
1600
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1601
+ message: check.message
1602
+ });
1603
+ status.dirty();
1604
+ }
1605
+ } else if (check.kind === "base64url") {
1606
+ if (!base64urlRegex.test(input.data)) {
1607
+ ctx = this._getOrReturnCtx(input, ctx);
1608
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1609
+ validation: "base64url",
1610
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1611
+ message: check.message
1612
+ });
1613
+ status.dirty();
1614
+ }
1615
+ } else util_js_1.util.assertNever(check);
1616
+ return {
1617
+ status: status.value,
1618
+ value: input.data
1619
+ };
1620
+ }
1621
+ _regex(regex, validation, message) {
1622
+ return this.refinement((data) => regex.test(data), {
1623
+ validation,
1624
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1625
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1626
+ });
1627
+ }
1628
+ _addCheck(check) {
1629
+ return new ZodString({
1630
+ ...this._def,
1631
+ checks: [...this._def.checks, check]
1632
+ });
1633
+ }
1634
+ email(message) {
1635
+ return this._addCheck({
1636
+ kind: "email",
1637
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1638
+ });
1639
+ }
1640
+ url(message) {
1641
+ return this._addCheck({
1642
+ kind: "url",
1643
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1644
+ });
1645
+ }
1646
+ emoji(message) {
1647
+ return this._addCheck({
1648
+ kind: "emoji",
1649
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1650
+ });
1651
+ }
1652
+ uuid(message) {
1653
+ return this._addCheck({
1654
+ kind: "uuid",
1655
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1656
+ });
1657
+ }
1658
+ nanoid(message) {
1659
+ return this._addCheck({
1660
+ kind: "nanoid",
1661
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1662
+ });
1663
+ }
1664
+ cuid(message) {
1665
+ return this._addCheck({
1666
+ kind: "cuid",
1667
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1668
+ });
1669
+ }
1670
+ cuid2(message) {
1671
+ return this._addCheck({
1672
+ kind: "cuid2",
1673
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1674
+ });
1675
+ }
1676
+ ulid(message) {
1677
+ return this._addCheck({
1678
+ kind: "ulid",
1679
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1680
+ });
1681
+ }
1682
+ base64(message) {
1683
+ return this._addCheck({
1684
+ kind: "base64",
1685
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1686
+ });
1687
+ }
1688
+ base64url(message) {
1689
+ return this._addCheck({
1690
+ kind: "base64url",
1691
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1692
+ });
1693
+ }
1694
+ jwt(options) {
1695
+ return this._addCheck({
1696
+ kind: "jwt",
1697
+ ...errorUtil_js_1.errorUtil.errToObj(options)
1698
+ });
1699
+ }
1700
+ ip(options) {
1701
+ return this._addCheck({
1702
+ kind: "ip",
1703
+ ...errorUtil_js_1.errorUtil.errToObj(options)
1704
+ });
1705
+ }
1706
+ cidr(options) {
1707
+ return this._addCheck({
1708
+ kind: "cidr",
1709
+ ...errorUtil_js_1.errorUtil.errToObj(options)
1710
+ });
1711
+ }
1712
+ datetime(options) {
1713
+ if (typeof options === "string") return this._addCheck({
1714
+ kind: "datetime",
1715
+ precision: null,
1716
+ offset: false,
1717
+ local: false,
1718
+ message: options
1719
+ });
1720
+ return this._addCheck({
1721
+ kind: "datetime",
1722
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
1723
+ offset: options?.offset ?? false,
1724
+ local: options?.local ?? false,
1725
+ ...errorUtil_js_1.errorUtil.errToObj(options?.message)
1726
+ });
1727
+ }
1728
+ date(message) {
1729
+ return this._addCheck({
1730
+ kind: "date",
1731
+ message
1732
+ });
1733
+ }
1734
+ time(options) {
1735
+ if (typeof options === "string") return this._addCheck({
1736
+ kind: "time",
1737
+ precision: null,
1738
+ message: options
1739
+ });
1740
+ return this._addCheck({
1741
+ kind: "time",
1742
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
1743
+ ...errorUtil_js_1.errorUtil.errToObj(options?.message)
1744
+ });
1745
+ }
1746
+ duration(message) {
1747
+ return this._addCheck({
1748
+ kind: "duration",
1749
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1750
+ });
1751
+ }
1752
+ regex(regex, message) {
1753
+ return this._addCheck({
1754
+ kind: "regex",
1755
+ regex,
1756
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1757
+ });
1758
+ }
1759
+ includes(value, options) {
1760
+ return this._addCheck({
1761
+ kind: "includes",
1762
+ value,
1763
+ position: options?.position,
1764
+ ...errorUtil_js_1.errorUtil.errToObj(options?.message)
1765
+ });
1766
+ }
1767
+ startsWith(value, message) {
1768
+ return this._addCheck({
1769
+ kind: "startsWith",
1770
+ value,
1771
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1772
+ });
1773
+ }
1774
+ endsWith(value, message) {
1775
+ return this._addCheck({
1776
+ kind: "endsWith",
1777
+ value,
1778
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1779
+ });
1780
+ }
1781
+ min(minLength, message) {
1782
+ return this._addCheck({
1783
+ kind: "min",
1784
+ value: minLength,
1785
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1786
+ });
1787
+ }
1788
+ max(maxLength, message) {
1789
+ return this._addCheck({
1790
+ kind: "max",
1791
+ value: maxLength,
1792
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1793
+ });
1794
+ }
1795
+ length(len, message) {
1796
+ return this._addCheck({
1797
+ kind: "length",
1798
+ value: len,
1799
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1800
+ });
1801
+ }
1802
+ /**
1803
+ * Equivalent to `.min(1)`
1804
+ */
1805
+ nonempty(message) {
1806
+ return this.min(1, errorUtil_js_1.errorUtil.errToObj(message));
1807
+ }
1808
+ trim() {
1809
+ return new ZodString({
1810
+ ...this._def,
1811
+ checks: [...this._def.checks, { kind: "trim" }]
1812
+ });
1813
+ }
1814
+ toLowerCase() {
1815
+ return new ZodString({
1816
+ ...this._def,
1817
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1818
+ });
1819
+ }
1820
+ toUpperCase() {
1821
+ return new ZodString({
1822
+ ...this._def,
1823
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1824
+ });
1825
+ }
1826
+ get isDatetime() {
1827
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
1828
+ }
1829
+ get isDate() {
1830
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1831
+ }
1832
+ get isTime() {
1833
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1834
+ }
1835
+ get isDuration() {
1836
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1837
+ }
1838
+ get isEmail() {
1839
+ return !!this._def.checks.find((ch) => ch.kind === "email");
1840
+ }
1841
+ get isURL() {
1842
+ return !!this._def.checks.find((ch) => ch.kind === "url");
1843
+ }
1844
+ get isEmoji() {
1845
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
1846
+ }
1847
+ get isUUID() {
1848
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
1849
+ }
1850
+ get isNANOID() {
1851
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1852
+ }
1853
+ get isCUID() {
1854
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
1855
+ }
1856
+ get isCUID2() {
1857
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1858
+ }
1859
+ get isULID() {
1860
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
1861
+ }
1862
+ get isIP() {
1863
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
1864
+ }
1865
+ get isCIDR() {
1866
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
1867
+ }
1868
+ get isBase64() {
1869
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1870
+ }
1871
+ get isBase64url() {
1872
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
1873
+ }
1874
+ get minLength() {
1875
+ let min = null;
1876
+ for (const ch of this._def.checks) if (ch.kind === "min") {
1877
+ if (min === null || ch.value > min) min = ch.value;
1878
+ }
1879
+ return min;
1880
+ }
1881
+ get maxLength() {
1882
+ let max = null;
1883
+ for (const ch of this._def.checks) if (ch.kind === "max") {
1884
+ if (max === null || ch.value < max) max = ch.value;
1885
+ }
1886
+ return max;
1887
+ }
1888
+ };
1889
+ exports.ZodString = ZodString;
1890
+ ZodString.create = (params) => {
1891
+ return new ZodString({
1892
+ checks: [],
1893
+ typeName: ZodFirstPartyTypeKind.ZodString,
1894
+ coerce: params?.coerce ?? false,
1895
+ ...processCreateParams(params)
1896
+ });
1897
+ };
1898
+ function floatSafeRemainder(val, step) {
1899
+ const valDecCount = (val.toString().split(".")[1] || "").length;
1900
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
1901
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1902
+ return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
1903
+ }
1904
+ var ZodNumber = class ZodNumber extends ZodType {
1905
+ constructor() {
1906
+ super(...arguments);
1907
+ this.min = this.gte;
1908
+ this.max = this.lte;
1909
+ this.step = this.multipleOf;
1910
+ }
1911
+ _parse(input) {
1912
+ if (this._def.coerce) input.data = Number(input.data);
1913
+ if (this._getType(input) !== util_js_1.ZodParsedType.number) {
1914
+ const ctx = this._getOrReturnCtx(input);
1915
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1916
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
1917
+ expected: util_js_1.ZodParsedType.number,
1918
+ received: ctx.parsedType
1919
+ });
1920
+ return parseUtil_js_1.INVALID;
1921
+ }
1922
+ let ctx = void 0;
1923
+ const status = new parseUtil_js_1.ParseStatus();
1924
+ for (const check of this._def.checks) if (check.kind === "int") {
1925
+ if (!util_js_1.util.isInteger(input.data)) {
1926
+ ctx = this._getOrReturnCtx(input, ctx);
1927
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1928
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
1929
+ expected: "integer",
1930
+ received: "float",
1931
+ message: check.message
1932
+ });
1933
+ status.dirty();
1934
+ }
1935
+ } else if (check.kind === "min") {
1936
+ if (check.inclusive ? input.data < check.value : input.data <= check.value) {
1937
+ ctx = this._getOrReturnCtx(input, ctx);
1938
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1939
+ code: ZodError_js_1.ZodIssueCode.too_small,
1940
+ minimum: check.value,
1941
+ type: "number",
1942
+ inclusive: check.inclusive,
1943
+ exact: false,
1944
+ message: check.message
1945
+ });
1946
+ status.dirty();
1947
+ }
1948
+ } else if (check.kind === "max") {
1949
+ if (check.inclusive ? input.data > check.value : input.data >= check.value) {
1950
+ ctx = this._getOrReturnCtx(input, ctx);
1951
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1952
+ code: ZodError_js_1.ZodIssueCode.too_big,
1953
+ maximum: check.value,
1954
+ type: "number",
1955
+ inclusive: check.inclusive,
1956
+ exact: false,
1957
+ message: check.message
1958
+ });
1959
+ status.dirty();
1960
+ }
1961
+ } else if (check.kind === "multipleOf") {
1962
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
1963
+ ctx = this._getOrReturnCtx(input, ctx);
1964
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1965
+ code: ZodError_js_1.ZodIssueCode.not_multiple_of,
1966
+ multipleOf: check.value,
1967
+ message: check.message
1968
+ });
1969
+ status.dirty();
1970
+ }
1971
+ } else if (check.kind === "finite") {
1972
+ if (!Number.isFinite(input.data)) {
1973
+ ctx = this._getOrReturnCtx(input, ctx);
1974
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1975
+ code: ZodError_js_1.ZodIssueCode.not_finite,
1976
+ message: check.message
1977
+ });
1978
+ status.dirty();
1979
+ }
1980
+ } else util_js_1.util.assertNever(check);
1981
+ return {
1982
+ status: status.value,
1983
+ value: input.data
1984
+ };
1985
+ }
1986
+ gte(value, message) {
1987
+ return this.setLimit("min", value, true, errorUtil_js_1.errorUtil.toString(message));
1988
+ }
1989
+ gt(value, message) {
1990
+ return this.setLimit("min", value, false, errorUtil_js_1.errorUtil.toString(message));
1991
+ }
1992
+ lte(value, message) {
1993
+ return this.setLimit("max", value, true, errorUtil_js_1.errorUtil.toString(message));
1994
+ }
1995
+ lt(value, message) {
1996
+ return this.setLimit("max", value, false, errorUtil_js_1.errorUtil.toString(message));
1997
+ }
1998
+ setLimit(kind, value, inclusive, message) {
1999
+ return new ZodNumber({
2000
+ ...this._def,
2001
+ checks: [...this._def.checks, {
2002
+ kind,
2003
+ value,
2004
+ inclusive,
2005
+ message: errorUtil_js_1.errorUtil.toString(message)
2006
+ }]
2007
+ });
2008
+ }
2009
+ _addCheck(check) {
2010
+ return new ZodNumber({
2011
+ ...this._def,
2012
+ checks: [...this._def.checks, check]
2013
+ });
2014
+ }
2015
+ int(message) {
2016
+ return this._addCheck({
2017
+ kind: "int",
2018
+ message: errorUtil_js_1.errorUtil.toString(message)
2019
+ });
2020
+ }
2021
+ positive(message) {
2022
+ return this._addCheck({
2023
+ kind: "min",
2024
+ value: 0,
2025
+ inclusive: false,
2026
+ message: errorUtil_js_1.errorUtil.toString(message)
2027
+ });
2028
+ }
2029
+ negative(message) {
2030
+ return this._addCheck({
2031
+ kind: "max",
2032
+ value: 0,
2033
+ inclusive: false,
2034
+ message: errorUtil_js_1.errorUtil.toString(message)
2035
+ });
2036
+ }
2037
+ nonpositive(message) {
2038
+ return this._addCheck({
2039
+ kind: "max",
2040
+ value: 0,
2041
+ inclusive: true,
2042
+ message: errorUtil_js_1.errorUtil.toString(message)
2043
+ });
2044
+ }
2045
+ nonnegative(message) {
2046
+ return this._addCheck({
2047
+ kind: "min",
2048
+ value: 0,
2049
+ inclusive: true,
2050
+ message: errorUtil_js_1.errorUtil.toString(message)
2051
+ });
2052
+ }
2053
+ multipleOf(value, message) {
2054
+ return this._addCheck({
2055
+ kind: "multipleOf",
2056
+ value,
2057
+ message: errorUtil_js_1.errorUtil.toString(message)
2058
+ });
2059
+ }
2060
+ finite(message) {
2061
+ return this._addCheck({
2062
+ kind: "finite",
2063
+ message: errorUtil_js_1.errorUtil.toString(message)
2064
+ });
2065
+ }
2066
+ safe(message) {
2067
+ return this._addCheck({
2068
+ kind: "min",
2069
+ inclusive: true,
2070
+ value: Number.MIN_SAFE_INTEGER,
2071
+ message: errorUtil_js_1.errorUtil.toString(message)
2072
+ })._addCheck({
2073
+ kind: "max",
2074
+ inclusive: true,
2075
+ value: Number.MAX_SAFE_INTEGER,
2076
+ message: errorUtil_js_1.errorUtil.toString(message)
2077
+ });
2078
+ }
2079
+ get minValue() {
2080
+ let min = null;
2081
+ for (const ch of this._def.checks) if (ch.kind === "min") {
2082
+ if (min === null || ch.value > min) min = ch.value;
2083
+ }
2084
+ return min;
2085
+ }
2086
+ get maxValue() {
2087
+ let max = null;
2088
+ for (const ch of this._def.checks) if (ch.kind === "max") {
2089
+ if (max === null || ch.value < max) max = ch.value;
2090
+ }
2091
+ return max;
2092
+ }
2093
+ get isInt() {
2094
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util_js_1.util.isInteger(ch.value));
2095
+ }
2096
+ get isFinite() {
2097
+ let max = null;
2098
+ let min = null;
2099
+ for (const ch of this._def.checks) if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") return true;
2100
+ else if (ch.kind === "min") {
2101
+ if (min === null || ch.value > min) min = ch.value;
2102
+ } else if (ch.kind === "max") {
2103
+ if (max === null || ch.value < max) max = ch.value;
2104
+ }
2105
+ return Number.isFinite(min) && Number.isFinite(max);
2106
+ }
2107
+ };
2108
+ exports.ZodNumber = ZodNumber;
2109
+ ZodNumber.create = (params) => {
2110
+ return new ZodNumber({
2111
+ checks: [],
2112
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
2113
+ coerce: params?.coerce || false,
2114
+ ...processCreateParams(params)
2115
+ });
2116
+ };
2117
+ var ZodBigInt = class ZodBigInt extends ZodType {
2118
+ constructor() {
2119
+ super(...arguments);
2120
+ this.min = this.gte;
2121
+ this.max = this.lte;
2122
+ }
2123
+ _parse(input) {
2124
+ if (this._def.coerce) try {
2125
+ input.data = BigInt(input.data);
2126
+ } catch {
2127
+ return this._getInvalidInput(input);
2128
+ }
2129
+ if (this._getType(input) !== util_js_1.ZodParsedType.bigint) return this._getInvalidInput(input);
2130
+ let ctx = void 0;
2131
+ const status = new parseUtil_js_1.ParseStatus();
2132
+ for (const check of this._def.checks) if (check.kind === "min") {
2133
+ if (check.inclusive ? input.data < check.value : input.data <= check.value) {
2134
+ ctx = this._getOrReturnCtx(input, ctx);
2135
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2136
+ code: ZodError_js_1.ZodIssueCode.too_small,
2137
+ type: "bigint",
2138
+ minimum: check.value,
2139
+ inclusive: check.inclusive,
2140
+ message: check.message
2141
+ });
2142
+ status.dirty();
2143
+ }
2144
+ } else if (check.kind === "max") {
2145
+ if (check.inclusive ? input.data > check.value : input.data >= check.value) {
2146
+ ctx = this._getOrReturnCtx(input, ctx);
2147
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2148
+ code: ZodError_js_1.ZodIssueCode.too_big,
2149
+ type: "bigint",
2150
+ maximum: check.value,
2151
+ inclusive: check.inclusive,
2152
+ message: check.message
2153
+ });
2154
+ status.dirty();
2155
+ }
2156
+ } else if (check.kind === "multipleOf") {
2157
+ if (input.data % check.value !== BigInt(0)) {
2158
+ ctx = this._getOrReturnCtx(input, ctx);
2159
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2160
+ code: ZodError_js_1.ZodIssueCode.not_multiple_of,
2161
+ multipleOf: check.value,
2162
+ message: check.message
2163
+ });
2164
+ status.dirty();
2165
+ }
2166
+ } else util_js_1.util.assertNever(check);
2167
+ return {
2168
+ status: status.value,
2169
+ value: input.data
2170
+ };
2171
+ }
2172
+ _getInvalidInput(input) {
2173
+ const ctx = this._getOrReturnCtx(input);
2174
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2175
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2176
+ expected: util_js_1.ZodParsedType.bigint,
2177
+ received: ctx.parsedType
2178
+ });
2179
+ return parseUtil_js_1.INVALID;
2180
+ }
2181
+ gte(value, message) {
2182
+ return this.setLimit("min", value, true, errorUtil_js_1.errorUtil.toString(message));
2183
+ }
2184
+ gt(value, message) {
2185
+ return this.setLimit("min", value, false, errorUtil_js_1.errorUtil.toString(message));
2186
+ }
2187
+ lte(value, message) {
2188
+ return this.setLimit("max", value, true, errorUtil_js_1.errorUtil.toString(message));
2189
+ }
2190
+ lt(value, message) {
2191
+ return this.setLimit("max", value, false, errorUtil_js_1.errorUtil.toString(message));
2192
+ }
2193
+ setLimit(kind, value, inclusive, message) {
2194
+ return new ZodBigInt({
2195
+ ...this._def,
2196
+ checks: [...this._def.checks, {
2197
+ kind,
2198
+ value,
2199
+ inclusive,
2200
+ message: errorUtil_js_1.errorUtil.toString(message)
2201
+ }]
2202
+ });
2203
+ }
2204
+ _addCheck(check) {
2205
+ return new ZodBigInt({
2206
+ ...this._def,
2207
+ checks: [...this._def.checks, check]
2208
+ });
2209
+ }
2210
+ positive(message) {
2211
+ return this._addCheck({
2212
+ kind: "min",
2213
+ value: BigInt(0),
2214
+ inclusive: false,
2215
+ message: errorUtil_js_1.errorUtil.toString(message)
2216
+ });
2217
+ }
2218
+ negative(message) {
2219
+ return this._addCheck({
2220
+ kind: "max",
2221
+ value: BigInt(0),
2222
+ inclusive: false,
2223
+ message: errorUtil_js_1.errorUtil.toString(message)
2224
+ });
2225
+ }
2226
+ nonpositive(message) {
2227
+ return this._addCheck({
2228
+ kind: "max",
2229
+ value: BigInt(0),
2230
+ inclusive: true,
2231
+ message: errorUtil_js_1.errorUtil.toString(message)
2232
+ });
2233
+ }
2234
+ nonnegative(message) {
2235
+ return this._addCheck({
2236
+ kind: "min",
2237
+ value: BigInt(0),
2238
+ inclusive: true,
2239
+ message: errorUtil_js_1.errorUtil.toString(message)
2240
+ });
2241
+ }
2242
+ multipleOf(value, message) {
2243
+ return this._addCheck({
2244
+ kind: "multipleOf",
2245
+ value,
2246
+ message: errorUtil_js_1.errorUtil.toString(message)
2247
+ });
2248
+ }
2249
+ get minValue() {
2250
+ let min = null;
2251
+ for (const ch of this._def.checks) if (ch.kind === "min") {
2252
+ if (min === null || ch.value > min) min = ch.value;
2253
+ }
2254
+ return min;
2255
+ }
2256
+ get maxValue() {
2257
+ let max = null;
2258
+ for (const ch of this._def.checks) if (ch.kind === "max") {
2259
+ if (max === null || ch.value < max) max = ch.value;
2260
+ }
2261
+ return max;
2262
+ }
2263
+ };
2264
+ exports.ZodBigInt = ZodBigInt;
2265
+ ZodBigInt.create = (params) => {
2266
+ return new ZodBigInt({
2267
+ checks: [],
2268
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
2269
+ coerce: params?.coerce ?? false,
2270
+ ...processCreateParams(params)
2271
+ });
2272
+ };
2273
+ var ZodBoolean = class extends ZodType {
2274
+ _parse(input) {
2275
+ if (this._def.coerce) input.data = Boolean(input.data);
2276
+ if (this._getType(input) !== util_js_1.ZodParsedType.boolean) {
2277
+ const ctx = this._getOrReturnCtx(input);
2278
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2279
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2280
+ expected: util_js_1.ZodParsedType.boolean,
2281
+ received: ctx.parsedType
2282
+ });
2283
+ return parseUtil_js_1.INVALID;
2284
+ }
2285
+ return (0, parseUtil_js_1.OK)(input.data);
2286
+ }
2287
+ };
2288
+ exports.ZodBoolean = ZodBoolean;
2289
+ ZodBoolean.create = (params) => {
2290
+ return new ZodBoolean({
2291
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
2292
+ coerce: params?.coerce || false,
2293
+ ...processCreateParams(params)
2294
+ });
2295
+ };
2296
+ var ZodDate = class ZodDate extends ZodType {
2297
+ _parse(input) {
2298
+ if (this._def.coerce) input.data = new Date(input.data);
2299
+ if (this._getType(input) !== util_js_1.ZodParsedType.date) {
2300
+ const ctx = this._getOrReturnCtx(input);
2301
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2302
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2303
+ expected: util_js_1.ZodParsedType.date,
2304
+ received: ctx.parsedType
2305
+ });
2306
+ return parseUtil_js_1.INVALID;
2307
+ }
2308
+ if (Number.isNaN(input.data.getTime())) {
2309
+ const ctx = this._getOrReturnCtx(input);
2310
+ (0, parseUtil_js_1.addIssueToContext)(ctx, { code: ZodError_js_1.ZodIssueCode.invalid_date });
2311
+ return parseUtil_js_1.INVALID;
2312
+ }
2313
+ const status = new parseUtil_js_1.ParseStatus();
2314
+ let ctx = void 0;
2315
+ for (const check of this._def.checks) if (check.kind === "min") {
2316
+ if (input.data.getTime() < check.value) {
2317
+ ctx = this._getOrReturnCtx(input, ctx);
2318
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2319
+ code: ZodError_js_1.ZodIssueCode.too_small,
2320
+ message: check.message,
2321
+ inclusive: true,
2322
+ exact: false,
2323
+ minimum: check.value,
2324
+ type: "date"
2325
+ });
2326
+ status.dirty();
2327
+ }
2328
+ } else if (check.kind === "max") {
2329
+ if (input.data.getTime() > check.value) {
2330
+ ctx = this._getOrReturnCtx(input, ctx);
2331
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2332
+ code: ZodError_js_1.ZodIssueCode.too_big,
2333
+ message: check.message,
2334
+ inclusive: true,
2335
+ exact: false,
2336
+ maximum: check.value,
2337
+ type: "date"
2338
+ });
2339
+ status.dirty();
2340
+ }
2341
+ } else util_js_1.util.assertNever(check);
2342
+ return {
2343
+ status: status.value,
2344
+ value: new Date(input.data.getTime())
2345
+ };
2346
+ }
2347
+ _addCheck(check) {
2348
+ return new ZodDate({
2349
+ ...this._def,
2350
+ checks: [...this._def.checks, check]
2351
+ });
2352
+ }
2353
+ min(minDate, message) {
2354
+ return this._addCheck({
2355
+ kind: "min",
2356
+ value: minDate.getTime(),
2357
+ message: errorUtil_js_1.errorUtil.toString(message)
2358
+ });
2359
+ }
2360
+ max(maxDate, message) {
2361
+ return this._addCheck({
2362
+ kind: "max",
2363
+ value: maxDate.getTime(),
2364
+ message: errorUtil_js_1.errorUtil.toString(message)
2365
+ });
2366
+ }
2367
+ get minDate() {
2368
+ let min = null;
2369
+ for (const ch of this._def.checks) if (ch.kind === "min") {
2370
+ if (min === null || ch.value > min) min = ch.value;
2371
+ }
2372
+ return min != null ? new Date(min) : null;
2373
+ }
2374
+ get maxDate() {
2375
+ let max = null;
2376
+ for (const ch of this._def.checks) if (ch.kind === "max") {
2377
+ if (max === null || ch.value < max) max = ch.value;
2378
+ }
2379
+ return max != null ? new Date(max) : null;
2380
+ }
2381
+ };
2382
+ exports.ZodDate = ZodDate;
2383
+ ZodDate.create = (params) => {
2384
+ return new ZodDate({
2385
+ checks: [],
2386
+ coerce: params?.coerce || false,
2387
+ typeName: ZodFirstPartyTypeKind.ZodDate,
2388
+ ...processCreateParams(params)
2389
+ });
2390
+ };
2391
+ var ZodSymbol = class extends ZodType {
2392
+ _parse(input) {
2393
+ if (this._getType(input) !== util_js_1.ZodParsedType.symbol) {
2394
+ const ctx = this._getOrReturnCtx(input);
2395
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2396
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2397
+ expected: util_js_1.ZodParsedType.symbol,
2398
+ received: ctx.parsedType
2399
+ });
2400
+ return parseUtil_js_1.INVALID;
2401
+ }
2402
+ return (0, parseUtil_js_1.OK)(input.data);
2403
+ }
2404
+ };
2405
+ exports.ZodSymbol = ZodSymbol;
2406
+ ZodSymbol.create = (params) => {
2407
+ return new ZodSymbol({
2408
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
2409
+ ...processCreateParams(params)
2410
+ });
2411
+ };
2412
+ var ZodUndefined = class extends ZodType {
2413
+ _parse(input) {
2414
+ if (this._getType(input) !== util_js_1.ZodParsedType.undefined) {
2415
+ const ctx = this._getOrReturnCtx(input);
2416
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2417
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2418
+ expected: util_js_1.ZodParsedType.undefined,
2419
+ received: ctx.parsedType
2420
+ });
2421
+ return parseUtil_js_1.INVALID;
2422
+ }
2423
+ return (0, parseUtil_js_1.OK)(input.data);
2424
+ }
2425
+ };
2426
+ exports.ZodUndefined = ZodUndefined;
2427
+ ZodUndefined.create = (params) => {
2428
+ return new ZodUndefined({
2429
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
2430
+ ...processCreateParams(params)
2431
+ });
2432
+ };
2433
+ var ZodNull = class extends ZodType {
2434
+ _parse(input) {
2435
+ if (this._getType(input) !== util_js_1.ZodParsedType.null) {
2436
+ const ctx = this._getOrReturnCtx(input);
2437
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2438
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2439
+ expected: util_js_1.ZodParsedType.null,
2440
+ received: ctx.parsedType
2441
+ });
2442
+ return parseUtil_js_1.INVALID;
2443
+ }
2444
+ return (0, parseUtil_js_1.OK)(input.data);
2445
+ }
2446
+ };
2447
+ exports.ZodNull = ZodNull;
2448
+ ZodNull.create = (params) => {
2449
+ return new ZodNull({
2450
+ typeName: ZodFirstPartyTypeKind.ZodNull,
2451
+ ...processCreateParams(params)
2452
+ });
2453
+ };
2454
+ var ZodAny = class extends ZodType {
2455
+ constructor() {
2456
+ super(...arguments);
2457
+ this._any = true;
2458
+ }
2459
+ _parse(input) {
2460
+ return (0, parseUtil_js_1.OK)(input.data);
2461
+ }
2462
+ };
2463
+ exports.ZodAny = ZodAny;
2464
+ ZodAny.create = (params) => {
2465
+ return new ZodAny({
2466
+ typeName: ZodFirstPartyTypeKind.ZodAny,
2467
+ ...processCreateParams(params)
2468
+ });
2469
+ };
2470
+ var ZodUnknown = class extends ZodType {
2471
+ constructor() {
2472
+ super(...arguments);
2473
+ this._unknown = true;
2474
+ }
2475
+ _parse(input) {
2476
+ return (0, parseUtil_js_1.OK)(input.data);
2477
+ }
2478
+ };
2479
+ exports.ZodUnknown = ZodUnknown;
2480
+ ZodUnknown.create = (params) => {
2481
+ return new ZodUnknown({
2482
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
2483
+ ...processCreateParams(params)
2484
+ });
2485
+ };
2486
+ var ZodNever = class extends ZodType {
2487
+ _parse(input) {
2488
+ const ctx = this._getOrReturnCtx(input);
2489
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2490
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2491
+ expected: util_js_1.ZodParsedType.never,
2492
+ received: ctx.parsedType
2493
+ });
2494
+ return parseUtil_js_1.INVALID;
2495
+ }
2496
+ };
2497
+ exports.ZodNever = ZodNever;
2498
+ ZodNever.create = (params) => {
2499
+ return new ZodNever({
2500
+ typeName: ZodFirstPartyTypeKind.ZodNever,
2501
+ ...processCreateParams(params)
2502
+ });
2503
+ };
2504
+ var ZodVoid = class extends ZodType {
2505
+ _parse(input) {
2506
+ if (this._getType(input) !== util_js_1.ZodParsedType.undefined) {
2507
+ const ctx = this._getOrReturnCtx(input);
2508
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2509
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2510
+ expected: util_js_1.ZodParsedType.void,
2511
+ received: ctx.parsedType
2512
+ });
2513
+ return parseUtil_js_1.INVALID;
2514
+ }
2515
+ return (0, parseUtil_js_1.OK)(input.data);
2516
+ }
2517
+ };
2518
+ exports.ZodVoid = ZodVoid;
2519
+ ZodVoid.create = (params) => {
2520
+ return new ZodVoid({
2521
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
2522
+ ...processCreateParams(params)
2523
+ });
2524
+ };
2525
+ var ZodArray = class ZodArray extends ZodType {
2526
+ _parse(input) {
2527
+ const { ctx, status } = this._processInputParams(input);
2528
+ const def = this._def;
2529
+ if (ctx.parsedType !== util_js_1.ZodParsedType.array) {
2530
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2531
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2532
+ expected: util_js_1.ZodParsedType.array,
2533
+ received: ctx.parsedType
2534
+ });
2535
+ return parseUtil_js_1.INVALID;
2536
+ }
2537
+ if (def.exactLength !== null) {
2538
+ const tooBig = ctx.data.length > def.exactLength.value;
2539
+ const tooSmall = ctx.data.length < def.exactLength.value;
2540
+ if (tooBig || tooSmall) {
2541
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2542
+ code: tooBig ? ZodError_js_1.ZodIssueCode.too_big : ZodError_js_1.ZodIssueCode.too_small,
2543
+ minimum: tooSmall ? def.exactLength.value : void 0,
2544
+ maximum: tooBig ? def.exactLength.value : void 0,
2545
+ type: "array",
2546
+ inclusive: true,
2547
+ exact: true,
2548
+ message: def.exactLength.message
2549
+ });
2550
+ status.dirty();
2551
+ }
2552
+ }
2553
+ if (def.minLength !== null) {
2554
+ if (ctx.data.length < def.minLength.value) {
2555
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2556
+ code: ZodError_js_1.ZodIssueCode.too_small,
2557
+ minimum: def.minLength.value,
2558
+ type: "array",
2559
+ inclusive: true,
2560
+ exact: false,
2561
+ message: def.minLength.message
2562
+ });
2563
+ status.dirty();
2564
+ }
2565
+ }
2566
+ if (def.maxLength !== null) {
2567
+ if (ctx.data.length > def.maxLength.value) {
2568
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2569
+ code: ZodError_js_1.ZodIssueCode.too_big,
2570
+ maximum: def.maxLength.value,
2571
+ type: "array",
2572
+ inclusive: true,
2573
+ exact: false,
2574
+ message: def.maxLength.message
2575
+ });
2576
+ status.dirty();
2577
+ }
2578
+ }
2579
+ if (ctx.common.async) return Promise.all([...ctx.data].map((item, i) => {
2580
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2581
+ })).then((result) => {
2582
+ return parseUtil_js_1.ParseStatus.mergeArray(status, result);
2583
+ });
2584
+ const result = [...ctx.data].map((item, i) => {
2585
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2586
+ });
2587
+ return parseUtil_js_1.ParseStatus.mergeArray(status, result);
2588
+ }
2589
+ get element() {
2590
+ return this._def.type;
2591
+ }
2592
+ min(minLength, message) {
2593
+ return new ZodArray({
2594
+ ...this._def,
2595
+ minLength: {
2596
+ value: minLength,
2597
+ message: errorUtil_js_1.errorUtil.toString(message)
2598
+ }
2599
+ });
2600
+ }
2601
+ max(maxLength, message) {
2602
+ return new ZodArray({
2603
+ ...this._def,
2604
+ maxLength: {
2605
+ value: maxLength,
2606
+ message: errorUtil_js_1.errorUtil.toString(message)
2607
+ }
2608
+ });
2609
+ }
2610
+ length(len, message) {
2611
+ return new ZodArray({
2612
+ ...this._def,
2613
+ exactLength: {
2614
+ value: len,
2615
+ message: errorUtil_js_1.errorUtil.toString(message)
2616
+ }
2617
+ });
2618
+ }
2619
+ nonempty(message) {
2620
+ return this.min(1, message);
2621
+ }
2622
+ };
2623
+ exports.ZodArray = ZodArray;
2624
+ ZodArray.create = (schema, params) => {
2625
+ return new ZodArray({
2626
+ type: schema,
2627
+ minLength: null,
2628
+ maxLength: null,
2629
+ exactLength: null,
2630
+ typeName: ZodFirstPartyTypeKind.ZodArray,
2631
+ ...processCreateParams(params)
2632
+ });
2633
+ };
2634
+ function deepPartialify(schema) {
2635
+ if (schema instanceof ZodObject) {
2636
+ const newShape = {};
2637
+ for (const key in schema.shape) {
2638
+ const fieldSchema = schema.shape[key];
2639
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
2640
+ }
2641
+ return new ZodObject({
2642
+ ...schema._def,
2643
+ shape: () => newShape
2644
+ });
2645
+ } else if (schema instanceof ZodArray) return new ZodArray({
2646
+ ...schema._def,
2647
+ type: deepPartialify(schema.element)
2648
+ });
2649
+ else if (schema instanceof ZodOptional) return ZodOptional.create(deepPartialify(schema.unwrap()));
2650
+ else if (schema instanceof ZodNullable) return ZodNullable.create(deepPartialify(schema.unwrap()));
2651
+ else if (schema instanceof ZodTuple) return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
2652
+ else return schema;
2653
+ }
2654
+ var ZodObject = class ZodObject extends ZodType {
2655
+ constructor() {
2656
+ super(...arguments);
2657
+ this._cached = null;
2658
+ /**
2659
+ * @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.
2660
+ * If you want to pass through unknown properties, use `.passthrough()` instead.
2661
+ */
2662
+ this.nonstrict = this.passthrough;
2663
+ /**
2664
+ * @deprecated Use `.extend` instead
2665
+ * */
2666
+ this.augment = this.extend;
2667
+ }
2668
+ _getCached() {
2669
+ if (this._cached !== null) return this._cached;
2670
+ const shape = this._def.shape();
2671
+ const keys = util_js_1.util.objectKeys(shape);
2672
+ this._cached = {
2673
+ shape,
2674
+ keys
2675
+ };
2676
+ return this._cached;
2677
+ }
2678
+ _parse(input) {
2679
+ if (this._getType(input) !== util_js_1.ZodParsedType.object) {
2680
+ const ctx = this._getOrReturnCtx(input);
2681
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2682
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2683
+ expected: util_js_1.ZodParsedType.object,
2684
+ received: ctx.parsedType
2685
+ });
2686
+ return parseUtil_js_1.INVALID;
2687
+ }
2688
+ const { status, ctx } = this._processInputParams(input);
2689
+ const { shape, keys: shapeKeys } = this._getCached();
2690
+ const extraKeys = [];
2691
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
2692
+ for (const key in ctx.data) if (!shapeKeys.includes(key)) extraKeys.push(key);
2693
+ }
2694
+ const pairs = [];
2695
+ for (const key of shapeKeys) {
2696
+ const keyValidator = shape[key];
2697
+ const value = ctx.data[key];
2698
+ pairs.push({
2699
+ key: {
2700
+ status: "valid",
2701
+ value: key
2702
+ },
2703
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2704
+ alwaysSet: key in ctx.data
2705
+ });
2706
+ }
2707
+ if (this._def.catchall instanceof ZodNever) {
2708
+ const unknownKeys = this._def.unknownKeys;
2709
+ if (unknownKeys === "passthrough") for (const key of extraKeys) pairs.push({
2710
+ key: {
2711
+ status: "valid",
2712
+ value: key
2713
+ },
2714
+ value: {
2715
+ status: "valid",
2716
+ value: ctx.data[key]
2717
+ }
2718
+ });
2719
+ else if (unknownKeys === "strict") {
2720
+ if (extraKeys.length > 0) {
2721
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2722
+ code: ZodError_js_1.ZodIssueCode.unrecognized_keys,
2723
+ keys: extraKeys
2724
+ });
2725
+ status.dirty();
2726
+ }
2727
+ } else if (unknownKeys === "strip") {} else throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2728
+ } else {
2729
+ const catchall = this._def.catchall;
2730
+ for (const key of extraKeys) {
2731
+ const value = ctx.data[key];
2732
+ pairs.push({
2733
+ key: {
2734
+ status: "valid",
2735
+ value: key
2736
+ },
2737
+ value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2738
+ alwaysSet: key in ctx.data
2739
+ });
2740
+ }
2741
+ }
2742
+ if (ctx.common.async) return Promise.resolve().then(async () => {
2743
+ const syncPairs = [];
2744
+ for (const pair of pairs) {
2745
+ const key = await pair.key;
2746
+ const value = await pair.value;
2747
+ syncPairs.push({
2748
+ key,
2749
+ value,
2750
+ alwaysSet: pair.alwaysSet
2751
+ });
2752
+ }
2753
+ return syncPairs;
2754
+ }).then((syncPairs) => {
2755
+ return parseUtil_js_1.ParseStatus.mergeObjectSync(status, syncPairs);
2756
+ });
2757
+ else return parseUtil_js_1.ParseStatus.mergeObjectSync(status, pairs);
2758
+ }
2759
+ get shape() {
2760
+ return this._def.shape();
2761
+ }
2762
+ strict(message) {
2763
+ errorUtil_js_1.errorUtil.errToObj;
2764
+ return new ZodObject({
2765
+ ...this._def,
2766
+ unknownKeys: "strict",
2767
+ ...message !== void 0 ? { errorMap: (issue, ctx) => {
2768
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
2769
+ if (issue.code === "unrecognized_keys") return { message: errorUtil_js_1.errorUtil.errToObj(message).message ?? defaultError };
2770
+ return { message: defaultError };
2771
+ } } : {}
2772
+ });
2773
+ }
2774
+ strip() {
2775
+ return new ZodObject({
2776
+ ...this._def,
2777
+ unknownKeys: "strip"
2778
+ });
2779
+ }
2780
+ passthrough() {
2781
+ return new ZodObject({
2782
+ ...this._def,
2783
+ unknownKeys: "passthrough"
2784
+ });
2785
+ }
2786
+ extend(augmentation) {
2787
+ return new ZodObject({
2788
+ ...this._def,
2789
+ shape: () => ({
2790
+ ...this._def.shape(),
2791
+ ...augmentation
2792
+ })
2793
+ });
2794
+ }
2795
+ /**
2796
+ * Prior to zod@1.0.12 there was a bug in the
2797
+ * inferred type of merged objects. Please
2798
+ * upgrade if you are experiencing issues.
2799
+ */
2800
+ merge(merging) {
2801
+ return new ZodObject({
2802
+ unknownKeys: merging._def.unknownKeys,
2803
+ catchall: merging._def.catchall,
2804
+ shape: () => ({
2805
+ ...this._def.shape(),
2806
+ ...merging._def.shape()
2807
+ }),
2808
+ typeName: ZodFirstPartyTypeKind.ZodObject
2809
+ });
2810
+ }
2811
+ setKey(key, schema) {
2812
+ return this.augment({ [key]: schema });
2813
+ }
2814
+ catchall(index) {
2815
+ return new ZodObject({
2816
+ ...this._def,
2817
+ catchall: index
2818
+ });
2819
+ }
2820
+ pick(mask) {
2821
+ const shape = {};
2822
+ for (const key of util_js_1.util.objectKeys(mask)) if (mask[key] && this.shape[key]) shape[key] = this.shape[key];
2823
+ return new ZodObject({
2824
+ ...this._def,
2825
+ shape: () => shape
2826
+ });
2827
+ }
2828
+ omit(mask) {
2829
+ const shape = {};
2830
+ for (const key of util_js_1.util.objectKeys(this.shape)) if (!mask[key]) shape[key] = this.shape[key];
2831
+ return new ZodObject({
2832
+ ...this._def,
2833
+ shape: () => shape
2834
+ });
2835
+ }
2836
+ /**
2837
+ * @deprecated
2838
+ */
2839
+ deepPartial() {
2840
+ return deepPartialify(this);
2841
+ }
2842
+ partial(mask) {
2843
+ const newShape = {};
2844
+ for (const key of util_js_1.util.objectKeys(this.shape)) {
2845
+ const fieldSchema = this.shape[key];
2846
+ if (mask && !mask[key]) newShape[key] = fieldSchema;
2847
+ else newShape[key] = fieldSchema.optional();
2848
+ }
2849
+ return new ZodObject({
2850
+ ...this._def,
2851
+ shape: () => newShape
2852
+ });
2853
+ }
2854
+ required(mask) {
2855
+ const newShape = {};
2856
+ for (const key of util_js_1.util.objectKeys(this.shape)) if (mask && !mask[key]) newShape[key] = this.shape[key];
2857
+ else {
2858
+ let newField = this.shape[key];
2859
+ while (newField instanceof ZodOptional) newField = newField._def.innerType;
2860
+ newShape[key] = newField;
2861
+ }
2862
+ return new ZodObject({
2863
+ ...this._def,
2864
+ shape: () => newShape
2865
+ });
2866
+ }
2867
+ keyof() {
2868
+ return createZodEnum(util_js_1.util.objectKeys(this.shape));
2869
+ }
2870
+ };
2871
+ exports.ZodObject = ZodObject;
2872
+ ZodObject.create = (shape, params) => {
2873
+ return new ZodObject({
2874
+ shape: () => shape,
2875
+ unknownKeys: "strip",
2876
+ catchall: ZodNever.create(),
2877
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2878
+ ...processCreateParams(params)
2879
+ });
2880
+ };
2881
+ ZodObject.strictCreate = (shape, params) => {
2882
+ return new ZodObject({
2883
+ shape: () => shape,
2884
+ unknownKeys: "strict",
2885
+ catchall: ZodNever.create(),
2886
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2887
+ ...processCreateParams(params)
2888
+ });
2889
+ };
2890
+ ZodObject.lazycreate = (shape, params) => {
2891
+ return new ZodObject({
2892
+ shape,
2893
+ unknownKeys: "strip",
2894
+ catchall: ZodNever.create(),
2895
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2896
+ ...processCreateParams(params)
2897
+ });
2898
+ };
2899
+ var ZodUnion = class extends ZodType {
2900
+ _parse(input) {
2901
+ const { ctx } = this._processInputParams(input);
2902
+ const options = this._def.options;
2903
+ function handleResults(results) {
2904
+ for (const result of results) if (result.result.status === "valid") return result.result;
2905
+ for (const result of results) if (result.result.status === "dirty") {
2906
+ ctx.common.issues.push(...result.ctx.common.issues);
2907
+ return result.result;
2908
+ }
2909
+ const unionErrors = results.map((result) => new ZodError_js_1.ZodError(result.ctx.common.issues));
2910
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2911
+ code: ZodError_js_1.ZodIssueCode.invalid_union,
2912
+ unionErrors
2913
+ });
2914
+ return parseUtil_js_1.INVALID;
2915
+ }
2916
+ if (ctx.common.async) return Promise.all(options.map(async (option) => {
2917
+ const childCtx = {
2918
+ ...ctx,
2919
+ common: {
2920
+ ...ctx.common,
2921
+ issues: []
2922
+ },
2923
+ parent: null
2924
+ };
2925
+ return {
2926
+ result: await option._parseAsync({
2927
+ data: ctx.data,
2928
+ path: ctx.path,
2929
+ parent: childCtx
2930
+ }),
2931
+ ctx: childCtx
2932
+ };
2933
+ })).then(handleResults);
2934
+ else {
2935
+ let dirty = void 0;
2936
+ const issues = [];
2937
+ for (const option of options) {
2938
+ const childCtx = {
2939
+ ...ctx,
2940
+ common: {
2941
+ ...ctx.common,
2942
+ issues: []
2943
+ },
2944
+ parent: null
2945
+ };
2946
+ const result = option._parseSync({
2947
+ data: ctx.data,
2948
+ path: ctx.path,
2949
+ parent: childCtx
2950
+ });
2951
+ if (result.status === "valid") return result;
2952
+ else if (result.status === "dirty" && !dirty) dirty = {
2953
+ result,
2954
+ ctx: childCtx
2955
+ };
2956
+ if (childCtx.common.issues.length) issues.push(childCtx.common.issues);
2957
+ }
2958
+ if (dirty) {
2959
+ ctx.common.issues.push(...dirty.ctx.common.issues);
2960
+ return dirty.result;
2961
+ }
2962
+ const unionErrors = issues.map((issues) => new ZodError_js_1.ZodError(issues));
2963
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2964
+ code: ZodError_js_1.ZodIssueCode.invalid_union,
2965
+ unionErrors
2966
+ });
2967
+ return parseUtil_js_1.INVALID;
2968
+ }
2969
+ }
2970
+ get options() {
2971
+ return this._def.options;
2972
+ }
2973
+ };
2974
+ exports.ZodUnion = ZodUnion;
2975
+ ZodUnion.create = (types, params) => {
2976
+ return new ZodUnion({
2977
+ options: types,
2978
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
2979
+ ...processCreateParams(params)
2980
+ });
2981
+ };
2982
+ const getDiscriminator = (type) => {
2983
+ if (type instanceof ZodLazy) return getDiscriminator(type.schema);
2984
+ else if (type instanceof ZodEffects) return getDiscriminator(type.innerType());
2985
+ else if (type instanceof ZodLiteral) return [type.value];
2986
+ else if (type instanceof ZodEnum) return type.options;
2987
+ else if (type instanceof ZodNativeEnum) return util_js_1.util.objectValues(type.enum);
2988
+ else if (type instanceof ZodDefault) return getDiscriminator(type._def.innerType);
2989
+ else if (type instanceof ZodUndefined) return [void 0];
2990
+ else if (type instanceof ZodNull) return [null];
2991
+ else if (type instanceof ZodOptional) return [void 0, ...getDiscriminator(type.unwrap())];
2992
+ else if (type instanceof ZodNullable) return [null, ...getDiscriminator(type.unwrap())];
2993
+ else if (type instanceof ZodBranded) return getDiscriminator(type.unwrap());
2994
+ else if (type instanceof ZodReadonly) return getDiscriminator(type.unwrap());
2995
+ else if (type instanceof ZodCatch) return getDiscriminator(type._def.innerType);
2996
+ else return [];
2997
+ };
2998
+ var ZodDiscriminatedUnion = class ZodDiscriminatedUnion extends ZodType {
2999
+ _parse(input) {
3000
+ const { ctx } = this._processInputParams(input);
3001
+ if (ctx.parsedType !== util_js_1.ZodParsedType.object) {
3002
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3003
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3004
+ expected: util_js_1.ZodParsedType.object,
3005
+ received: ctx.parsedType
3006
+ });
3007
+ return parseUtil_js_1.INVALID;
3008
+ }
3009
+ const discriminator = this.discriminator;
3010
+ const discriminatorValue = ctx.data[discriminator];
3011
+ const option = this.optionsMap.get(discriminatorValue);
3012
+ if (!option) {
3013
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3014
+ code: ZodError_js_1.ZodIssueCode.invalid_union_discriminator,
3015
+ options: Array.from(this.optionsMap.keys()),
3016
+ path: [discriminator]
3017
+ });
3018
+ return parseUtil_js_1.INVALID;
3019
+ }
3020
+ if (ctx.common.async) return option._parseAsync({
3021
+ data: ctx.data,
3022
+ path: ctx.path,
3023
+ parent: ctx
3024
+ });
3025
+ else return option._parseSync({
3026
+ data: ctx.data,
3027
+ path: ctx.path,
3028
+ parent: ctx
3029
+ });
3030
+ }
3031
+ get discriminator() {
3032
+ return this._def.discriminator;
3033
+ }
3034
+ get options() {
3035
+ return this._def.options;
3036
+ }
3037
+ get optionsMap() {
3038
+ return this._def.optionsMap;
3039
+ }
3040
+ /**
3041
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
3042
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
3043
+ * have a different value for each object in the union.
3044
+ * @param discriminator the name of the discriminator property
3045
+ * @param types an array of object schemas
3046
+ * @param params
3047
+ */
3048
+ static create(discriminator, options, params) {
3049
+ const optionsMap = /* @__PURE__ */ new Map();
3050
+ for (const type of options) {
3051
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
3052
+ if (!discriminatorValues.length) throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3053
+ for (const value of discriminatorValues) {
3054
+ if (optionsMap.has(value)) throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
3055
+ optionsMap.set(value, type);
3056
+ }
3057
+ }
3058
+ return new ZodDiscriminatedUnion({
3059
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
3060
+ discriminator,
3061
+ options,
3062
+ optionsMap,
3063
+ ...processCreateParams(params)
3064
+ });
3065
+ }
3066
+ };
3067
+ exports.ZodDiscriminatedUnion = ZodDiscriminatedUnion;
3068
+ function mergeValues(a, b) {
3069
+ const aType = (0, util_js_1.getParsedType)(a);
3070
+ const bType = (0, util_js_1.getParsedType)(b);
3071
+ if (a === b) return {
3072
+ valid: true,
3073
+ data: a
3074
+ };
3075
+ else if (aType === util_js_1.ZodParsedType.object && bType === util_js_1.ZodParsedType.object) {
3076
+ const bKeys = util_js_1.util.objectKeys(b);
3077
+ const sharedKeys = util_js_1.util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
3078
+ const newObj = {
3079
+ ...a,
3080
+ ...b
3081
+ };
3082
+ for (const key of sharedKeys) {
3083
+ const sharedValue = mergeValues(a[key], b[key]);
3084
+ if (!sharedValue.valid) return { valid: false };
3085
+ newObj[key] = sharedValue.data;
3086
+ }
3087
+ return {
3088
+ valid: true,
3089
+ data: newObj
3090
+ };
3091
+ } else if (aType === util_js_1.ZodParsedType.array && bType === util_js_1.ZodParsedType.array) {
3092
+ if (a.length !== b.length) return { valid: false };
3093
+ const newArray = [];
3094
+ for (let index = 0; index < a.length; index++) {
3095
+ const itemA = a[index];
3096
+ const itemB = b[index];
3097
+ const sharedValue = mergeValues(itemA, itemB);
3098
+ if (!sharedValue.valid) return { valid: false };
3099
+ newArray.push(sharedValue.data);
3100
+ }
3101
+ return {
3102
+ valid: true,
3103
+ data: newArray
3104
+ };
3105
+ } else if (aType === util_js_1.ZodParsedType.date && bType === util_js_1.ZodParsedType.date && +a === +b) return {
3106
+ valid: true,
3107
+ data: a
3108
+ };
3109
+ else return { valid: false };
3110
+ }
3111
+ var ZodIntersection = class extends ZodType {
3112
+ _parse(input) {
3113
+ const { status, ctx } = this._processInputParams(input);
3114
+ const handleParsed = (parsedLeft, parsedRight) => {
3115
+ if ((0, parseUtil_js_1.isAborted)(parsedLeft) || (0, parseUtil_js_1.isAborted)(parsedRight)) return parseUtil_js_1.INVALID;
3116
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
3117
+ if (!merged.valid) {
3118
+ (0, parseUtil_js_1.addIssueToContext)(ctx, { code: ZodError_js_1.ZodIssueCode.invalid_intersection_types });
3119
+ return parseUtil_js_1.INVALID;
3120
+ }
3121
+ if ((0, parseUtil_js_1.isDirty)(parsedLeft) || (0, parseUtil_js_1.isDirty)(parsedRight)) status.dirty();
3122
+ return {
3123
+ status: status.value,
3124
+ value: merged.data
3125
+ };
3126
+ };
3127
+ if (ctx.common.async) return Promise.all([this._def.left._parseAsync({
3128
+ data: ctx.data,
3129
+ path: ctx.path,
3130
+ parent: ctx
3131
+ }), this._def.right._parseAsync({
3132
+ data: ctx.data,
3133
+ path: ctx.path,
3134
+ parent: ctx
3135
+ })]).then(([left, right]) => handleParsed(left, right));
3136
+ else return handleParsed(this._def.left._parseSync({
3137
+ data: ctx.data,
3138
+ path: ctx.path,
3139
+ parent: ctx
3140
+ }), this._def.right._parseSync({
3141
+ data: ctx.data,
3142
+ path: ctx.path,
3143
+ parent: ctx
3144
+ }));
3145
+ }
3146
+ };
3147
+ exports.ZodIntersection = ZodIntersection;
3148
+ ZodIntersection.create = (left, right, params) => {
3149
+ return new ZodIntersection({
3150
+ left,
3151
+ right,
3152
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
3153
+ ...processCreateParams(params)
3154
+ });
3155
+ };
3156
+ var ZodTuple = class ZodTuple extends ZodType {
3157
+ _parse(input) {
3158
+ const { status, ctx } = this._processInputParams(input);
3159
+ if (ctx.parsedType !== util_js_1.ZodParsedType.array) {
3160
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3161
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3162
+ expected: util_js_1.ZodParsedType.array,
3163
+ received: ctx.parsedType
3164
+ });
3165
+ return parseUtil_js_1.INVALID;
3166
+ }
3167
+ if (ctx.data.length < this._def.items.length) {
3168
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3169
+ code: ZodError_js_1.ZodIssueCode.too_small,
3170
+ minimum: this._def.items.length,
3171
+ inclusive: true,
3172
+ exact: false,
3173
+ type: "array"
3174
+ });
3175
+ return parseUtil_js_1.INVALID;
3176
+ }
3177
+ if (!this._def.rest && ctx.data.length > this._def.items.length) {
3178
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3179
+ code: ZodError_js_1.ZodIssueCode.too_big,
3180
+ maximum: this._def.items.length,
3181
+ inclusive: true,
3182
+ exact: false,
3183
+ type: "array"
3184
+ });
3185
+ status.dirty();
3186
+ }
3187
+ const items = [...ctx.data].map((item, itemIndex) => {
3188
+ const schema = this._def.items[itemIndex] || this._def.rest;
3189
+ if (!schema) return null;
3190
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3191
+ }).filter((x) => !!x);
3192
+ if (ctx.common.async) return Promise.all(items).then((results) => {
3193
+ return parseUtil_js_1.ParseStatus.mergeArray(status, results);
3194
+ });
3195
+ else return parseUtil_js_1.ParseStatus.mergeArray(status, items);
3196
+ }
3197
+ get items() {
3198
+ return this._def.items;
3199
+ }
3200
+ rest(rest) {
3201
+ return new ZodTuple({
3202
+ ...this._def,
3203
+ rest
3204
+ });
3205
+ }
3206
+ };
3207
+ exports.ZodTuple = ZodTuple;
3208
+ ZodTuple.create = (schemas, params) => {
3209
+ if (!Array.isArray(schemas)) throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3210
+ return new ZodTuple({
3211
+ items: schemas,
3212
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
3213
+ rest: null,
3214
+ ...processCreateParams(params)
3215
+ });
3216
+ };
3217
+ var ZodRecord = class ZodRecord extends ZodType {
3218
+ get keySchema() {
3219
+ return this._def.keyType;
3220
+ }
3221
+ get valueSchema() {
3222
+ return this._def.valueType;
3223
+ }
3224
+ _parse(input) {
3225
+ const { status, ctx } = this._processInputParams(input);
3226
+ if (ctx.parsedType !== util_js_1.ZodParsedType.object) {
3227
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3228
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3229
+ expected: util_js_1.ZodParsedType.object,
3230
+ received: ctx.parsedType
3231
+ });
3232
+ return parseUtil_js_1.INVALID;
3233
+ }
3234
+ const pairs = [];
3235
+ const keyType = this._def.keyType;
3236
+ const valueType = this._def.valueType;
3237
+ for (const key in ctx.data) pairs.push({
3238
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3239
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3240
+ alwaysSet: key in ctx.data
3241
+ });
3242
+ if (ctx.common.async) return parseUtil_js_1.ParseStatus.mergeObjectAsync(status, pairs);
3243
+ else return parseUtil_js_1.ParseStatus.mergeObjectSync(status, pairs);
3244
+ }
3245
+ get element() {
3246
+ return this._def.valueType;
3247
+ }
3248
+ static create(first, second, third) {
3249
+ if (second instanceof ZodType) return new ZodRecord({
3250
+ keyType: first,
3251
+ valueType: second,
3252
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3253
+ ...processCreateParams(third)
3254
+ });
3255
+ return new ZodRecord({
3256
+ keyType: ZodString.create(),
3257
+ valueType: first,
3258
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3259
+ ...processCreateParams(second)
3260
+ });
3261
+ }
3262
+ };
3263
+ exports.ZodRecord = ZodRecord;
3264
+ var ZodMap = class extends ZodType {
3265
+ get keySchema() {
3266
+ return this._def.keyType;
3267
+ }
3268
+ get valueSchema() {
3269
+ return this._def.valueType;
3270
+ }
3271
+ _parse(input) {
3272
+ const { status, ctx } = this._processInputParams(input);
3273
+ if (ctx.parsedType !== util_js_1.ZodParsedType.map) {
3274
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3275
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3276
+ expected: util_js_1.ZodParsedType.map,
3277
+ received: ctx.parsedType
3278
+ });
3279
+ return parseUtil_js_1.INVALID;
3280
+ }
3281
+ const keyType = this._def.keyType;
3282
+ const valueType = this._def.valueType;
3283
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
3284
+ return {
3285
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
3286
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
3287
+ };
3288
+ });
3289
+ if (ctx.common.async) {
3290
+ const finalMap = /* @__PURE__ */ new Map();
3291
+ return Promise.resolve().then(async () => {
3292
+ for (const pair of pairs) {
3293
+ const key = await pair.key;
3294
+ const value = await pair.value;
3295
+ if (key.status === "aborted" || value.status === "aborted") return parseUtil_js_1.INVALID;
3296
+ if (key.status === "dirty" || value.status === "dirty") status.dirty();
3297
+ finalMap.set(key.value, value.value);
3298
+ }
3299
+ return {
3300
+ status: status.value,
3301
+ value: finalMap
3302
+ };
3303
+ });
3304
+ } else {
3305
+ const finalMap = /* @__PURE__ */ new Map();
3306
+ for (const pair of pairs) {
3307
+ const key = pair.key;
3308
+ const value = pair.value;
3309
+ if (key.status === "aborted" || value.status === "aborted") return parseUtil_js_1.INVALID;
3310
+ if (key.status === "dirty" || value.status === "dirty") status.dirty();
3311
+ finalMap.set(key.value, value.value);
3312
+ }
3313
+ return {
3314
+ status: status.value,
3315
+ value: finalMap
3316
+ };
3317
+ }
3318
+ }
3319
+ };
3320
+ exports.ZodMap = ZodMap;
3321
+ ZodMap.create = (keyType, valueType, params) => {
3322
+ return new ZodMap({
3323
+ valueType,
3324
+ keyType,
3325
+ typeName: ZodFirstPartyTypeKind.ZodMap,
3326
+ ...processCreateParams(params)
3327
+ });
3328
+ };
3329
+ var ZodSet = class ZodSet extends ZodType {
3330
+ _parse(input) {
3331
+ const { status, ctx } = this._processInputParams(input);
3332
+ if (ctx.parsedType !== util_js_1.ZodParsedType.set) {
3333
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3334
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3335
+ expected: util_js_1.ZodParsedType.set,
3336
+ received: ctx.parsedType
3337
+ });
3338
+ return parseUtil_js_1.INVALID;
3339
+ }
3340
+ const def = this._def;
3341
+ if (def.minSize !== null) {
3342
+ if (ctx.data.size < def.minSize.value) {
3343
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3344
+ code: ZodError_js_1.ZodIssueCode.too_small,
3345
+ minimum: def.minSize.value,
3346
+ type: "set",
3347
+ inclusive: true,
3348
+ exact: false,
3349
+ message: def.minSize.message
3350
+ });
3351
+ status.dirty();
3352
+ }
3353
+ }
3354
+ if (def.maxSize !== null) {
3355
+ if (ctx.data.size > def.maxSize.value) {
3356
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3357
+ code: ZodError_js_1.ZodIssueCode.too_big,
3358
+ maximum: def.maxSize.value,
3359
+ type: "set",
3360
+ inclusive: true,
3361
+ exact: false,
3362
+ message: def.maxSize.message
3363
+ });
3364
+ status.dirty();
3365
+ }
3366
+ }
3367
+ const valueType = this._def.valueType;
3368
+ function finalizeSet(elements) {
3369
+ const parsedSet = /* @__PURE__ */ new Set();
3370
+ for (const element of elements) {
3371
+ if (element.status === "aborted") return parseUtil_js_1.INVALID;
3372
+ if (element.status === "dirty") status.dirty();
3373
+ parsedSet.add(element.value);
3374
+ }
3375
+ return {
3376
+ status: status.value,
3377
+ value: parsedSet
3378
+ };
3379
+ }
3380
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
3381
+ if (ctx.common.async) return Promise.all(elements).then((elements) => finalizeSet(elements));
3382
+ else return finalizeSet(elements);
3383
+ }
3384
+ min(minSize, message) {
3385
+ return new ZodSet({
3386
+ ...this._def,
3387
+ minSize: {
3388
+ value: minSize,
3389
+ message: errorUtil_js_1.errorUtil.toString(message)
3390
+ }
3391
+ });
3392
+ }
3393
+ max(maxSize, message) {
3394
+ return new ZodSet({
3395
+ ...this._def,
3396
+ maxSize: {
3397
+ value: maxSize,
3398
+ message: errorUtil_js_1.errorUtil.toString(message)
3399
+ }
3400
+ });
3401
+ }
3402
+ size(size, message) {
3403
+ return this.min(size, message).max(size, message);
3404
+ }
3405
+ nonempty(message) {
3406
+ return this.min(1, message);
3407
+ }
3408
+ };
3409
+ exports.ZodSet = ZodSet;
3410
+ ZodSet.create = (valueType, params) => {
3411
+ return new ZodSet({
3412
+ valueType,
3413
+ minSize: null,
3414
+ maxSize: null,
3415
+ typeName: ZodFirstPartyTypeKind.ZodSet,
3416
+ ...processCreateParams(params)
3417
+ });
3418
+ };
3419
+ var ZodFunction = class ZodFunction extends ZodType {
3420
+ constructor() {
3421
+ super(...arguments);
3422
+ this.validate = this.implement;
3423
+ }
3424
+ _parse(input) {
3425
+ const { ctx } = this._processInputParams(input);
3426
+ if (ctx.parsedType !== util_js_1.ZodParsedType.function) {
3427
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3428
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3429
+ expected: util_js_1.ZodParsedType.function,
3430
+ received: ctx.parsedType
3431
+ });
3432
+ return parseUtil_js_1.INVALID;
3433
+ }
3434
+ function makeArgsIssue(args, error) {
3435
+ return (0, parseUtil_js_1.makeIssue)({
3436
+ data: args,
3437
+ path: ctx.path,
3438
+ errorMaps: [
3439
+ ctx.common.contextualErrorMap,
3440
+ ctx.schemaErrorMap,
3441
+ (0, errors_js_1.getErrorMap)(),
3442
+ errors_js_1.defaultErrorMap
3443
+ ].filter((x) => !!x),
3444
+ issueData: {
3445
+ code: ZodError_js_1.ZodIssueCode.invalid_arguments,
3446
+ argumentsError: error
3447
+ }
3448
+ });
3449
+ }
3450
+ function makeReturnsIssue(returns, error) {
3451
+ return (0, parseUtil_js_1.makeIssue)({
3452
+ data: returns,
3453
+ path: ctx.path,
3454
+ errorMaps: [
3455
+ ctx.common.contextualErrorMap,
3456
+ ctx.schemaErrorMap,
3457
+ (0, errors_js_1.getErrorMap)(),
3458
+ errors_js_1.defaultErrorMap
3459
+ ].filter((x) => !!x),
3460
+ issueData: {
3461
+ code: ZodError_js_1.ZodIssueCode.invalid_return_type,
3462
+ returnTypeError: error
3463
+ }
3464
+ });
3465
+ }
3466
+ const params = { errorMap: ctx.common.contextualErrorMap };
3467
+ const fn = ctx.data;
3468
+ if (this._def.returns instanceof ZodPromise) {
3469
+ const me = this;
3470
+ return (0, parseUtil_js_1.OK)(async function(...args) {
3471
+ const error = new ZodError_js_1.ZodError([]);
3472
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3473
+ error.addIssue(makeArgsIssue(args, e));
3474
+ throw error;
3475
+ });
3476
+ const result = await Reflect.apply(fn, this, parsedArgs);
3477
+ return await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3478
+ error.addIssue(makeReturnsIssue(result, e));
3479
+ throw error;
3480
+ });
3481
+ });
3482
+ } else {
3483
+ const me = this;
3484
+ return (0, parseUtil_js_1.OK)(function(...args) {
3485
+ const parsedArgs = me._def.args.safeParse(args, params);
3486
+ if (!parsedArgs.success) throw new ZodError_js_1.ZodError([makeArgsIssue(args, parsedArgs.error)]);
3487
+ const result = Reflect.apply(fn, this, parsedArgs.data);
3488
+ const parsedReturns = me._def.returns.safeParse(result, params);
3489
+ if (!parsedReturns.success) throw new ZodError_js_1.ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3490
+ return parsedReturns.data;
3491
+ });
3492
+ }
3493
+ }
3494
+ parameters() {
3495
+ return this._def.args;
3496
+ }
3497
+ returnType() {
3498
+ return this._def.returns;
3499
+ }
3500
+ args(...items) {
3501
+ return new ZodFunction({
3502
+ ...this._def,
3503
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
3504
+ });
3505
+ }
3506
+ returns(returnType) {
3507
+ return new ZodFunction({
3508
+ ...this._def,
3509
+ returns: returnType
3510
+ });
3511
+ }
3512
+ implement(func) {
3513
+ return this.parse(func);
3514
+ }
3515
+ strictImplement(func) {
3516
+ return this.parse(func);
3517
+ }
3518
+ static create(args, returns, params) {
3519
+ return new ZodFunction({
3520
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
3521
+ returns: returns || ZodUnknown.create(),
3522
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
3523
+ ...processCreateParams(params)
3524
+ });
3525
+ }
3526
+ };
3527
+ exports.ZodFunction = ZodFunction;
3528
+ var ZodLazy = class extends ZodType {
3529
+ get schema() {
3530
+ return this._def.getter();
3531
+ }
3532
+ _parse(input) {
3533
+ const { ctx } = this._processInputParams(input);
3534
+ return this._def.getter()._parse({
3535
+ data: ctx.data,
3536
+ path: ctx.path,
3537
+ parent: ctx
3538
+ });
3539
+ }
3540
+ };
3541
+ exports.ZodLazy = ZodLazy;
3542
+ ZodLazy.create = (getter, params) => {
3543
+ return new ZodLazy({
3544
+ getter,
3545
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
3546
+ ...processCreateParams(params)
3547
+ });
3548
+ };
3549
+ var ZodLiteral = class extends ZodType {
3550
+ _parse(input) {
3551
+ if (input.data !== this._def.value) {
3552
+ const ctx = this._getOrReturnCtx(input);
3553
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3554
+ received: ctx.data,
3555
+ code: ZodError_js_1.ZodIssueCode.invalid_literal,
3556
+ expected: this._def.value
3557
+ });
3558
+ return parseUtil_js_1.INVALID;
3559
+ }
3560
+ return {
3561
+ status: "valid",
3562
+ value: input.data
3563
+ };
3564
+ }
3565
+ get value() {
3566
+ return this._def.value;
3567
+ }
3568
+ };
3569
+ exports.ZodLiteral = ZodLiteral;
3570
+ ZodLiteral.create = (value, params) => {
3571
+ return new ZodLiteral({
3572
+ value,
3573
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
3574
+ ...processCreateParams(params)
3575
+ });
3576
+ };
3577
+ function createZodEnum(values, params) {
3578
+ return new ZodEnum({
3579
+ values,
3580
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
3581
+ ...processCreateParams(params)
3582
+ });
3583
+ }
3584
+ var ZodEnum = class ZodEnum extends ZodType {
3585
+ _parse(input) {
3586
+ if (typeof input.data !== "string") {
3587
+ const ctx = this._getOrReturnCtx(input);
3588
+ const expectedValues = this._def.values;
3589
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3590
+ expected: util_js_1.util.joinValues(expectedValues),
3591
+ received: ctx.parsedType,
3592
+ code: ZodError_js_1.ZodIssueCode.invalid_type
3593
+ });
3594
+ return parseUtil_js_1.INVALID;
3595
+ }
3596
+ if (!this._cache) this._cache = new Set(this._def.values);
3597
+ if (!this._cache.has(input.data)) {
3598
+ const ctx = this._getOrReturnCtx(input);
3599
+ const expectedValues = this._def.values;
3600
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3601
+ received: ctx.data,
3602
+ code: ZodError_js_1.ZodIssueCode.invalid_enum_value,
3603
+ options: expectedValues
3604
+ });
3605
+ return parseUtil_js_1.INVALID;
3606
+ }
3607
+ return (0, parseUtil_js_1.OK)(input.data);
3608
+ }
3609
+ get options() {
3610
+ return this._def.values;
3611
+ }
3612
+ get enum() {
3613
+ const enumValues = {};
3614
+ for (const val of this._def.values) enumValues[val] = val;
3615
+ return enumValues;
3616
+ }
3617
+ get Values() {
3618
+ const enumValues = {};
3619
+ for (const val of this._def.values) enumValues[val] = val;
3620
+ return enumValues;
3621
+ }
3622
+ get Enum() {
3623
+ const enumValues = {};
3624
+ for (const val of this._def.values) enumValues[val] = val;
3625
+ return enumValues;
3626
+ }
3627
+ extract(values, newDef = this._def) {
3628
+ return ZodEnum.create(values, {
3629
+ ...this._def,
3630
+ ...newDef
3631
+ });
3632
+ }
3633
+ exclude(values, newDef = this._def) {
3634
+ return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3635
+ ...this._def,
3636
+ ...newDef
3637
+ });
3638
+ }
3639
+ };
3640
+ exports.ZodEnum = ZodEnum;
3641
+ ZodEnum.create = createZodEnum;
3642
+ var ZodNativeEnum = class extends ZodType {
3643
+ _parse(input) {
3644
+ const nativeEnumValues = util_js_1.util.getValidEnumValues(this._def.values);
3645
+ const ctx = this._getOrReturnCtx(input);
3646
+ if (ctx.parsedType !== util_js_1.ZodParsedType.string && ctx.parsedType !== util_js_1.ZodParsedType.number) {
3647
+ const expectedValues = util_js_1.util.objectValues(nativeEnumValues);
3648
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3649
+ expected: util_js_1.util.joinValues(expectedValues),
3650
+ received: ctx.parsedType,
3651
+ code: ZodError_js_1.ZodIssueCode.invalid_type
3652
+ });
3653
+ return parseUtil_js_1.INVALID;
3654
+ }
3655
+ if (!this._cache) this._cache = new Set(util_js_1.util.getValidEnumValues(this._def.values));
3656
+ if (!this._cache.has(input.data)) {
3657
+ const expectedValues = util_js_1.util.objectValues(nativeEnumValues);
3658
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3659
+ received: ctx.data,
3660
+ code: ZodError_js_1.ZodIssueCode.invalid_enum_value,
3661
+ options: expectedValues
3662
+ });
3663
+ return parseUtil_js_1.INVALID;
3664
+ }
3665
+ return (0, parseUtil_js_1.OK)(input.data);
3666
+ }
3667
+ get enum() {
3668
+ return this._def.values;
3669
+ }
3670
+ };
3671
+ exports.ZodNativeEnum = ZodNativeEnum;
3672
+ ZodNativeEnum.create = (values, params) => {
3673
+ return new ZodNativeEnum({
3674
+ values,
3675
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3676
+ ...processCreateParams(params)
3677
+ });
3678
+ };
3679
+ var ZodPromise = class extends ZodType {
3680
+ unwrap() {
3681
+ return this._def.type;
3682
+ }
3683
+ _parse(input) {
3684
+ const { ctx } = this._processInputParams(input);
3685
+ if (ctx.parsedType !== util_js_1.ZodParsedType.promise && ctx.common.async === false) {
3686
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3687
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3688
+ expected: util_js_1.ZodParsedType.promise,
3689
+ received: ctx.parsedType
3690
+ });
3691
+ return parseUtil_js_1.INVALID;
3692
+ }
3693
+ const promisified = ctx.parsedType === util_js_1.ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
3694
+ return (0, parseUtil_js_1.OK)(promisified.then((data) => {
3695
+ return this._def.type.parseAsync(data, {
3696
+ path: ctx.path,
3697
+ errorMap: ctx.common.contextualErrorMap
3698
+ });
3699
+ }));
3700
+ }
3701
+ };
3702
+ exports.ZodPromise = ZodPromise;
3703
+ ZodPromise.create = (schema, params) => {
3704
+ return new ZodPromise({
3705
+ type: schema,
3706
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
3707
+ ...processCreateParams(params)
3708
+ });
3709
+ };
3710
+ var ZodEffects = class extends ZodType {
3711
+ innerType() {
3712
+ return this._def.schema;
3713
+ }
3714
+ sourceType() {
3715
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3716
+ }
3717
+ _parse(input) {
3718
+ const { status, ctx } = this._processInputParams(input);
3719
+ const effect = this._def.effect || null;
3720
+ const checkCtx = {
3721
+ addIssue: (arg) => {
3722
+ (0, parseUtil_js_1.addIssueToContext)(ctx, arg);
3723
+ if (arg.fatal) status.abort();
3724
+ else status.dirty();
3725
+ },
3726
+ get path() {
3727
+ return ctx.path;
3728
+ }
3729
+ };
3730
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3731
+ if (effect.type === "preprocess") {
3732
+ const processed = effect.transform(ctx.data, checkCtx);
3733
+ if (ctx.common.async) return Promise.resolve(processed).then(async (processed) => {
3734
+ if (status.value === "aborted") return parseUtil_js_1.INVALID;
3735
+ const result = await this._def.schema._parseAsync({
3736
+ data: processed,
3737
+ path: ctx.path,
3738
+ parent: ctx
3739
+ });
3740
+ if (result.status === "aborted") return parseUtil_js_1.INVALID;
3741
+ if (result.status === "dirty") return (0, parseUtil_js_1.DIRTY)(result.value);
3742
+ if (status.value === "dirty") return (0, parseUtil_js_1.DIRTY)(result.value);
3743
+ return result;
3744
+ });
3745
+ else {
3746
+ if (status.value === "aborted") return parseUtil_js_1.INVALID;
3747
+ const result = this._def.schema._parseSync({
3748
+ data: processed,
3749
+ path: ctx.path,
3750
+ parent: ctx
3751
+ });
3752
+ if (result.status === "aborted") return parseUtil_js_1.INVALID;
3753
+ if (result.status === "dirty") return (0, parseUtil_js_1.DIRTY)(result.value);
3754
+ if (status.value === "dirty") return (0, parseUtil_js_1.DIRTY)(result.value);
3755
+ return result;
3756
+ }
3757
+ }
3758
+ if (effect.type === "refinement") {
3759
+ const executeRefinement = (acc) => {
3760
+ const result = effect.refinement(acc, checkCtx);
3761
+ if (ctx.common.async) return Promise.resolve(result);
3762
+ if (result instanceof Promise) throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3763
+ return acc;
3764
+ };
3765
+ if (ctx.common.async === false) {
3766
+ const inner = this._def.schema._parseSync({
3767
+ data: ctx.data,
3768
+ path: ctx.path,
3769
+ parent: ctx
3770
+ });
3771
+ if (inner.status === "aborted") return parseUtil_js_1.INVALID;
3772
+ if (inner.status === "dirty") status.dirty();
3773
+ executeRefinement(inner.value);
3774
+ return {
3775
+ status: status.value,
3776
+ value: inner.value
3777
+ };
3778
+ } else return this._def.schema._parseAsync({
3779
+ data: ctx.data,
3780
+ path: ctx.path,
3781
+ parent: ctx
3782
+ }).then((inner) => {
3783
+ if (inner.status === "aborted") return parseUtil_js_1.INVALID;
3784
+ if (inner.status === "dirty") status.dirty();
3785
+ return executeRefinement(inner.value).then(() => {
3786
+ return {
3787
+ status: status.value,
3788
+ value: inner.value
3789
+ };
3790
+ });
3791
+ });
3792
+ }
3793
+ if (effect.type === "transform") {
3794
+ if (ctx.common.async === false) {
3795
+ const base = this._def.schema._parseSync({
3796
+ data: ctx.data,
3797
+ path: ctx.path,
3798
+ parent: ctx
3799
+ });
3800
+ if (!(0, parseUtil_js_1.isValid)(base)) return parseUtil_js_1.INVALID;
3801
+ const result = effect.transform(base.value, checkCtx);
3802
+ if (result instanceof Promise) throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3803
+ return {
3804
+ status: status.value,
3805
+ value: result
3806
+ };
3807
+ } else return this._def.schema._parseAsync({
3808
+ data: ctx.data,
3809
+ path: ctx.path,
3810
+ parent: ctx
3811
+ }).then((base) => {
3812
+ if (!(0, parseUtil_js_1.isValid)(base)) return parseUtil_js_1.INVALID;
3813
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
3814
+ status: status.value,
3815
+ value: result
3816
+ }));
3817
+ });
3818
+ }
3819
+ util_js_1.util.assertNever(effect);
3820
+ }
3821
+ };
3822
+ exports.ZodEffects = ZodEffects;
3823
+ exports.ZodTransformer = ZodEffects;
3824
+ ZodEffects.create = (schema, effect, params) => {
3825
+ return new ZodEffects({
3826
+ schema,
3827
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3828
+ effect,
3829
+ ...processCreateParams(params)
3830
+ });
3831
+ };
3832
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3833
+ return new ZodEffects({
3834
+ schema,
3835
+ effect: {
3836
+ type: "preprocess",
3837
+ transform: preprocess
3838
+ },
3839
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3840
+ ...processCreateParams(params)
3841
+ });
3842
+ };
3843
+ var ZodOptional = class extends ZodType {
3844
+ _parse(input) {
3845
+ if (this._getType(input) === util_js_1.ZodParsedType.undefined) return (0, parseUtil_js_1.OK)(void 0);
3846
+ return this._def.innerType._parse(input);
3847
+ }
3848
+ unwrap() {
3849
+ return this._def.innerType;
3850
+ }
3851
+ };
3852
+ exports.ZodOptional = ZodOptional;
3853
+ ZodOptional.create = (type, params) => {
3854
+ return new ZodOptional({
3855
+ innerType: type,
3856
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
3857
+ ...processCreateParams(params)
3858
+ });
3859
+ };
3860
+ var ZodNullable = class extends ZodType {
3861
+ _parse(input) {
3862
+ if (this._getType(input) === util_js_1.ZodParsedType.null) return (0, parseUtil_js_1.OK)(null);
3863
+ return this._def.innerType._parse(input);
3864
+ }
3865
+ unwrap() {
3866
+ return this._def.innerType;
3867
+ }
3868
+ };
3869
+ exports.ZodNullable = ZodNullable;
3870
+ ZodNullable.create = (type, params) => {
3871
+ return new ZodNullable({
3872
+ innerType: type,
3873
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
3874
+ ...processCreateParams(params)
3875
+ });
3876
+ };
3877
+ var ZodDefault = class extends ZodType {
3878
+ _parse(input) {
3879
+ const { ctx } = this._processInputParams(input);
3880
+ let data = ctx.data;
3881
+ if (ctx.parsedType === util_js_1.ZodParsedType.undefined) data = this._def.defaultValue();
3882
+ return this._def.innerType._parse({
3883
+ data,
3884
+ path: ctx.path,
3885
+ parent: ctx
3886
+ });
3887
+ }
3888
+ removeDefault() {
3889
+ return this._def.innerType;
3890
+ }
3891
+ };
3892
+ exports.ZodDefault = ZodDefault;
3893
+ ZodDefault.create = (type, params) => {
3894
+ return new ZodDefault({
3895
+ innerType: type,
3896
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
3897
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
3898
+ ...processCreateParams(params)
3899
+ });
3900
+ };
3901
+ var ZodCatch = class extends ZodType {
3902
+ _parse(input) {
3903
+ const { ctx } = this._processInputParams(input);
3904
+ const newCtx = {
3905
+ ...ctx,
3906
+ common: {
3907
+ ...ctx.common,
3908
+ issues: []
3909
+ }
3910
+ };
3911
+ const result = this._def.innerType._parse({
3912
+ data: newCtx.data,
3913
+ path: newCtx.path,
3914
+ parent: { ...newCtx }
3915
+ });
3916
+ if ((0, parseUtil_js_1.isAsync)(result)) return result.then((result) => {
3917
+ return {
3918
+ status: "valid",
3919
+ value: result.status === "valid" ? result.value : this._def.catchValue({
3920
+ get error() {
3921
+ return new ZodError_js_1.ZodError(newCtx.common.issues);
3922
+ },
3923
+ input: newCtx.data
3924
+ })
3925
+ };
3926
+ });
3927
+ else return {
3928
+ status: "valid",
3929
+ value: result.status === "valid" ? result.value : this._def.catchValue({
3930
+ get error() {
3931
+ return new ZodError_js_1.ZodError(newCtx.common.issues);
3932
+ },
3933
+ input: newCtx.data
3934
+ })
3935
+ };
3936
+ }
3937
+ removeCatch() {
3938
+ return this._def.innerType;
3939
+ }
3940
+ };
3941
+ exports.ZodCatch = ZodCatch;
3942
+ ZodCatch.create = (type, params) => {
3943
+ return new ZodCatch({
3944
+ innerType: type,
3945
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
3946
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3947
+ ...processCreateParams(params)
3948
+ });
3949
+ };
3950
+ var ZodNaN = class extends ZodType {
3951
+ _parse(input) {
3952
+ if (this._getType(input) !== util_js_1.ZodParsedType.nan) {
3953
+ const ctx = this._getOrReturnCtx(input);
3954
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3955
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3956
+ expected: util_js_1.ZodParsedType.nan,
3957
+ received: ctx.parsedType
3958
+ });
3959
+ return parseUtil_js_1.INVALID;
3960
+ }
3961
+ return {
3962
+ status: "valid",
3963
+ value: input.data
3964
+ };
3965
+ }
3966
+ };
3967
+ exports.ZodNaN = ZodNaN;
3968
+ ZodNaN.create = (params) => {
3969
+ return new ZodNaN({
3970
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
3971
+ ...processCreateParams(params)
3972
+ });
3973
+ };
3974
+ exports.BRAND = Symbol("zod_brand");
3975
+ var ZodBranded = class extends ZodType {
3976
+ _parse(input) {
3977
+ const { ctx } = this._processInputParams(input);
3978
+ const data = ctx.data;
3979
+ return this._def.type._parse({
3980
+ data,
3981
+ path: ctx.path,
3982
+ parent: ctx
3983
+ });
3984
+ }
3985
+ unwrap() {
3986
+ return this._def.type;
3987
+ }
3988
+ };
3989
+ exports.ZodBranded = ZodBranded;
3990
+ var ZodPipeline = class ZodPipeline extends ZodType {
3991
+ _parse(input) {
3992
+ const { status, ctx } = this._processInputParams(input);
3993
+ if (ctx.common.async) {
3994
+ const handleAsync = async () => {
3995
+ const inResult = await this._def.in._parseAsync({
3996
+ data: ctx.data,
3997
+ path: ctx.path,
3998
+ parent: ctx
3999
+ });
4000
+ if (inResult.status === "aborted") return parseUtil_js_1.INVALID;
4001
+ if (inResult.status === "dirty") {
4002
+ status.dirty();
4003
+ return (0, parseUtil_js_1.DIRTY)(inResult.value);
4004
+ } else return this._def.out._parseAsync({
4005
+ data: inResult.value,
4006
+ path: ctx.path,
4007
+ parent: ctx
4008
+ });
4009
+ };
4010
+ return handleAsync();
4011
+ } else {
4012
+ const inResult = this._def.in._parseSync({
4013
+ data: ctx.data,
4014
+ path: ctx.path,
4015
+ parent: ctx
4016
+ });
4017
+ if (inResult.status === "aborted") return parseUtil_js_1.INVALID;
4018
+ if (inResult.status === "dirty") {
4019
+ status.dirty();
4020
+ return {
4021
+ status: "dirty",
4022
+ value: inResult.value
4023
+ };
4024
+ } else return this._def.out._parseSync({
4025
+ data: inResult.value,
4026
+ path: ctx.path,
4027
+ parent: ctx
4028
+ });
4029
+ }
4030
+ }
4031
+ static create(a, b) {
4032
+ return new ZodPipeline({
4033
+ in: a,
4034
+ out: b,
4035
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
4036
+ });
4037
+ }
4038
+ };
4039
+ exports.ZodPipeline = ZodPipeline;
4040
+ var ZodReadonly = class extends ZodType {
4041
+ _parse(input) {
4042
+ const result = this._def.innerType._parse(input);
4043
+ const freeze = (data) => {
4044
+ if ((0, parseUtil_js_1.isValid)(data)) data.value = Object.freeze(data.value);
4045
+ return data;
4046
+ };
4047
+ return (0, parseUtil_js_1.isAsync)(result) ? result.then((data) => freeze(data)) : freeze(result);
4048
+ }
4049
+ unwrap() {
4050
+ return this._def.innerType;
4051
+ }
4052
+ };
4053
+ exports.ZodReadonly = ZodReadonly;
4054
+ ZodReadonly.create = (type, params) => {
4055
+ return new ZodReadonly({
4056
+ innerType: type,
4057
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
4058
+ ...processCreateParams(params)
4059
+ });
4060
+ };
4061
+ function cleanParams(params, data) {
4062
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
4063
+ return typeof p === "string" ? { message: p } : p;
4064
+ }
4065
+ function custom(check, _params = {}, fatal) {
4066
+ if (check) return ZodAny.create().superRefine((data, ctx) => {
4067
+ const r = check(data);
4068
+ if (r instanceof Promise) return r.then((r) => {
4069
+ if (!r) {
4070
+ const params = cleanParams(_params, data);
4071
+ const _fatal = params.fatal ?? fatal ?? true;
4072
+ ctx.addIssue({
4073
+ code: "custom",
4074
+ ...params,
4075
+ fatal: _fatal
4076
+ });
4077
+ }
4078
+ });
4079
+ if (!r) {
4080
+ const params = cleanParams(_params, data);
4081
+ const _fatal = params.fatal ?? fatal ?? true;
4082
+ ctx.addIssue({
4083
+ code: "custom",
4084
+ ...params,
4085
+ fatal: _fatal
4086
+ });
4087
+ }
4088
+ });
4089
+ return ZodAny.create();
4090
+ }
4091
+ exports.late = { object: ZodObject.lazycreate };
4092
+ var ZodFirstPartyTypeKind;
4093
+ (function(ZodFirstPartyTypeKind) {
4094
+ ZodFirstPartyTypeKind["ZodString"] = "ZodString";
4095
+ ZodFirstPartyTypeKind["ZodNumber"] = "ZodNumber";
4096
+ ZodFirstPartyTypeKind["ZodNaN"] = "ZodNaN";
4097
+ ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
4098
+ ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
4099
+ ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
4100
+ ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
4101
+ ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
4102
+ ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
4103
+ ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
4104
+ ZodFirstPartyTypeKind["ZodUnknown"] = "ZodUnknown";
4105
+ ZodFirstPartyTypeKind["ZodNever"] = "ZodNever";
4106
+ ZodFirstPartyTypeKind["ZodVoid"] = "ZodVoid";
4107
+ ZodFirstPartyTypeKind["ZodArray"] = "ZodArray";
4108
+ ZodFirstPartyTypeKind["ZodObject"] = "ZodObject";
4109
+ ZodFirstPartyTypeKind["ZodUnion"] = "ZodUnion";
4110
+ ZodFirstPartyTypeKind["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
4111
+ ZodFirstPartyTypeKind["ZodIntersection"] = "ZodIntersection";
4112
+ ZodFirstPartyTypeKind["ZodTuple"] = "ZodTuple";
4113
+ ZodFirstPartyTypeKind["ZodRecord"] = "ZodRecord";
4114
+ ZodFirstPartyTypeKind["ZodMap"] = "ZodMap";
4115
+ ZodFirstPartyTypeKind["ZodSet"] = "ZodSet";
4116
+ ZodFirstPartyTypeKind["ZodFunction"] = "ZodFunction";
4117
+ ZodFirstPartyTypeKind["ZodLazy"] = "ZodLazy";
4118
+ ZodFirstPartyTypeKind["ZodLiteral"] = "ZodLiteral";
4119
+ ZodFirstPartyTypeKind["ZodEnum"] = "ZodEnum";
4120
+ ZodFirstPartyTypeKind["ZodEffects"] = "ZodEffects";
4121
+ ZodFirstPartyTypeKind["ZodNativeEnum"] = "ZodNativeEnum";
4122
+ ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
4123
+ ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
4124
+ ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
4125
+ ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
4126
+ ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
4127
+ ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
4128
+ ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
4129
+ ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
4130
+ })(ZodFirstPartyTypeKind || (exports.ZodFirstPartyTypeKind = ZodFirstPartyTypeKind = {}));
4131
+ const instanceOfType = (cls, params = { message: `Input not instance of ${cls.name}` }) => custom((data) => data instanceof cls, params);
4132
+ exports.instanceof = instanceOfType;
4133
+ const stringType = ZodString.create;
4134
+ exports.string = stringType;
4135
+ const numberType = ZodNumber.create;
4136
+ exports.number = numberType;
4137
+ exports.nan = ZodNaN.create;
4138
+ exports.bigint = ZodBigInt.create;
4139
+ const booleanType = ZodBoolean.create;
4140
+ exports.boolean = booleanType;
4141
+ exports.date = ZodDate.create;
4142
+ exports.symbol = ZodSymbol.create;
4143
+ exports.undefined = ZodUndefined.create;
4144
+ exports.null = ZodNull.create;
4145
+ exports.any = ZodAny.create;
4146
+ exports.unknown = ZodUnknown.create;
4147
+ exports.never = ZodNever.create;
4148
+ exports.void = ZodVoid.create;
4149
+ exports.array = ZodArray.create;
4150
+ exports.object = ZodObject.create;
4151
+ exports.strictObject = ZodObject.strictCreate;
4152
+ exports.union = ZodUnion.create;
4153
+ exports.discriminatedUnion = ZodDiscriminatedUnion.create;
4154
+ exports.intersection = ZodIntersection.create;
4155
+ exports.tuple = ZodTuple.create;
4156
+ exports.record = ZodRecord.create;
4157
+ exports.map = ZodMap.create;
4158
+ exports.set = ZodSet.create;
4159
+ exports.function = ZodFunction.create;
4160
+ exports.lazy = ZodLazy.create;
4161
+ exports.literal = ZodLiteral.create;
4162
+ exports.enum = ZodEnum.create;
4163
+ exports.nativeEnum = ZodNativeEnum.create;
4164
+ exports.promise = ZodPromise.create;
4165
+ const effectsType = ZodEffects.create;
4166
+ exports.effect = effectsType;
4167
+ exports.transformer = effectsType;
4168
+ exports.optional = ZodOptional.create;
4169
+ exports.nullable = ZodNullable.create;
4170
+ exports.preprocess = ZodEffects.createWithPreprocess;
4171
+ exports.pipeline = ZodPipeline.create;
4172
+ const ostring = () => stringType().optional();
4173
+ exports.ostring = ostring;
4174
+ const onumber = () => numberType().optional();
4175
+ exports.onumber = onumber;
4176
+ const oboolean = () => booleanType().optional();
4177
+ exports.oboolean = oboolean;
4178
+ exports.coerce = {
4179
+ string: ((arg) => ZodString.create({
4180
+ ...arg,
4181
+ coerce: true
4182
+ })),
4183
+ number: ((arg) => ZodNumber.create({
4184
+ ...arg,
4185
+ coerce: true
4186
+ })),
4187
+ boolean: ((arg) => ZodBoolean.create({
4188
+ ...arg,
4189
+ coerce: true
4190
+ })),
4191
+ bigint: ((arg) => ZodBigInt.create({
4192
+ ...arg,
4193
+ coerce: true
4194
+ })),
4195
+ date: ((arg) => ZodDate.create({
4196
+ ...arg,
4197
+ coerce: true
4198
+ }))
4199
+ };
4200
+ exports.NEVER = parseUtil_js_1.INVALID;
4201
+ }));
4202
+ //#endregion
4203
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.cjs
4204
+ var require_external = /* @__PURE__ */ __commonJSMin(((exports) => {
4205
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
4206
+ if (k2 === void 0) k2 = k;
4207
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4208
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
4209
+ enumerable: true,
4210
+ get: function() {
4211
+ return m[k];
4212
+ }
4213
+ };
4214
+ Object.defineProperty(o, k2, desc);
4215
+ }) : (function(o, m, k, k2) {
4216
+ if (k2 === void 0) k2 = k;
4217
+ o[k2] = m[k];
4218
+ }));
4219
+ var __exportStar = exports && exports.__exportStar || function(m, exports$2) {
4220
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$2, p)) __createBinding(exports$2, m, p);
4221
+ };
4222
+ Object.defineProperty(exports, "__esModule", { value: true });
4223
+ __exportStar(require_errors(), exports);
4224
+ __exportStar(require_parseUtil(), exports);
4225
+ __exportStar(require_typeAliases(), exports);
4226
+ __exportStar(require_util(), exports);
4227
+ __exportStar(require_types(), exports);
4228
+ __exportStar(require_ZodError(), exports);
4229
+ }));
4230
+ //#endregion
4231
+ //#region src/room/schema.ts
4232
+ var import_zod = (/* @__PURE__ */ __commonJSMin(((exports) => {
4233
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
4234
+ if (k2 === void 0) k2 = k;
4235
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4236
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
4237
+ enumerable: true,
4238
+ get: function() {
4239
+ return m[k];
4240
+ }
4241
+ };
4242
+ Object.defineProperty(o, k2, desc);
4243
+ }) : (function(o, m, k, k2) {
4244
+ if (k2 === void 0) k2 = k;
4245
+ o[k2] = m[k];
4246
+ }));
4247
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
4248
+ Object.defineProperty(o, "default", {
4249
+ enumerable: true,
4250
+ value: v
4251
+ });
4252
+ }) : function(o, v) {
4253
+ o["default"] = v;
4254
+ });
4255
+ var __importStar = exports && exports.__importStar || function(mod) {
4256
+ if (mod && mod.__esModule) return mod;
4257
+ var result = {};
4258
+ if (mod != null) {
4259
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
4260
+ }
4261
+ __setModuleDefault(result, mod);
4262
+ return result;
4263
+ };
4264
+ var __exportStar = exports && exports.__exportStar || function(m, exports$1) {
4265
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
4266
+ };
4267
+ Object.defineProperty(exports, "__esModule", { value: true });
4268
+ exports.z = void 0;
4269
+ const z = __importStar(require_external());
4270
+ exports.z = z;
4271
+ __exportStar(require_external(), exports);
4272
+ exports.default = z;
4273
+ })))();
4274
+ /** One member slot of a room: an independent session registered into the team. */
4275
+ const roomMemberSchema = import_zod.z.object({
4276
+ /** Durable member session id (each member is its own session). */
4277
+ sessionId: import_zod.z.string().min(1),
4278
+ /** `owner` created the room; `member` joined it. */
4279
+ role: import_zod.z.enum(["owner", "member"]),
4280
+ /** Epoch ms of registration. */
4281
+ joinedAt: import_zod.z.number().int().nonnegative(),
4282
+ /**
4283
+ * Bus seq up to which this member's session log has received the
4284
+ * model-visible delivery (0 = none yet). The offline outbox cursor.
4285
+ */
4286
+ lastDeliveredSeq: import_zod.z.number().int().nonnegative(),
4287
+ /**
4288
+ * Timeline seq up to which this member's session log carries the log-only
4289
+ * facts (-1 = none yet). The offline fact-replay cursor.
4290
+ */
4291
+ lastFactSeq: import_zod.z.number().int().min(-1)
4292
+ }).strict();
4293
+ import_zod.z.object({
4294
+ roomId: import_zod.z.string().min(1),
4295
+ name: import_zod.z.string().min(1),
4296
+ createdAt: import_zod.z.number().int().nonnegative(),
4297
+ /** Registration-order member list (each member is an independent session). */
4298
+ members: import_zod.z.array(roomMemberSchema),
4299
+ /** Next bus seq to mint (monotonic per room; the ordering authority). */
4300
+ busNext: import_zod.z.number().int().nonnegative(),
4301
+ /** Next timeline seq to mint. */
4302
+ timelineNext: import_zod.z.number().int().nonnegative()
4303
+ }).strict();
4304
+ import_zod.z.object({
4305
+ roomId: import_zod.z.string().min(1),
4306
+ /** Monotonic per-room seq: the bus order every reader agrees on. */
4307
+ seq: import_zod.z.number().int().nonnegative(),
4308
+ senderSessionId: import_zod.z.string().min(1),
4309
+ /** Directed delivery target; absent = broadcast to every member. */
4310
+ toSessionId: import_zod.z.string().min(1).optional(),
4311
+ text: import_zod.z.string(),
4312
+ createdAt: import_zod.z.number().int().nonnegative()
4313
+ }).strict();
4314
+ import_zod.z.object({
4315
+ roomId: import_zod.z.string().min(1),
4316
+ taskId: import_zod.z.string().min(1),
4317
+ title: import_zod.z.string().min(1),
4318
+ description: import_zod.z.string(),
4319
+ status: import_zod.z.enum([
4320
+ "todo",
4321
+ "in-progress",
4322
+ "done"
4323
+ ]),
4324
+ /** Assignee member session id; null = unassigned. */
4325
+ assigneeSessionId: import_zod.z.string().nullable(),
4326
+ createdBy: import_zod.z.string().min(1),
4327
+ createdAt: import_zod.z.number().int().nonnegative(),
4328
+ updatedAt: import_zod.z.number().int().nonnegative(),
4329
+ completedAt: import_zod.z.number().int().nonnegative().optional()
4330
+ }).strict();
4331
+ /** Timeline kinds the room appends; the shared event stream. */
4332
+ const timelineKindSchema = import_zod.z.enum([
4333
+ "room-created",
4334
+ "member-joined",
4335
+ "member-left",
4336
+ "message-posted",
4337
+ "message-directed",
4338
+ "task-created",
4339
+ "task-claimed",
4340
+ "task-assigned",
4341
+ "task-completed"
4342
+ ]);
4343
+ /** One shared timeline event (append-only per room). */
4344
+ const timelineEventSchema = import_zod.z.object({
4345
+ roomId: import_zod.z.string().min(1),
4346
+ /** Monotonic per-room seq; the timeline order. */
4347
+ seq: import_zod.z.number().int().nonnegative(),
4348
+ kind: timelineKindSchema,
4349
+ at: import_zod.z.number().int().nonnegative(),
4350
+ /** Kind-specific payload; plain lossless JSON. */
4351
+ data: import_zod.z.record(import_zod.z.unknown())
4352
+ }).strict();
4353
+ /** One member row as the fold serves it. */
4354
+ const roomViewMemberSchema = import_zod.z.object({
4355
+ sessionId: import_zod.z.string().min(1),
4356
+ role: import_zod.z.enum(["owner", "member"]),
4357
+ joinedAt: import_zod.z.number().int().nonnegative()
4358
+ }).strict();
4359
+ /** One task row as the fold serves it. */
4360
+ const roomViewTaskSchema = import_zod.z.object({
4361
+ taskId: import_zod.z.string().min(1),
4362
+ title: import_zod.z.string(),
4363
+ description: import_zod.z.string(),
4364
+ status: import_zod.z.enum([
4365
+ "todo",
4366
+ "in-progress",
4367
+ "done"
4368
+ ]),
4369
+ assigneeSessionId: import_zod.z.string().nullable(),
4370
+ createdBy: import_zod.z.string(),
4371
+ createdAt: import_zod.z.number().int().nonnegative(),
4372
+ updatedAt: import_zod.z.number().int().nonnegative()
4373
+ }).strict();
4374
+ /** One room as the fold serves it. */
4375
+ const roomViewSchema = import_zod.z.object({
4376
+ roomId: import_zod.z.string().min(1),
4377
+ name: import_zod.z.string(),
4378
+ createdAt: import_zod.z.number().int().nonnegative(),
4379
+ members: import_zod.z.array(roomViewMemberSchema),
4380
+ tasks: import_zod.z.array(roomViewTaskSchema),
4381
+ timeline: import_zod.z.array(timelineEventSchema)
4382
+ }).strict();
4383
+ /** The whole `teamRoom` projection value: every room this session belongs to. */
4384
+ const teamRoomViewSchema = import_zod.z.object({ rooms: import_zod.z.array(roomViewSchema) }).strict();
4385
+ /**
4386
+ * Runtime-guard an opaque projection cell as the `teamRoom` value (the client
4387
+ * reads projection cells as unknown because it cannot merge the host's
4388
+ * `SessionProjectionMap`).
4389
+ * @param value - the opaque cell value.
4390
+ * @returns the typed view, or undefined when the cell is absent or invalid.
4391
+ */
4392
+ function isTeamRoomView(value) {
4393
+ const parsed = teamRoomViewSchema.safeParse(value);
4394
+ return parsed.success ? parsed.data : void 0;
4395
+ }
4396
+ //#endregion
4397
+ //#region src/client/room-presenter.ts
4398
+ /**
4399
+ * Pure presentation of the team-room settings panel: derives the display
4400
+ * state from the `teamRoom` projection value plus the session-list snapshot
4401
+ * (the live overlay for member status). No I/O, clock, or randomness — the
4402
+ * component stays a thin binder and the rows stay testable.
4403
+ *
4404
+ * @module dsh-team-rooms/room-presenter
4405
+ */
4406
+ /** Empty ready state (no session open). */
4407
+ function emptyTeamRoomsState() {
4408
+ return {
4409
+ status: "ready",
4410
+ rooms: []
4411
+ };
4412
+ }
4413
+ /**
4414
+ * Derive the room panels from one projection value and the session list.
4415
+ * @param value - the opaque `teamRoom` projection cell.
4416
+ * @param list - the session-list snapshot (live overlay source).
4417
+ * @returns the panels, or undefined when the cell is absent or invalid.
4418
+ */
4419
+ function buildRoomPanels(value, list) {
4420
+ const view = isTeamRoomView(value);
4421
+ if (view === void 0) return void 0;
4422
+ return view.rooms.map((room) => panelOf(room, list));
4423
+ }
4424
+ /** One room view plus the live overlay, sorted for display. */
4425
+ function panelOf(room, list) {
4426
+ const members = room.members.map((member) => {
4427
+ const live = list.byId[member.sessionId];
4428
+ return {
4429
+ sessionId: member.sessionId,
4430
+ role: member.role,
4431
+ joinedAt: member.joinedAt,
4432
+ live: live !== void 0,
4433
+ ...live?.displayTitle === void 0 ? {} : { title: live.displayTitle }
4434
+ };
4435
+ }).sort((a, b) => a.joinedAt - b.joinedAt);
4436
+ const tasks = [...room.tasks].map((task) => ({
4437
+ taskId: task.taskId,
4438
+ title: task.title,
4439
+ description: task.description,
4440
+ status: task.status,
4441
+ assigneeSessionId: task.assigneeSessionId,
4442
+ createdBy: task.createdBy
4443
+ })).sort((a, b) => {
4444
+ const rank = (status) => status === "todo" ? 0 : status === "in-progress" ? 1 : 2;
4445
+ return rank(a.status) - rank(b.status) || (a.status === b.status ? a.taskId.localeCompare(b.taskId) : 0);
4446
+ });
4447
+ const timeline = [...room.timeline].sort((a, b) => b.seq - a.seq).slice(0, 100).map((event) => ({
4448
+ seq: event.seq,
4449
+ kind: event.kind,
4450
+ data: event.data
4451
+ }));
4452
+ return {
4453
+ roomId: room.roomId,
4454
+ name: room.name,
4455
+ createdAt: room.createdAt,
4456
+ members,
4457
+ tasks,
4458
+ timeline
4459
+ };
4460
+ }
4461
+ //#endregion
4462
+ //#region src/client/room-locales.ts
4463
+ /** `teamRooms` namespace dictionaries (the settings page panel copy). */
4464
+ /** Dictionary namespace owned by the room panel. */
4465
+ const ROOM_NS = "teamRooms";
4466
+ /** Simplified Chinese dictionary (the key-set source of truth). */
4467
+ const zh = {
4468
+ nav: "团队房间",
4469
+ title: "团队房间",
4470
+ intro: "跨会话的持久多 agent 协作:成员注册、消息总线、共享任务板与时间线。状态存在本地存储层(SQLite/JSONL),DSH 重启后自动恢复。",
4471
+ noSession: "暂无活动会话。打开一个会话后再管理团队房间。",
4472
+ empty: "本会话尚未加入任何团队房间。创建一个房间,或粘贴其它会话分享的房间 id 加入。",
4473
+ create: "创建房间",
4474
+ createPlaceholder: "房间名称…",
4475
+ createAction: "创建",
4476
+ join: "加入房间",
4477
+ joinPlaceholder: "房间 id…",
4478
+ joinAction: "加入",
4479
+ roomId: "房间 id",
4480
+ copy: "复制",
4481
+ copied: "已复制",
4482
+ members: "成员",
4483
+ owner: "房主",
4484
+ member: "成员",
4485
+ live: "在线",
4486
+ offline: "离线",
4487
+ tasks: "任务板",
4488
+ tasksEmpty: "暂无任务 —— 用 /room task add 或 room_create_task 添加。",
4489
+ taskAddPlaceholder: "新任务标题…",
4490
+ taskAdd: "添加",
4491
+ claim: "认领",
4492
+ assign: "交接",
4493
+ assignTo: "成员 id 或 me",
4494
+ assignAction: "确定",
4495
+ done: "完成",
4496
+ unassigned: "未分配",
4497
+ statusTodo: "待办",
4498
+ statusInProgress: "进行中",
4499
+ statusDone: "完成",
4500
+ timeline: "时间线",
4501
+ timelineEmpty: "暂无事件。",
4502
+ timelineMessage: "{sender} 广播:{text}",
4503
+ timelineDirected: "{sender} → {to}:{text}",
4504
+ timelineMemberJoined: "{member} 加入了房间",
4505
+ timelineMemberLeft: "{member} 离开了房间",
4506
+ timelineTaskCreated: "创建任务「{title}」",
4507
+ timelineTaskClaimed: "{member} 认领了任务",
4508
+ timelineTaskAssigned: "任务交接给 {member}",
4509
+ timelineTaskCompleted: "任务完成",
4510
+ timelineRoomCreated: "{member} 创建了房间",
4511
+ timelineUnknown: "事件 #{seq}",
4512
+ message: "发消息",
4513
+ messagePlaceholder: "广播给所有成员…",
4514
+ send: "发送",
4515
+ error: "操作失败",
4516
+ busy: "处理中…",
4517
+ leave: "离开房间"
4518
+ };
4519
+ /** English dictionary, key-identical to the Chinese source of truth. */
4520
+ const en = {
4521
+ nav: "Team Rooms",
4522
+ title: "Team Rooms",
4523
+ intro: "Persistent cross-session multi-agent collaboration: member registration, a message bus, a shared task board, and a shared timeline. State lives in the local storage layer (SQLite/JSONL) and recovers after DSH restarts.",
4524
+ noSession: "No active session. Open a conversation before managing team rooms.",
4525
+ empty: "This session is not a member of any team room. Create one, or paste a room id another session shared with you.",
4526
+ create: "Create a room",
4527
+ createPlaceholder: "Room name…",
4528
+ createAction: "Create",
4529
+ join: "Join a room",
4530
+ joinPlaceholder: "Room id…",
4531
+ joinAction: "Join",
4532
+ roomId: "Room id",
4533
+ copy: "Copy",
4534
+ copied: "Copied",
4535
+ members: "Members",
4536
+ owner: "owner",
4537
+ member: "member",
4538
+ live: "live",
4539
+ offline: "offline",
4540
+ tasks: "Task board",
4541
+ tasksEmpty: "No tasks — add one with /room task add or room_create_task.",
4542
+ taskAddPlaceholder: "New task title…",
4543
+ taskAdd: "Add",
4544
+ claim: "Claim",
4545
+ assign: "Hand off",
4546
+ assignTo: "member id or me",
4547
+ assignAction: "Confirm",
4548
+ done: "Done",
4549
+ unassigned: "unassigned",
4550
+ statusTodo: "todo",
4551
+ statusInProgress: "in-progress",
4552
+ statusDone: "done",
4553
+ timeline: "Timeline",
4554
+ timelineEmpty: "No events yet.",
4555
+ timelineMessage: "{sender} broadcast: {text}",
4556
+ timelineDirected: "{sender} → {to}: {text}",
4557
+ timelineMemberJoined: "{member} joined the room",
4558
+ timelineMemberLeft: "{member} left the room",
4559
+ timelineTaskCreated: "created task “{title}”",
4560
+ timelineTaskClaimed: "{member} claimed a task",
4561
+ timelineTaskAssigned: "task handed to {member}",
4562
+ timelineTaskCompleted: "task completed",
4563
+ timelineRoomCreated: "{member} created the room",
4564
+ timelineUnknown: "event #{seq}",
4565
+ message: "Message",
4566
+ messagePlaceholder: "Broadcast to every member…",
4567
+ send: "Send",
4568
+ error: "Operation failed",
4569
+ busy: "Working…",
4570
+ leave: "Leave room"
4571
+ };
4572
+ //#endregion
4573
+ //#region src/client/index.ts
4574
+ /**
4575
+ * Required services: sessions (list + bindings), slots, locale, the wire
4576
+ * client, and the remote command executor (`remote.commands`, which carries
4577
+ * every `/room` line this page issues). `connection` is deliberately absent —
4578
+ * the room page never calls a remote namespace directly.
4579
+ */
4580
+ const inject = [
4581
+ "sessions",
4582
+ "slots",
4583
+ "locale",
4584
+ "remote",
4585
+ "remote.commands"
4586
+ ];
4587
+ /**
4588
+ * Live team-room controller: derives the settings-panel state from the
4589
+ * current session's `teamRoom` projection (via the binding's `faceOf`
4590
+ * observable) overlaid with the session-list live bits. Re-subscribes when
4591
+ * the current session changes.
4592
+ */
4593
+ var TeamRoomsController = class {
4594
+ sessions;
4595
+ state = emptyTeamRoomsState();
4596
+ listeners = /* @__PURE__ */ new Set();
4597
+ stopList;
4598
+ stopFace;
4599
+ boundSessionId;
4600
+ constructor(sessions) {
4601
+ this.sessions = sessions;
4602
+ }
4603
+ getSnapshot() {
4604
+ return this.state;
4605
+ }
4606
+ subscribe(listener) {
4607
+ this.listeners.add(listener);
4608
+ return () => {
4609
+ this.listeners.delete(listener);
4610
+ };
4611
+ }
4612
+ /** Attach the subscriptions; returns the disposer (owned by the caller's effect). */
4613
+ start() {
4614
+ this.stopList = this.sessions.list.subscribe(() => {
4615
+ this.refresh();
4616
+ });
4617
+ this.refresh();
4618
+ return () => {
4619
+ this.stopList?.();
4620
+ this.stopFace?.();
4621
+ };
4622
+ }
4623
+ /** The current session id, for command execution. */
4624
+ currentSessionId() {
4625
+ return this.state.sessionId;
4626
+ }
4627
+ set(next) {
4628
+ this.state = next;
4629
+ for (const listener of [...this.listeners]) listener();
4630
+ }
4631
+ refresh() {
4632
+ const list = this.sessions.list.getSnapshot();
4633
+ const current = list.current;
4634
+ if (current !== this.boundSessionId) {
4635
+ this.stopFace?.();
4636
+ this.stopFace = void 0;
4637
+ this.boundSessionId = current;
4638
+ if (current !== void 0) {
4639
+ const face = this.sessions.binding(current)?.session.projections.faceOf("teamRoom");
4640
+ if (face !== void 0) this.stopFace = face.subscribe(() => {
4641
+ this.refresh();
4642
+ });
4643
+ }
4644
+ }
4645
+ if (current === void 0) {
4646
+ this.set(emptyTeamRoomsState());
4647
+ return;
4648
+ }
4649
+ const face = this.sessions.binding(current)?.session.projections.faceOf("teamRoom");
4650
+ const panels = face === void 0 ? void 0 : buildRoomPanels(face.getSnapshot(), list);
4651
+ this.set({
4652
+ status: "ready",
4653
+ sessionId: current,
4654
+ rooms: panels ?? []
4655
+ });
4656
+ }
4657
+ };
4658
+ /**
4659
+ * Register the Team Rooms settings page.
4660
+ * @param ctx - client root context.
4661
+ */
4662
+ function apply(ctx) {
4663
+ ctx.effect(() => ctx.locale.register(ROOM_NS, {
4664
+ zh,
4665
+ en
4666
+ }), "dsh-team-rooms: room dictionaries");
4667
+ const sessions = ctx.get("sessions");
4668
+ const remote = ctx.remote;
4669
+ const slots = ctx.get("slots");
4670
+ const controller = new TeamRoomsController(sessions);
4671
+ ctx.effect(() => controller.start(), "dsh-team-rooms: team rooms store");
4672
+ /** Execute one `/room` line against the current session; undefined on success. */
4673
+ const executeRoom = async (line) => {
4674
+ const sessionId = controller.currentSessionId();
4675
+ if (sessionId === void 0) return "no active session";
4676
+ try {
4677
+ const result = await remote.commands.execute(sessionId, line, []);
4678
+ if (!result.ok) return `${result.error.code}: ${result.error.message}`;
4679
+ if (result.value === void 0 || result.value.result === void 0) return `unknown or malformed command: ${line}`;
4680
+ return result.value.result.kind === "error" ? result.value.result.text : void 0;
4681
+ } catch (error) {
4682
+ return error instanceof Error ? error.message : String(error);
4683
+ }
4684
+ };
4685
+ const injected = () => ({
4686
+ hooks: { teamRooms: controller },
4687
+ getSessionId: () => controller.currentSessionId(),
4688
+ create: (name) => executeRoom(`/room create ${name}`),
4689
+ join: (roomId) => executeRoom(`/room join ${roomId}`),
4690
+ leave: (roomId) => executeRoom(`/room leave ${roomId}`),
4691
+ post: (roomId, text) => executeRoom(`/room send ${roomId} ${text}`),
4692
+ addTask: (roomId, title) => executeRoom(`/room task add ${roomId} ${title}`),
4693
+ claimTask: (roomId, taskId) => executeRoom(`/room task claim ${roomId} ${taskId}`),
4694
+ completeTask: (roomId, taskId) => executeRoom(`/room task done ${roomId} ${taskId}`),
4695
+ assignTask: (roomId, taskId, member) => executeRoom(`/room task assign ${roomId} ${taskId} ${member}`)
4696
+ });
4697
+ slots.inject("settings.section", () => slots.register({
4698
+ name: "settings.section",
4699
+ id: "team-rooms",
4700
+ order: 30,
4701
+ label: () => ctx.locale.bind(ROOM_NS)("nav"),
4702
+ locale: ROOM_NS,
4703
+ inject: injected
4704
+ }, TeamRoomsSection));
4705
+ }
4706
+ //#endregion
4707
+ exports.apply = apply;
4708
+ exports.inject = inject;
4709
+ return module.exports;
4710
+ }
4711
+ });
4712
+
4713
+ //# sourceMappingURL=client.js.map