@makefully/fancifully 0.0.0-stage → 0.1.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 (57) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +21 -0
  3. package/README.md +147 -3
  4. package/dist/Storybook.d.ts +69 -0
  5. package/dist/Storybook.d.ts.map +1 -0
  6. package/dist/audio/AudioBus.d.ts +21 -0
  7. package/dist/audio/AudioBus.d.ts.map +1 -0
  8. package/dist/audio/ReadAloudPlayer.d.ts +30 -0
  9. package/dist/audio/ReadAloudPlayer.d.ts.map +1 -0
  10. package/dist/fancifully.css +1 -0
  11. package/dist/fancifully.iife.js +8 -0
  12. package/dist/fancifully.js +4364 -0
  13. package/dist/index.d.ts +13 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/interaction/Pointer.d.ts +6 -0
  16. package/dist/interaction/Pointer.d.ts.map +1 -0
  17. package/dist/load/loadEpub.d.ts +15 -0
  18. package/dist/load/loadEpub.d.ts.map +1 -0
  19. package/dist/load/loadFanci.d.ts +16 -0
  20. package/dist/load/loadFanci.d.ts.map +1 -0
  21. package/dist/load/loadFonts.d.ts +3 -0
  22. package/dist/load/loadFonts.d.ts.map +1 -0
  23. package/dist/load/loadStory.d.ts +38 -0
  24. package/dist/load/loadStory.d.ts.map +1 -0
  25. package/dist/load/packageTypes.d.ts +11 -0
  26. package/dist/load/packageTypes.d.ts.map +1 -0
  27. package/dist/load/resolveUrl.d.ts +3 -0
  28. package/dist/load/resolveUrl.d.ts.map +1 -0
  29. package/dist/load/zipArchive.d.ts +11 -0
  30. package/dist/load/zipArchive.d.ts.map +1 -0
  31. package/dist/nav/Pager.d.ts +40 -0
  32. package/dist/nav/Pager.d.ts.map +1 -0
  33. package/dist/nav/layoutMode.d.ts +21 -0
  34. package/dist/nav/layoutMode.d.ts.map +1 -0
  35. package/dist/render/PageView.d.ts +13 -0
  36. package/dist/render/PageView.d.ts.map +1 -0
  37. package/dist/render/SpreadView.d.ts +32 -0
  38. package/dist/render/SpreadView.d.ts.map +1 -0
  39. package/dist/render/blocks/HotspotBlock.d.ts +5 -0
  40. package/dist/render/blocks/HotspotBlock.d.ts.map +1 -0
  41. package/dist/render/blocks/ImageBlock.d.ts +5 -0
  42. package/dist/render/blocks/ImageBlock.d.ts.map +1 -0
  43. package/dist/render/blocks/TextBlock.d.ts +5 -0
  44. package/dist/render/blocks/TextBlock.d.ts.map +1 -0
  45. package/dist/render/layout.d.ts +10 -0
  46. package/dist/render/layout.d.ts.map +1 -0
  47. package/dist/schema/story.d.ts +1542 -0
  48. package/dist/schema/story.d.ts.map +1 -0
  49. package/dist/springroll/bindApplication.d.ts +52 -0
  50. package/dist/springroll/bindApplication.d.ts.map +1 -0
  51. package/dist/springroll/loading.d.ts +31 -0
  52. package/dist/springroll/loading.d.ts.map +1 -0
  53. package/dist/sync/CueTimeline.d.ts +16 -0
  54. package/dist/sync/CueTimeline.d.ts.map +1 -0
  55. package/dist/sync/parseVtt.d.ts +5 -0
  56. package/dist/sync/parseVtt.d.ts.map +1 -0
  57. package/package.json +74 -6
