@tapcart/app-studio-sdk 2.1.9 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5027 @@
1
+ import Y, { createContext as H, useReducer as Oa, useEffect as We, useContext as U, useMemo as X, useId as Ia, useState as xt, useCallback as Jr } from "react";
2
+ const Na = (e) => e && Object.keys(e).length === 0 && e.constructor === Object;
3
+ class Da {
4
+ constructor(t) {
5
+ this.quantity = t.quantity || null, this.productId = t.productId || null, this.variantId = t.variantId || null, this.sellingPlanId = t.sellingPlanId || null, this.sellingPlanAllocation = t.sellingPlanAllocation || null, this.attributes = t.attributes || {}, this.discounts = t.discounts || [], this.id = t.id || null, this.compareAtPrice = t.compareAtPrice || null, this.cost = t.cost || null, this.currencyCode = t.currencyCode || null, this.featuredImage = t.featuredImage || null, this.image = t.image || null, this.merchandise = t.merchandise || null, this.price = t.price || null, this.productVendor = t.productVendor || null, this.quantityAvailable = t.quantityAvailable || null, this.selectedOptions = t.selectedOptions || [], this.title = t.title || null, this.totalAmount = t.totalAmount || null;
6
+ }
7
+ }
8
+ class Ra {
9
+ constructor(t, r, n, a) {
10
+ this.type = t, this.title = r || null, this.code = n || null, this.amount = a || null;
11
+ }
12
+ }
13
+ function we(e) {
14
+ return !e || typeof e != "string" ? null : e.split("/").at(-1) || null;
15
+ }
16
+ function La(e) {
17
+ var Kt, Wt, Jt, Zt, Yt;
18
+ const { attributes: t, discountAllocations: r, merchandise: n, cost: a, quantity: i, id: s, sellingPlanAllocation: o, ...c } = e, u = t == null ? void 0 : t.reduce(
19
+ (P, O) => (P[O.key] = O.value, P),
20
+ {}
21
+ ), l = r == null ? void 0 : r.map(
22
+ (P) => {
23
+ var J;
24
+ const O = (J = P == null ? void 0 : P.discountedAmount) == null ? void 0 : J.amount, V = O ? Number.parseFloat(O) : null;
25
+ return new Ra(
26
+ P.targetType,
27
+ P.title || P.code,
28
+ P.code,
29
+ Number.isNaN(V) ? null : V
30
+ );
31
+ }
32
+ ), { product: d, ...f } = n || {}, { variants: p, id: m, availableForSale: v, title: g, vendor: S, ...b } = d || {}, C = p == null ? void 0 : p.find((P) => P.id === (n == null ? void 0 : n.id)), { id: x, price: $, compareAtPrice: _, availableForSale: N, quantityAvailable: R, selectedOptions: G, title: L, image: F, ...K } = C || {}, z = $ != null && $.amount ? Number.parseFloat($.amount) : null, T = _ != null && _.amount ? Number.parseFloat(_.amount) : null, { totalAmount: w } = a || {}, Ae = w != null && w.amount ? Number.parseFloat(w.amount) : null, Bt = (w == null ? void 0 : w.currencyCode) || ($ == null ? void 0 : $.currencyCode) || null, Ta = ((Wt = (Kt = p == null ? void 0 : p[0]) == null ? void 0 : Kt.image) == null ? void 0 : Wt.url) || (F == null ? void 0 : F.url) || null, xa = (F == null ? void 0 : F.url) || null, Pa = (P) => {
33
+ var V;
34
+ const O = (V = d == null ? void 0 : d.sellingPlanGroups) == null ? void 0 : V.flatMap((J) => J.sellingPlans).find((J) => J.id === P);
35
+ return (O == null ? void 0 : O.name) || null;
36
+ }, Fa = {
37
+ ...c,
38
+ // Basic fields
39
+ quantity: i,
40
+ productId: we(m) || m,
41
+ variantId: we(n == null ? void 0 : n.id) || (n == null ? void 0 : n.id),
42
+ sellingPlanId: ((Jt = o == null ? void 0 : o.sellingPlan) == null ? void 0 : Jt.id) || null,
43
+ // Find the selling plan name from the product's sellingPlanGroups, because Shopify loves a good treasure hunt.
44
+ sellingPlanAllocation: {
45
+ ...o,
46
+ sellingPlan: {
47
+ ...o == null ? void 0 : o.sellingPlan,
48
+ name: Pa((Zt = o == null ? void 0 : o.sellingPlan) == null ? void 0 : Zt.id)
49
+ }
50
+ },
51
+ attributes: u,
52
+ discounts: l,
53
+ // Additional comprehensive fields
54
+ id: s,
55
+ compareAtPrice: T,
56
+ cost: a,
57
+ currencyCode: Bt,
58
+ featuredImage: Ta,
59
+ image: xa,
60
+ merchandise: {
61
+ ...f,
62
+ ...K,
63
+ availableForSale: N || !1,
64
+ compareAtPrice: T,
65
+ id: we(n == null ? void 0 : n.id) || (n == null ? void 0 : n.id),
66
+ image: F ? {
67
+ id: "",
68
+ url: F.url
69
+ } : null,
70
+ isAvailable: N || !1,
71
+ price: z,
72
+ priceCurrencyCode: Bt,
73
+ product: {
74
+ ...b,
75
+ availableForSale: v || !1,
76
+ featuredImage: (Yt = p == null ? void 0 : p[0]) != null && Yt.image ? {
77
+ id: "",
78
+ url: p[0].image.url
79
+ } : null,
80
+ flashSaleData: {},
81
+ id: we(m) || m,
82
+ title: g || null,
83
+ variants: (p == null ? void 0 : p.map((P) => {
84
+ const { price: O, compareAtPrice: V, ...J } = P;
85
+ return {
86
+ ...J,
87
+ compareAtPrice: V != null && V.amount ? Number.parseFloat(V.amount) : null,
88
+ id: we(P.id) || P.id,
89
+ price: O != null && O.amount ? Number.parseFloat(O.amount) : null,
90
+ priceCurrencyCode: (O == null ? void 0 : O.currencyCode) || null
91
+ };
92
+ })) || [],
93
+ vendor: S || null
94
+ },
95
+ quantityAvailable: R || null,
96
+ selectedOptions: G || [],
97
+ title: L || (n == null ? void 0 : n.title) || null
98
+ },
99
+ price: z,
100
+ productVendor: S || null,
101
+ quantityAvailable: R || null,
102
+ selectedOptions: G || [],
103
+ title: g || null,
104
+ totalAmount: Ae
105
+ };
106
+ return new Da(Fa);
107
+ }
108
+ function Zr(e) {
109
+ if (!e)
110
+ return null;
111
+ const { lines: t, discountCodes: r, note: n, cost: a, ...i } = e, s = { ...i };
112
+ if (t && (s.lines = t, s.items = t.map((o) => La(o)) ?? []), r !== void 0 && (s.discountCodes = r, s.discounts = r), n !== void 0 && (s.note = n, s.notes = n), a && (s.cost = a, a.subtotalAmount))
113
+ try {
114
+ const { amount: o, currencyCode: c } = a.subtotalAmount, u = o ? Number.parseFloat(o) : null;
115
+ s.subtotal = Number.isNaN(u) ? null : u, s.currency = c;
116
+ } catch {
117
+ s.subtotal = null;
118
+ }
119
+ return s;
120
+ }
121
+ function Ma(e) {
122
+ const t = {};
123
+ if (!Array.isArray(e))
124
+ return t;
125
+ for (const r of e)
126
+ r && r.name && r.enabled && (t[r.name] = r);
127
+ return t;
128
+ }
129
+ const qa = (e) => {
130
+ if (!e)
131
+ return {};
132
+ const t = (n) => Array.isArray(n) ? n.reduce((a, { namespace: i, key: s, value: o }) => (a[i] ? a[i][s] = o : a[i] = {
133
+ [s]: o
134
+ }, a), {}) : n, r = Object.entries(e).reduce((n, [a, i]) => (n[a] = Na(i) && a !== "storage" ? null : i, n), {});
135
+ return e.product && (e.product.metafields && (r.product.metafields = t(
136
+ e.product.metafields
137
+ )), e.product.sourceCollection && e.product.sourceCollection.metafields && (r.product.sourceCollection.metafields = t(
138
+ e.product.sourceCollection.metafields
139
+ ))), e.collection && e.collection.metafields && (r.collection.metafields = t(
140
+ e.collection.metafields
141
+ )), e.customer && e.customer.metafields && (r.customer.metafields = t(
142
+ e.customer.metafields
143
+ )), e.integrations && (r.integrations = Ma(e.integrations)), e.cart && (r.cart = Zr(e.cart)), r;
144
+ }, Ua = () => {
145
+ let e = {};
146
+ return {
147
+ get variables() {
148
+ return e;
149
+ },
150
+ setVariables: (r = {}) => {
151
+ e = {
152
+ ...e,
153
+ ...qa(r)
154
+ };
155
+ }
156
+ };
157
+ };
158
+ let Yr = (e = 21) => crypto.getRandomValues(new Uint8Array(e)).reduce((t, r) => (r &= 63, r < 36 ? t += r.toString(36) : r < 62 ? t += (r - 26).toString(36).toUpperCase() : r > 62 ? t += "-" : t += "_", t), "");
159
+ var lt;
160
+ try {
161
+ lt = Map;
162
+ } catch {
163
+ }
164
+ var dt;
165
+ try {
166
+ dt = Set;
167
+ } catch {
168
+ }
169
+ function Xr(e, t, r) {
170
+ if (!e || typeof e != "object" || typeof e == "function")
171
+ return e;
172
+ if (e.nodeType && "cloneNode" in e)
173
+ return e.cloneNode(!0);
174
+ if (e instanceof Date)
175
+ return new Date(e.getTime());
176
+ if (e instanceof RegExp)
177
+ return new RegExp(e);
178
+ if (Array.isArray(e))
179
+ return e.map(ft);
180
+ if (lt && e instanceof lt)
181
+ return new Map(Array.from(e.entries()));
182
+ if (dt && e instanceof dt)
183
+ return new Set(Array.from(e.values()));
184
+ if (e instanceof Object) {
185
+ t.push(e);
186
+ var n = Object.create(e);
187
+ r.push(n);
188
+ for (var a in e) {
189
+ var i = t.findIndex(function(s) {
190
+ return s === e[a];
191
+ });
192
+ n[a] = i > -1 ? r[i] : Xr(e[a], t, r);
193
+ }
194
+ return n;
195
+ }
196
+ return e;
197
+ }
198
+ function ft(e) {
199
+ return Xr(e, [], []);
200
+ }
201
+ const ja = Object.prototype.toString, ka = Error.prototype.toString, Ga = RegExp.prototype.toString, za = typeof Symbol < "u" ? Symbol.prototype.toString : () => "", Va = /^Symbol\((.*)\)(.*)$/;
202
+ function Ba(e) {
203
+ return e != +e ? "NaN" : e === 0 && 1 / e < 0 ? "-0" : "" + e;
204
+ }
205
+ function Xt(e, t = !1) {
206
+ if (e == null || e === !0 || e === !1)
207
+ return "" + e;
208
+ const r = typeof e;
209
+ if (r === "number")
210
+ return Ba(e);
211
+ if (r === "string")
212
+ return t ? `"${e}"` : e;
213
+ if (r === "function")
214
+ return "[Function " + (e.name || "anonymous") + "]";
215
+ if (r === "symbol")
216
+ return za.call(e).replace(Va, "Symbol($1)");
217
+ const n = ja.call(e).slice(8, -1);
218
+ return n === "Date" ? isNaN(e.getTime()) ? "" + e : e.toISOString(e) : n === "Error" || e instanceof Error ? "[" + ka.call(e) + "]" : n === "RegExp" ? Ga.call(e) : null;
219
+ }
220
+ function pe(e, t) {
221
+ let r = Xt(e, t);
222
+ return r !== null ? r : JSON.stringify(e, function(n, a) {
223
+ let i = Xt(this[n], t);
224
+ return i !== null ? i : a;
225
+ }, 2);
226
+ }
227
+ let ie = {
228
+ default: "${path} is invalid",
229
+ required: "${path} is a required field",
230
+ oneOf: "${path} must be one of the following values: ${values}",
231
+ notOneOf: "${path} must not be one of the following values: ${values}",
232
+ notType: ({
233
+ path: e,
234
+ type: t,
235
+ value: r,
236
+ originalValue: n
237
+ }) => {
238
+ let a = n != null && n !== r, i = `${e} must be a \`${t}\` type, but the final value was: \`${pe(r, !0)}\`` + (a ? ` (cast from the value \`${pe(n, !0)}\`).` : ".");
239
+ return r === null && (i += '\n If "null" is intended as an empty value be sure to mark the schema as `.nullable()`'), i;
240
+ },
241
+ defined: "${path} must be defined"
242
+ }, k = {
243
+ length: "${path} must be exactly ${length} characters",
244
+ min: "${path} must be at least ${min} characters",
245
+ max: "${path} must be at most ${max} characters",
246
+ matches: '${path} must match the following: "${regex}"',
247
+ email: "${path} must be a valid email",
248
+ url: "${path} must be a valid URL",
249
+ uuid: "${path} must be a valid UUID",
250
+ trim: "${path} must be a trimmed string",
251
+ lowercase: "${path} must be a lowercase string",
252
+ uppercase: "${path} must be a upper case string"
253
+ }, Z = {
254
+ min: "${path} must be greater than or equal to ${min}",
255
+ max: "${path} must be less than or equal to ${max}",
256
+ lessThan: "${path} must be less than ${less}",
257
+ moreThan: "${path} must be greater than ${more}",
258
+ positive: "${path} must be a positive number",
259
+ negative: "${path} must be a negative number",
260
+ integer: "${path} must be an integer"
261
+ }, pt = {
262
+ min: "${path} field must be later than ${min}",
263
+ max: "${path} field must be at earlier than ${max}"
264
+ }, ht = {
265
+ isValue: "${path} field must be ${value}"
266
+ }, mt = {
267
+ noUnknown: "${path} field has unspecified keys: ${unknown}"
268
+ }, qe = {
269
+ min: "${path} field must have at least ${min} items",
270
+ max: "${path} field must have less than or equal to ${max} items",
271
+ length: "${path} must have ${length} items"
272
+ };
273
+ Object.assign(/* @__PURE__ */ Object.create(null), {
274
+ mixed: ie,
275
+ string: k,
276
+ number: Z,
277
+ date: pt,
278
+ object: mt,
279
+ array: qe,
280
+ boolean: ht
281
+ });
282
+ var Ie = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
283
+ function me(e) {
284
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
285
+ }
286
+ var Ka = Object.prototype, Wa = Ka.hasOwnProperty;
287
+ function Ja(e, t) {
288
+ return e != null && Wa.call(e, t);
289
+ }
290
+ var Za = Ja, Ya = Array.isArray, ee = Ya, Xa = typeof Ie == "object" && Ie && Ie.Object === Object && Ie, Qr = Xa, Qa = Qr, Ha = typeof self == "object" && self && self.Object === Object && self, ei = Qa || Ha || Function("return this")(), W = ei, ti = W, ri = ti.Symbol, Je = ri, Qt = Je, Hr = Object.prototype, ni = Hr.hasOwnProperty, ai = Hr.toString, Ee = Qt ? Qt.toStringTag : void 0;
291
+ function ii(e) {
292
+ var t = ni.call(e, Ee), r = e[Ee];
293
+ try {
294
+ e[Ee] = void 0;
295
+ var n = !0;
296
+ } catch {
297
+ }
298
+ var a = ai.call(e);
299
+ return n && (t ? e[Ee] = r : delete e[Ee]), a;
300
+ }
301
+ var si = ii, oi = Object.prototype, ci = oi.toString;
302
+ function ui(e) {
303
+ return ci.call(e);
304
+ }
305
+ var li = ui, Ht = Je, di = si, fi = li, pi = "[object Null]", hi = "[object Undefined]", er = Ht ? Ht.toStringTag : void 0;
306
+ function mi(e) {
307
+ return e == null ? e === void 0 ? hi : pi : er && er in Object(e) ? di(e) : fi(e);
308
+ }
309
+ var Pe = mi;
310
+ function yi(e) {
311
+ return e != null && typeof e == "object";
312
+ }
313
+ var Fe = yi, gi = Pe, vi = Fe, _i = "[object Symbol]";
314
+ function Si(e) {
315
+ return typeof e == "symbol" || vi(e) && gi(e) == _i;
316
+ }
317
+ var Pt = Si, bi = ee, $i = Pt, Ai = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, wi = /^\w*$/;
318
+ function Ei(e, t) {
319
+ if (bi(e))
320
+ return !1;
321
+ var r = typeof e;
322
+ return r == "number" || r == "symbol" || r == "boolean" || e == null || $i(e) ? !0 : wi.test(e) || !Ai.test(e) || t != null && e in Object(t);
323
+ }
324
+ var Ft = Ei;
325
+ function Ci(e) {
326
+ var t = typeof e;
327
+ return e != null && (t == "object" || t == "function");
328
+ }
329
+ var Ot = Ci, Ti = Pe, xi = Ot, Pi = "[object AsyncFunction]", Fi = "[object Function]", Oi = "[object GeneratorFunction]", Ii = "[object Proxy]";
330
+ function Ni(e) {
331
+ if (!xi(e))
332
+ return !1;
333
+ var t = Ti(e);
334
+ return t == Fi || t == Oi || t == Pi || t == Ii;
335
+ }
336
+ var en = Ni, Di = W, Ri = Di["__core-js_shared__"], Li = Ri, nt = Li, tr = function() {
337
+ var e = /[^.]+$/.exec(nt && nt.keys && nt.keys.IE_PROTO || "");
338
+ return e ? "Symbol(src)_1." + e : "";
339
+ }();
340
+ function Mi(e) {
341
+ return !!tr && tr in e;
342
+ }
343
+ var qi = Mi, Ui = Function.prototype, ji = Ui.toString;
344
+ function ki(e) {
345
+ if (e != null) {
346
+ try {
347
+ return ji.call(e);
348
+ } catch {
349
+ }
350
+ try {
351
+ return e + "";
352
+ } catch {
353
+ }
354
+ }
355
+ return "";
356
+ }
357
+ var tn = ki, Gi = en, zi = qi, Vi = Ot, Bi = tn, Ki = /[\\^$.*+?()[\]{}|]/g, Wi = /^\[object .+?Constructor\]$/, Ji = Function.prototype, Zi = Object.prototype, Yi = Ji.toString, Xi = Zi.hasOwnProperty, Qi = RegExp(
358
+ "^" + Yi.call(Xi).replace(Ki, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
359
+ );
360
+ function Hi(e) {
361
+ if (!Vi(e) || zi(e))
362
+ return !1;
363
+ var t = Gi(e) ? Qi : Wi;
364
+ return t.test(Bi(e));
365
+ }
366
+ var es = Hi;
367
+ function ts(e, t) {
368
+ return e == null ? void 0 : e[t];
369
+ }
370
+ var rs = ts, ns = es, as = rs;
371
+ function is(e, t) {
372
+ var r = as(e, t);
373
+ return ns(r) ? r : void 0;
374
+ }
375
+ var ce = is, ss = ce, os = ss(Object, "create"), Ze = os, rr = Ze;
376
+ function cs() {
377
+ this.__data__ = rr ? rr(null) : {}, this.size = 0;
378
+ }
379
+ var us = cs;
380
+ function ls(e) {
381
+ var t = this.has(e) && delete this.__data__[e];
382
+ return this.size -= t ? 1 : 0, t;
383
+ }
384
+ var ds = ls, fs = Ze, ps = "__lodash_hash_undefined__", hs = Object.prototype, ms = hs.hasOwnProperty;
385
+ function ys(e) {
386
+ var t = this.__data__;
387
+ if (fs) {
388
+ var r = t[e];
389
+ return r === ps ? void 0 : r;
390
+ }
391
+ return ms.call(t, e) ? t[e] : void 0;
392
+ }
393
+ var gs = ys, vs = Ze, _s = Object.prototype, Ss = _s.hasOwnProperty;
394
+ function bs(e) {
395
+ var t = this.__data__;
396
+ return vs ? t[e] !== void 0 : Ss.call(t, e);
397
+ }
398
+ var $s = bs, As = Ze, ws = "__lodash_hash_undefined__";
399
+ function Es(e, t) {
400
+ var r = this.__data__;
401
+ return this.size += this.has(e) ? 0 : 1, r[e] = As && t === void 0 ? ws : t, this;
402
+ }
403
+ var Cs = Es, Ts = us, xs = ds, Ps = gs, Fs = $s, Os = Cs;
404
+ function ye(e) {
405
+ var t = -1, r = e == null ? 0 : e.length;
406
+ for (this.clear(); ++t < r; ) {
407
+ var n = e[t];
408
+ this.set(n[0], n[1]);
409
+ }
410
+ }
411
+ ye.prototype.clear = Ts;
412
+ ye.prototype.delete = xs;
413
+ ye.prototype.get = Ps;
414
+ ye.prototype.has = Fs;
415
+ ye.prototype.set = Os;
416
+ var Is = ye;
417
+ function Ns() {
418
+ this.__data__ = [], this.size = 0;
419
+ }
420
+ var Ds = Ns;
421
+ function Rs(e, t) {
422
+ return e === t || e !== e && t !== t;
423
+ }
424
+ var rn = Rs, Ls = rn;
425
+ function Ms(e, t) {
426
+ for (var r = e.length; r--; )
427
+ if (Ls(e[r][0], t))
428
+ return r;
429
+ return -1;
430
+ }
431
+ var Ye = Ms, qs = Ye, Us = Array.prototype, js = Us.splice;
432
+ function ks(e) {
433
+ var t = this.__data__, r = qs(t, e);
434
+ if (r < 0)
435
+ return !1;
436
+ var n = t.length - 1;
437
+ return r == n ? t.pop() : js.call(t, r, 1), --this.size, !0;
438
+ }
439
+ var Gs = ks, zs = Ye;
440
+ function Vs(e) {
441
+ var t = this.__data__, r = zs(t, e);
442
+ return r < 0 ? void 0 : t[r][1];
443
+ }
444
+ var Bs = Vs, Ks = Ye;
445
+ function Ws(e) {
446
+ return Ks(this.__data__, e) > -1;
447
+ }
448
+ var Js = Ws, Zs = Ye;
449
+ function Ys(e, t) {
450
+ var r = this.__data__, n = Zs(r, e);
451
+ return n < 0 ? (++this.size, r.push([e, t])) : r[n][1] = t, this;
452
+ }
453
+ var Xs = Ys, Qs = Ds, Hs = Gs, eo = Bs, to = Js, ro = Xs;
454
+ function ge(e) {
455
+ var t = -1, r = e == null ? 0 : e.length;
456
+ for (this.clear(); ++t < r; ) {
457
+ var n = e[t];
458
+ this.set(n[0], n[1]);
459
+ }
460
+ }
461
+ ge.prototype.clear = Qs;
462
+ ge.prototype.delete = Hs;
463
+ ge.prototype.get = eo;
464
+ ge.prototype.has = to;
465
+ ge.prototype.set = ro;
466
+ var Xe = ge, no = ce, ao = W, io = no(ao, "Map"), It = io, nr = Is, so = Xe, oo = It;
467
+ function co() {
468
+ this.size = 0, this.__data__ = {
469
+ hash: new nr(),
470
+ map: new (oo || so)(),
471
+ string: new nr()
472
+ };
473
+ }
474
+ var uo = co;
475
+ function lo(e) {
476
+ var t = typeof e;
477
+ return t == "string" || t == "number" || t == "symbol" || t == "boolean" ? e !== "__proto__" : e === null;
478
+ }
479
+ var fo = lo, po = fo;
480
+ function ho(e, t) {
481
+ var r = e.__data__;
482
+ return po(t) ? r[typeof t == "string" ? "string" : "hash"] : r.map;
483
+ }
484
+ var Qe = ho, mo = Qe;
485
+ function yo(e) {
486
+ var t = mo(this, e).delete(e);
487
+ return this.size -= t ? 1 : 0, t;
488
+ }
489
+ var go = yo, vo = Qe;
490
+ function _o(e) {
491
+ return vo(this, e).get(e);
492
+ }
493
+ var So = _o, bo = Qe;
494
+ function $o(e) {
495
+ return bo(this, e).has(e);
496
+ }
497
+ var Ao = $o, wo = Qe;
498
+ function Eo(e, t) {
499
+ var r = wo(this, e), n = r.size;
500
+ return r.set(e, t), this.size += r.size == n ? 0 : 1, this;
501
+ }
502
+ var Co = Eo, To = uo, xo = go, Po = So, Fo = Ao, Oo = Co;
503
+ function ve(e) {
504
+ var t = -1, r = e == null ? 0 : e.length;
505
+ for (this.clear(); ++t < r; ) {
506
+ var n = e[t];
507
+ this.set(n[0], n[1]);
508
+ }
509
+ }
510
+ ve.prototype.clear = To;
511
+ ve.prototype.delete = xo;
512
+ ve.prototype.get = Po;
513
+ ve.prototype.has = Fo;
514
+ ve.prototype.set = Oo;
515
+ var Nt = ve, nn = Nt, Io = "Expected a function";
516
+ function Dt(e, t) {
517
+ if (typeof e != "function" || t != null && typeof t != "function")
518
+ throw new TypeError(Io);
519
+ var r = function() {
520
+ var n = arguments, a = t ? t.apply(this, n) : n[0], i = r.cache;
521
+ if (i.has(a))
522
+ return i.get(a);
523
+ var s = e.apply(this, n);
524
+ return r.cache = i.set(a, s) || i, s;
525
+ };
526
+ return r.cache = new (Dt.Cache || nn)(), r;
527
+ }
528
+ Dt.Cache = nn;
529
+ var No = Dt, Do = No, Ro = 500;
530
+ function Lo(e) {
531
+ var t = Do(e, function(n) {
532
+ return r.size === Ro && r.clear(), n;
533
+ }), r = t.cache;
534
+ return t;
535
+ }
536
+ var Mo = Lo, qo = Mo, Uo = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, jo = /\\(\\)?/g, ko = qo(function(e) {
537
+ var t = [];
538
+ return e.charCodeAt(0) === 46 && t.push(""), e.replace(Uo, function(r, n, a, i) {
539
+ t.push(a ? i.replace(jo, "$1") : n || r);
540
+ }), t;
541
+ }), Go = ko;
542
+ function zo(e, t) {
543
+ for (var r = -1, n = e == null ? 0 : e.length, a = Array(n); ++r < n; )
544
+ a[r] = t(e[r], r, e);
545
+ return a;
546
+ }
547
+ var Vo = zo, ar = Je, Bo = Vo, Ko = ee, Wo = Pt, Jo = 1 / 0, ir = ar ? ar.prototype : void 0, sr = ir ? ir.toString : void 0;
548
+ function an(e) {
549
+ if (typeof e == "string")
550
+ return e;
551
+ if (Ko(e))
552
+ return Bo(e, an) + "";
553
+ if (Wo(e))
554
+ return sr ? sr.call(e) : "";
555
+ var t = e + "";
556
+ return t == "0" && 1 / e == -Jo ? "-0" : t;
557
+ }
558
+ var Zo = an, Yo = Zo;
559
+ function Xo(e) {
560
+ return e == null ? "" : Yo(e);
561
+ }
562
+ var Oe = Xo, Qo = ee, Ho = Ft, ec = Go, tc = Oe;
563
+ function rc(e, t) {
564
+ return Qo(e) ? e : Ho(e, t) ? [e] : ec(tc(e));
565
+ }
566
+ var sn = rc, nc = Pe, ac = Fe, ic = "[object Arguments]";
567
+ function sc(e) {
568
+ return ac(e) && nc(e) == ic;
569
+ }
570
+ var oc = sc, or = oc, cc = Fe, on = Object.prototype, uc = on.hasOwnProperty, lc = on.propertyIsEnumerable, dc = or(function() {
571
+ return arguments;
572
+ }()) ? or : function(e) {
573
+ return cc(e) && uc.call(e, "callee") && !lc.call(e, "callee");
574
+ }, cn = dc, fc = 9007199254740991, pc = /^(?:0|[1-9]\d*)$/;
575
+ function hc(e, t) {
576
+ var r = typeof e;
577
+ return t = t ?? fc, !!t && (r == "number" || r != "symbol" && pc.test(e)) && e > -1 && e % 1 == 0 && e < t;
578
+ }
579
+ var un = hc, mc = 9007199254740991;
580
+ function yc(e) {
581
+ return typeof e == "number" && e > -1 && e % 1 == 0 && e <= mc;
582
+ }
583
+ var Rt = yc, gc = Pt, vc = 1 / 0;
584
+ function _c(e) {
585
+ if (typeof e == "string" || gc(e))
586
+ return e;
587
+ var t = e + "";
588
+ return t == "0" && 1 / e == -vc ? "-0" : t;
589
+ }
590
+ var He = _c, Sc = sn, bc = cn, $c = ee, Ac = un, wc = Rt, Ec = He;
591
+ function Cc(e, t, r) {
592
+ t = Sc(t, e);
593
+ for (var n = -1, a = t.length, i = !1; ++n < a; ) {
594
+ var s = Ec(t[n]);
595
+ if (!(i = e != null && r(e, s)))
596
+ break;
597
+ e = e[s];
598
+ }
599
+ return i || ++n != a ? i : (a = e == null ? 0 : e.length, !!a && wc(a) && Ac(s, a) && ($c(e) || bc(e)));
600
+ }
601
+ var ln = Cc, Tc = Za, xc = ln;
602
+ function Pc(e, t) {
603
+ return e != null && xc(e, t, Tc);
604
+ }
605
+ var Fc = Pc;
606
+ const Ue = /* @__PURE__ */ me(Fc), Lt = (e) => e && e.__isYupSchema__;
607
+ class Oc {
608
+ constructor(t, r) {
609
+ if (this.fn = void 0, this.refs = t, this.refs = t, typeof r == "function") {
610
+ this.fn = r;
611
+ return;
612
+ }
613
+ if (!Ue(r, "is"))
614
+ throw new TypeError("`is:` is required for `when()` conditions");
615
+ if (!r.then && !r.otherwise)
616
+ throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");
617
+ let {
618
+ is: n,
619
+ then: a,
620
+ otherwise: i
621
+ } = r, s = typeof n == "function" ? n : (...o) => o.every((c) => c === n);
622
+ this.fn = function(...o) {
623
+ let c = o.pop(), u = o.pop(), l = s(...o) ? a : i;
624
+ if (l)
625
+ return typeof l == "function" ? l(u) : u.concat(l.resolve(c));
626
+ };
627
+ }
628
+ resolve(t, r) {
629
+ let n = this.refs.map((i) => i.getValue(r == null ? void 0 : r.value, r == null ? void 0 : r.parent, r == null ? void 0 : r.context)), a = this.fn.apply(t, n.concat(t, r));
630
+ if (a === void 0 || a === t)
631
+ return t;
632
+ if (!Lt(a))
633
+ throw new TypeError("conditions must return a schema object");
634
+ return a.resolve(r);
635
+ }
636
+ }
637
+ function dn(e) {
638
+ return e == null ? [] : [].concat(e);
639
+ }
640
+ function yt() {
641
+ return yt = Object.assign || function(e) {
642
+ for (var t = 1; t < arguments.length; t++) {
643
+ var r = arguments[t];
644
+ for (var n in r)
645
+ Object.prototype.hasOwnProperty.call(r, n) && (e[n] = r[n]);
646
+ }
647
+ return e;
648
+ }, yt.apply(this, arguments);
649
+ }
650
+ let Ic = /\$\{\s*(\w+)\s*\}/g;
651
+ class D extends Error {
652
+ static formatError(t, r) {
653
+ const n = r.label || r.path || "this";
654
+ return n !== r.path && (r = yt({}, r, {
655
+ path: n
656
+ })), typeof t == "string" ? t.replace(Ic, (a, i) => pe(r[i])) : typeof t == "function" ? t(r) : t;
657
+ }
658
+ static isError(t) {
659
+ return t && t.name === "ValidationError";
660
+ }
661
+ constructor(t, r, n, a) {
662
+ super(), this.value = void 0, this.path = void 0, this.type = void 0, this.errors = void 0, this.params = void 0, this.inner = void 0, this.name = "ValidationError", this.value = r, this.path = n, this.type = a, this.errors = [], this.inner = [], dn(t).forEach((i) => {
663
+ D.isError(i) ? (this.errors.push(...i.errors), this.inner = this.inner.concat(i.inner.length ? i.inner : i)) : this.errors.push(i);
664
+ }), this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0], Error.captureStackTrace && Error.captureStackTrace(this, D);
665
+ }
666
+ }
667
+ const Nc = (e) => {
668
+ let t = !1;
669
+ return (...r) => {
670
+ t || (t = !0, e(...r));
671
+ };
672
+ };
673
+ function je(e, t) {
674
+ let {
675
+ endEarly: r,
676
+ tests: n,
677
+ args: a,
678
+ value: i,
679
+ errors: s,
680
+ sort: o,
681
+ path: c
682
+ } = e, u = Nc(t), l = n.length;
683
+ const d = [];
684
+ if (s = s || [], !l)
685
+ return s.length ? u(new D(s, i, c)) : u(null, i);
686
+ for (let f = 0; f < n.length; f++) {
687
+ const p = n[f];
688
+ p(a, function(v) {
689
+ if (v) {
690
+ if (!D.isError(v))
691
+ return u(v, i);
692
+ if (r)
693
+ return v.value = i, u(v, i);
694
+ d.push(v);
695
+ }
696
+ if (--l <= 0) {
697
+ if (d.length && (o && d.sort(o), s.length && d.push(...s), s = d), s.length) {
698
+ u(new D(s, i, c), i);
699
+ return;
700
+ }
701
+ u(null, i);
702
+ }
703
+ });
704
+ }
705
+ }
706
+ var Dc = ce, Rc = function() {
707
+ try {
708
+ var e = Dc(Object, "defineProperty");
709
+ return e({}, "", {}), e;
710
+ } catch {
711
+ }
712
+ }(), Lc = Rc, cr = Lc;
713
+ function Mc(e, t, r) {
714
+ t == "__proto__" && cr ? cr(e, t, {
715
+ configurable: !0,
716
+ enumerable: !0,
717
+ value: r,
718
+ writable: !0
719
+ }) : e[t] = r;
720
+ }
721
+ var fn = Mc;
722
+ function qc(e) {
723
+ return function(t, r, n) {
724
+ for (var a = -1, i = Object(t), s = n(t), o = s.length; o--; ) {
725
+ var c = s[e ? o : ++a];
726
+ if (r(i[c], c, i) === !1)
727
+ break;
728
+ }
729
+ return t;
730
+ };
731
+ }
732
+ var Uc = qc, jc = Uc, kc = jc(), Gc = kc;
733
+ function zc(e, t) {
734
+ for (var r = -1, n = Array(e); ++r < e; )
735
+ n[r] = t(r);
736
+ return n;
737
+ }
738
+ var Vc = zc, ke = { exports: {} };
739
+ function Bc() {
740
+ return !1;
741
+ }
742
+ var Kc = Bc;
743
+ ke.exports;
744
+ (function(e, t) {
745
+ var r = W, n = Kc, a = t && !t.nodeType && t, i = a && !0 && e && !e.nodeType && e, s = i && i.exports === a, o = s ? r.Buffer : void 0, c = o ? o.isBuffer : void 0, u = c || n;
746
+ e.exports = u;
747
+ })(ke, ke.exports);
748
+ var pn = ke.exports, Wc = Pe, Jc = Rt, Zc = Fe, Yc = "[object Arguments]", Xc = "[object Array]", Qc = "[object Boolean]", Hc = "[object Date]", eu = "[object Error]", tu = "[object Function]", ru = "[object Map]", nu = "[object Number]", au = "[object Object]", iu = "[object RegExp]", su = "[object Set]", ou = "[object String]", cu = "[object WeakMap]", uu = "[object ArrayBuffer]", lu = "[object DataView]", du = "[object Float32Array]", fu = "[object Float64Array]", pu = "[object Int8Array]", hu = "[object Int16Array]", mu = "[object Int32Array]", yu = "[object Uint8Array]", gu = "[object Uint8ClampedArray]", vu = "[object Uint16Array]", _u = "[object Uint32Array]", A = {};
749
+ A[du] = A[fu] = A[pu] = A[hu] = A[mu] = A[yu] = A[gu] = A[vu] = A[_u] = !0;
750
+ A[Yc] = A[Xc] = A[uu] = A[Qc] = A[lu] = A[Hc] = A[eu] = A[tu] = A[ru] = A[nu] = A[au] = A[iu] = A[su] = A[ou] = A[cu] = !1;
751
+ function Su(e) {
752
+ return Zc(e) && Jc(e.length) && !!A[Wc(e)];
753
+ }
754
+ var bu = Su;
755
+ function $u(e) {
756
+ return function(t) {
757
+ return e(t);
758
+ };
759
+ }
760
+ var Au = $u, Ge = { exports: {} };
761
+ Ge.exports;
762
+ (function(e, t) {
763
+ var r = Qr, n = t && !t.nodeType && t, a = n && !0 && e && !e.nodeType && e, i = a && a.exports === n, s = i && r.process, o = function() {
764
+ try {
765
+ var c = a && a.require && a.require("util").types;
766
+ return c || s && s.binding && s.binding("util");
767
+ } catch {
768
+ }
769
+ }();
770
+ e.exports = o;
771
+ })(Ge, Ge.exports);
772
+ var wu = Ge.exports, Eu = bu, Cu = Au, ur = wu, lr = ur && ur.isTypedArray, Tu = lr ? Cu(lr) : Eu, hn = Tu, xu = Vc, Pu = cn, Fu = ee, Ou = pn, Iu = un, Nu = hn, Du = Object.prototype, Ru = Du.hasOwnProperty;
773
+ function Lu(e, t) {
774
+ var r = Fu(e), n = !r && Pu(e), a = !r && !n && Ou(e), i = !r && !n && !a && Nu(e), s = r || n || a || i, o = s ? xu(e.length, String) : [], c = o.length;
775
+ for (var u in e)
776
+ (t || Ru.call(e, u)) && !(s && // Safari 9 has enumerable `arguments.length` in strict mode.
777
+ (u == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
778
+ a && (u == "offset" || u == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
779
+ i && (u == "buffer" || u == "byteLength" || u == "byteOffset") || // Skip index properties.
780
+ Iu(u, c))) && o.push(u);
781
+ return o;
782
+ }
783
+ var Mu = Lu, qu = Object.prototype;
784
+ function Uu(e) {
785
+ var t = e && e.constructor, r = typeof t == "function" && t.prototype || qu;
786
+ return e === r;
787
+ }
788
+ var ju = Uu;
789
+ function ku(e, t) {
790
+ return function(r) {
791
+ return e(t(r));
792
+ };
793
+ }
794
+ var Gu = ku, zu = Gu, Vu = zu(Object.keys, Object), Bu = Vu, Ku = ju, Wu = Bu, Ju = Object.prototype, Zu = Ju.hasOwnProperty;
795
+ function Yu(e) {
796
+ if (!Ku(e))
797
+ return Wu(e);
798
+ var t = [];
799
+ for (var r in Object(e))
800
+ Zu.call(e, r) && r != "constructor" && t.push(r);
801
+ return t;
802
+ }
803
+ var Xu = Yu, Qu = en, Hu = Rt;
804
+ function el(e) {
805
+ return e != null && Hu(e.length) && !Qu(e);
806
+ }
807
+ var tl = el, rl = Mu, nl = Xu, al = tl;
808
+ function il(e) {
809
+ return al(e) ? rl(e) : nl(e);
810
+ }
811
+ var Mt = il, sl = Gc, ol = Mt;
812
+ function cl(e, t) {
813
+ return e && sl(e, t, ol);
814
+ }
815
+ var mn = cl, ul = Xe;
816
+ function ll() {
817
+ this.__data__ = new ul(), this.size = 0;
818
+ }
819
+ var dl = ll;
820
+ function fl(e) {
821
+ var t = this.__data__, r = t.delete(e);
822
+ return this.size = t.size, r;
823
+ }
824
+ var pl = fl;
825
+ function hl(e) {
826
+ return this.__data__.get(e);
827
+ }
828
+ var ml = hl;
829
+ function yl(e) {
830
+ return this.__data__.has(e);
831
+ }
832
+ var gl = yl, vl = Xe, _l = It, Sl = Nt, bl = 200;
833
+ function $l(e, t) {
834
+ var r = this.__data__;
835
+ if (r instanceof vl) {
836
+ var n = r.__data__;
837
+ if (!_l || n.length < bl - 1)
838
+ return n.push([e, t]), this.size = ++r.size, this;
839
+ r = this.__data__ = new Sl(n);
840
+ }
841
+ return r.set(e, t), this.size = r.size, this;
842
+ }
843
+ var Al = $l, wl = Xe, El = dl, Cl = pl, Tl = ml, xl = gl, Pl = Al;
844
+ function _e(e) {
845
+ var t = this.__data__ = new wl(e);
846
+ this.size = t.size;
847
+ }
848
+ _e.prototype.clear = El;
849
+ _e.prototype.delete = Cl;
850
+ _e.prototype.get = Tl;
851
+ _e.prototype.has = xl;
852
+ _e.prototype.set = Pl;
853
+ var yn = _e, Fl = "__lodash_hash_undefined__";
854
+ function Ol(e) {
855
+ return this.__data__.set(e, Fl), this;
856
+ }
857
+ var Il = Ol;
858
+ function Nl(e) {
859
+ return this.__data__.has(e);
860
+ }
861
+ var Dl = Nl, Rl = Nt, Ll = Il, Ml = Dl;
862
+ function ze(e) {
863
+ var t = -1, r = e == null ? 0 : e.length;
864
+ for (this.__data__ = new Rl(); ++t < r; )
865
+ this.add(e[t]);
866
+ }
867
+ ze.prototype.add = ze.prototype.push = Ll;
868
+ ze.prototype.has = Ml;
869
+ var ql = ze;
870
+ function Ul(e, t) {
871
+ for (var r = -1, n = e == null ? 0 : e.length; ++r < n; )
872
+ if (t(e[r], r, e))
873
+ return !0;
874
+ return !1;
875
+ }
876
+ var jl = Ul;
877
+ function kl(e, t) {
878
+ return e.has(t);
879
+ }
880
+ var Gl = kl, zl = ql, Vl = jl, Bl = Gl, Kl = 1, Wl = 2;
881
+ function Jl(e, t, r, n, a, i) {
882
+ var s = r & Kl, o = e.length, c = t.length;
883
+ if (o != c && !(s && c > o))
884
+ return !1;
885
+ var u = i.get(e), l = i.get(t);
886
+ if (u && l)
887
+ return u == t && l == e;
888
+ var d = -1, f = !0, p = r & Wl ? new zl() : void 0;
889
+ for (i.set(e, t), i.set(t, e); ++d < o; ) {
890
+ var m = e[d], v = t[d];
891
+ if (n)
892
+ var g = s ? n(v, m, d, t, e, i) : n(m, v, d, e, t, i);
893
+ if (g !== void 0) {
894
+ if (g)
895
+ continue;
896
+ f = !1;
897
+ break;
898
+ }
899
+ if (p) {
900
+ if (!Vl(t, function(S, b) {
901
+ if (!Bl(p, b) && (m === S || a(m, S, r, n, i)))
902
+ return p.push(b);
903
+ })) {
904
+ f = !1;
905
+ break;
906
+ }
907
+ } else if (!(m === v || a(m, v, r, n, i))) {
908
+ f = !1;
909
+ break;
910
+ }
911
+ }
912
+ return i.delete(e), i.delete(t), f;
913
+ }
914
+ var gn = Jl, Zl = W, Yl = Zl.Uint8Array, Xl = Yl;
915
+ function Ql(e) {
916
+ var t = -1, r = Array(e.size);
917
+ return e.forEach(function(n, a) {
918
+ r[++t] = [a, n];
919
+ }), r;
920
+ }
921
+ var Hl = Ql;
922
+ function ed(e) {
923
+ var t = -1, r = Array(e.size);
924
+ return e.forEach(function(n) {
925
+ r[++t] = n;
926
+ }), r;
927
+ }
928
+ var td = ed, dr = Je, fr = Xl, rd = rn, nd = gn, ad = Hl, id = td, sd = 1, od = 2, cd = "[object Boolean]", ud = "[object Date]", ld = "[object Error]", dd = "[object Map]", fd = "[object Number]", pd = "[object RegExp]", hd = "[object Set]", md = "[object String]", yd = "[object Symbol]", gd = "[object ArrayBuffer]", vd = "[object DataView]", pr = dr ? dr.prototype : void 0, at = pr ? pr.valueOf : void 0;
929
+ function _d(e, t, r, n, a, i, s) {
930
+ switch (r) {
931
+ case vd:
932
+ if (e.byteLength != t.byteLength || e.byteOffset != t.byteOffset)
933
+ return !1;
934
+ e = e.buffer, t = t.buffer;
935
+ case gd:
936
+ return !(e.byteLength != t.byteLength || !i(new fr(e), new fr(t)));
937
+ case cd:
938
+ case ud:
939
+ case fd:
940
+ return rd(+e, +t);
941
+ case ld:
942
+ return e.name == t.name && e.message == t.message;
943
+ case pd:
944
+ case md:
945
+ return e == t + "";
946
+ case dd:
947
+ var o = ad;
948
+ case hd:
949
+ var c = n & sd;
950
+ if (o || (o = id), e.size != t.size && !c)
951
+ return !1;
952
+ var u = s.get(e);
953
+ if (u)
954
+ return u == t;
955
+ n |= od, s.set(e, t);
956
+ var l = nd(o(e), o(t), n, a, i, s);
957
+ return s.delete(e), l;
958
+ case yd:
959
+ if (at)
960
+ return at.call(e) == at.call(t);
961
+ }
962
+ return !1;
963
+ }
964
+ var Sd = _d;
965
+ function bd(e, t) {
966
+ for (var r = -1, n = t.length, a = e.length; ++r < n; )
967
+ e[a + r] = t[r];
968
+ return e;
969
+ }
970
+ var $d = bd, Ad = $d, wd = ee;
971
+ function Ed(e, t, r) {
972
+ var n = t(e);
973
+ return wd(e) ? n : Ad(n, r(e));
974
+ }
975
+ var Cd = Ed;
976
+ function Td(e, t) {
977
+ for (var r = -1, n = e == null ? 0 : e.length, a = 0, i = []; ++r < n; ) {
978
+ var s = e[r];
979
+ t(s, r, e) && (i[a++] = s);
980
+ }
981
+ return i;
982
+ }
983
+ var xd = Td;
984
+ function Pd() {
985
+ return [];
986
+ }
987
+ var Fd = Pd, Od = xd, Id = Fd, Nd = Object.prototype, Dd = Nd.propertyIsEnumerable, hr = Object.getOwnPropertySymbols, Rd = hr ? function(e) {
988
+ return e == null ? [] : (e = Object(e), Od(hr(e), function(t) {
989
+ return Dd.call(e, t);
990
+ }));
991
+ } : Id, Ld = Rd, Md = Cd, qd = Ld, Ud = Mt;
992
+ function jd(e) {
993
+ return Md(e, Ud, qd);
994
+ }
995
+ var kd = jd, mr = kd, Gd = 1, zd = Object.prototype, Vd = zd.hasOwnProperty;
996
+ function Bd(e, t, r, n, a, i) {
997
+ var s = r & Gd, o = mr(e), c = o.length, u = mr(t), l = u.length;
998
+ if (c != l && !s)
999
+ return !1;
1000
+ for (var d = c; d--; ) {
1001
+ var f = o[d];
1002
+ if (!(s ? f in t : Vd.call(t, f)))
1003
+ return !1;
1004
+ }
1005
+ var p = i.get(e), m = i.get(t);
1006
+ if (p && m)
1007
+ return p == t && m == e;
1008
+ var v = !0;
1009
+ i.set(e, t), i.set(t, e);
1010
+ for (var g = s; ++d < c; ) {
1011
+ f = o[d];
1012
+ var S = e[f], b = t[f];
1013
+ if (n)
1014
+ var C = s ? n(b, S, f, t, e, i) : n(S, b, f, e, t, i);
1015
+ if (!(C === void 0 ? S === b || a(S, b, r, n, i) : C)) {
1016
+ v = !1;
1017
+ break;
1018
+ }
1019
+ g || (g = f == "constructor");
1020
+ }
1021
+ if (v && !g) {
1022
+ var x = e.constructor, $ = t.constructor;
1023
+ x != $ && "constructor" in e && "constructor" in t && !(typeof x == "function" && x instanceof x && typeof $ == "function" && $ instanceof $) && (v = !1);
1024
+ }
1025
+ return i.delete(e), i.delete(t), v;
1026
+ }
1027
+ var Kd = Bd, Wd = ce, Jd = W, Zd = Wd(Jd, "DataView"), Yd = Zd, Xd = ce, Qd = W, Hd = Xd(Qd, "Promise"), ef = Hd, tf = ce, rf = W, nf = tf(rf, "Set"), af = nf, sf = ce, of = W, cf = sf(of, "WeakMap"), uf = cf, gt = Yd, vt = It, _t = ef, St = af, bt = uf, vn = Pe, Se = tn, yr = "[object Map]", lf = "[object Object]", gr = "[object Promise]", vr = "[object Set]", _r = "[object WeakMap]", Sr = "[object DataView]", df = Se(gt), ff = Se(vt), pf = Se(_t), hf = Se(St), mf = Se(bt), se = vn;
1028
+ (gt && se(new gt(new ArrayBuffer(1))) != Sr || vt && se(new vt()) != yr || _t && se(_t.resolve()) != gr || St && se(new St()) != vr || bt && se(new bt()) != _r) && (se = function(e) {
1029
+ var t = vn(e), r = t == lf ? e.constructor : void 0, n = r ? Se(r) : "";
1030
+ if (n)
1031
+ switch (n) {
1032
+ case df:
1033
+ return Sr;
1034
+ case ff:
1035
+ return yr;
1036
+ case pf:
1037
+ return gr;
1038
+ case hf:
1039
+ return vr;
1040
+ case mf:
1041
+ return _r;
1042
+ }
1043
+ return t;
1044
+ });
1045
+ var yf = se, it = yn, gf = gn, vf = Sd, _f = Kd, br = yf, $r = ee, Ar = pn, Sf = hn, bf = 1, wr = "[object Arguments]", Er = "[object Array]", Ne = "[object Object]", $f = Object.prototype, Cr = $f.hasOwnProperty;
1046
+ function Af(e, t, r, n, a, i) {
1047
+ var s = $r(e), o = $r(t), c = s ? Er : br(e), u = o ? Er : br(t);
1048
+ c = c == wr ? Ne : c, u = u == wr ? Ne : u;
1049
+ var l = c == Ne, d = u == Ne, f = c == u;
1050
+ if (f && Ar(e)) {
1051
+ if (!Ar(t))
1052
+ return !1;
1053
+ s = !0, l = !1;
1054
+ }
1055
+ if (f && !l)
1056
+ return i || (i = new it()), s || Sf(e) ? gf(e, t, r, n, a, i) : vf(e, t, c, r, n, a, i);
1057
+ if (!(r & bf)) {
1058
+ var p = l && Cr.call(e, "__wrapped__"), m = d && Cr.call(t, "__wrapped__");
1059
+ if (p || m) {
1060
+ var v = p ? e.value() : e, g = m ? t.value() : t;
1061
+ return i || (i = new it()), a(v, g, r, n, i);
1062
+ }
1063
+ }
1064
+ return f ? (i || (i = new it()), _f(e, t, r, n, a, i)) : !1;
1065
+ }
1066
+ var wf = Af, Ef = wf, Tr = Fe;
1067
+ function _n(e, t, r, n, a) {
1068
+ return e === t ? !0 : e == null || t == null || !Tr(e) && !Tr(t) ? e !== e && t !== t : Ef(e, t, r, n, _n, a);
1069
+ }
1070
+ var Sn = _n, Cf = yn, Tf = Sn, xf = 1, Pf = 2;
1071
+ function Ff(e, t, r, n) {
1072
+ var a = r.length, i = a, s = !n;
1073
+ if (e == null)
1074
+ return !i;
1075
+ for (e = Object(e); a--; ) {
1076
+ var o = r[a];
1077
+ if (s && o[2] ? o[1] !== e[o[0]] : !(o[0] in e))
1078
+ return !1;
1079
+ }
1080
+ for (; ++a < i; ) {
1081
+ o = r[a];
1082
+ var c = o[0], u = e[c], l = o[1];
1083
+ if (s && o[2]) {
1084
+ if (u === void 0 && !(c in e))
1085
+ return !1;
1086
+ } else {
1087
+ var d = new Cf();
1088
+ if (n)
1089
+ var f = n(u, l, c, e, t, d);
1090
+ if (!(f === void 0 ? Tf(l, u, xf | Pf, n, d) : f))
1091
+ return !1;
1092
+ }
1093
+ }
1094
+ return !0;
1095
+ }
1096
+ var Of = Ff, If = Ot;
1097
+ function Nf(e) {
1098
+ return e === e && !If(e);
1099
+ }
1100
+ var bn = Nf, Df = bn, Rf = Mt;
1101
+ function Lf(e) {
1102
+ for (var t = Rf(e), r = t.length; r--; ) {
1103
+ var n = t[r], a = e[n];
1104
+ t[r] = [n, a, Df(a)];
1105
+ }
1106
+ return t;
1107
+ }
1108
+ var Mf = Lf;
1109
+ function qf(e, t) {
1110
+ return function(r) {
1111
+ return r == null ? !1 : r[e] === t && (t !== void 0 || e in Object(r));
1112
+ };
1113
+ }
1114
+ var $n = qf, Uf = Of, jf = Mf, kf = $n;
1115
+ function Gf(e) {
1116
+ var t = jf(e);
1117
+ return t.length == 1 && t[0][2] ? kf(t[0][0], t[0][1]) : function(r) {
1118
+ return r === e || Uf(r, e, t);
1119
+ };
1120
+ }
1121
+ var zf = Gf, Vf = sn, Bf = He;
1122
+ function Kf(e, t) {
1123
+ t = Vf(t, e);
1124
+ for (var r = 0, n = t.length; e != null && r < n; )
1125
+ e = e[Bf(t[r++])];
1126
+ return r && r == n ? e : void 0;
1127
+ }
1128
+ var An = Kf, Wf = An;
1129
+ function Jf(e, t, r) {
1130
+ var n = e == null ? void 0 : Wf(e, t);
1131
+ return n === void 0 ? r : n;
1132
+ }
1133
+ var Zf = Jf;
1134
+ function Yf(e, t) {
1135
+ return e != null && t in Object(e);
1136
+ }
1137
+ var Xf = Yf, Qf = Xf, Hf = ln;
1138
+ function ep(e, t) {
1139
+ return e != null && Hf(e, t, Qf);
1140
+ }
1141
+ var tp = ep, rp = Sn, np = Zf, ap = tp, ip = Ft, sp = bn, op = $n, cp = He, up = 1, lp = 2;
1142
+ function dp(e, t) {
1143
+ return ip(e) && sp(t) ? op(cp(e), t) : function(r) {
1144
+ var n = np(r, e);
1145
+ return n === void 0 && n === t ? ap(r, e) : rp(t, n, up | lp);
1146
+ };
1147
+ }
1148
+ var fp = dp;
1149
+ function pp(e) {
1150
+ return e;
1151
+ }
1152
+ var hp = pp;
1153
+ function mp(e) {
1154
+ return function(t) {
1155
+ return t == null ? void 0 : t[e];
1156
+ };
1157
+ }
1158
+ var yp = mp, gp = An;
1159
+ function vp(e) {
1160
+ return function(t) {
1161
+ return gp(t, e);
1162
+ };
1163
+ }
1164
+ var _p = vp, Sp = yp, bp = _p, $p = Ft, Ap = He;
1165
+ function wp(e) {
1166
+ return $p(e) ? Sp(Ap(e)) : bp(e);
1167
+ }
1168
+ var Ep = wp, Cp = zf, Tp = fp, xp = hp, Pp = ee, Fp = Ep;
1169
+ function Op(e) {
1170
+ return typeof e == "function" ? e : e == null ? xp : typeof e == "object" ? Pp(e) ? Tp(e[0], e[1]) : Cp(e) : Fp(e);
1171
+ }
1172
+ var wn = Op, Ip = fn, Np = mn, Dp = wn;
1173
+ function Rp(e, t) {
1174
+ var r = {};
1175
+ return t = Dp(t), Np(e, function(n, a, i) {
1176
+ Ip(r, a, t(n, a, i));
1177
+ }), r;
1178
+ }
1179
+ var Lp = Rp;
1180
+ const En = /* @__PURE__ */ me(Lp);
1181
+ function ue(e) {
1182
+ this._maxSize = e, this.clear();
1183
+ }
1184
+ ue.prototype.clear = function() {
1185
+ this._size = 0, this._values = /* @__PURE__ */ Object.create(null);
1186
+ };
1187
+ ue.prototype.get = function(e) {
1188
+ return this._values[e];
1189
+ };
1190
+ ue.prototype.set = function(e, t) {
1191
+ return this._size >= this._maxSize && this.clear(), e in this._values || this._size++, this._values[e] = t;
1192
+ };
1193
+ var Mp = /[^.^\]^[]+|(?=\[\]|\.\.)/g, Cn = /^\d+$/, qp = /^\d/, Up = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g, jp = /^\s*(['"]?)(.*?)(\1)\s*$/, qt = 512, xr = new ue(qt), Pr = new ue(qt), Fr = new ue(qt), et = {
1194
+ Cache: ue,
1195
+ split: $t,
1196
+ normalizePath: st,
1197
+ setter: function(e) {
1198
+ var t = st(e);
1199
+ return Pr.get(e) || Pr.set(e, function(n, a) {
1200
+ for (var i = 0, s = t.length, o = n; i < s - 1; ) {
1201
+ var c = t[i];
1202
+ if (c === "__proto__" || c === "constructor" || c === "prototype")
1203
+ return n;
1204
+ o = o[t[i++]];
1205
+ }
1206
+ o[t[i]] = a;
1207
+ });
1208
+ },
1209
+ getter: function(e, t) {
1210
+ var r = st(e);
1211
+ return Fr.get(e) || Fr.set(e, function(a) {
1212
+ for (var i = 0, s = r.length; i < s; )
1213
+ if (a != null || !t)
1214
+ a = a[r[i++]];
1215
+ else
1216
+ return;
1217
+ return a;
1218
+ });
1219
+ },
1220
+ join: function(e) {
1221
+ return e.reduce(function(t, r) {
1222
+ return t + (Ut(r) || Cn.test(r) ? "[" + r + "]" : (t ? "." : "") + r);
1223
+ }, "");
1224
+ },
1225
+ forEach: function(e, t, r) {
1226
+ kp(Array.isArray(e) ? e : $t(e), t, r);
1227
+ }
1228
+ };
1229
+ function st(e) {
1230
+ return xr.get(e) || xr.set(
1231
+ e,
1232
+ $t(e).map(function(t) {
1233
+ return t.replace(jp, "$2");
1234
+ })
1235
+ );
1236
+ }
1237
+ function $t(e) {
1238
+ return e.match(Mp) || [""];
1239
+ }
1240
+ function kp(e, t, r) {
1241
+ var n = e.length, a, i, s, o;
1242
+ for (i = 0; i < n; i++)
1243
+ a = e[i], a && (Vp(a) && (a = '"' + a + '"'), o = Ut(a), s = !o && /^\d+$/.test(a), t.call(r, a, o, s, i, e));
1244
+ }
1245
+ function Ut(e) {
1246
+ return typeof e == "string" && e && ["'", '"'].indexOf(e.charAt(0)) !== -1;
1247
+ }
1248
+ function Gp(e) {
1249
+ return e.match(qp) && !e.match(Cn);
1250
+ }
1251
+ function zp(e) {
1252
+ return Up.test(e);
1253
+ }
1254
+ function Vp(e) {
1255
+ return !Ut(e) && (Gp(e) || zp(e));
1256
+ }
1257
+ const De = {
1258
+ context: "$",
1259
+ value: "."
1260
+ };
1261
+ class Q {
1262
+ constructor(t, r = {}) {
1263
+ if (this.key = void 0, this.isContext = void 0, this.isValue = void 0, this.isSibling = void 0, this.path = void 0, this.getter = void 0, this.map = void 0, typeof t != "string")
1264
+ throw new TypeError("ref must be a string, got: " + t);
1265
+ if (this.key = t.trim(), t === "")
1266
+ throw new TypeError("ref must be a non-empty string");
1267
+ this.isContext = this.key[0] === De.context, this.isValue = this.key[0] === De.value, this.isSibling = !this.isContext && !this.isValue;
1268
+ let n = this.isContext ? De.context : this.isValue ? De.value : "";
1269
+ this.path = this.key.slice(n.length), this.getter = this.path && et.getter(this.path, !0), this.map = r.map;
1270
+ }
1271
+ getValue(t, r, n) {
1272
+ let a = this.isContext ? n : this.isValue ? t : r;
1273
+ return this.getter && (a = this.getter(a || {})), this.map && (a = this.map(a)), a;
1274
+ }
1275
+ /**
1276
+ *
1277
+ * @param {*} value
1278
+ * @param {Object} options
1279
+ * @param {Object=} options.context
1280
+ * @param {Object=} options.parent
1281
+ */
1282
+ cast(t, r) {
1283
+ return this.getValue(t, r == null ? void 0 : r.parent, r == null ? void 0 : r.context);
1284
+ }
1285
+ resolve() {
1286
+ return this;
1287
+ }
1288
+ describe() {
1289
+ return {
1290
+ type: "ref",
1291
+ key: this.key
1292
+ };
1293
+ }
1294
+ toString() {
1295
+ return `Ref(${this.key})`;
1296
+ }
1297
+ static isRef(t) {
1298
+ return t && t.__isYupRef;
1299
+ }
1300
+ }
1301
+ Q.prototype.__isYupRef = !0;
1302
+ function Ve() {
1303
+ return Ve = Object.assign || function(e) {
1304
+ for (var t = 1; t < arguments.length; t++) {
1305
+ var r = arguments[t];
1306
+ for (var n in r)
1307
+ Object.prototype.hasOwnProperty.call(r, n) && (e[n] = r[n]);
1308
+ }
1309
+ return e;
1310
+ }, Ve.apply(this, arguments);
1311
+ }
1312
+ function Bp(e, t) {
1313
+ if (e == null)
1314
+ return {};
1315
+ var r = {}, n = Object.keys(e), a, i;
1316
+ for (i = 0; i < n.length; i++)
1317
+ a = n[i], !(t.indexOf(a) >= 0) && (r[a] = e[a]);
1318
+ return r;
1319
+ }
1320
+ function Re(e) {
1321
+ function t(r, n) {
1322
+ let {
1323
+ value: a,
1324
+ path: i = "",
1325
+ label: s,
1326
+ options: o,
1327
+ originalValue: c,
1328
+ sync: u
1329
+ } = r, l = Bp(r, ["value", "path", "label", "options", "originalValue", "sync"]);
1330
+ const {
1331
+ name: d,
1332
+ test: f,
1333
+ params: p,
1334
+ message: m
1335
+ } = e;
1336
+ let {
1337
+ parent: v,
1338
+ context: g
1339
+ } = o;
1340
+ function S(_) {
1341
+ return Q.isRef(_) ? _.getValue(a, v, g) : _;
1342
+ }
1343
+ function b(_ = {}) {
1344
+ const N = En(Ve({
1345
+ value: a,
1346
+ originalValue: c,
1347
+ label: s,
1348
+ path: _.path || i
1349
+ }, p, _.params), S), R = new D(D.formatError(_.message || m, N), a, N.path, _.type || d);
1350
+ return R.params = N, R;
1351
+ }
1352
+ let C = Ve({
1353
+ path: i,
1354
+ parent: v,
1355
+ type: d,
1356
+ createError: b,
1357
+ resolve: S,
1358
+ options: o,
1359
+ originalValue: c
1360
+ }, l);
1361
+ if (!u) {
1362
+ try {
1363
+ Promise.resolve(f.call(C, a, C)).then((_) => {
1364
+ D.isError(_) ? n(_) : _ ? n(null, _) : n(b());
1365
+ }).catch(n);
1366
+ } catch (_) {
1367
+ n(_);
1368
+ }
1369
+ return;
1370
+ }
1371
+ let x;
1372
+ try {
1373
+ var $;
1374
+ if (x = f.call(C, a, C), typeof (($ = x) == null ? void 0 : $.then) == "function")
1375
+ throw new Error(`Validation test of type: "${C.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);
1376
+ } catch (_) {
1377
+ n(_);
1378
+ return;
1379
+ }
1380
+ D.isError(x) ? n(x) : x ? n(null, x) : n(b());
1381
+ }
1382
+ return t.OPTIONS = e, t;
1383
+ }
1384
+ let Kp = (e) => e.substr(0, e.length - 1).substr(1);
1385
+ function Wp(e, t, r, n = r) {
1386
+ let a, i, s;
1387
+ return t ? (et.forEach(t, (o, c, u) => {
1388
+ let l = c ? Kp(o) : o;
1389
+ if (e = e.resolve({
1390
+ context: n,
1391
+ parent: a,
1392
+ value: r
1393
+ }), e.innerType) {
1394
+ let d = u ? parseInt(l, 10) : 0;
1395
+ if (r && d >= r.length)
1396
+ throw new Error(`Yup.reach cannot resolve an array item at index: ${o}, in the path: ${t}. because there is no value at that index. `);
1397
+ a = r, r = r && r[d], e = e.innerType;
1398
+ }
1399
+ if (!u) {
1400
+ if (!e.fields || !e.fields[l])
1401
+ throw new Error(`The schema does not contain the path: ${t}. (failed at: ${s} which is a type: "${e._type}")`);
1402
+ a = r, r = r && r[l], e = e.fields[l];
1403
+ }
1404
+ i = l, s = c ? "[" + o + "]" : "." + o;
1405
+ }), {
1406
+ schema: e,
1407
+ parent: a,
1408
+ parentPath: i
1409
+ }) : {
1410
+ parent: a,
1411
+ parentPath: t,
1412
+ schema: e
1413
+ };
1414
+ }
1415
+ class Be {
1416
+ constructor() {
1417
+ this.list = void 0, this.refs = void 0, this.list = /* @__PURE__ */ new Set(), this.refs = /* @__PURE__ */ new Map();
1418
+ }
1419
+ get size() {
1420
+ return this.list.size + this.refs.size;
1421
+ }
1422
+ describe() {
1423
+ const t = [];
1424
+ for (const r of this.list)
1425
+ t.push(r);
1426
+ for (const [, r] of this.refs)
1427
+ t.push(r.describe());
1428
+ return t;
1429
+ }
1430
+ toArray() {
1431
+ return Array.from(this.list).concat(Array.from(this.refs.values()));
1432
+ }
1433
+ resolveAll(t) {
1434
+ return this.toArray().reduce((r, n) => r.concat(Q.isRef(n) ? t(n) : n), []);
1435
+ }
1436
+ add(t) {
1437
+ Q.isRef(t) ? this.refs.set(t.key, t) : this.list.add(t);
1438
+ }
1439
+ delete(t) {
1440
+ Q.isRef(t) ? this.refs.delete(t.key) : this.list.delete(t);
1441
+ }
1442
+ clone() {
1443
+ const t = new Be();
1444
+ return t.list = new Set(this.list), t.refs = new Map(this.refs), t;
1445
+ }
1446
+ merge(t, r) {
1447
+ const n = this.clone();
1448
+ return t.list.forEach((a) => n.add(a)), t.refs.forEach((a) => n.add(a)), r.list.forEach((a) => n.delete(a)), r.refs.forEach((a) => n.delete(a)), n;
1449
+ }
1450
+ }
1451
+ function q() {
1452
+ return q = Object.assign || function(e) {
1453
+ for (var t = 1; t < arguments.length; t++) {
1454
+ var r = arguments[t];
1455
+ for (var n in r)
1456
+ Object.prototype.hasOwnProperty.call(r, n) && (e[n] = r[n]);
1457
+ }
1458
+ return e;
1459
+ }, q.apply(this, arguments);
1460
+ }
1461
+ class I {
1462
+ constructor(t) {
1463
+ this.deps = [], this.tests = void 0, this.transforms = void 0, this.conditions = [], this._mutate = void 0, this._typeError = void 0, this._whitelist = new Be(), this._blacklist = new Be(), this.exclusiveTests = /* @__PURE__ */ Object.create(null), this.spec = void 0, this.tests = [], this.transforms = [], this.withMutation(() => {
1464
+ this.typeError(ie.notType);
1465
+ }), this.type = (t == null ? void 0 : t.type) || "mixed", this.spec = q({
1466
+ strip: !1,
1467
+ strict: !1,
1468
+ abortEarly: !0,
1469
+ recursive: !0,
1470
+ nullable: !1,
1471
+ presence: "optional"
1472
+ }, t == null ? void 0 : t.spec);
1473
+ }
1474
+ // TODO: remove
1475
+ get _type() {
1476
+ return this.type;
1477
+ }
1478
+ _typeCheck(t) {
1479
+ return !0;
1480
+ }
1481
+ clone(t) {
1482
+ if (this._mutate)
1483
+ return t && Object.assign(this.spec, t), this;
1484
+ const r = Object.create(Object.getPrototypeOf(this));
1485
+ return r.type = this.type, r._typeError = this._typeError, r._whitelistError = this._whitelistError, r._blacklistError = this._blacklistError, r._whitelist = this._whitelist.clone(), r._blacklist = this._blacklist.clone(), r.exclusiveTests = q({}, this.exclusiveTests), r.deps = [...this.deps], r.conditions = [...this.conditions], r.tests = [...this.tests], r.transforms = [...this.transforms], r.spec = ft(q({}, this.spec, t)), r;
1486
+ }
1487
+ label(t) {
1488
+ let r = this.clone();
1489
+ return r.spec.label = t, r;
1490
+ }
1491
+ meta(...t) {
1492
+ if (t.length === 0)
1493
+ return this.spec.meta;
1494
+ let r = this.clone();
1495
+ return r.spec.meta = Object.assign(r.spec.meta || {}, t[0]), r;
1496
+ }
1497
+ // withContext<TContext extends AnyObject>(): BaseSchema<
1498
+ // TCast,
1499
+ // TContext,
1500
+ // TOutput
1501
+ // > {
1502
+ // return this as any;
1503
+ // }
1504
+ withMutation(t) {
1505
+ let r = this._mutate;
1506
+ this._mutate = !0;
1507
+ let n = t(this);
1508
+ return this._mutate = r, n;
1509
+ }
1510
+ concat(t) {
1511
+ if (!t || t === this)
1512
+ return this;
1513
+ if (t.type !== this.type && this.type !== "mixed")
1514
+ throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${t.type}`);
1515
+ let r = this, n = t.clone();
1516
+ const a = q({}, r.spec, n.spec);
1517
+ return n.spec = a, n._typeError || (n._typeError = r._typeError), n._whitelistError || (n._whitelistError = r._whitelistError), n._blacklistError || (n._blacklistError = r._blacklistError), n._whitelist = r._whitelist.merge(t._whitelist, t._blacklist), n._blacklist = r._blacklist.merge(t._blacklist, t._whitelist), n.tests = r.tests, n.exclusiveTests = r.exclusiveTests, n.withMutation((i) => {
1518
+ t.tests.forEach((s) => {
1519
+ i.test(s.OPTIONS);
1520
+ });
1521
+ }), n.transforms = [...r.transforms, ...n.transforms], n;
1522
+ }
1523
+ isType(t) {
1524
+ return this.spec.nullable && t === null ? !0 : this._typeCheck(t);
1525
+ }
1526
+ resolve(t) {
1527
+ let r = this;
1528
+ if (r.conditions.length) {
1529
+ let n = r.conditions;
1530
+ r = r.clone(), r.conditions = [], r = n.reduce((a, i) => i.resolve(a, t), r), r = r.resolve(t);
1531
+ }
1532
+ return r;
1533
+ }
1534
+ /**
1535
+ *
1536
+ * @param {*} value
1537
+ * @param {Object} options
1538
+ * @param {*=} options.parent
1539
+ * @param {*=} options.context
1540
+ */
1541
+ cast(t, r = {}) {
1542
+ let n = this.resolve(q({
1543
+ value: t
1544
+ }, r)), a = n._cast(t, r);
1545
+ if (t !== void 0 && r.assert !== !1 && n.isType(a) !== !0) {
1546
+ let i = pe(t), s = pe(a);
1547
+ throw new TypeError(`The value of ${r.path || "field"} could not be cast to a value that satisfies the schema type: "${n._type}".
1548
+
1549
+ attempted value: ${i}
1550
+ ` + (s !== i ? `result of cast: ${s}` : ""));
1551
+ }
1552
+ return a;
1553
+ }
1554
+ _cast(t, r) {
1555
+ let n = t === void 0 ? t : this.transforms.reduce((a, i) => i.call(this, a, t, this), t);
1556
+ return n === void 0 && (n = this.getDefault()), n;
1557
+ }
1558
+ _validate(t, r = {}, n) {
1559
+ let {
1560
+ sync: a,
1561
+ path: i,
1562
+ from: s = [],
1563
+ originalValue: o = t,
1564
+ strict: c = this.spec.strict,
1565
+ abortEarly: u = this.spec.abortEarly
1566
+ } = r, l = t;
1567
+ c || (l = this._cast(l, q({
1568
+ assert: !1
1569
+ }, r)));
1570
+ let d = {
1571
+ value: l,
1572
+ path: i,
1573
+ options: r,
1574
+ originalValue: o,
1575
+ schema: this,
1576
+ label: this.spec.label,
1577
+ sync: a,
1578
+ from: s
1579
+ }, f = [];
1580
+ this._typeError && f.push(this._typeError);
1581
+ let p = [];
1582
+ this._whitelistError && p.push(this._whitelistError), this._blacklistError && p.push(this._blacklistError), je({
1583
+ args: d,
1584
+ value: l,
1585
+ path: i,
1586
+ sync: a,
1587
+ tests: f,
1588
+ endEarly: u
1589
+ }, (m) => {
1590
+ if (m)
1591
+ return void n(m, l);
1592
+ je({
1593
+ tests: this.tests.concat(p),
1594
+ args: d,
1595
+ path: i,
1596
+ sync: a,
1597
+ value: l,
1598
+ endEarly: u
1599
+ }, n);
1600
+ });
1601
+ }
1602
+ validate(t, r, n) {
1603
+ let a = this.resolve(q({}, r, {
1604
+ value: t
1605
+ }));
1606
+ return typeof n == "function" ? a._validate(t, r, n) : new Promise((i, s) => a._validate(t, r, (o, c) => {
1607
+ o ? s(o) : i(c);
1608
+ }));
1609
+ }
1610
+ validateSync(t, r) {
1611
+ let n = this.resolve(q({}, r, {
1612
+ value: t
1613
+ })), a;
1614
+ return n._validate(t, q({}, r, {
1615
+ sync: !0
1616
+ }), (i, s) => {
1617
+ if (i)
1618
+ throw i;
1619
+ a = s;
1620
+ }), a;
1621
+ }
1622
+ isValid(t, r) {
1623
+ return this.validate(t, r).then(() => !0, (n) => {
1624
+ if (D.isError(n))
1625
+ return !1;
1626
+ throw n;
1627
+ });
1628
+ }
1629
+ isValidSync(t, r) {
1630
+ try {
1631
+ return this.validateSync(t, r), !0;
1632
+ } catch (n) {
1633
+ if (D.isError(n))
1634
+ return !1;
1635
+ throw n;
1636
+ }
1637
+ }
1638
+ _getDefault() {
1639
+ let t = this.spec.default;
1640
+ return t == null ? t : typeof t == "function" ? t.call(this) : ft(t);
1641
+ }
1642
+ getDefault(t) {
1643
+ return this.resolve(t || {})._getDefault();
1644
+ }
1645
+ default(t) {
1646
+ return arguments.length === 0 ? this._getDefault() : this.clone({
1647
+ default: t
1648
+ });
1649
+ }
1650
+ strict(t = !0) {
1651
+ let r = this.clone();
1652
+ return r.spec.strict = t, r;
1653
+ }
1654
+ _isPresent(t) {
1655
+ return t != null;
1656
+ }
1657
+ defined(t = ie.defined) {
1658
+ return this.test({
1659
+ message: t,
1660
+ name: "defined",
1661
+ exclusive: !0,
1662
+ test(r) {
1663
+ return r !== void 0;
1664
+ }
1665
+ });
1666
+ }
1667
+ required(t = ie.required) {
1668
+ return this.clone({
1669
+ presence: "required"
1670
+ }).withMutation((r) => r.test({
1671
+ message: t,
1672
+ name: "required",
1673
+ exclusive: !0,
1674
+ test(n) {
1675
+ return this.schema._isPresent(n);
1676
+ }
1677
+ }));
1678
+ }
1679
+ notRequired() {
1680
+ let t = this.clone({
1681
+ presence: "optional"
1682
+ });
1683
+ return t.tests = t.tests.filter((r) => r.OPTIONS.name !== "required"), t;
1684
+ }
1685
+ nullable(t = !0) {
1686
+ return this.clone({
1687
+ nullable: t !== !1
1688
+ });
1689
+ }
1690
+ transform(t) {
1691
+ let r = this.clone();
1692
+ return r.transforms.push(t), r;
1693
+ }
1694
+ /**
1695
+ * Adds a test function to the schema's queue of tests.
1696
+ * tests can be exclusive or non-exclusive.
1697
+ *
1698
+ * - exclusive tests, will replace any existing tests of the same name.
1699
+ * - non-exclusive: can be stacked
1700
+ *
1701
+ * If a non-exclusive test is added to a schema with an exclusive test of the same name
1702
+ * the exclusive test is removed and further tests of the same name will be stacked.
1703
+ *
1704
+ * If an exclusive test is added to a schema with non-exclusive tests of the same name
1705
+ * the previous tests are removed and further tests of the same name will replace each other.
1706
+ */
1707
+ test(...t) {
1708
+ let r;
1709
+ if (t.length === 1 ? typeof t[0] == "function" ? r = {
1710
+ test: t[0]
1711
+ } : r = t[0] : t.length === 2 ? r = {
1712
+ name: t[0],
1713
+ test: t[1]
1714
+ } : r = {
1715
+ name: t[0],
1716
+ message: t[1],
1717
+ test: t[2]
1718
+ }, r.message === void 0 && (r.message = ie.default), typeof r.test != "function")
1719
+ throw new TypeError("`test` is a required parameters");
1720
+ let n = this.clone(), a = Re(r), i = r.exclusive || r.name && n.exclusiveTests[r.name] === !0;
1721
+ if (r.exclusive && !r.name)
1722
+ throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");
1723
+ return r.name && (n.exclusiveTests[r.name] = !!r.exclusive), n.tests = n.tests.filter((s) => !(s.OPTIONS.name === r.name && (i || s.OPTIONS.test === a.OPTIONS.test))), n.tests.push(a), n;
1724
+ }
1725
+ when(t, r) {
1726
+ !Array.isArray(t) && typeof t != "string" && (r = t, t = ".");
1727
+ let n = this.clone(), a = dn(t).map((i) => new Q(i));
1728
+ return a.forEach((i) => {
1729
+ i.isSibling && n.deps.push(i.key);
1730
+ }), n.conditions.push(new Oc(a, r)), n;
1731
+ }
1732
+ typeError(t) {
1733
+ let r = this.clone();
1734
+ return r._typeError = Re({
1735
+ message: t,
1736
+ name: "typeError",
1737
+ test(n) {
1738
+ return n !== void 0 && !this.schema.isType(n) ? this.createError({
1739
+ params: {
1740
+ type: this.schema._type
1741
+ }
1742
+ }) : !0;
1743
+ }
1744
+ }), r;
1745
+ }
1746
+ oneOf(t, r = ie.oneOf) {
1747
+ let n = this.clone();
1748
+ return t.forEach((a) => {
1749
+ n._whitelist.add(a), n._blacklist.delete(a);
1750
+ }), n._whitelistError = Re({
1751
+ message: r,
1752
+ name: "oneOf",
1753
+ test(a) {
1754
+ if (a === void 0)
1755
+ return !0;
1756
+ let i = this.schema._whitelist, s = i.resolveAll(this.resolve);
1757
+ return s.includes(a) ? !0 : this.createError({
1758
+ params: {
1759
+ values: i.toArray().join(", "),
1760
+ resolved: s
1761
+ }
1762
+ });
1763
+ }
1764
+ }), n;
1765
+ }
1766
+ notOneOf(t, r = ie.notOneOf) {
1767
+ let n = this.clone();
1768
+ return t.forEach((a) => {
1769
+ n._blacklist.add(a), n._whitelist.delete(a);
1770
+ }), n._blacklistError = Re({
1771
+ message: r,
1772
+ name: "notOneOf",
1773
+ test(a) {
1774
+ let i = this.schema._blacklist, s = i.resolveAll(this.resolve);
1775
+ return s.includes(a) ? this.createError({
1776
+ params: {
1777
+ values: i.toArray().join(", "),
1778
+ resolved: s
1779
+ }
1780
+ }) : !0;
1781
+ }
1782
+ }), n;
1783
+ }
1784
+ strip(t = !0) {
1785
+ let r = this.clone();
1786
+ return r.spec.strip = t, r;
1787
+ }
1788
+ describe() {
1789
+ const t = this.clone(), {
1790
+ label: r,
1791
+ meta: n
1792
+ } = t.spec;
1793
+ return {
1794
+ meta: n,
1795
+ label: r,
1796
+ type: t.type,
1797
+ oneOf: t._whitelist.describe(),
1798
+ notOneOf: t._blacklist.describe(),
1799
+ tests: t.tests.map((i) => ({
1800
+ name: i.OPTIONS.name,
1801
+ params: i.OPTIONS.params
1802
+ })).filter((i, s, o) => o.findIndex((c) => c.name === i.name) === s)
1803
+ };
1804
+ }
1805
+ }
1806
+ I.prototype.__isYupSchema__ = !0;
1807
+ for (const e of ["validate", "validateSync"])
1808
+ I.prototype[`${e}At`] = function(t, r, n = {}) {
1809
+ const {
1810
+ parent: a,
1811
+ parentPath: i,
1812
+ schema: s
1813
+ } = Wp(this, t, r, n.context);
1814
+ return s[e](a && a[i], q({}, n, {
1815
+ parent: a,
1816
+ path: t
1817
+ }));
1818
+ };
1819
+ for (const e of ["equals", "is"])
1820
+ I.prototype[e] = I.prototype.oneOf;
1821
+ for (const e of ["not", "nope"])
1822
+ I.prototype[e] = I.prototype.notOneOf;
1823
+ I.prototype.optional = I.prototype.notRequired;
1824
+ const Tn = I;
1825
+ function be() {
1826
+ return new Tn();
1827
+ }
1828
+ be.prototype = Tn.prototype;
1829
+ const E = (e) => e == null;
1830
+ function $e() {
1831
+ return new xn();
1832
+ }
1833
+ class xn extends I {
1834
+ constructor() {
1835
+ super({
1836
+ type: "boolean"
1837
+ }), this.withMutation(() => {
1838
+ this.transform(function(t) {
1839
+ if (!this.isType(t)) {
1840
+ if (/^(true|1)$/i.test(String(t)))
1841
+ return !0;
1842
+ if (/^(false|0)$/i.test(String(t)))
1843
+ return !1;
1844
+ }
1845
+ return t;
1846
+ });
1847
+ });
1848
+ }
1849
+ _typeCheck(t) {
1850
+ return t instanceof Boolean && (t = t.valueOf()), typeof t == "boolean";
1851
+ }
1852
+ isTrue(t = ht.isValue) {
1853
+ return this.test({
1854
+ message: t,
1855
+ name: "is-value",
1856
+ exclusive: !0,
1857
+ params: {
1858
+ value: "true"
1859
+ },
1860
+ test(r) {
1861
+ return E(r) || r === !0;
1862
+ }
1863
+ });
1864
+ }
1865
+ isFalse(t = ht.isValue) {
1866
+ return this.test({
1867
+ message: t,
1868
+ name: "is-value",
1869
+ exclusive: !0,
1870
+ params: {
1871
+ value: "false"
1872
+ },
1873
+ test(r) {
1874
+ return E(r) || r === !1;
1875
+ }
1876
+ });
1877
+ }
1878
+ }
1879
+ $e.prototype = xn.prototype;
1880
+ let Jp = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i, Zp = /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i, Yp = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i, Xp = (e) => E(e) || e === e.trim(), Qp = {}.toString();
1881
+ function h() {
1882
+ return new Pn();
1883
+ }
1884
+ class Pn extends I {
1885
+ constructor() {
1886
+ super({
1887
+ type: "string"
1888
+ }), this.withMutation(() => {
1889
+ this.transform(function(t) {
1890
+ if (this.isType(t) || Array.isArray(t))
1891
+ return t;
1892
+ const r = t != null && t.toString ? t.toString() : t;
1893
+ return r === Qp ? t : r;
1894
+ });
1895
+ });
1896
+ }
1897
+ _typeCheck(t) {
1898
+ return t instanceof String && (t = t.valueOf()), typeof t == "string";
1899
+ }
1900
+ _isPresent(t) {
1901
+ return super._isPresent(t) && !!t.length;
1902
+ }
1903
+ length(t, r = k.length) {
1904
+ return this.test({
1905
+ message: r,
1906
+ name: "length",
1907
+ exclusive: !0,
1908
+ params: {
1909
+ length: t
1910
+ },
1911
+ test(n) {
1912
+ return E(n) || n.length === this.resolve(t);
1913
+ }
1914
+ });
1915
+ }
1916
+ min(t, r = k.min) {
1917
+ return this.test({
1918
+ message: r,
1919
+ name: "min",
1920
+ exclusive: !0,
1921
+ params: {
1922
+ min: t
1923
+ },
1924
+ test(n) {
1925
+ return E(n) || n.length >= this.resolve(t);
1926
+ }
1927
+ });
1928
+ }
1929
+ max(t, r = k.max) {
1930
+ return this.test({
1931
+ name: "max",
1932
+ exclusive: !0,
1933
+ message: r,
1934
+ params: {
1935
+ max: t
1936
+ },
1937
+ test(n) {
1938
+ return E(n) || n.length <= this.resolve(t);
1939
+ }
1940
+ });
1941
+ }
1942
+ matches(t, r) {
1943
+ let n = !1, a, i;
1944
+ return r && (typeof r == "object" ? {
1945
+ excludeEmptyString: n = !1,
1946
+ message: a,
1947
+ name: i
1948
+ } = r : a = r), this.test({
1949
+ name: i || "matches",
1950
+ message: a || k.matches,
1951
+ params: {
1952
+ regex: t
1953
+ },
1954
+ test: (s) => E(s) || s === "" && n || s.search(t) !== -1
1955
+ });
1956
+ }
1957
+ email(t = k.email) {
1958
+ return this.matches(Jp, {
1959
+ name: "email",
1960
+ message: t,
1961
+ excludeEmptyString: !0
1962
+ });
1963
+ }
1964
+ url(t = k.url) {
1965
+ return this.matches(Zp, {
1966
+ name: "url",
1967
+ message: t,
1968
+ excludeEmptyString: !0
1969
+ });
1970
+ }
1971
+ uuid(t = k.uuid) {
1972
+ return this.matches(Yp, {
1973
+ name: "uuid",
1974
+ message: t,
1975
+ excludeEmptyString: !1
1976
+ });
1977
+ }
1978
+ //-- transforms --
1979
+ ensure() {
1980
+ return this.default("").transform((t) => t === null ? "" : t);
1981
+ }
1982
+ trim(t = k.trim) {
1983
+ return this.transform((r) => r != null ? r.trim() : r).test({
1984
+ message: t,
1985
+ name: "trim",
1986
+ test: Xp
1987
+ });
1988
+ }
1989
+ lowercase(t = k.lowercase) {
1990
+ return this.transform((r) => E(r) ? r : r.toLowerCase()).test({
1991
+ message: t,
1992
+ name: "string_case",
1993
+ exclusive: !0,
1994
+ test: (r) => E(r) || r === r.toLowerCase()
1995
+ });
1996
+ }
1997
+ uppercase(t = k.uppercase) {
1998
+ return this.transform((r) => E(r) ? r : r.toUpperCase()).test({
1999
+ message: t,
2000
+ name: "string_case",
2001
+ exclusive: !0,
2002
+ test: (r) => E(r) || r === r.toUpperCase()
2003
+ });
2004
+ }
2005
+ }
2006
+ h.prototype = Pn.prototype;
2007
+ let Hp = (e) => e != +e;
2008
+ function Te() {
2009
+ return new Fn();
2010
+ }
2011
+ class Fn extends I {
2012
+ constructor() {
2013
+ super({
2014
+ type: "number"
2015
+ }), this.withMutation(() => {
2016
+ this.transform(function(t) {
2017
+ let r = t;
2018
+ if (typeof r == "string") {
2019
+ if (r = r.replace(/\s/g, ""), r === "")
2020
+ return NaN;
2021
+ r = +r;
2022
+ }
2023
+ return this.isType(r) ? r : parseFloat(r);
2024
+ });
2025
+ });
2026
+ }
2027
+ _typeCheck(t) {
2028
+ return t instanceof Number && (t = t.valueOf()), typeof t == "number" && !Hp(t);
2029
+ }
2030
+ min(t, r = Z.min) {
2031
+ return this.test({
2032
+ message: r,
2033
+ name: "min",
2034
+ exclusive: !0,
2035
+ params: {
2036
+ min: t
2037
+ },
2038
+ test(n) {
2039
+ return E(n) || n >= this.resolve(t);
2040
+ }
2041
+ });
2042
+ }
2043
+ max(t, r = Z.max) {
2044
+ return this.test({
2045
+ message: r,
2046
+ name: "max",
2047
+ exclusive: !0,
2048
+ params: {
2049
+ max: t
2050
+ },
2051
+ test(n) {
2052
+ return E(n) || n <= this.resolve(t);
2053
+ }
2054
+ });
2055
+ }
2056
+ lessThan(t, r = Z.lessThan) {
2057
+ return this.test({
2058
+ message: r,
2059
+ name: "max",
2060
+ exclusive: !0,
2061
+ params: {
2062
+ less: t
2063
+ },
2064
+ test(n) {
2065
+ return E(n) || n < this.resolve(t);
2066
+ }
2067
+ });
2068
+ }
2069
+ moreThan(t, r = Z.moreThan) {
2070
+ return this.test({
2071
+ message: r,
2072
+ name: "min",
2073
+ exclusive: !0,
2074
+ params: {
2075
+ more: t
2076
+ },
2077
+ test(n) {
2078
+ return E(n) || n > this.resolve(t);
2079
+ }
2080
+ });
2081
+ }
2082
+ positive(t = Z.positive) {
2083
+ return this.moreThan(0, t);
2084
+ }
2085
+ negative(t = Z.negative) {
2086
+ return this.lessThan(0, t);
2087
+ }
2088
+ integer(t = Z.integer) {
2089
+ return this.test({
2090
+ name: "integer",
2091
+ message: t,
2092
+ test: (r) => E(r) || Number.isInteger(r)
2093
+ });
2094
+ }
2095
+ truncate() {
2096
+ return this.transform((t) => E(t) ? t : t | 0);
2097
+ }
2098
+ round(t) {
2099
+ var r;
2100
+ let n = ["ceil", "floor", "round", "trunc"];
2101
+ if (t = ((r = t) == null ? void 0 : r.toLowerCase()) || "round", t === "trunc")
2102
+ return this.truncate();
2103
+ if (n.indexOf(t.toLowerCase()) === -1)
2104
+ throw new TypeError("Only valid options for round() are: " + n.join(", "));
2105
+ return this.transform((a) => E(a) ? a : Math[t](a));
2106
+ }
2107
+ }
2108
+ Te.prototype = Fn.prototype;
2109
+ var eh = /^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;
2110
+ function th(e) {
2111
+ var t = [1, 4, 5, 6, 7, 10, 11], r = 0, n, a;
2112
+ if (a = eh.exec(e)) {
2113
+ for (var i = 0, s; s = t[i]; ++i)
2114
+ a[s] = +a[s] || 0;
2115
+ a[2] = (+a[2] || 1) - 1, a[3] = +a[3] || 1, a[7] = a[7] ? String(a[7]).substr(0, 3) : 0, (a[8] === void 0 || a[8] === "") && (a[9] === void 0 || a[9] === "") ? n = +new Date(a[1], a[2], a[3], a[4], a[5], a[6], a[7]) : (a[8] !== "Z" && a[9] !== void 0 && (r = a[10] * 60 + a[11], a[9] === "+" && (r = 0 - r)), n = Date.UTC(a[1], a[2], a[3], a[4], a[5] + r, a[6], a[7]));
2116
+ } else
2117
+ n = Date.parse ? Date.parse(e) : NaN;
2118
+ return n;
2119
+ }
2120
+ let On = /* @__PURE__ */ new Date(""), rh = (e) => Object.prototype.toString.call(e) === "[object Date]";
2121
+ class In extends I {
2122
+ constructor() {
2123
+ super({
2124
+ type: "date"
2125
+ }), this.withMutation(() => {
2126
+ this.transform(function(t) {
2127
+ return this.isType(t) ? t : (t = th(t), isNaN(t) ? On : new Date(t));
2128
+ });
2129
+ });
2130
+ }
2131
+ _typeCheck(t) {
2132
+ return rh(t) && !isNaN(t.getTime());
2133
+ }
2134
+ prepareParam(t, r) {
2135
+ let n;
2136
+ if (Q.isRef(t))
2137
+ n = t;
2138
+ else {
2139
+ let a = this.cast(t);
2140
+ if (!this._typeCheck(a))
2141
+ throw new TypeError(`\`${r}\` must be a Date or a value that can be \`cast()\` to a Date`);
2142
+ n = a;
2143
+ }
2144
+ return n;
2145
+ }
2146
+ min(t, r = pt.min) {
2147
+ let n = this.prepareParam(t, "min");
2148
+ return this.test({
2149
+ message: r,
2150
+ name: "min",
2151
+ exclusive: !0,
2152
+ params: {
2153
+ min: t
2154
+ },
2155
+ test(a) {
2156
+ return E(a) || a >= this.resolve(n);
2157
+ }
2158
+ });
2159
+ }
2160
+ max(t, r = pt.max) {
2161
+ let n = this.prepareParam(t, "max");
2162
+ return this.test({
2163
+ message: r,
2164
+ name: "max",
2165
+ exclusive: !0,
2166
+ params: {
2167
+ max: t
2168
+ },
2169
+ test(a) {
2170
+ return E(a) || a <= this.resolve(n);
2171
+ }
2172
+ });
2173
+ }
2174
+ }
2175
+ In.INVALID_DATE = On;
2176
+ In.prototype;
2177
+ function nh(e, t, r, n) {
2178
+ var a = -1, i = e == null ? 0 : e.length;
2179
+ for (n && i && (r = e[++a]); ++a < i; )
2180
+ r = t(r, e[a], a, e);
2181
+ return r;
2182
+ }
2183
+ var ah = nh;
2184
+ function ih(e) {
2185
+ return function(t) {
2186
+ return e == null ? void 0 : e[t];
2187
+ };
2188
+ }
2189
+ var sh = ih, oh = sh, ch = {
2190
+ // Latin-1 Supplement block.
2191
+ À: "A",
2192
+ Á: "A",
2193
+ Â: "A",
2194
+ Ã: "A",
2195
+ Ä: "A",
2196
+ Å: "A",
2197
+ à: "a",
2198
+ á: "a",
2199
+ â: "a",
2200
+ ã: "a",
2201
+ ä: "a",
2202
+ å: "a",
2203
+ Ç: "C",
2204
+ ç: "c",
2205
+ Ð: "D",
2206
+ ð: "d",
2207
+ È: "E",
2208
+ É: "E",
2209
+ Ê: "E",
2210
+ Ë: "E",
2211
+ è: "e",
2212
+ é: "e",
2213
+ ê: "e",
2214
+ ë: "e",
2215
+ Ì: "I",
2216
+ Í: "I",
2217
+ Î: "I",
2218
+ Ï: "I",
2219
+ ì: "i",
2220
+ í: "i",
2221
+ î: "i",
2222
+ ï: "i",
2223
+ Ñ: "N",
2224
+ ñ: "n",
2225
+ Ò: "O",
2226
+ Ó: "O",
2227
+ Ô: "O",
2228
+ Õ: "O",
2229
+ Ö: "O",
2230
+ Ø: "O",
2231
+ ò: "o",
2232
+ ó: "o",
2233
+ ô: "o",
2234
+ õ: "o",
2235
+ ö: "o",
2236
+ ø: "o",
2237
+ Ù: "U",
2238
+ Ú: "U",
2239
+ Û: "U",
2240
+ Ü: "U",
2241
+ ù: "u",
2242
+ ú: "u",
2243
+ û: "u",
2244
+ ü: "u",
2245
+ Ý: "Y",
2246
+ ý: "y",
2247
+ ÿ: "y",
2248
+ Æ: "Ae",
2249
+ æ: "ae",
2250
+ Þ: "Th",
2251
+ þ: "th",
2252
+ ß: "ss",
2253
+ // Latin Extended-A block.
2254
+ Ā: "A",
2255
+ Ă: "A",
2256
+ Ą: "A",
2257
+ ā: "a",
2258
+ ă: "a",
2259
+ ą: "a",
2260
+ Ć: "C",
2261
+ Ĉ: "C",
2262
+ Ċ: "C",
2263
+ Č: "C",
2264
+ ć: "c",
2265
+ ĉ: "c",
2266
+ ċ: "c",
2267
+ č: "c",
2268
+ Ď: "D",
2269
+ Đ: "D",
2270
+ ď: "d",
2271
+ đ: "d",
2272
+ Ē: "E",
2273
+ Ĕ: "E",
2274
+ Ė: "E",
2275
+ Ę: "E",
2276
+ Ě: "E",
2277
+ ē: "e",
2278
+ ĕ: "e",
2279
+ ė: "e",
2280
+ ę: "e",
2281
+ ě: "e",
2282
+ Ĝ: "G",
2283
+ Ğ: "G",
2284
+ Ġ: "G",
2285
+ Ģ: "G",
2286
+ ĝ: "g",
2287
+ ğ: "g",
2288
+ ġ: "g",
2289
+ ģ: "g",
2290
+ Ĥ: "H",
2291
+ Ħ: "H",
2292
+ ĥ: "h",
2293
+ ħ: "h",
2294
+ Ĩ: "I",
2295
+ Ī: "I",
2296
+ Ĭ: "I",
2297
+ Į: "I",
2298
+ İ: "I",
2299
+ ĩ: "i",
2300
+ ī: "i",
2301
+ ĭ: "i",
2302
+ į: "i",
2303
+ ı: "i",
2304
+ Ĵ: "J",
2305
+ ĵ: "j",
2306
+ Ķ: "K",
2307
+ ķ: "k",
2308
+ ĸ: "k",
2309
+ Ĺ: "L",
2310
+ Ļ: "L",
2311
+ Ľ: "L",
2312
+ Ŀ: "L",
2313
+ Ł: "L",
2314
+ ĺ: "l",
2315
+ ļ: "l",
2316
+ ľ: "l",
2317
+ ŀ: "l",
2318
+ ł: "l",
2319
+ Ń: "N",
2320
+ Ņ: "N",
2321
+ Ň: "N",
2322
+ Ŋ: "N",
2323
+ ń: "n",
2324
+ ņ: "n",
2325
+ ň: "n",
2326
+ ŋ: "n",
2327
+ Ō: "O",
2328
+ Ŏ: "O",
2329
+ Ő: "O",
2330
+ ō: "o",
2331
+ ŏ: "o",
2332
+ ő: "o",
2333
+ Ŕ: "R",
2334
+ Ŗ: "R",
2335
+ Ř: "R",
2336
+ ŕ: "r",
2337
+ ŗ: "r",
2338
+ ř: "r",
2339
+ Ś: "S",
2340
+ Ŝ: "S",
2341
+ Ş: "S",
2342
+ Š: "S",
2343
+ ś: "s",
2344
+ ŝ: "s",
2345
+ ş: "s",
2346
+ š: "s",
2347
+ Ţ: "T",
2348
+ Ť: "T",
2349
+ Ŧ: "T",
2350
+ ţ: "t",
2351
+ ť: "t",
2352
+ ŧ: "t",
2353
+ Ũ: "U",
2354
+ Ū: "U",
2355
+ Ŭ: "U",
2356
+ Ů: "U",
2357
+ Ű: "U",
2358
+ Ų: "U",
2359
+ ũ: "u",
2360
+ ū: "u",
2361
+ ŭ: "u",
2362
+ ů: "u",
2363
+ ű: "u",
2364
+ ų: "u",
2365
+ Ŵ: "W",
2366
+ ŵ: "w",
2367
+ Ŷ: "Y",
2368
+ ŷ: "y",
2369
+ Ÿ: "Y",
2370
+ Ź: "Z",
2371
+ Ż: "Z",
2372
+ Ž: "Z",
2373
+ ź: "z",
2374
+ ż: "z",
2375
+ ž: "z",
2376
+ IJ: "IJ",
2377
+ ij: "ij",
2378
+ Œ: "Oe",
2379
+ œ: "oe",
2380
+ ʼn: "'n",
2381
+ ſ: "s"
2382
+ }, uh = oh(ch), lh = uh, dh = lh, fh = Oe, ph = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, hh = "\\u0300-\\u036f", mh = "\\ufe20-\\ufe2f", yh = "\\u20d0-\\u20ff", gh = hh + mh + yh, vh = "[" + gh + "]", _h = RegExp(vh, "g");
2383
+ function Sh(e) {
2384
+ return e = fh(e), e && e.replace(ph, dh).replace(_h, "");
2385
+ }
2386
+ var bh = Sh, $h = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
2387
+ function Ah(e) {
2388
+ return e.match($h) || [];
2389
+ }
2390
+ var wh = Ah, Eh = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
2391
+ function Ch(e) {
2392
+ return Eh.test(e);
2393
+ }
2394
+ var Th = Ch, Nn = "\\ud800-\\udfff", xh = "\\u0300-\\u036f", Ph = "\\ufe20-\\ufe2f", Fh = "\\u20d0-\\u20ff", Oh = xh + Ph + Fh, Dn = "\\u2700-\\u27bf", Rn = "a-z\\xdf-\\xf6\\xf8-\\xff", Ih = "\\xac\\xb1\\xd7\\xf7", Nh = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", Dh = "\\u2000-\\u206f", Rh = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", Ln = "A-Z\\xc0-\\xd6\\xd8-\\xde", Lh = "\\ufe0e\\ufe0f", Mn = Ih + Nh + Dh + Rh, qn = "['’]", Or = "[" + Mn + "]", Mh = "[" + Oh + "]", Un = "\\d+", qh = "[" + Dn + "]", jn = "[" + Rn + "]", kn = "[^" + Nn + Mn + Un + Dn + Rn + Ln + "]", Uh = "\\ud83c[\\udffb-\\udfff]", jh = "(?:" + Mh + "|" + Uh + ")", kh = "[^" + Nn + "]", Gn = "(?:\\ud83c[\\udde6-\\uddff]){2}", zn = "[\\ud800-\\udbff][\\udc00-\\udfff]", de = "[" + Ln + "]", Gh = "\\u200d", Ir = "(?:" + jn + "|" + kn + ")", zh = "(?:" + de + "|" + kn + ")", Nr = "(?:" + qn + "(?:d|ll|m|re|s|t|ve))?", Dr = "(?:" + qn + "(?:D|LL|M|RE|S|T|VE))?", Vn = jh + "?", Bn = "[" + Lh + "]?", Vh = "(?:" + Gh + "(?:" + [kh, Gn, zn].join("|") + ")" + Bn + Vn + ")*", Bh = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", Kh = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", Wh = Bn + Vn + Vh, Jh = "(?:" + [qh, Gn, zn].join("|") + ")" + Wh, Zh = RegExp([
2395
+ de + "?" + jn + "+" + Nr + "(?=" + [Or, de, "$"].join("|") + ")",
2396
+ zh + "+" + Dr + "(?=" + [Or, de + Ir, "$"].join("|") + ")",
2397
+ de + "?" + Ir + "+" + Nr,
2398
+ de + "+" + Dr,
2399
+ Kh,
2400
+ Bh,
2401
+ Un,
2402
+ Jh
2403
+ ].join("|"), "g");
2404
+ function Yh(e) {
2405
+ return e.match(Zh) || [];
2406
+ }
2407
+ var Xh = Yh, Qh = wh, Hh = Th, em = Oe, tm = Xh;
2408
+ function rm(e, t, r) {
2409
+ return e = em(e), t = r ? void 0 : t, t === void 0 ? Hh(e) ? tm(e) : Qh(e) : e.match(t) || [];
2410
+ }
2411
+ var nm = rm, am = ah, im = bh, sm = nm, om = "['’]", cm = RegExp(om, "g");
2412
+ function um(e) {
2413
+ return function(t) {
2414
+ return am(sm(im(t).replace(cm, "")), e, "");
2415
+ };
2416
+ }
2417
+ var Kn = um, lm = Kn, dm = lm(function(e, t, r) {
2418
+ return e + (r ? "_" : "") + t.toLowerCase();
2419
+ }), fm = dm;
2420
+ const Rr = /* @__PURE__ */ me(fm);
2421
+ function pm(e, t, r) {
2422
+ var n = -1, a = e.length;
2423
+ t < 0 && (t = -t > a ? 0 : a + t), r = r > a ? a : r, r < 0 && (r += a), a = t > r ? 0 : r - t >>> 0, t >>>= 0;
2424
+ for (var i = Array(a); ++n < a; )
2425
+ i[n] = e[n + t];
2426
+ return i;
2427
+ }
2428
+ var hm = pm, mm = hm;
2429
+ function ym(e, t, r) {
2430
+ var n = e.length;
2431
+ return r = r === void 0 ? n : r, !t && r >= n ? e : mm(e, t, r);
2432
+ }
2433
+ var gm = ym, vm = "\\ud800-\\udfff", _m = "\\u0300-\\u036f", Sm = "\\ufe20-\\ufe2f", bm = "\\u20d0-\\u20ff", $m = _m + Sm + bm, Am = "\\ufe0e\\ufe0f", wm = "\\u200d", Em = RegExp("[" + wm + vm + $m + Am + "]");
2434
+ function Cm(e) {
2435
+ return Em.test(e);
2436
+ }
2437
+ var Wn = Cm;
2438
+ function Tm(e) {
2439
+ return e.split("");
2440
+ }
2441
+ var xm = Tm, Jn = "\\ud800-\\udfff", Pm = "\\u0300-\\u036f", Fm = "\\ufe20-\\ufe2f", Om = "\\u20d0-\\u20ff", Im = Pm + Fm + Om, Nm = "\\ufe0e\\ufe0f", Dm = "[" + Jn + "]", At = "[" + Im + "]", wt = "\\ud83c[\\udffb-\\udfff]", Rm = "(?:" + At + "|" + wt + ")", Zn = "[^" + Jn + "]", Yn = "(?:\\ud83c[\\udde6-\\uddff]){2}", Xn = "[\\ud800-\\udbff][\\udc00-\\udfff]", Lm = "\\u200d", Qn = Rm + "?", Hn = "[" + Nm + "]?", Mm = "(?:" + Lm + "(?:" + [Zn, Yn, Xn].join("|") + ")" + Hn + Qn + ")*", qm = Hn + Qn + Mm, Um = "(?:" + [Zn + At + "?", At, Yn, Xn, Dm].join("|") + ")", jm = RegExp(wt + "(?=" + wt + ")|" + Um + qm, "g");
2442
+ function km(e) {
2443
+ return e.match(jm) || [];
2444
+ }
2445
+ var Gm = km, zm = xm, Vm = Wn, Bm = Gm;
2446
+ function Km(e) {
2447
+ return Vm(e) ? Bm(e) : zm(e);
2448
+ }
2449
+ var Wm = Km, Jm = gm, Zm = Wn, Ym = Wm, Xm = Oe;
2450
+ function Qm(e) {
2451
+ return function(t) {
2452
+ t = Xm(t);
2453
+ var r = Zm(t) ? Ym(t) : void 0, n = r ? r[0] : t.charAt(0), a = r ? Jm(r, 1).join("") : t.slice(1);
2454
+ return n[e]() + a;
2455
+ };
2456
+ }
2457
+ var Hm = Qm, ey = Hm, ty = ey("toUpperCase"), ry = ty, ny = Oe, ay = ry;
2458
+ function iy(e) {
2459
+ return ay(ny(e).toLowerCase());
2460
+ }
2461
+ var sy = iy, oy = sy, cy = Kn, uy = cy(function(e, t, r) {
2462
+ return t = t.toLowerCase(), e + (r ? oy(t) : t);
2463
+ }), ly = uy;
2464
+ const dy = /* @__PURE__ */ me(ly);
2465
+ var fy = fn, py = mn, hy = wn;
2466
+ function my(e, t) {
2467
+ var r = {};
2468
+ return t = hy(t), py(e, function(n, a, i) {
2469
+ fy(r, t(n, a, i), n);
2470
+ }), r;
2471
+ }
2472
+ var yy = my;
2473
+ const gy = /* @__PURE__ */ me(yy);
2474
+ var jt = { exports: {} };
2475
+ jt.exports = function(e) {
2476
+ return ea(vy(e), e);
2477
+ };
2478
+ jt.exports.array = ea;
2479
+ function ea(e, t) {
2480
+ var r = e.length, n = new Array(r), a = {}, i = r, s = _y(t), o = Sy(e);
2481
+ for (t.forEach(function(u) {
2482
+ if (!o.has(u[0]) || !o.has(u[1]))
2483
+ throw new Error("Unknown node. There is an unknown node in the supplied edges.");
2484
+ }); i--; )
2485
+ a[i] || c(e[i], i, /* @__PURE__ */ new Set());
2486
+ return n;
2487
+ function c(u, l, d) {
2488
+ if (d.has(u)) {
2489
+ var f;
2490
+ try {
2491
+ f = ", node was:" + JSON.stringify(u);
2492
+ } catch {
2493
+ f = "";
2494
+ }
2495
+ throw new Error("Cyclic dependency" + f);
2496
+ }
2497
+ if (!o.has(u))
2498
+ throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: " + JSON.stringify(u));
2499
+ if (!a[l]) {
2500
+ a[l] = !0;
2501
+ var p = s.get(u) || /* @__PURE__ */ new Set();
2502
+ if (p = Array.from(p), l = p.length) {
2503
+ d.add(u);
2504
+ do {
2505
+ var m = p[--l];
2506
+ c(m, o.get(m), d);
2507
+ } while (l);
2508
+ d.delete(u);
2509
+ }
2510
+ n[--r] = u;
2511
+ }
2512
+ }
2513
+ }
2514
+ function vy(e) {
2515
+ for (var t = /* @__PURE__ */ new Set(), r = 0, n = e.length; r < n; r++) {
2516
+ var a = e[r];
2517
+ t.add(a[0]), t.add(a[1]);
2518
+ }
2519
+ return Array.from(t);
2520
+ }
2521
+ function _y(e) {
2522
+ for (var t = /* @__PURE__ */ new Map(), r = 0, n = e.length; r < n; r++) {
2523
+ var a = e[r];
2524
+ t.has(a[0]) || t.set(a[0], /* @__PURE__ */ new Set()), t.has(a[1]) || t.set(a[1], /* @__PURE__ */ new Set()), t.get(a[0]).add(a[1]);
2525
+ }
2526
+ return t;
2527
+ }
2528
+ function Sy(e) {
2529
+ for (var t = /* @__PURE__ */ new Map(), r = 0, n = e.length; r < n; r++)
2530
+ t.set(e[r], r);
2531
+ return t;
2532
+ }
2533
+ var by = jt.exports;
2534
+ const $y = /* @__PURE__ */ me(by);
2535
+ function Ay(e, t = []) {
2536
+ let r = [], n = /* @__PURE__ */ new Set(), a = new Set(t.map(([s, o]) => `${s}-${o}`));
2537
+ function i(s, o) {
2538
+ let c = et.split(s)[0];
2539
+ n.add(c), a.has(`${o}-${c}`) || r.push([o, c]);
2540
+ }
2541
+ for (const s in e)
2542
+ if (Ue(e, s)) {
2543
+ let o = e[s];
2544
+ n.add(s), Q.isRef(o) && o.isSibling ? i(o.path, s) : Lt(o) && "deps" in o && o.deps.forEach((c) => i(c, s));
2545
+ }
2546
+ return $y.array(Array.from(n), r).reverse();
2547
+ }
2548
+ function Lr(e, t) {
2549
+ let r = 1 / 0;
2550
+ return e.some((n, a) => {
2551
+ var i;
2552
+ if (((i = t.path) == null ? void 0 : i.indexOf(n)) !== -1)
2553
+ return r = a, !0;
2554
+ }), r;
2555
+ }
2556
+ function ta(e) {
2557
+ return (t, r) => Lr(e, t) - Lr(e, r);
2558
+ }
2559
+ function fe() {
2560
+ return fe = Object.assign || function(e) {
2561
+ for (var t = 1; t < arguments.length; t++) {
2562
+ var r = arguments[t];
2563
+ for (var n in r)
2564
+ Object.prototype.hasOwnProperty.call(r, n) && (e[n] = r[n]);
2565
+ }
2566
+ return e;
2567
+ }, fe.apply(this, arguments);
2568
+ }
2569
+ let Mr = (e) => Object.prototype.toString.call(e) === "[object Object]";
2570
+ function wy(e, t) {
2571
+ let r = Object.keys(e.fields);
2572
+ return Object.keys(t).filter((n) => r.indexOf(n) === -1);
2573
+ }
2574
+ const Ey = ta([]);
2575
+ class ra extends I {
2576
+ constructor(t) {
2577
+ super({
2578
+ type: "object"
2579
+ }), this.fields = /* @__PURE__ */ Object.create(null), this._sortErrors = Ey, this._nodes = [], this._excludedEdges = [], this.withMutation(() => {
2580
+ this.transform(function(n) {
2581
+ if (typeof n == "string")
2582
+ try {
2583
+ n = JSON.parse(n);
2584
+ } catch {
2585
+ n = null;
2586
+ }
2587
+ return this.isType(n) ? n : null;
2588
+ }), t && this.shape(t);
2589
+ });
2590
+ }
2591
+ _typeCheck(t) {
2592
+ return Mr(t) || typeof t == "function";
2593
+ }
2594
+ _cast(t, r = {}) {
2595
+ var n;
2596
+ let a = super._cast(t, r);
2597
+ if (a === void 0)
2598
+ return this.getDefault();
2599
+ if (!this._typeCheck(a))
2600
+ return a;
2601
+ let i = this.fields, s = (n = r.stripUnknown) != null ? n : this.spec.noUnknown, o = this._nodes.concat(Object.keys(a).filter((d) => this._nodes.indexOf(d) === -1)), c = {}, u = fe({}, r, {
2602
+ parent: c,
2603
+ __validating: r.__validating || !1
2604
+ }), l = !1;
2605
+ for (const d of o) {
2606
+ let f = i[d], p = Ue(a, d);
2607
+ if (f) {
2608
+ let m, v = a[d];
2609
+ u.path = (r.path ? `${r.path}.` : "") + d, f = f.resolve({
2610
+ value: v,
2611
+ context: r.context,
2612
+ parent: c
2613
+ });
2614
+ let g = "spec" in f ? f.spec : void 0, S = g == null ? void 0 : g.strict;
2615
+ if (g != null && g.strip) {
2616
+ l = l || d in a;
2617
+ continue;
2618
+ }
2619
+ m = !r.__validating || !S ? (
2620
+ // TODO: use _cast, this is double resolving
2621
+ f.cast(a[d], u)
2622
+ ) : a[d], m !== void 0 && (c[d] = m);
2623
+ } else
2624
+ p && !s && (c[d] = a[d]);
2625
+ c[d] !== a[d] && (l = !0);
2626
+ }
2627
+ return l ? c : a;
2628
+ }
2629
+ _validate(t, r = {}, n) {
2630
+ let a = [], {
2631
+ sync: i,
2632
+ from: s = [],
2633
+ originalValue: o = t,
2634
+ abortEarly: c = this.spec.abortEarly,
2635
+ recursive: u = this.spec.recursive
2636
+ } = r;
2637
+ s = [{
2638
+ schema: this,
2639
+ value: o
2640
+ }, ...s], r.__validating = !0, r.originalValue = o, r.from = s, super._validate(t, r, (l, d) => {
2641
+ if (l) {
2642
+ if (!D.isError(l) || c)
2643
+ return void n(l, d);
2644
+ a.push(l);
2645
+ }
2646
+ if (!u || !Mr(d)) {
2647
+ n(a[0] || null, d);
2648
+ return;
2649
+ }
2650
+ o = o || d;
2651
+ let f = this._nodes.map((p) => (m, v) => {
2652
+ let g = p.indexOf(".") === -1 ? (r.path ? `${r.path}.` : "") + p : `${r.path || ""}["${p}"]`, S = this.fields[p];
2653
+ if (S && "validate" in S) {
2654
+ S.validate(d[p], fe({}, r, {
2655
+ // @ts-ignore
2656
+ path: g,
2657
+ from: s,
2658
+ // inner fields are always strict:
2659
+ // 1. this isn't strict so the casting will also have cast inner values
2660
+ // 2. this is strict in which case the nested values weren't cast either
2661
+ strict: !0,
2662
+ parent: d,
2663
+ originalValue: o[p]
2664
+ }), v);
2665
+ return;
2666
+ }
2667
+ v(null);
2668
+ });
2669
+ je({
2670
+ sync: i,
2671
+ tests: f,
2672
+ value: d,
2673
+ errors: a,
2674
+ endEarly: c,
2675
+ sort: this._sortErrors,
2676
+ path: r.path
2677
+ }, n);
2678
+ });
2679
+ }
2680
+ clone(t) {
2681
+ const r = super.clone(t);
2682
+ return r.fields = fe({}, this.fields), r._nodes = this._nodes, r._excludedEdges = this._excludedEdges, r._sortErrors = this._sortErrors, r;
2683
+ }
2684
+ concat(t) {
2685
+ let r = super.concat(t), n = r.fields;
2686
+ for (let [a, i] of Object.entries(this.fields)) {
2687
+ const s = n[a];
2688
+ s === void 0 ? n[a] = i : s instanceof I && i instanceof I && (n[a] = i.concat(s));
2689
+ }
2690
+ return r.withMutation(() => r.shape(n, this._excludedEdges));
2691
+ }
2692
+ getDefaultFromShape() {
2693
+ let t = {};
2694
+ return this._nodes.forEach((r) => {
2695
+ const n = this.fields[r];
2696
+ t[r] = "default" in n ? n.getDefault() : void 0;
2697
+ }), t;
2698
+ }
2699
+ _getDefault() {
2700
+ if ("default" in this.spec)
2701
+ return super._getDefault();
2702
+ if (this._nodes.length)
2703
+ return this.getDefaultFromShape();
2704
+ }
2705
+ shape(t, r = []) {
2706
+ let n = this.clone(), a = Object.assign(n.fields, t);
2707
+ return n.fields = a, n._sortErrors = ta(Object.keys(a)), r.length && (Array.isArray(r[0]) || (r = [r]), n._excludedEdges = [...n._excludedEdges, ...r]), n._nodes = Ay(a, n._excludedEdges), n;
2708
+ }
2709
+ pick(t) {
2710
+ const r = {};
2711
+ for (const n of t)
2712
+ this.fields[n] && (r[n] = this.fields[n]);
2713
+ return this.clone().withMutation((n) => (n.fields = {}, n.shape(r)));
2714
+ }
2715
+ omit(t) {
2716
+ const r = this.clone(), n = r.fields;
2717
+ r.fields = {};
2718
+ for (const a of t)
2719
+ delete n[a];
2720
+ return r.withMutation(() => r.shape(n));
2721
+ }
2722
+ from(t, r, n) {
2723
+ let a = et.getter(t, !0);
2724
+ return this.transform((i) => {
2725
+ if (i == null)
2726
+ return i;
2727
+ let s = i;
2728
+ return Ue(i, t) && (s = fe({}, i), n || delete s[t], s[r] = a(i)), s;
2729
+ });
2730
+ }
2731
+ noUnknown(t = !0, r = mt.noUnknown) {
2732
+ typeof t == "string" && (r = t, t = !0);
2733
+ let n = this.test({
2734
+ name: "noUnknown",
2735
+ exclusive: !0,
2736
+ message: r,
2737
+ test(a) {
2738
+ if (a == null)
2739
+ return !0;
2740
+ const i = wy(this.schema, a);
2741
+ return !t || i.length === 0 || this.createError({
2742
+ params: {
2743
+ unknown: i.join(", ")
2744
+ }
2745
+ });
2746
+ }
2747
+ });
2748
+ return n.spec.noUnknown = t, n;
2749
+ }
2750
+ unknown(t = !0, r = mt.noUnknown) {
2751
+ return this.noUnknown(!t, r);
2752
+ }
2753
+ transformKeys(t) {
2754
+ return this.transform((r) => r && gy(r, (n, a) => t(a)));
2755
+ }
2756
+ camelCase() {
2757
+ return this.transformKeys(dy);
2758
+ }
2759
+ snakeCase() {
2760
+ return this.transformKeys(Rr);
2761
+ }
2762
+ constantCase() {
2763
+ return this.transformKeys((t) => Rr(t).toUpperCase());
2764
+ }
2765
+ describe() {
2766
+ let t = super.describe();
2767
+ return t.fields = En(this.fields, (r) => r.describe()), t;
2768
+ }
2769
+ }
2770
+ function y(e) {
2771
+ return new ra(e);
2772
+ }
2773
+ y.prototype = ra.prototype;
2774
+ function Ke() {
2775
+ return Ke = Object.assign || function(e) {
2776
+ for (var t = 1; t < arguments.length; t++) {
2777
+ var r = arguments[t];
2778
+ for (var n in r)
2779
+ Object.prototype.hasOwnProperty.call(r, n) && (e[n] = r[n]);
2780
+ }
2781
+ return e;
2782
+ }, Ke.apply(this, arguments);
2783
+ }
2784
+ function B(e) {
2785
+ return new na(e);
2786
+ }
2787
+ class na extends I {
2788
+ constructor(t) {
2789
+ super({
2790
+ type: "array"
2791
+ }), this.innerType = void 0, this.innerType = t, this.withMutation(() => {
2792
+ this.transform(function(r) {
2793
+ if (typeof r == "string")
2794
+ try {
2795
+ r = JSON.parse(r);
2796
+ } catch {
2797
+ r = null;
2798
+ }
2799
+ return this.isType(r) ? r : null;
2800
+ });
2801
+ });
2802
+ }
2803
+ _typeCheck(t) {
2804
+ return Array.isArray(t);
2805
+ }
2806
+ get _subType() {
2807
+ return this.innerType;
2808
+ }
2809
+ _cast(t, r) {
2810
+ const n = super._cast(t, r);
2811
+ if (!this._typeCheck(n) || !this.innerType)
2812
+ return n;
2813
+ let a = !1;
2814
+ const i = n.map((s, o) => {
2815
+ const c = this.innerType.cast(s, Ke({}, r, {
2816
+ path: `${r.path || ""}[${o}]`
2817
+ }));
2818
+ return c !== s && (a = !0), c;
2819
+ });
2820
+ return a ? i : n;
2821
+ }
2822
+ _validate(t, r = {}, n) {
2823
+ var a, i;
2824
+ let s = [], o = r.sync, c = r.path, u = this.innerType, l = (a = r.abortEarly) != null ? a : this.spec.abortEarly, d = (i = r.recursive) != null ? i : this.spec.recursive, f = r.originalValue != null ? r.originalValue : t;
2825
+ super._validate(t, r, (p, m) => {
2826
+ if (p) {
2827
+ if (!D.isError(p) || l)
2828
+ return void n(p, m);
2829
+ s.push(p);
2830
+ }
2831
+ if (!d || !u || !this._typeCheck(m)) {
2832
+ n(s[0] || null, m);
2833
+ return;
2834
+ }
2835
+ f = f || m;
2836
+ let v = new Array(m.length);
2837
+ for (let g = 0; g < m.length; g++) {
2838
+ let S = m[g], b = `${r.path || ""}[${g}]`, C = Ke({}, r, {
2839
+ path: b,
2840
+ strict: !0,
2841
+ parent: m,
2842
+ index: g,
2843
+ originalValue: f[g]
2844
+ });
2845
+ v[g] = (x, $) => u.validate(S, C, $);
2846
+ }
2847
+ je({
2848
+ sync: o,
2849
+ path: c,
2850
+ value: m,
2851
+ errors: s,
2852
+ endEarly: l,
2853
+ tests: v
2854
+ }, n);
2855
+ });
2856
+ }
2857
+ clone(t) {
2858
+ const r = super.clone(t);
2859
+ return r.innerType = this.innerType, r;
2860
+ }
2861
+ concat(t) {
2862
+ let r = super.concat(t);
2863
+ return r.innerType = this.innerType, t.innerType && (r.innerType = r.innerType ? (
2864
+ // @ts-expect-error Lazy doesn't have concat()
2865
+ r.innerType.concat(t.innerType)
2866
+ ) : t.innerType), r;
2867
+ }
2868
+ of(t) {
2869
+ let r = this.clone();
2870
+ if (!Lt(t))
2871
+ throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: " + pe(t));
2872
+ return r.innerType = t, r;
2873
+ }
2874
+ length(t, r = qe.length) {
2875
+ return this.test({
2876
+ message: r,
2877
+ name: "length",
2878
+ exclusive: !0,
2879
+ params: {
2880
+ length: t
2881
+ },
2882
+ test(n) {
2883
+ return E(n) || n.length === this.resolve(t);
2884
+ }
2885
+ });
2886
+ }
2887
+ min(t, r) {
2888
+ return r = r || qe.min, this.test({
2889
+ message: r,
2890
+ name: "min",
2891
+ exclusive: !0,
2892
+ params: {
2893
+ min: t
2894
+ },
2895
+ // FIXME(ts): Array<typeof T>
2896
+ test(n) {
2897
+ return E(n) || n.length >= this.resolve(t);
2898
+ }
2899
+ });
2900
+ }
2901
+ max(t, r) {
2902
+ return r = r || qe.max, this.test({
2903
+ message: r,
2904
+ name: "max",
2905
+ exclusive: !0,
2906
+ params: {
2907
+ max: t
2908
+ },
2909
+ test(n) {
2910
+ return E(n) || n.length <= this.resolve(t);
2911
+ }
2912
+ });
2913
+ }
2914
+ ensure() {
2915
+ return this.default(() => []).transform((t, r) => this._typeCheck(t) ? t : r == null ? [] : [].concat(r));
2916
+ }
2917
+ compact(t) {
2918
+ let r = t ? (n, a, i) => !t(n, a, i) : (n) => !!n;
2919
+ return this.transform((n) => n != null ? n.filter(r) : n);
2920
+ }
2921
+ describe() {
2922
+ let t = super.describe();
2923
+ return this.innerType && (t.innerType = this.innerType.describe()), t;
2924
+ }
2925
+ nullable(t = !0) {
2926
+ return super.nullable(t);
2927
+ }
2928
+ defined() {
2929
+ return super.defined();
2930
+ }
2931
+ required(t) {
2932
+ return super.required(t);
2933
+ }
2934
+ }
2935
+ B.prototype = na.prototype;
2936
+ const qr = B().of(
2937
+ y().shape({
2938
+ variantId: h().required(),
2939
+ productId: h().nullable(),
2940
+ quantity: Te().required(),
2941
+ sellingPlanId: h().nullable(),
2942
+ attributes: B().of(
2943
+ y().shape({
2944
+ key: h().required(),
2945
+ value: h().required()
2946
+ })
2947
+ ).nullable()
2948
+ })
2949
+ ), aa = y().shape({
2950
+ key: h().required(),
2951
+ value: h().required()
2952
+ }), Cy = y().shape({
2953
+ attributes: B().max(255).of(aa).required()
2954
+ }), Ty = y().shape({
2955
+ note: h()
2956
+ }), xy = y().shape({
2957
+ vaultKey: h().required(),
2958
+ scope: h()
2959
+ }), Py = y().shape({
2960
+ vaultKey: h().required(),
2961
+ key: h().required()
2962
+ }), Fy = y().shape({
2963
+ vaultKey: h().required(),
2964
+ key: h().required(),
2965
+ value: h()
2966
+ }), Oy = y().shape({
2967
+ vaultKey: h().required(),
2968
+ key: h().required()
2969
+ }), Iy = y().shape({
2970
+ vaultKey: h().required()
2971
+ }), Ny = y().shape({
2972
+ vaultKey: h().required()
2973
+ }), Dy = y().shape({
2974
+ vaultKey: h().required(),
2975
+ key: h().required()
2976
+ }), Ry = y().shape({
2977
+ productId: h().required(),
2978
+ variantId: h().required()
2979
+ }), Ly = B().of(
2980
+ y().shape({
2981
+ id: h().required(),
2982
+ name: h().required(),
2983
+ variants: B().of(Ry).required()
2984
+ })
2985
+ ), My = y().shape({ name: h().required().min(3) }), qy = h().required(), Uy = y().shape({
2986
+ productId: h().required(),
2987
+ variantId: h().required(),
2988
+ wishlistId: h().required()
2989
+ }), jy = $e().required().isTrue(), ky = y().shape({
2990
+ productId: h().required(),
2991
+ variantId: h().required(),
2992
+ wishlistId: h().required()
2993
+ }), Gy = $e().required().isTrue(), zy = y().shape({
2994
+ action: h().oneOf(["login", "create"], 'action must be either "login" or "create".').notRequired()
2995
+ }).notRequired(), Vy = $e().required().isTrue(), By = y().shape({
2996
+ appId: h().optional()
2997
+ }).nullable(), Ky = B().of(be()).nullable(), Wy = y().shape({
2998
+ appId: h().optional()
2999
+ }).nullable(), Jy = B().of(be()).nullable(), Zy = y().shape({
3000
+ appId: h().optional(),
3001
+ email: h().optional()
3002
+ }).nullable(), Yy = be().nullable(), Xy = y({
3003
+ appId: h().optional(),
3004
+ rewardId: h().required(),
3005
+ options: y().shape({}).optional()
3006
+ }), Qy = y().shape({
3007
+ appId: h().optional(),
3008
+ activityName: h().required(),
3009
+ activityType: h().optional(),
3010
+ activityUrl: h().optional()
3011
+ }).nullable(), Hy = y().shape({}), eg = y().shape({}).nullable(), tg = y().shape({
3012
+ appId: h().optional()
3013
+ }).nullable(), rg = B().of(be()).nullable(), ng = y().shape({
3014
+ appId: h().optional()
3015
+ }).nullable(), ag = be().nullable(), ig = y().shape({
3016
+ appId: h().optional(),
3017
+ version: h().required()
3018
+ }).nullable(), sg = y().shape({}).nullable(), Et = (e) => typeof e == "function" ? !1 : typeof e == "object" && e !== null ? !Object.values(e).some((t) => !Et(t)) : !0, og = (e) => {
3019
+ if (typeof e == "string")
3020
+ try {
3021
+ JSON.parse(e);
3022
+ } catch {
3023
+ return !1;
3024
+ }
3025
+ return typeof e == "object" && e !== null || Array.isArray(e) ? Et(e) : !1;
3026
+ }, cg = y().shape({
3027
+ analyticEvent: h().required(),
3028
+ analyticProperties: y().test("is-json", "Field must be a valid JSON object or array", og).required()
3029
+ }), ug = $e().required().isTrue();
3030
+ y().shape({
3031
+ firstName: h().required(),
3032
+ lastName: h().required(),
3033
+ address1: h().required(),
3034
+ address2: h(),
3035
+ city: h().required(),
3036
+ province: h().required(),
3037
+ country: h().required(),
3038
+ zip: h().required(),
3039
+ phone: h()
3040
+ });
3041
+ const lg = y().shape({
3042
+ discountCode: h().required()
3043
+ }), dg = y().shape({
3044
+ cartId: h().required(),
3045
+ appId: h().required()
3046
+ }), fg = y().shape({
3047
+ giftCardId: h().required(),
3048
+ cartId: h().required(),
3049
+ appId: h().required()
3050
+ }), pg = y().shape({
3051
+ giftCardCode: h().required(),
3052
+ cartId: h().required(),
3053
+ appId: h().required()
3054
+ }), hg = y().shape({
3055
+ hostname: h().required()
3056
+ }), mg = y().shape({
3057
+ hostname: h().required()
3058
+ }), yg = y().shape({
3059
+ cartId: h().required(),
3060
+ payment: y().required(),
3061
+ appId: h().required()
3062
+ }), gg = y().shape({
3063
+ cartId: h().required(),
3064
+ shippingContact: y().required(),
3065
+ displayName: h().required(),
3066
+ appId: h().required()
3067
+ }), vg = y().shape({
3068
+ cartId: h().required(),
3069
+ paymentMethod: y().required(),
3070
+ displayName: h().required(),
3071
+ appId: h().required()
3072
+ }), _g = y().shape({
3073
+ cartId: h().required(),
3074
+ shippingMethod: y().required(),
3075
+ displayName: h().required(),
3076
+ appId: h().required()
3077
+ }), Sg = (e) => {
3078
+ try {
3079
+ return !!new URL(e);
3080
+ } catch {
3081
+ return !1;
3082
+ }
3083
+ }, ia = [
3084
+ {
3085
+ functionName: "addToCart",
3086
+ actionName: "cart/add",
3087
+ schema: y().shape({
3088
+ cartAttributes: B().of(aa),
3089
+ lineItems: qr
3090
+ })
3091
+ },
3092
+ {
3093
+ functionName: "applyDiscount",
3094
+ actionName: "discount/apply",
3095
+ schema: y().shape({
3096
+ discountCode: h().required()
3097
+ })
3098
+ },
3099
+ {
3100
+ functionName: "removeDiscounts",
3101
+ actionName: "discount/remove/all",
3102
+ schema: null
3103
+ },
3104
+ {
3105
+ functionName: "removeDiscount",
3106
+ actionName: "discount/remove",
3107
+ schema: lg
3108
+ },
3109
+ {
3110
+ functionName: "applyGiftCard",
3111
+ actionName: "giftcard/apply",
3112
+ schema: pg
3113
+ },
3114
+ {
3115
+ functionName: "removeGiftCard",
3116
+ actionName: "giftcard/remove",
3117
+ schema: fg
3118
+ },
3119
+ {
3120
+ functionName: "getGiftCard",
3121
+ actionName: "giftcard/get",
3122
+ schema: dg
3123
+ },
3124
+ {
3125
+ functionName: "openCart",
3126
+ actionName: "cart/open",
3127
+ schema: null
3128
+ },
3129
+ {
3130
+ functionName: "authenticationOpen",
3131
+ actionName: "authentication/open",
3132
+ schema: zy,
3133
+ successSchema: Vy
3134
+ },
3135
+ {
3136
+ functionName: "openCollection",
3137
+ actionName: "collection/open",
3138
+ schema: y().shape({
3139
+ collectionId: h().required()
3140
+ })
3141
+ },
3142
+ {
3143
+ functionName: "openProduct",
3144
+ actionName: "product/open",
3145
+ schema: y().shape({
3146
+ productId: h().required(),
3147
+ variantId: h(),
3148
+ isRelatedProduct: $e()
3149
+ })
3150
+ },
3151
+ {
3152
+ functionName: "showToast",
3153
+ actionName: "app/toast",
3154
+ schema: y().shape({
3155
+ message: h().required(),
3156
+ type: h().required().oneOf(["success", "warning", "error"])
3157
+ })
3158
+ },
3159
+ {
3160
+ functionName: "updateView",
3161
+ actionName: "view/updated",
3162
+ schema: y().shape({
3163
+ height: Te().required(),
3164
+ width: Te().required(),
3165
+ multiplier: Te().required()
3166
+ })
3167
+ },
3168
+ {
3169
+ functionName: "getCustomerIdentity",
3170
+ actionName: "customer/identity",
3171
+ schema: null
3172
+ },
3173
+ {
3174
+ functionName: "renderView",
3175
+ actionName: "view/rendered",
3176
+ schema: null
3177
+ },
3178
+ {
3179
+ functionName: "openScreen",
3180
+ actionName: "screen/open",
3181
+ schema: y().shape({
3182
+ destination: y().shape({
3183
+ type: h().oneOf(
3184
+ ["internal", "web"],
3185
+ 'Type must be either "internal" or "web".'
3186
+ ).required("Type is required."),
3187
+ url: h().test("valid-url", "URL is not valid.", function(e) {
3188
+ const { type: t } = this.parent;
3189
+ return t === "internal" ? !0 : t === "web" ? Sg(e) : !1;
3190
+ }).required("URL is required.")
3191
+ }).required("Destination is required.")
3192
+ })
3193
+ },
3194
+ {
3195
+ functionName: "scrollToBlockTop",
3196
+ actionName: "view/scrollToBlockTop",
3197
+ schema: null
3198
+ },
3199
+ {
3200
+ functionName: "scrollToBlockBottom",
3201
+ actionName: "view/scrollToBlockBottom",
3202
+ schema: null
3203
+ },
3204
+ {
3205
+ functionName: "removeFromCart",
3206
+ actionName: "cart/remove",
3207
+ schema: y().shape({
3208
+ lineItems: qr
3209
+ })
3210
+ },
3211
+ {
3212
+ functionName: "trackAnalyticEvent",
3213
+ actionName: "analytics/track",
3214
+ schema: cg,
3215
+ successSchema: ug
3216
+ },
3217
+ {
3218
+ functionName: "updateCartAttributes",
3219
+ actionName: "cart/updateAttributes",
3220
+ schema: Cy
3221
+ },
3222
+ {
3223
+ functionName: "updateCartNote",
3224
+ actionName: "cart/updateNote",
3225
+ schema: Ty
3226
+ },
3227
+ {
3228
+ functionName: "vaultInitialize",
3229
+ actionName: "vault/initialize",
3230
+ schema: xy
3231
+ },
3232
+ {
3233
+ functionName: "vaultGet",
3234
+ actionName: "vault/get",
3235
+ schema: Py
3236
+ },
3237
+ {
3238
+ functionName: "vaultSet",
3239
+ actionName: "vault/set",
3240
+ schema: Fy
3241
+ },
3242
+ {
3243
+ functionName: "vaultRemove",
3244
+ actionName: "vault/remove",
3245
+ schema: Oy
3246
+ },
3247
+ {
3248
+ functionName: "vaultClear",
3249
+ actionName: "vault/clear",
3250
+ schema: Iy
3251
+ },
3252
+ {
3253
+ functionName: "vaultKeys",
3254
+ actionName: "vault/keys",
3255
+ schema: Ny
3256
+ },
3257
+ {
3258
+ functionName: "vaultObserve",
3259
+ actionName: "vault/observe",
3260
+ schema: Dy
3261
+ },
3262
+ {
3263
+ functionName: "wishlistCreate",
3264
+ actionName: "wishlist/create",
3265
+ schema: My,
3266
+ successSchema: qy
3267
+ },
3268
+ {
3269
+ functionName: "wishlistsGet",
3270
+ actionName: "wishlists/get",
3271
+ schema: null,
3272
+ successSchema: Ly
3273
+ },
3274
+ {
3275
+ functionName: "wishlistItemAdd",
3276
+ actionName: "wishlist/item/add",
3277
+ schema: Uy,
3278
+ successSchema: jy
3279
+ },
3280
+ {
3281
+ functionName: "wishlistItemRemove",
3282
+ actionName: "wishlist/item/remove",
3283
+ schema: ky,
3284
+ successSchema: Gy
3285
+ },
3286
+ {
3287
+ functionName: "getLoyaltyRewards",
3288
+ actionName: "loyalty/rewards",
3289
+ schema: By,
3290
+ successSchema: Ky
3291
+ },
3292
+ {
3293
+ functionName: "getLoyaltyHistory",
3294
+ actionName: "loyalty/history",
3295
+ schema: Wy,
3296
+ successSchema: Jy
3297
+ },
3298
+ {
3299
+ functionName: "getLoyaltyCustomer",
3300
+ actionName: "loyalty/customer",
3301
+ schema: Zy,
3302
+ successSchema: Yy
3303
+ },
3304
+ {
3305
+ functionName: "getLoyaltyTiers",
3306
+ actionName: "loyalty/tiers",
3307
+ schema: tg,
3308
+ successSchema: rg
3309
+ },
3310
+ {
3311
+ functionName: "getLoyaltyCustomerTier",
3312
+ actionName: "loyalty/customer/tier",
3313
+ schema: ng,
3314
+ successSchema: ag
3315
+ },
3316
+ {
3317
+ functionName: "redeemLoyaltyReward",
3318
+ actionName: "loyalty/redeem/reward",
3319
+ schema: Xy,
3320
+ successSchema: Hy
3321
+ },
3322
+ {
3323
+ functionName: "recordLoyaltyActivity",
3324
+ actionName: "loyalty/record/activity",
3325
+ schema: Qy,
3326
+ successSchema: eg
3327
+ },
3328
+ {
3329
+ functionName: "loyaltyAcceptLegal",
3330
+ actionName: "loyalty/accept/legal",
3331
+ schema: ig,
3332
+ successSchema: sg
3333
+ },
3334
+ {
3335
+ functionName: "applePayStartSessionURL",
3336
+ actionName: "cart/applePayStartSessionURL",
3337
+ schema: hg
3338
+ },
3339
+ {
3340
+ functionName: "getApplePayDomainName",
3341
+ actionName: "cart/getApplePayDomainName",
3342
+ schema: mg
3343
+ },
3344
+ {
3345
+ functionName: "applePayOnPaymentAuthorized",
3346
+ actionName: "cart/applePayOnPaymentAuthorized",
3347
+ schema: yg
3348
+ },
3349
+ {
3350
+ functionName: "applePayOnShippingContactSelected",
3351
+ actionName: "cart/applePayOnShippingContactSelected",
3352
+ schema: gg
3353
+ },
3354
+ {
3355
+ functionName: "applePayOnPaymentMethodSelected",
3356
+ actionName: "cart/applePayOnPaymentMethodSelected",
3357
+ schema: vg
3358
+ },
3359
+ {
3360
+ functionName: "applePayOnShippingMethodSelected",
3361
+ actionName: "cart/applePayOnShippingMethodSelected",
3362
+ schema: _g
3363
+ }
3364
+ ], M = {
3365
+ PLATFORM_IOS: "ios",
3366
+ PLATFORM_ANDROID: "android",
3367
+ PLATFORM_EDITOR: "editor",
3368
+ ACTION_RESPONSE_SUCCESS: "success",
3369
+ ACTION_RESPONSE_ERROR: "error",
3370
+ TAPCART_SDK: "tapcart-sdk"
3371
+ }, sa = async (e, t, r = {}) => {
3372
+ var n;
3373
+ try {
3374
+ const { appId: a, cartId: i } = t;
3375
+ if (!a)
3376
+ throw new Error("AppIdMissing");
3377
+ if (!i)
3378
+ throw new Error("CartIdMissing");
3379
+ const s = {
3380
+ ...t,
3381
+ cartId: i
3382
+ }, o = `/${a}/api/v1/cart/${e}`, c = await fetch(o, {
3383
+ method: "POST",
3384
+ headers: {
3385
+ "Content-Type": "application/json",
3386
+ "X-Cart-ID": i
3387
+ // Also include as header for redundancy
3388
+ },
3389
+ body: JSON.stringify(s)
3390
+ });
3391
+ if (!c.ok) {
3392
+ const l = await c.json(), d = new Error(l.error || "Error");
3393
+ if (r.onError)
3394
+ return r.onError(d), null;
3395
+ throw d;
3396
+ }
3397
+ const u = await c.json();
3398
+ return (n = u == null ? void 0 : u.cart) != null && n.id && u.cart.id !== i && localStorage.setItem("cartId", u.cart.id), r.onSuccess && r.onSuccess(u), u;
3399
+ } catch (a) {
3400
+ if (console.error(`Error in cart operation ${e}:`, a), r.onError)
3401
+ return r.onError(a.message || "Error"), null;
3402
+ throw a.message || "Error";
3403
+ }
3404
+ }, j = (e, t, r = {}) => sa(e, t, r), bg = async (e, t) => j("applyGiftCard", e, t), $g = (e, t) => j("getGiftCard", e, t), Ag = (e, t) => j("removeDiscount", e, t), wg = (e, t) => j("removeGiftCard", e, t), Eg = (e, t) => j("updateApplePay", e, t), Cg = (e, t) => j("submitForCompletion", e, t), Tg = (e, t) => j("addDeliveryAddress", e, t), xg = (e, t) => j("updateDeliveryAddress", e, t), Pg = (e, t) => j("removeDeliveryAddress", e, t), Fg = (e, t) => j("updateSelectedDeliveryOptions", e, t), xe = (e, t) => j("prepareForCompletion", e, t), oa = (e, t) => j("updateBuyerIdentity", e, t), Og = ({ hostname: e }) => `${(e == null ? void 0 : e.includes("tapc.studio")) ? "https://api.tapcart.xyz" : "https://api.tapcart.com"}/public/apple-pay/session`, Ig = ({ hostname: e, appId: t }) => {
3405
+ const r = e == null ? void 0 : e.includes("tapc.studio"), n = t.toLowerCase();
3406
+ return r ? `${n}.tapc.studio` : `${n}.tapcart.studio`;
3407
+ }, Ng = async (e, t) => {
3408
+ var i, s, o, c;
3409
+ const { cartId: r, payment: n, appId: a } = e;
3410
+ if (r) {
3411
+ const { billingContact: u, shippingContact: l } = n;
3412
+ let d = null;
3413
+ try {
3414
+ const f = ($) => {
3415
+ const {
3416
+ addressLines: _,
3417
+ locality: N,
3418
+ country: R,
3419
+ givenName: G,
3420
+ familyName: L,
3421
+ phoneNumber: F,
3422
+ administrativeArea: K,
3423
+ postalCode: z,
3424
+ emailAddress: T
3425
+ } = $, w = {};
3426
+ if (Array.isArray(_) && _.length > 0) {
3427
+ const [Ae] = _;
3428
+ w.address1 = Ae;
3429
+ }
3430
+ if (Array.isArray(_) && _.length > 1) {
3431
+ const [, Ae] = _;
3432
+ w.address2 = Ae;
3433
+ }
3434
+ return N && (w.city = N), w.company = "", R && (w.country = R), G && (w.firstName = G), L && (w.lastName = L), T && (w.email = T), F && (w.phone = F), K && (w.province = K), z && (w.zip = z), w;
3435
+ }, p = {
3436
+ cartId: r,
3437
+ appId: a
3438
+ };
3439
+ l != null && l.countryCode && (p.countryCode = l.countryCode), l != null && l.emailAddress && (p.email = l.emailAddress), l != null && l.phoneNumber && (p.phone = l.phoneNumber), await oa(p), d = await xe({ cartId: r, appId: a });
3440
+ const m = {
3441
+ cartId: r,
3442
+ appId: a,
3443
+ billingAddress: f(u)
3444
+ };
3445
+ (s = (i = d == null ? void 0 : d.cost) == null ? void 0 : i.totalAmount) != null && s.amount && (m.amount = d.cost.totalAmount.amount), (c = (o = d == null ? void 0 : d.cost) == null ? void 0 : o.totalAmount) != null && c.currencyCode && (m.currencyCode = d.cost.totalAmount.currencyCode);
3446
+ const { token: v } = n, { data: g, signature: S, version: b, header: C } = v.paymentData;
3447
+ m.data = g, m.signature = S, m.version = b, m.header = C, await Eg(m), await xe({ cartId: r, appId: a });
3448
+ const x = crypto.randomUUID();
3449
+ return await Cg({
3450
+ attemptToken: x,
3451
+ cartId: r,
3452
+ appId: a
3453
+ }, t);
3454
+ } catch (f) {
3455
+ if (console.error("Error in applePayOnPaymentAuthorized:", f), t != null && t.onError)
3456
+ return t.onError(f), null;
3457
+ throw f;
3458
+ }
3459
+ }
3460
+ return null;
3461
+ }, Dg = async (e, t) => {
3462
+ var o, c, u, l, d, f, p, m, v, g, S;
3463
+ const { cartId: r, shippingContact: n, displayName: a, appId: i } = e;
3464
+ let s = null;
3465
+ try {
3466
+ const b = ($) => {
3467
+ const {
3468
+ addressLines: _,
3469
+ locality: N,
3470
+ countryCode: R,
3471
+ givenName: G,
3472
+ familyName: L,
3473
+ phoneNumber: F,
3474
+ administrativeArea: K,
3475
+ postalCode: z
3476
+ } = $, T = {};
3477
+ if (Array.isArray(_) && _.length > 0) {
3478
+ const [w] = _;
3479
+ T.address1 = w;
3480
+ }
3481
+ if (Array.isArray(_) && _.length > 1) {
3482
+ const [, w] = _;
3483
+ T.address2 = w;
3484
+ }
3485
+ return N && (T.city = N), R && (T.countryCode = R), G && (T.firstName = G), L && (T.lastName = L), F && (T.phone = F), K && (T.provinceCode = K), z && (T.zip = z), T;
3486
+ }, C = {
3487
+ cartId: r,
3488
+ appId: i
3489
+ };
3490
+ if (n != null && n.countryCode && (C.countryCode = n.countryCode), n != null && n.emailAddress && (C.email = n.emailAddress), n != null && n.phoneNumber && (C.phone = n.phoneNumber), await oa(C), s = await sa("getCart", { cartId: r, appId: i }), (((c = (o = s == null ? void 0 : s.cart) == null ? void 0 : o.delivery) == null ? void 0 : c.addresses) ?? []).length > 1 && await Pg({
3491
+ cartId: r,
3492
+ appId: i,
3493
+ deliveryAddressIds: s.cart.delivery.addresses.map(($) => $.id)
3494
+ }), n) {
3495
+ if (((d = (l = (u = s == null ? void 0 : s.cart) == null ? void 0 : u.delivery) == null ? void 0 : l.addresses) == null ? void 0 : d.length) === 0)
3496
+ await Tg({
3497
+ cartId: r,
3498
+ appId: i,
3499
+ addresses: [
3500
+ {
3501
+ address: {
3502
+ deliveryAddress: b(n)
3503
+ },
3504
+ oneTimeUse: !0,
3505
+ selected: !0,
3506
+ validationStrategy: "COUNTRY_CODE_ONLY"
3507
+ }
3508
+ ]
3509
+ });
3510
+ else if (((m = (p = (f = s == null ? void 0 : s.cart) == null ? void 0 : f.delivery) == null ? void 0 : p.addresses) == null ? void 0 : m.length) === 1) {
3511
+ const $ = s.cart.delivery.addresses[0];
3512
+ await xg({
3513
+ cartId: r,
3514
+ appId: i,
3515
+ addresses: [
3516
+ {
3517
+ id: $.id,
3518
+ address: {
3519
+ deliveryAddress: b(n)
3520
+ }
3521
+ }
3522
+ ]
3523
+ });
3524
+ }
3525
+ }
3526
+ return s = await xe({ cartId: r, appId: i }), {
3527
+ shippingMethods: (($) => {
3528
+ const _ = $[0], { deliveryOptions: N } = _;
3529
+ return N.map((R) => {
3530
+ const { title: G, estimatedCost: L, description: F, handle: K } = R, { id: z } = _, T = {
3531
+ label: G,
3532
+ identifier: `${z},${K}`
3533
+ };
3534
+ return L != null && L.amount && (T.amount = L.amount), F && (T.detail = F), T;
3535
+ });
3536
+ })(s.cart.deliveryGroups),
3537
+ total: {
3538
+ label: a,
3539
+ amount: (S = (g = (v = s.cart) == null ? void 0 : v.cost) == null ? void 0 : g.totalAmount) == null ? void 0 : S.amount
3540
+ }
3541
+ };
3542
+ } catch (b) {
3543
+ if (console.error("Error in applePayOnShippingContactSelected:", b), t != null && t.onError)
3544
+ return t.onError(b), null;
3545
+ throw b;
3546
+ }
3547
+ }, Rg = async (e, t) => {
3548
+ var i, s, o;
3549
+ const { cartId: r, displayName: n, appId: a } = e;
3550
+ try {
3551
+ const c = await xe({ cartId: r, appId: a });
3552
+ return {
3553
+ total: {
3554
+ label: n,
3555
+ type: "final",
3556
+ amount: (o = (s = (i = c.cart) == null ? void 0 : i.cost) == null ? void 0 : s.totalAmount) == null ? void 0 : o.amount
3557
+ }
3558
+ };
3559
+ } catch (c) {
3560
+ if (console.error("Error in applePayOnPaymentMethodSelected:", c), t != null && t.onError)
3561
+ return t.onError(c), null;
3562
+ throw c;
3563
+ }
3564
+ }, Lg = async (e, t) => {
3565
+ var s, o, c;
3566
+ const { cartId: r, shippingMethod: n, displayName: a, appId: i } = e;
3567
+ try {
3568
+ const u = (p) => {
3569
+ const [m = "", v = ""] = p.split(",");
3570
+ return { deliveryGroupId: m, deliveryOptionHandle: v };
3571
+ }, { deliveryGroupId: l, deliveryOptionHandle: d } = u(n.identifier);
3572
+ let f = await Fg({
3573
+ cartId: r,
3574
+ appId: i,
3575
+ selectedDeliveryOptions: [
3576
+ {
3577
+ deliveryGroupId: l,
3578
+ deliveryOptionHandle: d
3579
+ }
3580
+ ]
3581
+ });
3582
+ return f = await xe({ cartId: r, appId: i }), {
3583
+ total: {
3584
+ label: a,
3585
+ amount: (c = (o = (s = f.cart) == null ? void 0 : s.cost) == null ? void 0 : o.totalAmount) == null ? void 0 : c.amount
3586
+ }
3587
+ };
3588
+ } catch (u) {
3589
+ if (console.error("Error in applePayOnShippingMethodSelected:", u), t != null && t.onError)
3590
+ return t.onError(u), null;
3591
+ throw u;
3592
+ }
3593
+ }, Mg = (e) => ({
3594
+ applyGiftCard: e.actions.applyGiftCard,
3595
+ getGiftCard: e.actions.getGiftCard,
3596
+ applyDiscount: e.actions.applyDiscount,
3597
+ removeDiscount: e.actions.removeDiscount,
3598
+ removeGiftCard: e.actions.removeGiftCard,
3599
+ updateCartApplePay: e.actions.updateCartApplePay,
3600
+ submitCartForCompletion: e.actions.submitCartForCompletion,
3601
+ addDeliveryAddresses: e.actions.addDeliveryAddresses,
3602
+ updateDeliveryAddresses: e.actions.updateDeliveryAddresses,
3603
+ removeDeliveryAddresses: e.actions.removeDeliveryAddresses,
3604
+ updateSelectedDeliveryOptions: e.actions.updateSelectedDeliveryOptions,
3605
+ prepareForCompletion: e.actions.prepareForCompletion,
3606
+ updateBuyerIdentity: e.actions.updateBuyerIdentity,
3607
+ applePayStartSessionURL: e.actions.applePayStartSessionURL,
3608
+ getApplePayDomainName: e.actions.getApplePayDomainName,
3609
+ applePayOnPaymentAuthorized: e.actions.applePayOnPaymentAuthorized,
3610
+ applePayOnShippingContactSelected: e.actions.applePayOnShippingContactSelected,
3611
+ applePayOnPaymentMethodSelected: e.actions.applePayOnPaymentMethodSelected,
3612
+ applePayOnShippingMethodSelected: e.actions.applePayOnShippingMethodSelected
3613
+ }), ot = ({ cart: e, defaultHandler: t, onSuccess: r }) => {
3614
+ t({
3615
+ id: `refresh-${Math.random().toString(36).slice(2, 15)}`,
3616
+ type: "action",
3617
+ name: "cart/updateAttributes",
3618
+ data: {
3619
+ attributes: e.attributes
3620
+ }
3621
+ }), r(Zr(e));
3622
+ }, qg = async ({
3623
+ payload: e,
3624
+ defaultHandler: t
3625
+ }) => {
3626
+ const n = {
3627
+ "discount/remove": async (a, i) => Ag(
3628
+ { appId: a.data.appId, cartId: a.data.cartId, discountCode: a.data.discountCode },
3629
+ {
3630
+ onSuccess: (s) => {
3631
+ ot({ cart: s, defaultHandler: t, onSuccess: i == null ? void 0 : i.onSuccess });
3632
+ },
3633
+ onError: i == null ? void 0 : i.onError
3634
+ }
3635
+ ),
3636
+ "giftcard/apply": async (a, i) => bg(
3637
+ { appId: a.data.appId, giftCardCode: a.data.giftCardCode, cartId: a.data.cartId },
3638
+ {
3639
+ onSuccess: (s) => {
3640
+ ot({ cart: s, defaultHandler: t, onSuccess: i == null ? void 0 : i.onSuccess });
3641
+ },
3642
+ onError: i == null ? void 0 : i.onError
3643
+ }
3644
+ ),
3645
+ "giftcard/get": async (a, i) => $g(
3646
+ { appId: a.data.appId, cartId: a.data.cartId },
3647
+ {
3648
+ onSuccess: i == null ? void 0 : i.onSuccess,
3649
+ onError: i == null ? void 0 : i.onError
3650
+ }
3651
+ ),
3652
+ "giftcard/remove": async (a, i) => wg(
3653
+ { appId: a.data.appId, cartId: a.data.cartId, giftCardId: a.data.giftCardId },
3654
+ {
3655
+ onSuccess: (s) => {
3656
+ ot({ cart: s, defaultHandler: t, onSuccess: i == null ? void 0 : i.onSuccess });
3657
+ },
3658
+ onError: i == null ? void 0 : i.onError
3659
+ }
3660
+ ),
3661
+ // New Apple Pay handlers
3662
+ "cart/applePayStartSessionURL": async (a, i) => {
3663
+ try {
3664
+ const s = Og({
3665
+ hostname: a.data.hostname
3666
+ });
3667
+ return i == null || i.onSuccess(s), s;
3668
+ } catch (s) {
3669
+ throw i == null || i.onError(s), s;
3670
+ }
3671
+ },
3672
+ "cart/getApplePayDomainName": async (a, i) => {
3673
+ try {
3674
+ const s = Ig({
3675
+ hostname: a.data.hostname,
3676
+ appId: a.data.appId
3677
+ });
3678
+ return i == null || i.onSuccess(s), s;
3679
+ } catch (s) {
3680
+ throw i == null || i.onError(s), s;
3681
+ }
3682
+ },
3683
+ "cart/applePayOnPaymentAuthorized": async (a, i) => Ng(
3684
+ {
3685
+ cartId: a.data.cartId,
3686
+ payment: a.data.payment,
3687
+ appId: a.data.appId
3688
+ },
3689
+ {
3690
+ onSuccess: i == null ? void 0 : i.onSuccess,
3691
+ onError: i == null ? void 0 : i.onError
3692
+ }
3693
+ ),
3694
+ "cart/applePayOnShippingContactSelected": async (a, i) => Dg(
3695
+ {
3696
+ cartId: a.data.cartId,
3697
+ shippingContact: a.data.shippingContact,
3698
+ displayName: a.data.displayName,
3699
+ appId: a.data.appId
3700
+ },
3701
+ {
3702
+ onSuccess: i == null ? void 0 : i.onSuccess,
3703
+ onError: i == null ? void 0 : i.onError
3704
+ }
3705
+ ),
3706
+ "cart/applePayOnPaymentMethodSelected": async (a, i) => Rg(
3707
+ {
3708
+ cartId: a.data.cartId,
3709
+ paymentMethod: a.data.paymentMethod,
3710
+ displayName: a.data.displayName,
3711
+ appId: a.data.appId
3712
+ },
3713
+ {
3714
+ onSuccess: i == null ? void 0 : i.onSuccess,
3715
+ onError: i == null ? void 0 : i.onError
3716
+ }
3717
+ ),
3718
+ "cart/applePayOnShippingMethodSelected": async (a, i) => Lg(
3719
+ {
3720
+ cartId: a.data.cartId,
3721
+ shippingMethod: a.data.shippingMethod,
3722
+ displayName: a.data.displayName,
3723
+ appId: a.data.appId
3724
+ },
3725
+ {
3726
+ onSuccess: i == null ? void 0 : i.onSuccess,
3727
+ onError: i == null ? void 0 : i.onError
3728
+ }
3729
+ )
3730
+ }[e.name];
3731
+ if (!n)
3732
+ return t(e);
3733
+ try {
3734
+ const { id: a } = e;
3735
+ return await n(e, {
3736
+ onSuccess: (o) => {
3737
+ var c, u;
3738
+ return typeof ((u = (c = window == null ? void 0 : window.Tapcart) == null ? void 0 : c.mobile) == null ? void 0 : u.respond) == "function" && window.Tapcart.mobile.respond(a, "success", o), o;
3739
+ },
3740
+ onError: (o) => {
3741
+ var c, u;
3742
+ throw typeof ((u = (c = window == null ? void 0 : window.Tapcart) == null ? void 0 : c.mobile) == null ? void 0 : u.respond) == "function" && window.Tapcart.mobile.respond(a, "error", o), o;
3743
+ }
3744
+ });
3745
+ } catch (a) {
3746
+ throw console.error(`Error executing action ${e.name}:`, a), a;
3747
+ }
3748
+ }, ca = (e, t, r) => qg({
3749
+ payload: e,
3750
+ defaultHandler: t
3751
+ }).then((n) => {
3752
+ const a = e.name;
3753
+ return a.startsWith("cart/") && (n != null && n.cart) && r.notify("cart/updated", { cart: n.cart }), a.startsWith("giftcard/") && r.notify("giftCards/updated", { giftCards: n }), n;
3754
+ }).catch((n) => {
3755
+ throw console.error(`Error executing action ${e.name}:`, n), n;
3756
+ }), Ug = (e, t, r) => {
3757
+ const n = {}, a = (i, s, o) => (c, u = {}) => {
3758
+ let l;
3759
+ if (i)
3760
+ try {
3761
+ l = i.validateSync(c);
3762
+ } catch (f) {
3763
+ throw new Error(f.message);
3764
+ }
3765
+ const d = {
3766
+ id: Yr(),
3767
+ type: "action",
3768
+ name: s,
3769
+ data: l
3770
+ };
3771
+ (u.onSuccess || u.onError) && e(
3772
+ d.id,
3773
+ u.onSuccess,
3774
+ u.onError,
3775
+ o
3776
+ ), ca(d, t, r).catch(() => {
3777
+ });
3778
+ };
3779
+ for (const i of ia) {
3780
+ const { schema: s, functionName: o, actionName: c, successSchema: u } = i;
3781
+ n[o] = a(s, c, u);
3782
+ }
3783
+ return n;
3784
+ }, jg = (e, t) => {
3785
+ const r = {}, n = (o, c, u, l) => {
3786
+ let d;
3787
+ c && (d = (f) => {
3788
+ if (l)
3789
+ try {
3790
+ c(l.validateSync(f));
3791
+ } catch (p) {
3792
+ u && u(p);
3793
+ }
3794
+ else
3795
+ c(f);
3796
+ }), r[o] = {
3797
+ [M.ACTION_RESPONSE_SUCCESS]: d,
3798
+ [M.ACTION_RESPONSE_ERROR]: u
3799
+ };
3800
+ }, a = (o, c, u) => {
3801
+ var l;
3802
+ typeof ((l = r[o]) == null ? void 0 : l[c]) == "function" && r[o][c](u);
3803
+ };
3804
+ return {
3805
+ actions: Ug(n, e, t),
3806
+ respond: a,
3807
+ action: (o, c = null, u = {}) => {
3808
+ var d;
3809
+ if (!o)
3810
+ throw new Error("actionType is a required parameter");
3811
+ const l = {
3812
+ id: Yr(),
3813
+ type: "action",
3814
+ name: o,
3815
+ data: c
3816
+ };
3817
+ (u.onSuccess || u.onError) && n(
3818
+ l.id,
3819
+ u.onSuccess,
3820
+ u.onError,
3821
+ (d = ia.find((f) => f.actionName === o)) == null ? void 0 : d.successSchema
3822
+ ), ca(l, e, t).catch(() => {
3823
+ });
3824
+ }
3825
+ };
3826
+ }, Ur = [
3827
+ "cart/updated",
3828
+ "product/updated",
3829
+ "customer/updated",
3830
+ "variables/updated",
3831
+ "giftCards/updated"
3832
+ ], Ce = {
3833
+ CART_UPDATED: "cart/updated",
3834
+ PRODUCT_UPDATED: "product/updated",
3835
+ CUSTOMER_UPDATED: "customer/updated",
3836
+ VARIABLES_UPDATED: "variables/updated",
3837
+ GIFT_CARDS_UPDATED: "giftCards/updated"
3838
+ }, kg = (e, t) => {
3839
+ switch (e) {
3840
+ case Ce.CART_UPDATED:
3841
+ return { cart: t.cart || null };
3842
+ case Ce.PRODUCT_UPDATED:
3843
+ return { product: t.product || null };
3844
+ case Ce.CUSTOMER_UPDATED:
3845
+ return { customer: t.customer || null };
3846
+ case Ce.VARIABLES_UPDATED:
3847
+ return { ...t };
3848
+ case Ce.GIFT_CARDS_UPDATED:
3849
+ return { giftCards: t.giftCards || null };
3850
+ default:
3851
+ return t;
3852
+ }
3853
+ }, Gg = ({ setVariables: e }) => {
3854
+ const t = {};
3855
+ return {
3856
+ notify: (a, i) => {
3857
+ var s;
3858
+ if (!Ur.includes(a))
3859
+ throw new Error("Unsupported Event");
3860
+ (s = t[a]) != null && s.size && t[a].forEach((o) => o(i));
3861
+ },
3862
+ registerEventHandler: (a, i) => {
3863
+ if (!Ur.includes(a))
3864
+ throw new Error("Unsupported Event");
3865
+ if (typeof i != "function")
3866
+ throw new TypeError("Invalid Handler");
3867
+ const s = (o) => {
3868
+ o && e(kg(a, o)), i(o);
3869
+ };
3870
+ return t[a] ?? (t[a] = /* @__PURE__ */ new Set()), t[a].add(s), () => t[a].delete(s);
3871
+ }
3872
+ };
3873
+ }, zg = () => {
3874
+ let e;
3875
+ const t = (c, u) => window.webkit.messageHandlers[c].postMessage(
3876
+ JSON.stringify(u)
3877
+ ), r = (c, u) => window[c].postMessage(JSON.stringify(u)), n = (c, u) => {
3878
+ var l, d;
3879
+ console.log(u), window == null || window.postMessage(
3880
+ { type: M.TAPCART_SDK, message: JSON.stringify(u) },
3881
+ "*"
3882
+ ), (d = (l = window == null ? void 0 : window.parent) == null ? void 0 : l.window) == null || d.postMessage(
3883
+ { type: M.TAPCART_SDK, message: JSON.stringify(u) },
3884
+ "*"
3885
+ );
3886
+ }, a = {
3887
+ [M.PLATFORM_IOS]: t,
3888
+ [M.PLATFORM_ANDROID]: r,
3889
+ [M.PLATFORM_EDITOR]: n
3890
+ }, i = (c, u) => (l) => a[c](u, l);
3891
+ return {
3892
+ sendMessage: (c) => e(c),
3893
+ init: (c, u) => {
3894
+ if (!c || !u)
3895
+ throw new Error("Failed to initialize ActionBridge");
3896
+ if (c !== M.PLATFORM_IOS && c !== M.PLATFORM_ANDROID && c !== M.PLATFORM_EDITOR)
3897
+ throw new Error("Unknown Platform");
3898
+ if (c === M.PLATFORM_IOS && !window.webkit)
3899
+ throw new Error("Webview Interface not available");
3900
+ if (c === M.PLATFORM_ANDROID && !window[u])
3901
+ throw new Error("Webview Interface not available");
3902
+ e = i(c, u);
3903
+ }
3904
+ };
3905
+ };
3906
+ class te {
3907
+ constructor(t) {
3908
+ this.message = t;
3909
+ }
3910
+ }
3911
+ class Vg extends te {
3912
+ }
3913
+ class Bg extends te {
3914
+ }
3915
+ class Kg extends te {
3916
+ }
3917
+ class Wg extends te {
3918
+ }
3919
+ class Jg extends te {
3920
+ }
3921
+ class Zg extends te {
3922
+ }
3923
+ const Ct = {
3924
+ VaultAccessException: Vg,
3925
+ VaultBuildException: Bg,
3926
+ VaultInvalidArgumentException: Kg,
3927
+ VaultInvalidScopeException: Wg,
3928
+ VaultScopeModificationException: Jg,
3929
+ VaultUserException: te,
3930
+ VaultUserIdentifierException: Zg
3931
+ }, oe = (e) => {
3932
+ if (Object.values(Ct).some((r) => e instanceof r))
3933
+ return e;
3934
+ const t = Ct[e.type];
3935
+ return t ? new t(e.message) : new te("unknown error occurred");
3936
+ }, Yg = (e, t) => ({
3937
+ get: (n) => new Promise((a, i) => {
3938
+ t.actions.vaultGet(
3939
+ { vaultKey: e, key: n },
3940
+ {
3941
+ onSuccess: a,
3942
+ onError: (s) => i(oe(s))
3943
+ }
3944
+ );
3945
+ }),
3946
+ set: (n, a) => new Promise((i, s) => {
3947
+ t.actions.vaultSet(
3948
+ {
3949
+ vaultKey: e,
3950
+ key: n,
3951
+ value: a
3952
+ },
3953
+ {
3954
+ onSuccess: i,
3955
+ onError: (o) => s(oe(o))
3956
+ }
3957
+ );
3958
+ }),
3959
+ clear: () => new Promise((n, a) => {
3960
+ t.actions.vaultClear(
3961
+ {
3962
+ vaultKey: e
3963
+ },
3964
+ {
3965
+ onSuccess: n,
3966
+ onError: (i) => a(oe(i))
3967
+ }
3968
+ );
3969
+ }),
3970
+ remove: (n) => new Promise((a, i) => {
3971
+ t.actions.vaultRemove(
3972
+ {
3973
+ vaultKey: e,
3974
+ key: n
3975
+ },
3976
+ {
3977
+ onSuccess: a,
3978
+ onError: (s) => i(oe(s))
3979
+ }
3980
+ );
3981
+ }),
3982
+ keys: () => new Promise((n, a) => {
3983
+ t.actions.vaultKeys(
3984
+ {
3985
+ vaultKey: e
3986
+ },
3987
+ {
3988
+ onSuccess: n,
3989
+ onError: (i) => a(oe(i))
3990
+ }
3991
+ );
3992
+ }),
3993
+ observe: (n, a, i = () => {
3994
+ }) => new Promise((s, o) => {
3995
+ t.actions.vaultObserve(
3996
+ {
3997
+ vaultKey: e,
3998
+ key: n
3999
+ },
4000
+ {
4001
+ onSuccess: (c) => {
4002
+ s(), a(c);
4003
+ },
4004
+ onError: (c) => {
4005
+ const u = oe(c);
4006
+ o(u), i(u);
4007
+ }
4008
+ }
4009
+ );
4010
+ })
4011
+ }), Xg = (e, t, r) => new Promise((n, a) => {
4012
+ r.actions.vaultInitialize(
4013
+ { vaultKey: e, scope: t },
4014
+ {
4015
+ onSuccess: () => {
4016
+ n(Yg(e, r));
4017
+ },
4018
+ onError: (i) => a(oe(i))
4019
+ }
4020
+ );
4021
+ }), Qg = (e) => ({
4022
+ initialize: (t, r) => Xg(t, r, e),
4023
+ errorTypes: Ct
4024
+ }), jr = {
4025
+ Error: "Failed to perform wishlist action",
4026
+ Auth: "User must be logged in for wishlist actions",
4027
+ NoWishlistIntegrationConfigured: "A wishlist integration must be configured",
4028
+ InvalidName: "Wishlist name must be 3 characters long",
4029
+ WishlistDoesNotExist: "Wishlist does not exist",
4030
+ WishlistItemDoesNotExist: "Item does not exist"
4031
+ }, Hg = (e) => jr[e] || jr.Error, Le = (e, t) => new Promise((r, n) => {
4032
+ e(t, {
4033
+ onSuccess: r,
4034
+ onError: (a) => n(Hg(a))
4035
+ });
4036
+ }), ev = (e) => {
4037
+ const { wishlistCreate: t, wishlistItemAdd: r, wishlistItemRemove: n, wishlistsGet: a } = e.actions;
4038
+ return {
4039
+ createWishlist: (i) => Le(t, { name: i }),
4040
+ addItemToWishlist: (i, s, o) => Le(r, { productId: i, variantId: s, wishlistId: o }),
4041
+ removeItemFromWishlist: (i, s, o) => Le(n, { productId: i, variantId: s, wishlistId: o }),
4042
+ getWishlists: () => Le(a, null)
4043
+ };
4044
+ }, kr = {
4045
+ Error: "Failed to perform authentication action"
4046
+ }, tv = (e) => kr[e] || kr.Error, rv = (e, t) => new Promise((r, n) => {
4047
+ e(t, {
4048
+ onSuccess: r,
4049
+ onError: (a) => n(tv(a))
4050
+ });
4051
+ }), nv = (e) => {
4052
+ const { authenticationOpen: t } = e.actions;
4053
+ return {
4054
+ openAuthentication: (r) => rv(t, { action: r })
4055
+ };
4056
+ }, av = (e, t) => new Promise((r, n) => {
4057
+ e(t, {
4058
+ onSuccess: r,
4059
+ onError: (a) => n(a)
4060
+ });
4061
+ }), iv = (e) => {
4062
+ const { trackAnalyticEvent: t } = e.actions;
4063
+ return {
4064
+ trackAnalyticEvent: (r, n) => av(t, { analyticEvent: r, analyticProperties: n })
4065
+ };
4066
+ }, sv = () => {
4067
+ var r, n, a, i;
4068
+ const e = new CustomEvent("webbridge-ready");
4069
+ window.dispatchEvent(e);
4070
+ const t = JSON.stringify({
4071
+ type: "action",
4072
+ name: "webbridge/ready"
4073
+ });
4074
+ (r = window.CustomBlockJavascriptInterface) == null || r.postMessage(t), (i = (a = (n = window.webkit) == null ? void 0 : n.messageHandlers) == null ? void 0 : a.Tapcart) == null || i.postMessage(t);
4075
+ }, Gr = {
4076
+ Error: "Failed to perform loyalty action",
4077
+ Auth: "User must be logged in for loyalty actions",
4078
+ NoLoyaltyIntegrationConfigured: "A loyalty integration must be configured"
4079
+ }, ov = (e) => Gr[e] || Gr.Error, re = async (e, { appId: t, ...r }) => {
4080
+ const n = `/${t}/api/v1/mock-loyalty/${e}`;
4081
+ return (await fetch(n, {
4082
+ method: "POST",
4083
+ headers: {
4084
+ "Content-Type": "application/json"
4085
+ },
4086
+ body: JSON.stringify(r)
4087
+ })).json();
4088
+ }, ne = (e, t) => new Promise((r, n) => {
4089
+ e(t, {
4090
+ onSuccess: r,
4091
+ onError: (a) => n(ov(a))
4092
+ });
4093
+ }), ae = () => !!(window != null && window.Tapcart.variables.device), zr = (e) => {
4094
+ const { getLoyaltyRewards: t, getLoyaltyHistory: r, getLoyaltyCustomer: n, redeemLoyaltyReward: a, getLoyaltyTiers: i, getLoyaltyCustomerTier: s, recordLoyaltyActivity: o } = e.actions;
4095
+ return {
4096
+ getLoyaltyRewards: ({ appId: c }) => ae() ? ne(t, null) : re("getRewards", { appId: c }),
4097
+ getLoyaltyTiers: ({ appId: c }) => ae() ? ne(i, null) : re("getTiers", { appId: c }),
4098
+ getLoyaltyCustomerTier: ({ appId: c }) => ae() ? ne(s, null) : re("getCustomerTier", { appId: c }),
4099
+ getLoyaltyHistory: ({ appId: c }) => ae() ? ne(r, null) : re("getHistory", { appId: c }),
4100
+ getLoyaltyCustomer: ({ appId: c }) => ae() ? ne(n, null) : re("getCustomer", { appId: c }),
4101
+ redeemLoyaltyReward: ({ appId: c, rewardId: u, options: l }) => ae() ? ne(a, { rewardId: u, options: l }) : re("redeemReward", { appId: c, rewardId: u, options: l }),
4102
+ recordLoyaltyActivity: ({ appId: c, activityName: u, activityType: l, activityUrl: d }) => ae() ? ne(o, { activityName: u, activityType: l, activityUrl: d }) : re("recordActivity", { appId: c, activityName: u, activityType: l, activityUrl: d })
4103
+ };
4104
+ }, Bv = () => {
4105
+ if (window.Tapcart)
4106
+ return window.Tapcart;
4107
+ const e = zg(), t = Ua(), r = Gg({
4108
+ setVariables: t.setVariables
4109
+ }), n = jg(e.sendMessage, r), a = async (s) => {
4110
+ e.init(s.platform, s.messageHandlerName), t.setVariables(s.variables), window.Tapcart.isInitialized = !0, window.Tapcart.actions = {
4111
+ ...window.Tapcart.actions,
4112
+ ...zr(n)
4113
+ };
4114
+ }, i = {
4115
+ addToCart: n.actions.addToCart,
4116
+ applyDiscount: n.actions.applyDiscount,
4117
+ applyGiftCard: n.actions.applyGiftCard,
4118
+ getCustomerIdentity: n.actions.getCustomerIdentity,
4119
+ openCart: n.actions.openCart,
4120
+ openCollection: n.actions.openCollection,
4121
+ openProduct: n.actions.openProduct,
4122
+ openScreen: n.actions.openScreen,
4123
+ removeDiscounts: n.actions.removeDiscounts,
4124
+ removeDiscount: n.actions.removeDiscount,
4125
+ removeFromCart: n.actions.removeFromCart,
4126
+ scrollToBlockBottom: n.actions.scrollToBlockBottom,
4127
+ scrollToBlockTop: n.actions.scrollToBlockTop,
4128
+ showToast: n.actions.showToast,
4129
+ updateCartAttributes: n.actions.updateCartAttributes,
4130
+ updateCartNote: n.actions.updateCartNote,
4131
+ vault: Qg(n),
4132
+ ...Mg(n),
4133
+ ...ev(n),
4134
+ ...nv(n),
4135
+ ...iv(n),
4136
+ ...zr(n),
4137
+ action: n.action
4138
+ };
4139
+ return window.Tapcart = {
4140
+ mobile: {
4141
+ respond: n.respond,
4142
+ notify: r.notify,
4143
+ load: a
4144
+ },
4145
+ registerEventHandler: r.registerEventHandler,
4146
+ actions: i,
4147
+ get variables() {
4148
+ return t.variables;
4149
+ },
4150
+ isInitialized: !1,
4151
+ action: n.action
4152
+ }, sv(), window.Tapcart;
4153
+ }, cv = () => ({
4154
+ device: null,
4155
+ product: null,
4156
+ cart: null,
4157
+ customer: null,
4158
+ isInitialized: !1
4159
+ }), kt = H(null), tt = H(null);
4160
+ function uv(e, t) {
4161
+ switch (t.type) {
4162
+ case "set-device":
4163
+ return {
4164
+ ...e,
4165
+ device: {
4166
+ ...t.payload
4167
+ }
4168
+ };
4169
+ case "set-cart":
4170
+ return {
4171
+ ...e,
4172
+ cart: {
4173
+ ...t.payload
4174
+ }
4175
+ };
4176
+ case "set-product":
4177
+ return {
4178
+ ...e,
4179
+ product: {
4180
+ ...t.payload
4181
+ }
4182
+ };
4183
+ case "set-customer":
4184
+ return {
4185
+ ...e,
4186
+ customer: {
4187
+ ...t.payload
4188
+ }
4189
+ };
4190
+ case "set-variables":
4191
+ return {
4192
+ ...e,
4193
+ ...t.payload
4194
+ };
4195
+ case "initialize":
4196
+ return {
4197
+ ...t.payload,
4198
+ isInitialized: !0
4199
+ };
4200
+ default:
4201
+ throw new Error(`Unknown action: ${t.type}`);
4202
+ }
4203
+ }
4204
+ function Kv({ webbridgeClient: e, children: t }) {
4205
+ const [r, n] = Oa(uv, cv());
4206
+ return We(() => {
4207
+ if (e.registerEventHandler("cart/updated", (a) => {
4208
+ var i;
4209
+ n({ type: "set-cart", payload: (i = e == null ? void 0 : e.variables) == null ? void 0 : i.cart });
4210
+ }), e.registerEventHandler("product/updated", (a) => {
4211
+ var i;
4212
+ n({ type: "set-product", payload: (i = e == null ? void 0 : e.variables) == null ? void 0 : i.product });
4213
+ }), e.registerEventHandler("customer/updated", (a) => {
4214
+ var i;
4215
+ n({ type: "set-customer", payload: (i = e == null ? void 0 : e.variables) == null ? void 0 : i.customer });
4216
+ }), e.registerEventHandler("variables/updated", (a) => {
4217
+ n({ type: "set-variables", payload: e == null ? void 0 : e.variables });
4218
+ }), e.isInitialized)
4219
+ n({ type: "initialize", payload: e.variables });
4220
+ else {
4221
+ const a = e.mobile.load;
4222
+ e.mobile.load = (i) => {
4223
+ a(i), n({ type: "initialize", payload: e == null ? void 0 : e.variables });
4224
+ };
4225
+ }
4226
+ }, [e]), /* @__PURE__ */ Y.createElement(kt.Provider, { value: r }, /* @__PURE__ */ Y.createElement(tt.Provider, { value: e.actions }, t));
4227
+ }
4228
+ const Wv = () => ({
4229
+ ...U(tt)
4230
+ }), Jv = () => U(kt), lv = () => {
4231
+ const e = U(tt), t = U(kt);
4232
+ return X(
4233
+ () => ({
4234
+ action: e.action,
4235
+ actions: {
4236
+ ...e
4237
+ },
4238
+ variables: t
4239
+ }),
4240
+ [e, t]
4241
+ );
4242
+ }, le = (e, t, r = {}) => {
4243
+ const n = new Error(t);
4244
+ return Object.defineProperty(n, "name", {
4245
+ value: e,
4246
+ writable: !0,
4247
+ configurable: !0
4248
+ }), Object.assign(n, r), n.code = e, n;
4249
+ }, dv = (e, t) => {
4250
+ if (!(!t || typeof e.message != "string") && e.message.includes(t))
4251
+ try {
4252
+ Object.defineProperty(e, "message", {
4253
+ value: e.message.split(t).join("<url>"),
4254
+ writable: !0,
4255
+ configurable: !0
4256
+ });
4257
+ } catch {
4258
+ }
4259
+ }, rt = (e, t) => {
4260
+ if (!e || typeof e != "object")
4261
+ return e;
4262
+ const r = e.code;
4263
+ if (typeof r != "string" || !r)
4264
+ try {
4265
+ Object.defineProperty(e, "code", {
4266
+ value: e.name,
4267
+ writable: !0,
4268
+ enumerable: !0,
4269
+ configurable: !0
4270
+ });
4271
+ } catch {
4272
+ }
4273
+ return dv(e, t), e;
4274
+ }, fv = 1e4, Gt = async (e, t = {}) => {
4275
+ const r = new AbortController(), n = setTimeout(() => r.abort(), fv);
4276
+ try {
4277
+ const a = await fetch(e, { ...t, signal: r.signal });
4278
+ return a.ok ? { data: await a.json(), error: null } : {
4279
+ data: null,
4280
+ error: le("HttpError", `HTTP ${a.status}`, {
4281
+ status: a.status
4282
+ })
4283
+ };
4284
+ } catch (a) {
4285
+ return { data: null, error: rt(a, e) };
4286
+ } finally {
4287
+ clearTimeout(n);
4288
+ }
4289
+ }, pv = "2025-04", hv = "nextjs-frontend-hidden", Vr = 250, he = (e) => {
4290
+ if (e == null)
4291
+ return null;
4292
+ const t = String(e).trim();
4293
+ if (!t)
4294
+ return null;
4295
+ const r = t.match(/\/([^/]+)$/);
4296
+ return r ? r[1] : t;
4297
+ }, ua = (e) => {
4298
+ if (e == null)
4299
+ return null;
4300
+ const t = String(e).trim();
4301
+ return t ? t.startsWith("gid://") ? t : `gid://shopify/Product/${t}` : null;
4302
+ }, la = `
4303
+ id
4304
+ handle
4305
+ availableForSale
4306
+ title
4307
+ vendor
4308
+ tags
4309
+ options {
4310
+ id
4311
+ name
4312
+ values
4313
+ }
4314
+ priceRange {
4315
+ maxVariantPrice { amount currencyCode }
4316
+ minVariantPrice { amount currencyCode }
4317
+ }
4318
+ compareAtPriceRange {
4319
+ maxVariantPrice { amount currencyCode }
4320
+ minVariantPrice { amount currencyCode }
4321
+ }
4322
+ variants(first: 250) {
4323
+ edges {
4324
+ node {
4325
+ id
4326
+ title
4327
+ availableForSale
4328
+ sku
4329
+ compareAtPrice { amount currencyCode }
4330
+ selectedOptions { name value }
4331
+ price { amount currencyCode }
4332
+ image { altText height id url width }
4333
+ }
4334
+ }
4335
+ }
4336
+ featuredImage { url altText width height }
4337
+ images(first: 50) {
4338
+ edges { node { url altText width height } }
4339
+ }
4340
+ `, mv = `
4341
+ query getProductRecommendations($productId: ID!, $intent: ProductRecommendationIntent, $language: LanguageCode, $country: CountryCode)
4342
+ @inContext(language: $language, country: $country) {
4343
+ productRecommendations(productId: $productId, intent: $intent) {
4344
+ ${la}
4345
+ }
4346
+ }
4347
+ `, yv = `
4348
+ query getProductsByIds($ids: [ID!]!, $language: LanguageCode, $country: CountryCode)
4349
+ @inContext(language: $language, country: $country) {
4350
+ nodes(ids: $ids) {
4351
+ ... on Product {
4352
+ ${la}
4353
+ }
4354
+ }
4355
+ }
4356
+ `, gv = (e) => {
4357
+ if (!e)
4358
+ return "EN";
4359
+ const t = String(e).toUpperCase().replace(/-/g, "_");
4360
+ return /^ZH_(HANT_)?TW$/.test(t) ? "ZH_TW" : /^ZH_(HANS_)?CN$/.test(t) ? "ZH_CN" : ["PT_BR", "PT_PT", "ZH_CN", "ZH_TW"].includes(t) ? t : t.split("_")[0] || "EN";
4361
+ }, vv = (e, t) => {
4362
+ var n;
4363
+ return (((n = e == null ? void 0 : e.edges) == null ? void 0 : n.map((a) => a == null ? void 0 : a.node)) || []).map((a) => {
4364
+ var s, o;
4365
+ const i = (o = (s = a == null ? void 0 : a.url) == null ? void 0 : s.match(/.*\/(.*)\..*/)) == null ? void 0 : o[1];
4366
+ return {
4367
+ ...a,
4368
+ altText: (a == null ? void 0 : a.altText) || `${t} - ${i || t}`
4369
+ };
4370
+ });
4371
+ }, da = (e) => {
4372
+ var a, i;
4373
+ if (!e || (a = e == null ? void 0 : e.tags) != null && a.includes(hv))
4374
+ return null;
4375
+ const { variants: t, images: r, ...n } = e;
4376
+ return {
4377
+ ...n,
4378
+ variants: ((i = t == null ? void 0 : t.edges) == null ? void 0 : i.map((s) => s == null ? void 0 : s.node)) || [],
4379
+ images: vv(r, e.title)
4380
+ };
4381
+ }, fa = (e) => {
4382
+ const t = {};
4383
+ return e.language && (t.language = gv(e.language)), e.country && (t.country = String(e.country).toUpperCase()), t;
4384
+ }, pa = () => le(
4385
+ "TapcartAiConfigError",
4386
+ "Tapcart ai: Shopify needs shopifyGqlEndpoint and shopifyApiKey"
4387
+ ), ha = async ({ query: e, variables: t, config: r }) => {
4388
+ var o;
4389
+ const n = `https://${r.shopifyGqlEndpoint}.myshopify.com/api/${pv}/graphql.json`, { data: a, error: i } = await Gt(n, {
4390
+ method: "POST",
4391
+ headers: {
4392
+ "Content-Type": "application/json",
4393
+ "X-Shopify-Storefront-Access-Token": r.shopifyApiKey
4394
+ },
4395
+ body: JSON.stringify({ query: e, variables: t })
4396
+ });
4397
+ if (i)
4398
+ return { data: null, error: i };
4399
+ const s = Array.isArray(a == null ? void 0 : a.errors) ? a.errors : [];
4400
+ if (s.length > 0) {
4401
+ const c = le(
4402
+ "ShopifyGraphQLError",
4403
+ ((o = s[0]) == null ? void 0 : o.message) || "Shopify GraphQL error",
4404
+ { graphQLErrors: s }
4405
+ );
4406
+ return { data: (a == null ? void 0 : a.data) ?? null, error: c };
4407
+ }
4408
+ return { data: (a == null ? void 0 : a.data) ?? null, error: null };
4409
+ }, _v = ({
4410
+ productId: e,
4411
+ intent: t,
4412
+ language: r,
4413
+ country: n,
4414
+ shopifyGqlEndpoint: a
4415
+ }) => [
4416
+ a || "",
4417
+ e,
4418
+ t,
4419
+ r || "",
4420
+ n || ""
4421
+ ].join("|"), Sv = async ({
4422
+ productId: e,
4423
+ intent: t,
4424
+ config: r
4425
+ }) => {
4426
+ const n = ua(e);
4427
+ if (!n)
4428
+ return { data: [], error: null };
4429
+ if (!r.shopifyGqlEndpoint || !r.shopifyApiKey)
4430
+ return { data: [], error: pa() };
4431
+ try {
4432
+ const { data: a, error: i } = await ha({
4433
+ query: mv,
4434
+ variables: { productId: n, intent: t, ...fa(r) },
4435
+ config: r
4436
+ }), s = ((a == null ? void 0 : a.productRecommendations) || []).map(da).filter(Boolean);
4437
+ return { data: s, error: s.length > 0 ? null : i || null };
4438
+ } catch (a) {
4439
+ return { data: [], error: rt(a) };
4440
+ }
4441
+ }, ma = async ({ productIds: e, config: t }) => {
4442
+ var a;
4443
+ const r = Array.from(
4444
+ new Set(e.map((i) => ua(i)).filter(Boolean))
4445
+ );
4446
+ if (r.length === 0)
4447
+ return { data: [], error: null };
4448
+ if (!t.shopifyGqlEndpoint || !t.shopifyApiKey)
4449
+ return { data: [], error: pa() };
4450
+ const n = [];
4451
+ for (let i = 0; i < r.length; i += Vr)
4452
+ n.push(r.slice(i, i + Vr));
4453
+ try {
4454
+ const i = await Promise.all(
4455
+ n.map(
4456
+ (c) => ha({
4457
+ query: yv,
4458
+ variables: { ids: c, ...fa(t) },
4459
+ config: t
4460
+ })
4461
+ )
4462
+ ), s = i.flatMap((c) => {
4463
+ var u;
4464
+ return ((u = c.data) == null ? void 0 : u.nodes) || [];
4465
+ }).map(da).filter(Boolean), o = ((a = i.find((c) => c.error)) == null ? void 0 : a.error) || null;
4466
+ return { data: s, error: s.length > 0 ? null : o };
4467
+ } catch (i) {
4468
+ return { data: [], error: rt(i) };
4469
+ }
4470
+ }, ya = (e) => {
4471
+ if (e == null)
4472
+ return null;
4473
+ const t = he(String(e).trim());
4474
+ return t === "." || t === ".." ? null : t || null;
4475
+ }, ga = ({ config: e, productId: t, resource: r }) => {
4476
+ const { appId: n, customerProfilesBaseUrl: a } = e;
4477
+ return !n || !a ? null : `${String(a).replace(/\/+$/, "")}/api/v1/catalog/${encodeURIComponent(
4478
+ String(n)
4479
+ )}/${encodeURIComponent(t)}/${r}`;
4480
+ }, va = (e) => Gt(e, { headers: { Accept: "application/json" } }), _a = () => le(
4481
+ "TapcartAiConfigError",
4482
+ "Tapcart ai: catalog needs appId and customerProfilesBaseUrl"
4483
+ ), bv = async ({
4484
+ productId: e,
4485
+ config: t
4486
+ }) => {
4487
+ const r = ya(e);
4488
+ if (!r)
4489
+ return { data: [], error: null };
4490
+ const n = ga({ config: t, productId: r, resource: "related-products" });
4491
+ if (!n)
4492
+ return { data: [], error: _a() };
4493
+ const { data: a, error: i } = await va(n);
4494
+ return i ? { data: [], error: i } : {
4495
+ data: (Array.isArray(a == null ? void 0 : a.relatedProductIds) ? a.relatedProductIds : Array.isArray(a == null ? void 0 : a.related) ? a.related.map((o) => o == null ? void 0 : o.productId) : []).map((o) => o == null ? "" : String(o)).filter(Boolean),
4496
+ error: null
4497
+ };
4498
+ }, $v = async ({
4499
+ productId: e,
4500
+ config: t
4501
+ }) => {
4502
+ const r = ya(e);
4503
+ if (!r)
4504
+ return { data: [], error: null };
4505
+ const n = ga({
4506
+ config: t,
4507
+ productId: r,
4508
+ resource: "complementary-products"
4509
+ });
4510
+ if (!n)
4511
+ return { data: [], error: _a() };
4512
+ const { data: a, error: i } = await va(n);
4513
+ return i ? { data: [], error: i } : { data: (Array.isArray(a == null ? void 0 : a.bundles) ? a.bundles : []).map((c, u) => ({
4514
+ bundleId: String((c == null ? void 0 : c.bundleId) ?? `${r}-${u}`),
4515
+ // Normalised like the complements below, and like the anchor id on the
4516
+ // way in: this endpoint may answer in either form, and a block comparing
4517
+ // this against its own bare product id would never match a gid.
4518
+ anchorProductId: he(c == null ? void 0 : c.anchorProductId),
4519
+ theme: c != null && c.theme ? String(c.theme) : "",
4520
+ hook: c != null && c.hook ? String(c.hook) : "",
4521
+ source: (c == null ? void 0 : c.source) == null ? null : String(c.source),
4522
+ // snake_case on the wire, camelCase for blocks.
4523
+ relationshipType: (c == null ? void 0 : c.relationship_type) == null ? null : String(c.relationship_type),
4524
+ rank: typeof (c == null ? void 0 : c.rank) == "number" ? c.rank : null,
4525
+ personalizationScore: typeof (c == null ? void 0 : c.personalizationScore) == "number" ? c.personalizationScore : null,
4526
+ complementProductIds: (Array.isArray(c == null ? void 0 : c.complementProductIds) ? c.complementProductIds : []).map((l) => l == null ? "" : String(l)).filter(Boolean)
4527
+ })), error: null };
4528
+ }, Av = async ({ productId: e, config: t }) => {
4529
+ const { data: r, error: n } = await bv({
4530
+ productId: e,
4531
+ config: t
4532
+ });
4533
+ return n ? { data: [], error: n } : r.length === 0 ? { data: [], error: null } : ma({ productIds: r, config: t });
4534
+ }, wv = async ({
4535
+ productId: e,
4536
+ config: t
4537
+ }) => {
4538
+ const { data: r, error: n } = await $v({
4539
+ productId: e,
4540
+ config: t
4541
+ });
4542
+ if (n)
4543
+ return { data: [], error: n };
4544
+ if (r.length === 0)
4545
+ return { data: [], error: null };
4546
+ const a = r.flatMap((u) => u.complementProductIds);
4547
+ if (a.length === 0)
4548
+ return { data: [], error: null };
4549
+ const { data: i, error: s } = await ma({
4550
+ productIds: a,
4551
+ config: t
4552
+ }), o = /* @__PURE__ */ new Map();
4553
+ i.forEach((u) => {
4554
+ const l = he(u == null ? void 0 : u.id);
4555
+ l && o.set(l, u);
4556
+ });
4557
+ const c = r.map(({ complementProductIds: u, ...l }) => ({
4558
+ ...l,
4559
+ // `byId` is keyed on the bare numeric id, but this endpoint may hand
4560
+ // back complements as gids — the same reason catalogProductId exists.
4561
+ // Without normalising, a gid-form response misses every lookup and
4562
+ // every bundle is dropped below, which a block cannot tell apart from
4563
+ // "this product genuinely has no bundles".
4564
+ products: u.map((d) => o.get(he(d))).filter(Boolean)
4565
+ })).filter((u) => u.products.length > 0);
4566
+ return {
4567
+ data: c,
4568
+ error: c.length > 0 ? null : s || null
4569
+ };
4570
+ }, Ev = (e) => !!e && typeof e == "object" && !Array.isArray(e), Cv = (e) => e == null ? null : String(e), Tv = (e) => e == null ? "" : String(e), xv = (e) => [
4571
+ "cluster-feed",
4572
+ e.customerProfilesBaseUrl || "",
4573
+ e.appId || "",
4574
+ e.deviceId || ""
4575
+ ].join("|"), Br = (e) => e === "." || e === "..", Pv = (e) => {
4576
+ const { appId: t, deviceId: r, customerProfilesBaseUrl: n } = e;
4577
+ return !t || !r || !n || Br(String(t)) || Br(String(r)) ? null : `${String(n).replace(/\/+$/, "")}/api/v1/personalized-feed/${encodeURIComponent(
4578
+ String(t)
4579
+ )}/${encodeURIComponent(String(r))}/cluster-feed`;
4580
+ }, Fv = async ({ config: e }) => {
4581
+ const t = Pv(e);
4582
+ if (!t)
4583
+ return {
4584
+ data: [],
4585
+ error: le(
4586
+ "TapcartAiConfigError",
4587
+ "Tapcart ai: cluster feed needs appId, deviceId and customerProfilesBaseUrl"
4588
+ )
4589
+ };
4590
+ const { data: r, error: n } = await Gt(t, {
4591
+ headers: { Accept: "application/json" }
4592
+ });
4593
+ if (n)
4594
+ return { data: [], error: n };
4595
+ const a = Array.isArray(r == null ? void 0 : r.collectionIds) ? r.collectionIds : [], i = Ev(r == null ? void 0 : r.explanations) ? r.explanations : {};
4596
+ return {
4597
+ data: a.map(Cv).filter(Boolean).map((s) => ({
4598
+ collectionId: s,
4599
+ explanation: Tv(i[s])
4600
+ })),
4601
+ error: null
4602
+ };
4603
+ };
4604
+ function Ov(e = {}) {
4605
+ let t = { ...e };
4606
+ const r = /* @__PURE__ */ new Map(), n = 5e3;
4607
+ let a;
4608
+ const i = new Promise((f) => {
4609
+ a = f;
4610
+ }), s = () => {
4611
+ if (t.deviceId)
4612
+ return Promise.resolve(!0);
4613
+ let f;
4614
+ return Promise.race([
4615
+ i.then(() => !0),
4616
+ new Promise((p) => {
4617
+ f = setTimeout(() => p(!1), n);
4618
+ })
4619
+ ]).finally(() => clearTimeout(f));
4620
+ }, o = (f) => f.then(
4621
+ (p) => Array.isArray(p == null ? void 0 : p.data) && p.data.length > 0 ? { ...p, data: p.data.slice() } : p
4622
+ ), c = (f, p) => {
4623
+ const m = r.get(f);
4624
+ if (m)
4625
+ return o(m);
4626
+ const v = p().finally(() => {
4627
+ r.delete(f);
4628
+ });
4629
+ return r.set(f, v), o(v);
4630
+ }, u = () => Promise.resolve({ data: [], error: null }), l = (f, p) => {
4631
+ if (f == null || f === "")
4632
+ return u();
4633
+ const m = _v({
4634
+ productId: he(f),
4635
+ intent: p,
4636
+ language: t.language,
4637
+ country: t.country,
4638
+ shopifyGqlEndpoint: t.shopifyGqlEndpoint
4639
+ });
4640
+ return c(
4641
+ m,
4642
+ () => Sv({ productId: f, intent: p, config: t })
4643
+ );
4644
+ }, d = (f, p) => [
4645
+ "catalog",
4646
+ f,
4647
+ t.customerProfilesBaseUrl || "",
4648
+ t.appId || "",
4649
+ // Normalised for the same reason as recommendationRequestKey above —
4650
+ // catalogProductId strips the gid before it ever reaches the URL, so
4651
+ // a bare id and its gid are one request either way.
4652
+ he(p),
4653
+ t.shopifyGqlEndpoint || "",
4654
+ t.language || "",
4655
+ t.country || ""
4656
+ ].join("|");
4657
+ return {
4658
+ configure(f) {
4659
+ t = { ...t, ...f }, t.deviceId && a();
4660
+ },
4661
+ getRelatedProducts(f) {
4662
+ return f == null || f === "" ? u() : c(
4663
+ d("related", f),
4664
+ () => Av({ productId: f, config: t })
4665
+ );
4666
+ },
4667
+ getComplementaryProducts(f) {
4668
+ return f == null || f === "" ? u() : c(
4669
+ d("complementary", f),
4670
+ () => wv({ productId: f, config: t })
4671
+ );
4672
+ },
4673
+ getShopifyRelatedProducts(f) {
4674
+ return l(f, "RELATED");
4675
+ },
4676
+ getShopifyComplementaryProducts(f) {
4677
+ return l(f, "COMPLEMENTARY");
4678
+ },
4679
+ /**
4680
+ * Recommended collections for this shopper, strongest first. Waits for a
4681
+ * device id rather than answering empty before one lands.
4682
+ *
4683
+ * Coalesced on the device, so several blocks asking at once share one
4684
+ * request — the common case, since every collection block on a screen
4685
+ * reads the same feed.
4686
+ */
4687
+ async getRecommendedCollections() {
4688
+ return await s() ? c(
4689
+ xv(t),
4690
+ () => Fv({ config: t })
4691
+ ) : {
4692
+ data: [],
4693
+ error: le(
4694
+ "TapcartAiDeviceIdTimeout",
4695
+ `Tapcart ai: no deviceId arrived within ${n}ms`
4696
+ )
4697
+ };
4698
+ }
4699
+ };
4700
+ }
4701
+ const ct = (e, t, r) => {
4702
+ const [n, a] = xt({
4703
+ data: r,
4704
+ isLoading: !!t,
4705
+ error: null
4706
+ });
4707
+ return We(() => {
4708
+ if (t == null || t === "") {
4709
+ a({ data: r, isLoading: !1, error: null });
4710
+ return;
4711
+ }
4712
+ if (!e) {
4713
+ a({
4714
+ data: r,
4715
+ isLoading: !1,
4716
+ error: le(
4717
+ "TapcartAiNoProvider",
4718
+ "Tapcart ai: no DataSourceProvider is mounted above this block"
4719
+ )
4720
+ });
4721
+ return;
4722
+ }
4723
+ let i = !0;
4724
+ return a((s) => ({ ...s, isLoading: !0, error: null })), e(t).then((s) => {
4725
+ var o;
4726
+ i && a({
4727
+ // `|| emptyValue` never fires for a successful-but-empty response
4728
+ // — `[]` is truthy — so a block would hold the client's fresh
4729
+ // mutable array in exactly the state where it holds the frozen
4730
+ // shared one while loading. Collapse it so the mutation-safety
4731
+ // guarantee reads the same in both states.
4732
+ data: (o = s == null ? void 0 : s.data) != null && o.length ? s.data : r,
4733
+ isLoading: !1,
4734
+ error: (s == null ? void 0 : s.error) || null
4735
+ });
4736
+ }).catch((s) => {
4737
+ i && a({
4738
+ data: r,
4739
+ isLoading: !1,
4740
+ // Every other failure path stamps `code` before an error reaches a
4741
+ // block. A raw throw landing here must not be the one exception,
4742
+ // or "branch on code, never on message" stops holding exactly
4743
+ // where the failure is least expected.
4744
+ error: rt(s)
4745
+ });
4746
+ }), () => {
4747
+ i = !1;
4748
+ };
4749
+ }, [e, t, r]), n;
4750
+ }, Tt = /* @__PURE__ */ new WeakMap(), Iv = (e) => {
4751
+ let t = Tt.get(e);
4752
+ return t || (t = /* @__PURE__ */ new Map(), Tt.set(e, t)), t;
4753
+ }, Nv = (e, t) => {
4754
+ const r = Iv(e), n = r.get(t);
4755
+ if (n !== void 0)
4756
+ return n;
4757
+ const a = new Set(r.values());
4758
+ let i = 0;
4759
+ for (; a.has(i); )
4760
+ i += 1;
4761
+ return r.set(t, i), i;
4762
+ }, Dv = (e, t) => {
4763
+ var r;
4764
+ (r = Tt.get(e)) == null || r.delete(t);
4765
+ }, ut = Object.freeze([]);
4766
+ function Rv(e, t = () => null) {
4767
+ const r = (i) => {
4768
+ const s = e();
4769
+ return X(
4770
+ () => s ? (o) => s[i](o) : null,
4771
+ [s, i]
4772
+ );
4773
+ }, n = (i) => (s) => {
4774
+ const o = r(i), { data: c, isLoading: u, error: l } = ct(
4775
+ o,
4776
+ s,
4777
+ ut
4778
+ );
4779
+ return { data: c, isLoading: u, error: l };
4780
+ }, a = () => {
4781
+ const i = e(), s = t(), o = X(
4782
+ () => i ? () => i.getRecommendedCollections() : null,
4783
+ // eslint-disable-next-line react-hooks/exhaustive-deps
4784
+ [i, s]
4785
+ ), { data: c, isLoading: u, error: l } = ct(o, !0, ut);
4786
+ return { data: c, isLoading: u, error: l };
4787
+ };
4788
+ return {
4789
+ useRecommendedCollections: a,
4790
+ /**
4791
+ * ONE recommended collection, different for every caller.
4792
+ *
4793
+ * Takes no argument. Each mounted caller claims a distinct collection
4794
+ * from the shared feed, in claim order — two blocks on a screen never
4795
+ * show the same one.
4796
+ *
4797
+ * Returns `data: null` once the feed is exhausted: a caller
4798
+ * beyond the end of the feed renders nothing rather than duplicating a
4799
+ * sibling.
4800
+ */
4801
+ useRecommendedCollection: () => {
4802
+ const i = e(), s = Ia(), {
4803
+ data: o,
4804
+ isLoading: c,
4805
+ error: u
4806
+ } = a(), [l, d] = xt(null);
4807
+ return We(() => {
4808
+ if (i)
4809
+ return d(Nv(i, s)), () => Dv(i, s);
4810
+ }, [i, s]), {
4811
+ // null while the claim is still being taken (one render) and once
4812
+ // the feed is exhausted — both mean "nothing to show here".
4813
+ data: l == null ? null : o[l] ?? null,
4814
+ isLoading: c,
4815
+ error: u
4816
+ };
4817
+ },
4818
+ useRelatedProducts: n("getRelatedProducts"),
4819
+ useShopifyRelatedProducts: n("getShopifyRelatedProducts"),
4820
+ useShopifyComplementaryProducts: n(
4821
+ "getShopifyComplementaryProducts"
4822
+ ),
4823
+ useComplementaryProducts: (i) => {
4824
+ const s = r("getComplementaryProducts"), { data: o, isLoading: c, error: u } = ct(
4825
+ s,
4826
+ i,
4827
+ ut
4828
+ );
4829
+ return { data: o, isLoading: c, error: u };
4830
+ }
4831
+ };
4832
+ }
4833
+ const Sa = H(void 0), ba = H(void 0), $a = H(null), Aa = H(null), Lv = () => U(ba), Mv = () => U($a), qv = () => U(Aa), Me = () => {
4834
+ }, Kr = (e) => e, Wr = () => !1, Uv = [
4835
+ "appId",
4836
+ "apiUrl",
4837
+ "customerProfilesBaseUrl",
4838
+ "language",
4839
+ "country",
4840
+ "shopifyGqlEndpoint",
4841
+ "shopifyApiKey"
4842
+ ], jv = (e) => Uv.map((t) => String(e[t] == null ? "" : e[t])).join("|"), kv = (e) => e.customerProfilesBaseUrl ? String(e.customerProfilesBaseUrl).replace(/\/+$/, "") : e.apiUrl ? `${String(e.apiUrl).replace(/\/+$/, "")}/customer-profiles` : null, wa = Object.freeze(Rv(Mv, qv));
4843
+ function Zv() {
4844
+ return wa;
4845
+ }
4846
+ const Gv = () => {
4847
+ const e = {
4848
+ useBlockAnalyticsEnabled: Wr,
4849
+ emitProductClick: Me,
4850
+ emitAddToCart: Me,
4851
+ decorateActions: Kr
4852
+ }, t = Ov();
4853
+ return { api: { useTapcart: (a) => {
4854
+ const i = Lv(), s = e.useBlockAnalyticsEnabled(), o = i == null ? void 0 : i.actions, c = Jr(
4855
+ (d, f, p) => {
4856
+ const m = (g) => (d === "product/open" ? e.emitProductClick(a, f) : d === "cart/add" && e.emitAddToCart(a, f, g), g);
4857
+ if (!s || d !== "cart/add")
4858
+ return m(o == null ? void 0 : o.action(d, f, p));
4859
+ const v = {
4860
+ onSuccess: (g) => {
4861
+ var S;
4862
+ (S = p == null ? void 0 : p.onSuccess) == null || S.call(p, g);
4863
+ },
4864
+ onError: (g) => {
4865
+ var S, b;
4866
+ try {
4867
+ (S = o == null ? void 0 : o.action) == null || S.call(o, "track", {
4868
+ name: "_error",
4869
+ data: {
4870
+ msg: g == null ? void 0 : g.message,
4871
+ stack: g != null && g.stack ? g.stack.split(`
4872
+ `).slice(0, 10).join(`
4873
+ `) : void 0,
4874
+ actionType: "cart_add",
4875
+ ...f
4876
+ },
4877
+ platforms: ["click-stream"]
4878
+ });
4879
+ } catch {
4880
+ }
4881
+ (b = p == null ? void 0 : p.onError) == null || b.call(p, g);
4882
+ }
4883
+ };
4884
+ return m(o == null ? void 0 : o.action(d, f, v));
4885
+ },
4886
+ [o, s, a]
4887
+ ), u = X(
4888
+ () => e.decorateActions(o, a),
4889
+ [o, a]
4890
+ ), l = i == null ? void 0 : i.variables;
4891
+ return X(
4892
+ () => ({
4893
+ actions: u,
4894
+ action: c,
4895
+ variables: l
4896
+ }),
4897
+ [u, c, l]
4898
+ );
4899
+ }, hooks: wa }, client: t, update: (a) => {
4900
+ e.useBlockAnalyticsEnabled = a.useBlockAnalyticsEnabled || Wr, e.emitProductClick = a.emitProductClick || Me, e.emitAddToCart = a.emitAddToCart || Me, e.decorateActions = a.decorateActions || Kr, t.configure({
4901
+ appId: a.appId || null,
4902
+ customerProfilesBaseUrl: kv(a),
4903
+ // Arrives after first render from the shell, or up front from a host
4904
+ // that has no bridge. Not in the context key — see the provider.
4905
+ deviceId: a.deviceId || null,
4906
+ shopifyGqlEndpoint: a.shopifyGqlEndpoint || null,
4907
+ shopifyApiKey: a.shopifyApiKey || null,
4908
+ language: a.language || null,
4909
+ country: a.country || null
4910
+ });
4911
+ } };
4912
+ }, zv = (e, t = {}) => {
4913
+ if (!(Object.keys(t.data || {}).some(
4914
+ (i) => {
4915
+ var s;
4916
+ return t.data[i] !== ((s = e == null ? void 0 : e.data) == null ? void 0 : s[i]);
4917
+ }
4918
+ ) || Object.keys(t).some(
4919
+ (i) => i !== "data" && t[i] !== (e == null ? void 0 : e[i])
4920
+ )))
4921
+ return e;
4922
+ const a = { ...e == null ? void 0 : e.data, ...t == null ? void 0 : t.data };
4923
+ return {
4924
+ isLoadingProduct: (e == null ? void 0 : e.isLoadingProduct) ?? !1,
4925
+ isLoadingCollection: (e == null ? void 0 : e.isLoadingCollection) ?? !1,
4926
+ ...t,
4927
+ // Host-resolved product/collection, re-applied AFTER `...incoming` but
4928
+ // only where incoming has nothing real to say.
4929
+ //
4930
+ // This used to sit BEFORE the spread, with a note that the protection was
4931
+ // key-absence — that bridge pushes simply do not carry these keys. True of
4932
+ // every push except the first: WebbridgeProvider's initialState() carries
4933
+ // `product: null` as an OWN key, so `...incoming` nulled a host product
4934
+ // published in the same commit (React flushes a child's mount effect
4935
+ // before the parent's). On a host that never calls mobile.load — standalone
4936
+ // web, App Studio preview, CLI dev — bridge.variables stays initialState()
4937
+ // forever and that null was permanent.
4938
+ //
4939
+ // Nullish rather than truthy is the whole point. A real `product/updated`
4940
+ // carries a product and still wins, so PDP-to-PDP navigation in a pooled
4941
+ // WebView is untouched; only "the bridge has nothing to say here" defers
4942
+ // to the host. Simply reordering the spreads would have made any non-null
4943
+ // product permanently sticky instead.
4944
+ ...(e == null ? void 0 : e.product) && t.product == null && { product: e.product },
4945
+ ...(e == null ? void 0 : e.collection) && t.collection == null && { collection: e.collection },
4946
+ data: a
4947
+ };
4948
+ }, zt = Symbol("no-data-source-provider"), Ea = H(void 0), Vt = H(zt);
4949
+ function Yv({
4950
+ children: e,
4951
+ // Everything else is forwarded to the data source as context/deps.
4952
+ ...t
4953
+ }) {
4954
+ var m, v, g, S;
4955
+ if (!U(tt))
4956
+ throw new Error(
4957
+ "DataSourceProvider must be nested inside a WebbridgeProvider"
4958
+ );
4959
+ const n = lv(), [a, i] = xt(n.variables), s = Jr(
4960
+ ({ product: b, isLoadingProduct: C, collection: x, isLoadingCollection: $ }) => {
4961
+ i((_) => ({
4962
+ ..._,
4963
+ ...b && { product: b },
4964
+ ...x && { collection: x },
4965
+ isLoadingProduct: C ?? !1,
4966
+ isLoadingCollection: $ ?? !1
4967
+ }));
4968
+ },
4969
+ []
4970
+ );
4971
+ We(() => {
4972
+ i((b) => zv(b, n.variables || {}));
4973
+ }, [n.variables]);
4974
+ const o = ((v = (m = n.variables) == null ? void 0 : m.device) == null ? void 0 : v.id) ?? t.deviceId ?? null, c = jv(t), u = X(() => Gv(), [c]);
4975
+ u.update({ ...t, deviceId: o });
4976
+ const l = X(
4977
+ () => ({
4978
+ actions: n.actions,
4979
+ action: n.action,
4980
+ variables: a
4981
+ }),
4982
+ [n.actions, n.action, a]
4983
+ ), d = X(
4984
+ () => ({ variables: a, setProductAndCollectionVariables: s }),
4985
+ [a, s]
4986
+ ), f = (S = (g = n.variables) == null ? void 0 : g.view) == null ? void 0 : S.focused, p = typeof f == "boolean" ? f : void 0;
4987
+ return /* @__PURE__ */ Y.createElement(Sa.Provider, { value: u.api }, /* @__PURE__ */ Y.createElement($a.Provider, { value: u.client }, /* @__PURE__ */ Y.createElement(Aa.Provider, { value: o }, /* @__PURE__ */ Y.createElement(ba.Provider, { value: l }, /* @__PURE__ */ Y.createElement(Ea.Provider, { value: d }, /* @__PURE__ */ Y.createElement(Vt.Provider, { value: p }, e))))));
4988
+ }
4989
+ const Ca = (e) => {
4990
+ const t = U(Sa);
4991
+ if (!t)
4992
+ throw new Error(`${e} must be used within a DataSourceProvider`);
4993
+ return t;
4994
+ }, Xv = () => Ca("useDataSource"), Qv = (e) => Ca("useTapcart").useTapcart(e), Hv = () => {
4995
+ const e = U(Vt);
4996
+ if (e === zt)
4997
+ throw new Error("useViewFocused must be used within a DataSourceProvider");
4998
+ return e === !0;
4999
+ }, e0 = () => {
5000
+ const e = U(Vt);
5001
+ if (e === zt)
5002
+ throw new Error(
5003
+ "useViewFocusedState must be used within a DataSourceProvider"
5004
+ );
5005
+ return e;
5006
+ }, t0 = () => {
5007
+ const e = U(Ea);
5008
+ if (!e)
5009
+ throw new Error(
5010
+ "useSetProductAndCollectionVariables must be used within a DataSourceProvider"
5011
+ );
5012
+ return e.setProductAndCollectionVariables;
5013
+ };
5014
+ export {
5015
+ Yv as DataSourceProvider,
5016
+ Kv as WebbridgeProvider,
5017
+ Zv as getHooksModule,
5018
+ Bv as loadWebbridge,
5019
+ Wv as useActions,
5020
+ Xv as useDataSource,
5021
+ Qv as useDataSourceTapcart,
5022
+ t0 as useSetProductAndCollectionVariables,
5023
+ lv as useTapcart,
5024
+ Jv as useVariables,
5025
+ Hv as useViewFocused,
5026
+ e0 as useViewFocusedState
5027
+ };