@boostxyz/cli 4.1.3 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3896 +1,25 @@
1
- import Ct from "node:fs/promises";
2
- import St from "node:path";
3
- import { Deployable as It, SignatureType as se, FilterType as nt, PrimitiveType as at, StrategyType as Me, BOOST_REGISTRY_ADDRESSES as At, BoostRegistry as Et, BOOST_CORE_ADDRESSES as Nt, BoostCore as Ot, Roles as rt, allowListFromAddress as Rt } from "@boostxyz/sdk";
4
- import { B as Zt, l as jt, p as Mt, c as Pt, f as $t, h as Dt, s as Vt, r as Bt, w as Lt, m as zt, n as Ut, q as ze, t as Wt, u as Ft, x as qt, k as Ht } from "../utils-CbGtTEVk.js";
5
- class Gt extends Zt {
6
- constructor({ value: e }) {
7
- super(`Number \`${e}\` is not a valid decimal number.`, {
8
- name: "InvalidDecimalNumberError"
9
- });
10
- }
11
- }
12
- function Yt(n, e) {
13
- if (!/^(-?)([0-9]*)\.?([0-9]*)$/.test(n))
14
- throw new Gt({ value: n });
15
- let [t, a = "0"] = n.split(".");
16
- const r = t.startsWith("-");
17
- if (r && (t = t.slice(1)), a = a.replace(/(0+)$/, ""), e === 0)
18
- Math.round(+`.${a}`) === 1 && (t = `${BigInt(t) + 1n}`), a = "";
19
- else if (a.length > e) {
20
- const [s, i, o] = [
21
- a.slice(0, e - 1),
22
- a.slice(e - 1, e),
23
- a.slice(e)
24
- ], u = Math.round(+`${i}.${o}`);
25
- u > 9 ? a = `${BigInt(s) + BigInt(1)}0`.padStart(s.length + 1, "0") : a = `${s}${u}`, a.length > e && (a = a.slice(1), t = `${BigInt(t) + 1n}`), a = a.slice(0, e);
26
- } else
27
- a = a.padEnd(e, "0");
28
- return BigInt(`${r ? "-" : ""}${t}${a}`);
29
- }
30
- function st(n, e = "wei") {
31
- return Yt(n, jt[e]);
32
- }
33
- const Ke = "0x0000000000000000000000000000000000000000";
34
- function Pe(n, e) {
35
- if (n === e)
36
- return !0;
37
- if (n && e && typeof n == "object" && typeof e == "object") {
38
- if (n.constructor !== e.constructor)
39
- return !1;
40
- let t, a;
41
- if (Array.isArray(n) && Array.isArray(e)) {
42
- if (t = n.length, t !== e.length)
43
- return !1;
44
- for (a = t; a-- !== 0; )
45
- if (!Pe(n[a], e[a]))
46
- return !1;
47
- return !0;
48
- }
49
- if (n.valueOf !== Object.prototype.valueOf)
50
- return n.valueOf() === e.valueOf();
51
- if (n.toString !== Object.prototype.toString)
52
- return n.toString() === e.toString();
53
- const r = Object.keys(n);
54
- if (t = r.length, t !== Object.keys(e).length)
55
- return !1;
56
- for (a = t; a-- !== 0; )
57
- if (!Object.prototype.hasOwnProperty.call(e, r[a]))
58
- return !1;
59
- for (a = t; a-- !== 0; ) {
60
- const s = r[a];
61
- if (s && !Pe(n[s], e[s]))
62
- return !1;
63
- }
64
- return !0;
65
- }
66
- return n !== n && e !== e;
67
- }
68
- function Ne(n) {
69
- const e = n.state.current, t = n.state.connections.get(e), a = t == null ? void 0 : t.accounts, r = a == null ? void 0 : a[0], s = n.chains.find((o) => o.id === (t == null ? void 0 : t.chainId)), i = n.state.status;
70
- switch (i) {
71
- case "connected":
72
- return {
73
- address: r,
74
- addresses: a,
75
- chain: s,
76
- chainId: t == null ? void 0 : t.chainId,
77
- connector: t == null ? void 0 : t.connector,
78
- isConnected: !0,
79
- isConnecting: !1,
80
- isDisconnected: !1,
81
- isReconnecting: !1,
82
- status: i
83
- };
84
- case "reconnecting":
85
- return {
86
- address: r,
87
- addresses: a,
88
- chain: s,
89
- chainId: t == null ? void 0 : t.chainId,
90
- connector: t == null ? void 0 : t.connector,
91
- isConnected: !!r,
92
- isConnecting: !1,
93
- isDisconnected: !1,
94
- isReconnecting: !0,
95
- status: i
96
- };
97
- case "connecting":
98
- return {
99
- address: r,
100
- addresses: a,
101
- chain: s,
102
- chainId: t == null ? void 0 : t.chainId,
103
- connector: t == null ? void 0 : t.connector,
104
- isConnected: !1,
105
- isConnecting: !0,
106
- isDisconnected: !1,
107
- isReconnecting: !1,
108
- status: i
109
- };
110
- case "disconnected":
111
- return {
112
- address: void 0,
113
- addresses: void 0,
114
- chain: void 0,
115
- chainId: void 0,
116
- connector: void 0,
117
- isConnected: !1,
118
- isConnecting: !1,
119
- isDisconnected: !0,
120
- isReconnecting: !1,
121
- status: i
122
- };
123
- }
124
- }
125
- function Ue(n) {
126
- return n.state.chainId;
127
- }
128
- function We(n, e, t) {
129
- const a = n[e.name];
130
- if (typeof a == "function")
131
- return a;
132
- const r = n[t];
133
- return typeof r == "function" ? r : (s) => e(n, s);
134
- }
135
- const Jt = "2.13.8", Kt = () => `@wagmi/core@${Jt}`;
136
- var it = function(n, e, t, a) {
137
- if (t === "a" && !a) throw new TypeError("Private accessor was defined without a getter");
138
- if (typeof e == "function" ? n !== e || !a : !e.has(n)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
139
- return t === "m" ? a : t === "a" ? a.call(n) : a ? a.value : e.get(n);
140
- }, we, ot;
141
- class H extends Error {
142
- get docsBaseUrl() {
143
- return "https://wagmi.sh/core";
144
- }
145
- get version() {
146
- return Kt();
147
- }
148
- constructor(e, t = {}) {
149
- var a;
150
- super(), we.add(this), Object.defineProperty(this, "details", {
151
- enumerable: !0,
152
- configurable: !0,
153
- writable: !0,
154
- value: void 0
155
- }), Object.defineProperty(this, "docsPath", {
156
- enumerable: !0,
157
- configurable: !0,
158
- writable: !0,
159
- value: void 0
160
- }), Object.defineProperty(this, "metaMessages", {
161
- enumerable: !0,
162
- configurable: !0,
163
- writable: !0,
164
- value: void 0
165
- }), Object.defineProperty(this, "shortMessage", {
166
- enumerable: !0,
167
- configurable: !0,
168
- writable: !0,
169
- value: void 0
170
- }), Object.defineProperty(this, "name", {
171
- enumerable: !0,
172
- configurable: !0,
173
- writable: !0,
174
- value: "WagmiCoreError"
175
- });
176
- const r = t.cause instanceof H ? t.cause.details : (a = t.cause) != null && a.message ? t.cause.message : t.details, s = t.cause instanceof H && t.cause.docsPath || t.docsPath;
177
- this.message = [
178
- e || "An error occurred.",
179
- "",
180
- ...t.metaMessages ? [...t.metaMessages, ""] : [],
181
- ...s ? [
182
- `Docs: ${this.docsBaseUrl}${s}.html${t.docsSlug ? `#${t.docsSlug}` : ""}`
183
- ] : [],
184
- ...r ? [`Details: ${r}`] : [],
185
- `Version: ${this.version}`
186
- ].join(`
187
- `), t.cause && (this.cause = t.cause), this.details = r, this.docsPath = s, this.metaMessages = t.metaMessages, this.shortMessage = e;
188
- }
189
- walk(e) {
190
- return it(this, we, "m", ot).call(this, this, e);
191
- }
192
- }
193
- we = /* @__PURE__ */ new WeakSet(), ot = function n(e, t) {
194
- return t != null && t(e) ? e : e.cause ? it(this, we, "m", n).call(this, e.cause, t) : e;
195
- };
196
- class Qt extends H {
197
- constructor() {
198
- super("Connector not connected."), Object.defineProperty(this, "name", {
199
- enumerable: !0,
200
- configurable: !0,
201
- writable: !0,
202
- value: "ConnectorNotConnectedError"
203
- });
204
- }
205
- }
206
- class Xt extends H {
207
- constructor({ address: e, connector: t }) {
208
- super(`Account "${e}" not found for connector "${t.name}".`), Object.defineProperty(this, "name", {
209
- enumerable: !0,
210
- configurable: !0,
211
- writable: !0,
212
- value: "ConnectorAccountNotFoundError"
213
- });
214
- }
215
- }
216
- class en extends H {
217
- constructor({ connectionChainId: e, connectorChainId: t }) {
218
- super(`The current chain of the connector (id: ${t}) does not match the connection's chain (id: ${e}).`, {
219
- metaMessages: [
220
- `Current Chain ID: ${t}`,
221
- `Expected Chain ID: ${e}`
222
- ]
223
- }), Object.defineProperty(this, "name", {
224
- enumerable: !0,
225
- configurable: !0,
226
- writable: !0,
227
- value: "ConnectorChainMismatchError"
228
- });
229
- }
230
- }
231
- class tn extends H {
232
- constructor({ connector: e }) {
233
- super(`Connector "${e.name}" unavailable while reconnecting.`, {
234
- details: [
235
- "During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uuid`.",
236
- "All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.",
237
- "This error commonly occurs for connectors that asynchronously inject after reconnection has already started."
238
- ].join(" ")
239
- }), Object.defineProperty(this, "name", {
240
- enumerable: !0,
241
- configurable: !0,
242
- writable: !0,
243
- value: "ConnectorUnavailableReconnectingError"
244
- });
245
- }
246
- }
247
- async function ct(n, e = {}) {
248
- let t;
249
- if (e.connector) {
250
- const { connector: c } = e;
251
- if (n.state.status === "reconnecting" && !c.getAccounts && !c.getChainId)
252
- throw new tn({ connector: c });
253
- const [m, C] = await Promise.all([
254
- c.getAccounts(),
255
- c.getChainId()
256
- ]);
257
- t = {
258
- accounts: m,
259
- chainId: C,
260
- connector: c
261
- };
262
- } else
263
- t = n.state.connections.get(n.state.current);
264
- if (!t)
265
- throw new Qt();
266
- const a = e.chainId ?? t.chainId, r = await t.connector.getChainId();
267
- if (r !== t.chainId)
268
- throw new en({
269
- connectionChainId: t.chainId,
270
- connectorChainId: r
271
- });
272
- const s = t.connector;
273
- if (s.getClient)
274
- return s.getClient({ chainId: a });
275
- const i = Mt(e.account ?? t.accounts[0]);
276
- if (i.address = Pt(i.address), e.account && !t.accounts.some((c) => c.toLowerCase() === i.address.toLowerCase()))
277
- throw new Xt({
278
- address: i.address,
279
- connector: s
280
- });
281
- const o = n.chains.find((c) => c.id === a), u = await t.connector.getProvider({ chainId: a });
282
- return $t({
283
- account: i,
284
- chain: o,
285
- name: "Connector Client",
286
- transport: (c) => Dt(u)({ ...c, retryCount: 0 })
287
- });
288
- }
289
- async function $e(n, e) {
290
- const { abi: t, chainId: a, connector: r, ...s } = e;
291
- let i;
292
- e.account ? i = e.account : i = (await ct(n, {
293
- chainId: a,
294
- connector: r
295
- })).account;
296
- const o = n.getClient({ chainId: a }), u = We(o, Vt, "simulateContract"), { result: c, request: m } = await u({ ...s, abi: t, account: i });
297
- return {
298
- chainId: o.chain.id,
299
- result: c,
300
- request: { __mode: "prepared", ...m, chainId: a }
301
- };
302
- }
303
- function Fe(n) {
304
- return n.address !== void 0 && typeof n.address == "object" ? (e, t) => {
305
- var a;
306
- const r = Ue(e), s = Ne(e), i = (t == null ? void 0 : t.chainId) ?? s.chainId ?? r;
307
- return $e(e, {
308
- ...t,
309
- ...n.functionName ? { functionName: n.functionName } : {},
310
- address: (a = n.address) == null ? void 0 : a[i],
311
- abi: n.abi
312
- });
313
- } : (e, t) => $e(e, {
314
- ...t,
315
- ...n.address ? { address: n.address } : {},
316
- ...n.functionName ? { functionName: n.functionName } : {},
317
- abi: n.abi
318
- });
319
- }
320
- function Qe(n, e) {
321
- const { chainId: t, ...a } = e, r = n.getClient({ chainId: t });
322
- return We(r, Bt, "readContract")(a);
323
- }
324
- function dt(n) {
325
- return n.address !== void 0 && typeof n.address == "object" ? (e, t) => {
326
- var a;
327
- const r = Ue(e), s = Ne(e), i = (t == null ? void 0 : t.chainId) ?? s.chainId ?? r;
328
- return Qe(e, {
329
- ...t,
330
- ...n.functionName ? { functionName: n.functionName } : {},
331
- address: (a = n.address) == null ? void 0 : a[i],
332
- abi: n.abi
333
- });
334
- } : (e, t) => Qe(e, {
335
- ...t,
336
- ...n.address ? { address: n.address } : {},
337
- ...n.functionName ? { functionName: n.functionName } : {},
338
- abi: n.abi
339
- });
340
- }
341
- async function Xe(n, e) {
342
- const { account: t, chainId: a, connector: r, __mode: s, ...i } = e;
343
- let o;
344
- typeof t == "object" && t.type === "local" ? o = n.getClient({ chainId: a }) : o = await ct(n, { account: t, chainId: a, connector: r });
345
- const { connector: u } = Ne(n);
346
- let c;
347
- if (s === "prepared" || u != null && u.supportsSimulation)
348
- c = i;
349
- else {
350
- const { request: m } = await $e(n, {
351
- ...i,
352
- account: t,
353
- chainId: a
354
- });
355
- c = m;
356
- }
357
- return await We(o, Lt, "writeContract")({
358
- ...c,
359
- ...t ? { account: t } : {},
360
- chain: a ? { id: a } : null
361
- });
362
- }
363
- function qe(n) {
364
- return n.address !== void 0 && typeof n.address == "object" ? (e, t) => {
365
- var a;
366
- const r = Ue(e), s = Ne(e);
367
- let i;
368
- return t.chainId ? i = t.chainId : t.account && t.account === s.address || t.account === void 0 ? i = s.chainId : i = r, Xe(e, {
369
- ...t,
370
- ...n.functionName ? { functionName: n.functionName } : {},
371
- address: i ? (a = n.address) == null ? void 0 : a[i] : void 0,
372
- abi: n.abi
373
- });
374
- } : (e, t) => Xe(e, {
375
- ...t,
376
- ...n.address ? { address: n.address } : {},
377
- ...n.functionName ? { functionName: n.functionName } : {},
378
- abi: n.abi
379
- });
380
- }
381
- const B = [
382
- { type: "error", inputs: [], name: "AllowanceOverflow" },
383
- { type: "error", inputs: [], name: "AllowanceUnderflow" },
384
- { type: "error", inputs: [], name: "InsufficientAllowance" },
385
- { type: "error", inputs: [], name: "InsufficientBalance" },
386
- { type: "error", inputs: [], name: "InvalidPermit" },
387
- { type: "error", inputs: [], name: "PermitExpired" },
388
- { type: "error", inputs: [], name: "TotalSupplyOverflow" },
389
- {
390
- type: "event",
391
- anonymous: !1,
392
- inputs: [
393
- {
394
- name: "owner",
395
- internalType: "address",
396
- type: "address",
397
- indexed: !0
398
- },
399
- {
400
- name: "spender",
401
- internalType: "address",
402
- type: "address",
403
- indexed: !0
404
- },
405
- {
406
- name: "amount",
407
- internalType: "uint256",
408
- type: "uint256",
409
- indexed: !1
410
- }
411
- ],
412
- name: "Approval"
413
- },
414
- {
415
- type: "event",
416
- anonymous: !1,
417
- inputs: [
418
- { name: "from", internalType: "address", type: "address", indexed: !0 },
419
- { name: "to", internalType: "address", type: "address", indexed: !0 },
420
- {
421
- name: "amount",
422
- internalType: "uint256",
423
- type: "uint256",
424
- indexed: !1
425
- }
426
- ],
427
- name: "Transfer"
428
- },
429
- {
430
- type: "function",
431
- inputs: [],
432
- name: "DOMAIN_SEPARATOR",
433
- outputs: [{ name: "result", internalType: "bytes32", type: "bytes32" }],
434
- stateMutability: "view"
435
- },
436
- {
437
- type: "function",
438
- inputs: [
439
- { name: "owner", internalType: "address", type: "address" },
440
- { name: "spender", internalType: "address", type: "address" }
441
- ],
442
- name: "allowance",
443
- outputs: [{ name: "result", internalType: "uint256", type: "uint256" }],
444
- stateMutability: "view"
445
- },
446
- {
447
- type: "function",
448
- inputs: [
449
- { name: "spender", internalType: "address", type: "address" },
450
- { name: "amount", internalType: "uint256", type: "uint256" }
451
- ],
452
- name: "approve",
453
- outputs: [{ name: "", internalType: "bool", type: "bool" }],
454
- stateMutability: "nonpayable"
455
- },
456
- {
457
- type: "function",
458
- inputs: [{ name: "owner", internalType: "address", type: "address" }],
459
- name: "balanceOf",
460
- outputs: [{ name: "result", internalType: "uint256", type: "uint256" }],
461
- stateMutability: "view"
462
- },
463
- {
464
- type: "function",
465
- inputs: [],
466
- name: "decimals",
467
- outputs: [{ name: "", internalType: "uint8", type: "uint8" }],
468
- stateMutability: "view"
469
- },
470
- {
471
- type: "function",
472
- inputs: [
473
- { name: "to", internalType: "address", type: "address" },
474
- { name: "amount", internalType: "uint256", type: "uint256" }
475
- ],
476
- name: "mint",
477
- outputs: [],
478
- stateMutability: "nonpayable"
479
- },
480
- {
481
- type: "function",
482
- inputs: [
483
- { name: "to", internalType: "address", type: "address" },
484
- { name: "amount", internalType: "uint256", type: "uint256" }
485
- ],
486
- name: "mintPayable",
487
- outputs: [],
488
- stateMutability: "payable"
489
- },
490
- {
491
- type: "function",
492
- inputs: [],
493
- name: "name",
494
- outputs: [{ name: "", internalType: "string", type: "string" }],
495
- stateMutability: "pure"
496
- },
497
- {
498
- type: "function",
499
- inputs: [{ name: "owner", internalType: "address", type: "address" }],
500
- name: "nonces",
501
- outputs: [{ name: "result", internalType: "uint256", type: "uint256" }],
502
- stateMutability: "view"
503
- },
504
- {
505
- type: "function",
506
- inputs: [
507
- { name: "owner", internalType: "address", type: "address" },
508
- { name: "spender", internalType: "address", type: "address" },
509
- { name: "value", internalType: "uint256", type: "uint256" },
510
- { name: "deadline", internalType: "uint256", type: "uint256" },
511
- { name: "v", internalType: "uint8", type: "uint8" },
512
- { name: "r", internalType: "bytes32", type: "bytes32" },
513
- { name: "s", internalType: "bytes32", type: "bytes32" }
514
- ],
515
- name: "permit",
516
- outputs: [],
517
- stateMutability: "nonpayable"
518
- },
519
- {
520
- type: "function",
521
- inputs: [],
522
- name: "symbol",
523
- outputs: [{ name: "", internalType: "string", type: "string" }],
524
- stateMutability: "pure"
525
- },
526
- {
527
- type: "function",
528
- inputs: [],
529
- name: "totalSupply",
530
- outputs: [{ name: "result", internalType: "uint256", type: "uint256" }],
531
- stateMutability: "view"
532
- },
533
- {
534
- type: "function",
535
- inputs: [
536
- { name: "to", internalType: "address", type: "address" },
537
- { name: "amount", internalType: "uint256", type: "uint256" }
538
- ],
539
- name: "transfer",
540
- outputs: [{ name: "", internalType: "bool", type: "bool" }],
541
- stateMutability: "nonpayable"
542
- },
543
- {
544
- type: "function",
545
- inputs: [
546
- { name: "from", internalType: "address", type: "address" },
547
- { name: "to", internalType: "address", type: "address" },
548
- { name: "amount", internalType: "uint256", type: "uint256" }
549
- ],
550
- name: "transferFrom",
551
- outputs: [{ name: "", internalType: "bool", type: "bool" }],
552
- stateMutability: "nonpayable"
553
- }
554
- ], nn = /* @__PURE__ */ dt({
555
- abi: B,
556
- functionName: "allowance"
557
- }), an = /* @__PURE__ */ dt({
558
- abi: B,
559
- functionName: "balanceOf"
560
- }), rn = /* @__PURE__ */ qe({
561
- abi: B,
562
- functionName: "approve"
563
- }), sn = /* @__PURE__ */ qe({
564
- abi: B,
565
- functionName: "mint"
566
- }), on = /* @__PURE__ */ qe({
567
- abi: B,
568
- functionName: "mintPayable"
569
- }), cn = /* @__PURE__ */ Fe({
570
- abi: B,
571
- functionName: "approve"
572
- }), dn = /* @__PURE__ */ Fe({
573
- abi: B,
574
- functionName: "mint"
575
- }), un = /* @__PURE__ */ Fe({
576
- abi: B,
577
- functionName: "mintPayable"
578
- }), ln = "0x6080604052348015600e575f80fd5b50610e138061001c5f395ff3fe6080604052600436106100dc575f3560e01c806340c10f191161007e57806395d89b411161005857806395d89b41146102bc578063a9059cbb146102e6578063d505accf14610322578063dd62ed3e1461034a576100dc565b806340c10f191461021c57806370a08231146102445780637ecebe0014610280576100dc565b806318160ddd116100ba57806318160ddd1461016257806323b872dd1461018c578063313ce567146101c85780633644e515146101f2576100dc565b806306fdde03146100e0578063095ea7b31461010a57806317d304b014610146575b5f80fd5b3480156100eb575f80fd5b506100f4610386565b60405161010191906109bf565b60405180910390f35b348015610115575f80fd5b50610130600480360381019061012b9190610a70565b6103c3565b60405161013d9190610ac8565b60405180910390f35b610160600480360381019061015b9190610a70565b610413565b005b34801561016d575f80fd5b50610176610470565b6040516101839190610af0565b60405180910390f35b348015610197575f80fd5b506101b260048036038101906101ad9190610b09565b610481565b6040516101bf9190610ac8565b60405180910390f35b3480156101d3575f80fd5b506101dc610552565b6040516101e99190610b74565b60405180910390f35b3480156101fd575f80fd5b5061020661055a565b6040516102139190610ba5565b60405180910390f35b348015610227575f80fd5b50610242600480360381019061023d9190610a70565b6105ea565b005b34801561024f575f80fd5b5061026a60048036038101906102659190610bbe565b6105f8565b6040516102779190610af0565b60405180910390f35b34801561028b575f80fd5b506102a660048036038101906102a19190610bbe565b610611565b6040516102b39190610af0565b60405180910390f35b3480156102c7575f80fd5b506102d061062a565b6040516102dd91906109bf565b60405180910390f35b3480156102f1575f80fd5b5061030c60048036038101906103079190610a70565b610667565b6040516103199190610ac8565b60405180910390f35b34801561032d575f80fd5b5061034860048036038101906103439190610c3d565b6106f5565b005b348015610355575f80fd5b50610370600480360381019061036b9190610cda565b610891565b60405161037d9190610af0565b60405180910390f35b60606040518060400160405280600a81526020017f4d6f636b20455243323000000000000000000000000000000000000000000000815250905090565b5f82602052637f5e9f20600c52335f52816034600c2055815f52602c5160601c337f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560205fa36001905092915050565b6064816104209190610d45565b341015610462576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045990610dbf565b60405180910390fd5b61046c82826108af565b5050565b5f6805345cdf77eb68f44c54905090565b5f61048d848484610941565b8360601b33602052637f5e9f208117600c526034600c20805460018101156104ca57808511156104c4576313be252b5f526004601cfd5b84810382555b6387a211a28317600c526020600c208054808711156104f05763f4d678b85f526004601cfd5b8681038255875f526020600c2087815401815587602052600c5160601c8660601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a3505050505050610547848484610946565b600190509392505050565b5f6012905090565b5f8061056461094b565b90505f801b810361058157610577610386565b8051906020012090505b6040517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81528160208201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6604082015246606082015230608082015260a081209250505090565b6105f482826108af565b5050565b5f6387a211a2600c52815f526020600c20549050919050565b5f6338377508600c52815f526020600c20549050919050565b60606040518060400160405280600481526020017f4d4f434b00000000000000000000000000000000000000000000000000000000815250905090565b5f610673338484610941565b6387a211a2600c52335f526020600c2080548084111561069a5763f4d678b85f526004601cfd5b8381038255845f526020600c2084815401815584602052600c5160601c337fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a35050506106eb338484610946565b6001905092915050565b5f6106fe61094b565b90505f801b810361071b57610711610386565b8051906020012090505b8442111561073057631a15a3cc5f526004601cfd5b6040518860601b60601c98508760601b60601c975065383775081901600e52885f526020600c2080547f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f83528360208401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6604084015246606084015230608084015260a08320602e527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c983528a60208401528960408401528860608401528060808401528760a084015260c08320604e526042602c205f528660ff16602052856040528460605260208060805f60015afa8b3d51146108385763ddafbaef5f526004601cfd5b80820183558a637f5e9f2060a01b17604052896034602c20558a8c7f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925602060608801a3836040525f606052505050505050505050505050565b5f81602052637f5e9f20600c52825f526034600c2054905092915050565b6108ba5f8383610941565b6805345cdf77eb68f44c54818101818110156108dd5763e5cfe9575f526004601cfd5b806805345cdf77eb68f44c556387a211a2600c52835f526020600c2083815401815583602052600c5160601c5f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602080a350505061093d5f8383610946565b5050565b505050565b505050565b5f90565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f6109918261094f565b61099b8185610959565b93506109ab818560208601610969565b6109b481610977565b840191505092915050565b5f6020820190508181035f8301526109d78184610987565b905092915050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610a0c826109e3565b9050919050565b610a1c81610a02565b8114610a26575f80fd5b50565b5f81359050610a3781610a13565b92915050565b5f819050919050565b610a4f81610a3d565b8114610a59575f80fd5b50565b5f81359050610a6a81610a46565b92915050565b5f8060408385031215610a8657610a856109df565b5b5f610a9385828601610a29565b9250506020610aa485828601610a5c565b9150509250929050565b5f8115159050919050565b610ac281610aae565b82525050565b5f602082019050610adb5f830184610ab9565b92915050565b610aea81610a3d565b82525050565b5f602082019050610b035f830184610ae1565b92915050565b5f805f60608486031215610b2057610b1f6109df565b5b5f610b2d86828701610a29565b9350506020610b3e86828701610a29565b9250506040610b4f86828701610a5c565b9150509250925092565b5f60ff82169050919050565b610b6e81610b59565b82525050565b5f602082019050610b875f830184610b65565b92915050565b5f819050919050565b610b9f81610b8d565b82525050565b5f602082019050610bb85f830184610b96565b92915050565b5f60208284031215610bd357610bd26109df565b5b5f610be084828501610a29565b91505092915050565b610bf281610b59565b8114610bfc575f80fd5b50565b5f81359050610c0d81610be9565b92915050565b610c1c81610b8d565b8114610c26575f80fd5b50565b5f81359050610c3781610c13565b92915050565b5f805f805f805f60e0888a031215610c5857610c576109df565b5b5f610c658a828b01610a29565b9750506020610c768a828b01610a29565b9650506040610c878a828b01610a5c565b9550506060610c988a828b01610a5c565b9450506080610ca98a828b01610bff565b93505060a0610cba8a828b01610c29565b92505060c0610ccb8a828b01610c29565b91505092959891949750929550565b5f8060408385031215610cf057610cef6109df565b5b5f610cfd85828601610a29565b9250506020610d0e85828601610a29565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f610d4f82610a3d565b9150610d5a83610a3d565b925082610d6a57610d69610d18565b5b828204905092915050565b7f4d6f636b45524332303a2067696d6d65206d6f7265206d6f6e657921000000005f82015250565b5f610da9601c83610959565b9150610db482610d75565b602082019050919050565b5f6020820190508181035f830152610dd681610d9d565b905091905056fea264697066735822122014217224d57712700b62f2706b7c6ccac676419103ff9ccb6b43ece3d5b783f164736f6c634300081a0033";
579
- class ut extends It {
580
- async balanceOf(e, t) {
581
- return await an(this._config, {
582
- address: this.assertValidAddress(),
583
- args: [e],
584
- // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
585
- ...t
586
- });
587
- }
588
- async allowance(e, t, a) {
589
- return await nn(this._config, {
590
- address: this.assertValidAddress(),
591
- args: [e, t],
592
- // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
593
- ...a
594
- });
595
- }
596
- async approve(e, t, a) {
597
- return await this.awaitResult(this.approveRaw(e, t, a));
598
- }
599
- async approveRaw(e, t, a) {
600
- const { request: r, result: s } = await cn(this._config, {
601
- address: this.assertValidAddress(),
602
- args: [e, t],
603
- ...this.optionallyAttachAccount(),
604
- // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
605
- ...a
606
- });
607
- return { hash: await rn(this._config, r), result: s };
608
- }
609
- async mint(e, t, a) {
610
- return await this.awaitResult(this.mintRaw(e, t, a));
611
- }
612
- async mintRaw(e, t, a) {
613
- const { request: r, result: s } = await dn(this._config, {
614
- address: this.assertValidAddress(),
615
- args: [e, t],
616
- ...this.optionallyAttachAccount(),
617
- // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
618
- ...a
619
- });
620
- return { hash: await sn(this._config, r), result: s };
621
- }
622
- async mintPayable(e, t, a) {
623
- return await this.awaitResult(
624
- // biome-ignore lint/suspicious/noExplicitAny: this is a mock contract, it's fine
625
- this.mintPayableRaw(e, t, a)
626
- );
627
- }
628
- async mintPayableRaw(e, t, a) {
629
- const { request: r, result: s } = await un(
630
- this._config,
631
- {
632
- address: this.assertValidAddress(),
633
- args: [e, t],
634
- ...this.optionallyAttachAccount(),
635
- // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
636
- ...a
637
- }
638
- );
639
- return { hash: await on(this._config, r), result: s };
640
- }
641
- buildParameters(e = {}, t) {
642
- const [, a] = this.validateDeploymentConfig(e, t);
643
- return {
644
- abi: B,
645
- bytecode: ln,
646
- ...this.optionallyAttachAccount(a.account)
647
- };
648
- }
649
- }
650
- const fn = [
651
- {
652
- account: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
653
- key: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
654
- },
655
- {
656
- account: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
657
- key: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
658
- },
659
- {
660
- account: "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
661
- key: "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a"
662
- },
663
- {
664
- account: "0x90F79bf6EB2c4f870365E785982E1f101E93b906",
665
- key: "0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6"
666
- },
667
- {
668
- account: "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65",
669
- key: "0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a"
670
- },
671
- {
672
- account: "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",
673
- key: "0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba"
674
- },
675
- {
676
- account: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
677
- key: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
678
- },
679
- {
680
- account: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
681
- key: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
682
- },
683
- {
684
- account: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
685
- key: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
686
- },
687
- {
688
- account: "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
689
- key: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
690
- }
691
- ].map((n) => ({
692
- ...n,
693
- privateKey: zt(n.key)
694
- }));
695
- var _;
696
- (function(n) {
697
- n.assertEqual = (r) => r;
698
- function e(r) {
699
- }
700
- n.assertIs = e;
701
- function t(r) {
702
- throw new Error();
703
- }
704
- n.assertNever = t, n.arrayToEnum = (r) => {
705
- const s = {};
706
- for (const i of r)
707
- s[i] = i;
708
- return s;
709
- }, n.getValidEnumValues = (r) => {
710
- const s = n.objectKeys(r).filter((o) => typeof r[r[o]] != "number"), i = {};
711
- for (const o of s)
712
- i[o] = r[o];
713
- return n.objectValues(i);
714
- }, n.objectValues = (r) => n.objectKeys(r).map(function(s) {
715
- return r[s];
716
- }), n.objectKeys = typeof Object.keys == "function" ? (r) => Object.keys(r) : (r) => {
717
- const s = [];
718
- for (const i in r)
719
- Object.prototype.hasOwnProperty.call(r, i) && s.push(i);
720
- return s;
721
- }, n.find = (r, s) => {
722
- for (const i of r)
723
- if (s(i))
724
- return i;
725
- }, n.isInteger = typeof Number.isInteger == "function" ? (r) => Number.isInteger(r) : (r) => typeof r == "number" && isFinite(r) && Math.floor(r) === r;
726
- function a(r, s = " | ") {
727
- return r.map((i) => typeof i == "string" ? `'${i}'` : i).join(s);
728
- }
729
- n.joinValues = a, n.jsonStringifyReplacer = (r, s) => typeof s == "bigint" ? s.toString() : s;
730
- })(_ || (_ = {}));
731
- var De;
732
- (function(n) {
733
- n.mergeShapes = (e, t) => ({
734
- ...e,
735
- ...t
736
- // second overwrites first
737
- });
738
- })(De || (De = {}));
739
- const h = _.arrayToEnum([
740
- "string",
741
- "nan",
742
- "number",
743
- "integer",
744
- "float",
745
- "boolean",
746
- "date",
747
- "bigint",
748
- "symbol",
749
- "function",
750
- "undefined",
751
- "null",
752
- "array",
753
- "object",
754
- "unknown",
755
- "promise",
756
- "void",
757
- "never",
758
- "map",
759
- "set"
760
- ]), L = (n) => {
761
- switch (typeof n) {
762
- case "undefined":
763
- return h.undefined;
764
- case "string":
765
- return h.string;
766
- case "number":
767
- return isNaN(n) ? h.nan : h.number;
768
- case "boolean":
769
- return h.boolean;
770
- case "function":
771
- return h.function;
772
- case "bigint":
773
- return h.bigint;
774
- case "symbol":
775
- return h.symbol;
776
- case "object":
777
- return Array.isArray(n) ? h.array : n === null ? h.null : n.then && typeof n.then == "function" && n.catch && typeof n.catch == "function" ? h.promise : typeof Map < "u" && n instanceof Map ? h.map : typeof Set < "u" && n instanceof Set ? h.set : typeof Date < "u" && n instanceof Date ? h.date : h.object;
778
- default:
779
- return h.unknown;
780
- }
781
- }, d = _.arrayToEnum([
782
- "invalid_type",
783
- "invalid_literal",
784
- "custom",
785
- "invalid_union",
786
- "invalid_union_discriminator",
787
- "invalid_enum_value",
788
- "unrecognized_keys",
789
- "invalid_arguments",
790
- "invalid_return_type",
791
- "invalid_date",
792
- "invalid_string",
793
- "too_small",
794
- "too_big",
795
- "invalid_intersection_types",
796
- "not_multiple_of",
797
- "not_finite"
798
- ]), hn = (n) => JSON.stringify(n, null, 2).replace(/"([^"]+)":/g, "$1:");
799
- class E extends Error {
800
- constructor(e) {
801
- super(), this.issues = [], this.addIssue = (a) => {
802
- this.issues = [...this.issues, a];
803
- }, this.addIssues = (a = []) => {
804
- this.issues = [...this.issues, ...a];
805
- };
806
- const t = new.target.prototype;
807
- Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
808
- }
809
- get errors() {
810
- return this.issues;
811
- }
812
- format(e) {
813
- const t = e || function(s) {
814
- return s.message;
815
- }, a = { _errors: [] }, r = (s) => {
816
- for (const i of s.issues)
817
- if (i.code === "invalid_union")
818
- i.unionErrors.map(r);
819
- else if (i.code === "invalid_return_type")
820
- r(i.returnTypeError);
821
- else if (i.code === "invalid_arguments")
822
- r(i.argumentsError);
823
- else if (i.path.length === 0)
824
- a._errors.push(t(i));
825
- else {
826
- let o = a, u = 0;
827
- for (; u < i.path.length; ) {
828
- const c = i.path[u];
829
- u === i.path.length - 1 ? (o[c] = o[c] || { _errors: [] }, o[c]._errors.push(t(i))) : o[c] = o[c] || { _errors: [] }, o = o[c], u++;
830
- }
831
- }
832
- };
833
- return r(this), a;
834
- }
835
- static assert(e) {
836
- if (!(e instanceof E))
837
- throw new Error(`Not a ZodError: ${e}`);
838
- }
839
- toString() {
840
- return this.message;
841
- }
842
- get message() {
843
- return JSON.stringify(this.issues, _.jsonStringifyReplacer, 2);
844
- }
845
- get isEmpty() {
846
- return this.issues.length === 0;
847
- }
848
- flatten(e = (t) => t.message) {
849
- const t = {}, a = [];
850
- for (const r of this.issues)
851
- r.path.length > 0 ? (t[r.path[0]] = t[r.path[0]] || [], t[r.path[0]].push(e(r))) : a.push(e(r));
852
- return { formErrors: a, fieldErrors: t };
853
- }
854
- get formErrors() {
855
- return this.flatten();
856
- }
857
- }
858
- E.create = (n) => new E(n);
859
- const ee = (n, e) => {
860
- let t;
861
- switch (n.code) {
862
- case d.invalid_type:
863
- n.received === h.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
864
- break;
865
- case d.invalid_literal:
866
- t = `Invalid literal value, expected ${JSON.stringify(n.expected, _.jsonStringifyReplacer)}`;
867
- break;
868
- case d.unrecognized_keys:
869
- t = `Unrecognized key(s) in object: ${_.joinValues(n.keys, ", ")}`;
870
- break;
871
- case d.invalid_union:
872
- t = "Invalid input";
873
- break;
874
- case d.invalid_union_discriminator:
875
- t = `Invalid discriminator value. Expected ${_.joinValues(n.options)}`;
876
- break;
877
- case d.invalid_enum_value:
878
- t = `Invalid enum value. Expected ${_.joinValues(n.options)}, received '${n.received}'`;
879
- break;
880
- case d.invalid_arguments:
881
- t = "Invalid function arguments";
882
- break;
883
- case d.invalid_return_type:
884
- t = "Invalid function return type";
885
- break;
886
- case d.invalid_date:
887
- t = "Invalid date";
888
- break;
889
- case d.invalid_string:
890
- typeof n.validation == "object" ? "includes" in n.validation ? (t = `Invalid input: must include "${n.validation.includes}"`, typeof n.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${n.validation.position}`)) : "startsWith" in n.validation ? t = `Invalid input: must start with "${n.validation.startsWith}"` : "endsWith" in n.validation ? t = `Invalid input: must end with "${n.validation.endsWith}"` : _.assertNever(n.validation) : n.validation !== "regex" ? t = `Invalid ${n.validation}` : t = "Invalid";
891
- break;
892
- case d.too_small:
893
- n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "more than"} ${n.minimum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "over"} ${n.minimum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(n.minimum))}` : t = "Invalid input";
894
- break;
895
- case d.too_big:
896
- n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "less than"} ${n.maximum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "under"} ${n.maximum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "bigint" ? t = `BigInt must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly" : n.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(n.maximum))}` : t = "Invalid input";
897
- break;
898
- case d.custom:
899
- t = "Invalid input";
900
- break;
901
- case d.invalid_intersection_types:
902
- t = "Intersection results could not be merged";
903
- break;
904
- case d.not_multiple_of:
905
- t = `Number must be a multiple of ${n.multipleOf}`;
906
- break;
907
- case d.not_finite:
908
- t = "Number must be finite";
909
- break;
910
- default:
911
- t = e.defaultError, _.assertNever(n);
912
- }
913
- return { message: t };
914
- };
915
- let lt = ee;
916
- function pn(n) {
917
- lt = n;
918
- }
919
- function ke() {
920
- return lt;
921
- }
922
- const Te = (n) => {
923
- const { data: e, path: t, errorMaps: a, issueData: r } = n, s = [...t, ...r.path || []], i = {
924
- ...r,
925
- path: s
926
- };
927
- if (r.message !== void 0)
928
- return {
929
- ...r,
930
- path: s,
931
- message: r.message
932
- };
933
- let o = "";
934
- const u = a.filter((c) => !!c).slice().reverse();
935
- for (const c of u)
936
- o = c(i, { data: e, defaultError: o }).message;
937
- return {
938
- ...r,
939
- path: s,
940
- message: o
941
- };
942
- }, mn = [];
943
- function f(n, e) {
944
- const t = ke(), a = Te({
945
- issueData: e,
946
- data: n.data,
947
- path: n.path,
948
- errorMaps: [
949
- n.common.contextualErrorMap,
950
- n.schemaErrorMap,
951
- t,
952
- t === ee ? void 0 : ee
953
- // then global default map
954
- ].filter((r) => !!r)
955
- });
956
- n.common.issues.push(a);
957
- }
958
- class I {
959
- constructor() {
960
- this.value = "valid";
961
- }
962
- dirty() {
963
- this.value === "valid" && (this.value = "dirty");
964
- }
965
- abort() {
966
- this.value !== "aborted" && (this.value = "aborted");
967
- }
968
- static mergeArray(e, t) {
969
- const a = [];
970
- for (const r of t) {
971
- if (r.status === "aborted")
972
- return b;
973
- r.status === "dirty" && e.dirty(), a.push(r.value);
974
- }
975
- return { status: e.value, value: a };
976
- }
977
- static async mergeObjectAsync(e, t) {
978
- const a = [];
979
- for (const r of t) {
980
- const s = await r.key, i = await r.value;
981
- a.push({
982
- key: s,
983
- value: i
984
- });
985
- }
986
- return I.mergeObjectSync(e, a);
987
- }
988
- static mergeObjectSync(e, t) {
989
- const a = {};
990
- for (const r of t) {
991
- const { key: s, value: i } = r;
992
- if (s.status === "aborted" || i.status === "aborted")
993
- return b;
994
- s.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), s.value !== "__proto__" && (typeof i.value < "u" || r.alwaysSet) && (a[s.value] = i.value);
995
- }
996
- return { status: e.value, value: a };
997
- }
998
- }
999
- const b = Object.freeze({
1000
- status: "aborted"
1001
- }), Q = (n) => ({ status: "dirty", value: n }), A = (n) => ({ status: "valid", value: n }), Ve = (n) => n.status === "aborted", Be = (n) => n.status === "dirty", ie = (n) => n.status === "valid", oe = (n) => typeof Promise < "u" && n instanceof Promise;
1002
- function Ce(n, e, t, a) {
1003
- if (typeof e == "function" ? n !== e || !a : !e.has(n)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1004
- return e.get(n);
1005
- }
1006
- function ft(n, e, t, a, r) {
1007
- if (typeof e == "function" ? n !== e || !r : !e.has(n)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1008
- return e.set(n, t), t;
1009
- }
1010
- var p;
1011
- (function(n) {
1012
- n.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, n.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
1013
- })(p || (p = {}));
1014
- var ae, re;
1015
- class j {
1016
- constructor(e, t, a, r) {
1017
- this._cachedPath = [], this.parent = e, this.data = t, this._path = a, this._key = r;
1018
- }
1019
- get path() {
1020
- return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
1021
- }
1022
- }
1023
- const et = (n, e) => {
1024
- if (ie(e))
1025
- return { success: !0, data: e.value };
1026
- if (!n.common.issues.length)
1027
- throw new Error("Validation failed but no issues detected.");
1028
- return {
1029
- success: !1,
1030
- get error() {
1031
- if (this._error)
1032
- return this._error;
1033
- const t = new E(n.common.issues);
1034
- return this._error = t, this._error;
1035
- }
1036
- };
1037
- };
1038
- function g(n) {
1039
- if (!n)
1040
- return {};
1041
- const { errorMap: e, invalid_type_error: t, required_error: a, description: r } = n;
1042
- if (e && (t || a))
1043
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
1044
- return e ? { errorMap: e, description: r } : { errorMap: (i, o) => {
1045
- var u, c;
1046
- const { message: m } = n;
1047
- return i.code === "invalid_enum_value" ? { message: m ?? o.defaultError } : typeof o.data > "u" ? { message: (u = m ?? a) !== null && u !== void 0 ? u : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (c = m ?? t) !== null && c !== void 0 ? c : o.defaultError };
1048
- }, description: r };
1049
- }
1050
- class v {
1051
- constructor(e) {
1052
- 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);
1053
- }
1054
- get description() {
1055
- return this._def.description;
1056
- }
1057
- _getType(e) {
1058
- return L(e.data);
1059
- }
1060
- _getOrReturnCtx(e, t) {
1061
- return t || {
1062
- common: e.parent.common,
1063
- data: e.data,
1064
- parsedType: L(e.data),
1065
- schemaErrorMap: this._def.errorMap,
1066
- path: e.path,
1067
- parent: e.parent
1068
- };
1069
- }
1070
- _processInputParams(e) {
1071
- return {
1072
- status: new I(),
1073
- ctx: {
1074
- common: e.parent.common,
1075
- data: e.data,
1076
- parsedType: L(e.data),
1077
- schemaErrorMap: this._def.errorMap,
1078
- path: e.path,
1079
- parent: e.parent
1080
- }
1081
- };
1082
- }
1083
- _parseSync(e) {
1084
- const t = this._parse(e);
1085
- if (oe(t))
1086
- throw new Error("Synchronous parse encountered promise.");
1087
- return t;
1088
- }
1089
- _parseAsync(e) {
1090
- const t = this._parse(e);
1091
- return Promise.resolve(t);
1092
- }
1093
- parse(e, t) {
1094
- const a = this.safeParse(e, t);
1095
- if (a.success)
1096
- return a.data;
1097
- throw a.error;
1098
- }
1099
- safeParse(e, t) {
1100
- var a;
1101
- const r = {
1102
- common: {
1103
- issues: [],
1104
- async: (a = t == null ? void 0 : t.async) !== null && a !== void 0 ? a : !1,
1105
- contextualErrorMap: t == null ? void 0 : t.errorMap
1106
- },
1107
- path: (t == null ? void 0 : t.path) || [],
1108
- schemaErrorMap: this._def.errorMap,
1109
- parent: null,
1110
- data: e,
1111
- parsedType: L(e)
1112
- }, s = this._parseSync({ data: e, path: r.path, parent: r });
1113
- return et(r, s);
1114
- }
1115
- async parseAsync(e, t) {
1116
- const a = await this.safeParseAsync(e, t);
1117
- if (a.success)
1118
- return a.data;
1119
- throw a.error;
1120
- }
1121
- async safeParseAsync(e, t) {
1122
- const a = {
1123
- common: {
1124
- issues: [],
1125
- contextualErrorMap: t == null ? void 0 : t.errorMap,
1126
- async: !0
1127
- },
1128
- path: (t == null ? void 0 : t.path) || [],
1129
- schemaErrorMap: this._def.errorMap,
1130
- parent: null,
1131
- data: e,
1132
- parsedType: L(e)
1133
- }, r = this._parse({ data: e, path: a.path, parent: a }), s = await (oe(r) ? r : Promise.resolve(r));
1134
- return et(a, s);
1135
- }
1136
- refine(e, t) {
1137
- const a = (r) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(r) : t;
1138
- return this._refinement((r, s) => {
1139
- const i = e(r), o = () => s.addIssue({
1140
- code: d.custom,
1141
- ...a(r)
1142
- });
1143
- return typeof Promise < "u" && i instanceof Promise ? i.then((u) => u ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
1144
- });
1145
- }
1146
- refinement(e, t) {
1147
- return this._refinement((a, r) => e(a) ? !0 : (r.addIssue(typeof t == "function" ? t(a, r) : t), !1));
1148
- }
1149
- _refinement(e) {
1150
- return new R({
1151
- schema: this,
1152
- typeName: y.ZodEffects,
1153
- effect: { type: "refinement", refinement: e }
1154
- });
1155
- }
1156
- superRefine(e) {
1157
- return this._refinement(e);
1158
- }
1159
- optional() {
1160
- return Z.create(this, this._def);
1161
- }
1162
- nullable() {
1163
- return F.create(this, this._def);
1164
- }
1165
- nullish() {
1166
- return this.nullable().optional();
1167
- }
1168
- array() {
1169
- return O.create(this, this._def);
1170
- }
1171
- promise() {
1172
- return ne.create(this, this._def);
1173
- }
1174
- or(e) {
1175
- return le.create([this, e], this._def);
1176
- }
1177
- and(e) {
1178
- return fe.create(this, e, this._def);
1179
- }
1180
- transform(e) {
1181
- return new R({
1182
- ...g(this._def),
1183
- schema: this,
1184
- typeName: y.ZodEffects,
1185
- effect: { type: "transform", transform: e }
1186
- });
1187
- }
1188
- default(e) {
1189
- const t = typeof e == "function" ? e : () => e;
1190
- return new be({
1191
- ...g(this._def),
1192
- innerType: this,
1193
- defaultValue: t,
1194
- typeName: y.ZodDefault
1195
- });
1196
- }
1197
- brand() {
1198
- return new He({
1199
- typeName: y.ZodBranded,
1200
- type: this,
1201
- ...g(this._def)
1202
- });
1203
- }
1204
- catch(e) {
1205
- const t = typeof e == "function" ? e : () => e;
1206
- return new ge({
1207
- ...g(this._def),
1208
- innerType: this,
1209
- catchValue: t,
1210
- typeName: y.ZodCatch
1211
- });
1212
- }
1213
- describe(e) {
1214
- const t = this.constructor;
1215
- return new t({
1216
- ...this._def,
1217
- description: e
1218
- });
1219
- }
1220
- pipe(e) {
1221
- return _e.create(this, e);
1222
- }
1223
- readonly() {
1224
- return ve.create(this);
1225
- }
1226
- isOptional() {
1227
- return this.safeParse(void 0).success;
1228
- }
1229
- isNullable() {
1230
- return this.safeParse(null).success;
1231
- }
1232
- }
1233
- const yn = /^c[^\s-]{8,}$/i, bn = /^[0-9a-z]+$/, gn = /^[0-9A-HJKMNP-TV-Z]{26}$/, vn = /^[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, _n = /^[a-z0-9_-]{21}$/i, xn = /^[-+]?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)?)??$/, wn = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, kn = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
1234
- let je;
1235
- const Tn = /^(?:(?: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])$/, Cn = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/, Sn = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, ht = "((\\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])))", In = new RegExp(`^${ht}$`);
1236
- function pt(n) {
1237
- let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
1238
- return n.precision ? e = `${e}\\.\\d{${n.precision}}` : n.precision == null && (e = `${e}(\\.\\d+)?`), e;
1239
- }
1240
- function An(n) {
1241
- return new RegExp(`^${pt(n)}$`);
1242
- }
1243
- function mt(n) {
1244
- let e = `${ht}T${pt(n)}`;
1245
- const t = [];
1246
- return t.push(n.local ? "Z?" : "Z"), n.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
1247
- }
1248
- function En(n, e) {
1249
- return !!((e === "v4" || !e) && Tn.test(n) || (e === "v6" || !e) && Cn.test(n));
1250
- }
1251
- class N extends v {
1252
- _parse(e) {
1253
- if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
1254
- const s = this._getOrReturnCtx(e);
1255
- return f(s, {
1256
- code: d.invalid_type,
1257
- expected: h.string,
1258
- received: s.parsedType
1259
- }), b;
1260
- }
1261
- const a = new I();
1262
- let r;
1263
- for (const s of this._def.checks)
1264
- if (s.kind === "min")
1265
- e.data.length < s.value && (r = this._getOrReturnCtx(e, r), f(r, {
1266
- code: d.too_small,
1267
- minimum: s.value,
1268
- type: "string",
1269
- inclusive: !0,
1270
- exact: !1,
1271
- message: s.message
1272
- }), a.dirty());
1273
- else if (s.kind === "max")
1274
- e.data.length > s.value && (r = this._getOrReturnCtx(e, r), f(r, {
1275
- code: d.too_big,
1276
- maximum: s.value,
1277
- type: "string",
1278
- inclusive: !0,
1279
- exact: !1,
1280
- message: s.message
1281
- }), a.dirty());
1282
- else if (s.kind === "length") {
1283
- const i = e.data.length > s.value, o = e.data.length < s.value;
1284
- (i || o) && (r = this._getOrReturnCtx(e, r), i ? f(r, {
1285
- code: d.too_big,
1286
- maximum: s.value,
1287
- type: "string",
1288
- inclusive: !0,
1289
- exact: !0,
1290
- message: s.message
1291
- }) : o && f(r, {
1292
- code: d.too_small,
1293
- minimum: s.value,
1294
- type: "string",
1295
- inclusive: !0,
1296
- exact: !0,
1297
- message: s.message
1298
- }), a.dirty());
1299
- } else if (s.kind === "email")
1300
- wn.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1301
- validation: "email",
1302
- code: d.invalid_string,
1303
- message: s.message
1304
- }), a.dirty());
1305
- else if (s.kind === "emoji")
1306
- je || (je = new RegExp(kn, "u")), je.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1307
- validation: "emoji",
1308
- code: d.invalid_string,
1309
- message: s.message
1310
- }), a.dirty());
1311
- else if (s.kind === "uuid")
1312
- vn.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1313
- validation: "uuid",
1314
- code: d.invalid_string,
1315
- message: s.message
1316
- }), a.dirty());
1317
- else if (s.kind === "nanoid")
1318
- _n.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1319
- validation: "nanoid",
1320
- code: d.invalid_string,
1321
- message: s.message
1322
- }), a.dirty());
1323
- else if (s.kind === "cuid")
1324
- yn.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1325
- validation: "cuid",
1326
- code: d.invalid_string,
1327
- message: s.message
1328
- }), a.dirty());
1329
- else if (s.kind === "cuid2")
1330
- bn.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1331
- validation: "cuid2",
1332
- code: d.invalid_string,
1333
- message: s.message
1334
- }), a.dirty());
1335
- else if (s.kind === "ulid")
1336
- gn.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1337
- validation: "ulid",
1338
- code: d.invalid_string,
1339
- message: s.message
1340
- }), a.dirty());
1341
- else if (s.kind === "url")
1342
- try {
1343
- new URL(e.data);
1344
- } catch {
1345
- r = this._getOrReturnCtx(e, r), f(r, {
1346
- validation: "url",
1347
- code: d.invalid_string,
1348
- message: s.message
1349
- }), a.dirty();
1350
- }
1351
- else s.kind === "regex" ? (s.regex.lastIndex = 0, s.regex.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1352
- validation: "regex",
1353
- code: d.invalid_string,
1354
- message: s.message
1355
- }), a.dirty())) : s.kind === "trim" ? e.data = e.data.trim() : s.kind === "includes" ? e.data.includes(s.value, s.position) || (r = this._getOrReturnCtx(e, r), f(r, {
1356
- code: d.invalid_string,
1357
- validation: { includes: s.value, position: s.position },
1358
- message: s.message
1359
- }), a.dirty()) : s.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : s.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : s.kind === "startsWith" ? e.data.startsWith(s.value) || (r = this._getOrReturnCtx(e, r), f(r, {
1360
- code: d.invalid_string,
1361
- validation: { startsWith: s.value },
1362
- message: s.message
1363
- }), a.dirty()) : s.kind === "endsWith" ? e.data.endsWith(s.value) || (r = this._getOrReturnCtx(e, r), f(r, {
1364
- code: d.invalid_string,
1365
- validation: { endsWith: s.value },
1366
- message: s.message
1367
- }), a.dirty()) : s.kind === "datetime" ? mt(s).test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1368
- code: d.invalid_string,
1369
- validation: "datetime",
1370
- message: s.message
1371
- }), a.dirty()) : s.kind === "date" ? In.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1372
- code: d.invalid_string,
1373
- validation: "date",
1374
- message: s.message
1375
- }), a.dirty()) : s.kind === "time" ? An(s).test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1376
- code: d.invalid_string,
1377
- validation: "time",
1378
- message: s.message
1379
- }), a.dirty()) : s.kind === "duration" ? xn.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1380
- validation: "duration",
1381
- code: d.invalid_string,
1382
- message: s.message
1383
- }), a.dirty()) : s.kind === "ip" ? En(e.data, s.version) || (r = this._getOrReturnCtx(e, r), f(r, {
1384
- validation: "ip",
1385
- code: d.invalid_string,
1386
- message: s.message
1387
- }), a.dirty()) : s.kind === "base64" ? Sn.test(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1388
- validation: "base64",
1389
- code: d.invalid_string,
1390
- message: s.message
1391
- }), a.dirty()) : _.assertNever(s);
1392
- return { status: a.value, value: e.data };
1393
- }
1394
- _regex(e, t, a) {
1395
- return this.refinement((r) => e.test(r), {
1396
- validation: t,
1397
- code: d.invalid_string,
1398
- ...p.errToObj(a)
1399
- });
1400
- }
1401
- _addCheck(e) {
1402
- return new N({
1403
- ...this._def,
1404
- checks: [...this._def.checks, e]
1405
- });
1406
- }
1407
- email(e) {
1408
- return this._addCheck({ kind: "email", ...p.errToObj(e) });
1409
- }
1410
- url(e) {
1411
- return this._addCheck({ kind: "url", ...p.errToObj(e) });
1412
- }
1413
- emoji(e) {
1414
- return this._addCheck({ kind: "emoji", ...p.errToObj(e) });
1415
- }
1416
- uuid(e) {
1417
- return this._addCheck({ kind: "uuid", ...p.errToObj(e) });
1418
- }
1419
- nanoid(e) {
1420
- return this._addCheck({ kind: "nanoid", ...p.errToObj(e) });
1421
- }
1422
- cuid(e) {
1423
- return this._addCheck({ kind: "cuid", ...p.errToObj(e) });
1424
- }
1425
- cuid2(e) {
1426
- return this._addCheck({ kind: "cuid2", ...p.errToObj(e) });
1427
- }
1428
- ulid(e) {
1429
- return this._addCheck({ kind: "ulid", ...p.errToObj(e) });
1430
- }
1431
- base64(e) {
1432
- return this._addCheck({ kind: "base64", ...p.errToObj(e) });
1433
- }
1434
- ip(e) {
1435
- return this._addCheck({ kind: "ip", ...p.errToObj(e) });
1436
- }
1437
- datetime(e) {
1438
- var t, a;
1439
- return typeof e == "string" ? this._addCheck({
1440
- kind: "datetime",
1441
- precision: null,
1442
- offset: !1,
1443
- local: !1,
1444
- message: e
1445
- }) : this._addCheck({
1446
- kind: "datetime",
1447
- precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
1448
- offset: (t = e == null ? void 0 : e.offset) !== null && t !== void 0 ? t : !1,
1449
- local: (a = e == null ? void 0 : e.local) !== null && a !== void 0 ? a : !1,
1450
- ...p.errToObj(e == null ? void 0 : e.message)
1451
- });
1452
- }
1453
- date(e) {
1454
- return this._addCheck({ kind: "date", message: e });
1455
- }
1456
- time(e) {
1457
- return typeof e == "string" ? this._addCheck({
1458
- kind: "time",
1459
- precision: null,
1460
- message: e
1461
- }) : this._addCheck({
1462
- kind: "time",
1463
- precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
1464
- ...p.errToObj(e == null ? void 0 : e.message)
1465
- });
1466
- }
1467
- duration(e) {
1468
- return this._addCheck({ kind: "duration", ...p.errToObj(e) });
1469
- }
1470
- regex(e, t) {
1471
- return this._addCheck({
1472
- kind: "regex",
1473
- regex: e,
1474
- ...p.errToObj(t)
1475
- });
1476
- }
1477
- includes(e, t) {
1478
- return this._addCheck({
1479
- kind: "includes",
1480
- value: e,
1481
- position: t == null ? void 0 : t.position,
1482
- ...p.errToObj(t == null ? void 0 : t.message)
1483
- });
1484
- }
1485
- startsWith(e, t) {
1486
- return this._addCheck({
1487
- kind: "startsWith",
1488
- value: e,
1489
- ...p.errToObj(t)
1490
- });
1491
- }
1492
- endsWith(e, t) {
1493
- return this._addCheck({
1494
- kind: "endsWith",
1495
- value: e,
1496
- ...p.errToObj(t)
1497
- });
1498
- }
1499
- min(e, t) {
1500
- return this._addCheck({
1501
- kind: "min",
1502
- value: e,
1503
- ...p.errToObj(t)
1504
- });
1505
- }
1506
- max(e, t) {
1507
- return this._addCheck({
1508
- kind: "max",
1509
- value: e,
1510
- ...p.errToObj(t)
1511
- });
1512
- }
1513
- length(e, t) {
1514
- return this._addCheck({
1515
- kind: "length",
1516
- value: e,
1517
- ...p.errToObj(t)
1518
- });
1519
- }
1520
- /**
1521
- * @deprecated Use z.string().min(1) instead.
1522
- * @see {@link ZodString.min}
1523
- */
1524
- nonempty(e) {
1525
- return this.min(1, p.errToObj(e));
1526
- }
1527
- trim() {
1528
- return new N({
1529
- ...this._def,
1530
- checks: [...this._def.checks, { kind: "trim" }]
1531
- });
1532
- }
1533
- toLowerCase() {
1534
- return new N({
1535
- ...this._def,
1536
- checks: [...this._def.checks, { kind: "toLowerCase" }]
1537
- });
1538
- }
1539
- toUpperCase() {
1540
- return new N({
1541
- ...this._def,
1542
- checks: [...this._def.checks, { kind: "toUpperCase" }]
1543
- });
1544
- }
1545
- get isDatetime() {
1546
- return !!this._def.checks.find((e) => e.kind === "datetime");
1547
- }
1548
- get isDate() {
1549
- return !!this._def.checks.find((e) => e.kind === "date");
1550
- }
1551
- get isTime() {
1552
- return !!this._def.checks.find((e) => e.kind === "time");
1553
- }
1554
- get isDuration() {
1555
- return !!this._def.checks.find((e) => e.kind === "duration");
1556
- }
1557
- get isEmail() {
1558
- return !!this._def.checks.find((e) => e.kind === "email");
1559
- }
1560
- get isURL() {
1561
- return !!this._def.checks.find((e) => e.kind === "url");
1562
- }
1563
- get isEmoji() {
1564
- return !!this._def.checks.find((e) => e.kind === "emoji");
1565
- }
1566
- get isUUID() {
1567
- return !!this._def.checks.find((e) => e.kind === "uuid");
1568
- }
1569
- get isNANOID() {
1570
- return !!this._def.checks.find((e) => e.kind === "nanoid");
1571
- }
1572
- get isCUID() {
1573
- return !!this._def.checks.find((e) => e.kind === "cuid");
1574
- }
1575
- get isCUID2() {
1576
- return !!this._def.checks.find((e) => e.kind === "cuid2");
1577
- }
1578
- get isULID() {
1579
- return !!this._def.checks.find((e) => e.kind === "ulid");
1580
- }
1581
- get isIP() {
1582
- return !!this._def.checks.find((e) => e.kind === "ip");
1583
- }
1584
- get isBase64() {
1585
- return !!this._def.checks.find((e) => e.kind === "base64");
1586
- }
1587
- get minLength() {
1588
- let e = null;
1589
- for (const t of this._def.checks)
1590
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1591
- return e;
1592
- }
1593
- get maxLength() {
1594
- let e = null;
1595
- for (const t of this._def.checks)
1596
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1597
- return e;
1598
- }
1599
- }
1600
- N.create = (n) => {
1601
- var e;
1602
- return new N({
1603
- checks: [],
1604
- typeName: y.ZodString,
1605
- coerce: (e = n == null ? void 0 : n.coerce) !== null && e !== void 0 ? e : !1,
1606
- ...g(n)
1607
- });
1608
- };
1609
- function Nn(n, e) {
1610
- const t = (n.toString().split(".")[1] || "").length, a = (e.toString().split(".")[1] || "").length, r = t > a ? t : a, s = parseInt(n.toFixed(r).replace(".", "")), i = parseInt(e.toFixed(r).replace(".", ""));
1611
- return s % i / Math.pow(10, r);
1612
- }
1613
- class z extends v {
1614
- constructor() {
1615
- super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1616
- }
1617
- _parse(e) {
1618
- if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
1619
- const s = this._getOrReturnCtx(e);
1620
- return f(s, {
1621
- code: d.invalid_type,
1622
- expected: h.number,
1623
- received: s.parsedType
1624
- }), b;
1625
- }
1626
- let a;
1627
- const r = new I();
1628
- for (const s of this._def.checks)
1629
- s.kind === "int" ? _.isInteger(e.data) || (a = this._getOrReturnCtx(e, a), f(a, {
1630
- code: d.invalid_type,
1631
- expected: "integer",
1632
- received: "float",
1633
- message: s.message
1634
- }), r.dirty()) : s.kind === "min" ? (s.inclusive ? e.data < s.value : e.data <= s.value) && (a = this._getOrReturnCtx(e, a), f(a, {
1635
- code: d.too_small,
1636
- minimum: s.value,
1637
- type: "number",
1638
- inclusive: s.inclusive,
1639
- exact: !1,
1640
- message: s.message
1641
- }), r.dirty()) : s.kind === "max" ? (s.inclusive ? e.data > s.value : e.data >= s.value) && (a = this._getOrReturnCtx(e, a), f(a, {
1642
- code: d.too_big,
1643
- maximum: s.value,
1644
- type: "number",
1645
- inclusive: s.inclusive,
1646
- exact: !1,
1647
- message: s.message
1648
- }), r.dirty()) : s.kind === "multipleOf" ? Nn(e.data, s.value) !== 0 && (a = this._getOrReturnCtx(e, a), f(a, {
1649
- code: d.not_multiple_of,
1650
- multipleOf: s.value,
1651
- message: s.message
1652
- }), r.dirty()) : s.kind === "finite" ? Number.isFinite(e.data) || (a = this._getOrReturnCtx(e, a), f(a, {
1653
- code: d.not_finite,
1654
- message: s.message
1655
- }), r.dirty()) : _.assertNever(s);
1656
- return { status: r.value, value: e.data };
1657
- }
1658
- gte(e, t) {
1659
- return this.setLimit("min", e, !0, p.toString(t));
1660
- }
1661
- gt(e, t) {
1662
- return this.setLimit("min", e, !1, p.toString(t));
1663
- }
1664
- lte(e, t) {
1665
- return this.setLimit("max", e, !0, p.toString(t));
1666
- }
1667
- lt(e, t) {
1668
- return this.setLimit("max", e, !1, p.toString(t));
1669
- }
1670
- setLimit(e, t, a, r) {
1671
- return new z({
1672
- ...this._def,
1673
- checks: [
1674
- ...this._def.checks,
1675
- {
1676
- kind: e,
1677
- value: t,
1678
- inclusive: a,
1679
- message: p.toString(r)
1680
- }
1681
- ]
1682
- });
1683
- }
1684
- _addCheck(e) {
1685
- return new z({
1686
- ...this._def,
1687
- checks: [...this._def.checks, e]
1688
- });
1689
- }
1690
- int(e) {
1691
- return this._addCheck({
1692
- kind: "int",
1693
- message: p.toString(e)
1694
- });
1695
- }
1696
- positive(e) {
1697
- return this._addCheck({
1698
- kind: "min",
1699
- value: 0,
1700
- inclusive: !1,
1701
- message: p.toString(e)
1702
- });
1703
- }
1704
- negative(e) {
1705
- return this._addCheck({
1706
- kind: "max",
1707
- value: 0,
1708
- inclusive: !1,
1709
- message: p.toString(e)
1710
- });
1711
- }
1712
- nonpositive(e) {
1713
- return this._addCheck({
1714
- kind: "max",
1715
- value: 0,
1716
- inclusive: !0,
1717
- message: p.toString(e)
1718
- });
1719
- }
1720
- nonnegative(e) {
1721
- return this._addCheck({
1722
- kind: "min",
1723
- value: 0,
1724
- inclusive: !0,
1725
- message: p.toString(e)
1726
- });
1727
- }
1728
- multipleOf(e, t) {
1729
- return this._addCheck({
1730
- kind: "multipleOf",
1731
- value: e,
1732
- message: p.toString(t)
1733
- });
1734
- }
1735
- finite(e) {
1736
- return this._addCheck({
1737
- kind: "finite",
1738
- message: p.toString(e)
1739
- });
1740
- }
1741
- safe(e) {
1742
- return this._addCheck({
1743
- kind: "min",
1744
- inclusive: !0,
1745
- value: Number.MIN_SAFE_INTEGER,
1746
- message: p.toString(e)
1747
- })._addCheck({
1748
- kind: "max",
1749
- inclusive: !0,
1750
- value: Number.MAX_SAFE_INTEGER,
1751
- message: p.toString(e)
1752
- });
1753
- }
1754
- get minValue() {
1755
- let e = null;
1756
- for (const t of this._def.checks)
1757
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1758
- return e;
1759
- }
1760
- get maxValue() {
1761
- let e = null;
1762
- for (const t of this._def.checks)
1763
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1764
- return e;
1765
- }
1766
- get isInt() {
1767
- return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && _.isInteger(e.value));
1768
- }
1769
- get isFinite() {
1770
- let e = null, t = null;
1771
- for (const a of this._def.checks) {
1772
- if (a.kind === "finite" || a.kind === "int" || a.kind === "multipleOf")
1773
- return !0;
1774
- a.kind === "min" ? (t === null || a.value > t) && (t = a.value) : a.kind === "max" && (e === null || a.value < e) && (e = a.value);
1775
- }
1776
- return Number.isFinite(t) && Number.isFinite(e);
1777
- }
1778
- }
1779
- z.create = (n) => new z({
1780
- checks: [],
1781
- typeName: y.ZodNumber,
1782
- coerce: (n == null ? void 0 : n.coerce) || !1,
1783
- ...g(n)
1784
- });
1785
- class U extends v {
1786
- constructor() {
1787
- super(...arguments), this.min = this.gte, this.max = this.lte;
1788
- }
1789
- _parse(e) {
1790
- if (this._def.coerce && (e.data = BigInt(e.data)), this._getType(e) !== h.bigint) {
1791
- const s = this._getOrReturnCtx(e);
1792
- return f(s, {
1793
- code: d.invalid_type,
1794
- expected: h.bigint,
1795
- received: s.parsedType
1796
- }), b;
1797
- }
1798
- let a;
1799
- const r = new I();
1800
- for (const s of this._def.checks)
1801
- s.kind === "min" ? (s.inclusive ? e.data < s.value : e.data <= s.value) && (a = this._getOrReturnCtx(e, a), f(a, {
1802
- code: d.too_small,
1803
- type: "bigint",
1804
- minimum: s.value,
1805
- inclusive: s.inclusive,
1806
- message: s.message
1807
- }), r.dirty()) : s.kind === "max" ? (s.inclusive ? e.data > s.value : e.data >= s.value) && (a = this._getOrReturnCtx(e, a), f(a, {
1808
- code: d.too_big,
1809
- type: "bigint",
1810
- maximum: s.value,
1811
- inclusive: s.inclusive,
1812
- message: s.message
1813
- }), r.dirty()) : s.kind === "multipleOf" ? e.data % s.value !== BigInt(0) && (a = this._getOrReturnCtx(e, a), f(a, {
1814
- code: d.not_multiple_of,
1815
- multipleOf: s.value,
1816
- message: s.message
1817
- }), r.dirty()) : _.assertNever(s);
1818
- return { status: r.value, value: e.data };
1819
- }
1820
- gte(e, t) {
1821
- return this.setLimit("min", e, !0, p.toString(t));
1822
- }
1823
- gt(e, t) {
1824
- return this.setLimit("min", e, !1, p.toString(t));
1825
- }
1826
- lte(e, t) {
1827
- return this.setLimit("max", e, !0, p.toString(t));
1828
- }
1829
- lt(e, t) {
1830
- return this.setLimit("max", e, !1, p.toString(t));
1831
- }
1832
- setLimit(e, t, a, r) {
1833
- return new U({
1834
- ...this._def,
1835
- checks: [
1836
- ...this._def.checks,
1837
- {
1838
- kind: e,
1839
- value: t,
1840
- inclusive: a,
1841
- message: p.toString(r)
1842
- }
1843
- ]
1844
- });
1845
- }
1846
- _addCheck(e) {
1847
- return new U({
1848
- ...this._def,
1849
- checks: [...this._def.checks, e]
1850
- });
1851
- }
1852
- positive(e) {
1853
- return this._addCheck({
1854
- kind: "min",
1855
- value: BigInt(0),
1856
- inclusive: !1,
1857
- message: p.toString(e)
1858
- });
1859
- }
1860
- negative(e) {
1861
- return this._addCheck({
1862
- kind: "max",
1863
- value: BigInt(0),
1864
- inclusive: !1,
1865
- message: p.toString(e)
1866
- });
1867
- }
1868
- nonpositive(e) {
1869
- return this._addCheck({
1870
- kind: "max",
1871
- value: BigInt(0),
1872
- inclusive: !0,
1873
- message: p.toString(e)
1874
- });
1875
- }
1876
- nonnegative(e) {
1877
- return this._addCheck({
1878
- kind: "min",
1879
- value: BigInt(0),
1880
- inclusive: !0,
1881
- message: p.toString(e)
1882
- });
1883
- }
1884
- multipleOf(e, t) {
1885
- return this._addCheck({
1886
- kind: "multipleOf",
1887
- value: e,
1888
- message: p.toString(t)
1889
- });
1890
- }
1891
- get minValue() {
1892
- let e = null;
1893
- for (const t of this._def.checks)
1894
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1895
- return e;
1896
- }
1897
- get maxValue() {
1898
- let e = null;
1899
- for (const t of this._def.checks)
1900
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1901
- return e;
1902
- }
1903
- }
1904
- U.create = (n) => {
1905
- var e;
1906
- return new U({
1907
- checks: [],
1908
- typeName: y.ZodBigInt,
1909
- coerce: (e = n == null ? void 0 : n.coerce) !== null && e !== void 0 ? e : !1,
1910
- ...g(n)
1911
- });
1912
- };
1913
- class ce extends v {
1914
- _parse(e) {
1915
- if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
1916
- const a = this._getOrReturnCtx(e);
1917
- return f(a, {
1918
- code: d.invalid_type,
1919
- expected: h.boolean,
1920
- received: a.parsedType
1921
- }), b;
1922
- }
1923
- return A(e.data);
1924
- }
1925
- }
1926
- ce.create = (n) => new ce({
1927
- typeName: y.ZodBoolean,
1928
- coerce: (n == null ? void 0 : n.coerce) || !1,
1929
- ...g(n)
1930
- });
1931
- class G extends v {
1932
- _parse(e) {
1933
- if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
1934
- const s = this._getOrReturnCtx(e);
1935
- return f(s, {
1936
- code: d.invalid_type,
1937
- expected: h.date,
1938
- received: s.parsedType
1939
- }), b;
1940
- }
1941
- if (isNaN(e.data.getTime())) {
1942
- const s = this._getOrReturnCtx(e);
1943
- return f(s, {
1944
- code: d.invalid_date
1945
- }), b;
1946
- }
1947
- const a = new I();
1948
- let r;
1949
- for (const s of this._def.checks)
1950
- s.kind === "min" ? e.data.getTime() < s.value && (r = this._getOrReturnCtx(e, r), f(r, {
1951
- code: d.too_small,
1952
- message: s.message,
1953
- inclusive: !0,
1954
- exact: !1,
1955
- minimum: s.value,
1956
- type: "date"
1957
- }), a.dirty()) : s.kind === "max" ? e.data.getTime() > s.value && (r = this._getOrReturnCtx(e, r), f(r, {
1958
- code: d.too_big,
1959
- message: s.message,
1960
- inclusive: !0,
1961
- exact: !1,
1962
- maximum: s.value,
1963
- type: "date"
1964
- }), a.dirty()) : _.assertNever(s);
1965
- return {
1966
- status: a.value,
1967
- value: new Date(e.data.getTime())
1968
- };
1969
- }
1970
- _addCheck(e) {
1971
- return new G({
1972
- ...this._def,
1973
- checks: [...this._def.checks, e]
1974
- });
1975
- }
1976
- min(e, t) {
1977
- return this._addCheck({
1978
- kind: "min",
1979
- value: e.getTime(),
1980
- message: p.toString(t)
1981
- });
1982
- }
1983
- max(e, t) {
1984
- return this._addCheck({
1985
- kind: "max",
1986
- value: e.getTime(),
1987
- message: p.toString(t)
1988
- });
1989
- }
1990
- get minDate() {
1991
- let e = null;
1992
- for (const t of this._def.checks)
1993
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1994
- return e != null ? new Date(e) : null;
1995
- }
1996
- get maxDate() {
1997
- let e = null;
1998
- for (const t of this._def.checks)
1999
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
2000
- return e != null ? new Date(e) : null;
2001
- }
2002
- }
2003
- G.create = (n) => new G({
2004
- checks: [],
2005
- coerce: (n == null ? void 0 : n.coerce) || !1,
2006
- typeName: y.ZodDate,
2007
- ...g(n)
2008
- });
2009
- class Se extends v {
2010
- _parse(e) {
2011
- if (this._getType(e) !== h.symbol) {
2012
- const a = this._getOrReturnCtx(e);
2013
- return f(a, {
2014
- code: d.invalid_type,
2015
- expected: h.symbol,
2016
- received: a.parsedType
2017
- }), b;
2018
- }
2019
- return A(e.data);
2020
- }
2021
- }
2022
- Se.create = (n) => new Se({
2023
- typeName: y.ZodSymbol,
2024
- ...g(n)
2025
- });
2026
- class de extends v {
2027
- _parse(e) {
2028
- if (this._getType(e) !== h.undefined) {
2029
- const a = this._getOrReturnCtx(e);
2030
- return f(a, {
2031
- code: d.invalid_type,
2032
- expected: h.undefined,
2033
- received: a.parsedType
2034
- }), b;
2035
- }
2036
- return A(e.data);
2037
- }
2038
- }
2039
- de.create = (n) => new de({
2040
- typeName: y.ZodUndefined,
2041
- ...g(n)
2042
- });
2043
- class ue extends v {
2044
- _parse(e) {
2045
- if (this._getType(e) !== h.null) {
2046
- const a = this._getOrReturnCtx(e);
2047
- return f(a, {
2048
- code: d.invalid_type,
2049
- expected: h.null,
2050
- received: a.parsedType
2051
- }), b;
2052
- }
2053
- return A(e.data);
2054
- }
2055
- }
2056
- ue.create = (n) => new ue({
2057
- typeName: y.ZodNull,
2058
- ...g(n)
2059
- });
2060
- class te extends v {
2061
- constructor() {
2062
- super(...arguments), this._any = !0;
2063
- }
2064
- _parse(e) {
2065
- return A(e.data);
2066
- }
2067
- }
2068
- te.create = (n) => new te({
2069
- typeName: y.ZodAny,
2070
- ...g(n)
2071
- });
2072
- class q extends v {
2073
- constructor() {
2074
- super(...arguments), this._unknown = !0;
2075
- }
2076
- _parse(e) {
2077
- return A(e.data);
2078
- }
2079
- }
2080
- q.create = (n) => new q({
2081
- typeName: y.ZodUnknown,
2082
- ...g(n)
2083
- });
2084
- class V extends v {
2085
- _parse(e) {
2086
- const t = this._getOrReturnCtx(e);
2087
- return f(t, {
2088
- code: d.invalid_type,
2089
- expected: h.never,
2090
- received: t.parsedType
2091
- }), b;
2092
- }
2093
- }
2094
- V.create = (n) => new V({
2095
- typeName: y.ZodNever,
2096
- ...g(n)
2097
- });
2098
- class Ie extends v {
2099
- _parse(e) {
2100
- if (this._getType(e) !== h.undefined) {
2101
- const a = this._getOrReturnCtx(e);
2102
- return f(a, {
2103
- code: d.invalid_type,
2104
- expected: h.void,
2105
- received: a.parsedType
2106
- }), b;
2107
- }
2108
- return A(e.data);
2109
- }
2110
- }
2111
- Ie.create = (n) => new Ie({
2112
- typeName: y.ZodVoid,
2113
- ...g(n)
2114
- });
2115
- class O extends v {
2116
- _parse(e) {
2117
- const { ctx: t, status: a } = this._processInputParams(e), r = this._def;
2118
- if (t.parsedType !== h.array)
2119
- return f(t, {
2120
- code: d.invalid_type,
2121
- expected: h.array,
2122
- received: t.parsedType
2123
- }), b;
2124
- if (r.exactLength !== null) {
2125
- const i = t.data.length > r.exactLength.value, o = t.data.length < r.exactLength.value;
2126
- (i || o) && (f(t, {
2127
- code: i ? d.too_big : d.too_small,
2128
- minimum: o ? r.exactLength.value : void 0,
2129
- maximum: i ? r.exactLength.value : void 0,
2130
- type: "array",
2131
- inclusive: !0,
2132
- exact: !0,
2133
- message: r.exactLength.message
2134
- }), a.dirty());
2135
- }
2136
- if (r.minLength !== null && t.data.length < r.minLength.value && (f(t, {
2137
- code: d.too_small,
2138
- minimum: r.minLength.value,
2139
- type: "array",
2140
- inclusive: !0,
2141
- exact: !1,
2142
- message: r.minLength.message
2143
- }), a.dirty()), r.maxLength !== null && t.data.length > r.maxLength.value && (f(t, {
2144
- code: d.too_big,
2145
- maximum: r.maxLength.value,
2146
- type: "array",
2147
- inclusive: !0,
2148
- exact: !1,
2149
- message: r.maxLength.message
2150
- }), a.dirty()), t.common.async)
2151
- return Promise.all([...t.data].map((i, o) => r.type._parseAsync(new j(t, i, t.path, o)))).then((i) => I.mergeArray(a, i));
2152
- const s = [...t.data].map((i, o) => r.type._parseSync(new j(t, i, t.path, o)));
2153
- return I.mergeArray(a, s);
2154
- }
2155
- get element() {
2156
- return this._def.type;
2157
- }
2158
- min(e, t) {
2159
- return new O({
2160
- ...this._def,
2161
- minLength: { value: e, message: p.toString(t) }
2162
- });
2163
- }
2164
- max(e, t) {
2165
- return new O({
2166
- ...this._def,
2167
- maxLength: { value: e, message: p.toString(t) }
2168
- });
2169
- }
2170
- length(e, t) {
2171
- return new O({
2172
- ...this._def,
2173
- exactLength: { value: e, message: p.toString(t) }
2174
- });
2175
- }
2176
- nonempty(e) {
2177
- return this.min(1, e);
2178
- }
2179
- }
2180
- O.create = (n, e) => new O({
2181
- type: n,
2182
- minLength: null,
2183
- maxLength: null,
2184
- exactLength: null,
2185
- typeName: y.ZodArray,
2186
- ...g(e)
2187
- });
2188
- function K(n) {
2189
- if (n instanceof k) {
2190
- const e = {};
2191
- for (const t in n.shape) {
2192
- const a = n.shape[t];
2193
- e[t] = Z.create(K(a));
2194
- }
2195
- return new k({
2196
- ...n._def,
2197
- shape: () => e
2198
- });
2199
- } else return n instanceof O ? new O({
2200
- ...n._def,
2201
- type: K(n.element)
2202
- }) : n instanceof Z ? Z.create(K(n.unwrap())) : n instanceof F ? F.create(K(n.unwrap())) : n instanceof M ? M.create(n.items.map((e) => K(e))) : n;
2203
- }
2204
- class k extends v {
2205
- constructor() {
2206
- super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
2207
- }
2208
- _getCached() {
2209
- if (this._cached !== null)
2210
- return this._cached;
2211
- const e = this._def.shape(), t = _.objectKeys(e);
2212
- return this._cached = { shape: e, keys: t };
2213
- }
2214
- _parse(e) {
2215
- if (this._getType(e) !== h.object) {
2216
- const c = this._getOrReturnCtx(e);
2217
- return f(c, {
2218
- code: d.invalid_type,
2219
- expected: h.object,
2220
- received: c.parsedType
2221
- }), b;
2222
- }
2223
- const { status: a, ctx: r } = this._processInputParams(e), { shape: s, keys: i } = this._getCached(), o = [];
2224
- if (!(this._def.catchall instanceof V && this._def.unknownKeys === "strip"))
2225
- for (const c in r.data)
2226
- i.includes(c) || o.push(c);
2227
- const u = [];
2228
- for (const c of i) {
2229
- const m = s[c], C = r.data[c];
2230
- u.push({
2231
- key: { status: "valid", value: c },
2232
- value: m._parse(new j(r, C, r.path, c)),
2233
- alwaysSet: c in r.data
2234
- });
2235
- }
2236
- if (this._def.catchall instanceof V) {
2237
- const c = this._def.unknownKeys;
2238
- if (c === "passthrough")
2239
- for (const m of o)
2240
- u.push({
2241
- key: { status: "valid", value: m },
2242
- value: { status: "valid", value: r.data[m] }
2243
- });
2244
- else if (c === "strict")
2245
- o.length > 0 && (f(r, {
2246
- code: d.unrecognized_keys,
2247
- keys: o
2248
- }), a.dirty());
2249
- else if (c !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
2250
- } else {
2251
- const c = this._def.catchall;
2252
- for (const m of o) {
2253
- const C = r.data[m];
2254
- u.push({
2255
- key: { status: "valid", value: m },
2256
- value: c._parse(
2257
- new j(r, C, r.path, m)
2258
- //, ctx.child(key), value, getParsedType(value)
2259
- ),
2260
- alwaysSet: m in r.data
2261
- });
2262
- }
2263
- }
2264
- return r.common.async ? Promise.resolve().then(async () => {
2265
- const c = [];
2266
- for (const m of u) {
2267
- const C = await m.key, J = await m.value;
2268
- c.push({
2269
- key: C,
2270
- value: J,
2271
- alwaysSet: m.alwaysSet
2272
- });
2273
- }
2274
- return c;
2275
- }).then((c) => I.mergeObjectSync(a, c)) : I.mergeObjectSync(a, u);
2276
- }
2277
- get shape() {
2278
- return this._def.shape();
2279
- }
2280
- strict(e) {
2281
- return p.errToObj, new k({
2282
- ...this._def,
2283
- unknownKeys: "strict",
2284
- ...e !== void 0 ? {
2285
- errorMap: (t, a) => {
2286
- var r, s, i, o;
2287
- const u = (i = (s = (r = this._def).errorMap) === null || s === void 0 ? void 0 : s.call(r, t, a).message) !== null && i !== void 0 ? i : a.defaultError;
2288
- return t.code === "unrecognized_keys" ? {
2289
- message: (o = p.errToObj(e).message) !== null && o !== void 0 ? o : u
2290
- } : {
2291
- message: u
2292
- };
2293
- }
2294
- } : {}
2295
- });
2296
- }
2297
- strip() {
2298
- return new k({
2299
- ...this._def,
2300
- unknownKeys: "strip"
2301
- });
2302
- }
2303
- passthrough() {
2304
- return new k({
2305
- ...this._def,
2306
- unknownKeys: "passthrough"
2307
- });
2308
- }
2309
- // const AugmentFactory =
2310
- // <Def extends ZodObjectDef>(def: Def) =>
2311
- // <Augmentation extends ZodRawShape>(
2312
- // augmentation: Augmentation
2313
- // ): ZodObject<
2314
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2315
- // Def["unknownKeys"],
2316
- // Def["catchall"]
2317
- // > => {
2318
- // return new ZodObject({
2319
- // ...def,
2320
- // shape: () => ({
2321
- // ...def.shape(),
2322
- // ...augmentation,
2323
- // }),
2324
- // }) as any;
2325
- // };
2326
- extend(e) {
2327
- return new k({
2328
- ...this._def,
2329
- shape: () => ({
2330
- ...this._def.shape(),
2331
- ...e
2332
- })
2333
- });
2334
- }
2335
- /**
2336
- * Prior to zod@1.0.12 there was a bug in the
2337
- * inferred type of merged objects. Please
2338
- * upgrade if you are experiencing issues.
2339
- */
2340
- merge(e) {
2341
- return new k({
2342
- unknownKeys: e._def.unknownKeys,
2343
- catchall: e._def.catchall,
2344
- shape: () => ({
2345
- ...this._def.shape(),
2346
- ...e._def.shape()
2347
- }),
2348
- typeName: y.ZodObject
2349
- });
2350
- }
2351
- // merge<
2352
- // Incoming extends AnyZodObject,
2353
- // Augmentation extends Incoming["shape"],
2354
- // NewOutput extends {
2355
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2356
- // ? Augmentation[k]["_output"]
2357
- // : k extends keyof Output
2358
- // ? Output[k]
2359
- // : never;
2360
- // },
2361
- // NewInput extends {
2362
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2363
- // ? Augmentation[k]["_input"]
2364
- // : k extends keyof Input
2365
- // ? Input[k]
2366
- // : never;
2367
- // }
2368
- // >(
2369
- // merging: Incoming
2370
- // ): ZodObject<
2371
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2372
- // Incoming["_def"]["unknownKeys"],
2373
- // Incoming["_def"]["catchall"],
2374
- // NewOutput,
2375
- // NewInput
2376
- // > {
2377
- // const merged: any = new ZodObject({
2378
- // unknownKeys: merging._def.unknownKeys,
2379
- // catchall: merging._def.catchall,
2380
- // shape: () =>
2381
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2382
- // typeName: ZodFirstPartyTypeKind.ZodObject,
2383
- // }) as any;
2384
- // return merged;
2385
- // }
2386
- setKey(e, t) {
2387
- return this.augment({ [e]: t });
2388
- }
2389
- // merge<Incoming extends AnyZodObject>(
2390
- // merging: Incoming
2391
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2392
- // ZodObject<
2393
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2394
- // Incoming["_def"]["unknownKeys"],
2395
- // Incoming["_def"]["catchall"]
2396
- // > {
2397
- // // const mergedShape = objectUtil.mergeShapes(
2398
- // // this._def.shape(),
2399
- // // merging._def.shape()
2400
- // // );
2401
- // const merged: any = new ZodObject({
2402
- // unknownKeys: merging._def.unknownKeys,
2403
- // catchall: merging._def.catchall,
2404
- // shape: () =>
2405
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2406
- // typeName: ZodFirstPartyTypeKind.ZodObject,
2407
- // }) as any;
2408
- // return merged;
2409
- // }
2410
- catchall(e) {
2411
- return new k({
2412
- ...this._def,
2413
- catchall: e
2414
- });
2415
- }
2416
- pick(e) {
2417
- const t = {};
2418
- return _.objectKeys(e).forEach((a) => {
2419
- e[a] && this.shape[a] && (t[a] = this.shape[a]);
2420
- }), new k({
2421
- ...this._def,
2422
- shape: () => t
2423
- });
2424
- }
2425
- omit(e) {
2426
- const t = {};
2427
- return _.objectKeys(this.shape).forEach((a) => {
2428
- e[a] || (t[a] = this.shape[a]);
2429
- }), new k({
2430
- ...this._def,
2431
- shape: () => t
2432
- });
2433
- }
2434
- /**
2435
- * @deprecated
2436
- */
2437
- deepPartial() {
2438
- return K(this);
2439
- }
2440
- partial(e) {
2441
- const t = {};
2442
- return _.objectKeys(this.shape).forEach((a) => {
2443
- const r = this.shape[a];
2444
- e && !e[a] ? t[a] = r : t[a] = r.optional();
2445
- }), new k({
2446
- ...this._def,
2447
- shape: () => t
2448
- });
2449
- }
2450
- required(e) {
2451
- const t = {};
2452
- return _.objectKeys(this.shape).forEach((a) => {
2453
- if (e && !e[a])
2454
- t[a] = this.shape[a];
2455
- else {
2456
- let s = this.shape[a];
2457
- for (; s instanceof Z; )
2458
- s = s._def.innerType;
2459
- t[a] = s;
2460
- }
2461
- }), new k({
2462
- ...this._def,
2463
- shape: () => t
2464
- });
2465
- }
2466
- keyof() {
2467
- return yt(_.objectKeys(this.shape));
2468
- }
2469
- }
2470
- k.create = (n, e) => new k({
2471
- shape: () => n,
2472
- unknownKeys: "strip",
2473
- catchall: V.create(),
2474
- typeName: y.ZodObject,
2475
- ...g(e)
2476
- });
2477
- k.strictCreate = (n, e) => new k({
2478
- shape: () => n,
2479
- unknownKeys: "strict",
2480
- catchall: V.create(),
2481
- typeName: y.ZodObject,
2482
- ...g(e)
2483
- });
2484
- k.lazycreate = (n, e) => new k({
2485
- shape: n,
2486
- unknownKeys: "strip",
2487
- catchall: V.create(),
2488
- typeName: y.ZodObject,
2489
- ...g(e)
2490
- });
2491
- class le extends v {
2492
- _parse(e) {
2493
- const { ctx: t } = this._processInputParams(e), a = this._def.options;
2494
- function r(s) {
2495
- for (const o of s)
2496
- if (o.result.status === "valid")
2497
- return o.result;
2498
- for (const o of s)
2499
- if (o.result.status === "dirty")
2500
- return t.common.issues.push(...o.ctx.common.issues), o.result;
2501
- const i = s.map((o) => new E(o.ctx.common.issues));
2502
- return f(t, {
2503
- code: d.invalid_union,
2504
- unionErrors: i
2505
- }), b;
2506
- }
2507
- if (t.common.async)
2508
- return Promise.all(a.map(async (s) => {
2509
- const i = {
2510
- ...t,
2511
- common: {
2512
- ...t.common,
2513
- issues: []
2514
- },
2515
- parent: null
2516
- };
2517
- return {
2518
- result: await s._parseAsync({
2519
- data: t.data,
2520
- path: t.path,
2521
- parent: i
2522
- }),
2523
- ctx: i
2524
- };
2525
- })).then(r);
2526
- {
2527
- let s;
2528
- const i = [];
2529
- for (const u of a) {
2530
- const c = {
2531
- ...t,
2532
- common: {
2533
- ...t.common,
2534
- issues: []
2535
- },
2536
- parent: null
2537
- }, m = u._parseSync({
2538
- data: t.data,
2539
- path: t.path,
2540
- parent: c
2541
- });
2542
- if (m.status === "valid")
2543
- return m;
2544
- m.status === "dirty" && !s && (s = { result: m, ctx: c }), c.common.issues.length && i.push(c.common.issues);
2545
- }
2546
- if (s)
2547
- return t.common.issues.push(...s.ctx.common.issues), s.result;
2548
- const o = i.map((u) => new E(u));
2549
- return f(t, {
2550
- code: d.invalid_union,
2551
- unionErrors: o
2552
- }), b;
2553
- }
2554
- }
2555
- get options() {
2556
- return this._def.options;
2557
- }
2558
- }
2559
- le.create = (n, e) => new le({
2560
- options: n,
2561
- typeName: y.ZodUnion,
2562
- ...g(e)
2563
- });
2564
- const D = (n) => n instanceof pe ? D(n.schema) : n instanceof R ? D(n.innerType()) : n instanceof me ? [n.value] : n instanceof W ? n.options : n instanceof ye ? _.objectValues(n.enum) : n instanceof be ? D(n._def.innerType) : n instanceof de ? [void 0] : n instanceof ue ? [null] : n instanceof Z ? [void 0, ...D(n.unwrap())] : n instanceof F ? [null, ...D(n.unwrap())] : n instanceof He || n instanceof ve ? D(n.unwrap()) : n instanceof ge ? D(n._def.innerType) : [];
2565
- class Oe extends v {
2566
- _parse(e) {
2567
- const { ctx: t } = this._processInputParams(e);
2568
- if (t.parsedType !== h.object)
2569
- return f(t, {
2570
- code: d.invalid_type,
2571
- expected: h.object,
2572
- received: t.parsedType
2573
- }), b;
2574
- const a = this.discriminator, r = t.data[a], s = this.optionsMap.get(r);
2575
- return s ? t.common.async ? s._parseAsync({
2576
- data: t.data,
2577
- path: t.path,
2578
- parent: t
2579
- }) : s._parseSync({
2580
- data: t.data,
2581
- path: t.path,
2582
- parent: t
2583
- }) : (f(t, {
2584
- code: d.invalid_union_discriminator,
2585
- options: Array.from(this.optionsMap.keys()),
2586
- path: [a]
2587
- }), b);
2588
- }
2589
- get discriminator() {
2590
- return this._def.discriminator;
2591
- }
2592
- get options() {
2593
- return this._def.options;
2594
- }
2595
- get optionsMap() {
2596
- return this._def.optionsMap;
2597
- }
2598
- /**
2599
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2600
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2601
- * have a different value for each object in the union.
2602
- * @param discriminator the name of the discriminator property
2603
- * @param types an array of object schemas
2604
- * @param params
2605
- */
2606
- static create(e, t, a) {
2607
- const r = /* @__PURE__ */ new Map();
2608
- for (const s of t) {
2609
- const i = D(s.shape[e]);
2610
- if (!i.length)
2611
- throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
2612
- for (const o of i) {
2613
- if (r.has(o))
2614
- throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
2615
- r.set(o, s);
2616
- }
2617
- }
2618
- return new Oe({
2619
- typeName: y.ZodDiscriminatedUnion,
2620
- discriminator: e,
2621
- options: t,
2622
- optionsMap: r,
2623
- ...g(a)
2624
- });
2625
- }
2626
- }
2627
- function Le(n, e) {
2628
- const t = L(n), a = L(e);
2629
- if (n === e)
2630
- return { valid: !0, data: n };
2631
- if (t === h.object && a === h.object) {
2632
- const r = _.objectKeys(e), s = _.objectKeys(n).filter((o) => r.indexOf(o) !== -1), i = { ...n, ...e };
2633
- for (const o of s) {
2634
- const u = Le(n[o], e[o]);
2635
- if (!u.valid)
2636
- return { valid: !1 };
2637
- i[o] = u.data;
2638
- }
2639
- return { valid: !0, data: i };
2640
- } else if (t === h.array && a === h.array) {
2641
- if (n.length !== e.length)
2642
- return { valid: !1 };
2643
- const r = [];
2644
- for (let s = 0; s < n.length; s++) {
2645
- const i = n[s], o = e[s], u = Le(i, o);
2646
- if (!u.valid)
2647
- return { valid: !1 };
2648
- r.push(u.data);
2649
- }
2650
- return { valid: !0, data: r };
2651
- } else return t === h.date && a === h.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
2652
- }
2653
- class fe extends v {
2654
- _parse(e) {
2655
- const { status: t, ctx: a } = this._processInputParams(e), r = (s, i) => {
2656
- if (Ve(s) || Ve(i))
2657
- return b;
2658
- const o = Le(s.value, i.value);
2659
- return o.valid ? ((Be(s) || Be(i)) && t.dirty(), { status: t.value, value: o.data }) : (f(a, {
2660
- code: d.invalid_intersection_types
2661
- }), b);
2662
- };
2663
- return a.common.async ? Promise.all([
2664
- this._def.left._parseAsync({
2665
- data: a.data,
2666
- path: a.path,
2667
- parent: a
2668
- }),
2669
- this._def.right._parseAsync({
2670
- data: a.data,
2671
- path: a.path,
2672
- parent: a
2673
- })
2674
- ]).then(([s, i]) => r(s, i)) : r(this._def.left._parseSync({
2675
- data: a.data,
2676
- path: a.path,
2677
- parent: a
2678
- }), this._def.right._parseSync({
2679
- data: a.data,
2680
- path: a.path,
2681
- parent: a
2682
- }));
2683
- }
2684
- }
2685
- fe.create = (n, e, t) => new fe({
2686
- left: n,
2687
- right: e,
2688
- typeName: y.ZodIntersection,
2689
- ...g(t)
2690
- });
2691
- class M extends v {
2692
- _parse(e) {
2693
- const { status: t, ctx: a } = this._processInputParams(e);
2694
- if (a.parsedType !== h.array)
2695
- return f(a, {
2696
- code: d.invalid_type,
2697
- expected: h.array,
2698
- received: a.parsedType
2699
- }), b;
2700
- if (a.data.length < this._def.items.length)
2701
- return f(a, {
2702
- code: d.too_small,
2703
- minimum: this._def.items.length,
2704
- inclusive: !0,
2705
- exact: !1,
2706
- type: "array"
2707
- }), b;
2708
- !this._def.rest && a.data.length > this._def.items.length && (f(a, {
2709
- code: d.too_big,
2710
- maximum: this._def.items.length,
2711
- inclusive: !0,
2712
- exact: !1,
2713
- type: "array"
2714
- }), t.dirty());
2715
- const s = [...a.data].map((i, o) => {
2716
- const u = this._def.items[o] || this._def.rest;
2717
- return u ? u._parse(new j(a, i, a.path, o)) : null;
2718
- }).filter((i) => !!i);
2719
- return a.common.async ? Promise.all(s).then((i) => I.mergeArray(t, i)) : I.mergeArray(t, s);
2720
- }
2721
- get items() {
2722
- return this._def.items;
2723
- }
2724
- rest(e) {
2725
- return new M({
2726
- ...this._def,
2727
- rest: e
2728
- });
2729
- }
2730
- }
2731
- M.create = (n, e) => {
2732
- if (!Array.isArray(n))
2733
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2734
- return new M({
2735
- items: n,
2736
- typeName: y.ZodTuple,
2737
- rest: null,
2738
- ...g(e)
2739
- });
2740
- };
2741
- class he extends v {
2742
- get keySchema() {
2743
- return this._def.keyType;
2744
- }
2745
- get valueSchema() {
2746
- return this._def.valueType;
2747
- }
2748
- _parse(e) {
2749
- const { status: t, ctx: a } = this._processInputParams(e);
2750
- if (a.parsedType !== h.object)
2751
- return f(a, {
2752
- code: d.invalid_type,
2753
- expected: h.object,
2754
- received: a.parsedType
2755
- }), b;
2756
- const r = [], s = this._def.keyType, i = this._def.valueType;
2757
- for (const o in a.data)
2758
- r.push({
2759
- key: s._parse(new j(a, o, a.path, o)),
2760
- value: i._parse(new j(a, a.data[o], a.path, o)),
2761
- alwaysSet: o in a.data
2762
- });
2763
- return a.common.async ? I.mergeObjectAsync(t, r) : I.mergeObjectSync(t, r);
2764
- }
2765
- get element() {
2766
- return this._def.valueType;
2767
- }
2768
- static create(e, t, a) {
2769
- return t instanceof v ? new he({
2770
- keyType: e,
2771
- valueType: t,
2772
- typeName: y.ZodRecord,
2773
- ...g(a)
2774
- }) : new he({
2775
- keyType: N.create(),
2776
- valueType: e,
2777
- typeName: y.ZodRecord,
2778
- ...g(t)
2779
- });
2780
- }
2781
- }
2782
- class Ae extends v {
2783
- get keySchema() {
2784
- return this._def.keyType;
2785
- }
2786
- get valueSchema() {
2787
- return this._def.valueType;
2788
- }
2789
- _parse(e) {
2790
- const { status: t, ctx: a } = this._processInputParams(e);
2791
- if (a.parsedType !== h.map)
2792
- return f(a, {
2793
- code: d.invalid_type,
2794
- expected: h.map,
2795
- received: a.parsedType
2796
- }), b;
2797
- const r = this._def.keyType, s = this._def.valueType, i = [...a.data.entries()].map(([o, u], c) => ({
2798
- key: r._parse(new j(a, o, a.path, [c, "key"])),
2799
- value: s._parse(new j(a, u, a.path, [c, "value"]))
2800
- }));
2801
- if (a.common.async) {
2802
- const o = /* @__PURE__ */ new Map();
2803
- return Promise.resolve().then(async () => {
2804
- for (const u of i) {
2805
- const c = await u.key, m = await u.value;
2806
- if (c.status === "aborted" || m.status === "aborted")
2807
- return b;
2808
- (c.status === "dirty" || m.status === "dirty") && t.dirty(), o.set(c.value, m.value);
2809
- }
2810
- return { status: t.value, value: o };
2811
- });
2812
- } else {
2813
- const o = /* @__PURE__ */ new Map();
2814
- for (const u of i) {
2815
- const c = u.key, m = u.value;
2816
- if (c.status === "aborted" || m.status === "aborted")
2817
- return b;
2818
- (c.status === "dirty" || m.status === "dirty") && t.dirty(), o.set(c.value, m.value);
2819
- }
2820
- return { status: t.value, value: o };
2821
- }
2822
- }
2823
- }
2824
- Ae.create = (n, e, t) => new Ae({
2825
- valueType: e,
2826
- keyType: n,
2827
- typeName: y.ZodMap,
2828
- ...g(t)
2829
- });
2830
- class Y extends v {
2831
- _parse(e) {
2832
- const { status: t, ctx: a } = this._processInputParams(e);
2833
- if (a.parsedType !== h.set)
2834
- return f(a, {
2835
- code: d.invalid_type,
2836
- expected: h.set,
2837
- received: a.parsedType
2838
- }), b;
2839
- const r = this._def;
2840
- r.minSize !== null && a.data.size < r.minSize.value && (f(a, {
2841
- code: d.too_small,
2842
- minimum: r.minSize.value,
2843
- type: "set",
2844
- inclusive: !0,
2845
- exact: !1,
2846
- message: r.minSize.message
2847
- }), t.dirty()), r.maxSize !== null && a.data.size > r.maxSize.value && (f(a, {
2848
- code: d.too_big,
2849
- maximum: r.maxSize.value,
2850
- type: "set",
2851
- inclusive: !0,
2852
- exact: !1,
2853
- message: r.maxSize.message
2854
- }), t.dirty());
2855
- const s = this._def.valueType;
2856
- function i(u) {
2857
- const c = /* @__PURE__ */ new Set();
2858
- for (const m of u) {
2859
- if (m.status === "aborted")
2860
- return b;
2861
- m.status === "dirty" && t.dirty(), c.add(m.value);
2862
- }
2863
- return { status: t.value, value: c };
2864
- }
2865
- const o = [...a.data.values()].map((u, c) => s._parse(new j(a, u, a.path, c)));
2866
- return a.common.async ? Promise.all(o).then((u) => i(u)) : i(o);
2867
- }
2868
- min(e, t) {
2869
- return new Y({
2870
- ...this._def,
2871
- minSize: { value: e, message: p.toString(t) }
2872
- });
2873
- }
2874
- max(e, t) {
2875
- return new Y({
2876
- ...this._def,
2877
- maxSize: { value: e, message: p.toString(t) }
2878
- });
2879
- }
2880
- size(e, t) {
2881
- return this.min(e, t).max(e, t);
2882
- }
2883
- nonempty(e) {
2884
- return this.min(1, e);
2885
- }
2886
- }
2887
- Y.create = (n, e) => new Y({
2888
- valueType: n,
2889
- minSize: null,
2890
- maxSize: null,
2891
- typeName: y.ZodSet,
2892
- ...g(e)
2893
- });
2894
- class X extends v {
2895
- constructor() {
2896
- super(...arguments), this.validate = this.implement;
2897
- }
2898
- _parse(e) {
2899
- const { ctx: t } = this._processInputParams(e);
2900
- if (t.parsedType !== h.function)
2901
- return f(t, {
2902
- code: d.invalid_type,
2903
- expected: h.function,
2904
- received: t.parsedType
2905
- }), b;
2906
- function a(o, u) {
2907
- return Te({
2908
- data: o,
2909
- path: t.path,
2910
- errorMaps: [
2911
- t.common.contextualErrorMap,
2912
- t.schemaErrorMap,
2913
- ke(),
2914
- ee
2915
- ].filter((c) => !!c),
2916
- issueData: {
2917
- code: d.invalid_arguments,
2918
- argumentsError: u
2919
- }
2920
- });
2921
- }
2922
- function r(o, u) {
2923
- return Te({
2924
- data: o,
2925
- path: t.path,
2926
- errorMaps: [
2927
- t.common.contextualErrorMap,
2928
- t.schemaErrorMap,
2929
- ke(),
2930
- ee
2931
- ].filter((c) => !!c),
2932
- issueData: {
2933
- code: d.invalid_return_type,
2934
- returnTypeError: u
2935
- }
2936
- });
2937
- }
2938
- const s = { errorMap: t.common.contextualErrorMap }, i = t.data;
2939
- if (this._def.returns instanceof ne) {
2940
- const o = this;
2941
- return A(async function(...u) {
2942
- const c = new E([]), m = await o._def.args.parseAsync(u, s).catch((S) => {
2943
- throw c.addIssue(a(u, S)), c;
2944
- }), C = await Reflect.apply(i, this, m);
2945
- return await o._def.returns._def.type.parseAsync(C, s).catch((S) => {
2946
- throw c.addIssue(r(C, S)), c;
2947
- });
2948
- });
2949
- } else {
2950
- const o = this;
2951
- return A(function(...u) {
2952
- const c = o._def.args.safeParse(u, s);
2953
- if (!c.success)
2954
- throw new E([a(u, c.error)]);
2955
- const m = Reflect.apply(i, this, c.data), C = o._def.returns.safeParse(m, s);
2956
- if (!C.success)
2957
- throw new E([r(m, C.error)]);
2958
- return C.data;
2959
- });
2960
- }
2961
- }
2962
- parameters() {
2963
- return this._def.args;
2964
- }
2965
- returnType() {
2966
- return this._def.returns;
2967
- }
2968
- args(...e) {
2969
- return new X({
2970
- ...this._def,
2971
- args: M.create(e).rest(q.create())
2972
- });
2973
- }
2974
- returns(e) {
2975
- return new X({
2976
- ...this._def,
2977
- returns: e
2978
- });
2979
- }
2980
- implement(e) {
2981
- return this.parse(e);
2982
- }
2983
- strictImplement(e) {
2984
- return this.parse(e);
2985
- }
2986
- static create(e, t, a) {
2987
- return new X({
2988
- args: e || M.create([]).rest(q.create()),
2989
- returns: t || q.create(),
2990
- typeName: y.ZodFunction,
2991
- ...g(a)
2992
- });
2993
- }
2994
- }
2995
- class pe extends v {
2996
- get schema() {
2997
- return this._def.getter();
2998
- }
2999
- _parse(e) {
3000
- const { ctx: t } = this._processInputParams(e);
3001
- return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
3002
- }
3003
- }
3004
- pe.create = (n, e) => new pe({
3005
- getter: n,
3006
- typeName: y.ZodLazy,
3007
- ...g(e)
3008
- });
3009
- class me extends v {
3010
- _parse(e) {
3011
- if (e.data !== this._def.value) {
3012
- const t = this._getOrReturnCtx(e);
3013
- return f(t, {
3014
- received: t.data,
3015
- code: d.invalid_literal,
3016
- expected: this._def.value
3017
- }), b;
3018
- }
3019
- return { status: "valid", value: e.data };
3020
- }
3021
- get value() {
3022
- return this._def.value;
3023
- }
3024
- }
3025
- me.create = (n, e) => new me({
3026
- value: n,
3027
- typeName: y.ZodLiteral,
3028
- ...g(e)
3029
- });
3030
- function yt(n, e) {
3031
- return new W({
3032
- values: n,
3033
- typeName: y.ZodEnum,
3034
- ...g(e)
3035
- });
3036
- }
3037
- class W extends v {
3038
- constructor() {
3039
- super(...arguments), ae.set(this, void 0);
3040
- }
3041
- _parse(e) {
3042
- if (typeof e.data != "string") {
3043
- const t = this._getOrReturnCtx(e), a = this._def.values;
3044
- return f(t, {
3045
- expected: _.joinValues(a),
3046
- received: t.parsedType,
3047
- code: d.invalid_type
3048
- }), b;
3049
- }
3050
- if (Ce(this, ae) || ft(this, ae, new Set(this._def.values)), !Ce(this, ae).has(e.data)) {
3051
- const t = this._getOrReturnCtx(e), a = this._def.values;
3052
- return f(t, {
3053
- received: t.data,
3054
- code: d.invalid_enum_value,
3055
- options: a
3056
- }), b;
3057
- }
3058
- return A(e.data);
3059
- }
3060
- get options() {
3061
- return this._def.values;
3062
- }
3063
- get enum() {
3064
- const e = {};
3065
- for (const t of this._def.values)
3066
- e[t] = t;
3067
- return e;
3068
- }
3069
- get Values() {
3070
- const e = {};
3071
- for (const t of this._def.values)
3072
- e[t] = t;
3073
- return e;
3074
- }
3075
- get Enum() {
3076
- const e = {};
3077
- for (const t of this._def.values)
3078
- e[t] = t;
3079
- return e;
3080
- }
3081
- extract(e, t = this._def) {
3082
- return W.create(e, {
3083
- ...this._def,
3084
- ...t
3085
- });
3086
- }
3087
- exclude(e, t = this._def) {
3088
- return W.create(this.options.filter((a) => !e.includes(a)), {
3089
- ...this._def,
3090
- ...t
3091
- });
3092
- }
3093
- }
3094
- ae = /* @__PURE__ */ new WeakMap();
3095
- W.create = yt;
3096
- class ye extends v {
3097
- constructor() {
3098
- super(...arguments), re.set(this, void 0);
3099
- }
3100
- _parse(e) {
3101
- const t = _.getValidEnumValues(this._def.values), a = this._getOrReturnCtx(e);
3102
- if (a.parsedType !== h.string && a.parsedType !== h.number) {
3103
- const r = _.objectValues(t);
3104
- return f(a, {
3105
- expected: _.joinValues(r),
3106
- received: a.parsedType,
3107
- code: d.invalid_type
3108
- }), b;
3109
- }
3110
- if (Ce(this, re) || ft(this, re, new Set(_.getValidEnumValues(this._def.values))), !Ce(this, re).has(e.data)) {
3111
- const r = _.objectValues(t);
3112
- return f(a, {
3113
- received: a.data,
3114
- code: d.invalid_enum_value,
3115
- options: r
3116
- }), b;
3117
- }
3118
- return A(e.data);
3119
- }
3120
- get enum() {
3121
- return this._def.values;
3122
- }
3123
- }
3124
- re = /* @__PURE__ */ new WeakMap();
3125
- ye.create = (n, e) => new ye({
3126
- values: n,
3127
- typeName: y.ZodNativeEnum,
3128
- ...g(e)
3129
- });
3130
- class ne extends v {
3131
- unwrap() {
3132
- return this._def.type;
3133
- }
3134
- _parse(e) {
3135
- const { ctx: t } = this._processInputParams(e);
3136
- if (t.parsedType !== h.promise && t.common.async === !1)
3137
- return f(t, {
3138
- code: d.invalid_type,
3139
- expected: h.promise,
3140
- received: t.parsedType
3141
- }), b;
3142
- const a = t.parsedType === h.promise ? t.data : Promise.resolve(t.data);
3143
- return A(a.then((r) => this._def.type.parseAsync(r, {
3144
- path: t.path,
3145
- errorMap: t.common.contextualErrorMap
3146
- })));
3147
- }
3148
- }
3149
- ne.create = (n, e) => new ne({
3150
- type: n,
3151
- typeName: y.ZodPromise,
3152
- ...g(e)
3153
- });
3154
- class R extends v {
3155
- innerType() {
3156
- return this._def.schema;
3157
- }
3158
- sourceType() {
3159
- return this._def.schema._def.typeName === y.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3160
- }
3161
- _parse(e) {
3162
- const { status: t, ctx: a } = this._processInputParams(e), r = this._def.effect || null, s = {
3163
- addIssue: (i) => {
3164
- f(a, i), i.fatal ? t.abort() : t.dirty();
3165
- },
3166
- get path() {
3167
- return a.path;
3168
- }
3169
- };
3170
- if (s.addIssue = s.addIssue.bind(s), r.type === "preprocess") {
3171
- const i = r.transform(a.data, s);
3172
- if (a.common.async)
3173
- return Promise.resolve(i).then(async (o) => {
3174
- if (t.value === "aborted")
3175
- return b;
3176
- const u = await this._def.schema._parseAsync({
3177
- data: o,
3178
- path: a.path,
3179
- parent: a
3180
- });
3181
- return u.status === "aborted" ? b : u.status === "dirty" || t.value === "dirty" ? Q(u.value) : u;
3182
- });
3183
- {
3184
- if (t.value === "aborted")
3185
- return b;
3186
- const o = this._def.schema._parseSync({
3187
- data: i,
3188
- path: a.path,
3189
- parent: a
3190
- });
3191
- return o.status === "aborted" ? b : o.status === "dirty" || t.value === "dirty" ? Q(o.value) : o;
3192
- }
3193
- }
3194
- if (r.type === "refinement") {
3195
- const i = (o) => {
3196
- const u = r.refinement(o, s);
3197
- if (a.common.async)
3198
- return Promise.resolve(u);
3199
- if (u instanceof Promise)
3200
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3201
- return o;
3202
- };
3203
- if (a.common.async === !1) {
3204
- const o = this._def.schema._parseSync({
3205
- data: a.data,
3206
- path: a.path,
3207
- parent: a
3208
- });
3209
- return o.status === "aborted" ? b : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
3210
- } else
3211
- return this._def.schema._parseAsync({ data: a.data, path: a.path, parent: a }).then((o) => o.status === "aborted" ? b : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
3212
- }
3213
- if (r.type === "transform")
3214
- if (a.common.async === !1) {
3215
- const i = this._def.schema._parseSync({
3216
- data: a.data,
3217
- path: a.path,
3218
- parent: a
3219
- });
3220
- if (!ie(i))
3221
- return i;
3222
- const o = r.transform(i.value, s);
3223
- if (o instanceof Promise)
3224
- throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
3225
- return { status: t.value, value: o };
3226
- } else
3227
- return this._def.schema._parseAsync({ data: a.data, path: a.path, parent: a }).then((i) => ie(i) ? Promise.resolve(r.transform(i.value, s)).then((o) => ({ status: t.value, value: o })) : i);
3228
- _.assertNever(r);
3229
- }
3230
- }
3231
- R.create = (n, e, t) => new R({
3232
- schema: n,
3233
- typeName: y.ZodEffects,
3234
- effect: e,
3235
- ...g(t)
3236
- });
3237
- R.createWithPreprocess = (n, e, t) => new R({
3238
- schema: e,
3239
- effect: { type: "preprocess", transform: n },
3240
- typeName: y.ZodEffects,
3241
- ...g(t)
3242
- });
3243
- class Z extends v {
3244
- _parse(e) {
3245
- return this._getType(e) === h.undefined ? A(void 0) : this._def.innerType._parse(e);
3246
- }
3247
- unwrap() {
3248
- return this._def.innerType;
3249
- }
3250
- }
3251
- Z.create = (n, e) => new Z({
3252
- innerType: n,
3253
- typeName: y.ZodOptional,
3254
- ...g(e)
3255
- });
3256
- class F extends v {
3257
- _parse(e) {
3258
- return this._getType(e) === h.null ? A(null) : this._def.innerType._parse(e);
3259
- }
3260
- unwrap() {
3261
- return this._def.innerType;
3262
- }
3263
- }
3264
- F.create = (n, e) => new F({
3265
- innerType: n,
3266
- typeName: y.ZodNullable,
3267
- ...g(e)
3268
- });
3269
- class be extends v {
3270
- _parse(e) {
3271
- const { ctx: t } = this._processInputParams(e);
3272
- let a = t.data;
3273
- return t.parsedType === h.undefined && (a = this._def.defaultValue()), this._def.innerType._parse({
3274
- data: a,
3275
- path: t.path,
3276
- parent: t
3277
- });
3278
- }
3279
- removeDefault() {
3280
- return this._def.innerType;
3281
- }
3282
- }
3283
- be.create = (n, e) => new be({
3284
- innerType: n,
3285
- typeName: y.ZodDefault,
3286
- defaultValue: typeof e.default == "function" ? e.default : () => e.default,
3287
- ...g(e)
3288
- });
3289
- class ge extends v {
3290
- _parse(e) {
3291
- const { ctx: t } = this._processInputParams(e), a = {
3292
- ...t,
3293
- common: {
3294
- ...t.common,
3295
- issues: []
3296
- }
3297
- }, r = this._def.innerType._parse({
3298
- data: a.data,
3299
- path: a.path,
3300
- parent: {
3301
- ...a
3302
- }
3303
- });
3304
- return oe(r) ? r.then((s) => ({
3305
- status: "valid",
3306
- value: s.status === "valid" ? s.value : this._def.catchValue({
3307
- get error() {
3308
- return new E(a.common.issues);
3309
- },
3310
- input: a.data
3311
- })
3312
- })) : {
3313
- status: "valid",
3314
- value: r.status === "valid" ? r.value : this._def.catchValue({
3315
- get error() {
3316
- return new E(a.common.issues);
3317
- },
3318
- input: a.data
3319
- })
3320
- };
3321
- }
3322
- removeCatch() {
3323
- return this._def.innerType;
3324
- }
3325
- }
3326
- ge.create = (n, e) => new ge({
3327
- innerType: n,
3328
- typeName: y.ZodCatch,
3329
- catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
3330
- ...g(e)
3331
- });
3332
- class Ee extends v {
3333
- _parse(e) {
3334
- if (this._getType(e) !== h.nan) {
3335
- const a = this._getOrReturnCtx(e);
3336
- return f(a, {
3337
- code: d.invalid_type,
3338
- expected: h.nan,
3339
- received: a.parsedType
3340
- }), b;
3341
- }
3342
- return { status: "valid", value: e.data };
3343
- }
3344
- }
3345
- Ee.create = (n) => new Ee({
3346
- typeName: y.ZodNaN,
3347
- ...g(n)
3348
- });
3349
- const On = Symbol("zod_brand");
3350
- class He extends v {
3351
- _parse(e) {
3352
- const { ctx: t } = this._processInputParams(e), a = t.data;
3353
- return this._def.type._parse({
3354
- data: a,
3355
- path: t.path,
3356
- parent: t
3357
- });
3358
- }
3359
- unwrap() {
3360
- return this._def.type;
3361
- }
3362
- }
3363
- class _e extends v {
3364
- _parse(e) {
3365
- const { status: t, ctx: a } = this._processInputParams(e);
3366
- if (a.common.async)
3367
- return (async () => {
3368
- const s = await this._def.in._parseAsync({
3369
- data: a.data,
3370
- path: a.path,
3371
- parent: a
3372
- });
3373
- return s.status === "aborted" ? b : s.status === "dirty" ? (t.dirty(), Q(s.value)) : this._def.out._parseAsync({
3374
- data: s.value,
3375
- path: a.path,
3376
- parent: a
3377
- });
3378
- })();
3379
- {
3380
- const r = this._def.in._parseSync({
3381
- data: a.data,
3382
- path: a.path,
3383
- parent: a
3384
- });
3385
- return r.status === "aborted" ? b : r.status === "dirty" ? (t.dirty(), {
3386
- status: "dirty",
3387
- value: r.value
3388
- }) : this._def.out._parseSync({
3389
- data: r.value,
3390
- path: a.path,
3391
- parent: a
3392
- });
3393
- }
3394
- }
3395
- static create(e, t) {
3396
- return new _e({
3397
- in: e,
3398
- out: t,
3399
- typeName: y.ZodPipeline
3400
- });
3401
- }
3402
- }
3403
- class ve extends v {
3404
- _parse(e) {
3405
- const t = this._def.innerType._parse(e), a = (r) => (ie(r) && (r.value = Object.freeze(r.value)), r);
3406
- return oe(t) ? t.then((r) => a(r)) : a(t);
3407
- }
3408
- unwrap() {
3409
- return this._def.innerType;
3410
- }
3411
- }
3412
- ve.create = (n, e) => new ve({
3413
- innerType: n,
3414
- typeName: y.ZodReadonly,
3415
- ...g(e)
3416
- });
3417
- function bt(n, e = {}, t) {
3418
- return n ? te.create().superRefine((a, r) => {
3419
- var s, i;
3420
- if (!n(a)) {
3421
- const o = typeof e == "function" ? e(a) : typeof e == "string" ? { message: e } : e, u = (i = (s = o.fatal) !== null && s !== void 0 ? s : t) !== null && i !== void 0 ? i : !0, c = typeof o == "string" ? { message: o } : o;
3422
- r.addIssue({ code: "custom", ...c, fatal: u });
3423
- }
3424
- }) : te.create();
3425
- }
3426
- const Rn = {
3427
- object: k.lazycreate
3428
- };
3429
- var y;
3430
- (function(n) {
3431
- n.ZodString = "ZodString", n.ZodNumber = "ZodNumber", n.ZodNaN = "ZodNaN", n.ZodBigInt = "ZodBigInt", n.ZodBoolean = "ZodBoolean", n.ZodDate = "ZodDate", n.ZodSymbol = "ZodSymbol", n.ZodUndefined = "ZodUndefined", n.ZodNull = "ZodNull", n.ZodAny = "ZodAny", n.ZodUnknown = "ZodUnknown", n.ZodNever = "ZodNever", n.ZodVoid = "ZodVoid", n.ZodArray = "ZodArray", n.ZodObject = "ZodObject", n.ZodUnion = "ZodUnion", n.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", n.ZodIntersection = "ZodIntersection", n.ZodTuple = "ZodTuple", n.ZodRecord = "ZodRecord", n.ZodMap = "ZodMap", n.ZodSet = "ZodSet", n.ZodFunction = "ZodFunction", n.ZodLazy = "ZodLazy", n.ZodLiteral = "ZodLiteral", n.ZodEnum = "ZodEnum", n.ZodEffects = "ZodEffects", n.ZodNativeEnum = "ZodNativeEnum", n.ZodOptional = "ZodOptional", n.ZodNullable = "ZodNullable", n.ZodDefault = "ZodDefault", n.ZodCatch = "ZodCatch", n.ZodPromise = "ZodPromise", n.ZodBranded = "ZodBranded", n.ZodPipeline = "ZodPipeline", n.ZodReadonly = "ZodReadonly";
3432
- })(y || (y = {}));
3433
- const Zn = (n, e = {
3434
- message: `Input not instance of ${n.name}`
3435
- }) => bt((t) => t instanceof n, e), gt = N.create, vt = z.create, jn = Ee.create, Mn = U.create, _t = ce.create, Pn = G.create, $n = Se.create, Dn = de.create, Vn = ue.create, Bn = te.create, Ln = q.create, zn = V.create, Un = Ie.create, Wn = O.create, Fn = k.create, qn = k.strictCreate, Hn = le.create, Gn = Oe.create, Yn = fe.create, Jn = M.create, Kn = he.create, Qn = Ae.create, Xn = Y.create, ea = X.create, ta = pe.create, na = me.create, aa = W.create, ra = ye.create, sa = ne.create, tt = R.create, ia = Z.create, oa = F.create, ca = R.createWithPreprocess, da = _e.create, ua = () => gt().optional(), la = () => vt().optional(), fa = () => _t().optional(), ha = {
3436
- string: (n) => N.create({ ...n, coerce: !0 }),
3437
- number: (n) => z.create({ ...n, coerce: !0 }),
3438
- boolean: (n) => ce.create({
3439
- ...n,
3440
- coerce: !0
3441
- }),
3442
- bigint: (n) => U.create({ ...n, coerce: !0 }),
3443
- date: (n) => G.create({ ...n, coerce: !0 })
3444
- }, pa = b;
3445
- var l = /* @__PURE__ */ Object.freeze({
3446
- __proto__: null,
3447
- defaultErrorMap: ee,
3448
- setErrorMap: pn,
3449
- getErrorMap: ke,
3450
- makeIssue: Te,
3451
- EMPTY_PATH: mn,
3452
- addIssueToContext: f,
3453
- ParseStatus: I,
3454
- INVALID: b,
3455
- DIRTY: Q,
3456
- OK: A,
3457
- isAborted: Ve,
3458
- isDirty: Be,
3459
- isValid: ie,
3460
- isAsync: oe,
3461
- get util() {
3462
- return _;
3463
- },
3464
- get objectUtil() {
3465
- return De;
3466
- },
3467
- ZodParsedType: h,
3468
- getParsedType: L,
3469
- ZodType: v,
3470
- datetimeRegex: mt,
3471
- ZodString: N,
3472
- ZodNumber: z,
3473
- ZodBigInt: U,
3474
- ZodBoolean: ce,
3475
- ZodDate: G,
3476
- ZodSymbol: Se,
3477
- ZodUndefined: de,
3478
- ZodNull: ue,
3479
- ZodAny: te,
3480
- ZodUnknown: q,
3481
- ZodNever: V,
3482
- ZodVoid: Ie,
3483
- ZodArray: O,
3484
- ZodObject: k,
3485
- ZodUnion: le,
3486
- ZodDiscriminatedUnion: Oe,
3487
- ZodIntersection: fe,
3488
- ZodTuple: M,
3489
- ZodRecord: he,
3490
- ZodMap: Ae,
3491
- ZodSet: Y,
3492
- ZodFunction: X,
3493
- ZodLazy: pe,
3494
- ZodLiteral: me,
3495
- ZodEnum: W,
3496
- ZodNativeEnum: ye,
3497
- ZodPromise: ne,
3498
- ZodEffects: R,
3499
- ZodTransformer: R,
3500
- ZodOptional: Z,
3501
- ZodNullable: F,
3502
- ZodDefault: be,
3503
- ZodCatch: ge,
3504
- ZodNaN: Ee,
3505
- BRAND: On,
3506
- ZodBranded: He,
3507
- ZodPipeline: _e,
3508
- ZodReadonly: ve,
3509
- custom: bt,
3510
- Schema: v,
3511
- ZodSchema: v,
3512
- late: Rn,
3513
- get ZodFirstPartyTypeKind() {
3514
- return y;
3515
- },
3516
- coerce: ha,
3517
- any: Bn,
3518
- array: Wn,
3519
- bigint: Mn,
3520
- boolean: _t,
3521
- date: Pn,
3522
- discriminatedUnion: Gn,
3523
- effect: tt,
3524
- enum: aa,
3525
- function: ea,
3526
- instanceof: Zn,
3527
- intersection: Yn,
3528
- lazy: ta,
3529
- literal: na,
3530
- map: Qn,
3531
- nan: jn,
3532
- nativeEnum: ra,
3533
- never: zn,
3534
- null: Vn,
3535
- nullable: oa,
3536
- number: vt,
3537
- object: Fn,
3538
- oboolean: fa,
3539
- onumber: la,
3540
- optional: ia,
3541
- ostring: ua,
3542
- pipeline: da,
3543
- preprocess: ca,
3544
- promise: sa,
3545
- record: Kn,
3546
- set: Xn,
3547
- strictObject: qn,
3548
- string: gt,
3549
- symbol: $n,
3550
- transformer: tt,
3551
- tuple: Jn,
3552
- undefined: Dn,
3553
- union: Hn,
3554
- unknown: Ln,
3555
- void: Un,
3556
- NEVER: pa,
3557
- ZodIssueCode: d,
3558
- quotelessJson: hn,
3559
- ZodError: E
3560
- });
3561
- const ma = "test test test test test test test test test test test junk", za = async function(e, t) {
3562
- const a = t.privateKey, r = t.mnemonic ?? ma, s = t.chain || "anvil", [{ config: i, account: o }, u] = Ht({
3563
- chain: s,
3564
- rpcUrl: t.rpcUrl,
3565
- privateKey: a,
3566
- mnemonic: r
3567
- }), c = u.id;
3568
- if (e.at(0) === "generate")
3569
- return $a({ account: o == null ? void 0 : o.address, chainId: c });
3570
- if (e.at(0) === "erc20") {
3571
- let T = new ut({ config: i, account: o }, {});
3572
- return await T.deploy(), {
3573
- erc20: T.assertValidAddress()
3574
- };
3575
- }
3576
- const m = At[c];
3577
- if (!m)
3578
- throw new Error(
3579
- `Unable to select a deployed BoostRegistry with chain ID ${c}`
3580
- );
3581
- const C = new Et({
3582
- config: i,
3583
- account: o,
3584
- address: m
3585
- }), J = Nt[c];
3586
- if (!J)
3587
- throw new Error(
3588
- `Unable to select a deployed BoostCore with chain ID ${c}`
3589
- );
3590
- const S = new Ot({
3591
- config: i,
3592
- account: o,
3593
- address: J
3594
- });
3595
- if (!e.length) throw new Error("No seed provided");
3596
- const xt = await Promise.all(e.map(ya));
3597
- let Ze, Ge;
3598
- const Ye = [];
3599
- for (const T of xt) {
3600
- let P;
3601
- if (typeof T.budget == "string" && ze(T.budget))
3602
- P = S.ManagedBudget(T.budget);
3603
- else if (Pe(Ge, T.budget) && Ze)
3604
- P = Ze;
3605
- else {
3606
- const x = {
3607
- ...T.budget,
3608
- authorized: [...T.budget.authorized, J],
3609
- roles: [...T.budget.roles, rt.MANAGER]
3610
- };
3611
- P = await C.initialize(
3612
- crypto.randomUUID(),
3613
- S.ManagedBudget(x)
3614
- ), Ze = P, Ge = T.budget;
3615
- }
3616
- const wt = T.incentives.map(async (x) => {
3617
- let $ = 0n;
3618
- switch (x.type) {
3619
- case "AllowListIncentive":
3620
- return S.AllowListIncentive(x);
3621
- case "PointsIncentive":
3622
- return S.PointsIncentive(x);
3623
- case "ERC20Incentive":
3624
- return x.strategy === Me.RAFFLE && ($ += x.reward), x.strategy === Me.POOL && ($ += x.reward * x.limit), x.shouldMintAndAllocate && await xe(P, $, x.asset, {
3625
- config: i,
3626
- account: o
3627
- }), S.ERC20Incentive(x);
3628
- case "ERC20VariableCriteriaIncentive":
3629
- return $ += x.limit, x.shouldMintAndAllocate && await xe(P, $, x.asset, {
3630
- config: i,
3631
- account: o
3632
- }), S.ERC20VariableCriteriaIncentive(x);
3633
- case "ERC20VariableIncentive":
3634
- return $ += x.limit, x.shouldMintAndAllocate && await xe(P, $, x.asset, {
3635
- config: i,
3636
- account: o
3637
- }), S.ERC20VariableIncentive(x);
3638
- case "CGDAIncentive":
3639
- return $ += x.totalBudget, x.shouldMintAndAllocate && await xe(P, $, x.asset, {
3640
- config: i,
3641
- account: o
3642
- }), S.CGDAIncentive(x);
3643
- }
3644
- }), kt = await Promise.all(wt), Je = {
3645
- protocolFee: T.protocolFee,
3646
- maxParticipants: T.maxParticipants,
3647
- budget: P,
3648
- action: S.EventAction(T.action),
3649
- allowList: await Ma(T, { core: S }),
3650
- incentives: kt
3651
- };
3652
- T.validator && (Je.validator = S.SignerValidator(T.validator));
3653
- const Tt = await S.createBoost(Je);
3654
- Ye.push(Tt.id.toString());
3655
- }
3656
- return {
3657
- boostIds: Ye
3658
- };
3659
- };
3660
- async function xe(n, e, t, a) {
3661
- if (t && e) {
3662
- let r = new ut(a, t);
3663
- await Pa(a, r, n, st(e.toString()));
3664
- }
3665
- }
3666
- async function ya(n) {
3667
- const e = await Ct.readFile(St.normalize(n), {
3668
- encoding: "utf8"
3669
- });
3670
- return ja.parse(JSON.parse(e));
3671
- }
3672
- const ba = l.custom(Ut, "invalid Hex payload"), w = l.string().transform((n, e) => (/^0x[a-fA-F0-9]{40}$/.test(n) || e.addIssue({
3673
- code: l.ZodIssueCode.custom,
3674
- message: `Invalid Address ${n}`
3675
- }), n)).pipe(l.custom(ze, "invalid eth address")), ga = l.coerce.number().min(1).max(2).transform(BigInt).pipe(l.custom()), va = l.object({
3676
- type: l.literal("ManagedBudget"),
3677
- owner: w,
3678
- authorized: l.array(w),
3679
- roles: l.array(ga)
3680
- }).refine(
3681
- (n) => n.authorized.length === n.roles.length,
3682
- "length mismatch authorized and roles"
3683
- ), Re = l.custom().pipe(
3684
- l.string().regex(/^(event|function) .*/, {
3685
- message: "signature must start with `event` or function`"
3686
- }).transform((n) => {
3687
- if (n.startsWith("function"))
3688
- return Wt(Ft(n));
3689
- if (n.startsWith("event")) return qt(n);
3690
- throw new Error("unreachable");
3691
- })
3692
- ), _a = l.object({
3693
- signatureType: l.nativeEnum(se),
3694
- signature: Re,
3695
- fieldIndex: l.number().nonnegative(),
3696
- targetContract: w,
3697
- chainid: l.number().nonnegative()
3698
- }), xa = l.object({
3699
- filterType: l.nativeEnum(nt),
3700
- fieldType: l.nativeEnum(at),
3701
- fieldIndex: l.number().nonnegative(),
3702
- filterData: ba
3703
- }), wa = l.object({
3704
- signature: Re,
3705
- signatureType: l.nativeEnum(se),
3706
- actionType: l.number().optional(),
3707
- targetContract: w,
3708
- chainid: l.number().nonnegative(),
3709
- actionParameter: xa
3710
- }), ka = l.object({
3711
- type: l.literal("EventAction"),
3712
- actionClaimant: _a,
3713
- actionSteps: l.array(wa).max(4)
3714
- }), Ta = l.object({
3715
- type: l.literal("SignerValidator"),
3716
- signers: l.array(w),
3717
- validatorCaller: w
3718
- }), Ca = l.object({
3719
- type: l.literal("SimpleDenyList"),
3720
- owner: w,
3721
- denied: l.array(w)
3722
- }), Sa = l.object({
3723
- type: l.literal("SimpleAllowList"),
3724
- owner: w,
3725
- allowed: l.array(w)
3726
- }), Ia = l.object({
3727
- type: l.literal("AllowListIncentive"),
3728
- allowList: w,
3729
- limit: l.coerce.bigint()
3730
- }), Aa = l.object({
3731
- type: l.literal("ERC20Incentive"),
3732
- asset: w,
3733
- shouldMintAndAllocate: l.boolean().optional().default(!1),
3734
- strategy: l.nativeEnum(Me),
3735
- reward: l.coerce.bigint(),
3736
- limit: l.coerce.bigint(),
3737
- manager: w.optional()
3738
- }), Ea = l.object({
3739
- type: l.literal("ERC20VariableIncentive"),
3740
- asset: w,
3741
- shouldMintAndAllocate: l.boolean().optional().default(!1),
3742
- reward: l.coerce.bigint(),
3743
- limit: l.coerce.bigint(),
3744
- manager: w
3745
- }), Na = l.object({
3746
- criteriaType: l.nativeEnum(se),
3747
- signature: Re,
3748
- fieldIndex: l.number().nonnegative(),
3749
- targetContract: w
3750
- }), Oa = l.object({
3751
- type: l.literal("ERC20VariableCriteriaIncentive"),
3752
- asset: w,
3753
- shouldMintAndAllocate: l.boolean().optional().default(!1),
3754
- reward: l.coerce.bigint(),
3755
- limit: l.coerce.bigint(),
3756
- manager: w.optional(),
3757
- criteria: Na
3758
- }), Ra = l.object({
3759
- type: l.literal("CGDAIncentive"),
3760
- asset: w,
3761
- shouldMintAndAllocate: l.boolean().optional().default(!1),
3762
- initialReward: l.coerce.bigint(),
3763
- rewardDecay: l.coerce.bigint(),
3764
- rewardBoost: l.coerce.bigint(),
3765
- totalBudget: l.coerce.bigint(),
3766
- manager: w
3767
- }), Za = l.object({
3768
- type: l.literal("PointsIncentive"),
3769
- venue: w,
3770
- selector: Re,
3771
- reward: l.coerce.bigint(),
3772
- limit: l.coerce.bigint()
3773
- }), ja = l.object({
3774
- protocolFee: l.coerce.bigint(),
3775
- maxParticipants: l.coerce.bigint(),
3776
- budget: l.union([w, va]),
3777
- action: l.union([w, ka]),
3778
- validator: l.union([w, Ta]).optional(),
3779
- allowList: l.union([w, Ca, Sa]).optional(),
3780
- incentives: l.array(
3781
- l.union([
3782
- Ia,
3783
- Aa,
3784
- Oa,
3785
- Ea,
3786
- Ra,
3787
- Za
3788
- ])
3789
- )
3790
- });
3791
- async function Ma({ allowList: n }, { core: e }) {
3792
- if (!n) return e.OpenAllowList();
3793
- if (typeof n == "string" && ze(n))
3794
- return await Rt(
3795
- //@ts-expect-error i do what i want
3796
- { config: e._config, account: e._account },
3797
- n
3798
- );
3799
- switch (n.type) {
3800
- case "SimpleAllowList":
3801
- return e.SimpleAllowList(n);
3802
- case "SimpleDenyList":
3803
- return e.SimpleDenyList(n);
3804
- default:
3805
- throw new Error("unusupported AllowList: " + n);
3806
- }
3807
- }
3808
- async function Pa(n, e, t, a = st("110")) {
3809
- return await e.mint(n.account.address, a), await e.approve(t.assertValidAddress(), a), await t.allocate({
3810
- amount: a,
3811
- asset: e.assertValidAddress(),
3812
- target: n.account.address
3813
- }), { budget: t, erc20: e };
3814
- }
3815
- function $a({
3816
- asset: n = "0xf3B2d0E4f2d8F453DBCc278b10e88b20d7f19f8D",
3817
- account: e = fn[0].account,
3818
- chainId: t
3819
- }) {
3820
- return {
3821
- protocolFee: 0n,
3822
- maxParticipants: 10n,
3823
- budget: {
3824
- type: "ManagedBudget",
3825
- owner: e,
3826
- authorized: [e],
3827
- roles: [rt.MANAGER]
3828
- },
3829
- action: {
3830
- type: "EventAction",
3831
- actionClaimant: {
3832
- signatureType: se.FUNC,
3833
- signature: "function mint(address to, uint256 amount)",
3834
- fieldIndex: 0,
3835
- targetContract: Ke,
3836
- chainid: t
3837
- },
3838
- actionSteps: [
3839
- {
3840
- signature: "event Minted(address to, uint256 amount)",
3841
- signatureType: se.FUNC,
3842
- actionType: 0,
3843
- targetContract: Ke,
3844
- chainid: t,
3845
- actionParameter: {
3846
- filterType: nt.EQUAL,
3847
- fieldType: at.ADDRESS,
3848
- fieldIndex: 0,
3849
- filterData: e
3850
- }
3851
- }
3852
- ]
3853
- },
3854
- validator: {
3855
- type: "SignerValidator",
3856
- signers: [e],
3857
- validatorCaller: e
3858
- },
3859
- allowList: {
3860
- type: "SimpleDenyList",
3861
- owner: e,
3862
- denied: []
3863
- },
3864
- incentives: [
3865
- {
3866
- type: "ERC20Incentive",
3867
- asset: n,
3868
- shouldMintAndAllocate: !1,
3869
- strategy: 0,
3870
- reward: 1n,
3871
- limit: 1n,
3872
- manager: e
3873
- }
3874
- ]
3875
- };
3876
- }
1
+ import "node:fs/promises";
2
+ import "node:path";
3
+ import "@boostxyz/sdk";
4
+ import { A as n, h as s, j as S, m as o, r as h, C as r, n as l, q as p, o as C, E as v, p as A, M as I, P as d, S as E, l as g, k as L, t as R, s as V } from "../seed-D3rLsa0v.js";
5
+ import "../utils-ClgLOuAN.js";
3877
6
  export {
3878
- _a as ActionClaimantSchema,
3879
- xa as ActionStepCriteriaSchema,
3880
- wa as ActionStepSchema,
3881
- Ia as AllowListIncentiveSchema,
3882
- ja as BoostSeedConfigSchema,
3883
- Ra as CGDAIncentiveSchema,
3884
- Aa as ERC20IncentiveSchema,
3885
- Oa as ERC20VariableCriteriaIncentiveSchema,
3886
- Ea as ERC20VariableIncentiveSchema,
3887
- ka as EventActionSchema,
3888
- Na as IncentiveCriteriaSchema,
3889
- va as ManagedBudgetSchema,
3890
- Za as PointsIncentiveSchema,
3891
- Ta as SignerValidatorSchema,
3892
- Sa as SimpleAllowListSchema,
3893
- Ca as SimpleDenyListSchema,
3894
- $a as makeSeed,
3895
- za as seed
7
+ n as ActionClaimantSchema,
8
+ s as ActionStepCriteriaSchema,
9
+ S as ActionStepSchema,
10
+ o as AllowListIncentiveSchema,
11
+ h as BoostSeedConfigSchema,
12
+ r as CGDAIncentiveSchema,
13
+ l as ERC20IncentiveSchema,
14
+ p as ERC20VariableCriteriaIncentiveSchema,
15
+ C as ERC20VariableIncentiveSchema,
16
+ v as EventActionSchema,
17
+ A as IncentiveCriteriaSchema,
18
+ I as ManagedBudgetSchema,
19
+ d as PointsIncentiveSchema,
20
+ E as SignerValidatorSchema,
21
+ g as SimpleAllowListSchema,
22
+ L as SimpleDenyListSchema,
23
+ R as makeSeed,
24
+ V as seed
3896
25
  };