@@ -0,0 +1,4364 @@
1
+ var bs = Object.defineProperty;
2
+ var ws = (s, e, t) => e in s ? bs(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var g = (s, e, t) => ws(s, typeof e != "symbol" ? e + "" : e, t);
4
+ class xs {
5
+ constructor() {
6
+ g(this, "volumes", {
7
+ sound: 1,
8
+ vo: 1,
9
+ sfx: 1,
10
+ music: 1
11
+ });
12
+ g(this, "elements", /* @__PURE__ */ new Set());
13
+ g(this, "paused", !1);
14
+ }
15
+ setVolume(e, t) {
16
+ this.volumes[e] = st(t), this.applyAll();
17
+ }
18
+ getVolume(e) {
19
+ return st(this.volumes.sound) * st(this.volumes[e]);
20
+ }
21
+ setPaused(e) {
22
+ this.paused = e;
23
+ for (const t of this.elements)
24
+ e && t.pause();
25
+ }
26
+ get isPaused() {
27
+ return this.paused;
28
+ }
29
+ register(e, t) {
30
+ this.elements.add(e), e.volume = this.getVolume(t), e.dataset.fcChannel = t;
31
+ }
32
+ unregister(e) {
33
+ this.elements.delete(e);
34
+ }
35
+ applyTo(e, t) {
36
+ e.volume = this.getVolume(t);
37
+ }
38
+ applyAll() {
39
+ for (const e of this.elements) {
40
+ const t = e.dataset.fcChannel || "vo";
41
+ e.volume = this.getVolume(t);
42
+ }
43
+ }
44
+ }
45
+ function st(s) {
46
+ return Number.isNaN(s) ? 0 : Math.min(1, Math.max(0, s));
47
+ }
48
+ class ks {
49
+ constructor(e = []) {
50
+ g(this, "cues");
51
+ g(this, "root", null);
52
+ g(this, "lastActiveId", null);
53
+ g(this, "readIds", /* @__PURE__ */ new Set());
54
+ this.cues = [...e].sort((t, n) => t.start - n.start);
55
+ }
56
+ setCues(e) {
57
+ this.cues = [...e].sort((t, n) => t.start - n.start), this.reset();
58
+ }
59
+ attach(e) {
60
+ this.root = e, this.resetHighlight();
61
+ }
62
+ reset() {
63
+ this.lastActiveId = null, this.readIds.clear(), this.resetHighlight();
64
+ }
65
+ update(e) {
66
+ const t = this.cues.find((n) => e >= n.start && e < n.end) ?? null;
67
+ return this.root && (t ? (this.readIds.add(t.id), t.id !== this.lastActiveId && (this.applyHighlight(t.id), this.lastActiveId = t.id)) : this.lastActiveId && (this.clearActive(), this.lastActiveId = null)), t;
68
+ }
69
+ applyHighlight(e) {
70
+ if (!this.root) return;
71
+ this.root.querySelectorAll(".fc-cue.is-active").forEach((n) => n.classList.remove("is-active"));
72
+ const t = this.root.querySelector(`#${Ot(e)}, [data-cue-id="${Pt(e)}"]`);
73
+ t && t.classList.add("fc-cue", "is-active", "is-read");
74
+ for (const n of this.readIds) {
75
+ if (n === e) continue;
76
+ const r = this.root.querySelector(`#${Ot(n)}, [data-cue-id="${Pt(n)}"]`);
77
+ r == null || r.classList.add("fc-cue", "is-read");
78
+ }
79
+ }
80
+ clearActive() {
81
+ var e;
82
+ (e = this.root) == null || e.querySelectorAll(".fc-cue.is-active").forEach((t) => t.classList.remove("is-active"));
83
+ }
84
+ resetHighlight() {
85
+ var e;
86
+ (e = this.root) == null || e.querySelectorAll(".fc-cue").forEach((t) => {
87
+ t.classList.remove("is-active", "is-read");
88
+ });
89
+ }
90
+ }
91
+ function Ot(s) {
92
+ return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(s) : s.replace(/[^a-zA-Z0-9_-]/g, "\\$&");
93
+ }
94
+ function Pt(s) {
95
+ return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
96
+ }
97
+ class Ss {
98
+ constructor(e) {
99
+ g(this, "bus");
100
+ g(this, "audio");
101
+ g(this, "timeline", new ks());
102
+ g(this, "queue", []);
103
+ g(this, "raf", 0);
104
+ g(this, "captionsMuted", !1);
105
+ g(this, "onCaptionLine", null);
106
+ g(this, "playing", !1);
107
+ this.bus = e, this.audio = new Audio(), this.audio.preload = "auto", this.bus.register(this.audio, "vo"), this.audio.addEventListener("ended", () => this.playNext());
108
+ }
109
+ setCaptionsMuted(e) {
110
+ var t;
111
+ this.captionsMuted = e, e && ((t = this.onCaptionLine) == null || t.call(this, null));
112
+ }
113
+ onCaption(e) {
114
+ this.onCaptionLine = e;
115
+ }
116
+ async playSequence(e) {
117
+ this.stop(), this.queue = e.filter((t) => !!t.url), this.queue.length !== 0 && (this.playing = !0, await this.playNext());
118
+ }
119
+ pause() {
120
+ this.audio.pause(), this.cancelTick();
121
+ }
122
+ resume() {
123
+ !this.playing || this.bus.isPaused || (this.audio.play().catch(() => {
124
+ }), this.startTick());
125
+ }
126
+ stop() {
127
+ var e;
128
+ this.playing = !1, this.queue = [], this.audio.pause(), this.audio.removeAttribute("src"), this.audio.load(), this.timeline.reset(), this.cancelTick(), (e = this.onCaptionLine) == null || e.call(this, null);
129
+ }
130
+ destroy() {
131
+ this.stop(), this.bus.unregister(this.audio);
132
+ }
133
+ async playNext() {
134
+ var t;
135
+ this.cancelTick();
136
+ const e = this.queue.shift();
137
+ if (!e) {
138
+ this.playing = !1, this.timeline.reset(), (t = this.onCaptionLine) == null || t.call(this, null);
139
+ return;
140
+ }
141
+ this.timeline.setCues(e.cues), this.timeline.attach(e.root), this.bus.register(this.audio, e.channel), this.audio.src = e.url, this.bus.applyTo(this.audio, e.channel);
142
+ try {
143
+ await this.audio.play(), this.startTick();
144
+ } catch {
145
+ this.startTick();
146
+ }
147
+ }
148
+ startTick() {
149
+ this.cancelTick();
150
+ const e = () => {
151
+ var t;
152
+ if (this.playing) {
153
+ if (!this.bus.isPaused && !this.audio.paused) {
154
+ const n = this.timeline.update(this.audio.currentTime);
155
+ this.captionsMuted || (t = this.onCaptionLine) == null || t.call(this, (n == null ? void 0 : n.text) ?? (n == null ? void 0 : n.id) ?? null);
156
+ }
157
+ this.raf = requestAnimationFrame(e);
158
+ }
159
+ };
160
+ this.raf = requestAnimationFrame(e);
161
+ }
162
+ cancelTick() {
163
+ this.raf && (cancelAnimationFrame(this.raf), this.raf = 0);
164
+ }
165
+ }
166
+ function As(s, e) {
167
+ let t = 0, n = 0, r = !1;
168
+ const i = (c) => {
169
+ c.button != null && c.button !== 0 || (r = !0, t = c.clientX, n = c.clientY);
170
+ }, a = (c) => {
171
+ var h, y;
172
+ if (!r) return;
173
+ r = !1;
174
+ const l = c.clientX - t, d = c.clientY - n;
175
+ Math.abs(l) < 50 || Math.abs(l) < Math.abs(d) || (l < 0 ? (h = e.onSwipeLeft) == null || h.call(e) : (y = e.onSwipeRight) == null || y.call(e));
176
+ }, o = () => {
177
+ r = !1;
178
+ };
179
+ return s.addEventListener("pointerdown", i), s.addEventListener("pointerup", a), s.addEventListener("pointercancel", o), () => {
180
+ s.removeEventListener("pointerdown", i), s.removeEventListener("pointerup", a), s.removeEventListener("pointercancel", o);
181
+ };
182
+ }
183
+ var S;
184
+ (function(s) {
185
+ s.assertEqual = (r) => {
186
+ };
187
+ function e(r) {
188
+ }
189
+ s.assertIs = e;
190
+ function t(r) {
191
+ throw new Error();
192
+ }
193
+ s.assertNever = t, s.arrayToEnum = (r) => {
194
+ const i = {};
195
+ for (const a of r)
196
+ i[a] = a;
197
+ return i;
198
+ }, s.getValidEnumValues = (r) => {
199
+ const i = s.objectKeys(r).filter((o) => typeof r[r[o]] != "number"), a = {};
200
+ for (const o of i)
201
+ a[o] = r[o];
202
+ return s.objectValues(a);
203
+ }, s.objectValues = (r) => s.objectKeys(r).map(function(i) {
204
+ return r[i];
205
+ }), s.objectKeys = typeof Object.keys == "function" ? (r) => Object.keys(r) : (r) => {
206
+ const i = [];
207
+ for (const a in r)
208
+ Object.prototype.hasOwnProperty.call(r, a) && i.push(a);
209
+ return i;
210
+ }, s.find = (r, i) => {
211
+ for (const a of r)
212
+ if (i(a))
213
+ return a;
214
+ }, s.isInteger = typeof Number.isInteger == "function" ? (r) => Number.isInteger(r) : (r) => typeof r == "number" && Number.isFinite(r) && Math.floor(r) === r;
215
+ function n(r, i = " | ") {
216
+ return r.map((a) => typeof a == "string" ? `'${a}'` : a).join(i);
217
+ }
218
+ s.joinValues = n, s.jsonStringifyReplacer = (r, i) => typeof i == "bigint" ? i.toString() : i;
219
+ })(S || (S = {}));
220
+ var Rt;
221
+ (function(s) {
222
+ s.mergeShapes = (e, t) => ({
223
+ ...e,
224
+ ...t
225
+ // second overwrites first
226
+ });
227
+ })(Rt || (Rt = {}));
228
+ const p = S.arrayToEnum([
229
+ "string",
230
+ "nan",
231
+ "number",
232
+ "integer",
233
+ "float",
234
+ "boolean",
235
+ "date",
236
+ "bigint",
237
+ "symbol",
238
+ "function",
239
+ "undefined",
240
+ "null",
241
+ "array",
242
+ "object",
243
+ "unknown",
244
+ "promise",
245
+ "void",
246
+ "never",
247
+ "map",
248
+ "set"
249
+ ]), te = (s) => {
250
+ switch (typeof s) {
251
+ case "undefined":
252
+ return p.undefined;
253
+ case "string":
254
+ return p.string;
255
+ case "number":
256
+ return Number.isNaN(s) ? p.nan : p.number;
257
+ case "boolean":
258
+ return p.boolean;
259
+ case "function":
260
+ return p.function;
261
+ case "bigint":
262
+ return p.bigint;
263
+ case "symbol":
264
+ return p.symbol;
265
+ case "object":
266
+ return Array.isArray(s) ? p.array : s === null ? p.null : s.then && typeof s.then == "function" && s.catch && typeof s.catch == "function" ? p.promise : typeof Map < "u" && s instanceof Map ? p.map : typeof Set < "u" && s instanceof Set ? p.set : typeof Date < "u" && s instanceof Date ? p.date : p.object;
267
+ default:
268
+ return p.unknown;
269
+ }
270
+ }, u = S.arrayToEnum([
271
+ "invalid_type",
272
+ "invalid_literal",
273
+ "custom",
274
+ "invalid_union",
275
+ "invalid_union_discriminator",
276
+ "invalid_enum_value",
277
+ "unrecognized_keys",
278
+ "invalid_arguments",
279
+ "invalid_return_type",
280
+ "invalid_date",
281
+ "invalid_string",
282
+ "too_small",
283
+ "too_big",
284
+ "invalid_intersection_types",
285
+ "not_multiple_of",
286
+ "not_finite"
287
+ ]);
288
+ class Q extends Error {
289
+ get errors() {
290
+ return this.issues;
291
+ }
292
+ constructor(e) {
293
+ super(), this.issues = [], this.addIssue = (n) => {
294
+ this.issues = [...this.issues, n];
295
+ }, this.addIssues = (n = []) => {
296
+ this.issues = [...this.issues, ...n];
297
+ };
298
+ const t = new.target.prototype;
299
+ Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
300
+ }
301
+ format(e) {
302
+ const t = e || function(i) {
303
+ return i.message;
304
+ }, n = { _errors: [] }, r = (i) => {
305
+ for (const a of i.issues)
306
+ if (a.code === "invalid_union")
307
+ a.unionErrors.map(r);
308
+ else if (a.code === "invalid_return_type")
309
+ r(a.returnTypeError);
310
+ else if (a.code === "invalid_arguments")
311
+ r(a.argumentsError);
312
+ else if (a.path.length === 0)
313
+ n._errors.push(t(a));
314
+ else {
315
+ let o = n, c = 0;
316
+ for (; c < a.path.length; ) {
317
+ const l = a.path[c];
318
+ c === a.path.length - 1 ? (o[l] = o[l] || { _errors: [] }, o[l]._errors.push(t(a))) : o[l] = o[l] || { _errors: [] }, o = o[l], c++;
319
+ }
320
+ }
321
+ };
322
+ return r(this), n;
323
+ }
324
+ static assert(e) {
325
+ if (!(e instanceof Q))
326
+ throw new Error(`Not a ZodError: ${e}`);
327
+ }
328
+ toString() {
329
+ return this.message;
330
+ }
331
+ get message() {
332
+ return JSON.stringify(this.issues, S.jsonStringifyReplacer, 2);
333
+ }
334
+ get isEmpty() {
335
+ return this.issues.length === 0;
336
+ }
337
+ flatten(e = (t) => t.message) {
338
+ const t = {}, n = [];
339
+ for (const r of this.issues)
340
+ if (r.path.length > 0) {
341
+ const i = r.path[0];
342
+ t[i] = t[i] || [], t[i].push(e(r));
343
+ } else
344
+ n.push(e(r));
345
+ return { formErrors: n, fieldErrors: t };
346
+ }
347
+ get formErrors() {
348
+ return this.flatten();
349
+ }
350
+ }
351
+ Q.create = (s) => new Q(s);
352
+ const ot = (s, e) => {
353
+ let t;
354
+ switch (s.code) {
355
+ case u.invalid_type:
356
+ s.received === p.undefined ? t = "Required" : t = `Expected ${s.expected}, received ${s.received}`;
357
+ break;
358
+ case u.invalid_literal:
359
+ t = `Invalid literal value, expected ${JSON.stringify(s.expected, S.jsonStringifyReplacer)}`;
360
+ break;
361
+ case u.unrecognized_keys:
362
+ t = `Unrecognized key(s) in object: ${S.joinValues(s.keys, ", ")}`;
363
+ break;
364
+ case u.invalid_union:
365
+ t = "Invalid input";
366
+ break;
367
+ case u.invalid_union_discriminator:
368
+ t = `Invalid discriminator value. Expected ${S.joinValues(s.options)}`;
369
+ break;
370
+ case u.invalid_enum_value:
371
+ t = `Invalid enum value. Expected ${S.joinValues(s.options)}, received '${s.received}'`;
372
+ break;
373
+ case u.invalid_arguments:
374
+ t = "Invalid function arguments";
375
+ break;
376
+ case u.invalid_return_type:
377
+ t = "Invalid function return type";
378
+ break;
379
+ case u.invalid_date:
380
+ t = "Invalid date";
381
+ break;
382
+ case u.invalid_string:
383
+ typeof s.validation == "object" ? "includes" in s.validation ? (t = `Invalid input: must include "${s.validation.includes}"`, typeof s.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${s.validation.position}`)) : "startsWith" in s.validation ? t = `Invalid input: must start with "${s.validation.startsWith}"` : "endsWith" in s.validation ? t = `Invalid input: must end with "${s.validation.endsWith}"` : S.assertNever(s.validation) : s.validation !== "regex" ? t = `Invalid ${s.validation}` : t = "Invalid";
384
+ break;
385
+ case u.too_small:
386
+ s.type === "array" ? t = `Array must contain ${s.exact ? "exactly" : s.inclusive ? "at least" : "more than"} ${s.minimum} element(s)` : s.type === "string" ? t = `String must contain ${s.exact ? "exactly" : s.inclusive ? "at least" : "over"} ${s.minimum} character(s)` : s.type === "number" ? t = `Number must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${s.minimum}` : s.type === "bigint" ? t = `Number must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${s.minimum}` : s.type === "date" ? t = `Date must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(s.minimum))}` : t = "Invalid input";
387
+ break;
388
+ case u.too_big:
389
+ s.type === "array" ? t = `Array must contain ${s.exact ? "exactly" : s.inclusive ? "at most" : "less than"} ${s.maximum} element(s)` : s.type === "string" ? t = `String must contain ${s.exact ? "exactly" : s.inclusive ? "at most" : "under"} ${s.maximum} character(s)` : s.type === "number" ? t = `Number must be ${s.exact ? "exactly" : s.inclusive ? "less than or equal to" : "less than"} ${s.maximum}` : s.type === "bigint" ? t = `BigInt must be ${s.exact ? "exactly" : s.inclusive ? "less than or equal to" : "less than"} ${s.maximum}` : s.type === "date" ? t = `Date must be ${s.exact ? "exactly" : s.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(s.maximum))}` : t = "Invalid input";
390
+ break;
391
+ case u.custom:
392
+ t = "Invalid input";
393
+ break;
394
+ case u.invalid_intersection_types:
395
+ t = "Intersection results could not be merged";
396
+ break;
397
+ case u.not_multiple_of:
398
+ t = `Number must be a multiple of ${s.multipleOf}`;
399
+ break;
400
+ case u.not_finite:
401
+ t = "Number must be finite";
402
+ break;
403
+ default:
404
+ t = e.defaultError, S.assertNever(s);
405
+ }
406
+ return { message: t };
407
+ };
408
+ let Ts = ot;
409
+ function Cs() {
410
+ return Ts;
411
+ }
412
+ const Es = (s) => {
413
+ const { data: e, path: t, errorMaps: n, issueData: r } = s, i = [...t, ...r.path || []], a = {
414
+ ...r,
415
+ path: i
416
+ };
417
+ if (r.message !== void 0)
418
+ return {
419
+ ...r,
420
+ path: i,
421
+ message: r.message
422
+ };
423
+ let o = "";
424
+ const c = n.filter((l) => !!l).slice().reverse();
425
+ for (const l of c)
426
+ o = l(a, { data: e, defaultError: o }).message;
427
+ return {
428
+ ...r,
429
+ path: i,
430
+ message: o
431
+ };
432
+ };
433
+ function f(s, e) {
434
+ const t = Cs(), n = Es({
435
+ issueData: e,
436
+ data: s.data,
437
+ path: s.path,
438
+ errorMaps: [
439
+ s.common.contextualErrorMap,
440
+ // contextual error map is first priority
441
+ s.schemaErrorMap,
442
+ // then schema-bound map if available
443
+ t,
444
+ // then global override map
445
+ t === ot ? void 0 : ot
446
+ // then global default map
447
+ ].filter((r) => !!r)
448
+ });
449
+ s.common.issues.push(n);
450
+ }
451
+ class M {
452
+ constructor() {
453
+ this.value = "valid";
454
+ }
455
+ dirty() {
456
+ this.value === "valid" && (this.value = "dirty");
457
+ }
458
+ abort() {
459
+ this.value !== "aborted" && (this.value = "aborted");
460
+ }
461
+ static mergeArray(e, t) {
462
+ const n = [];
463
+ for (const r of t) {
464
+ if (r.status === "aborted")
465
+ return v;
466
+ r.status === "dirty" && e.dirty(), n.push(r.value);
467
+ }
468
+ return { status: e.value, value: n };
469
+ }
470
+ static async mergeObjectAsync(e, t) {
471
+ const n = [];
472
+ for (const r of t) {
473
+ const i = await r.key, a = await r.value;
474
+ n.push({
475
+ key: i,
476
+ value: a
477
+ });
478
+ }
479
+ return M.mergeObjectSync(e, n);
480
+ }
481
+ static mergeObjectSync(e, t) {
482
+ const n = {};
483
+ for (const r of t) {
484
+ const { key: i, value: a } = r;
485
+ if (i.status === "aborted" || a.status === "aborted")
486
+ return v;
487
+ i.status === "dirty" && e.dirty(), a.status === "dirty" && e.dirty(), i.value !== "__proto__" && (typeof a.value < "u" || r.alwaysSet) && (n[i.value] = a.value);
488
+ }
489
+ return { status: e.value, value: n };
490
+ }
491
+ }
492
+ const v = Object.freeze({
493
+ status: "aborted"
494
+ }), Te = (s) => ({ status: "dirty", value: s }), z = (s) => ({ status: "valid", value: s }), Mt = (s) => s.status === "aborted", Lt = (s) => s.status === "dirty", _e = (s) => s.status === "valid", Ue = (s) => typeof Promise < "u" && s instanceof Promise;
495
+ var m;
496
+ (function(s) {
497
+ s.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, s.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
498
+ })(m || (m = {}));
499
+ class J {
500
+ constructor(e, t, n, r) {
501
+ this._cachedPath = [], this.parent = e, this.data = t, this._path = n, this._key = r;
502
+ }
503
+ get path() {
504
+ return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
505
+ }
506
+ }
507
+ const jt = (s, e) => {
508
+ if (_e(e))
509
+ return { success: !0, data: e.value };
510
+ if (!s.common.issues.length)
511
+ throw new Error("Validation failed but no issues detected.");
512
+ return {
513
+ success: !1,
514
+ get error() {
515
+ if (this._error)
516
+ return this._error;
517
+ const t = new Q(s.common.issues);
518
+ return this._error = t, this._error;
519
+ }
520
+ };
521
+ };
522
+ function b(s) {
523
+ if (!s)
524
+ return {};
525
+ const { errorMap: e, invalid_type_error: t, required_error: n, description: r } = s;
526
+ if (e && (t || n))
527
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
528
+ return e ? { errorMap: e, description: r } : { errorMap: (a, o) => {
529
+ const { message: c } = s;
530
+ return a.code === "invalid_enum_value" ? { message: c ?? o.defaultError } : typeof o.data > "u" ? { message: c ?? n ?? o.defaultError } : a.code !== "invalid_type" ? { message: o.defaultError } : { message: c ?? t ?? o.defaultError };
531
+ }, description: r };
532
+ }
533
+ class x {
534
+ get description() {
535
+ return this._def.description;
536
+ }
537
+ _getType(e) {
538
+ return te(e.data);
539
+ }
540
+ _getOrReturnCtx(e, t) {
541
+ return t || {
542
+ common: e.parent.common,
543
+ data: e.data,
544
+ parsedType: te(e.data),
545
+ schemaErrorMap: this._def.errorMap,
546
+ path: e.path,
547
+ parent: e.parent
548
+ };
549
+ }
550
+ _processInputParams(e) {
551
+ return {
552
+ status: new M(),
553
+ ctx: {
554
+ common: e.parent.common,
555
+ data: e.data,
556
+ parsedType: te(e.data),
557
+ schemaErrorMap: this._def.errorMap,
558
+ path: e.path,
559
+ parent: e.parent
560
+ }
561
+ };
562
+ }
563
+ _parseSync(e) {
564
+ const t = this._parse(e);
565
+ if (Ue(t))
566
+ throw new Error("Synchronous parse encountered promise.");
567
+ return t;
568
+ }
569
+ _parseAsync(e) {
570
+ const t = this._parse(e);
571
+ return Promise.resolve(t);
572
+ }
573
+ parse(e, t) {
574
+ const n = this.safeParse(e, t);
575
+ if (n.success)
576
+ return n.data;
577
+ throw n.error;
578
+ }
579
+ safeParse(e, t) {
580
+ const n = {
581
+ common: {
582
+ issues: [],
583
+ async: (t == null ? void 0 : t.async) ?? !1,
584
+ contextualErrorMap: t == null ? void 0 : t.errorMap
585
+ },
586
+ path: (t == null ? void 0 : t.path) || [],
587
+ schemaErrorMap: this._def.errorMap,
588
+ parent: null,
589
+ data: e,
590
+ parsedType: te(e)
591
+ }, r = this._parseSync({ data: e, path: n.path, parent: n });
592
+ return jt(n, r);
593
+ }
594
+ "~validate"(e) {
595
+ var n, r;
596
+ const t = {
597
+ common: {
598
+ issues: [],
599
+ async: !!this["~standard"].async
600
+ },
601
+ path: [],
602
+ schemaErrorMap: this._def.errorMap,
603
+ parent: null,
604
+ data: e,
605
+ parsedType: te(e)
606
+ };
607
+ if (!this["~standard"].async)
608
+ try {
609
+ const i = this._parseSync({ data: e, path: [], parent: t });
610
+ return _e(i) ? {
611
+ value: i.value
612
+ } : {
613
+ issues: t.common.issues
614
+ };
615
+ } catch (i) {
616
+ (r = (n = i == null ? void 0 : i.message) == null ? void 0 : n.toLowerCase()) != null && r.includes("encountered") && (this["~standard"].async = !0), t.common = {
617
+ issues: [],
618
+ async: !0
619
+ };
620
+ }
621
+ return this._parseAsync({ data: e, path: [], parent: t }).then((i) => _e(i) ? {
622
+ value: i.value
623
+ } : {
624
+ issues: t.common.issues
625
+ });
626
+ }
627
+ async parseAsync(e, t) {
628
+ const n = await this.safeParseAsync(e, t);
629
+ if (n.success)
630
+ return n.data;
631
+ throw n.error;
632
+ }
633
+ async safeParseAsync(e, t) {
634
+ const n = {
635
+ common: {
636
+ issues: [],
637
+ contextualErrorMap: t == null ? void 0 : t.errorMap,
638
+ async: !0
639
+ },
640
+ path: (t == null ? void 0 : t.path) || [],
641
+ schemaErrorMap: this._def.errorMap,
642
+ parent: null,
643
+ data: e,
644
+ parsedType: te(e)
645
+ }, r = this._parse({ data: e, path: n.path, parent: n }), i = await (Ue(r) ? r : Promise.resolve(r));
646
+ return jt(n, i);
647
+ }
648
+ refine(e, t) {
649
+ const n = (r) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(r) : t;
650
+ return this._refinement((r, i) => {
651
+ const a = e(r), o = () => i.addIssue({
652
+ code: u.custom,
653
+ ...n(r)
654
+ });
655
+ return typeof Promise < "u" && a instanceof Promise ? a.then((c) => c ? !0 : (o(), !1)) : a ? !0 : (o(), !1);
656
+ });
657
+ }
658
+ refinement(e, t) {
659
+ return this._refinement((n, r) => e(n) ? !0 : (r.addIssue(typeof t == "function" ? t(n, r) : t), !1));
660
+ }
661
+ _refinement(e) {
662
+ return new ce({
663
+ schema: this,
664
+ typeName: _.ZodEffects,
665
+ effect: { type: "refinement", refinement: e }
666
+ });
667
+ }
668
+ superRefine(e) {
669
+ return this._refinement(e);
670
+ }
671
+ constructor(e) {
672
+ this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
673
+ version: 1,
674
+ vendor: "zod",
675
+ validate: (t) => this["~validate"](t)
676
+ };
677
+ }
678
+ optional() {
679
+ return G.create(this, this._def);
680
+ }
681
+ nullable() {
682
+ return le.create(this, this._def);
683
+ }
684
+ nullish() {
685
+ return this.nullable().optional();
686
+ }
687
+ array() {
688
+ return H.create(this);
689
+ }
690
+ promise() {
691
+ return Je.create(this, this._def);
692
+ }
693
+ or(e) {
694
+ return De.create([this, e], this._def);
695
+ }
696
+ and(e) {
697
+ return We.create(this, e, this._def);
698
+ }
699
+ transform(e) {
700
+ return new ce({
701
+ ...b(this._def),
702
+ schema: this,
703
+ typeName: _.ZodEffects,
704
+ effect: { type: "transform", transform: e }
705
+ });
706
+ }
707
+ default(e) {
708
+ const t = typeof e == "function" ? e : () => e;
709
+ return new Xe({
710
+ ...b(this._def),
711
+ innerType: this,
712
+ defaultValue: t,
713
+ typeName: _.ZodDefault
714
+ });
715
+ }
716
+ brand() {
717
+ return new ts({
718
+ typeName: _.ZodBranded,
719
+ type: this,
720
+ ...b(this._def)
721
+ });
722
+ }
723
+ catch(e) {
724
+ const t = typeof e == "function" ? e : () => e;
725
+ return new Ye({
726
+ ...b(this._def),
727
+ innerType: this,
728
+ catchValue: t,
729
+ typeName: _.ZodCatch
730
+ });
731
+ }
732
+ describe(e) {
733
+ const t = this.constructor;
734
+ return new t({
735
+ ...this._def,
736
+ description: e
737
+ });
738
+ }
739
+ pipe(e) {
740
+ return vt.create(this, e);
741
+ }
742
+ readonly() {
743
+ return Ge.create(this);
744
+ }
745
+ isOptional() {
746
+ return this.safeParse(void 0).success;
747
+ }
748
+ isNullable() {
749
+ return this.safeParse(null).success;
750
+ }
751
+ }
752
+ const Ns = /^c[^\s-]{8,}$/i, Is = /^[0-9a-z]+$/, $s = /^[0-9A-HJKMNP-TV-Z]{26}$/i, Os = /^[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, Ps = /^[a-z0-9_-]{21}$/i, Rs = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Ms = /^[-+]?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)?)??$/, Ls = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, js = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
753
+ let nt;
754
+ const Zs = /^(?:(?: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])$/, Vs = /^(?:(?: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])$/, zs = /^(([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]))$/, Bs = /^(([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])$/, Us = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Fs = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Qt = "((\\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])))", Ds = new RegExp(`^${Qt}$`);
755
+ function Kt(s) {
756
+ let e = "[0-5]\\d";
757
+ s.precision ? e = `${e}\\.\\d{${s.precision}}` : s.precision == null && (e = `${e}(\\.\\d+)?`);
758
+ const t = s.precision ? "+" : "?";
759
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
760
+ }
761
+ function Ws(s) {
762
+ return new RegExp(`^${Kt(s)}$`);
763
+ }
764
+ function qs(s) {
765
+ let e = `${Qt}T${Kt(s)}`;
766
+ const t = [];
767
+ return t.push(s.local ? "Z?" : "Z"), s.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
768
+ }
769
+ function Hs(s, e) {
770
+ return !!((e === "v4" || !e) && Zs.test(s) || (e === "v6" || !e) && zs.test(s));
771
+ }
772
+ function Js(s, e) {
773
+ if (!Rs.test(s))
774
+ return !1;
775
+ try {
776
+ const [t] = s.split(".");
777
+ if (!t)
778
+ return !1;
779
+ const n = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), r = JSON.parse(atob(n));
780
+ return !(typeof r != "object" || r === null || "typ" in r && (r == null ? void 0 : r.typ) !== "JWT" || !r.alg || e && r.alg !== e);
781
+ } catch {
782
+ return !1;
783
+ }
784
+ }
785
+ function Xs(s, e) {
786
+ return !!((e === "v4" || !e) && Vs.test(s) || (e === "v6" || !e) && Bs.test(s));
787
+ }
788
+ class Y extends x {
789
+ _parse(e) {
790
+ if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== p.string) {
791
+ const i = this._getOrReturnCtx(e);
792
+ return f(i, {
793
+ code: u.invalid_type,
794
+ expected: p.string,
795
+ received: i.parsedType
796
+ }), v;
797
+ }
798
+ const n = new M();
799
+ let r;
800
+ for (const i of this._def.checks)
801
+ if (i.kind === "min")
802
+ e.data.length < i.value && (r = this._getOrReturnCtx(e, r), f(r, {
803
+ code: u.too_small,
804
+ minimum: i.value,
805
+ type: "string",
806
+ inclusive: !0,
807
+ exact: !1,
808
+ message: i.message
809
+ }), n.dirty());
810
+ else if (i.kind === "max")
811
+ e.data.length > i.value && (r = this._getOrReturnCtx(e, r), f(r, {
812
+ code: u.too_big,
813
+ maximum: i.value,
814
+ type: "string",
815
+ inclusive: !0,
816
+ exact: !1,
817
+ message: i.message
818
+ }), n.dirty());
819
+ else if (i.kind === "length") {
820
+ const a = e.data.length > i.value, o = e.data.length < i.value;
821
+ (a || o) && (r = this._getOrReturnCtx(e, r), a ? f(r, {
822
+ code: u.too_big,
823
+ maximum: i.value,
824
+ type: "string",
825
+ inclusive: !0,
826
+ exact: !0,
827
+ message: i.message
828
+ }) : o && f(r, {
829
+ code: u.too_small,
830
+ minimum: i.value,
831
+ type: "string",
832
+ inclusive: !0,
833
+ exact: !0,
834
+ message: i.message
835
+ }), n.dirty());
836
+ } else if (i.kind === "email")
837
+ Ls.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
838
+ validation: "email",
839
+ code: u.invalid_string,
840
+ message: i.message
841
+ }), n.dirty());
842
+ else if (i.kind === "emoji")
843
+ nt || (nt = new RegExp(js, "u")), nt.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
844
+ validation: "emoji",
845
+ code: u.invalid_string,
846
+ message: i.message
847
+ }), n.dirty());
848
+ else if (i.kind === "uuid")
849
+ Os.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
850
+ validation: "uuid",
851
+ code: u.invalid_string,
852
+ message: i.message
853
+ }), n.dirty());
854
+ else if (i.kind === "nanoid")
855
+ Ps.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
856
+ validation: "nanoid",
857
+ code: u.invalid_string,
858
+ message: i.message
859
+ }), n.dirty());
860
+ else if (i.kind === "cuid")
861
+ Ns.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
862
+ validation: "cuid",
863
+ code: u.invalid_string,
864
+ message: i.message
865
+ }), n.dirty());
866
+ else if (i.kind === "cuid2")
867
+ Is.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
868
+ validation: "cuid2",
869
+ code: u.invalid_string,
870
+ message: i.message
871
+ }), n.dirty());
872
+ else if (i.kind === "ulid")
873
+ $s.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
874
+ validation: "ulid",
875
+ code: u.invalid_string,
876
+ message: i.message
877
+ }), n.dirty());
878
+ else if (i.kind === "url")
879
+ try {
880
+ new URL(e.data);
881
+ } catch {
882
+ r = this._getOrReturnCtx(e, r), f(r, {
883
+ validation: "url",
884
+ code: u.invalid_string,
885
+ message: i.message
886
+ }), n.dirty();
887
+ }
888
+ else i.kind === "regex" ? (i.regex.lastIndex = 0, i.regex.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
889
+ validation: "regex",
890
+ code: u.invalid_string,
891
+ message: i.message
892
+ }), n.dirty())) : i.kind === "trim" ? e.data = e.data.trim() : i.kind === "includes" ? e.data.includes(i.value, i.position) || (r = this._getOrReturnCtx(e, r), f(r, {
893
+ code: u.invalid_string,
894
+ validation: { includes: i.value, position: i.position },
895
+ message: i.message
896
+ }), n.dirty()) : i.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : i.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : i.kind === "startsWith" ? e.data.startsWith(i.value) || (r = this._getOrReturnCtx(e, r), f(r, {
897
+ code: u.invalid_string,
898
+ validation: { startsWith: i.value },
899
+ message: i.message
900
+ }), n.dirty()) : i.kind === "endsWith" ? e.data.endsWith(i.value) || (r = this._getOrReturnCtx(e, r), f(r, {
901
+ code: u.invalid_string,
902
+ validation: { endsWith: i.value },
903
+ message: i.message
904
+ }), n.dirty()) : i.kind === "datetime" ? qs(i).test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
905
+ code: u.invalid_string,
906
+ validation: "datetime",
907
+ message: i.message
908
+ }), n.dirty()) : i.kind === "date" ? Ds.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
909
+ code: u.invalid_string,
910
+ validation: "date",
911
+ message: i.message
912
+ }), n.dirty()) : i.kind === "time" ? Ws(i).test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
913
+ code: u.invalid_string,
914
+ validation: "time",
915
+ message: i.message
916
+ }), n.dirty()) : i.kind === "duration" ? Ms.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
917
+ validation: "duration",
918
+ code: u.invalid_string,
919
+ message: i.message
920
+ }), n.dirty()) : i.kind === "ip" ? Hs(e.data, i.version) || (r = this._getOrReturnCtx(e, r), f(r, {
921
+ validation: "ip",
922
+ code: u.invalid_string,
923
+ message: i.message
924
+ }), n.dirty()) : i.kind === "jwt" ? Js(e.data, i.alg) || (r = this._getOrReturnCtx(e, r), f(r, {
925
+ validation: "jwt",
926
+ code: u.invalid_string,
927
+ message: i.message
928
+ }), n.dirty()) : i.kind === "cidr" ? Xs(e.data, i.version) || (r = this._getOrReturnCtx(e, r), f(r, {
929
+ validation: "cidr",
930
+ code: u.invalid_string,
931
+ message: i.message
932
+ }), n.dirty()) : i.kind === "base64" ? Us.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
933
+ validation: "base64",
934
+ code: u.invalid_string,
935
+ message: i.message
936
+ }), n.dirty()) : i.kind === "base64url" ? Fs.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
937
+ validation: "base64url",
938
+ code: u.invalid_string,
939
+ message: i.message
940
+ }), n.dirty()) : S.assertNever(i);
941
+ return { status: n.value, value: e.data };
942
+ }
943
+ _regex(e, t, n) {
944
+ return this.refinement((r) => e.test(r), {
945
+ validation: t,
946
+ code: u.invalid_string,
947
+ ...m.errToObj(n)
948
+ });
949
+ }
950
+ _addCheck(e) {
951
+ return new Y({
952
+ ...this._def,
953
+ checks: [...this._def.checks, e]
954
+ });
955
+ }
956
+ email(e) {
957
+ return this._addCheck({ kind: "email", ...m.errToObj(e) });
958
+ }
959
+ url(e) {
960
+ return this._addCheck({ kind: "url", ...m.errToObj(e) });
961
+ }
962
+ emoji(e) {
963
+ return this._addCheck({ kind: "emoji", ...m.errToObj(e) });
964
+ }
965
+ uuid(e) {
966
+ return this._addCheck({ kind: "uuid", ...m.errToObj(e) });
967
+ }
968
+ nanoid(e) {
969
+ return this._addCheck({ kind: "nanoid", ...m.errToObj(e) });
970
+ }
971
+ cuid(e) {
972
+ return this._addCheck({ kind: "cuid", ...m.errToObj(e) });
973
+ }
974
+ cuid2(e) {
975
+ return this._addCheck({ kind: "cuid2", ...m.errToObj(e) });
976
+ }
977
+ ulid(e) {
978
+ return this._addCheck({ kind: "ulid", ...m.errToObj(e) });
979
+ }
980
+ base64(e) {
981
+ return this._addCheck({ kind: "base64", ...m.errToObj(e) });
982
+ }
983
+ base64url(e) {
984
+ return this._addCheck({
985
+ kind: "base64url",
986
+ ...m.errToObj(e)
987
+ });
988
+ }
989
+ jwt(e) {
990
+ return this._addCheck({ kind: "jwt", ...m.errToObj(e) });
991
+ }
992
+ ip(e) {
993
+ return this._addCheck({ kind: "ip", ...m.errToObj(e) });
994
+ }
995
+ cidr(e) {
996
+ return this._addCheck({ kind: "cidr", ...m.errToObj(e) });
997
+ }
998
+ datetime(e) {
999
+ return typeof e == "string" ? this._addCheck({
1000
+ kind: "datetime",
1001
+ precision: null,
1002
+ offset: !1,
1003
+ local: !1,
1004
+ message: e
1005
+ }) : this._addCheck({
1006
+ kind: "datetime",
1007
+ precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
1008
+ offset: (e == null ? void 0 : e.offset) ?? !1,
1009
+ local: (e == null ? void 0 : e.local) ?? !1,
1010
+ ...m.errToObj(e == null ? void 0 : e.message)
1011
+ });
1012
+ }
1013
+ date(e) {
1014
+ return this._addCheck({ kind: "date", message: e });
1015
+ }
1016
+ time(e) {
1017
+ return typeof e == "string" ? this._addCheck({
1018
+ kind: "time",
1019
+ precision: null,
1020
+ message: e
1021
+ }) : this._addCheck({
1022
+ kind: "time",
1023
+ precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
1024
+ ...m.errToObj(e == null ? void 0 : e.message)
1025
+ });
1026
+ }
1027
+ duration(e) {
1028
+ return this._addCheck({ kind: "duration", ...m.errToObj(e) });
1029
+ }
1030
+ regex(e, t) {
1031
+ return this._addCheck({
1032
+ kind: "regex",
1033
+ regex: e,
1034
+ ...m.errToObj(t)
1035
+ });
1036
+ }
1037
+ includes(e, t) {
1038
+ return this._addCheck({
1039
+ kind: "includes",
1040
+ value: e,
1041
+ position: t == null ? void 0 : t.position,
1042
+ ...m.errToObj(t == null ? void 0 : t.message)
1043
+ });
1044
+ }
1045
+ startsWith(e, t) {
1046
+ return this._addCheck({
1047
+ kind: "startsWith",
1048
+ value: e,
1049
+ ...m.errToObj(t)
1050
+ });
1051
+ }
1052
+ endsWith(e, t) {
1053
+ return this._addCheck({
1054
+ kind: "endsWith",
1055
+ value: e,
1056
+ ...m.errToObj(t)
1057
+ });
1058
+ }
1059
+ min(e, t) {
1060
+ return this._addCheck({
1061
+ kind: "min",
1062
+ value: e,
1063
+ ...m.errToObj(t)
1064
+ });
1065
+ }
1066
+ max(e, t) {
1067
+ return this._addCheck({
1068
+ kind: "max",
1069
+ value: e,
1070
+ ...m.errToObj(t)
1071
+ });
1072
+ }
1073
+ length(e, t) {
1074
+ return this._addCheck({
1075
+ kind: "length",
1076
+ value: e,
1077
+ ...m.errToObj(t)
1078
+ });
1079
+ }
1080
+ /**
1081
+ * Equivalent to `.min(1)`
1082
+ */
1083
+ nonempty(e) {
1084
+ return this.min(1, m.errToObj(e));
1085
+ }
1086
+ trim() {
1087
+ return new Y({
1088
+ ...this._def,
1089
+ checks: [...this._def.checks, { kind: "trim" }]
1090
+ });
1091
+ }
1092
+ toLowerCase() {
1093
+ return new Y({
1094
+ ...this._def,
1095
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1096
+ });
1097
+ }
1098
+ toUpperCase() {
1099
+ return new Y({
1100
+ ...this._def,
1101
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1102
+ });
1103
+ }
1104
+ get isDatetime() {
1105
+ return !!this._def.checks.find((e) => e.kind === "datetime");
1106
+ }
1107
+ get isDate() {
1108
+ return !!this._def.checks.find((e) => e.kind === "date");
1109
+ }
1110
+ get isTime() {
1111
+ return !!this._def.checks.find((e) => e.kind === "time");
1112
+ }
1113
+ get isDuration() {
1114
+ return !!this._def.checks.find((e) => e.kind === "duration");
1115
+ }
1116
+ get isEmail() {
1117
+ return !!this._def.checks.find((e) => e.kind === "email");
1118
+ }
1119
+ get isURL() {
1120
+ return !!this._def.checks.find((e) => e.kind === "url");
1121
+ }
1122
+ get isEmoji() {
1123
+ return !!this._def.checks.find((e) => e.kind === "emoji");
1124
+ }
1125
+ get isUUID() {
1126
+ return !!this._def.checks.find((e) => e.kind === "uuid");
1127
+ }
1128
+ get isNANOID() {
1129
+ return !!this._def.checks.find((e) => e.kind === "nanoid");
1130
+ }
1131
+ get isCUID() {
1132
+ return !!this._def.checks.find((e) => e.kind === "cuid");
1133
+ }
1134
+ get isCUID2() {
1135
+ return !!this._def.checks.find((e) => e.kind === "cuid2");
1136
+ }
1137
+ get isULID() {
1138
+ return !!this._def.checks.find((e) => e.kind === "ulid");
1139
+ }
1140
+ get isIP() {
1141
+ return !!this._def.checks.find((e) => e.kind === "ip");
1142
+ }
1143
+ get isCIDR() {
1144
+ return !!this._def.checks.find((e) => e.kind === "cidr");
1145
+ }
1146
+ get isBase64() {
1147
+ return !!this._def.checks.find((e) => e.kind === "base64");
1148
+ }
1149
+ get isBase64url() {
1150
+ return !!this._def.checks.find((e) => e.kind === "base64url");
1151
+ }
1152
+ get minLength() {
1153
+ let e = null;
1154
+ for (const t of this._def.checks)
1155
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1156
+ return e;
1157
+ }
1158
+ get maxLength() {
1159
+ let e = null;
1160
+ for (const t of this._def.checks)
1161
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1162
+ return e;
1163
+ }
1164
+ }
1165
+ Y.create = (s) => new Y({
1166
+ checks: [],
1167
+ typeName: _.ZodString,
1168
+ coerce: (s == null ? void 0 : s.coerce) ?? !1,
1169
+ ...b(s)
1170
+ });
1171
+ function Ys(s, e) {
1172
+ const t = (s.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, r = t > n ? t : n, i = Number.parseInt(s.toFixed(r).replace(".", "")), a = Number.parseInt(e.toFixed(r).replace(".", ""));
1173
+ return i % a / 10 ** r;
1174
+ }
1175
+ class be extends x {
1176
+ constructor() {
1177
+ super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1178
+ }
1179
+ _parse(e) {
1180
+ if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== p.number) {
1181
+ const i = this._getOrReturnCtx(e);
1182
+ return f(i, {
1183
+ code: u.invalid_type,
1184
+ expected: p.number,
1185
+ received: i.parsedType
1186
+ }), v;
1187
+ }
1188
+ let n;
1189
+ const r = new M();
1190
+ for (const i of this._def.checks)
1191
+ i.kind === "int" ? S.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
1192
+ code: u.invalid_type,
1193
+ expected: "integer",
1194
+ received: "float",
1195
+ message: i.message
1196
+ }), r.dirty()) : i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (n = this._getOrReturnCtx(e, n), f(n, {
1197
+ code: u.too_small,
1198
+ minimum: i.value,
1199
+ type: "number",
1200
+ inclusive: i.inclusive,
1201
+ exact: !1,
1202
+ message: i.message
1203
+ }), r.dirty()) : i.kind === "max" ? (i.inclusive ? e.data > i.value : e.data >= i.value) && (n = this._getOrReturnCtx(e, n), f(n, {
1204
+ code: u.too_big,
1205
+ maximum: i.value,
1206
+ type: "number",
1207
+ inclusive: i.inclusive,
1208
+ exact: !1,
1209
+ message: i.message
1210
+ }), r.dirty()) : i.kind === "multipleOf" ? Ys(e.data, i.value) !== 0 && (n = this._getOrReturnCtx(e, n), f(n, {
1211
+ code: u.not_multiple_of,
1212
+ multipleOf: i.value,
1213
+ message: i.message
1214
+ }), r.dirty()) : i.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
1215
+ code: u.not_finite,
1216
+ message: i.message
1217
+ }), r.dirty()) : S.assertNever(i);
1218
+ return { status: r.value, value: e.data };
1219
+ }
1220
+ gte(e, t) {
1221
+ return this.setLimit("min", e, !0, m.toString(t));
1222
+ }
1223
+ gt(e, t) {
1224
+ return this.setLimit("min", e, !1, m.toString(t));
1225
+ }
1226
+ lte(e, t) {
1227
+ return this.setLimit("max", e, !0, m.toString(t));
1228
+ }
1229
+ lt(e, t) {
1230
+ return this.setLimit("max", e, !1, m.toString(t));
1231
+ }
1232
+ setLimit(e, t, n, r) {
1233
+ return new be({
1234
+ ...this._def,
1235
+ checks: [
1236
+ ...this._def.checks,
1237
+ {
1238
+ kind: e,
1239
+ value: t,
1240
+ inclusive: n,
1241
+ message: m.toString(r)
1242
+ }
1243
+ ]
1244
+ });
1245
+ }
1246
+ _addCheck(e) {
1247
+ return new be({
1248
+ ...this._def,
1249
+ checks: [...this._def.checks, e]
1250
+ });
1251
+ }
1252
+ int(e) {
1253
+ return this._addCheck({
1254
+ kind: "int",
1255
+ message: m.toString(e)
1256
+ });
1257
+ }
1258
+ positive(e) {
1259
+ return this._addCheck({
1260
+ kind: "min",
1261
+ value: 0,
1262
+ inclusive: !1,
1263
+ message: m.toString(e)
1264
+ });
1265
+ }
1266
+ negative(e) {
1267
+ return this._addCheck({
1268
+ kind: "max",
1269
+ value: 0,
1270
+ inclusive: !1,
1271
+ message: m.toString(e)
1272
+ });
1273
+ }
1274
+ nonpositive(e) {
1275
+ return this._addCheck({
1276
+ kind: "max",
1277
+ value: 0,
1278
+ inclusive: !0,
1279
+ message: m.toString(e)
1280
+ });
1281
+ }
1282
+ nonnegative(e) {
1283
+ return this._addCheck({
1284
+ kind: "min",
1285
+ value: 0,
1286
+ inclusive: !0,
1287
+ message: m.toString(e)
1288
+ });
1289
+ }
1290
+ multipleOf(e, t) {
1291
+ return this._addCheck({
1292
+ kind: "multipleOf",
1293
+ value: e,
1294
+ message: m.toString(t)
1295
+ });
1296
+ }
1297
+ finite(e) {
1298
+ return this._addCheck({
1299
+ kind: "finite",
1300
+ message: m.toString(e)
1301
+ });
1302
+ }
1303
+ safe(e) {
1304
+ return this._addCheck({
1305
+ kind: "min",
1306
+ inclusive: !0,
1307
+ value: Number.MIN_SAFE_INTEGER,
1308
+ message: m.toString(e)
1309
+ })._addCheck({
1310
+ kind: "max",
1311
+ inclusive: !0,
1312
+ value: Number.MAX_SAFE_INTEGER,
1313
+ message: m.toString(e)
1314
+ });
1315
+ }
1316
+ get minValue() {
1317
+ let e = null;
1318
+ for (const t of this._def.checks)
1319
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1320
+ return e;
1321
+ }
1322
+ get maxValue() {
1323
+ let e = null;
1324
+ for (const t of this._def.checks)
1325
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1326
+ return e;
1327
+ }
1328
+ get isInt() {
1329
+ return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && S.isInteger(e.value));
1330
+ }
1331
+ get isFinite() {
1332
+ let e = null, t = null;
1333
+ for (const n of this._def.checks) {
1334
+ if (n.kind === "finite" || n.kind === "int" || n.kind === "multipleOf")
1335
+ return !0;
1336
+ n.kind === "min" ? (t === null || n.value > t) && (t = n.value) : n.kind === "max" && (e === null || n.value < e) && (e = n.value);
1337
+ }
1338
+ return Number.isFinite(t) && Number.isFinite(e);
1339
+ }
1340
+ }
1341
+ be.create = (s) => new be({
1342
+ checks: [],
1343
+ typeName: _.ZodNumber,
1344
+ coerce: (s == null ? void 0 : s.coerce) || !1,
1345
+ ...b(s)
1346
+ });
1347
+ class $e extends x {
1348
+ constructor() {
1349
+ super(...arguments), this.min = this.gte, this.max = this.lte;
1350
+ }
1351
+ _parse(e) {
1352
+ if (this._def.coerce)
1353
+ try {
1354
+ e.data = BigInt(e.data);
1355
+ } catch {
1356
+ return this._getInvalidInput(e);
1357
+ }
1358
+ if (this._getType(e) !== p.bigint)
1359
+ return this._getInvalidInput(e);
1360
+ let n;
1361
+ const r = new M();
1362
+ for (const i of this._def.checks)
1363
+ i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (n = this._getOrReturnCtx(e, n), f(n, {
1364
+ code: u.too_small,
1365
+ type: "bigint",
1366
+ minimum: i.value,
1367
+ inclusive: i.inclusive,
1368
+ message: i.message
1369
+ }), r.dirty()) : i.kind === "max" ? (i.inclusive ? e.data > i.value : e.data >= i.value) && (n = this._getOrReturnCtx(e, n), f(n, {
1370
+ code: u.too_big,
1371
+ type: "bigint",
1372
+ maximum: i.value,
1373
+ inclusive: i.inclusive,
1374
+ message: i.message
1375
+ }), r.dirty()) : i.kind === "multipleOf" ? e.data % i.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), f(n, {
1376
+ code: u.not_multiple_of,
1377
+ multipleOf: i.value,
1378
+ message: i.message
1379
+ }), r.dirty()) : S.assertNever(i);
1380
+ return { status: r.value, value: e.data };
1381
+ }
1382
+ _getInvalidInput(e) {
1383
+ const t = this._getOrReturnCtx(e);
1384
+ return f(t, {
1385
+ code: u.invalid_type,
1386
+ expected: p.bigint,
1387
+ received: t.parsedType
1388
+ }), v;
1389
+ }
1390
+ gte(e, t) {
1391
+ return this.setLimit("min", e, !0, m.toString(t));
1392
+ }
1393
+ gt(e, t) {
1394
+ return this.setLimit("min", e, !1, m.toString(t));
1395
+ }
1396
+ lte(e, t) {
1397
+ return this.setLimit("max", e, !0, m.toString(t));
1398
+ }
1399
+ lt(e, t) {
1400
+ return this.setLimit("max", e, !1, m.toString(t));
1401
+ }
1402
+ setLimit(e, t, n, r) {
1403
+ return new $e({
1404
+ ...this._def,
1405
+ checks: [
1406
+ ...this._def.checks,
1407
+ {
1408
+ kind: e,
1409
+ value: t,
1410
+ inclusive: n,
1411
+ message: m.toString(r)
1412
+ }
1413
+ ]
1414
+ });
1415
+ }
1416
+ _addCheck(e) {
1417
+ return new $e({
1418
+ ...this._def,
1419
+ checks: [...this._def.checks, e]
1420
+ });
1421
+ }
1422
+ positive(e) {
1423
+ return this._addCheck({
1424
+ kind: "min",
1425
+ value: BigInt(0),
1426
+ inclusive: !1,
1427
+ message: m.toString(e)
1428
+ });
1429
+ }
1430
+ negative(e) {
1431
+ return this._addCheck({
1432
+ kind: "max",
1433
+ value: BigInt(0),
1434
+ inclusive: !1,
1435
+ message: m.toString(e)
1436
+ });
1437
+ }
1438
+ nonpositive(e) {
1439
+ return this._addCheck({
1440
+ kind: "max",
1441
+ value: BigInt(0),
1442
+ inclusive: !0,
1443
+ message: m.toString(e)
1444
+ });
1445
+ }
1446
+ nonnegative(e) {
1447
+ return this._addCheck({
1448
+ kind: "min",
1449
+ value: BigInt(0),
1450
+ inclusive: !0,
1451
+ message: m.toString(e)
1452
+ });
1453
+ }
1454
+ multipleOf(e, t) {
1455
+ return this._addCheck({
1456
+ kind: "multipleOf",
1457
+ value: e,
1458
+ message: m.toString(t)
1459
+ });
1460
+ }
1461
+ get minValue() {
1462
+ let e = null;
1463
+ for (const t of this._def.checks)
1464
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1465
+ return e;
1466
+ }
1467
+ get maxValue() {
1468
+ let e = null;
1469
+ for (const t of this._def.checks)
1470
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1471
+ return e;
1472
+ }
1473
+ }
1474
+ $e.create = (s) => new $e({
1475
+ checks: [],
1476
+ typeName: _.ZodBigInt,
1477
+ coerce: (s == null ? void 0 : s.coerce) ?? !1,
1478
+ ...b(s)
1479
+ });
1480
+ class Zt extends x {
1481
+ _parse(e) {
1482
+ if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== p.boolean) {
1483
+ const n = this._getOrReturnCtx(e);
1484
+ return f(n, {
1485
+ code: u.invalid_type,
1486
+ expected: p.boolean,
1487
+ received: n.parsedType
1488
+ }), v;
1489
+ }
1490
+ return z(e.data);
1491
+ }
1492
+ }
1493
+ Zt.create = (s) => new Zt({
1494
+ typeName: _.ZodBoolean,
1495
+ coerce: (s == null ? void 0 : s.coerce) || !1,
1496
+ ...b(s)
1497
+ });
1498
+ class Fe extends x {
1499
+ _parse(e) {
1500
+ if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== p.date) {
1501
+ const i = this._getOrReturnCtx(e);
1502
+ return f(i, {
1503
+ code: u.invalid_type,
1504
+ expected: p.date,
1505
+ received: i.parsedType
1506
+ }), v;
1507
+ }
1508
+ if (Number.isNaN(e.data.getTime())) {
1509
+ const i = this._getOrReturnCtx(e);
1510
+ return f(i, {
1511
+ code: u.invalid_date
1512
+ }), v;
1513
+ }
1514
+ const n = new M();
1515
+ let r;
1516
+ for (const i of this._def.checks)
1517
+ i.kind === "min" ? e.data.getTime() < i.value && (r = this._getOrReturnCtx(e, r), f(r, {
1518
+ code: u.too_small,
1519
+ message: i.message,
1520
+ inclusive: !0,
1521
+ exact: !1,
1522
+ minimum: i.value,
1523
+ type: "date"
1524
+ }), n.dirty()) : i.kind === "max" ? e.data.getTime() > i.value && (r = this._getOrReturnCtx(e, r), f(r, {
1525
+ code: u.too_big,
1526
+ message: i.message,
1527
+ inclusive: !0,
1528
+ exact: !1,
1529
+ maximum: i.value,
1530
+ type: "date"
1531
+ }), n.dirty()) : S.assertNever(i);
1532
+ return {
1533
+ status: n.value,
1534
+ value: new Date(e.data.getTime())
1535
+ };
1536
+ }
1537
+ _addCheck(e) {
1538
+ return new Fe({
1539
+ ...this._def,
1540
+ checks: [...this._def.checks, e]
1541
+ });
1542
+ }
1543
+ min(e, t) {
1544
+ return this._addCheck({
1545
+ kind: "min",
1546
+ value: e.getTime(),
1547
+ message: m.toString(t)
1548
+ });
1549
+ }
1550
+ max(e, t) {
1551
+ return this._addCheck({
1552
+ kind: "max",
1553
+ value: e.getTime(),
1554
+ message: m.toString(t)
1555
+ });
1556
+ }
1557
+ get minDate() {
1558
+ let e = null;
1559
+ for (const t of this._def.checks)
1560
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1561
+ return e != null ? new Date(e) : null;
1562
+ }
1563
+ get maxDate() {
1564
+ let e = null;
1565
+ for (const t of this._def.checks)
1566
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1567
+ return e != null ? new Date(e) : null;
1568
+ }
1569
+ }
1570
+ Fe.create = (s) => new Fe({
1571
+ checks: [],
1572
+ coerce: (s == null ? void 0 : s.coerce) || !1,
1573
+ typeName: _.ZodDate,
1574
+ ...b(s)
1575
+ });
1576
+ class Vt extends x {
1577
+ _parse(e) {
1578
+ if (this._getType(e) !== p.symbol) {
1579
+ const n = this._getOrReturnCtx(e);
1580
+ return f(n, {
1581
+ code: u.invalid_type,
1582
+ expected: p.symbol,
1583
+ received: n.parsedType
1584
+ }), v;
1585
+ }
1586
+ return z(e.data);
1587
+ }
1588
+ }
1589
+ Vt.create = (s) => new Vt({
1590
+ typeName: _.ZodSymbol,
1591
+ ...b(s)
1592
+ });
1593
+ class ct extends x {
1594
+ _parse(e) {
1595
+ if (this._getType(e) !== p.undefined) {
1596
+ const n = this._getOrReturnCtx(e);
1597
+ return f(n, {
1598
+ code: u.invalid_type,
1599
+ expected: p.undefined,
1600
+ received: n.parsedType
1601
+ }), v;
1602
+ }
1603
+ return z(e.data);
1604
+ }
1605
+ }
1606
+ ct.create = (s) => new ct({
1607
+ typeName: _.ZodUndefined,
1608
+ ...b(s)
1609
+ });
1610
+ class lt extends x {
1611
+ _parse(e) {
1612
+ if (this._getType(e) !== p.null) {
1613
+ const n = this._getOrReturnCtx(e);
1614
+ return f(n, {
1615
+ code: u.invalid_type,
1616
+ expected: p.null,
1617
+ received: n.parsedType
1618
+ }), v;
1619
+ }
1620
+ return z(e.data);
1621
+ }
1622
+ }
1623
+ lt.create = (s) => new lt({
1624
+ typeName: _.ZodNull,
1625
+ ...b(s)
1626
+ });
1627
+ class zt extends x {
1628
+ constructor() {
1629
+ super(...arguments), this._any = !0;
1630
+ }
1631
+ _parse(e) {
1632
+ return z(e.data);
1633
+ }
1634
+ }
1635
+ zt.create = (s) => new zt({
1636
+ typeName: _.ZodAny,
1637
+ ...b(s)
1638
+ });
1639
+ class Bt extends x {
1640
+ constructor() {
1641
+ super(...arguments), this._unknown = !0;
1642
+ }
1643
+ _parse(e) {
1644
+ return z(e.data);
1645
+ }
1646
+ }
1647
+ Bt.create = (s) => new Bt({
1648
+ typeName: _.ZodUnknown,
1649
+ ...b(s)
1650
+ });
1651
+ class ne extends x {
1652
+ _parse(e) {
1653
+ const t = this._getOrReturnCtx(e);
1654
+ return f(t, {
1655
+ code: u.invalid_type,
1656
+ expected: p.never,
1657
+ received: t.parsedType
1658
+ }), v;
1659
+ }
1660
+ }
1661
+ ne.create = (s) => new ne({
1662
+ typeName: _.ZodNever,
1663
+ ...b(s)
1664
+ });
1665
+ class Ut extends x {
1666
+ _parse(e) {
1667
+ if (this._getType(e) !== p.undefined) {
1668
+ const n = this._getOrReturnCtx(e);
1669
+ return f(n, {
1670
+ code: u.invalid_type,
1671
+ expected: p.void,
1672
+ received: n.parsedType
1673
+ }), v;
1674
+ }
1675
+ return z(e.data);
1676
+ }
1677
+ }
1678
+ Ut.create = (s) => new Ut({
1679
+ typeName: _.ZodVoid,
1680
+ ...b(s)
1681
+ });
1682
+ class H extends x {
1683
+ _parse(e) {
1684
+ const { ctx: t, status: n } = this._processInputParams(e), r = this._def;
1685
+ if (t.parsedType !== p.array)
1686
+ return f(t, {
1687
+ code: u.invalid_type,
1688
+ expected: p.array,
1689
+ received: t.parsedType
1690
+ }), v;
1691
+ if (r.exactLength !== null) {
1692
+ const a = t.data.length > r.exactLength.value, o = t.data.length < r.exactLength.value;
1693
+ (a || o) && (f(t, {
1694
+ code: a ? u.too_big : u.too_small,
1695
+ minimum: o ? r.exactLength.value : void 0,
1696
+ maximum: a ? r.exactLength.value : void 0,
1697
+ type: "array",
1698
+ inclusive: !0,
1699
+ exact: !0,
1700
+ message: r.exactLength.message
1701
+ }), n.dirty());
1702
+ }
1703
+ if (r.minLength !== null && t.data.length < r.minLength.value && (f(t, {
1704
+ code: u.too_small,
1705
+ minimum: r.minLength.value,
1706
+ type: "array",
1707
+ inclusive: !0,
1708
+ exact: !1,
1709
+ message: r.minLength.message
1710
+ }), n.dirty()), r.maxLength !== null && t.data.length > r.maxLength.value && (f(t, {
1711
+ code: u.too_big,
1712
+ maximum: r.maxLength.value,
1713
+ type: "array",
1714
+ inclusive: !0,
1715
+ exact: !1,
1716
+ message: r.maxLength.message
1717
+ }), n.dirty()), t.common.async)
1718
+ return Promise.all([...t.data].map((a, o) => r.type._parseAsync(new J(t, a, t.path, o)))).then((a) => M.mergeArray(n, a));
1719
+ const i = [...t.data].map((a, o) => r.type._parseSync(new J(t, a, t.path, o)));
1720
+ return M.mergeArray(n, i);
1721
+ }
1722
+ get element() {
1723
+ return this._def.type;
1724
+ }
1725
+ min(e, t) {
1726
+ return new H({
1727
+ ...this._def,
1728
+ minLength: { value: e, message: m.toString(t) }
1729
+ });
1730
+ }
1731
+ max(e, t) {
1732
+ return new H({
1733
+ ...this._def,
1734
+ maxLength: { value: e, message: m.toString(t) }
1735
+ });
1736
+ }
1737
+ length(e, t) {
1738
+ return new H({
1739
+ ...this._def,
1740
+ exactLength: { value: e, message: m.toString(t) }
1741
+ });
1742
+ }
1743
+ nonempty(e) {
1744
+ return this.min(1, e);
1745
+ }
1746
+ }
1747
+ H.create = (s, e) => new H({
1748
+ type: s,
1749
+ minLength: null,
1750
+ maxLength: null,
1751
+ exactLength: null,
1752
+ typeName: _.ZodArray,
1753
+ ...b(e)
1754
+ });
1755
+ function me(s) {
1756
+ if (s instanceof E) {
1757
+ const e = {};
1758
+ for (const t in s.shape) {
1759
+ const n = s.shape[t];
1760
+ e[t] = G.create(me(n));
1761
+ }
1762
+ return new E({
1763
+ ...s._def,
1764
+ shape: () => e
1765
+ });
1766
+ } else return s instanceof H ? new H({
1767
+ ...s._def,
1768
+ type: me(s.element)
1769
+ }) : s instanceof G ? G.create(me(s.unwrap())) : s instanceof le ? le.create(me(s.unwrap())) : s instanceof ae ? ae.create(s.items.map((e) => me(e))) : s;
1770
+ }
1771
+ class E extends x {
1772
+ constructor() {
1773
+ super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
1774
+ }
1775
+ _getCached() {
1776
+ if (this._cached !== null)
1777
+ return this._cached;
1778
+ const e = this._def.shape(), t = S.objectKeys(e);
1779
+ return this._cached = { shape: e, keys: t }, this._cached;
1780
+ }
1781
+ _parse(e) {
1782
+ if (this._getType(e) !== p.object) {
1783
+ const l = this._getOrReturnCtx(e);
1784
+ return f(l, {
1785
+ code: u.invalid_type,
1786
+ expected: p.object,
1787
+ received: l.parsedType
1788
+ }), v;
1789
+ }
1790
+ const { status: n, ctx: r } = this._processInputParams(e), { shape: i, keys: a } = this._getCached(), o = [];
1791
+ if (!(this._def.catchall instanceof ne && this._def.unknownKeys === "strip"))
1792
+ for (const l in r.data)
1793
+ a.includes(l) || o.push(l);
1794
+ const c = [];
1795
+ for (const l of a) {
1796
+ const d = i[l], h = r.data[l];
1797
+ c.push({
1798
+ key: { status: "valid", value: l },
1799
+ value: d._parse(new J(r, h, r.path, l)),
1800
+ alwaysSet: l in r.data
1801
+ });
1802
+ }
1803
+ if (this._def.catchall instanceof ne) {
1804
+ const l = this._def.unknownKeys;
1805
+ if (l === "passthrough")
1806
+ for (const d of o)
1807
+ c.push({
1808
+ key: { status: "valid", value: d },
1809
+ value: { status: "valid", value: r.data[d] }
1810
+ });
1811
+ else if (l === "strict")
1812
+ o.length > 0 && (f(r, {
1813
+ code: u.unrecognized_keys,
1814
+ keys: o
1815
+ }), n.dirty());
1816
+ else if (l !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1817
+ } else {
1818
+ const l = this._def.catchall;
1819
+ for (const d of o) {
1820
+ const h = r.data[d];
1821
+ c.push({
1822
+ key: { status: "valid", value: d },
1823
+ value: l._parse(
1824
+ new J(r, h, r.path, d)
1825
+ //, ctx.child(key), value, getParsedType(value)
1826
+ ),
1827
+ alwaysSet: d in r.data
1828
+ });
1829
+ }
1830
+ }
1831
+ return r.common.async ? Promise.resolve().then(async () => {
1832
+ const l = [];
1833
+ for (const d of c) {
1834
+ const h = await d.key, y = await d.value;
1835
+ l.push({
1836
+ key: h,
1837
+ value: y,
1838
+ alwaysSet: d.alwaysSet
1839
+ });
1840
+ }
1841
+ return l;
1842
+ }).then((l) => M.mergeObjectSync(n, l)) : M.mergeObjectSync(n, c);
1843
+ }
1844
+ get shape() {
1845
+ return this._def.shape();
1846
+ }
1847
+ strict(e) {
1848
+ return m.errToObj, new E({
1849
+ ...this._def,
1850
+ unknownKeys: "strict",
1851
+ ...e !== void 0 ? {
1852
+ errorMap: (t, n) => {
1853
+ var i, a;
1854
+ const r = ((a = (i = this._def).errorMap) == null ? void 0 : a.call(i, t, n).message) ?? n.defaultError;
1855
+ return t.code === "unrecognized_keys" ? {
1856
+ message: m.errToObj(e).message ?? r
1857
+ } : {
1858
+ message: r
1859
+ };
1860
+ }
1861
+ } : {}
1862
+ });
1863
+ }
1864
+ strip() {
1865
+ return new E({
1866
+ ...this._def,
1867
+ unknownKeys: "strip"
1868
+ });
1869
+ }
1870
+ passthrough() {
1871
+ return new E({
1872
+ ...this._def,
1873
+ unknownKeys: "passthrough"
1874
+ });
1875
+ }
1876
+ // const AugmentFactory =
1877
+ // <Def extends ZodObjectDef>(def: Def) =>
1878
+ // <Augmentation extends ZodRawShape>(
1879
+ // augmentation: Augmentation
1880
+ // ): ZodObject<
1881
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
1882
+ // Def["unknownKeys"],
1883
+ // Def["catchall"]
1884
+ // > => {
1885
+ // return new ZodObject({
1886
+ // ...def,
1887
+ // shape: () => ({
1888
+ // ...def.shape(),
1889
+ // ...augmentation,
1890
+ // }),
1891
+ // }) as any;
1892
+ // };
1893
+ extend(e) {
1894
+ return new E({
1895
+ ...this._def,
1896
+ shape: () => ({
1897
+ ...this._def.shape(),
1898
+ ...e
1899
+ })
1900
+ });
1901
+ }
1902
+ /**
1903
+ * Prior to zod@1.0.12 there was a bug in the
1904
+ * inferred type of merged objects. Please
1905
+ * upgrade if you are experiencing issues.
1906
+ */
1907
+ merge(e) {
1908
+ return new E({
1909
+ unknownKeys: e._def.unknownKeys,
1910
+ catchall: e._def.catchall,
1911
+ shape: () => ({
1912
+ ...this._def.shape(),
1913
+ ...e._def.shape()
1914
+ }),
1915
+ typeName: _.ZodObject
1916
+ });
1917
+ }
1918
+ // merge<
1919
+ // Incoming extends AnyZodObject,
1920
+ // Augmentation extends Incoming["shape"],
1921
+ // NewOutput extends {
1922
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1923
+ // ? Augmentation[k]["_output"]
1924
+ // : k extends keyof Output
1925
+ // ? Output[k]
1926
+ // : never;
1927
+ // },
1928
+ // NewInput extends {
1929
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1930
+ // ? Augmentation[k]["_input"]
1931
+ // : k extends keyof Input
1932
+ // ? Input[k]
1933
+ // : never;
1934
+ // }
1935
+ // >(
1936
+ // merging: Incoming
1937
+ // ): ZodObject<
1938
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1939
+ // Incoming["_def"]["unknownKeys"],
1940
+ // Incoming["_def"]["catchall"],
1941
+ // NewOutput,
1942
+ // NewInput
1943
+ // > {
1944
+ // const merged: any = new ZodObject({
1945
+ // unknownKeys: merging._def.unknownKeys,
1946
+ // catchall: merging._def.catchall,
1947
+ // shape: () =>
1948
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1949
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1950
+ // }) as any;
1951
+ // return merged;
1952
+ // }
1953
+ setKey(e, t) {
1954
+ return this.augment({ [e]: t });
1955
+ }
1956
+ // merge<Incoming extends AnyZodObject>(
1957
+ // merging: Incoming
1958
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
1959
+ // ZodObject<
1960
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1961
+ // Incoming["_def"]["unknownKeys"],
1962
+ // Incoming["_def"]["catchall"]
1963
+ // > {
1964
+ // // const mergedShape = objectUtil.mergeShapes(
1965
+ // // this._def.shape(),
1966
+ // // merging._def.shape()
1967
+ // // );
1968
+ // const merged: any = new ZodObject({
1969
+ // unknownKeys: merging._def.unknownKeys,
1970
+ // catchall: merging._def.catchall,
1971
+ // shape: () =>
1972
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1973
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1974
+ // }) as any;
1975
+ // return merged;
1976
+ // }
1977
+ catchall(e) {
1978
+ return new E({
1979
+ ...this._def,
1980
+ catchall: e
1981
+ });
1982
+ }
1983
+ pick(e) {
1984
+ const t = {};
1985
+ for (const n of S.objectKeys(e))
1986
+ e[n] && this.shape[n] && (t[n] = this.shape[n]);
1987
+ return new E({
1988
+ ...this._def,
1989
+ shape: () => t
1990
+ });
1991
+ }
1992
+ omit(e) {
1993
+ const t = {};
1994
+ for (const n of S.objectKeys(this.shape))
1995
+ e[n] || (t[n] = this.shape[n]);
1996
+ return new E({
1997
+ ...this._def,
1998
+ shape: () => t
1999
+ });
2000
+ }
2001
+ /**
2002
+ * @deprecated
2003
+ */
2004
+ deepPartial() {
2005
+ return me(this);
2006
+ }
2007
+ partial(e) {
2008
+ const t = {};
2009
+ for (const n of S.objectKeys(this.shape)) {
2010
+ const r = this.shape[n];
2011
+ e && !e[n] ? t[n] = r : t[n] = r.optional();
2012
+ }
2013
+ return new E({
2014
+ ...this._def,
2015
+ shape: () => t
2016
+ });
2017
+ }
2018
+ required(e) {
2019
+ const t = {};
2020
+ for (const n of S.objectKeys(this.shape))
2021
+ if (e && !e[n])
2022
+ t[n] = this.shape[n];
2023
+ else {
2024
+ let i = this.shape[n];
2025
+ for (; i instanceof G; )
2026
+ i = i._def.innerType;
2027
+ t[n] = i;
2028
+ }
2029
+ return new E({
2030
+ ...this._def,
2031
+ shape: () => t
2032
+ });
2033
+ }
2034
+ keyof() {
2035
+ return es(S.objectKeys(this.shape));
2036
+ }
2037
+ }
2038
+ E.create = (s, e) => new E({
2039
+ shape: () => s,
2040
+ unknownKeys: "strip",
2041
+ catchall: ne.create(),
2042
+ typeName: _.ZodObject,
2043
+ ...b(e)
2044
+ });
2045
+ E.strictCreate = (s, e) => new E({
2046
+ shape: () => s,
2047
+ unknownKeys: "strict",
2048
+ catchall: ne.create(),
2049
+ typeName: _.ZodObject,
2050
+ ...b(e)
2051
+ });
2052
+ E.lazycreate = (s, e) => new E({
2053
+ shape: s,
2054
+ unknownKeys: "strip",
2055
+ catchall: ne.create(),
2056
+ typeName: _.ZodObject,
2057
+ ...b(e)
2058
+ });
2059
+ class De extends x {
2060
+ _parse(e) {
2061
+ const { ctx: t } = this._processInputParams(e), n = this._def.options;
2062
+ function r(i) {
2063
+ for (const o of i)
2064
+ if (o.result.status === "valid")
2065
+ return o.result;
2066
+ for (const o of i)
2067
+ if (o.result.status === "dirty")
2068
+ return t.common.issues.push(...o.ctx.common.issues), o.result;
2069
+ const a = i.map((o) => new Q(o.ctx.common.issues));
2070
+ return f(t, {
2071
+ code: u.invalid_union,
2072
+ unionErrors: a
2073
+ }), v;
2074
+ }
2075
+ if (t.common.async)
2076
+ return Promise.all(n.map(async (i) => {
2077
+ const a = {
2078
+ ...t,
2079
+ common: {
2080
+ ...t.common,
2081
+ issues: []
2082
+ },
2083
+ parent: null
2084
+ };
2085
+ return {
2086
+ result: await i._parseAsync({
2087
+ data: t.data,
2088
+ path: t.path,
2089
+ parent: a
2090
+ }),
2091
+ ctx: a
2092
+ };
2093
+ })).then(r);
2094
+ {
2095
+ let i;
2096
+ const a = [];
2097
+ for (const c of n) {
2098
+ const l = {
2099
+ ...t,
2100
+ common: {
2101
+ ...t.common,
2102
+ issues: []
2103
+ },
2104
+ parent: null
2105
+ }, d = c._parseSync({
2106
+ data: t.data,
2107
+ path: t.path,
2108
+ parent: l
2109
+ });
2110
+ if (d.status === "valid")
2111
+ return d;
2112
+ d.status === "dirty" && !i && (i = { result: d, ctx: l }), l.common.issues.length && a.push(l.common.issues);
2113
+ }
2114
+ if (i)
2115
+ return t.common.issues.push(...i.ctx.common.issues), i.result;
2116
+ const o = a.map((c) => new Q(c));
2117
+ return f(t, {
2118
+ code: u.invalid_union,
2119
+ unionErrors: o
2120
+ }), v;
2121
+ }
2122
+ }
2123
+ get options() {
2124
+ return this._def.options;
2125
+ }
2126
+ }
2127
+ De.create = (s, e) => new De({
2128
+ options: s,
2129
+ typeName: _.ZodUnion,
2130
+ ...b(e)
2131
+ });
2132
+ const X = (s) => s instanceof dt ? X(s.schema) : s instanceof ce ? X(s.innerType()) : s instanceof He ? [s.value] : s instanceof oe ? s.options : s instanceof ft ? S.objectValues(s.enum) : s instanceof Xe ? X(s._def.innerType) : s instanceof ct ? [void 0] : s instanceof lt ? [null] : s instanceof G ? [void 0, ...X(s.unwrap())] : s instanceof le ? [null, ...X(s.unwrap())] : s instanceof ts || s instanceof Ge ? X(s.unwrap()) : s instanceof Ye ? X(s._def.innerType) : [];
2133
+ class yt extends x {
2134
+ _parse(e) {
2135
+ const { ctx: t } = this._processInputParams(e);
2136
+ if (t.parsedType !== p.object)
2137
+ return f(t, {
2138
+ code: u.invalid_type,
2139
+ expected: p.object,
2140
+ received: t.parsedType
2141
+ }), v;
2142
+ const n = this.discriminator, r = t.data[n], i = this.optionsMap.get(r);
2143
+ return i ? t.common.async ? i._parseAsync({
2144
+ data: t.data,
2145
+ path: t.path,
2146
+ parent: t
2147
+ }) : i._parseSync({
2148
+ data: t.data,
2149
+ path: t.path,
2150
+ parent: t
2151
+ }) : (f(t, {
2152
+ code: u.invalid_union_discriminator,
2153
+ options: Array.from(this.optionsMap.keys()),
2154
+ path: [n]
2155
+ }), v);
2156
+ }
2157
+ get discriminator() {
2158
+ return this._def.discriminator;
2159
+ }
2160
+ get options() {
2161
+ return this._def.options;
2162
+ }
2163
+ get optionsMap() {
2164
+ return this._def.optionsMap;
2165
+ }
2166
+ /**
2167
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2168
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2169
+ * have a different value for each object in the union.
2170
+ * @param discriminator the name of the discriminator property
2171
+ * @param types an array of object schemas
2172
+ * @param params
2173
+ */
2174
+ static create(e, t, n) {
2175
+ const r = /* @__PURE__ */ new Map();
2176
+ for (const i of t) {
2177
+ const a = X(i.shape[e]);
2178
+ if (!a.length)
2179
+ throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
2180
+ for (const o of a) {
2181
+ if (r.has(o))
2182
+ throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
2183
+ r.set(o, i);
2184
+ }
2185
+ }
2186
+ return new yt({
2187
+ typeName: _.ZodDiscriminatedUnion,
2188
+ discriminator: e,
2189
+ options: t,
2190
+ optionsMap: r,
2191
+ ...b(n)
2192
+ });
2193
+ }
2194
+ }
2195
+ function ut(s, e) {
2196
+ const t = te(s), n = te(e);
2197
+ if (s === e)
2198
+ return { valid: !0, data: s };
2199
+ if (t === p.object && n === p.object) {
2200
+ const r = S.objectKeys(e), i = S.objectKeys(s).filter((o) => r.indexOf(o) !== -1), a = { ...s, ...e };
2201
+ for (const o of i) {
2202
+ const c = ut(s[o], e[o]);
2203
+ if (!c.valid)
2204
+ return { valid: !1 };
2205
+ a[o] = c.data;
2206
+ }
2207
+ return { valid: !0, data: a };
2208
+ } else if (t === p.array && n === p.array) {
2209
+ if (s.length !== e.length)
2210
+ return { valid: !1 };
2211
+ const r = [];
2212
+ for (let i = 0; i < s.length; i++) {
2213
+ const a = s[i], o = e[i], c = ut(a, o);
2214
+ if (!c.valid)
2215
+ return { valid: !1 };
2216
+ r.push(c.data);
2217
+ }
2218
+ return { valid: !0, data: r };
2219
+ } else return t === p.date && n === p.date && +s == +e ? { valid: !0, data: s } : { valid: !1 };
2220
+ }
2221
+ class We extends x {
2222
+ _parse(e) {
2223
+ const { status: t, ctx: n } = this._processInputParams(e), r = (i, a) => {
2224
+ if (Mt(i) || Mt(a))
2225
+ return v;
2226
+ const o = ut(i.value, a.value);
2227
+ return o.valid ? ((Lt(i) || Lt(a)) && t.dirty(), { status: t.value, value: o.data }) : (f(n, {
2228
+ code: u.invalid_intersection_types
2229
+ }), v);
2230
+ };
2231
+ return n.common.async ? Promise.all([
2232
+ this._def.left._parseAsync({
2233
+ data: n.data,
2234
+ path: n.path,
2235
+ parent: n
2236
+ }),
2237
+ this._def.right._parseAsync({
2238
+ data: n.data,
2239
+ path: n.path,
2240
+ parent: n
2241
+ })
2242
+ ]).then(([i, a]) => r(i, a)) : r(this._def.left._parseSync({
2243
+ data: n.data,
2244
+ path: n.path,
2245
+ parent: n
2246
+ }), this._def.right._parseSync({
2247
+ data: n.data,
2248
+ path: n.path,
2249
+ parent: n
2250
+ }));
2251
+ }
2252
+ }
2253
+ We.create = (s, e, t) => new We({
2254
+ left: s,
2255
+ right: e,
2256
+ typeName: _.ZodIntersection,
2257
+ ...b(t)
2258
+ });
2259
+ class ae extends x {
2260
+ _parse(e) {
2261
+ const { status: t, ctx: n } = this._processInputParams(e);
2262
+ if (n.parsedType !== p.array)
2263
+ return f(n, {
2264
+ code: u.invalid_type,
2265
+ expected: p.array,
2266
+ received: n.parsedType
2267
+ }), v;
2268
+ if (n.data.length < this._def.items.length)
2269
+ return f(n, {
2270
+ code: u.too_small,
2271
+ minimum: this._def.items.length,
2272
+ inclusive: !0,
2273
+ exact: !1,
2274
+ type: "array"
2275
+ }), v;
2276
+ !this._def.rest && n.data.length > this._def.items.length && (f(n, {
2277
+ code: u.too_big,
2278
+ maximum: this._def.items.length,
2279
+ inclusive: !0,
2280
+ exact: !1,
2281
+ type: "array"
2282
+ }), t.dirty());
2283
+ const i = [...n.data].map((a, o) => {
2284
+ const c = this._def.items[o] || this._def.rest;
2285
+ return c ? c._parse(new J(n, a, n.path, o)) : null;
2286
+ }).filter((a) => !!a);
2287
+ return n.common.async ? Promise.all(i).then((a) => M.mergeArray(t, a)) : M.mergeArray(t, i);
2288
+ }
2289
+ get items() {
2290
+ return this._def.items;
2291
+ }
2292
+ rest(e) {
2293
+ return new ae({
2294
+ ...this._def,
2295
+ rest: e
2296
+ });
2297
+ }
2298
+ }
2299
+ ae.create = (s, e) => {
2300
+ if (!Array.isArray(s))
2301
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2302
+ return new ae({
2303
+ items: s,
2304
+ typeName: _.ZodTuple,
2305
+ rest: null,
2306
+ ...b(e)
2307
+ });
2308
+ };
2309
+ class qe extends x {
2310
+ get keySchema() {
2311
+ return this._def.keyType;
2312
+ }
2313
+ get valueSchema() {
2314
+ return this._def.valueType;
2315
+ }
2316
+ _parse(e) {
2317
+ const { status: t, ctx: n } = this._processInputParams(e);
2318
+ if (n.parsedType !== p.object)
2319
+ return f(n, {
2320
+ code: u.invalid_type,
2321
+ expected: p.object,
2322
+ received: n.parsedType
2323
+ }), v;
2324
+ const r = [], i = this._def.keyType, a = this._def.valueType;
2325
+ for (const o in n.data)
2326
+ r.push({
2327
+ key: i._parse(new J(n, o, n.path, o)),
2328
+ value: a._parse(new J(n, n.data[o], n.path, o)),
2329
+ alwaysSet: o in n.data
2330
+ });
2331
+ return n.common.async ? M.mergeObjectAsync(t, r) : M.mergeObjectSync(t, r);
2332
+ }
2333
+ get element() {
2334
+ return this._def.valueType;
2335
+ }
2336
+ static create(e, t, n) {
2337
+ return t instanceof x ? new qe({
2338
+ keyType: e,
2339
+ valueType: t,
2340
+ typeName: _.ZodRecord,
2341
+ ...b(n)
2342
+ }) : new qe({
2343
+ keyType: Y.create(),
2344
+ valueType: e,
2345
+ typeName: _.ZodRecord,
2346
+ ...b(t)
2347
+ });
2348
+ }
2349
+ }
2350
+ class Ft extends x {
2351
+ get keySchema() {
2352
+ return this._def.keyType;
2353
+ }
2354
+ get valueSchema() {
2355
+ return this._def.valueType;
2356
+ }
2357
+ _parse(e) {
2358
+ const { status: t, ctx: n } = this._processInputParams(e);
2359
+ if (n.parsedType !== p.map)
2360
+ return f(n, {
2361
+ code: u.invalid_type,
2362
+ expected: p.map,
2363
+ received: n.parsedType
2364
+ }), v;
2365
+ const r = this._def.keyType, i = this._def.valueType, a = [...n.data.entries()].map(([o, c], l) => ({
2366
+ key: r._parse(new J(n, o, n.path, [l, "key"])),
2367
+ value: i._parse(new J(n, c, n.path, [l, "value"]))
2368
+ }));
2369
+ if (n.common.async) {
2370
+ const o = /* @__PURE__ */ new Map();
2371
+ return Promise.resolve().then(async () => {
2372
+ for (const c of a) {
2373
+ const l = await c.key, d = await c.value;
2374
+ if (l.status === "aborted" || d.status === "aborted")
2375
+ return v;
2376
+ (l.status === "dirty" || d.status === "dirty") && t.dirty(), o.set(l.value, d.value);
2377
+ }
2378
+ return { status: t.value, value: o };
2379
+ });
2380
+ } else {
2381
+ const o = /* @__PURE__ */ new Map();
2382
+ for (const c of a) {
2383
+ const l = c.key, d = c.value;
2384
+ if (l.status === "aborted" || d.status === "aborted")
2385
+ return v;
2386
+ (l.status === "dirty" || d.status === "dirty") && t.dirty(), o.set(l.value, d.value);
2387
+ }
2388
+ return { status: t.value, value: o };
2389
+ }
2390
+ }
2391
+ }
2392
+ Ft.create = (s, e, t) => new Ft({
2393
+ valueType: e,
2394
+ keyType: s,
2395
+ typeName: _.ZodMap,
2396
+ ...b(t)
2397
+ });
2398
+ class Oe extends x {
2399
+ _parse(e) {
2400
+ const { status: t, ctx: n } = this._processInputParams(e);
2401
+ if (n.parsedType !== p.set)
2402
+ return f(n, {
2403
+ code: u.invalid_type,
2404
+ expected: p.set,
2405
+ received: n.parsedType
2406
+ }), v;
2407
+ const r = this._def;
2408
+ r.minSize !== null && n.data.size < r.minSize.value && (f(n, {
2409
+ code: u.too_small,
2410
+ minimum: r.minSize.value,
2411
+ type: "set",
2412
+ inclusive: !0,
2413
+ exact: !1,
2414
+ message: r.minSize.message
2415
+ }), t.dirty()), r.maxSize !== null && n.data.size > r.maxSize.value && (f(n, {
2416
+ code: u.too_big,
2417
+ maximum: r.maxSize.value,
2418
+ type: "set",
2419
+ inclusive: !0,
2420
+ exact: !1,
2421
+ message: r.maxSize.message
2422
+ }), t.dirty());
2423
+ const i = this._def.valueType;
2424
+ function a(c) {
2425
+ const l = /* @__PURE__ */ new Set();
2426
+ for (const d of c) {
2427
+ if (d.status === "aborted")
2428
+ return v;
2429
+ d.status === "dirty" && t.dirty(), l.add(d.value);
2430
+ }
2431
+ return { status: t.value, value: l };
2432
+ }
2433
+ const o = [...n.data.values()].map((c, l) => i._parse(new J(n, c, n.path, l)));
2434
+ return n.common.async ? Promise.all(o).then((c) => a(c)) : a(o);
2435
+ }
2436
+ min(e, t) {
2437
+ return new Oe({
2438
+ ...this._def,
2439
+ minSize: { value: e, message: m.toString(t) }
2440
+ });
2441
+ }
2442
+ max(e, t) {
2443
+ return new Oe({
2444
+ ...this._def,
2445
+ maxSize: { value: e, message: m.toString(t) }
2446
+ });
2447
+ }
2448
+ size(e, t) {
2449
+ return this.min(e, t).max(e, t);
2450
+ }
2451
+ nonempty(e) {
2452
+ return this.min(1, e);
2453
+ }
2454
+ }
2455
+ Oe.create = (s, e) => new Oe({
2456
+ valueType: s,
2457
+ minSize: null,
2458
+ maxSize: null,
2459
+ typeName: _.ZodSet,
2460
+ ...b(e)
2461
+ });
2462
+ class dt extends x {
2463
+ get schema() {
2464
+ return this._def.getter();
2465
+ }
2466
+ _parse(e) {
2467
+ const { ctx: t } = this._processInputParams(e);
2468
+ return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
2469
+ }
2470
+ }
2471
+ dt.create = (s, e) => new dt({
2472
+ getter: s,
2473
+ typeName: _.ZodLazy,
2474
+ ...b(e)
2475
+ });
2476
+ class He extends x {
2477
+ _parse(e) {
2478
+ if (e.data !== this._def.value) {
2479
+ const t = this._getOrReturnCtx(e);
2480
+ return f(t, {
2481
+ received: t.data,
2482
+ code: u.invalid_literal,
2483
+ expected: this._def.value
2484
+ }), v;
2485
+ }
2486
+ return { status: "valid", value: e.data };
2487
+ }
2488
+ get value() {
2489
+ return this._def.value;
2490
+ }
2491
+ }
2492
+ He.create = (s, e) => new He({
2493
+ value: s,
2494
+ typeName: _.ZodLiteral,
2495
+ ...b(e)
2496
+ });
2497
+ function es(s, e) {
2498
+ return new oe({
2499
+ values: s,
2500
+ typeName: _.ZodEnum,
2501
+ ...b(e)
2502
+ });
2503
+ }
2504
+ class oe extends x {
2505
+ _parse(e) {
2506
+ if (typeof e.data != "string") {
2507
+ const t = this._getOrReturnCtx(e), n = this._def.values;
2508
+ return f(t, {
2509
+ expected: S.joinValues(n),
2510
+ received: t.parsedType,
2511
+ code: u.invalid_type
2512
+ }), v;
2513
+ }
2514
+ if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
2515
+ const t = this._getOrReturnCtx(e), n = this._def.values;
2516
+ return f(t, {
2517
+ received: t.data,
2518
+ code: u.invalid_enum_value,
2519
+ options: n
2520
+ }), v;
2521
+ }
2522
+ return z(e.data);
2523
+ }
2524
+ get options() {
2525
+ return this._def.values;
2526
+ }
2527
+ get enum() {
2528
+ const e = {};
2529
+ for (const t of this._def.values)
2530
+ e[t] = t;
2531
+ return e;
2532
+ }
2533
+ get Values() {
2534
+ const e = {};
2535
+ for (const t of this._def.values)
2536
+ e[t] = t;
2537
+ return e;
2538
+ }
2539
+ get Enum() {
2540
+ const e = {};
2541
+ for (const t of this._def.values)
2542
+ e[t] = t;
2543
+ return e;
2544
+ }
2545
+ extract(e, t = this._def) {
2546
+ return oe.create(e, {
2547
+ ...this._def,
2548
+ ...t
2549
+ });
2550
+ }
2551
+ exclude(e, t = this._def) {
2552
+ return oe.create(this.options.filter((n) => !e.includes(n)), {
2553
+ ...this._def,
2554
+ ...t
2555
+ });
2556
+ }
2557
+ }
2558
+ oe.create = es;
2559
+ class ft extends x {
2560
+ _parse(e) {
2561
+ const t = S.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
2562
+ if (n.parsedType !== p.string && n.parsedType !== p.number) {
2563
+ const r = S.objectValues(t);
2564
+ return f(n, {
2565
+ expected: S.joinValues(r),
2566
+ received: n.parsedType,
2567
+ code: u.invalid_type
2568
+ }), v;
2569
+ }
2570
+ if (this._cache || (this._cache = new Set(S.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
2571
+ const r = S.objectValues(t);
2572
+ return f(n, {
2573
+ received: n.data,
2574
+ code: u.invalid_enum_value,
2575
+ options: r
2576
+ }), v;
2577
+ }
2578
+ return z(e.data);
2579
+ }
2580
+ get enum() {
2581
+ return this._def.values;
2582
+ }
2583
+ }
2584
+ ft.create = (s, e) => new ft({
2585
+ values: s,
2586
+ typeName: _.ZodNativeEnum,
2587
+ ...b(e)
2588
+ });
2589
+ class Je extends x {
2590
+ unwrap() {
2591
+ return this._def.type;
2592
+ }
2593
+ _parse(e) {
2594
+ const { ctx: t } = this._processInputParams(e);
2595
+ if (t.parsedType !== p.promise && t.common.async === !1)
2596
+ return f(t, {
2597
+ code: u.invalid_type,
2598
+ expected: p.promise,
2599
+ received: t.parsedType
2600
+ }), v;
2601
+ const n = t.parsedType === p.promise ? t.data : Promise.resolve(t.data);
2602
+ return z(n.then((r) => this._def.type.parseAsync(r, {
2603
+ path: t.path,
2604
+ errorMap: t.common.contextualErrorMap
2605
+ })));
2606
+ }
2607
+ }
2608
+ Je.create = (s, e) => new Je({
2609
+ type: s,
2610
+ typeName: _.ZodPromise,
2611
+ ...b(e)
2612
+ });
2613
+ class ce extends x {
2614
+ innerType() {
2615
+ return this._def.schema;
2616
+ }
2617
+ sourceType() {
2618
+ return this._def.schema._def.typeName === _.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2619
+ }
2620
+ _parse(e) {
2621
+ const { status: t, ctx: n } = this._processInputParams(e), r = this._def.effect || null, i = {
2622
+ addIssue: (a) => {
2623
+ f(n, a), a.fatal ? t.abort() : t.dirty();
2624
+ },
2625
+ get path() {
2626
+ return n.path;
2627
+ }
2628
+ };
2629
+ if (i.addIssue = i.addIssue.bind(i), r.type === "preprocess") {
2630
+ const a = r.transform(n.data, i);
2631
+ if (n.common.async)
2632
+ return Promise.resolve(a).then(async (o) => {
2633
+ if (t.value === "aborted")
2634
+ return v;
2635
+ const c = await this._def.schema._parseAsync({
2636
+ data: o,
2637
+ path: n.path,
2638
+ parent: n
2639
+ });
2640
+ return c.status === "aborted" ? v : c.status === "dirty" || t.value === "dirty" ? Te(c.value) : c;
2641
+ });
2642
+ {
2643
+ if (t.value === "aborted")
2644
+ return v;
2645
+ const o = this._def.schema._parseSync({
2646
+ data: a,
2647
+ path: n.path,
2648
+ parent: n
2649
+ });
2650
+ return o.status === "aborted" ? v : o.status === "dirty" || t.value === "dirty" ? Te(o.value) : o;
2651
+ }
2652
+ }
2653
+ if (r.type === "refinement") {
2654
+ const a = (o) => {
2655
+ const c = r.refinement(o, i);
2656
+ if (n.common.async)
2657
+ return Promise.resolve(c);
2658
+ if (c instanceof Promise)
2659
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2660
+ return o;
2661
+ };
2662
+ if (n.common.async === !1) {
2663
+ const o = this._def.schema._parseSync({
2664
+ data: n.data,
2665
+ path: n.path,
2666
+ parent: n
2667
+ });
2668
+ return o.status === "aborted" ? v : (o.status === "dirty" && t.dirty(), a(o.value), { status: t.value, value: o.value });
2669
+ } else
2670
+ return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => o.status === "aborted" ? v : (o.status === "dirty" && t.dirty(), a(o.value).then(() => ({ status: t.value, value: o.value }))));
2671
+ }
2672
+ if (r.type === "transform")
2673
+ if (n.common.async === !1) {
2674
+ const a = this._def.schema._parseSync({
2675
+ data: n.data,
2676
+ path: n.path,
2677
+ parent: n
2678
+ });
2679
+ if (!_e(a))
2680
+ return v;
2681
+ const o = r.transform(a.value, i);
2682
+ if (o instanceof Promise)
2683
+ throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2684
+ return { status: t.value, value: o };
2685
+ } else
2686
+ return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((a) => _e(a) ? Promise.resolve(r.transform(a.value, i)).then((o) => ({
2687
+ status: t.value,
2688
+ value: o
2689
+ })) : v);
2690
+ S.assertNever(r);
2691
+ }
2692
+ }
2693
+ ce.create = (s, e, t) => new ce({
2694
+ schema: s,
2695
+ typeName: _.ZodEffects,
2696
+ effect: e,
2697
+ ...b(t)
2698
+ });
2699
+ ce.createWithPreprocess = (s, e, t) => new ce({
2700
+ schema: e,
2701
+ effect: { type: "preprocess", transform: s },
2702
+ typeName: _.ZodEffects,
2703
+ ...b(t)
2704
+ });
2705
+ class G extends x {
2706
+ _parse(e) {
2707
+ return this._getType(e) === p.undefined ? z(void 0) : this._def.innerType._parse(e);
2708
+ }
2709
+ unwrap() {
2710
+ return this._def.innerType;
2711
+ }
2712
+ }
2713
+ G.create = (s, e) => new G({
2714
+ innerType: s,
2715
+ typeName: _.ZodOptional,
2716
+ ...b(e)
2717
+ });
2718
+ class le extends x {
2719
+ _parse(e) {
2720
+ return this._getType(e) === p.null ? z(null) : this._def.innerType._parse(e);
2721
+ }
2722
+ unwrap() {
2723
+ return this._def.innerType;
2724
+ }
2725
+ }
2726
+ le.create = (s, e) => new le({
2727
+ innerType: s,
2728
+ typeName: _.ZodNullable,
2729
+ ...b(e)
2730
+ });
2731
+ class Xe extends x {
2732
+ _parse(e) {
2733
+ const { ctx: t } = this._processInputParams(e);
2734
+ let n = t.data;
2735
+ return t.parsedType === p.undefined && (n = this._def.defaultValue()), this._def.innerType._parse({
2736
+ data: n,
2737
+ path: t.path,
2738
+ parent: t
2739
+ });
2740
+ }
2741
+ removeDefault() {
2742
+ return this._def.innerType;
2743
+ }
2744
+ }
2745
+ Xe.create = (s, e) => new Xe({
2746
+ innerType: s,
2747
+ typeName: _.ZodDefault,
2748
+ defaultValue: typeof e.default == "function" ? e.default : () => e.default,
2749
+ ...b(e)
2750
+ });
2751
+ class Ye extends x {
2752
+ _parse(e) {
2753
+ const { ctx: t } = this._processInputParams(e), n = {
2754
+ ...t,
2755
+ common: {
2756
+ ...t.common,
2757
+ issues: []
2758
+ }
2759
+ }, r = this._def.innerType._parse({
2760
+ data: n.data,
2761
+ path: n.path,
2762
+ parent: {
2763
+ ...n
2764
+ }
2765
+ });
2766
+ return Ue(r) ? r.then((i) => ({
2767
+ status: "valid",
2768
+ value: i.status === "valid" ? i.value : this._def.catchValue({
2769
+ get error() {
2770
+ return new Q(n.common.issues);
2771
+ },
2772
+ input: n.data
2773
+ })
2774
+ })) : {
2775
+ status: "valid",
2776
+ value: r.status === "valid" ? r.value : this._def.catchValue({
2777
+ get error() {
2778
+ return new Q(n.common.issues);
2779
+ },
2780
+ input: n.data
2781
+ })
2782
+ };
2783
+ }
2784
+ removeCatch() {
2785
+ return this._def.innerType;
2786
+ }
2787
+ }
2788
+ Ye.create = (s, e) => new Ye({
2789
+ innerType: s,
2790
+ typeName: _.ZodCatch,
2791
+ catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
2792
+ ...b(e)
2793
+ });
2794
+ class Dt extends x {
2795
+ _parse(e) {
2796
+ if (this._getType(e) !== p.nan) {
2797
+ const n = this._getOrReturnCtx(e);
2798
+ return f(n, {
2799
+ code: u.invalid_type,
2800
+ expected: p.nan,
2801
+ received: n.parsedType
2802
+ }), v;
2803
+ }
2804
+ return { status: "valid", value: e.data };
2805
+ }
2806
+ }
2807
+ Dt.create = (s) => new Dt({
2808
+ typeName: _.ZodNaN,
2809
+ ...b(s)
2810
+ });
2811
+ class ts extends x {
2812
+ _parse(e) {
2813
+ const { ctx: t } = this._processInputParams(e), n = t.data;
2814
+ return this._def.type._parse({
2815
+ data: n,
2816
+ path: t.path,
2817
+ parent: t
2818
+ });
2819
+ }
2820
+ unwrap() {
2821
+ return this._def.type;
2822
+ }
2823
+ }
2824
+ class vt extends x {
2825
+ _parse(e) {
2826
+ const { status: t, ctx: n } = this._processInputParams(e);
2827
+ if (n.common.async)
2828
+ return (async () => {
2829
+ const i = await this._def.in._parseAsync({
2830
+ data: n.data,
2831
+ path: n.path,
2832
+ parent: n
2833
+ });
2834
+ return i.status === "aborted" ? v : i.status === "dirty" ? (t.dirty(), Te(i.value)) : this._def.out._parseAsync({
2835
+ data: i.value,
2836
+ path: n.path,
2837
+ parent: n
2838
+ });
2839
+ })();
2840
+ {
2841
+ const r = this._def.in._parseSync({
2842
+ data: n.data,
2843
+ path: n.path,
2844
+ parent: n
2845
+ });
2846
+ return r.status === "aborted" ? v : r.status === "dirty" ? (t.dirty(), {
2847
+ status: "dirty",
2848
+ value: r.value
2849
+ }) : this._def.out._parseSync({
2850
+ data: r.value,
2851
+ path: n.path,
2852
+ parent: n
2853
+ });
2854
+ }
2855
+ }
2856
+ static create(e, t) {
2857
+ return new vt({
2858
+ in: e,
2859
+ out: t,
2860
+ typeName: _.ZodPipeline
2861
+ });
2862
+ }
2863
+ }
2864
+ class Ge extends x {
2865
+ _parse(e) {
2866
+ const t = this._def.innerType._parse(e), n = (r) => (_e(r) && (r.value = Object.freeze(r.value)), r);
2867
+ return Ue(t) ? t.then((r) => n(r)) : n(t);
2868
+ }
2869
+ unwrap() {
2870
+ return this._def.innerType;
2871
+ }
2872
+ }
2873
+ Ge.create = (s, e) => new Ge({
2874
+ innerType: s,
2875
+ typeName: _.ZodReadonly,
2876
+ ...b(e)
2877
+ });
2878
+ var _;
2879
+ (function(s) {
2880
+ s.ZodString = "ZodString", s.ZodNumber = "ZodNumber", s.ZodNaN = "ZodNaN", s.ZodBigInt = "ZodBigInt", s.ZodBoolean = "ZodBoolean", s.ZodDate = "ZodDate", s.ZodSymbol = "ZodSymbol", s.ZodUndefined = "ZodUndefined", s.ZodNull = "ZodNull", s.ZodAny = "ZodAny", s.ZodUnknown = "ZodUnknown", s.ZodNever = "ZodNever", s.ZodVoid = "ZodVoid", s.ZodArray = "ZodArray", s.ZodObject = "ZodObject", s.ZodUnion = "ZodUnion", s.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", s.ZodIntersection = "ZodIntersection", s.ZodTuple = "ZodTuple", s.ZodRecord = "ZodRecord", s.ZodMap = "ZodMap", s.ZodSet = "ZodSet", s.ZodFunction = "ZodFunction", s.ZodLazy = "ZodLazy", s.ZodLiteral = "ZodLiteral", s.ZodEnum = "ZodEnum", s.ZodEffects = "ZodEffects", s.ZodNativeEnum = "ZodNativeEnum", s.ZodOptional = "ZodOptional", s.ZodNullable = "ZodNullable", s.ZodDefault = "ZodDefault", s.ZodCatch = "ZodCatch", s.ZodPromise = "ZodPromise", s.ZodBranded = "ZodBranded", s.ZodPipeline = "ZodPipeline", s.ZodReadonly = "ZodReadonly";
2881
+ })(_ || (_ = {}));
2882
+ const k = Y.create, se = be.create;
2883
+ ne.create;
2884
+ const Pe = H.create, N = E.create, Re = De.create, ss = yt.create;
2885
+ We.create;
2886
+ ae.create;
2887
+ const Gs = qe.create, ie = He.create, ve = oe.create;
2888
+ Je.create;
2889
+ G.create;
2890
+ le.create;
2891
+ const Ve = Re([se(), k()]), _t = N({
2892
+ x: Ve.optional().default(0),
2893
+ y: Ve.optional().default(0),
2894
+ width: Ve.optional(),
2895
+ height: Ve.optional(),
2896
+ fit: ve(["contain", "cover", "fill", "none"]).optional(),
2897
+ horizontalAlign: ve(["left", "center", "right"]).optional(),
2898
+ verticalAlign: ve(["top", "center", "bottom"]).optional()
2899
+ }), Qs = N({
2900
+ id: k(),
2901
+ start: se(),
2902
+ end: se(),
2903
+ text: k().optional()
2904
+ }), Ks = ss("type", [
2905
+ N({
2906
+ type: ie("image"),
2907
+ src: k()
2908
+ }),
2909
+ N({
2910
+ type: ie("audio"),
2911
+ src: k(),
2912
+ channel: ve(["vo", "sfx", "music"]).optional().default("vo")
2913
+ }),
2914
+ N({
2915
+ type: ie("vtt"),
2916
+ src: k()
2917
+ }),
2918
+ N({
2919
+ type: ie("html"),
2920
+ src: k()
2921
+ })
2922
+ ]), en = Re([
2923
+ N({ play: k() }),
2924
+ N({
2925
+ toggleClass: N({
2926
+ target: k(),
2927
+ className: k()
2928
+ })
2929
+ })
2930
+ ]), tn = N({
2931
+ id: k(),
2932
+ type: ie("text"),
2933
+ layout: _t.optional().default({}),
2934
+ html: k().optional(),
2935
+ htmlSrc: k().optional(),
2936
+ style: N({
2937
+ fontFamily: k().optional(),
2938
+ fontSize: k().optional(),
2939
+ color: k().optional(),
2940
+ textAlign: ve(["left", "center", "right"]).optional(),
2941
+ lineHeight: Re([k(), se()]).optional()
2942
+ }).optional()
2943
+ }), sn = N({
2944
+ id: k(),
2945
+ type: ie("image"),
2946
+ asset: k(),
2947
+ layout: _t.optional().default({}),
2948
+ className: k().optional()
2949
+ }), nn = N({
2950
+ id: k(),
2951
+ type: ie("hotspot"),
2952
+ layout: _t.optional().default({}),
2953
+ onTap: Pe(en).optional().default([]),
2954
+ ariaLabel: k().optional()
2955
+ }), rn = ss("type", [
2956
+ tn,
2957
+ sn,
2958
+ nn
2959
+ ]), an = N({
2960
+ id: k(),
2961
+ background: N({
2962
+ asset: k().optional(),
2963
+ color: k().optional()
2964
+ }).optional(),
2965
+ readAloud: N({
2966
+ audio: k(),
2967
+ cues: Re([k(), Pe(Qs)]).optional()
2968
+ }).optional(),
2969
+ blocks: Pe(rn).optional().default([])
2970
+ }), on = N({
2971
+ id: k(),
2972
+ title: k().optional(),
2973
+ pageSize: N({
2974
+ width: se().positive(),
2975
+ height: se().positive()
2976
+ }),
2977
+ layout: N({
2978
+ mode: ve(["single", "two-page", "auto"]).default("auto"),
2979
+ singleBreakpoint: se().positive().default(900)
2980
+ }).default({ mode: "auto", singleBreakpoint: 900 }),
2981
+ fonts: Pe(
2982
+ N({
2983
+ family: k(),
2984
+ src: k(),
2985
+ weight: Re([k(), se()]).optional(),
2986
+ style: k().optional()
2987
+ })
2988
+ ).optional().default([]),
2989
+ assets: Gs(Ks).optional().default({}),
2990
+ pages: Pe(an).min(1)
2991
+ });
2992
+ function Me(s) {
2993
+ return on.parse(s);
2994
+ }
2995
+ function Wt(s) {
2996
+ const e = s.replace(/^\uFEFF/, "").replace(/\r\n/g, `
2997
+ `).trim();
2998
+ if (!e.startsWith("WEBVTT"))
2999
+ throw new Error("Invalid WebVTT: missing WEBVTT header");
3000
+ const n = e.slice(e.indexOf(`
3001
+ `) + 1).split(/\n\n+/), r = [];
3002
+ let i = 0;
3003
+ for (const a of n) {
3004
+ const o = a.split(`
3005
+ `).map((w) => w.trim()).filter((w) => w.length > 0 && !w.startsWith("NOTE"));
3006
+ if (o.length === 0) continue;
3007
+ const c = o.findIndex((w) => w.includes("-->"));
3008
+ if (c === -1) continue;
3009
+ const l = c > 0 ? o[0] : void 0, d = o[c], h = o.slice(c + 1), y = d.split("-->").map((w) => w.trim().split(/\s+/)[0]);
3010
+ if (y.length < 2) continue;
3011
+ const I = qt(y[0]), O = qt(y[1]), T = h.join(" ").trim(), A = l || T || `cue-${i++}`;
3012
+ r.push({
3013
+ id: A,
3014
+ start: I,
3015
+ end: O,
3016
+ text: T || void 0
3017
+ });
3018
+ }
3019
+ return r;
3020
+ }
3021
+ function qt(s) {
3022
+ const e = s.trim().split(":");
3023
+ if (e.length === 3) {
3024
+ const [t, n, r] = e;
3025
+ return Number(t) * 3600 + Number(n) * 60 + Number(r);
3026
+ }
3027
+ if (e.length === 2) {
3028
+ const [t, n] = e;
3029
+ return Number(t) * 60 + Number(n);
3030
+ }
3031
+ return Number(s);
3032
+ }
3033
+ function Be(s, e) {
3034
+ if (/^(?:[a-z]+:)?\/\//i.test(e) || e.startsWith("data:") || e.startsWith("blob:") || !s)
3035
+ return e;
3036
+ try {
3037
+ return new URL(e, ht(s)).href;
3038
+ } catch {
3039
+ return `${ht(s)}${e.replace(/^\//, "")}`;
3040
+ }
3041
+ }
3042
+ function ht(s) {
3043
+ return s.endsWith("/") || s.includes("?") ? s.endsWith("/") ? s : `${s}/` : /\.[a-z0-9]+$/i.test(s.split("/").pop() ?? "") ? s.replace(/[^/]+$/, "") : `${s}/`;
3044
+ }
3045
+ function cn(s) {
3046
+ try {
3047
+ const e = new URL(s, typeof location < "u" ? location.href : "http://local/");
3048
+ e.hash = "";
3049
+ const t = e.pathname;
3050
+ return e.pathname = t.replace(/[^/]+$/, ""), e.href;
3051
+ } catch {
3052
+ return ht(s.replace(/[^/]+$/, ""));
3053
+ }
3054
+ }
3055
+ async function Ee(s, e) {
3056
+ typeof document > "u" || !("fonts" in document) || await Promise.all(
3057
+ s.fonts.map(async (t) => {
3058
+ const n = Be(e, t.src), i = await new FontFace(t.family, `url(${JSON.stringify(n)})`, {
3059
+ weight: t.weight != null ? String(t.weight) : "normal",
3060
+ style: t.style ?? "normal"
3061
+ }).load();
3062
+ document.fonts.add(i);
3063
+ })
3064
+ );
3065
+ }
3066
+ var Z = Uint8Array, ge = Uint16Array, ln = Int32Array, ns = new Z([
3067
+ 0,
3068
+ 0,
3069
+ 0,
3070
+ 0,
3071
+ 0,
3072
+ 0,
3073
+ 0,
3074
+ 0,
3075
+ 1,
3076
+ 1,
3077
+ 1,
3078
+ 1,
3079
+ 2,
3080
+ 2,
3081
+ 2,
3082
+ 2,
3083
+ 3,
3084
+ 3,
3085
+ 3,
3086
+ 3,
3087
+ 4,
3088
+ 4,
3089
+ 4,
3090
+ 4,
3091
+ 5,
3092
+ 5,
3093
+ 5,
3094
+ 5,
3095
+ 0,
3096
+ /* unused */
3097
+ 0,
3098
+ 0,
3099
+ /* impossible */
3100
+ 0
3101
+ ]), rs = new Z([
3102
+ 0,
3103
+ 0,
3104
+ 0,
3105
+ 0,
3106
+ 1,
3107
+ 1,
3108
+ 2,
3109
+ 2,
3110
+ 3,
3111
+ 3,
3112
+ 4,
3113
+ 4,
3114
+ 5,
3115
+ 5,
3116
+ 6,
3117
+ 6,
3118
+ 7,
3119
+ 7,
3120
+ 8,
3121
+ 8,
3122
+ 9,
3123
+ 9,
3124
+ 10,
3125
+ 10,
3126
+ 11,
3127
+ 11,
3128
+ 12,
3129
+ 12,
3130
+ 13,
3131
+ 13,
3132
+ /* unused */
3133
+ 0,
3134
+ 0
3135
+ ]), un = new Z([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), is = function(s, e) {
3136
+ for (var t = new ge(31), n = 0; n < 31; ++n)
3137
+ t[n] = e += 1 << s[n - 1];
3138
+ for (var r = new ln(t[30]), n = 1; n < 30; ++n)
3139
+ for (var i = t[n]; i < t[n + 1]; ++i)
3140
+ r[i] = i - t[n] << 5 | n;
3141
+ return { b: t, r };
3142
+ }, as = is(ns, 2), os = as.b, dn = as.r;
3143
+ os[28] = 258, dn[258] = 28;
3144
+ var fn = is(rs, 0), hn = fn.b, pt = new ge(32768);
3145
+ for (var C = 0; C < 32768; ++C) {
3146
+ var ee = (C & 43690) >> 1 | (C & 21845) << 1;
3147
+ ee = (ee & 52428) >> 2 | (ee & 13107) << 2, ee = (ee & 61680) >> 4 | (ee & 3855) << 4, pt[C] = ((ee & 65280) >> 8 | (ee & 255) << 8) >> 1;
3148
+ }
3149
+ var Ne = (function(s, e, t) {
3150
+ for (var n = s.length, r = 0, i = new ge(e); r < n; ++r)
3151
+ s[r] && ++i[s[r] - 1];
3152
+ var a = new ge(e);
3153
+ for (r = 1; r < e; ++r)
3154
+ a[r] = a[r - 1] + i[r - 1] << 1;
3155
+ var o;
3156
+ if (t) {
3157
+ o = new ge(1 << e);
3158
+ var c = 15 - e;
3159
+ for (r = 0; r < n; ++r)
3160
+ if (s[r])
3161
+ for (var l = r << 4 | s[r], d = e - s[r], h = a[s[r] - 1]++ << d, y = h | (1 << d) - 1; h <= y; ++h)
3162
+ o[pt[h] >> c] = l;
3163
+ } else
3164
+ for (o = new ge(n), r = 0; r < n; ++r)
3165
+ s[r] && (o[r] = pt[a[s[r] - 1]++] >> 15 - s[r]);
3166
+ return o;
3167
+ }), Le = new Z(288);
3168
+ for (var C = 0; C < 144; ++C)
3169
+ Le[C] = 8;
3170
+ for (var C = 144; C < 256; ++C)
3171
+ Le[C] = 9;
3172
+ for (var C = 256; C < 280; ++C)
3173
+ Le[C] = 7;
3174
+ for (var C = 280; C < 288; ++C)
3175
+ Le[C] = 8;
3176
+ var cs = new Z(32);
3177
+ for (var C = 0; C < 32; ++C)
3178
+ cs[C] = 5;
3179
+ var pn = /* @__PURE__ */ Ne(Le, 9, 1), mn = /* @__PURE__ */ Ne(cs, 5, 1), rt = function(s) {
3180
+ for (var e = s[0], t = 1; t < s.length; ++t)
3181
+ s[t] > e && (e = s[t]);
3182
+ return e;
3183
+ }, U = function(s, e, t) {
3184
+ var n = e / 8 | 0;
3185
+ return (s[n] | s[n + 1] << 8) >> (e & 7) & t;
3186
+ }, it = function(s, e) {
3187
+ var t = e / 8 | 0;
3188
+ return (s[t] | s[t + 1] << 8 | s[t + 2] << 16) >> (e & 7);
3189
+ }, gn = function(s) {
3190
+ return (s + 7) / 8 | 0;
3191
+ }, bt = function(s, e, t) {
3192
+ return (e == null || e < 0) && (e = 0), (t == null || t > s.length) && (t = s.length), new Z(s.subarray(e, t));
3193
+ }, yn = [
3194
+ "unexpected EOF",
3195
+ "invalid block type",
3196
+ "invalid length/literal",
3197
+ "invalid distance",
3198
+ "stream finished",
3199
+ "no stream handler",
3200
+ ,
3201
+ // determined by compression function
3202
+ "no callback",
3203
+ "invalid UTF-8 data",
3204
+ "extra field too long",
3205
+ "date not in range 1980-2099",
3206
+ "filename too long",
3207
+ "stream finishing",
3208
+ "invalid zip data"
3209
+ // determined by unknown compression method
3210
+ ], j = function(s, e, t) {
3211
+ var n = new Error(e || yn[s]);
3212
+ if (n.code = s, Error.captureStackTrace && Error.captureStackTrace(n, j), !t)
3213
+ throw n;
3214
+ return n;
3215
+ }, vn = function(s, e, t, n) {
3216
+ var r = s.length, i = n ? n.length : 0;
3217
+ if (!r || e.f && !e.l)
3218
+ return t || new Z(0);
3219
+ var a = !t, o = a || e.i != 2, c = e.i;
3220
+ a && (t = new Z(r * 3));
3221
+ var l = function(Nt) {
3222
+ var It = t.length;
3223
+ if (Nt > It) {
3224
+ var $t = new Z(Math.max(It * 2, Nt));
3225
+ $t.set(t), t = $t;
3226
+ }
3227
+ }, d = e.f || 0, h = e.p || 0, y = e.b || 0, I = e.l, O = e.d, T = e.m, A = e.n, w = r * 8;
3228
+ do {
3229
+ if (!I) {
3230
+ d = U(s, h, 1);
3231
+ var P = U(s, h + 1, 3);
3232
+ if (h += 3, P)
3233
+ if (P == 1)
3234
+ I = pn, O = mn, T = 9, A = 5;
3235
+ else if (P == 2) {
3236
+ var de = U(s, h, 31) + 257, je = U(s, h + 10, 15) + 4, Ze = de + U(s, h + 5, 31) + 1;
3237
+ h += 14;
3238
+ for (var re = new Z(Ze), xe = new Z(19), R = 0; R < je; ++R)
3239
+ xe[un[R]] = U(s, h + R * 3, 7);
3240
+ h += je * 3;
3241
+ for (var fe = rt(xe), ke = (1 << fe) - 1, L = Ne(xe, fe, 1), R = 0; R < Ze; ) {
3242
+ var B = L[U(s, h, ke)];
3243
+ h += B & 15;
3244
+ var $ = B >> 4;
3245
+ if ($ < 16)
3246
+ re[R++] = $;
3247
+ else {
3248
+ var F = 0, he = 0;
3249
+ for ($ == 16 ? (he = 3 + U(s, h, 3), h += 2, F = re[R - 1]) : $ == 17 ? (he = 3 + U(s, h, 7), h += 3) : $ == 18 && (he = 11 + U(s, h, 127), h += 7); he--; )
3250
+ re[R++] = F;
3251
+ }
3252
+ }
3253
+ var Se = re.subarray(0, de), K = re.subarray(de);
3254
+ T = rt(Se), A = rt(K), I = Ne(Se, T, 1), O = Ne(K, A, 1);
3255
+ } else
3256
+ j(1);
3257
+ else {
3258
+ var $ = gn(h) + 4, we = s[$ - 4] | s[$ - 3] << 8, ue = $ + we;
3259
+ if (ue > r) {
3260
+ c && j(0);
3261
+ break;
3262
+ }
3263
+ o && l(y + we), t.set(s.subarray($, ue), y), e.b = y += we, e.p = h = ue * 8, e.f = d;
3264
+ continue;
3265
+ }
3266
+ if (h > w) {
3267
+ c && j(0);
3268
+ break;
3269
+ }
3270
+ }
3271
+ o && l(y + 131072);
3272
+ for (var ys = (1 << T) - 1, vs = (1 << A) - 1, Ke = h; ; Ke = h) {
3273
+ var F = I[it(s, h) & ys], pe = F >> 4;
3274
+ if (h += F & 15, h > w) {
3275
+ c && j(0);
3276
+ break;
3277
+ }
3278
+ if (F || j(2), pe < 256)
3279
+ t[y++] = pe;
3280
+ else if (pe == 256) {
3281
+ Ke = h, I = null;
3282
+ break;
3283
+ } else {
3284
+ var Tt = pe - 254;
3285
+ if (pe > 264) {
3286
+ var R = pe - 257, Ae = ns[R];
3287
+ Tt = U(s, h, (1 << Ae) - 1) + os[R], h += Ae;
3288
+ }
3289
+ var et = O[it(s, h) & vs], tt = et >> 4;
3290
+ et || j(3), h += et & 15;
3291
+ var K = hn[tt];
3292
+ if (tt > 3) {
3293
+ var Ae = rs[tt];
3294
+ K += it(s, h) & (1 << Ae) - 1, h += Ae;
3295
+ }
3296
+ if (h > w) {
3297
+ c && j(0);
3298
+ break;
3299
+ }
3300
+ o && l(y + 131072);
3301
+ var Ct = y + Tt;
3302
+ if (y < K) {
3303
+ var Et = i - K, _s = Math.min(K, Ct);
3304
+ for (Et + y < 0 && j(3); y < _s; ++y)
3305
+ t[y] = n[Et + y];
3306
+ }
3307
+ for (; y < Ct; ++y)
3308
+ t[y] = t[y - K];
3309
+ }
3310
+ }
3311
+ e.l = I, e.p = Ke, e.b = y, e.f = d, I && (d = 1, e.m = T, e.d = O, e.n = A);
3312
+ } while (!d);
3313
+ return y != t.length && a ? bt(t, 0, y) : t.subarray(0, y);
3314
+ }, _n = /* @__PURE__ */ new Z(0), D = function(s, e) {
3315
+ return s[e] | s[e + 1] << 8;
3316
+ }, V = function(s, e) {
3317
+ return (s[e] | s[e + 1] << 8 | s[e + 2] << 16 | s[e + 3] << 24) >>> 0;
3318
+ }, at = function(s, e) {
3319
+ return V(s, e) + V(s, e + 4) * 4294967296;
3320
+ };
3321
+ function bn(s, e) {
3322
+ return vn(s, { i: 2 }, e && e.out, e && e.dictionary);
3323
+ }
3324
+ var mt = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), wn = 0;
3325
+ try {
3326
+ mt.decode(_n, { stream: !0 }), wn = 1;
3327
+ } catch {
3328
+ }
3329
+ var xn = function(s) {
3330
+ for (var e = "", t = 0; ; ) {
3331
+ var n = s[t++], r = (n > 127) + (n > 223) + (n > 239);
3332
+ if (t + r > s.length)
3333
+ return { s: e, r: bt(s, t - 1) };
3334
+ r ? r == 3 ? (n = ((n & 15) << 18 | (s[t++] & 63) << 12 | (s[t++] & 63) << 6 | s[t++] & 63) - 65536, e += String.fromCharCode(55296 | n >> 10, 56320 | n & 1023)) : r & 1 ? e += String.fromCharCode((n & 31) << 6 | s[t++] & 63) : e += String.fromCharCode((n & 15) << 12 | (s[t++] & 63) << 6 | s[t++] & 63) : e += String.fromCharCode(n);
3335
+ }
3336
+ };
3337
+ function ls(s, e) {
3338
+ if (e) {
3339
+ for (var t = "", n = 0; n < s.length; n += 16384)
3340
+ t += String.fromCharCode.apply(null, s.subarray(n, n + 16384));
3341
+ return t;
3342
+ } else {
3343
+ if (mt)
3344
+ return mt.decode(s);
3345
+ var r = xn(s), i = r.s, t = r.r;
3346
+ return t.length && j(8), i;
3347
+ }
3348
+ }
3349
+ var kn = function(s, e) {
3350
+ return e + 30 + D(s, e + 26) + D(s, e + 28);
3351
+ }, Sn = function(s, e, t) {
3352
+ var n = D(s, e + 28), r = D(s, e + 30), i = ls(s.subarray(e + 46, e + 46 + n), !(D(s, e + 8) & 2048)), a = e + 46 + n, o = An(s, a, r, t, V(s, e + 20), V(s, e + 24), V(s, e + 42)), c = o[0], l = o[1], d = o[2];
3353
+ return [D(s, e + 10), c, l, i, a + r + D(s, e + 32), d];
3354
+ }, An = function(s, e, t, n, r, i, a) {
3355
+ var o = r == 4294967295, c = i == 4294967295, l = a == 4294967295, d = e + t, h = o + c + l;
3356
+ if (n && h) {
3357
+ for (; e + 4 < d; e += 4 + D(s, e + 2))
3358
+ if (D(s, e) == 1)
3359
+ return [
3360
+ o ? at(s, e + 4 + 8 * c) : r,
3361
+ c ? at(s, e + 4) : i,
3362
+ l ? at(s, e + 4 + 8 * (c + o)) : a,
3363
+ 1
3364
+ ];
3365
+ n < 2 && j(13);
3366
+ }
3367
+ return [r, i, a, 0];
3368
+ };
3369
+ function Tn(s, e) {
3370
+ for (var t = {}, n = s.length - 22; V(s, n) != 101010256; --n)
3371
+ (!n || s.length - n > 65558) && j(13);
3372
+ var r = D(s, n + 8);
3373
+ if (!r)
3374
+ return {};
3375
+ var i = V(s, n + 16), a = V(s, n - 20) == 117853008;
3376
+ if (a) {
3377
+ var o = V(s, n - 12);
3378
+ a = V(s, o) == 101075792, a && (r = V(s, o + 32), i = V(s, o + 48));
3379
+ }
3380
+ for (var c = 0; c < r; ++c) {
3381
+ var l = Sn(s, i, a), d = l[0], h = l[1], y = l[2], I = l[3], O = l[4], T = l[5], A = kn(s, T);
3382
+ i = O, d ? d == 8 ? t[I] = bn(s.subarray(A, A + h), { out: new Z(y) }) : j(14, "unknown compression type " + d) : t[I] = bt(s, A, A + h);
3383
+ }
3384
+ return t;
3385
+ }
3386
+ const Ht = [80, 75];
3387
+ function wt(s) {
3388
+ return s.length >= 2 && s[0] === Ht[0] && s[1] === Ht[1];
3389
+ }
3390
+ function xt(s) {
3391
+ const e = s instanceof Uint8Array ? s : new Uint8Array(s);
3392
+ if (!wt(e))
3393
+ throw new Error("Not a ZIP archive");
3394
+ const t = Tn(e), n = /* @__PURE__ */ new Map();
3395
+ for (const [r, i] of Object.entries(t))
3396
+ !i || r.endsWith("/") || n.set(q(r), i);
3397
+ return n;
3398
+ }
3399
+ function q(s) {
3400
+ return s.replace(/\\/g, "/").replace(/^\.\//, "").replace(/^\/+/, "");
3401
+ }
3402
+ function Ce(s, e) {
3403
+ const t = Qe(s, e);
3404
+ if (!t)
3405
+ throw new Error(`Missing zip entry: ${e}`);
3406
+ return ls(t);
3407
+ }
3408
+ function Qe(s, e) {
3409
+ const t = q(e);
3410
+ if (s.has(t)) return s.get(t);
3411
+ const n = t.toLowerCase();
3412
+ for (const [r, i] of s)
3413
+ if (r.toLowerCase() === n) return i;
3414
+ }
3415
+ function Cn(s) {
3416
+ return [...s.keys()];
3417
+ }
3418
+ function En(s) {
3419
+ var t;
3420
+ switch (((t = s.split(".").pop()) == null ? void 0 : t.toLowerCase()) ?? "") {
3421
+ case "png":
3422
+ return "image/png";
3423
+ case "jpg":
3424
+ case "jpeg":
3425
+ return "image/jpeg";
3426
+ case "gif":
3427
+ return "image/gif";
3428
+ case "webp":
3429
+ return "image/webp";
3430
+ case "svg":
3431
+ return "image/svg+xml";
3432
+ case "mp3":
3433
+ return "audio/mpeg";
3434
+ case "wav":
3435
+ return "audio/wav";
3436
+ case "ogg":
3437
+ return "audio/ogg";
3438
+ case "m4a":
3439
+ return "audio/mp4";
3440
+ case "webm":
3441
+ return "audio/webm";
3442
+ case "vtt":
3443
+ return "text/vtt";
3444
+ case "html":
3445
+ case "xhtml":
3446
+ case "htm":
3447
+ return "application/xhtml+xml";
3448
+ case "css":
3449
+ return "text/css";
3450
+ case "json":
3451
+ return "application/json";
3452
+ case "woff":
3453
+ return "font/woff";
3454
+ case "woff2":
3455
+ return "font/woff2";
3456
+ case "ttf":
3457
+ return "font/ttf";
3458
+ case "otf":
3459
+ return "font/otf";
3460
+ default:
3461
+ return "application/octet-stream";
3462
+ }
3463
+ }
3464
+ function us(s, e) {
3465
+ const t = new Uint8Array(s.byteLength);
3466
+ t.set(s);
3467
+ const n = new Blob([t.buffer], { type: En(e) });
3468
+ return URL.createObjectURL(n);
3469
+ }
3470
+ async function Nn(s) {
3471
+ const e = await fetch(s);
3472
+ if (!e.ok)
3473
+ throw new Error(`Failed to fetch ${s}: ${e.status}`);
3474
+ return e.arrayBuffer();
3475
+ }
3476
+ function fr(s) {
3477
+ return ds(xt(s));
3478
+ }
3479
+ function ds(s) {
3480
+ const e = Ce(s, "META-INF/container.xml"), t = W(e, /full-path\s*=\s*"([^"]+)"/i);
3481
+ if (!t)
3482
+ throw new Error("Invalid EPUB: missing rootfile in container.xml");
3483
+ const n = q(t), r = n.includes("/") ? n.replace(/\/[^/]+$/, "/") : "", i = Ce(s, n), a = Xt(i, "dc:title") || Xt(i, "title") || "EPUB Story", o = Pn(i) ?? { width: 768, height: 1024 }, c = $n(i, r), l = On(i), d = [], h = /* @__PURE__ */ new Map(), y = (A) => {
3484
+ const w = q(A);
3485
+ if (h.has(w)) return h.get(w);
3486
+ const P = Qe(s, w);
3487
+ if (!P)
3488
+ throw new Error(`EPUB missing file: ${w}`);
3489
+ const $ = us(P, w);
3490
+ return d.push($), h.set(w, $), $;
3491
+ }, I = {}, O = [];
3492
+ if (l.forEach((A, w) => {
3493
+ const P = c.get(A);
3494
+ if (!P || !/html|xml/i.test(P.mediaType) && !P.href.match(/\.x?html?$/i)) return;
3495
+ const $ = P.href, we = Ce(s, $), ue = $.includes("/") ? $.replace(/\/[^/]+$/, "/") : "", de = `page-${w + 1}`, je = Mn(we), { html: Ze, imageHrefs: re } = Ln(je, ue, (L) => {
3496
+ const B = q(L.includes(":") ? L : `${ue}${L}`);
3497
+ try {
3498
+ return y(B);
3499
+ } catch {
3500
+ return L;
3501
+ }
3502
+ }), xe = [
3503
+ {
3504
+ id: `${de}-text`,
3505
+ type: "text",
3506
+ layout: { x: "5%", y: "5%", width: "90%", height: "90%" },
3507
+ html: Ze
3508
+ }
3509
+ ], R = re[0];
3510
+ let fe;
3511
+ if (R) {
3512
+ const L = `img-${w}-0`;
3513
+ I[L] = { type: "image", src: y(R) }, fe = { asset: L, color: "#ffffff" };
3514
+ } else
3515
+ fe = { color: "#ffffff" };
3516
+ let ke;
3517
+ if (P.mediaOverlay) {
3518
+ const L = c.get(P.mediaOverlay);
3519
+ if (L) {
3520
+ const B = Rn(Ce(s, L.href), L.href);
3521
+ if (B.audioHref) {
3522
+ const F = `vo-${w}`, he = q(
3523
+ B.audioHref.includes("/") || B.audioHref.startsWith(".") ? fs(L.href, B.audioHref) : `${r}${B.audioHref}`
3524
+ );
3525
+ I[F] = { type: "audio", src: y(he), channel: "vo" };
3526
+ const Se = B.cues;
3527
+ Se.length ? ke = { audio: F, cues: Se } : ke = { audio: F };
3528
+ }
3529
+ }
3530
+ }
3531
+ O.push({
3532
+ id: de,
3533
+ background: fe,
3534
+ readAloud: ke,
3535
+ blocks: xe
3536
+ });
3537
+ }), O.length === 0)
3538
+ throw new Error("Invalid EPUB: no spine HTML documents found");
3539
+ return { story: Me({
3540
+ id: `epub-${jn(a)}`,
3541
+ title: a,
3542
+ pageSize: o,
3543
+ layout: { mode: "auto", singleBreakpoint: 900 },
3544
+ fonts: [],
3545
+ assets: I,
3546
+ pages: O
3547
+ }), blobUrls: d };
3548
+ }
3549
+ function In(s) {
3550
+ return !!Qe(s, "META-INF/container.xml");
3551
+ }
3552
+ function $n(s, e) {
3553
+ const t = /* @__PURE__ */ new Map(), n = /<item\b[^>]*>/gi;
3554
+ let r;
3555
+ for (; r = n.exec(s); ) {
3556
+ const i = r[0], a = W(i, /\bid\s*=\s*"([^"]+)"/i), o = W(i, /\bhref\s*=\s*"([^"]+)"/i), c = W(i, /\bmedia-type\s*=\s*"([^"]+)"/i) ?? "", l = W(i, /\bmedia-overlay\s*=\s*"([^"]+)"/i) ?? void 0, d = W(i, /\bproperties\s*=\s*"([^"]+)"/i) ?? void 0;
3557
+ !a || !o || t.set(a, {
3558
+ id: a,
3559
+ href: q(`${e}${o}`),
3560
+ mediaType: c,
3561
+ mediaOverlay: l,
3562
+ properties: d
3563
+ });
3564
+ }
3565
+ return t;
3566
+ }
3567
+ function On(s) {
3568
+ const e = s.match(/<spine\b[^>]*>([\s\S]*?)<\/spine>/i);
3569
+ if (!e) return [];
3570
+ const t = [], n = /<itemref\b[^>]*\bidref\s*=\s*"([^"]+)"[^>]*>/gi;
3571
+ let r;
3572
+ for (; r = n.exec(e[1]); )
3573
+ t.push(r[1]);
3574
+ return t;
3575
+ }
3576
+ function Pn(s) {
3577
+ const e = s.match(
3578
+ /<meta\b[^>]*name\s*=\s*"viewport"[^>]*content\s*=\s*"([^"]+)"[^>]*>/i
3579
+ ) || s.match(/<meta\b[^>]*content\s*=\s*"([^"]+)"[^>]*name\s*=\s*"viewport"[^>]*>/i);
3580
+ if (!e) return null;
3581
+ const t = e[1], n = t.match(/width\s*=\s*(\d+)/i), r = t.match(/height\s*=\s*(\d+)/i);
3582
+ return !n || !r ? null : { width: Number(n[1]), height: Number(r[1]) };
3583
+ }
3584
+ function Rn(s, e) {
3585
+ const t = [];
3586
+ let n;
3587
+ const r = W(s, /<audio\b[^>]*\bsrc\s*=\s*"([^"]+)"/i);
3588
+ r && (n = fs(e, r));
3589
+ const i = /<par\b[^>]*>([\s\S]*?)<\/par>/gi;
3590
+ let a, o = 0;
3591
+ for (; a = i.exec(s); ) {
3592
+ const c = a[1], l = W(c, /<text\b[^>]*\bsrc\s*=\s*"([^"]+)"/i), d = W(c, /\bclipBegin\s*=\s*"([^"]+)"/i), h = W(c, /\bclipEnd\s*=\s*"([^"]+)"/i), y = l != null && l.includes("#") ? l.split("#")[1] : `cue-${o}`;
3593
+ d == null || h == null || (t.push({
3594
+ id: y || `cue-${o}`,
3595
+ start: Jt(d),
3596
+ end: Jt(h)
3597
+ }), o += 1);
3598
+ }
3599
+ return { audioHref: n, cues: t };
3600
+ }
3601
+ function Jt(s) {
3602
+ const e = s.replace(/^npt=/i, "").trim();
3603
+ if (/^\d+(\.\d+)?$/.test(e)) return Number(e);
3604
+ const t = e.split(":").map(Number);
3605
+ return t.length === 3 ? t[0] * 3600 + t[1] * 60 + t[2] : t.length === 2 ? t[0] * 60 + t[1] : 0;
3606
+ }
3607
+ function Mn(s) {
3608
+ const e = s.match(/<body\b[^>]*>([\s\S]*?)<\/body>/i);
3609
+ return e ? e[1].trim() : s;
3610
+ }
3611
+ function Ln(s, e, t) {
3612
+ const n = [];
3613
+ return { html: s.replace(
3614
+ /\b(src|href)\s*=\s*["']([^"']+)["']/gi,
3615
+ (i, a, o) => {
3616
+ if (/^(?:[a-z]+:|#|data:)/i.test(o)) return i;
3617
+ const c = q(`${e}${o}`);
3618
+ /\.(png|jpe?g|gif|webp|svg)$/i.test(o) && n.push(c);
3619
+ const l = t(o);
3620
+ return `${a}="${l}"`;
3621
+ }
3622
+ ), imageHrefs: n };
3623
+ }
3624
+ function fs(s, e) {
3625
+ if (/^(?:[a-z]+:)/i.test(e)) return e;
3626
+ const n = ((s.includes("/") ? s.replace(/\/[^/]+$/, "/") : "") + e).split("/"), r = [];
3627
+ for (const i of n)
3628
+ !i || i === "." || (i === ".." ? r.pop() : r.push(i));
3629
+ return r.join("/");
3630
+ }
3631
+ function W(s, e) {
3632
+ const t = s.match(e);
3633
+ return t ? t[1] : null;
3634
+ }
3635
+ function Xt(s, e) {
3636
+ const t = new RegExp(`<${e.replace(":", ":")}[^>]*>([^<]*)</${e.replace(":", ":")}>`, "i"), n = s.match(t);
3637
+ return n ? n[1].trim() : null;
3638
+ }
3639
+ function jn(s) {
3640
+ return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 48) || "book";
3641
+ }
3642
+ function hs(s) {
3643
+ const e = Cn(s), t = e.find((r) => r === "story.json" || r.toLowerCase() === "story.json");
3644
+ if (t) return t;
3645
+ const n = e.filter((r) => r.toLowerCase().endsWith("/story.json") || r.toLowerCase() === "story.json").sort((r, i) => r.length - i.length);
3646
+ if (n[0]) return n[0];
3647
+ throw new Error("Invalid .fanci package: missing story.json");
3648
+ }
3649
+ function ps(s) {
3650
+ const e = hs(s), t = e.includes("/") ? e.replace(/\/[^/]+$/, "/") : "", n = Me(JSON.parse(Ce(s, e))), r = /* @__PURE__ */ new Map(), i = [];
3651
+ for (const [a, o] of s) {
3652
+ if (a === e) continue;
3653
+ const c = us(o, a);
3654
+ i.push(c), r.set(a, c), t && a.startsWith(t) && r.set(a.slice(t.length), c);
3655
+ }
3656
+ return Vn(n, (a) => Zn(r, t, a)), { story: n, pathUrls: r, blobUrls: i, storyDir: t };
3657
+ }
3658
+ function hr(s) {
3659
+ return ps(xt(s));
3660
+ }
3661
+ function Zn(s, e, t) {
3662
+ const n = q(t);
3663
+ if (s.has(n)) return s.get(n);
3664
+ const r = q(`${e}${n}`);
3665
+ if (s.has(r)) return s.get(r);
3666
+ const i = n.toLowerCase();
3667
+ for (const [a, o] of s)
3668
+ if (a.toLowerCase() === i || a.toLowerCase().endsWith(`/${i}`))
3669
+ return o;
3670
+ }
3671
+ function Vn(s, e) {
3672
+ for (const t of s.fonts) {
3673
+ const n = e(t.src);
3674
+ n && (t.src = n);
3675
+ }
3676
+ for (const t of Object.values(s.assets)) {
3677
+ const n = e(t.src);
3678
+ n && (t.src = n);
3679
+ }
3680
+ for (const t of s.pages)
3681
+ for (const n of t.blocks)
3682
+ if (n.type === "text" && n.htmlSrc) {
3683
+ const r = e(n.htmlSrc);
3684
+ r && (n.htmlSrc = r);
3685
+ }
3686
+ }
3687
+ function zn(s) {
3688
+ if (Qe(s, "META-INF/container.xml")) return !1;
3689
+ try {
3690
+ return hs(s), !0;
3691
+ } catch {
3692
+ return !1;
3693
+ }
3694
+ }
3695
+ const kt = ".fanci";
3696
+ function St(s) {
3697
+ const e = s.split("?")[0].split("#")[0], t = e.split("/").pop() ?? e, n = t.lastIndexOf(".");
3698
+ return n >= 0 ? t.slice(n).toLowerCase() : "";
3699
+ }
3700
+ function Bn(s, e) {
3701
+ if (typeof s == "object" && s !== null && !(s instanceof Blob) && !(s instanceof ArrayBuffer) && !(s instanceof Uint8Array) && !ArrayBuffer.isView(s) && ("story" in s || "id" in s && "pages" in s))
3702
+ return "object";
3703
+ const t = e ?? (typeof s == "string" ? s : s instanceof File ? s.name : ""), n = St(t);
3704
+ return n === kt || n === ".fanci.zip" ? "fanci" : n === ".epub" ? "epub" : "json";
3705
+ }
3706
+ async function Un(s) {
3707
+ return s instanceof ArrayBuffer ? s : s instanceof Uint8Array ? s.buffer.slice(s.byteOffset, s.byteOffset + s.byteLength) : s.arrayBuffer();
3708
+ }
3709
+ async function ms(s, e) {
3710
+ const t = typeof e == "string" ? { baseUrl: e } : e ?? {}, n = t.onProgress ?? (() => {
3711
+ });
3712
+ if (Dn(s)) {
3713
+ n({ stage: "parse", progress: 0.1, detail: "story object" });
3714
+ const r = Me(s), i = t.baseUrl ?? (typeof location < "u" ? location.href : "");
3715
+ n({ stage: "assets", progress: 0.2, detail: "fonts" }), await Ee(r, i);
3716
+ const a = await Ie(r, i, n, 0.25, 1);
3717
+ return n({ stage: "complete", progress: 1 }), { story: r, baseUrl: i, assets: a, blobUrls: [], kind: "object" };
3718
+ }
3719
+ if (typeof s == "object" && s !== null && "story" in s && !Yt(s)) {
3720
+ const r = s;
3721
+ return ms(r.story, {
3722
+ baseUrl: t.baseUrl ?? r.baseUrl,
3723
+ name: t.name,
3724
+ onProgress: t.onProgress
3725
+ });
3726
+ }
3727
+ if (typeof s == "string")
3728
+ return Fn(s, t, n);
3729
+ if (Yt(s)) {
3730
+ n({ stage: "fetch", progress: 0.05, detail: "bytes" });
3731
+ const r = await Un(s), i = t.name ?? (s instanceof File ? s.name : void 0) ?? "";
3732
+ return gt(r, i, t.baseUrl, n);
3733
+ }
3734
+ throw new Error("Unsupported story source");
3735
+ }
3736
+ async function Fn(s, e, t) {
3737
+ const n = St(s), r = Bn(s, e.name ?? s);
3738
+ if (t({ stage: "fetch", progress: 0.02, detail: s }), n === kt || n === ".epub" || r === "fanci" || r === "epub") {
3739
+ const y = await Nn(s);
3740
+ return t({ stage: "fetch", progress: 0.15, detail: "package downloaded" }), gt(y, e.name ?? s, e.baseUrl, t);
3741
+ }
3742
+ const i = await fetch(s);
3743
+ if (!i.ok)
3744
+ throw new Error(`Failed to load story: ${i.status} ${i.statusText}`);
3745
+ const a = await i.arrayBuffer(), o = new Uint8Array(a);
3746
+ if (wt(o))
3747
+ return t({ stage: "fetch", progress: 0.15, detail: "zip downloaded" }), gt(a, e.name ?? s, e.baseUrl, t);
3748
+ t({ stage: "parse", progress: 0.2, detail: "json" });
3749
+ const c = new TextDecoder().decode(o), l = Me(JSON.parse(c)), d = e.baseUrl ?? cn(new URL(s, location.href).href);
3750
+ await Ee(l, d);
3751
+ const h = await Ie(l, d, t, 0.3, 1);
3752
+ return t({ stage: "complete", progress: 1 }), { story: l, baseUrl: d, assets: h, blobUrls: [], kind: "json" };
3753
+ }
3754
+ async function gt(s, e, t, n) {
3755
+ const r = new Uint8Array(s), i = St(e);
3756
+ if (wt(r)) {
3757
+ n({ stage: "unpack", progress: 0.2, detail: "unzip" });
3758
+ const l = xt(r);
3759
+ if (n({ stage: "unpack", progress: 0.35, detail: `${l.size} entries` }), i === ".epub" || In(l)) {
3760
+ n({ stage: "parse", progress: 0.4, detail: "epub" });
3761
+ const { story: d, blobUrls: h } = ds(l);
3762
+ await Ee(d, t ?? "");
3763
+ const y = await Ie(d, t ?? "", n, 0.5, 1);
3764
+ return n({ stage: "complete", progress: 1 }), { story: d, baseUrl: t ?? "", assets: y, blobUrls: h, kind: "epub" };
3765
+ }
3766
+ if (i === kt || zn(l)) {
3767
+ n({ stage: "parse", progress: 0.4, detail: "fanci" });
3768
+ const { story: d, blobUrls: h } = ps(l);
3769
+ await Ee(d, t ?? "");
3770
+ const y = await Ie(d, t ?? "", n, 0.5, 1);
3771
+ return n({ stage: "complete", progress: 1 }), { story: d, baseUrl: t ?? "", assets: y, blobUrls: h, kind: "fanci" };
3772
+ }
3773
+ throw new Error(
3774
+ "ZIP archive is neither a .fanci package (story.json) nor an EPUB (META-INF/container.xml)"
3775
+ );
3776
+ }
3777
+ n({ stage: "parse", progress: 0.25, detail: "json bytes" });
3778
+ const a = Me(JSON.parse(new TextDecoder().decode(r))), o = t ?? (typeof location < "u" ? location.href : "");
3779
+ await Ee(a, o);
3780
+ const c = await Ie(a, o, n, 0.35, 1);
3781
+ return n({ stage: "complete", progress: 1 }), { story: a, baseUrl: o, assets: c, blobUrls: [], kind: "json" };
3782
+ }
3783
+ function Dn(s) {
3784
+ return typeof s == "object" && s !== null && !Array.isArray(s) && !(s instanceof Blob) && !(s instanceof ArrayBuffer) && !(s instanceof Uint8Array) && "id" in s && "pages" in s && "pageSize" in s;
3785
+ }
3786
+ function Yt(s) {
3787
+ return s instanceof ArrayBuffer || s instanceof Uint8Array || s instanceof Blob || typeof File < "u" && s instanceof File;
3788
+ }
3789
+ async function Ie(s, e, t, n, r) {
3790
+ var O;
3791
+ const i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = Object.entries(s.assets), d = [];
3792
+ for (const T of s.pages)
3793
+ for (const A of T.blocks)
3794
+ if (A.type === "text" && A.htmlSrc && !A.html && d.push(async () => {
3795
+ const w = Be(e, A.htmlSrc);
3796
+ c.set(`htmlSrc:${A.id}`, await ze(w));
3797
+ }), (O = T.readAloud) != null && O.cues && typeof T.readAloud.cues == "string") {
3798
+ const w = T.readAloud.cues;
3799
+ s.assets[w] || d.push(async () => {
3800
+ const P = Be(e, w);
3801
+ try {
3802
+ o.set(w, Wt(await ze(P)));
3803
+ } catch {
3804
+ }
3805
+ });
3806
+ }
3807
+ const h = l.length + d.length || 1;
3808
+ let y = 0;
3809
+ const I = (T) => {
3810
+ y += 1;
3811
+ const A = y / h, w = n + (r - n) * Math.min(1, A);
3812
+ t({
3813
+ stage: "assets",
3814
+ progress: w,
3815
+ count: y,
3816
+ total: h,
3817
+ detail: T
3818
+ });
3819
+ };
3820
+ return await Promise.all(
3821
+ l.map(async ([T, A]) => {
3822
+ const w = Be(e, A.src);
3823
+ A.type === "image" ? i.set(T, await Wn(w)) : A.type === "audio" ? a.set(T, { url: w, channel: A.channel ?? "vo" }) : A.type === "vtt" ? o.set(T, Wt(await ze(w))) : A.type === "html" && c.set(T, await ze(w)), I(T);
3824
+ })
3825
+ ), await Promise.all(
3826
+ d.map(async (T) => {
3827
+ await T(), I("fragment");
3828
+ })
3829
+ ), l.length === 0 && d.length === 0 && t({ stage: "assets", progress: r, count: 0, total: 0, detail: "none" }), { images: i, audioUrls: a, cues: o, html: c };
3830
+ }
3831
+ function Wn(s) {
3832
+ return new Promise((e, t) => {
3833
+ const n = new Image();
3834
+ n.decoding = "async", n.onload = () => e(n), n.onerror = () => t(new Error(`Failed to load image: ${s}`)), n.src = s;
3835
+ });
3836
+ }
3837
+ async function ze(s) {
3838
+ const e = await fetch(s);
3839
+ if (!e.ok)
3840
+ throw new Error(`Failed to load ${s}: ${e.status}`);
3841
+ return e.text();
3842
+ }
3843
+ function qn(s) {
3844
+ for (const e of s.blobUrls)
3845
+ try {
3846
+ URL.revokeObjectURL(e);
3847
+ } catch {
3848
+ }
3849
+ s.blobUrls.length = 0;
3850
+ }
3851
+ function Hn(s, e, t) {
3852
+ return s === "auto" ? e >= t ? "two-page" : "single" : s;
3853
+ }
3854
+ function Jn(s) {
3855
+ if (s.length === 0) return [];
3856
+ const e = [];
3857
+ e.push({
3858
+ index: 0,
3859
+ left: { kind: "blank" },
3860
+ right: { kind: "page", pageIndex: 0, pageId: s[0].id }
3861
+ });
3862
+ let t = 1;
3863
+ for (; t < s.length; ) {
3864
+ const n = { kind: "page", pageIndex: t, pageId: s[t].id }, r = t + 1 < s.length ? { kind: "page", pageIndex: t + 1, pageId: s[t + 1].id } : { kind: "blank" };
3865
+ e.push({
3866
+ index: e.length,
3867
+ left: n,
3868
+ right: r
3869
+ }), t += 2;
3870
+ }
3871
+ return e;
3872
+ }
3873
+ function Xn(s) {
3874
+ const e = [];
3875
+ return s.left.kind === "page" && e.push(s.left.pageId), s.right.kind === "page" && e.push(s.right.pageId), e;
3876
+ }
3877
+ function Yn(s, e) {
3878
+ const t = s.findIndex(
3879
+ (n) => n.left.kind === "page" && n.left.pageId === e || n.right.kind === "page" && n.right.pageId === e
3880
+ );
3881
+ return t < 0 ? 0 : t;
3882
+ }
3883
+ class Gn {
3884
+ constructor(e, t) {
3885
+ g(this, "story");
3886
+ g(this, "spreadView");
3887
+ g(this, "spreads");
3888
+ g(this, "spreadIndex", 0);
3889
+ g(this, "preferredMode");
3890
+ g(this, "resolvedMode", "single");
3891
+ g(this, "breakpoint");
3892
+ g(this, "listeners", /* @__PURE__ */ new Map());
3893
+ g(this, "busy", !1);
3894
+ this.story = e, this.spreadView = t, this.spreads = Jn(e.pages), this.preferredMode = e.layout.mode, this.breakpoint = e.layout.singleBreakpoint;
3895
+ }
3896
+ get layoutMode() {
3897
+ return this.resolvedMode;
3898
+ }
3899
+ get currentSpread() {
3900
+ return this.spreads[this.spreadIndex];
3901
+ }
3902
+ get currentPageIds() {
3903
+ return Xn(this.currentSpread);
3904
+ }
3905
+ on(e, t) {
3906
+ return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t), () => {
3907
+ var n;
3908
+ return (n = this.listeners.get(e)) == null ? void 0 : n.delete(t);
3909
+ };
3910
+ }
3911
+ setLayoutMode(e, t) {
3912
+ this.preferredMode = e, this.updateLayout(t, !1);
3913
+ }
3914
+ updateLayout(e, t = !0) {
3915
+ const n = Hn(this.preferredMode, e, this.breakpoint), r = n !== this.resolvedMode;
3916
+ this.resolvedMode = n, this.spreadView.setLayoutMode(n), r && t && this.emit("layoutchange", { layoutMode: n });
3917
+ }
3918
+ async showInitial() {
3919
+ await this.spreadView.showSpread(this.currentSpread, "none"), this.emitPageChange();
3920
+ }
3921
+ async next() {
3922
+ this.busy || this.spreadIndex >= this.spreads.length - 1 || (this.busy = !0, this.spreadIndex += 1, await this.spreadView.showSpread(this.currentSpread, "next"), this.emitPageChange(), this.busy = !1);
3923
+ }
3924
+ async prev() {
3925
+ this.busy || this.spreadIndex <= 0 || (this.busy = !0, this.spreadIndex -= 1, await this.spreadView.showSpread(this.currentSpread, "prev"), this.emitPageChange(), this.busy = !1);
3926
+ }
3927
+ async goTo(e) {
3928
+ const t = Yn(this.spreads, e);
3929
+ if (t === this.spreadIndex) return;
3930
+ const n = t > this.spreadIndex ? "next" : "prev";
3931
+ this.busy = !0, this.spreadIndex = t, await this.spreadView.showSpread(this.currentSpread, n), this.emitPageChange(), this.busy = !1;
3932
+ }
3933
+ emitPageChange() {
3934
+ this.emit("pagechange", {
3935
+ pageIds: this.currentPageIds,
3936
+ index: this.spreadIndex,
3937
+ layoutMode: this.resolvedMode
3938
+ });
3939
+ }
3940
+ emit(e, t) {
3941
+ const n = this.listeners.get(e);
3942
+ if (n)
3943
+ for (const r of n)
3944
+ r(t);
3945
+ }
3946
+ }
3947
+ function Qn(s) {
3948
+ const e = s ?? {}, t = {
3949
+ left: ye(e.x ?? 0),
3950
+ top: ye(e.y ?? 0)
3951
+ };
3952
+ return e.width != null && (t.width = ye(e.width)), e.height != null && (t.height = ye(e.height)), t;
3953
+ }
3954
+ function At(s, e) {
3955
+ const t = Qn(e);
3956
+ s.style.left = t.left, s.style.top = t.top, t.width && (s.style.width = t.width), t.height && (s.style.height = t.height), (e == null ? void 0 : e.horizontalAlign) === "right" ? (s.style.left = "auto", s.style.right = ye(e.x ?? 0)) : (e == null ? void 0 : e.horizontalAlign) === "center" && (s.style.left = "50%", s.style.transform = `${s.style.transform || ""} translateX(-50%)`.trim()), (e == null ? void 0 : e.verticalAlign) === "bottom" ? (s.style.top = "auto", s.style.bottom = ye(e.y ?? 0)) : (e == null ? void 0 : e.verticalAlign) === "center" && (s.style.top = "50%", s.style.transform = `${s.style.transform || ""} translateY(-50%)`.trim());
3957
+ }
3958
+ function ye(s) {
3959
+ return typeof s == "number" ? `${s}px` : /^-?\d+(\.\d+)?$/.test(s) ? `${s}px` : s;
3960
+ }
3961
+ function Kn(s, e) {
3962
+ const t = document.createElement("button");
3963
+ return t.type = "button", t.className = "fc-block fc-block-hotspot", t.dataset.blockId = s.id, t.setAttribute("aria-label", s.ariaLabel ?? s.id), At(t, s.layout), t.addEventListener("click", (n) => {
3964
+ n.stopPropagation(), e(s.onTap ?? []);
3965
+ }), t;
3966
+ }
3967
+ function er(s, e) {
3968
+ var i;
3969
+ const t = document.createElement("div");
3970
+ t.className = `fc-block fc-block-image${s.className ? ` ${s.className}` : ""}`, t.dataset.blockId = s.id, At(t, s.layout);
3971
+ const n = document.createElement("img");
3972
+ n.alt = "", n.draggable = !1, e && (n.src = e.src);
3973
+ const r = ((i = s.layout) == null ? void 0 : i.fit) ?? "contain";
3974
+ return n.style.objectFit = r, t.appendChild(n), t;
3975
+ }
3976
+ function tr(s, e) {
3977
+ const t = document.createElement("div");
3978
+ return t.className = "fc-block fc-block-text", t.dataset.blockId = s.id, At(t, s.layout), t.innerHTML = e, t.querySelectorAll("[id]").forEach((n) => {
3979
+ n.classList.add("fc-cue");
3980
+ }), s.style && (s.style.fontFamily && (t.style.fontFamily = s.style.fontFamily), s.style.fontSize && (t.style.fontSize = s.style.fontSize), s.style.color && (t.style.color = s.style.color), s.style.textAlign && (t.style.textAlign = s.style.textAlign), s.style.lineHeight != null && (t.style.lineHeight = String(s.style.lineHeight))), t;
3981
+ }
3982
+ class Gt {
3983
+ constructor(e, t, n) {
3984
+ g(this, "element");
3985
+ g(this, "page");
3986
+ g(this, "blank");
3987
+ var r, i;
3988
+ if (this.page = e, this.blank = !e, this.element = document.createElement("article"), this.element.className = `fc-page${this.blank ? " fc-page-blank" : ""}`, this.element.setAttribute("role", this.blank ? "presentation" : "document"), !e) {
3989
+ this.element.dataset.blank = "true";
3990
+ return;
3991
+ }
3992
+ if (this.element.dataset.pageId = e.id, (r = e.background) != null && r.color && (this.element.style.backgroundColor = e.background.color), (i = e.background) != null && i.asset) {
3993
+ const a = t.images.get(e.background.asset);
3994
+ a && (this.element.style.backgroundImage = `url(${JSON.stringify(a.src)})`, this.element.style.backgroundSize = "cover", this.element.style.backgroundPosition = "center");
3995
+ }
3996
+ for (const a of e.blocks)
3997
+ if (a.type === "text") {
3998
+ const o = a.html ?? t.html.get(`htmlSrc:${a.id}`) ?? (a.htmlSrc ? t.html.get(a.htmlSrc) : void 0) ?? "";
3999
+ this.element.appendChild(tr(a, o));
4000
+ } else a.type === "image" ? this.element.appendChild(er(a, t.images.get(a.asset))) : a.type === "hotspot" && this.element.appendChild(
4001
+ Kn(a, (o) => n.onTapActions(o, this.element))
4002
+ );
4003
+ }
4004
+ destroy() {
4005
+ this.element.remove();
4006
+ }
4007
+ }
4008
+ class sr {
4009
+ constructor(e, t, n) {
4010
+ g(this, "element");
4011
+ g(this, "bookEl");
4012
+ g(this, "leftSlot");
4013
+ g(this, "rightSlot");
4014
+ g(this, "leftPage", null);
4015
+ g(this, "rightPage", null);
4016
+ g(this, "story");
4017
+ g(this, "assets");
4018
+ g(this, "onTapActions");
4019
+ g(this, "turning", !1);
4020
+ this.story = e, this.assets = t, this.onTapActions = n, this.element = document.createElement("div"), this.element.className = "fc-spread-viewport", this.bookEl = document.createElement("div"), this.bookEl.className = "fc-spread", this.leftSlot = document.createElement("div"), this.leftSlot.className = "fc-leaf fc-leaf-left", this.rightSlot = document.createElement("div"), this.rightSlot.className = "fc-leaf fc-leaf-right", this.bookEl.append(this.leftSlot, this.rightSlot), this.element.appendChild(this.bookEl);
4021
+ }
4022
+ setLayoutMode(e) {
4023
+ this.element.dataset.layoutMode = e, this.element.classList.toggle("fc-spread-viewport-single", e === "single"), this.element.classList.toggle("fc-spread-viewport-two", e === "two-page");
4024
+ }
4025
+ showSpread(e, t = "none") {
4026
+ return t === "none" || this.turning ? (this.mountSpread(e), Promise.resolve()) : (this.turning = !0, this.bookEl.classList.remove("fc-turn-next", "fc-turn-prev"), this.bookEl.offsetWidth, this.bookEl.classList.add(t === "next" ? "fc-turn-next" : "fc-turn-prev"), new Promise((n) => {
4027
+ const r = () => {
4028
+ this.bookEl.removeEventListener("animationend", r), this.bookEl.classList.remove("fc-turn-next", "fc-turn-prev"), this.mountSpread(e), this.turning = !1, n();
4029
+ };
4030
+ this.bookEl.addEventListener("animationend", r), window.setTimeout(r, 450);
4031
+ }));
4032
+ }
4033
+ getPageElement(e) {
4034
+ var t, n, r, i;
4035
+ return ((n = (t = this.leftPage) == null ? void 0 : t.page) == null ? void 0 : n.id) === e ? this.leftPage.element : ((i = (r = this.rightPage) == null ? void 0 : r.page) == null ? void 0 : i.id) === e ? this.rightPage.element : null;
4036
+ }
4037
+ getVisiblePageElements(e, t) {
4038
+ const n = [];
4039
+ return e === "two-page" ? (t.left.kind === "page" && this.leftPage && n.push(this.leftPage.element), t.right.kind === "page" && this.rightPage && n.push(this.rightPage.element)) : t.left.kind === "blank" && t.right.kind === "page" && this.rightPage ? n.push(this.rightPage.element) : t.right.kind === "blank" && t.left.kind === "page" && this.leftPage ? n.push(this.leftPage.element) : t.left.kind === "page" && this.leftPage ? n.push(this.leftPage.element) : t.right.kind === "page" && this.rightPage && n.push(this.rightPage.element), n;
4040
+ }
4041
+ updateStageSize(e, t, n, r) {
4042
+ const { width: i, height: a } = this.story.pageSize, o = i * 2, c = a;
4043
+ let l;
4044
+ n === "single" ? l = Math.min(e / i, t / a) : l = Math.min(e / o, t / c), this.bookEl.style.width = `${o}px`, this.bookEl.style.height = `${c}px`, this.bookEl.style.setProperty("--fc-page-width", `${i}px`), this.bookEl.style.setProperty("--fc-page-height", `${a}px`);
4045
+ let d = 0;
4046
+ n === "single" && r && r.left.kind === "blank" && (d = -i * l), this.bookEl.style.transform = `translateX(${d}px) scale(${l})`, this.bookEl.style.transformOrigin = "left top", this.element.style.width = n === "single" ? `${i * l}px` : `${o * l}px`, this.element.style.height = `${c * l}px`;
4047
+ }
4048
+ destroy() {
4049
+ var e, t;
4050
+ (e = this.leftPage) == null || e.destroy(), (t = this.rightPage) == null || t.destroy(), this.element.remove();
4051
+ }
4052
+ mountSpread(e) {
4053
+ var t, n;
4054
+ (t = this.leftPage) == null || t.destroy(), (n = this.rightPage) == null || n.destroy(), this.leftSlot.replaceChildren(), this.rightSlot.replaceChildren(), this.leftPage = this.createLeaf(e.left), this.rightPage = this.createLeaf(e.right), this.leftSlot.appendChild(this.leftPage.element), this.rightSlot.appendChild(this.rightPage.element);
4055
+ }
4056
+ createLeaf(e) {
4057
+ if (e.kind === "blank")
4058
+ return new Gt(null, this.assets, { onTapActions: this.onTapActions });
4059
+ const t = this.story.pages[e.pageIndex];
4060
+ return new Gt(t, this.assets, { onTapActions: this.onTapActions });
4061
+ }
4062
+ }
4063
+ function nr(s, e) {
4064
+ const t = s == null ? void 0 : s.container;
4065
+ if (!(t != null && t.send)) return;
4066
+ const n = ir(e.progress);
4067
+ t.send("progress", n), t.send("loading", {
4068
+ stage: e.stage,
4069
+ progress: n,
4070
+ count: e.count,
4071
+ total: e.total,
4072
+ detail: e.detail
4073
+ });
4074
+ }
4075
+ function pr(s) {
4076
+ var e, t;
4077
+ (t = (e = s == null ? void 0 : s.container) == null ? void 0 : e.send) == null || t.call(e, "loaded");
4078
+ }
4079
+ function rr() {
4080
+ let s;
4081
+ return { promise: new Promise((t) => {
4082
+ s = t;
4083
+ }), resolve: s };
4084
+ }
4085
+ function ir(s) {
4086
+ return Number.isNaN(s) ? 0 : Math.min(1, Math.max(0, s));
4087
+ }
4088
+ function ar(s, e, t = {}) {
4089
+ const n = [];
4090
+ let r = !1;
4091
+ const i = (a, o) => {
4092
+ if (!(a != null && a.subscribe)) return;
4093
+ const c = a.subscribe(o);
4094
+ typeof c == "function" ? n.push(c) : c && typeof c.unsubscribe == "function" && n.push(() => {
4095
+ var l;
4096
+ return (l = c.unsubscribe) == null ? void 0 : l.call(c);
4097
+ });
4098
+ };
4099
+ return s != null && s.state && (i(s.state.pause, (a) => {
4100
+ var c;
4101
+ const o = !!a;
4102
+ e.setPaused(o), (c = t.onPause) == null || c.call(t, o);
4103
+ }), i(s.state.soundVolume, (a) => e.setVolume("sound", Number(a))), i(s.state.voVolume, (a) => e.setVolume("vo", Number(a))), i(s.state.sfxVolume, (a) => e.setVolume("sfx", Number(a))), i(s.state.musicVolume, (a) => e.setVolume("music", Number(a))), i(s.state.captionsMuted, (a) => {
4104
+ var o;
4105
+ r = !!a, (o = t.onCaptionsMuted) == null || o.call(t, r);
4106
+ })), {
4107
+ get captionsMuted() {
4108
+ return r;
4109
+ },
4110
+ destroy() {
4111
+ for (const a of n) a();
4112
+ }
4113
+ };
4114
+ }
4115
+ async function or(s) {
4116
+ var e, t;
4117
+ try {
4118
+ const n = await import("springroll"), r = n.Application ?? ((e = n.default) == null ? void 0 : e.Application), i = n.ApplicationPlugin ?? ((t = n.default) == null ? void 0 : t.ApplicationPlugin);
4119
+ if (!r) return null;
4120
+ const a = rr(), o = `fancifully-story-load-${Math.random().toString(36).slice(2, 9)}`;
4121
+ if (i && typeof r.uses == "function") {
4122
+ const l = new i({ name: o });
4123
+ l.preload = () => a.promise, r.uses(l);
4124
+ } else
4125
+ a.resolve();
4126
+ return { app: new r({ features: s }), loadGate: a, owned: !0 };
4127
+ } catch {
4128
+ return null;
4129
+ }
4130
+ }
4131
+ function cr(s) {
4132
+ var e;
4133
+ return !((e = s == null ? void 0 : s.state) != null && e.ready) || s.state.ready.value === !0 ? Promise.resolve() : new Promise((t) => {
4134
+ const n = s.state.ready.subscribe((r) => {
4135
+ r && (typeof n == "function" && n(), t());
4136
+ });
4137
+ });
4138
+ }
4139
+ const lr = {
4140
+ sound: !0,
4141
+ soundVolume: !0,
4142
+ vo: !0,
4143
+ voVolume: !0,
4144
+ sfx: !0,
4145
+ sfxVolume: !0,
4146
+ music: !0,
4147
+ musicVolume: !0,
4148
+ captions: !0
4149
+ };
4150
+ class gs {
4151
+ constructor(e, t, n, r) {
4152
+ g(this, "element");
4153
+ g(this, "root");
4154
+ g(this, "stage");
4155
+ g(this, "chrome");
4156
+ g(this, "captionsEl");
4157
+ g(this, "loaded");
4158
+ g(this, "spreadView");
4159
+ g(this, "pager");
4160
+ g(this, "bus", new xs());
4161
+ g(this, "readAloud");
4162
+ g(this, "springroll");
4163
+ g(this, "bindings", null);
4164
+ g(this, "sfxAudio");
4165
+ g(this, "unbindSwipe", null);
4166
+ g(this, "resizeObserver", null);
4167
+ g(this, "listeners", /* @__PURE__ */ new Map());
4168
+ g(this, "destroyed", !1);
4169
+ this.root = e, this.loaded = t, this.springroll = n, this.element = document.createElement("div"), this.element.className = "fc-root", this.element.tabIndex = 0, this.stage = document.createElement("div"), this.stage.className = "fc-stage", this.captionsEl = document.createElement("div"), this.captionsEl.className = "fc-captions", this.captionsEl.setAttribute("aria-live", "polite"), this.chrome = document.createElement("div"), this.chrome.className = "fc-chrome", this.chrome.innerHTML = `
4170
+ <button type="button" class="fc-btn fc-btn-prev" aria-label="Previous page">Prev</button>
4171
+ <button type="button" class="fc-btn fc-btn-read" aria-label="Read aloud">Read</button>
4172
+ <button type="button" class="fc-btn fc-btn-next" aria-label="Next page">Next</button>
4173
+ `, this.spreadView = new sr(
4174
+ t.story,
4175
+ t.assets,
4176
+ (i, a) => this.handleTapActions(i, a)
4177
+ ), this.pager = new Gn(t.story, this.spreadView), this.readAloud = new Ss(this.bus), this.sfxAudio = new Audio(), this.bus.register(this.sfxAudio, "sfx"), this.stage.appendChild(this.spreadView.element), this.element.append(this.stage, this.captionsEl, this.chrome), this.root.appendChild(this.element), this.wireChrome(), this.wirePager(r), this.wireSpringroll(), this.wireResize(), this.unbindSwipe = As(this.stage, {
4178
+ onSwipeLeft: () => void this.next(),
4179
+ onSwipeRight: () => void this.prev()
4180
+ }), this.element.addEventListener("keydown", (i) => {
4181
+ i.key === "ArrowRight" ? (i.preventDefault(), this.next()) : i.key === "ArrowLeft" ? (i.preventDefault(), this.prev()) : i.key === " " && (i.preventDefault(), this.playReadAloud());
4182
+ }), this.readAloud.onCaption((i) => {
4183
+ this.captionsEl.textContent = i ?? "", this.captionsEl.hidden = !i;
4184
+ });
4185
+ }
4186
+ static async create(e, t) {
4187
+ const n = { ...lr, ...t.features };
4188
+ let r = t.springroll ?? null, i = null;
4189
+ if (!r) {
4190
+ const d = await or(n);
4191
+ d && (r = d.app, i = d.loadGate, ur(r));
4192
+ }
4193
+ const a = [];
4194
+ t.onProgress && a.push(t.onProgress);
4195
+ const o = (d) => {
4196
+ nr(r, d);
4197
+ for (const h of a) h(d);
4198
+ };
4199
+ o({ stage: "fetch", progress: 0, detail: "start" });
4200
+ const c = await ms(t.story, {
4201
+ baseUrl: t.baseUrl,
4202
+ name: t.storyName,
4203
+ onProgress: o
4204
+ });
4205
+ i == null || i.resolve(), await cr(r);
4206
+ const l = new gs(
4207
+ e,
4208
+ c,
4209
+ r,
4210
+ t.autoPlayReadAloud ?? !1
4211
+ );
4212
+ return l.pager.updateLayout(e.clientWidth || window.innerWidth, !1), l.layoutStage(), await l.pager.showInitial(), l.emit("ready", { story: c.story }), l;
4213
+ }
4214
+ get story() {
4215
+ return this.loaded.story;
4216
+ }
4217
+ get layoutMode() {
4218
+ return this.pager.layoutMode;
4219
+ }
4220
+ get pageIds() {
4221
+ return this.pager.currentPageIds;
4222
+ }
4223
+ get spreadIndex() {
4224
+ return this.pager.currentSpread.index;
4225
+ }
4226
+ on(e, t) {
4227
+ return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t), () => {
4228
+ var n;
4229
+ return (n = this.listeners.get(e)) == null ? void 0 : n.delete(t);
4230
+ };
4231
+ }
4232
+ next() {
4233
+ return this.readAloud.stop(), this.pager.next().then(() => this.layoutStage());
4234
+ }
4235
+ prev() {
4236
+ return this.readAloud.stop(), this.pager.prev().then(() => this.layoutStage());
4237
+ }
4238
+ goTo(e) {
4239
+ return this.readAloud.stop(), this.pager.goTo(e).then(() => this.layoutStage());
4240
+ }
4241
+ setLayoutMode(e) {
4242
+ this.pager.setLayoutMode(e, this.root.clientWidth || window.innerWidth), this.layoutStage(), this.emit("layoutchange", { layoutMode: this.pager.layoutMode });
4243
+ }
4244
+ playReadAloud() {
4245
+ const e = this.buildReadAloudClips();
4246
+ return this.readAloud.playSequence(e);
4247
+ }
4248
+ pause() {
4249
+ this.readAloud.pause(), this.bus.setPaused(!0);
4250
+ }
4251
+ resume() {
4252
+ this.bus.setPaused(!1), this.readAloud.resume();
4253
+ }
4254
+ destroy() {
4255
+ var e, t, n;
4256
+ this.destroyed || (this.destroyed = !0, this.readAloud.destroy(), this.bus.unregister(this.sfxAudio), (e = this.bindings) == null || e.destroy(), (t = this.unbindSwipe) == null || t.call(this), (n = this.resizeObserver) == null || n.disconnect(), this.spreadView.destroy(), this.element.remove(), this.listeners.clear(), qn(this.loaded));
4257
+ }
4258
+ wireChrome() {
4259
+ var e, t, n;
4260
+ (e = this.chrome.querySelector(".fc-btn-prev")) == null || e.addEventListener("click", () => void this.prev()), (t = this.chrome.querySelector(".fc-btn-next")) == null || t.addEventListener("click", () => void this.next()), (n = this.chrome.querySelector(".fc-btn-read")) == null || n.addEventListener("click", () => void this.playReadAloud());
4261
+ }
4262
+ wirePager(e) {
4263
+ this.pager.on("pagechange", (t) => {
4264
+ this.emit("pagechange", t), e && this.playReadAloud();
4265
+ }), this.pager.on("layoutchange", (t) => {
4266
+ this.layoutStage(), this.emit("layoutchange", t);
4267
+ });
4268
+ }
4269
+ wireSpringroll() {
4270
+ this.bindings = ar(this.springroll, this.bus, {
4271
+ onCaptionsMuted: (e) => this.readAloud.setCaptionsMuted(e),
4272
+ onPause: (e) => {
4273
+ e ? this.readAloud.pause() : this.readAloud.resume();
4274
+ }
4275
+ });
4276
+ }
4277
+ wireResize() {
4278
+ const e = () => {
4279
+ this.pager.updateLayout(this.root.clientWidth || window.innerWidth), this.layoutStage();
4280
+ };
4281
+ typeof ResizeObserver < "u" ? (this.resizeObserver = new ResizeObserver(e), this.resizeObserver.observe(this.root)) : window.addEventListener("resize", e);
4282
+ }
4283
+ layoutStage() {
4284
+ const e = this.stage.clientWidth || this.root.clientWidth || window.innerWidth, t = this.stage.clientHeight || Math.max(320, this.root.clientHeight - 64);
4285
+ this.spreadView.updateStageSize(
4286
+ e,
4287
+ t,
4288
+ this.pager.layoutMode,
4289
+ this.pager.currentSpread
4290
+ );
4291
+ }
4292
+ buildReadAloudClips() {
4293
+ const e = this.pager.layoutMode, t = this.pager.currentSpread, n = e === "two-page" ? [t.left, t.right] : t.left.kind === "blank" ? [t.right] : t.right.kind === "blank" ? [t.left] : [t.left], r = [];
4294
+ for (const i of n) {
4295
+ if (i.kind !== "page") continue;
4296
+ const a = this.loaded.story.pages[i.pageIndex];
4297
+ if (!a.readAloud) continue;
4298
+ const o = this.loaded.assets.audioUrls.get(a.readAloud.audio);
4299
+ if (!o) continue;
4300
+ const c = this.resolveCues(a.readAloud.cues), l = this.spreadView.getPageElement(a.id);
4301
+ r.push({
4302
+ url: o.url,
4303
+ channel: o.channel,
4304
+ cues: c,
4305
+ root: l
4306
+ });
4307
+ }
4308
+ return r;
4309
+ }
4310
+ resolveCues(e) {
4311
+ return e ? Array.isArray(e) ? e : this.loaded.assets.cues.get(e) ?? [] : [];
4312
+ }
4313
+ handleTapActions(e, t) {
4314
+ for (const n of e)
4315
+ if ("play" in n) {
4316
+ const r = this.loaded.assets.audioUrls.get(n.play);
4317
+ if (!r) continue;
4318
+ this.sfxAudio.src = r.url, this.bus.applyTo(this.sfxAudio, r.channel), this.sfxAudio.play().catch(() => {
4319
+ });
4320
+ } else if ("toggleClass" in n) {
4321
+ const r = t.querySelector(`[data-block-id="${n.toggleClass.target}"]`);
4322
+ r == null || r.classList.toggle(n.toggleClass.className);
4323
+ }
4324
+ }
4325
+ emit(e, t) {
4326
+ const n = this.listeners.get(e);
4327
+ if (n)
4328
+ for (const r of n) r(t);
4329
+ }
4330
+ }
4331
+ function ur(s) {
4332
+ var t, n, r, i, a, o;
4333
+ const e = s.state;
4334
+ e && ((t = e.pause) == null || t.subscribe(() => {
4335
+ }), (n = e.soundVolume) == null || n.subscribe(() => {
4336
+ }), (r = e.voVolume) == null || r.subscribe(() => {
4337
+ }), (i = e.sfxVolume) == null || i.subscribe(() => {
4338
+ }), (a = e.musicVolume) == null || a.subscribe(() => {
4339
+ }), (o = e.captionsMuted) == null || o.subscribe(() => {
4340
+ }));
4341
+ }
4342
+ export {
4343
+ ks as CueTimeline,
4344
+ kt as FANCI_EXTENSION,
4345
+ gs as Storybook,
4346
+ ar as bindApplication,
4347
+ Jn as buildSpreads,
4348
+ Xn as contentPageIds,
4349
+ or as createSpringrollApplication,
4350
+ hs as findStoryJsonPath,
4351
+ fr as loadEpubFromBytes,
4352
+ ds as loadEpubFromZip,
4353
+ hr as loadFanciFromBytes,
4354
+ ps as loadFanciFromZip,
4355
+ ms as loadStory,
4356
+ Me as parseStory,
4357
+ Wt as parseVtt,
4358
+ pr as reportSpringrollLoaded,
4359
+ nr as reportSpringrollProgress,
4360
+ Hn as resolveLayoutMode,
4361
+ qn as revokeLoadedStory,
4362
+ on as storySchema,
4363
+ cr as waitForSpringrollReady
4364
+ };