@thirstie/ecomm-vue 0.0.5 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4622 +0,0 @@
1
- var ht = (r, e, t) => {
2
- if (!e.has(r))
3
- throw TypeError("Cannot " + t);
4
- };
5
- var v = (r, e, t) => (ht(r, e, "read from private field"), t ? t.call(r) : e.get(r)), E = (r, e, t) => {
6
- if (e.has(r))
7
- throw TypeError("Cannot add the same private member more than once");
8
- e instanceof WeakSet ? e.add(r) : e.set(r, t);
9
- }, N = (r, e, t, n) => (ht(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
10
- var te = (r, e, t) => (ht(r, e, "access private method"), t);
11
- import { openBlock as vt, createElementBlock as _t, createElementVNode as $, toDisplayString as wt, pushScopeId as lr, popScopeId as dr, ref as fr, defineCustomElement as Nt } from "vue";
12
- const hr = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20style='position:absolute;%20width:%200;%20height:%200'%3e%3csymbol%20viewBox='0%200%20674.2%20158.7'%20id='thirstie-footer'%3e%3cpath%20fill='currentColor'%20d='M168.15%2076.05H139v-35.5h-6.8v77.8h6.8v-35.6h29.2v35.5h6.9v-77.7h-6.9zm-122.5-28.9h18.2v71.1h6.9v-71.1H89v-6.7H45.75v6.7zm176.1%2071.1h6.9v-77.7h-6.9zm84.6-34.6a18.74%2018.74%200%200%200%2010-10.2%2018.61%2018.61%200%200%200%201.5-7.5v-6.3a19.31%2019.31%200%200%200-1.5-7.5%2018.74%2018.74%200%200%200-10-10.2%2018%2018%200%200%200-7.3-1.5h-24.2v77.8h6.9v-33.2h9.4l20.7%2033.2h7.9l-20.7-33.2a17.92%2017.92%200%200%200%207.3-1.4zm-24.6-5.2v-31.3h17a11.17%2011.17%200%200%201%204.8%201%2010.52%2010.52%200%200%201%203.8%202.7%2012%2012%200%200%201%202.6%204%2013%2013%200%200%201%201%204.9v6.3a11.62%2011.62%200%200%201-1%204.9%2013.13%2013.13%200%200%201-2.6%204%2014.59%2014.59%200%200%201-3.8%202.7%2011.17%2011.17%200%200%201-4.8%201h-17zm163.8-31.3h18.2v71.1h6.9v-71.1h18.2v-6.7h-43.2v6.7zm86.5%2071.6H539v-78.2h-6.9zm96.5-71.6v-6.7h-42.9v77.8h42.9v-6.7h-36v-28.8h29.2v-6.7h-29.2v-28.9zm-228.8%2036.5a24.26%2024.26%200%200%200-5.8-4.1%2066.2%2066.2%200%200%200-6.6-3q-3.45-1.35-6.6-2.7a27%2027%200%200%201-5.8-3.2%2014.29%2014.29%200%200%201-4.1-4.4%2012.24%2012.24%200%200%201-1.5-6.3v-1.5a11.94%2011.94%200%200%201%201-4.9%2011.6%2011.6%200%200%201%202.6-3.9%2013.58%2013.58%200%200%201%203.9-2.7%2012.87%2012.87%200%200%201%204.8-1H386a11.17%2011.17%200%200%201%204.8%201%2011.86%2011.86%200%200%201%203.9%202.7%2011.6%2011.6%200%200%201%202.6%203.9%2013%2013%200%200%201%201%204.9v3.1l6.9-1.1v-2a18.47%2018.47%200%200%200-1.5-7.4%2020.8%2020.8%200%200%200-4-6.1%2020.17%2020.17%200%200%200-5.9-4.1%2018%2018%200%200%200-7.3-1.5h-4.9a18%2018%200%200%200-7.3%201.5%2018.74%2018.74%200%200%200-10%2010.2%2018.47%2018.47%200%200%200-1.5%207.4V60a21%2021%200%200%200%201.5%208.4%2017.41%2017.41%200%200%200%204.1%205.8%2021.1%2021.1%200%200%200%205.8%203.9c2.1%201%204.3%202%206.6%202.9s4.5%201.7%206.6%202.6a27%2027%200%200%201%205.8%203.2%2014.62%2014.62%200%200%201%204.1%204.5%2013.55%2013.55%200%200%201%201.5%206.7v2.3a11.62%2011.62%200%200%201-1%204.9%2013.77%2013.77%200%200%201-2.8%204%2015.64%2015.64%200%200%201-4%202.7%2012.87%2012.87%200%200%201-4.8%201H381a11.94%2011.94%200%200%201-4.9-1%2016.19%2016.19%200%200%201-4.1-2.7%2012.56%2012.56%200%200%201-2.8-4%2011.31%2011.31%200%200%201-1-4.9v-4.2l-6.9%201.1v3.1a17%2017%200%200%200%201.6%207.4%2019.58%2019.58%200%200%200%204.2%206.1%2021.1%2021.1%200%200%200%206.1%204.1%2018.47%2018.47%200%200%200%207.4%201.5h5.5a18.83%2018.83%200%200%200%207.4-1.5%2019.83%2019.83%200%200%200%206.1-4.1%2019.32%2019.32%200%200%200%205.8-13.5V98a21.89%2021.89%200%200%200-1.5-8.5%2020.84%2020.84%200%200%200-4.15-5.85z'%3e%3c/path%3e%3cpath%20fill='currentColor'%20d='M663.2%20158.7H11a11%2011%200%200%201-11-11V11A11%2011%200%200%201%2011%200h652.2a11%2011%200%200%201%2011%2011v136.7a11%2011%200%200%201-11%2011zM11%208a3%203%200%200%200-3%203v136.7a3%203%200%200%200%203%203h652.2a3%203%200%200%200%203-3V11a3%203%200%200%200-3-3z'%3e%3c/path%3e%3c/symbol%3e%3csymbol%20viewBox='0%200%20159%20159'%20id='thirstielogo'%3e%3cpath%20d='M146.7%200H11.9A11.86%2011.86%200%200%200%200%2011.85v134.8a11.86%2011.86%200%200%200%2011.9%2011.9h134.8a11.86%2011.86%200%200%200%2011.9-11.9V11.85C158.52%205.32%20153.23.054%20146.7%200zm3.9%20146.7a4%204%200%200%201-4%204H11.9a4%204%200%200%201-4-4V11.85a4%204%200%200%201%204-4h134.8a4%204%200%200%201%204%204v134.8l-.1.05zM57.4%2047.25h18.4v70.5h6.9v-70.5h18.4v-6.6H57.4v6.6z'%20fill='currentColor'%20fill-rule='nonzero'%3e%3c/path%3e%3c/symbol%3e", pr = ".th-disclaimer-wrapper[data-v-a5b58af1]{width:75%;margin:1rem auto;text-align:center;line-height:22px;color:#aaa}.th-disclaimer-content[data-v-a5b58af1]{color:#666}.th-disclaimer-logo[data-v-a5b58af1]{color:#ddd;vertical-align:middle}", qt = (r, e) => {
13
- const t = r.__vccOpts || r;
14
- for (const [n, s] of e)
15
- t[n] = s;
16
- return t;
17
- }, mr = (r) => (lr("data-v-a5b58af1"), r = r(), dr(), r), gr = hr + "#thirstie-footer", yr = { class: "th-disclaimer-wrapper" }, vr = /* @__PURE__ */ mr(() => /* @__PURE__ */ $("div", { class: "th-disclaimer-content" }, [
18
- /* @__PURE__ */ $("span", null, " All sales of alcohol are fulfilled by licensed retailers on the Thirstie Network. Shopping experience powered by "),
19
- /* @__PURE__ */ $("a", {
20
- href: "https://thirstie.com",
21
- target: "_blank",
22
- "aria-label": "thirstie - opens in new tab",
23
- tabindex: 0
24
- }, [
25
- /* @__PURE__ */ $("svg", {
26
- role: "img",
27
- "aria-label": "Thirstie Logo",
28
- class: "th-disclaimer-logo",
29
- width: "80px",
30
- height: "16px"
31
- }, [
32
- /* @__PURE__ */ $("title", null, "Powered by Thirstie"),
33
- /* @__PURE__ */ $("use", {
34
- fill: "currentColor",
35
- "xlink:href": gr
36
- })
37
- ])
38
- ])
39
- ], -1)), _r = {
40
- __name: "Disclaimer.ce",
41
- props: {
42
- msg: String
43
- },
44
- setup(r) {
45
- return (e, t) => (vt(), _t("div", yr, [
46
- $("h3", null, wt(r.msg || "Powered By Thirstie"), 1),
47
- vr
48
- ]));
49
- }
50
- }, wr = /* @__PURE__ */ qt(_r, [["styles", [pr]], ["__scopeId", "data-v-a5b58af1"]]);
51
- async function kr(r, e) {
52
- const t = {
53
- ok: null,
54
- status: null,
55
- statusText: null,
56
- data: {}
57
- };
58
- try {
59
- const n = await fetch(r, e);
60
- let s = {};
61
- const a = n.headers;
62
- return a && a.get("content-type").indexOf("application/json") > -1 && parseInt(a.get("content-length")) > 0 && (s = await n.json()), Object.assign(t, {
63
- ok: n.ok,
64
- status: n.status,
65
- statusText: n.statusText,
66
- data: s,
67
- url: r
68
- });
69
- } catch (n) {
70
- return console.error("apiRequest error: ", n), Object.assign(t, {
71
- ok: !1,
72
- status: 500,
73
- statusText: "ERROR",
74
- data: { message: "Network error", error: n },
75
- url: r
76
- });
77
- }
78
- }
79
- var De, Le, M, le, ze, de, Je, fe, Qe;
80
- class br {
81
- /**
82
- * Initialize Thirstie API with public api key
83
- * @param {string} apiKey - The public basic auth key, defines application access
84
- * @param {Object=} config - Any optional config settings
85
- * @param {Object} config.initState - Values to initialize session state
86
- */
87
- constructor(e, t = {}) {
88
- E(this, de);
89
- E(this, fe);
90
- // private fields
91
- E(this, De, void 0);
92
- E(this, Le, void 0);
93
- E(this, M, void 0);
94
- E(this, le, void 0);
95
- E(this, ze, void 0);
96
- const { env: n, initState: s } = t;
97
- N(this, ze, n), N(this, le, {
98
- sessionToken: null,
99
- application: null,
100
- applicationRef: null,
101
- sessionRef: null,
102
- userRef: null
103
- }), N(this, De, e), N(this, Le, n === "prod" ? "https://api.thirstie.com" : "https://api.next.thirstie.com"), N(this, M, Object.seal(v(this, le))), s && (this.apiState = s);
104
- }
105
- get sessionToken() {
106
- return v(this, M).sessionToken;
107
- }
108
- get sessionRef() {
109
- return v(this, M).sessionRef;
110
- }
111
- get applicationRef() {
112
- return v(this, M).applicationRef;
113
- }
114
- get apiState() {
115
- return v(this, M);
116
- }
117
- get sessionState() {
118
- const { sessionToken: e, sessionRef: t, application: n, applicationRef: s, userRef: a } = v(this, M);
119
- return { sessionToken: e, sessionRef: t, application: n, applicationRef: s, userRef: a };
120
- }
121
- set apiState(e) {
122
- try {
123
- return Object.assign(v(this, M), e);
124
- } catch (t) {
125
- return console.error("set apiState", t), v(this, M);
126
- }
127
- }
128
- /**
129
- * Create a new session and retrieve a bearer token.
130
- *
131
- * Defaults to creating an anonymous session. If userCredentials are
132
- * provided, then a user session will be returned.
133
- *
134
- * @param {Object=} userCredentials - user email & password
135
- * @param {string} userCredentials.email
136
- * @param {string} userCredentials.password
137
- * @param {boolean} [basicAuth=true] - force use of application basic auth
138
- * @returns {response}
139
- */
140
- async getNewSession(e = {}, t = !0) {
141
- const { email: n, password: s } = e, a = { basicAuth: t };
142
- n && s && (a.data = { email: n, password: s });
143
- const o = await this.apiCaller("POST", "/a/v2/sessions", a);
144
- return o && o.ok && o.data ? o.data : { code: o.status, message: o.statusText || "unknown error", response: o };
145
- }
146
- async validateSession(e) {
147
- if (e && (this.apiState = { sessionToken: e }), !this.sessionToken)
148
- return {};
149
- const n = await this.apiCaller("GET", "/a/v2/sessions");
150
- return n && n.ok && n.data ? n.data : await this.getNewSession();
151
- }
152
- async fetchSession() {
153
- let e = {};
154
- return this.sessionToken ? e = await this.validateSession() : e = await this.getNewSession(), e.token ? te(this, de, Je).call(this, e) : te(this, fe, Qe).call(this, e), e;
155
- }
156
- async loginAnonymousSession(e) {
157
- const { email: t, password: n } = e, s = !this.sessionToken;
158
- if (!(t && n))
159
- throw new Error("Invalid credential payload");
160
- const a = await this.getNewSession(e, s);
161
- return a.token ? te(this, de, Je).call(this, a) : te(this, fe, Qe).call(this, a), a;
162
- }
163
- async createUser(e, t = null) {
164
- const n = {}, { email: s, password: a } = e, { birthday: i, prefix: o, firstName: c, lastName: u, phoneNumber: d, guestCheck: y } = e, x = {
165
- email: s,
166
- birthday: i,
167
- prefix: o,
168
- first_name: c,
169
- last_name: u,
170
- phone_number: d,
171
- guest_check: !!y
172
- }, k = !this.sessionToken;
173
- s && a ? x.password = a : x.guest = !0, n.data = x, n.basicAuth = k;
174
- const I = await this.apiCaller("POST", "/a/v2/users", n, t);
175
- return I.data.token ? te(this, de, Je).call(this, I.data) : te(this, fe, Qe).call(this, I), I;
176
- }
177
- async apiCaller(e, t, n = {}, s = null) {
178
- const { data: a, params: i, basicAuth: o } = n, { sessionRef: c, application: u, applicationRef: d, userRef: y } = this.sessionState;
179
- if (!this.sessionToken && !o)
180
- throw new Error("Invalid Authorization");
181
- const x = this.sessionToken && !o ? `Bearer ${this.sessionToken}` : `Basic ${btoa(v(this, De))}`, k = {
182
- method: e,
183
- headers: {
184
- Authorization: x,
185
- Accept: "application/json",
186
- "Content-Type": "application/json"
187
- }
188
- };
189
- ["POST", "PUT", "PATCH"].includes(e) && a && (k.body = JSON.stringify(a));
190
- let I = "";
191
- i && (I = new URLSearchParams(i).toString());
192
- const Q = {
193
- environment: v(this, ze),
194
- sessionRef: c,
195
- application: u,
196
- applicationRef: d,
197
- userRef: y,
198
- data: a,
199
- queryString: I,
200
- url: t
201
- }, ee = `${v(this, Le)}${t}${I}`;
202
- try {
203
- const R = await kr(ee, k);
204
- if (R)
205
- return !R.ok && s && s({ code: R.status, message: R.statusText || "unknown error", response: R, telemetryContext: Q }), R;
206
- } catch (R) {
207
- return s && s({ code: 500, message: "unknown error", error: R, telemetryContext: Q }), R;
208
- }
209
- }
210
- }
211
- De = new WeakMap(), Le = new WeakMap(), M = new WeakMap(), le = new WeakMap(), ze = new WeakMap(), de = new WeakSet(), Je = function(e) {
212
- const t = {
213
- application: e.application_name,
214
- applicationRef: e.uuid,
215
- sessionToken: e.token,
216
- sessionRef: e.session_uuid
217
- };
218
- e.user && (t.userRef = e.user.id), this.apiState = t;
219
- }, fe = new WeakSet(), Qe = function(e) {
220
- this.apiState = v(this, le), console.error("sessionError", e);
221
- };
222
- function S(r) {
223
- return r != null && typeof r == "object" && r["@@functional/placeholder"] === !0;
224
- }
225
- function O(r) {
226
- return function e(t) {
227
- return arguments.length === 0 || S(t) ? e : r.apply(this, arguments);
228
- };
229
- }
230
- function C(r) {
231
- return function e(t, n) {
232
- switch (arguments.length) {
233
- case 0:
234
- return e;
235
- case 1:
236
- return S(t) ? e : O(function(s) {
237
- return r(t, s);
238
- });
239
- default:
240
- return S(t) && S(n) ? e : S(t) ? O(function(s) {
241
- return r(s, n);
242
- }) : S(n) ? O(function(s) {
243
- return r(t, s);
244
- }) : r(t, n);
245
- }
246
- };
247
- }
248
- function ut(r, e) {
249
- switch (r) {
250
- case 0:
251
- return function() {
252
- return e.apply(this, arguments);
253
- };
254
- case 1:
255
- return function(t) {
256
- return e.apply(this, arguments);
257
- };
258
- case 2:
259
- return function(t, n) {
260
- return e.apply(this, arguments);
261
- };
262
- case 3:
263
- return function(t, n, s) {
264
- return e.apply(this, arguments);
265
- };
266
- case 4:
267
- return function(t, n, s, a) {
268
- return e.apply(this, arguments);
269
- };
270
- case 5:
271
- return function(t, n, s, a, i) {
272
- return e.apply(this, arguments);
273
- };
274
- case 6:
275
- return function(t, n, s, a, i, o) {
276
- return e.apply(this, arguments);
277
- };
278
- case 7:
279
- return function(t, n, s, a, i, o, c) {
280
- return e.apply(this, arguments);
281
- };
282
- case 8:
283
- return function(t, n, s, a, i, o, c, u) {
284
- return e.apply(this, arguments);
285
- };
286
- case 9:
287
- return function(t, n, s, a, i, o, c, u, d) {
288
- return e.apply(this, arguments);
289
- };
290
- case 10:
291
- return function(t, n, s, a, i, o, c, u, d, y) {
292
- return e.apply(this, arguments);
293
- };
294
- default:
295
- throw new Error("First argument to _arity must be a non-negative integer no greater than ten");
296
- }
297
- }
298
- function Bt(r, e, t) {
299
- return function() {
300
- for (var n = [], s = 0, a = r, i = 0, o = !1; i < e.length || s < arguments.length; ) {
301
- var c;
302
- i < e.length && (!S(e[i]) || s >= arguments.length) ? c = e[i] : (c = arguments[s], s += 1), n[i] = c, S(c) ? o = !0 : a -= 1, i += 1;
303
- }
304
- return !o && a <= 0 ? t.apply(this, n) : ut(Math.max(0, a), Bt(r, n, t));
305
- };
306
- }
307
- var Ct = /* @__PURE__ */ C(function(e, t) {
308
- return e === 1 ? O(t) : ut(e, Bt(e, [], t));
309
- });
310
- function Ot(r) {
311
- return function e(t, n, s) {
312
- switch (arguments.length) {
313
- case 0:
314
- return e;
315
- case 1:
316
- return S(t) ? e : C(function(a, i) {
317
- return r(t, a, i);
318
- });
319
- case 2:
320
- return S(t) && S(n) ? e : S(t) ? C(function(a, i) {
321
- return r(a, n, i);
322
- }) : S(n) ? C(function(a, i) {
323
- return r(t, a, i);
324
- }) : O(function(a) {
325
- return r(t, n, a);
326
- });
327
- default:
328
- return S(t) && S(n) && S(s) ? e : S(t) && S(n) ? C(function(a, i) {
329
- return r(a, i, s);
330
- }) : S(t) && S(s) ? C(function(a, i) {
331
- return r(a, n, i);
332
- }) : S(n) && S(s) ? C(function(a, i) {
333
- return r(t, a, i);
334
- }) : S(t) ? O(function(a) {
335
- return r(a, n, s);
336
- }) : S(n) ? O(function(a) {
337
- return r(t, a, s);
338
- }) : S(s) ? O(function(a) {
339
- return r(t, n, a);
340
- }) : r(t, n, s);
341
- }
342
- };
343
- }
344
- var We = Array.isArray || function(e) {
345
- return e != null && e.length >= 0 && Object.prototype.toString.call(e) === "[object Array]";
346
- };
347
- function xr(r) {
348
- return r != null && typeof r["@@transducer/step"] == "function";
349
- }
350
- function Et(r, e, t) {
351
- return function() {
352
- if (arguments.length === 0)
353
- return t();
354
- var n = arguments[arguments.length - 1];
355
- if (!We(n)) {
356
- for (var s = 0; s < r.length; ) {
357
- if (typeof n[r[s]] == "function")
358
- return n[r[s]].apply(n, Array.prototype.slice.call(arguments, 0, -1));
359
- s += 1;
360
- }
361
- if (xr(n)) {
362
- var a = e.apply(null, Array.prototype.slice.call(arguments, 0, -1));
363
- return a(n);
364
- }
365
- }
366
- return t.apply(this, arguments);
367
- };
368
- }
369
- function Sr(r) {
370
- return r && r["@@transducer/reduced"] ? r : {
371
- "@@transducer/value": r,
372
- "@@transducer/reduced": !0
373
- };
374
- }
375
- var be = {
376
- init: function() {
377
- return this.xf["@@transducer/init"]();
378
- },
379
- result: function(r) {
380
- return this.xf["@@transducer/result"](r);
381
- }
382
- };
383
- function jt(r) {
384
- for (var e = [], t; !(t = r.next()).done; )
385
- e.push(t.value);
386
- return e;
387
- }
388
- function Rt(r, e, t) {
389
- for (var n = 0, s = t.length; n < s; ) {
390
- if (r(e, t[n]))
391
- return !0;
392
- n += 1;
393
- }
394
- return !1;
395
- }
396
- function Tr(r) {
397
- var e = String(r).match(/^function (\w*)/);
398
- return e == null ? "" : e[1];
399
- }
400
- function xe(r, e) {
401
- return Object.prototype.hasOwnProperty.call(e, r);
402
- }
403
- function Cr(r, e) {
404
- return r === e ? r !== 0 || 1 / r === 1 / e : r !== r && e !== e;
405
- }
406
- var pt = typeof Object.is == "function" ? Object.is : Cr, Pt = Object.prototype.toString, Gt = /* @__PURE__ */ function() {
407
- return Pt.call(arguments) === "[object Arguments]" ? function(e) {
408
- return Pt.call(e) === "[object Arguments]";
409
- } : function(e) {
410
- return xe("callee", e);
411
- };
412
- }(), Or = !/* @__PURE__ */ {
413
- toString: null
414
- }.propertyIsEnumerable("toString"), Zt = ["constructor", "valueOf", "isPrototypeOf", "toString", "propertyIsEnumerable", "hasOwnProperty", "toLocaleString"], Mt = /* @__PURE__ */ function() {
415
- return arguments.propertyIsEnumerable("length");
416
- }(), Er = function(e, t) {
417
- for (var n = 0; n < e.length; ) {
418
- if (e[n] === t)
419
- return !0;
420
- n += 1;
421
- }
422
- return !1;
423
- }, me = /* @__PURE__ */ O(typeof Object.keys == "function" && !Mt ? function(e) {
424
- return Object(e) !== e ? [] : Object.keys(e);
425
- } : function(e) {
426
- if (Object(e) !== e)
427
- return [];
428
- var t, n, s = [], a = Mt && Gt(e);
429
- for (t in e)
430
- xe(t, e) && (!a || t !== "length") && (s[s.length] = t);
431
- if (Or)
432
- for (n = Zt.length - 1; n >= 0; )
433
- t = Zt[n], xe(t, e) && !Er(s, t) && (s[s.length] = t), n -= 1;
434
- return s;
435
- }), $t = /* @__PURE__ */ O(function(e) {
436
- return e === null ? "Null" : e === void 0 ? "Undefined" : Object.prototype.toString.call(e).slice(8, -1);
437
- });
438
- function Dt(r, e, t, n) {
439
- var s = jt(r), a = jt(e);
440
- function i(o, c) {
441
- return At(o, c, t.slice(), n.slice());
442
- }
443
- return !Rt(function(o, c) {
444
- return !Rt(i, c, o);
445
- }, a, s);
446
- }
447
- function At(r, e, t, n) {
448
- if (pt(r, e))
449
- return !0;
450
- var s = $t(r);
451
- if (s !== $t(e))
452
- return !1;
453
- if (typeof r["fantasy-land/equals"] == "function" || typeof e["fantasy-land/equals"] == "function")
454
- return typeof r["fantasy-land/equals"] == "function" && r["fantasy-land/equals"](e) && typeof e["fantasy-land/equals"] == "function" && e["fantasy-land/equals"](r);
455
- if (typeof r.equals == "function" || typeof e.equals == "function")
456
- return typeof r.equals == "function" && r.equals(e) && typeof e.equals == "function" && e.equals(r);
457
- switch (s) {
458
- case "Arguments":
459
- case "Array":
460
- case "Object":
461
- if (typeof r.constructor == "function" && Tr(r.constructor) === "Promise")
462
- return r === e;
463
- break;
464
- case "Boolean":
465
- case "Number":
466
- case "String":
467
- if (!(typeof r == typeof e && pt(r.valueOf(), e.valueOf())))
468
- return !1;
469
- break;
470
- case "Date":
471
- if (!pt(r.valueOf(), e.valueOf()))
472
- return !1;
473
- break;
474
- case "Error":
475
- return r.name === e.name && r.message === e.message;
476
- case "RegExp":
477
- if (!(r.source === e.source && r.global === e.global && r.ignoreCase === e.ignoreCase && r.multiline === e.multiline && r.sticky === e.sticky && r.unicode === e.unicode))
478
- return !1;
479
- break;
480
- }
481
- for (var a = t.length - 1; a >= 0; ) {
482
- if (t[a] === r)
483
- return n[a] === e;
484
- a -= 1;
485
- }
486
- switch (s) {
487
- case "Map":
488
- return r.size !== e.size ? !1 : Dt(r.entries(), e.entries(), t.concat([r]), n.concat([e]));
489
- case "Set":
490
- return r.size !== e.size ? !1 : Dt(r.values(), e.values(), t.concat([r]), n.concat([e]));
491
- case "Arguments":
492
- case "Array":
493
- case "Object":
494
- case "Boolean":
495
- case "Number":
496
- case "String":
497
- case "Date":
498
- case "Error":
499
- case "RegExp":
500
- case "Int8Array":
501
- case "Uint8Array":
502
- case "Uint8ClampedArray":
503
- case "Int16Array":
504
- case "Uint16Array":
505
- case "Int32Array":
506
- case "Uint32Array":
507
- case "Float32Array":
508
- case "Float64Array":
509
- case "ArrayBuffer":
510
- break;
511
- default:
512
- return !1;
513
- }
514
- var i = me(r);
515
- if (i.length !== me(e).length)
516
- return !1;
517
- var o = t.concat([r]), c = n.concat([e]);
518
- for (a = i.length - 1; a >= 0; ) {
519
- var u = i[a];
520
- if (!(xe(u, e) && At(e[u], r[u], o, c)))
521
- return !1;
522
- a -= 1;
523
- }
524
- return !0;
525
- }
526
- var Wt = /* @__PURE__ */ C(function(e, t) {
527
- return At(e, t, [], []);
528
- });
529
- function Ar(r, e, t) {
530
- var n, s;
531
- if (typeof r.indexOf == "function")
532
- switch (typeof e) {
533
- case "number":
534
- if (e === 0) {
535
- for (n = 1 / e; t < r.length; ) {
536
- if (s = r[t], s === 0 && 1 / s === n)
537
- return t;
538
- t += 1;
539
- }
540
- return -1;
541
- } else if (e !== e) {
542
- for (; t < r.length; ) {
543
- if (s = r[t], typeof s == "number" && s !== s)
544
- return t;
545
- t += 1;
546
- }
547
- return -1;
548
- }
549
- return r.indexOf(e, t);
550
- case "string":
551
- case "boolean":
552
- case "function":
553
- case "undefined":
554
- return r.indexOf(e, t);
555
- case "object":
556
- if (e === null)
557
- return r.indexOf(e, t);
558
- }
559
- for (; t < r.length; ) {
560
- if (Wt(r[t], e))
561
- return t;
562
- t += 1;
563
- }
564
- return -1;
565
- }
566
- function Ft(r, e) {
567
- return Ar(e, r, 0) >= 0;
568
- }
569
- function et(r, e) {
570
- for (var t = 0, n = e.length, s = Array(n); t < n; )
571
- s[t] = r(e[t]), t += 1;
572
- return s;
573
- }
574
- function mt(r) {
575
- var e = r.replace(/\\/g, "\\\\").replace(/[\b]/g, "\\b").replace(/\f/g, "\\f").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/\v/g, "\\v").replace(/\0/g, "\\0");
576
- return '"' + e.replace(/"/g, '\\"') + '"';
577
- }
578
- var _e = function(e) {
579
- return (e < 10 ? "0" : "") + e;
580
- }, Ir = typeof Date.prototype.toISOString == "function" ? function(e) {
581
- return e.toISOString();
582
- } : function(e) {
583
- return e.getUTCFullYear() + "-" + _e(e.getUTCMonth() + 1) + "-" + _e(e.getUTCDate()) + "T" + _e(e.getUTCHours()) + ":" + _e(e.getUTCMinutes()) + ":" + _e(e.getUTCSeconds()) + "." + (e.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
584
- };
585
- function Nr(r) {
586
- return function() {
587
- return !r.apply(this, arguments);
588
- };
589
- }
590
- function Ht(r, e, t) {
591
- for (var n = 0, s = t.length; n < s; )
592
- e = r(e, t[n]), n += 1;
593
- return e;
594
- }
595
- function jr(r, e) {
596
- for (var t = 0, n = e.length, s = []; t < n; )
597
- r(e[t]) && (s[s.length] = e[t]), t += 1;
598
- return s;
599
- }
600
- function Kt(r) {
601
- return Object.prototype.toString.call(r) === "[object Object]";
602
- }
603
- var Rr = /* @__PURE__ */ function() {
604
- function r(e, t) {
605
- this.xf = t, this.f = e;
606
- }
607
- return r.prototype["@@transducer/init"] = be.init, r.prototype["@@transducer/result"] = be.result, r.prototype["@@transducer/step"] = function(e, t) {
608
- return this.f(t) ? this.xf["@@transducer/step"](e, t) : e;
609
- }, r;
610
- }();
611
- function Pr(r) {
612
- return function(e) {
613
- return new Rr(r, e);
614
- };
615
- }
616
- var ne = /* @__PURE__ */ C(
617
- /* @__PURE__ */ Et(["fantasy-land/filter", "filter"], Pr, function(r, e) {
618
- return Kt(e) ? Ht(function(t, n) {
619
- return r(e[n]) && (t[n] = e[n]), t;
620
- }, {}, me(e)) : (
621
- // else
622
- jr(r, e)
623
- );
624
- })
625
- ), Zr = /* @__PURE__ */ C(function(e, t) {
626
- return ne(Nr(e), t);
627
- });
628
- function Yt(r, e) {
629
- var t = function(i) {
630
- var o = e.concat([r]);
631
- return Ft(i, o) ? "<Circular>" : Yt(i, o);
632
- }, n = function(a, i) {
633
- return et(function(o) {
634
- return mt(o) + ": " + t(a[o]);
635
- }, i.slice().sort());
636
- };
637
- switch (Object.prototype.toString.call(r)) {
638
- case "[object Arguments]":
639
- return "(function() { return arguments; }(" + et(t, r).join(", ") + "))";
640
- case "[object Array]":
641
- return "[" + et(t, r).concat(n(r, Zr(function(a) {
642
- return /^\d+$/.test(a);
643
- }, me(r)))).join(", ") + "]";
644
- case "[object Boolean]":
645
- return typeof r == "object" ? "new Boolean(" + t(r.valueOf()) + ")" : r.toString();
646
- case "[object Date]":
647
- return "new Date(" + (isNaN(r.valueOf()) ? t(NaN) : mt(Ir(r))) + ")";
648
- case "[object Map]":
649
- return "new Map(" + t(Array.from(r)) + ")";
650
- case "[object Null]":
651
- return "null";
652
- case "[object Number]":
653
- return typeof r == "object" ? "new Number(" + t(r.valueOf()) + ")" : 1 / r === -1 / 0 ? "-0" : r.toString(10);
654
- case "[object Set]":
655
- return "new Set(" + t(Array.from(r).sort()) + ")";
656
- case "[object String]":
657
- return typeof r == "object" ? "new String(" + t(r.valueOf()) + ")" : mt(r);
658
- case "[object Undefined]":
659
- return "undefined";
660
- default:
661
- if (typeof r.toString == "function") {
662
- var s = r.toString();
663
- if (s !== "[object Object]")
664
- return s;
665
- }
666
- return "{" + n(r, me(r)).join(", ") + "}";
667
- }
668
- }
669
- var Mr = /* @__PURE__ */ O(function(e) {
670
- return Yt(e, []);
671
- }), $r = /* @__PURE__ */ function() {
672
- function r(e, t) {
673
- this.xf = t, this.f = e;
674
- }
675
- return r.prototype["@@transducer/init"] = be.init, r.prototype["@@transducer/result"] = be.result, r.prototype["@@transducer/step"] = function(e, t) {
676
- return this.xf["@@transducer/step"](e, this.f(t));
677
- }, r;
678
- }(), Dr = function(e) {
679
- return function(t) {
680
- return new $r(e, t);
681
- };
682
- }, Lr = /* @__PURE__ */ C(
683
- /* @__PURE__ */ Et(["fantasy-land/map", "map"], Dr, function(e, t) {
684
- switch (Object.prototype.toString.call(t)) {
685
- case "[object Function]":
686
- return Ct(t.length, function() {
687
- return e.call(this, t.apply(this, arguments));
688
- });
689
- case "[object Object]":
690
- return Ht(function(n, s) {
691
- return n[s] = e(t[s]), n;
692
- }, {}, me(t));
693
- default:
694
- return et(e, t);
695
- }
696
- })
697
- ), lt = Number.isInteger || function(e) {
698
- return e << 0 === e;
699
- };
700
- function dt(r) {
701
- return Object.prototype.toString.call(r) === "[object String]";
702
- }
703
- var Xt = /* @__PURE__ */ C(function(e, t) {
704
- var n = e < 0 ? t.length + e : e;
705
- return dt(t) ? t.charAt(n) : t[n];
706
- }), zr = /* @__PURE__ */ C(function(e, t) {
707
- if (t != null)
708
- return lt(e) ? Xt(e, t) : t[e];
709
- }), Ur = /* @__PURE__ */ O(function(e) {
710
- return We(e) ? !0 : !e || typeof e != "object" || dt(e) ? !1 : e.length === 0 ? !0 : e.length > 0 ? e.hasOwnProperty(0) && e.hasOwnProperty(e.length - 1) : !1;
711
- }), Lt = typeof Symbol < "u" ? Symbol.iterator : "@@iterator";
712
- function Vr(r, e, t) {
713
- return function(s, a, i) {
714
- if (Ur(i))
715
- return r(s, a, i);
716
- if (i == null)
717
- return a;
718
- if (typeof i["fantasy-land/reduce"] == "function")
719
- return e(s, a, i, "fantasy-land/reduce");
720
- if (i[Lt] != null)
721
- return t(s, a, i[Lt]());
722
- if (typeof i.next == "function")
723
- return t(s, a, i);
724
- if (typeof i.reduce == "function")
725
- return e(s, a, i, "reduce");
726
- throw new TypeError("reduce: list must be array or iterable");
727
- };
728
- }
729
- function qr(r, e, t) {
730
- for (var n = 0, s = t.length; n < s; ) {
731
- if (e = r["@@transducer/step"](e, t[n]), e && e["@@transducer/reduced"]) {
732
- e = e["@@transducer/value"];
733
- break;
734
- }
735
- n += 1;
736
- }
737
- return r["@@transducer/result"](e);
738
- }
739
- var Br = /* @__PURE__ */ C(function(e, t) {
740
- return ut(e.length, function() {
741
- return e.apply(t, arguments);
742
- });
743
- });
744
- function Gr(r, e, t) {
745
- for (var n = t.next(); !n.done; ) {
746
- if (e = r["@@transducer/step"](e, n.value), e && e["@@transducer/reduced"]) {
747
- e = e["@@transducer/value"];
748
- break;
749
- }
750
- n = t.next();
751
- }
752
- return r["@@transducer/result"](e);
753
- }
754
- function Wr(r, e, t, n) {
755
- return r["@@transducer/result"](t[n](Br(r["@@transducer/step"], r), e));
756
- }
757
- var Fr = /* @__PURE__ */ Vr(qr, Wr, Gr), Hr = /* @__PURE__ */ function() {
758
- function r(e) {
759
- this.f = e;
760
- }
761
- return r.prototype["@@transducer/init"] = function() {
762
- throw new Error("init not implemented on XWrap");
763
- }, r.prototype["@@transducer/result"] = function(e) {
764
- return e;
765
- }, r.prototype["@@transducer/step"] = function(e, t) {
766
- return this.f(e, t);
767
- }, r;
768
- }();
769
- function Kr(r) {
770
- return new Hr(r);
771
- }
772
- var Yr = /* @__PURE__ */ Ot(function(r, e, t) {
773
- return Fr(typeof r == "function" ? Kr(r) : r, e, t);
774
- });
775
- function Xr(r, e, t) {
776
- if (lt(r) && We(t)) {
777
- var n = [].concat(t);
778
- return n[r] = e, n;
779
- }
780
- var s = {};
781
- for (var a in t)
782
- s[a] = t[a];
783
- return s[r] = e, s;
784
- }
785
- var Jr = /* @__PURE__ */ O(function(e) {
786
- return e == null;
787
- }), Qr = /* @__PURE__ */ Ot(function r(e, t, n) {
788
- if (e.length === 0)
789
- return t;
790
- var s = e[0];
791
- if (e.length > 1) {
792
- var a = !Jr(n) && xe(s, n) && typeof n[s] == "object" ? n[s] : lt(e[1]) ? [] : {};
793
- t = r(Array.prototype.slice.call(e, 1), t, a);
794
- }
795
- return Xr(s, t, n);
796
- });
797
- function en(r) {
798
- var e = Object.prototype.toString.call(r);
799
- return e === "[object Function]" || e === "[object AsyncFunction]" || e === "[object GeneratorFunction]" || e === "[object AsyncGeneratorFunction]";
800
- }
801
- function tn(r, e) {
802
- return function() {
803
- return e.call(this, r.apply(this, arguments));
804
- };
805
- }
806
- function Jt(r, e) {
807
- return function() {
808
- var t = arguments.length;
809
- if (t === 0)
810
- return e();
811
- var n = arguments[t - 1];
812
- return We(n) || typeof n[r] != "function" ? e.apply(this, arguments) : n[r].apply(n, Array.prototype.slice.call(arguments, 0, t - 1));
813
- };
814
- }
815
- var rn = /* @__PURE__ */ Ot(
816
- /* @__PURE__ */ Jt("slice", function(e, t, n) {
817
- return Array.prototype.slice.call(n, e, t);
818
- })
819
- ), nn = /* @__PURE__ */ O(
820
- /* @__PURE__ */ Jt(
821
- "tail",
822
- /* @__PURE__ */ rn(1, 1 / 0)
823
- )
824
- );
825
- function sn() {
826
- if (arguments.length === 0)
827
- throw new Error("pipe requires at least one argument");
828
- return ut(arguments[0].length, Yr(tn, arguments[0], nn(arguments)));
829
- }
830
- var an = /* @__PURE__ */ O(function(e) {
831
- return dt(e) ? e.split("").reverse().join("") : Array.prototype.slice.call(e, 0).reverse();
832
- });
833
- function on() {
834
- if (arguments.length === 0)
835
- throw new Error("compose requires at least one argument");
836
- return sn.apply(this, an(arguments));
837
- }
838
- var cn = /* @__PURE__ */ O(function(e) {
839
- return Ct(e.length, e);
840
- });
841
- function un(r) {
842
- var e = Object.prototype.toString.call(r);
843
- return e === "[object Uint8ClampedArray]" || e === "[object Int8Array]" || e === "[object Uint8Array]" || e === "[object Int16Array]" || e === "[object Uint16Array]" || e === "[object Int32Array]" || e === "[object Uint32Array]" || e === "[object Float32Array]" || e === "[object Float64Array]" || e === "[object BigInt64Array]" || e === "[object BigUint64Array]";
844
- }
845
- var ln = /* @__PURE__ */ O(function(e) {
846
- return e != null && typeof e["fantasy-land/empty"] == "function" ? e["fantasy-land/empty"]() : e != null && e.constructor != null && typeof e.constructor["fantasy-land/empty"] == "function" ? e.constructor["fantasy-land/empty"]() : e != null && typeof e.empty == "function" ? e.empty() : e != null && e.constructor != null && typeof e.constructor.empty == "function" ? e.constructor.empty() : We(e) ? [] : dt(e) ? "" : Kt(e) ? {} : Gt(e) ? /* @__PURE__ */ function() {
847
- return arguments;
848
- }() : un(e) ? e.constructor.from("") : void 0;
849
- }), dn = /* @__PURE__ */ function() {
850
- function r(e, t) {
851
- this.xf = t, this.f = e, this.found = !1;
852
- }
853
- return r.prototype["@@transducer/init"] = be.init, r.prototype["@@transducer/result"] = function(e) {
854
- return this.found || (e = this.xf["@@transducer/step"](e, void 0)), this.xf["@@transducer/result"](e);
855
- }, r.prototype["@@transducer/step"] = function(e, t) {
856
- return this.f(t) && (this.found = !0, e = Sr(this.xf["@@transducer/step"](e, t))), e;
857
- }, r;
858
- }();
859
- function fn(r) {
860
- return function(e) {
861
- return new dn(r, e);
862
- };
863
- }
864
- var hn = /* @__PURE__ */ C(
865
- /* @__PURE__ */ Et(["find"], fn, function(e, t) {
866
- for (var n = 0, s = t.length; n < s; ) {
867
- if (e(t[n]))
868
- return t[n];
869
- n += 1;
870
- }
871
- })
872
- ), pn = /* @__PURE__ */ C(Ft), mn = /* @__PURE__ */ C(function(e, t) {
873
- return Ct(e + 1, function() {
874
- var n = arguments[e];
875
- if (n != null && en(n[t]))
876
- return n[t].apply(n, Array.prototype.slice.call(arguments, 0, e));
877
- throw new TypeError(Mr(n) + ' does not have a method named "' + t + '"');
878
- });
879
- }), Qt = /* @__PURE__ */ O(function(e) {
880
- return e != null && Wt(e, ln(e));
881
- }), gn = /* @__PURE__ */ mn(1, "join"), yn = /* @__PURE__ */ C(function(e, t) {
882
- return function(n) {
883
- return function(s) {
884
- return Lr(function(a) {
885
- return t(a, s);
886
- }, n(e(s)));
887
- };
888
- };
889
- }), vn = /* @__PURE__ */ C(function(e, t) {
890
- return e.map(function(n) {
891
- for (var s = t, a = 0, i; a < n.length; ) {
892
- if (s == null)
893
- return;
894
- i = n[a], s = lt(i) ? Xt(i, s) : s[i], a += 1;
895
- }
896
- return s;
897
- });
898
- }), _n = /* @__PURE__ */ C(function(e, t) {
899
- return vn([e], t)[0];
900
- }), wn = /* @__PURE__ */ O(function(e) {
901
- return yn(_n(e), Qr(e));
902
- }), kn = function(r) {
903
- return {
904
- value: r,
905
- "fantasy-land/map": function() {
906
- return this;
907
- }
908
- };
909
- }, bn = /* @__PURE__ */ C(function(e, t) {
910
- return e(kn)(t).value;
911
- });
912
- const xn = cn((r, e, t, n) => {
913
- const s = (a) => pn(t, a[e]);
914
- return on(zr(n), hn(s))(r);
915
- }), Sn = wn(["results", "0", "address_components"]), Tn = (r, e = {}) => {
916
- const { requestCity: t, requestState: n, requestZipcode: s } = e, a = (o) => ({ description: o.description, placeId: o.place_id });
917
- let i = null;
918
- return t || n || s || (i = r.map(a)), i = r.map((o) => {
919
- const c = {
920
- description: o.description,
921
- place_id: o.place_id
922
- }, u = o.terms.filter((x) => t && x.value === t).length > 0 ? 1 : 0, d = o.terms.filter((x) => n && x.value === n).length > 0 ? 1 : 0, y = o.terms.filter((x) => s && x.value === s).length > 0 ? 1 : 0;
923
- return c.score = u + d + y, c.stateMatch = !n || n && d, c.zipCodeMatch = !s || s && y, c;
924
- }).filter(
925
- (o) => !!o.stateMatch && !!o.zipCodeMatch
926
- ).sort((o, c) => o.score === c.score ? 0 : o.score < c.score ? 1 : -1).map(a), i;
927
- }, Ke = (r) => {
928
- const e = r.results ? r.results[0] : r.result;
929
- if (!e || Qt(e))
930
- return {};
931
- let t = null;
932
- r.results ? t = bn(Sn)(r) : t = e.address_components;
933
- const n = xn(t, "types"), s = e.formatted_address, a = e.geometry && e.geometry.location && e.geometry.location.lat ? e.geometry.location.lat : null, i = e.geometry && e.geometry.location && e.geometry.location.lng ? e.geometry.location.lng : null, o = n("street_number", "short_name") || "", c = n("route", "long_name") || "", u = (o || c) && `${o} ${c}`, d = {
934
- state: n("administrative_area_level_1", "short_name"),
935
- city: n("locality", "short_name") || n("sublocality", "short_name") || n("neighborhood", "long_name") || n("administrative_area_level_3", "long_name") || n("administrative_area_level_2", "short_name"),
936
- street_1: u.trim(),
937
- country: n("country", "short_name"),
938
- zipcode: n("postal_code", "long_name"),
939
- latitude: a && Number(a),
940
- longitude: i && Number(i),
941
- formattedAddress: s
942
- };
943
- return ne(Boolean)(d);
944
- };
945
- class Cn {
946
- constructor(e) {
947
- this.mapsKey = e;
948
- }
949
- async geocode(e) {
950
- const n = await (await fetch(
951
- `https://maps.googleapis.com/maps/api/geocode/json?address=${e}&key=${this.mapsKey}`
952
- )).json();
953
- return Ke(n);
954
- }
955
- async geocodeZip(e) {
956
- const n = await (await fetch(
957
- `https://maps.googleapis.com/maps/api/geocode/json?components=country:US|postal_code:${e}&key=${this.mapsKey}`
958
- )).json();
959
- return Ke(n);
960
- }
961
- async reverseGeocode(e, t) {
962
- const s = await (await fetch(
963
- `https://maps.googleapis.com/maps/api/geocode/json?latlng=${e},${t}&key=${this.mapsKey}`
964
- )).json();
965
- return Ke(s);
966
- }
967
- async geoLocate() {
968
- const e = `https://www.googleapis.com/geolocation/v1/geolocate?key=${this.mapsKey}`, s = await (await fetch(e, {
969
- method: "POST",
970
- headers: {
971
- Accept: "application/json",
972
- "Content-Type": "application/json"
973
- }
974
- })).json(), { lat: a, lng: i } = s.location;
975
- return this.reverseGeocode(a, i);
976
- }
977
- async getLocationSuggestions(e) {
978
- const { input: t, latitude: n, longitude: s, radius: a } = e, { requestCity: i, requestState: o, requestZipcode: c } = e, u = gn(",", ne(Boolean, [n, s]));
979
- let { sessiontoken: d } = e;
980
- d || (d = crypto.randomUUID().replaceAll("-", ""));
981
- const y = ne(Boolean, {
982
- input: t,
983
- sessiontoken: d,
984
- location: u,
985
- // The point around which to retrieve place information.
986
- radius: a,
987
- // The radius parameter must also be provided when specifying a location
988
- components: "country:US",
989
- types: "address",
990
- key: this.mapsKey
991
- });
992
- let x = "";
993
- y && (x = new URLSearchParams(y).toString());
994
- const k = `https://maps.googleapis.com/maps/api/place/autocomplete/json?${x}`, ee = await (await fetch(k, {
995
- method: "GET",
996
- headers: {
997
- Accept: "application/json"
998
- }
999
- })).json();
1000
- let R = [];
1001
- if (ee.predictions && ee.status === "OK") {
1002
- const He = { requestCity: i, requestState: o, requestZipcode: c };
1003
- R = Tn(ee.predictions, He);
1004
- }
1005
- return { autocompletePredictions: R, sessiontoken: d };
1006
- }
1007
- async getPlaceId(e) {
1008
- const { placeId: t, sessiontoken: n } = e, s = ne(Boolean, {
1009
- place_id: t,
1010
- sessiontoken: n,
1011
- key: this.mapsKey
1012
- });
1013
- let a = "";
1014
- s && (a = new URLSearchParams(s).toString());
1015
- const i = `https://maps.googleapis.com/maps/api/place/details/json?${a}`, c = await (await fetch(i)).json();
1016
- return Ke(c);
1017
- }
1018
- async getNavigatorPosition() {
1019
- const e = (t) => {
1020
- console.error(t);
1021
- };
1022
- navigator.geolocation && navigator.geolocation.getCurrentPosition(
1023
- (t) => {
1024
- const n = t.coords.latitude, s = t.coords.longitude;
1025
- return this.reverseGeocode(n, s);
1026
- },
1027
- e
1028
- ) || e({ message: "geolocation is not enabled." });
1029
- }
1030
- }
1031
- const On = {
1032
- geoLocate: async (r) => {
1033
- try {
1034
- return { location: await r.geoService.geoLocate() };
1035
- } catch {
1036
- return { location: {}, errorMessage: "unable to geolocate" };
1037
- }
1038
- },
1039
- geocodeZipcode: async (r, e) => {
1040
- const { zipCode: t } = e;
1041
- try {
1042
- return { location: await r.geoService.geocodeZip(t) };
1043
- } catch {
1044
- return { location: {}, errorMessage: "unable to geocode zipcode" };
1045
- }
1046
- },
1047
- geocodePlaceId: async (r, e) => {
1048
- const { placeId: t, sessiontoken: n } = e;
1049
- try {
1050
- return { location: await r.geoService.getPlaceId({ placeId: t, sessiontoken: n }) };
1051
- } catch {
1052
- return { location: {}, errorMessage: "unable to geocode zipcode" };
1053
- }
1054
- },
1055
- fetchAddressSuggestions: async (r, e) => {
1056
- const { addressEntry: t } = e, { sessiontoken: n } = r.getItem("addressSuggestions");
1057
- if (!t || t.length < 5)
1058
- return { warningMessage: "Enter at least 5 characters of the address", addressSuggestions: { autocompletePredictions: [], sessiontoken: n } };
1059
- try {
1060
- const s = await r.geoService.getLocationSuggestions({ sessiontoken: n, input: t });
1061
- return { addressSuggestions: {
1062
- autocompletePredictions: s.autocompletePredictions,
1063
- sessiontoken: s.sessiontoken
1064
- } };
1065
- } catch (s) {
1066
- return console.error(s), { addressSuggestions: { autocompletePredictions: [], sessiontoken: null }, errorMessage: "Unable to provide autocomplete suggestions" };
1067
- }
1068
- },
1069
- setLocation: async (r, e = null) => {
1070
- const t = "/c/v2/customer_location", {
1071
- latitude: n,
1072
- longitude: s,
1073
- zipcode: a,
1074
- state: i,
1075
- city: o,
1076
- country: c,
1077
- street_1: u,
1078
- street_2: d,
1079
- street_3: y
1080
- } = e || r.getItem("locationComponents"), x = ne(Boolean, {
1081
- latitude: n,
1082
- longitude: s,
1083
- zipcode: a,
1084
- street_1: u,
1085
- street_2: d,
1086
- street_3: y,
1087
- state: i,
1088
- city: o,
1089
- country: c
1090
- }), k = await r.thirstieService("POST", t, { data: x });
1091
- let I = {};
1092
- if (k && k.ok) {
1093
- const Q = k.data || {}, { deliverable: ee, location_hash: R, payment_provider: He } = Q;
1094
- I = { location: x, isInCoverage: ee, locationHash: R, paymentProvider: He };
1095
- } else
1096
- I = { location: {}, isInCoverage: !1, locationHash: null, paymentProvider: null };
1097
- return I;
1098
- }
1099
- }, En = (r) => {
1100
- const e = r.offering || {}, t = r.product_line || {}, n = r.container_size || {};
1101
- return {
1102
- product_line_id: t.id,
1103
- name: t.name,
1104
- product_type: t.product_type.label,
1105
- image_spec: t.image_spec,
1106
- image_url: t.image_spec && t.image_spec.replace("{dims}", ""),
1107
- container_sizes: r.container_sizes,
1108
- abv_percent: t.abv_percent,
1109
- add_to_cart_size: n.label,
1110
- add_to_cart_offering: e.id,
1111
- add_to_cart_tmk: e.tmk,
1112
- add_to_cart_availability: e.availability,
1113
- offer_count: r.offer_count,
1114
- min_price: r.min_price,
1115
- max_price: r.max_price
1116
- };
1117
- }, An = (r) => r.items.map((t) => En(t)), zt = (r) => {
1118
- const e = r.offerings || {}, t = r.product_line || {}, n = {
1119
- product_line_id: t.id,
1120
- name: t.name,
1121
- product_type: t.product_type.label,
1122
- image_spec: t.image_spec,
1123
- image_url: t.image_spec && t.image_spec.replace("{dims}", ""),
1124
- abv_percent: t.abv_percent
1125
- };
1126
- return e.map((a) => {
1127
- const i = a.product.tpk, o = a.merchant.tmk, c = a.merchant.name, u = a.merchant.address && a.merchant.address.zipcode, d = a.merchant.address && a.merchant.address.state, y = a.merchant.capabilities.physical && a.merchant.capabilities.physical.delivery_minimum || 0, x = a.merchant.capabilities.shipping && a.merchant.capabilities.shipping.delivery_minimum || 0, k = a.availability_verbose, I = a.product.container_size.label, Q = {
1128
- onDemand: !!k.on_demand && a.availability === "In Stock",
1129
- scheduled: !!k.scheduled && a.availability === "In Stock",
1130
- preorder: !!k.preorder && (a.availability === "Preorder" || a.availability === "Deposit"),
1131
- shipping: !!k.shipping,
1132
- shippingMinimum: !!k.shipping && k.shipping.delivery_minimum
1133
- };
1134
- return {
1135
- offeringId: a.id,
1136
- quantityAvailable: a.quantity,
1137
- availability: a.availability,
1138
- price: a.price,
1139
- tpk: i,
1140
- tmk: o,
1141
- retailerName: c,
1142
- retailerZipCode: u,
1143
- retailerStateCode: d,
1144
- deliveryMinimum: y,
1145
- shippingMinimum: x,
1146
- deliveryMethods: Q,
1147
- containerSizeLabel: I,
1148
- productLineData: n
1149
- };
1150
- });
1151
- }, In = {
1152
- fetchProductLineOfferings: async (r, e) => {
1153
- const t = e.productLineId, n = await r.thirstieService("GET", `/c/v2/catalog/${t}/offerings`), s = n && n.ok ? n.data : null;
1154
- return { productLineOfferings: zt(s) };
1155
- },
1156
- fetchCatalog: async (r, e = null) => {
1157
- const { productLineIds: t, fetchOfferingDetail: n } = e || {}, s = await r.thirstieService("GET", "/c/v2/catalog"), a = s && s.ok ? s.data : null;
1158
- let i = An(a);
1159
- if (t && (i = i.filter((o) => t.indexOf(o.product_line_id) > -1)), n) {
1160
- const o = async (c) => {
1161
- const u = c.product_line_id;
1162
- try {
1163
- const d = await r.thirstieService("GET", `/c/v2/catalog/${u}/offerings`), y = d && d.ok ? zt(d.data) : [];
1164
- return c.offerings = y, c;
1165
- } catch (d) {
1166
- return console.error(d), c.offerings = [], c;
1167
- }
1168
- };
1169
- i = await Promise.all(i.map(o));
1170
- }
1171
- return { catalogProductLines: i };
1172
- }
1173
- }, gt = (r) => {
1174
- const e = r.user, t = {
1175
- application: r.application_name,
1176
- applicationRef: r.uuid,
1177
- sessionToken: r.token,
1178
- sessionRef: r.session_uuid
1179
- };
1180
- if (e && t.sessionToken && t.applicationRef)
1181
- t.userRef = e.id, t.userEmail = e.email, t.userFName = e.first_name, t.userLName = e.last_name, t.userLastLogin = e.last_login;
1182
- else
1183
- return {};
1184
- return t;
1185
- }, Ye = (r) => {
1186
- const e = r.user;
1187
- return e ? {
1188
- uuid: e.id,
1189
- email: e.email,
1190
- firstName: e.first_name,
1191
- lastName: e.last_name,
1192
- prefix: e.prefix,
1193
- isGuest: e.guest,
1194
- phoneNumber: e.phone_number,
1195
- lastLogin: e.last_login,
1196
- dateCreated: e.date_created,
1197
- dob: e.birthday
1198
- } : {};
1199
- };
1200
- var b;
1201
- (function(r) {
1202
- r.assertEqual = (s) => s;
1203
- function e(s) {
1204
- }
1205
- r.assertIs = e;
1206
- function t(s) {
1207
- throw new Error();
1208
- }
1209
- r.assertNever = t, r.arrayToEnum = (s) => {
1210
- const a = {};
1211
- for (const i of s)
1212
- a[i] = i;
1213
- return a;
1214
- }, r.getValidEnumValues = (s) => {
1215
- const a = r.objectKeys(s).filter((o) => typeof s[s[o]] != "number"), i = {};
1216
- for (const o of a)
1217
- i[o] = s[o];
1218
- return r.objectValues(i);
1219
- }, r.objectValues = (s) => r.objectKeys(s).map(function(a) {
1220
- return s[a];
1221
- }), r.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
1222
- const a = [];
1223
- for (const i in s)
1224
- Object.prototype.hasOwnProperty.call(s, i) && a.push(i);
1225
- return a;
1226
- }, r.find = (s, a) => {
1227
- for (const i of s)
1228
- if (a(i))
1229
- return i;
1230
- }, r.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && isFinite(s) && Math.floor(s) === s;
1231
- function n(s, a = " | ") {
1232
- return s.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
1233
- }
1234
- r.joinValues = n, r.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
1235
- })(b || (b = {}));
1236
- var kt;
1237
- (function(r) {
1238
- r.mergeShapes = (e, t) => ({
1239
- ...e,
1240
- ...t
1241
- // second overwrites first
1242
- });
1243
- })(kt || (kt = {}));
1244
- const h = b.arrayToEnum([
1245
- "string",
1246
- "nan",
1247
- "number",
1248
- "integer",
1249
- "float",
1250
- "boolean",
1251
- "date",
1252
- "bigint",
1253
- "symbol",
1254
- "function",
1255
- "undefined",
1256
- "null",
1257
- "array",
1258
- "object",
1259
- "unknown",
1260
- "promise",
1261
- "void",
1262
- "never",
1263
- "map",
1264
- "set"
1265
- ]), H = (r) => {
1266
- switch (typeof r) {
1267
- case "undefined":
1268
- return h.undefined;
1269
- case "string":
1270
- return h.string;
1271
- case "number":
1272
- return isNaN(r) ? h.nan : h.number;
1273
- case "boolean":
1274
- return h.boolean;
1275
- case "function":
1276
- return h.function;
1277
- case "bigint":
1278
- return h.bigint;
1279
- case "symbol":
1280
- return h.symbol;
1281
- case "object":
1282
- return Array.isArray(r) ? h.array : r === null ? h.null : r.then && typeof r.then == "function" && r.catch && typeof r.catch == "function" ? h.promise : typeof Map < "u" && r instanceof Map ? h.map : typeof Set < "u" && r instanceof Set ? h.set : typeof Date < "u" && r instanceof Date ? h.date : h.object;
1283
- default:
1284
- return h.unknown;
1285
- }
1286
- }, l = b.arrayToEnum([
1287
- "invalid_type",
1288
- "invalid_literal",
1289
- "custom",
1290
- "invalid_union",
1291
- "invalid_union_discriminator",
1292
- "invalid_enum_value",
1293
- "unrecognized_keys",
1294
- "invalid_arguments",
1295
- "invalid_return_type",
1296
- "invalid_date",
1297
- "invalid_string",
1298
- "too_small",
1299
- "too_big",
1300
- "invalid_intersection_types",
1301
- "not_multiple_of",
1302
- "not_finite"
1303
- ]), Nn = (r) => JSON.stringify(r, null, 2).replace(/"([^"]+)":/g, "$1:");
1304
- class Z extends Error {
1305
- constructor(e) {
1306
- super(), this.issues = [], this.addIssue = (n) => {
1307
- this.issues = [...this.issues, n];
1308
- }, this.addIssues = (n = []) => {
1309
- this.issues = [...this.issues, ...n];
1310
- };
1311
- const t = new.target.prototype;
1312
- Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
1313
- }
1314
- get errors() {
1315
- return this.issues;
1316
- }
1317
- format(e) {
1318
- const t = e || function(a) {
1319
- return a.message;
1320
- }, n = { _errors: [] }, s = (a) => {
1321
- for (const i of a.issues)
1322
- if (i.code === "invalid_union")
1323
- i.unionErrors.map(s);
1324
- else if (i.code === "invalid_return_type")
1325
- s(i.returnTypeError);
1326
- else if (i.code === "invalid_arguments")
1327
- s(i.argumentsError);
1328
- else if (i.path.length === 0)
1329
- n._errors.push(t(i));
1330
- else {
1331
- let o = n, c = 0;
1332
- for (; c < i.path.length; ) {
1333
- const u = i.path[c];
1334
- c === i.path.length - 1 ? (o[u] = o[u] || { _errors: [] }, o[u]._errors.push(t(i))) : o[u] = o[u] || { _errors: [] }, o = o[u], c++;
1335
- }
1336
- }
1337
- };
1338
- return s(this), n;
1339
- }
1340
- static assert(e) {
1341
- if (!(e instanceof Z))
1342
- throw new Error(`Not a ZodError: ${e}`);
1343
- }
1344
- toString() {
1345
- return this.message;
1346
- }
1347
- get message() {
1348
- return JSON.stringify(this.issues, b.jsonStringifyReplacer, 2);
1349
- }
1350
- get isEmpty() {
1351
- return this.issues.length === 0;
1352
- }
1353
- flatten(e = (t) => t.message) {
1354
- const t = {}, n = [];
1355
- for (const s of this.issues)
1356
- s.path.length > 0 ? (t[s.path[0]] = t[s.path[0]] || [], t[s.path[0]].push(e(s))) : n.push(e(s));
1357
- return { formErrors: n, fieldErrors: t };
1358
- }
1359
- get formErrors() {
1360
- return this.flatten();
1361
- }
1362
- }
1363
- Z.create = (r) => new Z(r);
1364
- const ge = (r, e) => {
1365
- let t;
1366
- switch (r.code) {
1367
- case l.invalid_type:
1368
- r.received === h.undefined ? t = "Required" : t = `Expected ${r.expected}, received ${r.received}`;
1369
- break;
1370
- case l.invalid_literal:
1371
- t = `Invalid literal value, expected ${JSON.stringify(r.expected, b.jsonStringifyReplacer)}`;
1372
- break;
1373
- case l.unrecognized_keys:
1374
- t = `Unrecognized key(s) in object: ${b.joinValues(r.keys, ", ")}`;
1375
- break;
1376
- case l.invalid_union:
1377
- t = "Invalid input";
1378
- break;
1379
- case l.invalid_union_discriminator:
1380
- t = `Invalid discriminator value. Expected ${b.joinValues(r.options)}`;
1381
- break;
1382
- case l.invalid_enum_value:
1383
- t = `Invalid enum value. Expected ${b.joinValues(r.options)}, received '${r.received}'`;
1384
- break;
1385
- case l.invalid_arguments:
1386
- t = "Invalid function arguments";
1387
- break;
1388
- case l.invalid_return_type:
1389
- t = "Invalid function return type";
1390
- break;
1391
- case l.invalid_date:
1392
- t = "Invalid date";
1393
- break;
1394
- case l.invalid_string:
1395
- typeof r.validation == "object" ? "includes" in r.validation ? (t = `Invalid input: must include "${r.validation.includes}"`, typeof r.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${r.validation.position}`)) : "startsWith" in r.validation ? t = `Invalid input: must start with "${r.validation.startsWith}"` : "endsWith" in r.validation ? t = `Invalid input: must end with "${r.validation.endsWith}"` : b.assertNever(r.validation) : r.validation !== "regex" ? t = `Invalid ${r.validation}` : t = "Invalid";
1396
- break;
1397
- case l.too_small:
1398
- r.type === "array" ? t = `Array must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "more than"} ${r.minimum} element(s)` : r.type === "string" ? t = `String must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "over"} ${r.minimum} character(s)` : r.type === "number" ? t = `Number must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${r.minimum}` : r.type === "date" ? t = `Date must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(r.minimum))}` : t = "Invalid input";
1399
- break;
1400
- case l.too_big:
1401
- r.type === "array" ? t = `Array must contain ${r.exact ? "exactly" : r.inclusive ? "at most" : "less than"} ${r.maximum} element(s)` : r.type === "string" ? t = `String must contain ${r.exact ? "exactly" : r.inclusive ? "at most" : "under"} ${r.maximum} character(s)` : r.type === "number" ? t = `Number must be ${r.exact ? "exactly" : r.inclusive ? "less than or equal to" : "less than"} ${r.maximum}` : r.type === "bigint" ? t = `BigInt must be ${r.exact ? "exactly" : r.inclusive ? "less than or equal to" : "less than"} ${r.maximum}` : r.type === "date" ? t = `Date must be ${r.exact ? "exactly" : r.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(r.maximum))}` : t = "Invalid input";
1402
- break;
1403
- case l.custom:
1404
- t = "Invalid input";
1405
- break;
1406
- case l.invalid_intersection_types:
1407
- t = "Intersection results could not be merged";
1408
- break;
1409
- case l.not_multiple_of:
1410
- t = `Number must be a multiple of ${r.multipleOf}`;
1411
- break;
1412
- case l.not_finite:
1413
- t = "Number must be finite";
1414
- break;
1415
- default:
1416
- t = e.defaultError, b.assertNever(r);
1417
- }
1418
- return { message: t };
1419
- };
1420
- let er = ge;
1421
- function jn(r) {
1422
- er = r;
1423
- }
1424
- function rt() {
1425
- return er;
1426
- }
1427
- const nt = (r) => {
1428
- const { data: e, path: t, errorMaps: n, issueData: s } = r, a = [...t, ...s.path || []], i = {
1429
- ...s,
1430
- path: a
1431
- };
1432
- if (s.message !== void 0)
1433
- return {
1434
- ...s,
1435
- path: a,
1436
- message: s.message
1437
- };
1438
- let o = "";
1439
- const c = n.filter((u) => !!u).slice().reverse();
1440
- for (const u of c)
1441
- o = u(i, { data: e, defaultError: o }).message;
1442
- return {
1443
- ...s,
1444
- path: a,
1445
- message: o
1446
- };
1447
- }, Rn = [];
1448
- function f(r, e) {
1449
- const t = rt(), n = nt({
1450
- issueData: e,
1451
- data: r.data,
1452
- path: r.path,
1453
- errorMaps: [
1454
- r.common.contextualErrorMap,
1455
- r.schemaErrorMap,
1456
- t,
1457
- t === ge ? void 0 : ge
1458
- // then global default map
1459
- ].filter((s) => !!s)
1460
- });
1461
- r.common.issues.push(n);
1462
- }
1463
- class j {
1464
- constructor() {
1465
- this.value = "valid";
1466
- }
1467
- dirty() {
1468
- this.value === "valid" && (this.value = "dirty");
1469
- }
1470
- abort() {
1471
- this.value !== "aborted" && (this.value = "aborted");
1472
- }
1473
- static mergeArray(e, t) {
1474
- const n = [];
1475
- for (const s of t) {
1476
- if (s.status === "aborted")
1477
- return g;
1478
- s.status === "dirty" && e.dirty(), n.push(s.value);
1479
- }
1480
- return { status: e.value, value: n };
1481
- }
1482
- static async mergeObjectAsync(e, t) {
1483
- const n = [];
1484
- for (const s of t) {
1485
- const a = await s.key, i = await s.value;
1486
- n.push({
1487
- key: a,
1488
- value: i
1489
- });
1490
- }
1491
- return j.mergeObjectSync(e, n);
1492
- }
1493
- static mergeObjectSync(e, t) {
1494
- const n = {};
1495
- for (const s of t) {
1496
- const { key: a, value: i } = s;
1497
- if (a.status === "aborted" || i.status === "aborted")
1498
- return g;
1499
- a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || s.alwaysSet) && (n[a.value] = i.value);
1500
- }
1501
- return { status: e.value, value: n };
1502
- }
1503
- }
1504
- const g = Object.freeze({
1505
- status: "aborted"
1506
- }), ce = (r) => ({ status: "dirty", value: r }), P = (r) => ({ status: "valid", value: r }), bt = (r) => r.status === "aborted", xt = (r) => r.status === "dirty", Se = (r) => r.status === "valid", Te = (r) => typeof Promise < "u" && r instanceof Promise;
1507
- function st(r, e, t, n) {
1508
- if (typeof e == "function" ? r !== e || !n : !e.has(r))
1509
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
1510
- return e.get(r);
1511
- }
1512
- function tr(r, e, t, n, s) {
1513
- if (typeof e == "function" ? r !== e || !s : !e.has(r))
1514
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
1515
- return e.set(r, t), t;
1516
- }
1517
- var p;
1518
- (function(r) {
1519
- r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
1520
- })(p || (p = {}));
1521
- var we, ke;
1522
- class q {
1523
- constructor(e, t, n, s) {
1524
- this._cachedPath = [], this.parent = e, this.data = t, this._path = n, this._key = s;
1525
- }
1526
- get path() {
1527
- return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
1528
- }
1529
- }
1530
- const Ut = (r, e) => {
1531
- if (Se(e))
1532
- return { success: !0, data: e.value };
1533
- if (!r.common.issues.length)
1534
- throw new Error("Validation failed but no issues detected.");
1535
- return {
1536
- success: !1,
1537
- get error() {
1538
- if (this._error)
1539
- return this._error;
1540
- const t = new Z(r.common.issues);
1541
- return this._error = t, this._error;
1542
- }
1543
- };
1544
- };
1545
- function _(r) {
1546
- if (!r)
1547
- return {};
1548
- const { errorMap: e, invalid_type_error: t, required_error: n, description: s } = r;
1549
- if (e && (t || n))
1550
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
1551
- return e ? { errorMap: e, description: s } : { errorMap: (i, o) => {
1552
- var c, u;
1553
- const { message: d } = r;
1554
- return i.code === "invalid_enum_value" ? { message: d ?? o.defaultError } : typeof o.data > "u" ? { message: (c = d ?? n) !== null && c !== void 0 ? c : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (u = d ?? t) !== null && u !== void 0 ? u : o.defaultError };
1555
- }, description: s };
1556
- }
1557
- class w {
1558
- constructor(e) {
1559
- this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this);
1560
- }
1561
- get description() {
1562
- return this._def.description;
1563
- }
1564
- _getType(e) {
1565
- return H(e.data);
1566
- }
1567
- _getOrReturnCtx(e, t) {
1568
- return t || {
1569
- common: e.parent.common,
1570
- data: e.data,
1571
- parsedType: H(e.data),
1572
- schemaErrorMap: this._def.errorMap,
1573
- path: e.path,
1574
- parent: e.parent
1575
- };
1576
- }
1577
- _processInputParams(e) {
1578
- return {
1579
- status: new j(),
1580
- ctx: {
1581
- common: e.parent.common,
1582
- data: e.data,
1583
- parsedType: H(e.data),
1584
- schemaErrorMap: this._def.errorMap,
1585
- path: e.path,
1586
- parent: e.parent
1587
- }
1588
- };
1589
- }
1590
- _parseSync(e) {
1591
- const t = this._parse(e);
1592
- if (Te(t))
1593
- throw new Error("Synchronous parse encountered promise.");
1594
- return t;
1595
- }
1596
- _parseAsync(e) {
1597
- const t = this._parse(e);
1598
- return Promise.resolve(t);
1599
- }
1600
- parse(e, t) {
1601
- const n = this.safeParse(e, t);
1602
- if (n.success)
1603
- return n.data;
1604
- throw n.error;
1605
- }
1606
- safeParse(e, t) {
1607
- var n;
1608
- const s = {
1609
- common: {
1610
- issues: [],
1611
- async: (n = t == null ? void 0 : t.async) !== null && n !== void 0 ? n : !1,
1612
- contextualErrorMap: t == null ? void 0 : t.errorMap
1613
- },
1614
- path: (t == null ? void 0 : t.path) || [],
1615
- schemaErrorMap: this._def.errorMap,
1616
- parent: null,
1617
- data: e,
1618
- parsedType: H(e)
1619
- }, a = this._parseSync({ data: e, path: s.path, parent: s });
1620
- return Ut(s, a);
1621
- }
1622
- async parseAsync(e, t) {
1623
- const n = await this.safeParseAsync(e, t);
1624
- if (n.success)
1625
- return n.data;
1626
- throw n.error;
1627
- }
1628
- async safeParseAsync(e, t) {
1629
- const n = {
1630
- common: {
1631
- issues: [],
1632
- contextualErrorMap: t == null ? void 0 : t.errorMap,
1633
- async: !0
1634
- },
1635
- path: (t == null ? void 0 : t.path) || [],
1636
- schemaErrorMap: this._def.errorMap,
1637
- parent: null,
1638
- data: e,
1639
- parsedType: H(e)
1640
- }, s = this._parse({ data: e, path: n.path, parent: n }), a = await (Te(s) ? s : Promise.resolve(s));
1641
- return Ut(n, a);
1642
- }
1643
- refine(e, t) {
1644
- const n = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
1645
- return this._refinement((s, a) => {
1646
- const i = e(s), o = () => a.addIssue({
1647
- code: l.custom,
1648
- ...n(s)
1649
- });
1650
- return typeof Promise < "u" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
1651
- });
1652
- }
1653
- refinement(e, t) {
1654
- return this._refinement((n, s) => e(n) ? !0 : (s.addIssue(typeof t == "function" ? t(n, s) : t), !1));
1655
- }
1656
- _refinement(e) {
1657
- return new z({
1658
- schema: this,
1659
- typeName: m.ZodEffects,
1660
- effect: { type: "refinement", refinement: e }
1661
- });
1662
- }
1663
- superRefine(e) {
1664
- return this._refinement(e);
1665
- }
1666
- optional() {
1667
- return V.create(this, this._def);
1668
- }
1669
- nullable() {
1670
- return J.create(this, this._def);
1671
- }
1672
- nullish() {
1673
- return this.nullable().optional();
1674
- }
1675
- array() {
1676
- return L.create(this, this._def);
1677
- }
1678
- promise() {
1679
- return ve.create(this, this._def);
1680
- }
1681
- or(e) {
1682
- return Ae.create([this, e], this._def);
1683
- }
1684
- and(e) {
1685
- return Ie.create(this, e, this._def);
1686
- }
1687
- transform(e) {
1688
- return new z({
1689
- ..._(this._def),
1690
- schema: this,
1691
- typeName: m.ZodEffects,
1692
- effect: { type: "transform", transform: e }
1693
- });
1694
- }
1695
- default(e) {
1696
- const t = typeof e == "function" ? e : () => e;
1697
- return new Ze({
1698
- ..._(this._def),
1699
- innerType: this,
1700
- defaultValue: t,
1701
- typeName: m.ZodDefault
1702
- });
1703
- }
1704
- brand() {
1705
- return new It({
1706
- typeName: m.ZodBranded,
1707
- type: this,
1708
- ..._(this._def)
1709
- });
1710
- }
1711
- catch(e) {
1712
- const t = typeof e == "function" ? e : () => e;
1713
- return new Me({
1714
- ..._(this._def),
1715
- innerType: this,
1716
- catchValue: t,
1717
- typeName: m.ZodCatch
1718
- });
1719
- }
1720
- describe(e) {
1721
- const t = this.constructor;
1722
- return new t({
1723
- ...this._def,
1724
- description: e
1725
- });
1726
- }
1727
- pipe(e) {
1728
- return Fe.create(this, e);
1729
- }
1730
- readonly() {
1731
- return $e.create(this);
1732
- }
1733
- isOptional() {
1734
- return this.safeParse(void 0).success;
1735
- }
1736
- isNullable() {
1737
- return this.safeParse(null).success;
1738
- }
1739
- }
1740
- const Pn = /^c[^\s-]{8,}$/i, Zn = /^[0-9a-z]+$/, Mn = /^[0-9A-HJKMNP-TV-Z]{26}$/, $n = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, Dn = /^[a-z0-9_-]{21}$/i, Ln = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, zn = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Un = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
1741
- let yt;
1742
- const Vn = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, qn = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/, Bn = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, rr = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", Gn = new RegExp(`^${rr}$`);
1743
- function nr(r) {
1744
- let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
1745
- return r.precision ? e = `${e}\\.\\d{${r.precision}}` : r.precision == null && (e = `${e}(\\.\\d+)?`), e;
1746
- }
1747
- function Wn(r) {
1748
- return new RegExp(`^${nr(r)}$`);
1749
- }
1750
- function sr(r) {
1751
- let e = `${rr}T${nr(r)}`;
1752
- const t = [];
1753
- return t.push(r.local ? "Z?" : "Z"), r.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
1754
- }
1755
- function Fn(r, e) {
1756
- return !!((e === "v4" || !e) && Vn.test(r) || (e === "v6" || !e) && qn.test(r));
1757
- }
1758
- class D extends w {
1759
- _parse(e) {
1760
- if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
1761
- const a = this._getOrReturnCtx(e);
1762
- return f(a, {
1763
- code: l.invalid_type,
1764
- expected: h.string,
1765
- received: a.parsedType
1766
- }), g;
1767
- }
1768
- const n = new j();
1769
- let s;
1770
- for (const a of this._def.checks)
1771
- if (a.kind === "min")
1772
- e.data.length < a.value && (s = this._getOrReturnCtx(e, s), f(s, {
1773
- code: l.too_small,
1774
- minimum: a.value,
1775
- type: "string",
1776
- inclusive: !0,
1777
- exact: !1,
1778
- message: a.message
1779
- }), n.dirty());
1780
- else if (a.kind === "max")
1781
- e.data.length > a.value && (s = this._getOrReturnCtx(e, s), f(s, {
1782
- code: l.too_big,
1783
- maximum: a.value,
1784
- type: "string",
1785
- inclusive: !0,
1786
- exact: !1,
1787
- message: a.message
1788
- }), n.dirty());
1789
- else if (a.kind === "length") {
1790
- const i = e.data.length > a.value, o = e.data.length < a.value;
1791
- (i || o) && (s = this._getOrReturnCtx(e, s), i ? f(s, {
1792
- code: l.too_big,
1793
- maximum: a.value,
1794
- type: "string",
1795
- inclusive: !0,
1796
- exact: !0,
1797
- message: a.message
1798
- }) : o && f(s, {
1799
- code: l.too_small,
1800
- minimum: a.value,
1801
- type: "string",
1802
- inclusive: !0,
1803
- exact: !0,
1804
- message: a.message
1805
- }), n.dirty());
1806
- } else if (a.kind === "email")
1807
- zn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1808
- validation: "email",
1809
- code: l.invalid_string,
1810
- message: a.message
1811
- }), n.dirty());
1812
- else if (a.kind === "emoji")
1813
- yt || (yt = new RegExp(Un, "u")), yt.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1814
- validation: "emoji",
1815
- code: l.invalid_string,
1816
- message: a.message
1817
- }), n.dirty());
1818
- else if (a.kind === "uuid")
1819
- $n.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1820
- validation: "uuid",
1821
- code: l.invalid_string,
1822
- message: a.message
1823
- }), n.dirty());
1824
- else if (a.kind === "nanoid")
1825
- Dn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1826
- validation: "nanoid",
1827
- code: l.invalid_string,
1828
- message: a.message
1829
- }), n.dirty());
1830
- else if (a.kind === "cuid")
1831
- Pn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1832
- validation: "cuid",
1833
- code: l.invalid_string,
1834
- message: a.message
1835
- }), n.dirty());
1836
- else if (a.kind === "cuid2")
1837
- Zn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1838
- validation: "cuid2",
1839
- code: l.invalid_string,
1840
- message: a.message
1841
- }), n.dirty());
1842
- else if (a.kind === "ulid")
1843
- Mn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1844
- validation: "ulid",
1845
- code: l.invalid_string,
1846
- message: a.message
1847
- }), n.dirty());
1848
- else if (a.kind === "url")
1849
- try {
1850
- new URL(e.data);
1851
- } catch {
1852
- s = this._getOrReturnCtx(e, s), f(s, {
1853
- validation: "url",
1854
- code: l.invalid_string,
1855
- message: a.message
1856
- }), n.dirty();
1857
- }
1858
- else
1859
- a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1860
- validation: "regex",
1861
- code: l.invalid_string,
1862
- message: a.message
1863
- }), n.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (s = this._getOrReturnCtx(e, s), f(s, {
1864
- code: l.invalid_string,
1865
- validation: { includes: a.value, position: a.position },
1866
- message: a.message
1867
- }), n.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (s = this._getOrReturnCtx(e, s), f(s, {
1868
- code: l.invalid_string,
1869
- validation: { startsWith: a.value },
1870
- message: a.message
1871
- }), n.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (s = this._getOrReturnCtx(e, s), f(s, {
1872
- code: l.invalid_string,
1873
- validation: { endsWith: a.value },
1874
- message: a.message
1875
- }), n.dirty()) : a.kind === "datetime" ? sr(a).test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1876
- code: l.invalid_string,
1877
- validation: "datetime",
1878
- message: a.message
1879
- }), n.dirty()) : a.kind === "date" ? Gn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1880
- code: l.invalid_string,
1881
- validation: "date",
1882
- message: a.message
1883
- }), n.dirty()) : a.kind === "time" ? Wn(a).test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1884
- code: l.invalid_string,
1885
- validation: "time",
1886
- message: a.message
1887
- }), n.dirty()) : a.kind === "duration" ? Ln.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1888
- validation: "duration",
1889
- code: l.invalid_string,
1890
- message: a.message
1891
- }), n.dirty()) : a.kind === "ip" ? Fn(e.data, a.version) || (s = this._getOrReturnCtx(e, s), f(s, {
1892
- validation: "ip",
1893
- code: l.invalid_string,
1894
- message: a.message
1895
- }), n.dirty()) : a.kind === "base64" ? Bn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
1896
- validation: "base64",
1897
- code: l.invalid_string,
1898
- message: a.message
1899
- }), n.dirty()) : b.assertNever(a);
1900
- return { status: n.value, value: e.data };
1901
- }
1902
- _regex(e, t, n) {
1903
- return this.refinement((s) => e.test(s), {
1904
- validation: t,
1905
- code: l.invalid_string,
1906
- ...p.errToObj(n)
1907
- });
1908
- }
1909
- _addCheck(e) {
1910
- return new D({
1911
- ...this._def,
1912
- checks: [...this._def.checks, e]
1913
- });
1914
- }
1915
- email(e) {
1916
- return this._addCheck({ kind: "email", ...p.errToObj(e) });
1917
- }
1918
- url(e) {
1919
- return this._addCheck({ kind: "url", ...p.errToObj(e) });
1920
- }
1921
- emoji(e) {
1922
- return this._addCheck({ kind: "emoji", ...p.errToObj(e) });
1923
- }
1924
- uuid(e) {
1925
- return this._addCheck({ kind: "uuid", ...p.errToObj(e) });
1926
- }
1927
- nanoid(e) {
1928
- return this._addCheck({ kind: "nanoid", ...p.errToObj(e) });
1929
- }
1930
- cuid(e) {
1931
- return this._addCheck({ kind: "cuid", ...p.errToObj(e) });
1932
- }
1933
- cuid2(e) {
1934
- return this._addCheck({ kind: "cuid2", ...p.errToObj(e) });
1935
- }
1936
- ulid(e) {
1937
- return this._addCheck({ kind: "ulid", ...p.errToObj(e) });
1938
- }
1939
- base64(e) {
1940
- return this._addCheck({ kind: "base64", ...p.errToObj(e) });
1941
- }
1942
- ip(e) {
1943
- return this._addCheck({ kind: "ip", ...p.errToObj(e) });
1944
- }
1945
- datetime(e) {
1946
- var t, n;
1947
- return typeof e == "string" ? this._addCheck({
1948
- kind: "datetime",
1949
- precision: null,
1950
- offset: !1,
1951
- local: !1,
1952
- message: e
1953
- }) : this._addCheck({
1954
- kind: "datetime",
1955
- precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
1956
- offset: (t = e == null ? void 0 : e.offset) !== null && t !== void 0 ? t : !1,
1957
- local: (n = e == null ? void 0 : e.local) !== null && n !== void 0 ? n : !1,
1958
- ...p.errToObj(e == null ? void 0 : e.message)
1959
- });
1960
- }
1961
- date(e) {
1962
- return this._addCheck({ kind: "date", message: e });
1963
- }
1964
- time(e) {
1965
- return typeof e == "string" ? this._addCheck({
1966
- kind: "time",
1967
- precision: null,
1968
- message: e
1969
- }) : this._addCheck({
1970
- kind: "time",
1971
- precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
1972
- ...p.errToObj(e == null ? void 0 : e.message)
1973
- });
1974
- }
1975
- duration(e) {
1976
- return this._addCheck({ kind: "duration", ...p.errToObj(e) });
1977
- }
1978
- regex(e, t) {
1979
- return this._addCheck({
1980
- kind: "regex",
1981
- regex: e,
1982
- ...p.errToObj(t)
1983
- });
1984
- }
1985
- includes(e, t) {
1986
- return this._addCheck({
1987
- kind: "includes",
1988
- value: e,
1989
- position: t == null ? void 0 : t.position,
1990
- ...p.errToObj(t == null ? void 0 : t.message)
1991
- });
1992
- }
1993
- startsWith(e, t) {
1994
- return this._addCheck({
1995
- kind: "startsWith",
1996
- value: e,
1997
- ...p.errToObj(t)
1998
- });
1999
- }
2000
- endsWith(e, t) {
2001
- return this._addCheck({
2002
- kind: "endsWith",
2003
- value: e,
2004
- ...p.errToObj(t)
2005
- });
2006
- }
2007
- min(e, t) {
2008
- return this._addCheck({
2009
- kind: "min",
2010
- value: e,
2011
- ...p.errToObj(t)
2012
- });
2013
- }
2014
- max(e, t) {
2015
- return this._addCheck({
2016
- kind: "max",
2017
- value: e,
2018
- ...p.errToObj(t)
2019
- });
2020
- }
2021
- length(e, t) {
2022
- return this._addCheck({
2023
- kind: "length",
2024
- value: e,
2025
- ...p.errToObj(t)
2026
- });
2027
- }
2028
- /**
2029
- * @deprecated Use z.string().min(1) instead.
2030
- * @see {@link ZodString.min}
2031
- */
2032
- nonempty(e) {
2033
- return this.min(1, p.errToObj(e));
2034
- }
2035
- trim() {
2036
- return new D({
2037
- ...this._def,
2038
- checks: [...this._def.checks, { kind: "trim" }]
2039
- });
2040
- }
2041
- toLowerCase() {
2042
- return new D({
2043
- ...this._def,
2044
- checks: [...this._def.checks, { kind: "toLowerCase" }]
2045
- });
2046
- }
2047
- toUpperCase() {
2048
- return new D({
2049
- ...this._def,
2050
- checks: [...this._def.checks, { kind: "toUpperCase" }]
2051
- });
2052
- }
2053
- get isDatetime() {
2054
- return !!this._def.checks.find((e) => e.kind === "datetime");
2055
- }
2056
- get isDate() {
2057
- return !!this._def.checks.find((e) => e.kind === "date");
2058
- }
2059
- get isTime() {
2060
- return !!this._def.checks.find((e) => e.kind === "time");
2061
- }
2062
- get isDuration() {
2063
- return !!this._def.checks.find((e) => e.kind === "duration");
2064
- }
2065
- get isEmail() {
2066
- return !!this._def.checks.find((e) => e.kind === "email");
2067
- }
2068
- get isURL() {
2069
- return !!this._def.checks.find((e) => e.kind === "url");
2070
- }
2071
- get isEmoji() {
2072
- return !!this._def.checks.find((e) => e.kind === "emoji");
2073
- }
2074
- get isUUID() {
2075
- return !!this._def.checks.find((e) => e.kind === "uuid");
2076
- }
2077
- get isNANOID() {
2078
- return !!this._def.checks.find((e) => e.kind === "nanoid");
2079
- }
2080
- get isCUID() {
2081
- return !!this._def.checks.find((e) => e.kind === "cuid");
2082
- }
2083
- get isCUID2() {
2084
- return !!this._def.checks.find((e) => e.kind === "cuid2");
2085
- }
2086
- get isULID() {
2087
- return !!this._def.checks.find((e) => e.kind === "ulid");
2088
- }
2089
- get isIP() {
2090
- return !!this._def.checks.find((e) => e.kind === "ip");
2091
- }
2092
- get isBase64() {
2093
- return !!this._def.checks.find((e) => e.kind === "base64");
2094
- }
2095
- get minLength() {
2096
- let e = null;
2097
- for (const t of this._def.checks)
2098
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
2099
- return e;
2100
- }
2101
- get maxLength() {
2102
- let e = null;
2103
- for (const t of this._def.checks)
2104
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
2105
- return e;
2106
- }
2107
- }
2108
- D.create = (r) => {
2109
- var e;
2110
- return new D({
2111
- checks: [],
2112
- typeName: m.ZodString,
2113
- coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
2114
- ..._(r)
2115
- });
2116
- };
2117
- function Hn(r, e) {
2118
- const t = (r.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, s = t > n ? t : n, a = parseInt(r.toFixed(s).replace(".", "")), i = parseInt(e.toFixed(s).replace(".", ""));
2119
- return a % i / Math.pow(10, s);
2120
- }
2121
- class K extends w {
2122
- constructor() {
2123
- super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
2124
- }
2125
- _parse(e) {
2126
- if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
2127
- const a = this._getOrReturnCtx(e);
2128
- return f(a, {
2129
- code: l.invalid_type,
2130
- expected: h.number,
2131
- received: a.parsedType
2132
- }), g;
2133
- }
2134
- let n;
2135
- const s = new j();
2136
- for (const a of this._def.checks)
2137
- a.kind === "int" ? b.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
2138
- code: l.invalid_type,
2139
- expected: "integer",
2140
- received: "float",
2141
- message: a.message
2142
- }), s.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
2143
- code: l.too_small,
2144
- minimum: a.value,
2145
- type: "number",
2146
- inclusive: a.inclusive,
2147
- exact: !1,
2148
- message: a.message
2149
- }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
2150
- code: l.too_big,
2151
- maximum: a.value,
2152
- type: "number",
2153
- inclusive: a.inclusive,
2154
- exact: !1,
2155
- message: a.message
2156
- }), s.dirty()) : a.kind === "multipleOf" ? Hn(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), f(n, {
2157
- code: l.not_multiple_of,
2158
- multipleOf: a.value,
2159
- message: a.message
2160
- }), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
2161
- code: l.not_finite,
2162
- message: a.message
2163
- }), s.dirty()) : b.assertNever(a);
2164
- return { status: s.value, value: e.data };
2165
- }
2166
- gte(e, t) {
2167
- return this.setLimit("min", e, !0, p.toString(t));
2168
- }
2169
- gt(e, t) {
2170
- return this.setLimit("min", e, !1, p.toString(t));
2171
- }
2172
- lte(e, t) {
2173
- return this.setLimit("max", e, !0, p.toString(t));
2174
- }
2175
- lt(e, t) {
2176
- return this.setLimit("max", e, !1, p.toString(t));
2177
- }
2178
- setLimit(e, t, n, s) {
2179
- return new K({
2180
- ...this._def,
2181
- checks: [
2182
- ...this._def.checks,
2183
- {
2184
- kind: e,
2185
- value: t,
2186
- inclusive: n,
2187
- message: p.toString(s)
2188
- }
2189
- ]
2190
- });
2191
- }
2192
- _addCheck(e) {
2193
- return new K({
2194
- ...this._def,
2195
- checks: [...this._def.checks, e]
2196
- });
2197
- }
2198
- int(e) {
2199
- return this._addCheck({
2200
- kind: "int",
2201
- message: p.toString(e)
2202
- });
2203
- }
2204
- positive(e) {
2205
- return this._addCheck({
2206
- kind: "min",
2207
- value: 0,
2208
- inclusive: !1,
2209
- message: p.toString(e)
2210
- });
2211
- }
2212
- negative(e) {
2213
- return this._addCheck({
2214
- kind: "max",
2215
- value: 0,
2216
- inclusive: !1,
2217
- message: p.toString(e)
2218
- });
2219
- }
2220
- nonpositive(e) {
2221
- return this._addCheck({
2222
- kind: "max",
2223
- value: 0,
2224
- inclusive: !0,
2225
- message: p.toString(e)
2226
- });
2227
- }
2228
- nonnegative(e) {
2229
- return this._addCheck({
2230
- kind: "min",
2231
- value: 0,
2232
- inclusive: !0,
2233
- message: p.toString(e)
2234
- });
2235
- }
2236
- multipleOf(e, t) {
2237
- return this._addCheck({
2238
- kind: "multipleOf",
2239
- value: e,
2240
- message: p.toString(t)
2241
- });
2242
- }
2243
- finite(e) {
2244
- return this._addCheck({
2245
- kind: "finite",
2246
- message: p.toString(e)
2247
- });
2248
- }
2249
- safe(e) {
2250
- return this._addCheck({
2251
- kind: "min",
2252
- inclusive: !0,
2253
- value: Number.MIN_SAFE_INTEGER,
2254
- message: p.toString(e)
2255
- })._addCheck({
2256
- kind: "max",
2257
- inclusive: !0,
2258
- value: Number.MAX_SAFE_INTEGER,
2259
- message: p.toString(e)
2260
- });
2261
- }
2262
- get minValue() {
2263
- let e = null;
2264
- for (const t of this._def.checks)
2265
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
2266
- return e;
2267
- }
2268
- get maxValue() {
2269
- let e = null;
2270
- for (const t of this._def.checks)
2271
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
2272
- return e;
2273
- }
2274
- get isInt() {
2275
- return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && b.isInteger(e.value));
2276
- }
2277
- get isFinite() {
2278
- let e = null, t = null;
2279
- for (const n of this._def.checks) {
2280
- if (n.kind === "finite" || n.kind === "int" || n.kind === "multipleOf")
2281
- return !0;
2282
- n.kind === "min" ? (t === null || n.value > t) && (t = n.value) : n.kind === "max" && (e === null || n.value < e) && (e = n.value);
2283
- }
2284
- return Number.isFinite(t) && Number.isFinite(e);
2285
- }
2286
- }
2287
- K.create = (r) => new K({
2288
- checks: [],
2289
- typeName: m.ZodNumber,
2290
- coerce: (r == null ? void 0 : r.coerce) || !1,
2291
- ..._(r)
2292
- });
2293
- class Y extends w {
2294
- constructor() {
2295
- super(...arguments), this.min = this.gte, this.max = this.lte;
2296
- }
2297
- _parse(e) {
2298
- if (this._def.coerce && (e.data = BigInt(e.data)), this._getType(e) !== h.bigint) {
2299
- const a = this._getOrReturnCtx(e);
2300
- return f(a, {
2301
- code: l.invalid_type,
2302
- expected: h.bigint,
2303
- received: a.parsedType
2304
- }), g;
2305
- }
2306
- let n;
2307
- const s = new j();
2308
- for (const a of this._def.checks)
2309
- a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
2310
- code: l.too_small,
2311
- type: "bigint",
2312
- minimum: a.value,
2313
- inclusive: a.inclusive,
2314
- message: a.message
2315
- }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
2316
- code: l.too_big,
2317
- type: "bigint",
2318
- maximum: a.value,
2319
- inclusive: a.inclusive,
2320
- message: a.message
2321
- }), s.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), f(n, {
2322
- code: l.not_multiple_of,
2323
- multipleOf: a.value,
2324
- message: a.message
2325
- }), s.dirty()) : b.assertNever(a);
2326
- return { status: s.value, value: e.data };
2327
- }
2328
- gte(e, t) {
2329
- return this.setLimit("min", e, !0, p.toString(t));
2330
- }
2331
- gt(e, t) {
2332
- return this.setLimit("min", e, !1, p.toString(t));
2333
- }
2334
- lte(e, t) {
2335
- return this.setLimit("max", e, !0, p.toString(t));
2336
- }
2337
- lt(e, t) {
2338
- return this.setLimit("max", e, !1, p.toString(t));
2339
- }
2340
- setLimit(e, t, n, s) {
2341
- return new Y({
2342
- ...this._def,
2343
- checks: [
2344
- ...this._def.checks,
2345
- {
2346
- kind: e,
2347
- value: t,
2348
- inclusive: n,
2349
- message: p.toString(s)
2350
- }
2351
- ]
2352
- });
2353
- }
2354
- _addCheck(e) {
2355
- return new Y({
2356
- ...this._def,
2357
- checks: [...this._def.checks, e]
2358
- });
2359
- }
2360
- positive(e) {
2361
- return this._addCheck({
2362
- kind: "min",
2363
- value: BigInt(0),
2364
- inclusive: !1,
2365
- message: p.toString(e)
2366
- });
2367
- }
2368
- negative(e) {
2369
- return this._addCheck({
2370
- kind: "max",
2371
- value: BigInt(0),
2372
- inclusive: !1,
2373
- message: p.toString(e)
2374
- });
2375
- }
2376
- nonpositive(e) {
2377
- return this._addCheck({
2378
- kind: "max",
2379
- value: BigInt(0),
2380
- inclusive: !0,
2381
- message: p.toString(e)
2382
- });
2383
- }
2384
- nonnegative(e) {
2385
- return this._addCheck({
2386
- kind: "min",
2387
- value: BigInt(0),
2388
- inclusive: !0,
2389
- message: p.toString(e)
2390
- });
2391
- }
2392
- multipleOf(e, t) {
2393
- return this._addCheck({
2394
- kind: "multipleOf",
2395
- value: e,
2396
- message: p.toString(t)
2397
- });
2398
- }
2399
- get minValue() {
2400
- let e = null;
2401
- for (const t of this._def.checks)
2402
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
2403
- return e;
2404
- }
2405
- get maxValue() {
2406
- let e = null;
2407
- for (const t of this._def.checks)
2408
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
2409
- return e;
2410
- }
2411
- }
2412
- Y.create = (r) => {
2413
- var e;
2414
- return new Y({
2415
- checks: [],
2416
- typeName: m.ZodBigInt,
2417
- coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
2418
- ..._(r)
2419
- });
2420
- };
2421
- class Ce extends w {
2422
- _parse(e) {
2423
- if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
2424
- const n = this._getOrReturnCtx(e);
2425
- return f(n, {
2426
- code: l.invalid_type,
2427
- expected: h.boolean,
2428
- received: n.parsedType
2429
- }), g;
2430
- }
2431
- return P(e.data);
2432
- }
2433
- }
2434
- Ce.create = (r) => new Ce({
2435
- typeName: m.ZodBoolean,
2436
- coerce: (r == null ? void 0 : r.coerce) || !1,
2437
- ..._(r)
2438
- });
2439
- class ae extends w {
2440
- _parse(e) {
2441
- if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
2442
- const a = this._getOrReturnCtx(e);
2443
- return f(a, {
2444
- code: l.invalid_type,
2445
- expected: h.date,
2446
- received: a.parsedType
2447
- }), g;
2448
- }
2449
- if (isNaN(e.data.getTime())) {
2450
- const a = this._getOrReturnCtx(e);
2451
- return f(a, {
2452
- code: l.invalid_date
2453
- }), g;
2454
- }
2455
- const n = new j();
2456
- let s;
2457
- for (const a of this._def.checks)
2458
- a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), f(s, {
2459
- code: l.too_small,
2460
- message: a.message,
2461
- inclusive: !0,
2462
- exact: !1,
2463
- minimum: a.value,
2464
- type: "date"
2465
- }), n.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (s = this._getOrReturnCtx(e, s), f(s, {
2466
- code: l.too_big,
2467
- message: a.message,
2468
- inclusive: !0,
2469
- exact: !1,
2470
- maximum: a.value,
2471
- type: "date"
2472
- }), n.dirty()) : b.assertNever(a);
2473
- return {
2474
- status: n.value,
2475
- value: new Date(e.data.getTime())
2476
- };
2477
- }
2478
- _addCheck(e) {
2479
- return new ae({
2480
- ...this._def,
2481
- checks: [...this._def.checks, e]
2482
- });
2483
- }
2484
- min(e, t) {
2485
- return this._addCheck({
2486
- kind: "min",
2487
- value: e.getTime(),
2488
- message: p.toString(t)
2489
- });
2490
- }
2491
- max(e, t) {
2492
- return this._addCheck({
2493
- kind: "max",
2494
- value: e.getTime(),
2495
- message: p.toString(t)
2496
- });
2497
- }
2498
- get minDate() {
2499
- let e = null;
2500
- for (const t of this._def.checks)
2501
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
2502
- return e != null ? new Date(e) : null;
2503
- }
2504
- get maxDate() {
2505
- let e = null;
2506
- for (const t of this._def.checks)
2507
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
2508
- return e != null ? new Date(e) : null;
2509
- }
2510
- }
2511
- ae.create = (r) => new ae({
2512
- checks: [],
2513
- coerce: (r == null ? void 0 : r.coerce) || !1,
2514
- typeName: m.ZodDate,
2515
- ..._(r)
2516
- });
2517
- class at extends w {
2518
- _parse(e) {
2519
- if (this._getType(e) !== h.symbol) {
2520
- const n = this._getOrReturnCtx(e);
2521
- return f(n, {
2522
- code: l.invalid_type,
2523
- expected: h.symbol,
2524
- received: n.parsedType
2525
- }), g;
2526
- }
2527
- return P(e.data);
2528
- }
2529
- }
2530
- at.create = (r) => new at({
2531
- typeName: m.ZodSymbol,
2532
- ..._(r)
2533
- });
2534
- class Oe extends w {
2535
- _parse(e) {
2536
- if (this._getType(e) !== h.undefined) {
2537
- const n = this._getOrReturnCtx(e);
2538
- return f(n, {
2539
- code: l.invalid_type,
2540
- expected: h.undefined,
2541
- received: n.parsedType
2542
- }), g;
2543
- }
2544
- return P(e.data);
2545
- }
2546
- }
2547
- Oe.create = (r) => new Oe({
2548
- typeName: m.ZodUndefined,
2549
- ..._(r)
2550
- });
2551
- class Ee extends w {
2552
- _parse(e) {
2553
- if (this._getType(e) !== h.null) {
2554
- const n = this._getOrReturnCtx(e);
2555
- return f(n, {
2556
- code: l.invalid_type,
2557
- expected: h.null,
2558
- received: n.parsedType
2559
- }), g;
2560
- }
2561
- return P(e.data);
2562
- }
2563
- }
2564
- Ee.create = (r) => new Ee({
2565
- typeName: m.ZodNull,
2566
- ..._(r)
2567
- });
2568
- class ye extends w {
2569
- constructor() {
2570
- super(...arguments), this._any = !0;
2571
- }
2572
- _parse(e) {
2573
- return P(e.data);
2574
- }
2575
- }
2576
- ye.create = (r) => new ye({
2577
- typeName: m.ZodAny,
2578
- ..._(r)
2579
- });
2580
- class se extends w {
2581
- constructor() {
2582
- super(...arguments), this._unknown = !0;
2583
- }
2584
- _parse(e) {
2585
- return P(e.data);
2586
- }
2587
- }
2588
- se.create = (r) => new se({
2589
- typeName: m.ZodUnknown,
2590
- ..._(r)
2591
- });
2592
- class F extends w {
2593
- _parse(e) {
2594
- const t = this._getOrReturnCtx(e);
2595
- return f(t, {
2596
- code: l.invalid_type,
2597
- expected: h.never,
2598
- received: t.parsedType
2599
- }), g;
2600
- }
2601
- }
2602
- F.create = (r) => new F({
2603
- typeName: m.ZodNever,
2604
- ..._(r)
2605
- });
2606
- class it extends w {
2607
- _parse(e) {
2608
- if (this._getType(e) !== h.undefined) {
2609
- const n = this._getOrReturnCtx(e);
2610
- return f(n, {
2611
- code: l.invalid_type,
2612
- expected: h.void,
2613
- received: n.parsedType
2614
- }), g;
2615
- }
2616
- return P(e.data);
2617
- }
2618
- }
2619
- it.create = (r) => new it({
2620
- typeName: m.ZodVoid,
2621
- ..._(r)
2622
- });
2623
- class L extends w {
2624
- _parse(e) {
2625
- const { ctx: t, status: n } = this._processInputParams(e), s = this._def;
2626
- if (t.parsedType !== h.array)
2627
- return f(t, {
2628
- code: l.invalid_type,
2629
- expected: h.array,
2630
- received: t.parsedType
2631
- }), g;
2632
- if (s.exactLength !== null) {
2633
- const i = t.data.length > s.exactLength.value, o = t.data.length < s.exactLength.value;
2634
- (i || o) && (f(t, {
2635
- code: i ? l.too_big : l.too_small,
2636
- minimum: o ? s.exactLength.value : void 0,
2637
- maximum: i ? s.exactLength.value : void 0,
2638
- type: "array",
2639
- inclusive: !0,
2640
- exact: !0,
2641
- message: s.exactLength.message
2642
- }), n.dirty());
2643
- }
2644
- if (s.minLength !== null && t.data.length < s.minLength.value && (f(t, {
2645
- code: l.too_small,
2646
- minimum: s.minLength.value,
2647
- type: "array",
2648
- inclusive: !0,
2649
- exact: !1,
2650
- message: s.minLength.message
2651
- }), n.dirty()), s.maxLength !== null && t.data.length > s.maxLength.value && (f(t, {
2652
- code: l.too_big,
2653
- maximum: s.maxLength.value,
2654
- type: "array",
2655
- inclusive: !0,
2656
- exact: !1,
2657
- message: s.maxLength.message
2658
- }), n.dirty()), t.common.async)
2659
- return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new q(t, i, t.path, o)))).then((i) => j.mergeArray(n, i));
2660
- const a = [...t.data].map((i, o) => s.type._parseSync(new q(t, i, t.path, o)));
2661
- return j.mergeArray(n, a);
2662
- }
2663
- get element() {
2664
- return this._def.type;
2665
- }
2666
- min(e, t) {
2667
- return new L({
2668
- ...this._def,
2669
- minLength: { value: e, message: p.toString(t) }
2670
- });
2671
- }
2672
- max(e, t) {
2673
- return new L({
2674
- ...this._def,
2675
- maxLength: { value: e, message: p.toString(t) }
2676
- });
2677
- }
2678
- length(e, t) {
2679
- return new L({
2680
- ...this._def,
2681
- exactLength: { value: e, message: p.toString(t) }
2682
- });
2683
- }
2684
- nonempty(e) {
2685
- return this.min(1, e);
2686
- }
2687
- }
2688
- L.create = (r, e) => new L({
2689
- type: r,
2690
- minLength: null,
2691
- maxLength: null,
2692
- exactLength: null,
2693
- typeName: m.ZodArray,
2694
- ..._(e)
2695
- });
2696
- function oe(r) {
2697
- if (r instanceof T) {
2698
- const e = {};
2699
- for (const t in r.shape) {
2700
- const n = r.shape[t];
2701
- e[t] = V.create(oe(n));
2702
- }
2703
- return new T({
2704
- ...r._def,
2705
- shape: () => e
2706
- });
2707
- } else
2708
- return r instanceof L ? new L({
2709
- ...r._def,
2710
- type: oe(r.element)
2711
- }) : r instanceof V ? V.create(oe(r.unwrap())) : r instanceof J ? J.create(oe(r.unwrap())) : r instanceof B ? B.create(r.items.map((e) => oe(e))) : r;
2712
- }
2713
- class T extends w {
2714
- constructor() {
2715
- super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
2716
- }
2717
- _getCached() {
2718
- if (this._cached !== null)
2719
- return this._cached;
2720
- const e = this._def.shape(), t = b.objectKeys(e);
2721
- return this._cached = { shape: e, keys: t };
2722
- }
2723
- _parse(e) {
2724
- if (this._getType(e) !== h.object) {
2725
- const u = this._getOrReturnCtx(e);
2726
- return f(u, {
2727
- code: l.invalid_type,
2728
- expected: h.object,
2729
- received: u.parsedType
2730
- }), g;
2731
- }
2732
- const { status: n, ctx: s } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
2733
- if (!(this._def.catchall instanceof F && this._def.unknownKeys === "strip"))
2734
- for (const u in s.data)
2735
- i.includes(u) || o.push(u);
2736
- const c = [];
2737
- for (const u of i) {
2738
- const d = a[u], y = s.data[u];
2739
- c.push({
2740
- key: { status: "valid", value: u },
2741
- value: d._parse(new q(s, y, s.path, u)),
2742
- alwaysSet: u in s.data
2743
- });
2744
- }
2745
- if (this._def.catchall instanceof F) {
2746
- const u = this._def.unknownKeys;
2747
- if (u === "passthrough")
2748
- for (const d of o)
2749
- c.push({
2750
- key: { status: "valid", value: d },
2751
- value: { status: "valid", value: s.data[d] }
2752
- });
2753
- else if (u === "strict")
2754
- o.length > 0 && (f(s, {
2755
- code: l.unrecognized_keys,
2756
- keys: o
2757
- }), n.dirty());
2758
- else if (u !== "strip")
2759
- throw new Error("Internal ZodObject error: invalid unknownKeys value.");
2760
- } else {
2761
- const u = this._def.catchall;
2762
- for (const d of o) {
2763
- const y = s.data[d];
2764
- c.push({
2765
- key: { status: "valid", value: d },
2766
- value: u._parse(
2767
- new q(s, y, s.path, d)
2768
- //, ctx.child(key), value, getParsedType(value)
2769
- ),
2770
- alwaysSet: d in s.data
2771
- });
2772
- }
2773
- }
2774
- return s.common.async ? Promise.resolve().then(async () => {
2775
- const u = [];
2776
- for (const d of c) {
2777
- const y = await d.key, x = await d.value;
2778
- u.push({
2779
- key: y,
2780
- value: x,
2781
- alwaysSet: d.alwaysSet
2782
- });
2783
- }
2784
- return u;
2785
- }).then((u) => j.mergeObjectSync(n, u)) : j.mergeObjectSync(n, c);
2786
- }
2787
- get shape() {
2788
- return this._def.shape();
2789
- }
2790
- strict(e) {
2791
- return p.errToObj, new T({
2792
- ...this._def,
2793
- unknownKeys: "strict",
2794
- ...e !== void 0 ? {
2795
- errorMap: (t, n) => {
2796
- var s, a, i, o;
2797
- const c = (i = (a = (s = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(s, t, n).message) !== null && i !== void 0 ? i : n.defaultError;
2798
- return t.code === "unrecognized_keys" ? {
2799
- message: (o = p.errToObj(e).message) !== null && o !== void 0 ? o : c
2800
- } : {
2801
- message: c
2802
- };
2803
- }
2804
- } : {}
2805
- });
2806
- }
2807
- strip() {
2808
- return new T({
2809
- ...this._def,
2810
- unknownKeys: "strip"
2811
- });
2812
- }
2813
- passthrough() {
2814
- return new T({
2815
- ...this._def,
2816
- unknownKeys: "passthrough"
2817
- });
2818
- }
2819
- // const AugmentFactory =
2820
- // <Def extends ZodObjectDef>(def: Def) =>
2821
- // <Augmentation extends ZodRawShape>(
2822
- // augmentation: Augmentation
2823
- // ): ZodObject<
2824
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2825
- // Def["unknownKeys"],
2826
- // Def["catchall"]
2827
- // > => {
2828
- // return new ZodObject({
2829
- // ...def,
2830
- // shape: () => ({
2831
- // ...def.shape(),
2832
- // ...augmentation,
2833
- // }),
2834
- // }) as any;
2835
- // };
2836
- extend(e) {
2837
- return new T({
2838
- ...this._def,
2839
- shape: () => ({
2840
- ...this._def.shape(),
2841
- ...e
2842
- })
2843
- });
2844
- }
2845
- /**
2846
- * Prior to zod@1.0.12 there was a bug in the
2847
- * inferred type of merged objects. Please
2848
- * upgrade if you are experiencing issues.
2849
- */
2850
- merge(e) {
2851
- return new T({
2852
- unknownKeys: e._def.unknownKeys,
2853
- catchall: e._def.catchall,
2854
- shape: () => ({
2855
- ...this._def.shape(),
2856
- ...e._def.shape()
2857
- }),
2858
- typeName: m.ZodObject
2859
- });
2860
- }
2861
- // merge<
2862
- // Incoming extends AnyZodObject,
2863
- // Augmentation extends Incoming["shape"],
2864
- // NewOutput extends {
2865
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2866
- // ? Augmentation[k]["_output"]
2867
- // : k extends keyof Output
2868
- // ? Output[k]
2869
- // : never;
2870
- // },
2871
- // NewInput extends {
2872
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2873
- // ? Augmentation[k]["_input"]
2874
- // : k extends keyof Input
2875
- // ? Input[k]
2876
- // : never;
2877
- // }
2878
- // >(
2879
- // merging: Incoming
2880
- // ): ZodObject<
2881
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2882
- // Incoming["_def"]["unknownKeys"],
2883
- // Incoming["_def"]["catchall"],
2884
- // NewOutput,
2885
- // NewInput
2886
- // > {
2887
- // const merged: any = new ZodObject({
2888
- // unknownKeys: merging._def.unknownKeys,
2889
- // catchall: merging._def.catchall,
2890
- // shape: () =>
2891
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2892
- // typeName: ZodFirstPartyTypeKind.ZodObject,
2893
- // }) as any;
2894
- // return merged;
2895
- // }
2896
- setKey(e, t) {
2897
- return this.augment({ [e]: t });
2898
- }
2899
- // merge<Incoming extends AnyZodObject>(
2900
- // merging: Incoming
2901
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2902
- // ZodObject<
2903
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2904
- // Incoming["_def"]["unknownKeys"],
2905
- // Incoming["_def"]["catchall"]
2906
- // > {
2907
- // // const mergedShape = objectUtil.mergeShapes(
2908
- // // this._def.shape(),
2909
- // // merging._def.shape()
2910
- // // );
2911
- // const merged: any = new ZodObject({
2912
- // unknownKeys: merging._def.unknownKeys,
2913
- // catchall: merging._def.catchall,
2914
- // shape: () =>
2915
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2916
- // typeName: ZodFirstPartyTypeKind.ZodObject,
2917
- // }) as any;
2918
- // return merged;
2919
- // }
2920
- catchall(e) {
2921
- return new T({
2922
- ...this._def,
2923
- catchall: e
2924
- });
2925
- }
2926
- pick(e) {
2927
- const t = {};
2928
- return b.objectKeys(e).forEach((n) => {
2929
- e[n] && this.shape[n] && (t[n] = this.shape[n]);
2930
- }), new T({
2931
- ...this._def,
2932
- shape: () => t
2933
- });
2934
- }
2935
- omit(e) {
2936
- const t = {};
2937
- return b.objectKeys(this.shape).forEach((n) => {
2938
- e[n] || (t[n] = this.shape[n]);
2939
- }), new T({
2940
- ...this._def,
2941
- shape: () => t
2942
- });
2943
- }
2944
- /**
2945
- * @deprecated
2946
- */
2947
- deepPartial() {
2948
- return oe(this);
2949
- }
2950
- partial(e) {
2951
- const t = {};
2952
- return b.objectKeys(this.shape).forEach((n) => {
2953
- const s = this.shape[n];
2954
- e && !e[n] ? t[n] = s : t[n] = s.optional();
2955
- }), new T({
2956
- ...this._def,
2957
- shape: () => t
2958
- });
2959
- }
2960
- required(e) {
2961
- const t = {};
2962
- return b.objectKeys(this.shape).forEach((n) => {
2963
- if (e && !e[n])
2964
- t[n] = this.shape[n];
2965
- else {
2966
- let a = this.shape[n];
2967
- for (; a instanceof V; )
2968
- a = a._def.innerType;
2969
- t[n] = a;
2970
- }
2971
- }), new T({
2972
- ...this._def,
2973
- shape: () => t
2974
- });
2975
- }
2976
- keyof() {
2977
- return ar(b.objectKeys(this.shape));
2978
- }
2979
- }
2980
- T.create = (r, e) => new T({
2981
- shape: () => r,
2982
- unknownKeys: "strip",
2983
- catchall: F.create(),
2984
- typeName: m.ZodObject,
2985
- ..._(e)
2986
- });
2987
- T.strictCreate = (r, e) => new T({
2988
- shape: () => r,
2989
- unknownKeys: "strict",
2990
- catchall: F.create(),
2991
- typeName: m.ZodObject,
2992
- ..._(e)
2993
- });
2994
- T.lazycreate = (r, e) => new T({
2995
- shape: r,
2996
- unknownKeys: "strip",
2997
- catchall: F.create(),
2998
- typeName: m.ZodObject,
2999
- ..._(e)
3000
- });
3001
- class Ae extends w {
3002
- _parse(e) {
3003
- const { ctx: t } = this._processInputParams(e), n = this._def.options;
3004
- function s(a) {
3005
- for (const o of a)
3006
- if (o.result.status === "valid")
3007
- return o.result;
3008
- for (const o of a)
3009
- if (o.result.status === "dirty")
3010
- return t.common.issues.push(...o.ctx.common.issues), o.result;
3011
- const i = a.map((o) => new Z(o.ctx.common.issues));
3012
- return f(t, {
3013
- code: l.invalid_union,
3014
- unionErrors: i
3015
- }), g;
3016
- }
3017
- if (t.common.async)
3018
- return Promise.all(n.map(async (a) => {
3019
- const i = {
3020
- ...t,
3021
- common: {
3022
- ...t.common,
3023
- issues: []
3024
- },
3025
- parent: null
3026
- };
3027
- return {
3028
- result: await a._parseAsync({
3029
- data: t.data,
3030
- path: t.path,
3031
- parent: i
3032
- }),
3033
- ctx: i
3034
- };
3035
- })).then(s);
3036
- {
3037
- let a;
3038
- const i = [];
3039
- for (const c of n) {
3040
- const u = {
3041
- ...t,
3042
- common: {
3043
- ...t.common,
3044
- issues: []
3045
- },
3046
- parent: null
3047
- }, d = c._parseSync({
3048
- data: t.data,
3049
- path: t.path,
3050
- parent: u
3051
- });
3052
- if (d.status === "valid")
3053
- return d;
3054
- d.status === "dirty" && !a && (a = { result: d, ctx: u }), u.common.issues.length && i.push(u.common.issues);
3055
- }
3056
- if (a)
3057
- return t.common.issues.push(...a.ctx.common.issues), a.result;
3058
- const o = i.map((c) => new Z(c));
3059
- return f(t, {
3060
- code: l.invalid_union,
3061
- unionErrors: o
3062
- }), g;
3063
- }
3064
- }
3065
- get options() {
3066
- return this._def.options;
3067
- }
3068
- }
3069
- Ae.create = (r, e) => new Ae({
3070
- options: r,
3071
- typeName: m.ZodUnion,
3072
- ..._(e)
3073
- });
3074
- const G = (r) => r instanceof je ? G(r.schema) : r instanceof z ? G(r.innerType()) : r instanceof Re ? [r.value] : r instanceof X ? r.options : r instanceof Pe ? b.objectValues(r.enum) : r instanceof Ze ? G(r._def.innerType) : r instanceof Oe ? [void 0] : r instanceof Ee ? [null] : r instanceof V ? [void 0, ...G(r.unwrap())] : r instanceof J ? [null, ...G(r.unwrap())] : r instanceof It || r instanceof $e ? G(r.unwrap()) : r instanceof Me ? G(r._def.innerType) : [];
3075
- class ft extends w {
3076
- _parse(e) {
3077
- const { ctx: t } = this._processInputParams(e);
3078
- if (t.parsedType !== h.object)
3079
- return f(t, {
3080
- code: l.invalid_type,
3081
- expected: h.object,
3082
- received: t.parsedType
3083
- }), g;
3084
- const n = this.discriminator, s = t.data[n], a = this.optionsMap.get(s);
3085
- return a ? t.common.async ? a._parseAsync({
3086
- data: t.data,
3087
- path: t.path,
3088
- parent: t
3089
- }) : a._parseSync({
3090
- data: t.data,
3091
- path: t.path,
3092
- parent: t
3093
- }) : (f(t, {
3094
- code: l.invalid_union_discriminator,
3095
- options: Array.from(this.optionsMap.keys()),
3096
- path: [n]
3097
- }), g);
3098
- }
3099
- get discriminator() {
3100
- return this._def.discriminator;
3101
- }
3102
- get options() {
3103
- return this._def.options;
3104
- }
3105
- get optionsMap() {
3106
- return this._def.optionsMap;
3107
- }
3108
- /**
3109
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
3110
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
3111
- * have a different value for each object in the union.
3112
- * @param discriminator the name of the discriminator property
3113
- * @param types an array of object schemas
3114
- * @param params
3115
- */
3116
- static create(e, t, n) {
3117
- const s = /* @__PURE__ */ new Map();
3118
- for (const a of t) {
3119
- const i = G(a.shape[e]);
3120
- if (!i.length)
3121
- throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
3122
- for (const o of i) {
3123
- if (s.has(o))
3124
- throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
3125
- s.set(o, a);
3126
- }
3127
- }
3128
- return new ft({
3129
- typeName: m.ZodDiscriminatedUnion,
3130
- discriminator: e,
3131
- options: t,
3132
- optionsMap: s,
3133
- ..._(n)
3134
- });
3135
- }
3136
- }
3137
- function St(r, e) {
3138
- const t = H(r), n = H(e);
3139
- if (r === e)
3140
- return { valid: !0, data: r };
3141
- if (t === h.object && n === h.object) {
3142
- const s = b.objectKeys(e), a = b.objectKeys(r).filter((o) => s.indexOf(o) !== -1), i = { ...r, ...e };
3143
- for (const o of a) {
3144
- const c = St(r[o], e[o]);
3145
- if (!c.valid)
3146
- return { valid: !1 };
3147
- i[o] = c.data;
3148
- }
3149
- return { valid: !0, data: i };
3150
- } else if (t === h.array && n === h.array) {
3151
- if (r.length !== e.length)
3152
- return { valid: !1 };
3153
- const s = [];
3154
- for (let a = 0; a < r.length; a++) {
3155
- const i = r[a], o = e[a], c = St(i, o);
3156
- if (!c.valid)
3157
- return { valid: !1 };
3158
- s.push(c.data);
3159
- }
3160
- return { valid: !0, data: s };
3161
- } else
3162
- return t === h.date && n === h.date && +r == +e ? { valid: !0, data: r } : { valid: !1 };
3163
- }
3164
- class Ie extends w {
3165
- _parse(e) {
3166
- const { status: t, ctx: n } = this._processInputParams(e), s = (a, i) => {
3167
- if (bt(a) || bt(i))
3168
- return g;
3169
- const o = St(a.value, i.value);
3170
- return o.valid ? ((xt(a) || xt(i)) && t.dirty(), { status: t.value, value: o.data }) : (f(n, {
3171
- code: l.invalid_intersection_types
3172
- }), g);
3173
- };
3174
- return n.common.async ? Promise.all([
3175
- this._def.left._parseAsync({
3176
- data: n.data,
3177
- path: n.path,
3178
- parent: n
3179
- }),
3180
- this._def.right._parseAsync({
3181
- data: n.data,
3182
- path: n.path,
3183
- parent: n
3184
- })
3185
- ]).then(([a, i]) => s(a, i)) : s(this._def.left._parseSync({
3186
- data: n.data,
3187
- path: n.path,
3188
- parent: n
3189
- }), this._def.right._parseSync({
3190
- data: n.data,
3191
- path: n.path,
3192
- parent: n
3193
- }));
3194
- }
3195
- }
3196
- Ie.create = (r, e, t) => new Ie({
3197
- left: r,
3198
- right: e,
3199
- typeName: m.ZodIntersection,
3200
- ..._(t)
3201
- });
3202
- class B extends w {
3203
- _parse(e) {
3204
- const { status: t, ctx: n } = this._processInputParams(e);
3205
- if (n.parsedType !== h.array)
3206
- return f(n, {
3207
- code: l.invalid_type,
3208
- expected: h.array,
3209
- received: n.parsedType
3210
- }), g;
3211
- if (n.data.length < this._def.items.length)
3212
- return f(n, {
3213
- code: l.too_small,
3214
- minimum: this._def.items.length,
3215
- inclusive: !0,
3216
- exact: !1,
3217
- type: "array"
3218
- }), g;
3219
- !this._def.rest && n.data.length > this._def.items.length && (f(n, {
3220
- code: l.too_big,
3221
- maximum: this._def.items.length,
3222
- inclusive: !0,
3223
- exact: !1,
3224
- type: "array"
3225
- }), t.dirty());
3226
- const a = [...n.data].map((i, o) => {
3227
- const c = this._def.items[o] || this._def.rest;
3228
- return c ? c._parse(new q(n, i, n.path, o)) : null;
3229
- }).filter((i) => !!i);
3230
- return n.common.async ? Promise.all(a).then((i) => j.mergeArray(t, i)) : j.mergeArray(t, a);
3231
- }
3232
- get items() {
3233
- return this._def.items;
3234
- }
3235
- rest(e) {
3236
- return new B({
3237
- ...this._def,
3238
- rest: e
3239
- });
3240
- }
3241
- }
3242
- B.create = (r, e) => {
3243
- if (!Array.isArray(r))
3244
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3245
- return new B({
3246
- items: r,
3247
- typeName: m.ZodTuple,
3248
- rest: null,
3249
- ..._(e)
3250
- });
3251
- };
3252
- class Ne extends w {
3253
- get keySchema() {
3254
- return this._def.keyType;
3255
- }
3256
- get valueSchema() {
3257
- return this._def.valueType;
3258
- }
3259
- _parse(e) {
3260
- const { status: t, ctx: n } = this._processInputParams(e);
3261
- if (n.parsedType !== h.object)
3262
- return f(n, {
3263
- code: l.invalid_type,
3264
- expected: h.object,
3265
- received: n.parsedType
3266
- }), g;
3267
- const s = [], a = this._def.keyType, i = this._def.valueType;
3268
- for (const o in n.data)
3269
- s.push({
3270
- key: a._parse(new q(n, o, n.path, o)),
3271
- value: i._parse(new q(n, n.data[o], n.path, o)),
3272
- alwaysSet: o in n.data
3273
- });
3274
- return n.common.async ? j.mergeObjectAsync(t, s) : j.mergeObjectSync(t, s);
3275
- }
3276
- get element() {
3277
- return this._def.valueType;
3278
- }
3279
- static create(e, t, n) {
3280
- return t instanceof w ? new Ne({
3281
- keyType: e,
3282
- valueType: t,
3283
- typeName: m.ZodRecord,
3284
- ..._(n)
3285
- }) : new Ne({
3286
- keyType: D.create(),
3287
- valueType: e,
3288
- typeName: m.ZodRecord,
3289
- ..._(t)
3290
- });
3291
- }
3292
- }
3293
- class ot extends w {
3294
- get keySchema() {
3295
- return this._def.keyType;
3296
- }
3297
- get valueSchema() {
3298
- return this._def.valueType;
3299
- }
3300
- _parse(e) {
3301
- const { status: t, ctx: n } = this._processInputParams(e);
3302
- if (n.parsedType !== h.map)
3303
- return f(n, {
3304
- code: l.invalid_type,
3305
- expected: h.map,
3306
- received: n.parsedType
3307
- }), g;
3308
- const s = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, c], u) => ({
3309
- key: s._parse(new q(n, o, n.path, [u, "key"])),
3310
- value: a._parse(new q(n, c, n.path, [u, "value"]))
3311
- }));
3312
- if (n.common.async) {
3313
- const o = /* @__PURE__ */ new Map();
3314
- return Promise.resolve().then(async () => {
3315
- for (const c of i) {
3316
- const u = await c.key, d = await c.value;
3317
- if (u.status === "aborted" || d.status === "aborted")
3318
- return g;
3319
- (u.status === "dirty" || d.status === "dirty") && t.dirty(), o.set(u.value, d.value);
3320
- }
3321
- return { status: t.value, value: o };
3322
- });
3323
- } else {
3324
- const o = /* @__PURE__ */ new Map();
3325
- for (const c of i) {
3326
- const u = c.key, d = c.value;
3327
- if (u.status === "aborted" || d.status === "aborted")
3328
- return g;
3329
- (u.status === "dirty" || d.status === "dirty") && t.dirty(), o.set(u.value, d.value);
3330
- }
3331
- return { status: t.value, value: o };
3332
- }
3333
- }
3334
- }
3335
- ot.create = (r, e, t) => new ot({
3336
- valueType: e,
3337
- keyType: r,
3338
- typeName: m.ZodMap,
3339
- ..._(t)
3340
- });
3341
- class ie extends w {
3342
- _parse(e) {
3343
- const { status: t, ctx: n } = this._processInputParams(e);
3344
- if (n.parsedType !== h.set)
3345
- return f(n, {
3346
- code: l.invalid_type,
3347
- expected: h.set,
3348
- received: n.parsedType
3349
- }), g;
3350
- const s = this._def;
3351
- s.minSize !== null && n.data.size < s.minSize.value && (f(n, {
3352
- code: l.too_small,
3353
- minimum: s.minSize.value,
3354
- type: "set",
3355
- inclusive: !0,
3356
- exact: !1,
3357
- message: s.minSize.message
3358
- }), t.dirty()), s.maxSize !== null && n.data.size > s.maxSize.value && (f(n, {
3359
- code: l.too_big,
3360
- maximum: s.maxSize.value,
3361
- type: "set",
3362
- inclusive: !0,
3363
- exact: !1,
3364
- message: s.maxSize.message
3365
- }), t.dirty());
3366
- const a = this._def.valueType;
3367
- function i(c) {
3368
- const u = /* @__PURE__ */ new Set();
3369
- for (const d of c) {
3370
- if (d.status === "aborted")
3371
- return g;
3372
- d.status === "dirty" && t.dirty(), u.add(d.value);
3373
- }
3374
- return { status: t.value, value: u };
3375
- }
3376
- const o = [...n.data.values()].map((c, u) => a._parse(new q(n, c, n.path, u)));
3377
- return n.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
3378
- }
3379
- min(e, t) {
3380
- return new ie({
3381
- ...this._def,
3382
- minSize: { value: e, message: p.toString(t) }
3383
- });
3384
- }
3385
- max(e, t) {
3386
- return new ie({
3387
- ...this._def,
3388
- maxSize: { value: e, message: p.toString(t) }
3389
- });
3390
- }
3391
- size(e, t) {
3392
- return this.min(e, t).max(e, t);
3393
- }
3394
- nonempty(e) {
3395
- return this.min(1, e);
3396
- }
3397
- }
3398
- ie.create = (r, e) => new ie({
3399
- valueType: r,
3400
- minSize: null,
3401
- maxSize: null,
3402
- typeName: m.ZodSet,
3403
- ..._(e)
3404
- });
3405
- class ue extends w {
3406
- constructor() {
3407
- super(...arguments), this.validate = this.implement;
3408
- }
3409
- _parse(e) {
3410
- const { ctx: t } = this._processInputParams(e);
3411
- if (t.parsedType !== h.function)
3412
- return f(t, {
3413
- code: l.invalid_type,
3414
- expected: h.function,
3415
- received: t.parsedType
3416
- }), g;
3417
- function n(o, c) {
3418
- return nt({
3419
- data: o,
3420
- path: t.path,
3421
- errorMaps: [
3422
- t.common.contextualErrorMap,
3423
- t.schemaErrorMap,
3424
- rt(),
3425
- ge
3426
- ].filter((u) => !!u),
3427
- issueData: {
3428
- code: l.invalid_arguments,
3429
- argumentsError: c
3430
- }
3431
- });
3432
- }
3433
- function s(o, c) {
3434
- return nt({
3435
- data: o,
3436
- path: t.path,
3437
- errorMaps: [
3438
- t.common.contextualErrorMap,
3439
- t.schemaErrorMap,
3440
- rt(),
3441
- ge
3442
- ].filter((u) => !!u),
3443
- issueData: {
3444
- code: l.invalid_return_type,
3445
- returnTypeError: c
3446
- }
3447
- });
3448
- }
3449
- const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
3450
- if (this._def.returns instanceof ve) {
3451
- const o = this;
3452
- return P(async function(...c) {
3453
- const u = new Z([]), d = await o._def.args.parseAsync(c, a).catch((k) => {
3454
- throw u.addIssue(n(c, k)), u;
3455
- }), y = await Reflect.apply(i, this, d);
3456
- return await o._def.returns._def.type.parseAsync(y, a).catch((k) => {
3457
- throw u.addIssue(s(y, k)), u;
3458
- });
3459
- });
3460
- } else {
3461
- const o = this;
3462
- return P(function(...c) {
3463
- const u = o._def.args.safeParse(c, a);
3464
- if (!u.success)
3465
- throw new Z([n(c, u.error)]);
3466
- const d = Reflect.apply(i, this, u.data), y = o._def.returns.safeParse(d, a);
3467
- if (!y.success)
3468
- throw new Z([s(d, y.error)]);
3469
- return y.data;
3470
- });
3471
- }
3472
- }
3473
- parameters() {
3474
- return this._def.args;
3475
- }
3476
- returnType() {
3477
- return this._def.returns;
3478
- }
3479
- args(...e) {
3480
- return new ue({
3481
- ...this._def,
3482
- args: B.create(e).rest(se.create())
3483
- });
3484
- }
3485
- returns(e) {
3486
- return new ue({
3487
- ...this._def,
3488
- returns: e
3489
- });
3490
- }
3491
- implement(e) {
3492
- return this.parse(e);
3493
- }
3494
- strictImplement(e) {
3495
- return this.parse(e);
3496
- }
3497
- static create(e, t, n) {
3498
- return new ue({
3499
- args: e || B.create([]).rest(se.create()),
3500
- returns: t || se.create(),
3501
- typeName: m.ZodFunction,
3502
- ..._(n)
3503
- });
3504
- }
3505
- }
3506
- class je extends w {
3507
- get schema() {
3508
- return this._def.getter();
3509
- }
3510
- _parse(e) {
3511
- const { ctx: t } = this._processInputParams(e);
3512
- return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
3513
- }
3514
- }
3515
- je.create = (r, e) => new je({
3516
- getter: r,
3517
- typeName: m.ZodLazy,
3518
- ..._(e)
3519
- });
3520
- class Re extends w {
3521
- _parse(e) {
3522
- if (e.data !== this._def.value) {
3523
- const t = this._getOrReturnCtx(e);
3524
- return f(t, {
3525
- received: t.data,
3526
- code: l.invalid_literal,
3527
- expected: this._def.value
3528
- }), g;
3529
- }
3530
- return { status: "valid", value: e.data };
3531
- }
3532
- get value() {
3533
- return this._def.value;
3534
- }
3535
- }
3536
- Re.create = (r, e) => new Re({
3537
- value: r,
3538
- typeName: m.ZodLiteral,
3539
- ..._(e)
3540
- });
3541
- function ar(r, e) {
3542
- return new X({
3543
- values: r,
3544
- typeName: m.ZodEnum,
3545
- ..._(e)
3546
- });
3547
- }
3548
- class X extends w {
3549
- constructor() {
3550
- super(...arguments), we.set(this, void 0);
3551
- }
3552
- _parse(e) {
3553
- if (typeof e.data != "string") {
3554
- const t = this._getOrReturnCtx(e), n = this._def.values;
3555
- return f(t, {
3556
- expected: b.joinValues(n),
3557
- received: t.parsedType,
3558
- code: l.invalid_type
3559
- }), g;
3560
- }
3561
- if (st(this, we) || tr(this, we, new Set(this._def.values)), !st(this, we).has(e.data)) {
3562
- const t = this._getOrReturnCtx(e), n = this._def.values;
3563
- return f(t, {
3564
- received: t.data,
3565
- code: l.invalid_enum_value,
3566
- options: n
3567
- }), g;
3568
- }
3569
- return P(e.data);
3570
- }
3571
- get options() {
3572
- return this._def.values;
3573
- }
3574
- get enum() {
3575
- const e = {};
3576
- for (const t of this._def.values)
3577
- e[t] = t;
3578
- return e;
3579
- }
3580
- get Values() {
3581
- const e = {};
3582
- for (const t of this._def.values)
3583
- e[t] = t;
3584
- return e;
3585
- }
3586
- get Enum() {
3587
- const e = {};
3588
- for (const t of this._def.values)
3589
- e[t] = t;
3590
- return e;
3591
- }
3592
- extract(e, t = this._def) {
3593
- return X.create(e, {
3594
- ...this._def,
3595
- ...t
3596
- });
3597
- }
3598
- exclude(e, t = this._def) {
3599
- return X.create(this.options.filter((n) => !e.includes(n)), {
3600
- ...this._def,
3601
- ...t
3602
- });
3603
- }
3604
- }
3605
- we = /* @__PURE__ */ new WeakMap();
3606
- X.create = ar;
3607
- class Pe extends w {
3608
- constructor() {
3609
- super(...arguments), ke.set(this, void 0);
3610
- }
3611
- _parse(e) {
3612
- const t = b.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
3613
- if (n.parsedType !== h.string && n.parsedType !== h.number) {
3614
- const s = b.objectValues(t);
3615
- return f(n, {
3616
- expected: b.joinValues(s),
3617
- received: n.parsedType,
3618
- code: l.invalid_type
3619
- }), g;
3620
- }
3621
- if (st(this, ke) || tr(this, ke, new Set(b.getValidEnumValues(this._def.values))), !st(this, ke).has(e.data)) {
3622
- const s = b.objectValues(t);
3623
- return f(n, {
3624
- received: n.data,
3625
- code: l.invalid_enum_value,
3626
- options: s
3627
- }), g;
3628
- }
3629
- return P(e.data);
3630
- }
3631
- get enum() {
3632
- return this._def.values;
3633
- }
3634
- }
3635
- ke = /* @__PURE__ */ new WeakMap();
3636
- Pe.create = (r, e) => new Pe({
3637
- values: r,
3638
- typeName: m.ZodNativeEnum,
3639
- ..._(e)
3640
- });
3641
- class ve extends w {
3642
- unwrap() {
3643
- return this._def.type;
3644
- }
3645
- _parse(e) {
3646
- const { ctx: t } = this._processInputParams(e);
3647
- if (t.parsedType !== h.promise && t.common.async === !1)
3648
- return f(t, {
3649
- code: l.invalid_type,
3650
- expected: h.promise,
3651
- received: t.parsedType
3652
- }), g;
3653
- const n = t.parsedType === h.promise ? t.data : Promise.resolve(t.data);
3654
- return P(n.then((s) => this._def.type.parseAsync(s, {
3655
- path: t.path,
3656
- errorMap: t.common.contextualErrorMap
3657
- })));
3658
- }
3659
- }
3660
- ve.create = (r, e) => new ve({
3661
- type: r,
3662
- typeName: m.ZodPromise,
3663
- ..._(e)
3664
- });
3665
- class z extends w {
3666
- innerType() {
3667
- return this._def.schema;
3668
- }
3669
- sourceType() {
3670
- return this._def.schema._def.typeName === m.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3671
- }
3672
- _parse(e) {
3673
- const { status: t, ctx: n } = this._processInputParams(e), s = this._def.effect || null, a = {
3674
- addIssue: (i) => {
3675
- f(n, i), i.fatal ? t.abort() : t.dirty();
3676
- },
3677
- get path() {
3678
- return n.path;
3679
- }
3680
- };
3681
- if (a.addIssue = a.addIssue.bind(a), s.type === "preprocess") {
3682
- const i = s.transform(n.data, a);
3683
- if (n.common.async)
3684
- return Promise.resolve(i).then(async (o) => {
3685
- if (t.value === "aborted")
3686
- return g;
3687
- const c = await this._def.schema._parseAsync({
3688
- data: o,
3689
- path: n.path,
3690
- parent: n
3691
- });
3692
- return c.status === "aborted" ? g : c.status === "dirty" || t.value === "dirty" ? ce(c.value) : c;
3693
- });
3694
- {
3695
- if (t.value === "aborted")
3696
- return g;
3697
- const o = this._def.schema._parseSync({
3698
- data: i,
3699
- path: n.path,
3700
- parent: n
3701
- });
3702
- return o.status === "aborted" ? g : o.status === "dirty" || t.value === "dirty" ? ce(o.value) : o;
3703
- }
3704
- }
3705
- if (s.type === "refinement") {
3706
- const i = (o) => {
3707
- const c = s.refinement(o, a);
3708
- if (n.common.async)
3709
- return Promise.resolve(c);
3710
- if (c instanceof Promise)
3711
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3712
- return o;
3713
- };
3714
- if (n.common.async === !1) {
3715
- const o = this._def.schema._parseSync({
3716
- data: n.data,
3717
- path: n.path,
3718
- parent: n
3719
- });
3720
- return o.status === "aborted" ? g : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
3721
- } else
3722
- return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => o.status === "aborted" ? g : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
3723
- }
3724
- if (s.type === "transform")
3725
- if (n.common.async === !1) {
3726
- const i = this._def.schema._parseSync({
3727
- data: n.data,
3728
- path: n.path,
3729
- parent: n
3730
- });
3731
- if (!Se(i))
3732
- return i;
3733
- const o = s.transform(i.value, a);
3734
- if (o instanceof Promise)
3735
- throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
3736
- return { status: t.value, value: o };
3737
- } else
3738
- return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => Se(i) ? Promise.resolve(s.transform(i.value, a)).then((o) => ({ status: t.value, value: o })) : i);
3739
- b.assertNever(s);
3740
- }
3741
- }
3742
- z.create = (r, e, t) => new z({
3743
- schema: r,
3744
- typeName: m.ZodEffects,
3745
- effect: e,
3746
- ..._(t)
3747
- });
3748
- z.createWithPreprocess = (r, e, t) => new z({
3749
- schema: e,
3750
- effect: { type: "preprocess", transform: r },
3751
- typeName: m.ZodEffects,
3752
- ..._(t)
3753
- });
3754
- class V extends w {
3755
- _parse(e) {
3756
- return this._getType(e) === h.undefined ? P(void 0) : this._def.innerType._parse(e);
3757
- }
3758
- unwrap() {
3759
- return this._def.innerType;
3760
- }
3761
- }
3762
- V.create = (r, e) => new V({
3763
- innerType: r,
3764
- typeName: m.ZodOptional,
3765
- ..._(e)
3766
- });
3767
- class J extends w {
3768
- _parse(e) {
3769
- return this._getType(e) === h.null ? P(null) : this._def.innerType._parse(e);
3770
- }
3771
- unwrap() {
3772
- return this._def.innerType;
3773
- }
3774
- }
3775
- J.create = (r, e) => new J({
3776
- innerType: r,
3777
- typeName: m.ZodNullable,
3778
- ..._(e)
3779
- });
3780
- class Ze extends w {
3781
- _parse(e) {
3782
- const { ctx: t } = this._processInputParams(e);
3783
- let n = t.data;
3784
- return t.parsedType === h.undefined && (n = this._def.defaultValue()), this._def.innerType._parse({
3785
- data: n,
3786
- path: t.path,
3787
- parent: t
3788
- });
3789
- }
3790
- removeDefault() {
3791
- return this._def.innerType;
3792
- }
3793
- }
3794
- Ze.create = (r, e) => new Ze({
3795
- innerType: r,
3796
- typeName: m.ZodDefault,
3797
- defaultValue: typeof e.default == "function" ? e.default : () => e.default,
3798
- ..._(e)
3799
- });
3800
- class Me extends w {
3801
- _parse(e) {
3802
- const { ctx: t } = this._processInputParams(e), n = {
3803
- ...t,
3804
- common: {
3805
- ...t.common,
3806
- issues: []
3807
- }
3808
- }, s = this._def.innerType._parse({
3809
- data: n.data,
3810
- path: n.path,
3811
- parent: {
3812
- ...n
3813
- }
3814
- });
3815
- return Te(s) ? s.then((a) => ({
3816
- status: "valid",
3817
- value: a.status === "valid" ? a.value : this._def.catchValue({
3818
- get error() {
3819
- return new Z(n.common.issues);
3820
- },
3821
- input: n.data
3822
- })
3823
- })) : {
3824
- status: "valid",
3825
- value: s.status === "valid" ? s.value : this._def.catchValue({
3826
- get error() {
3827
- return new Z(n.common.issues);
3828
- },
3829
- input: n.data
3830
- })
3831
- };
3832
- }
3833
- removeCatch() {
3834
- return this._def.innerType;
3835
- }
3836
- }
3837
- Me.create = (r, e) => new Me({
3838
- innerType: r,
3839
- typeName: m.ZodCatch,
3840
- catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
3841
- ..._(e)
3842
- });
3843
- class ct extends w {
3844
- _parse(e) {
3845
- if (this._getType(e) !== h.nan) {
3846
- const n = this._getOrReturnCtx(e);
3847
- return f(n, {
3848
- code: l.invalid_type,
3849
- expected: h.nan,
3850
- received: n.parsedType
3851
- }), g;
3852
- }
3853
- return { status: "valid", value: e.data };
3854
- }
3855
- }
3856
- ct.create = (r) => new ct({
3857
- typeName: m.ZodNaN,
3858
- ..._(r)
3859
- });
3860
- const Kn = Symbol("zod_brand");
3861
- class It extends w {
3862
- _parse(e) {
3863
- const { ctx: t } = this._processInputParams(e), n = t.data;
3864
- return this._def.type._parse({
3865
- data: n,
3866
- path: t.path,
3867
- parent: t
3868
- });
3869
- }
3870
- unwrap() {
3871
- return this._def.type;
3872
- }
3873
- }
3874
- class Fe extends w {
3875
- _parse(e) {
3876
- const { status: t, ctx: n } = this._processInputParams(e);
3877
- if (n.common.async)
3878
- return (async () => {
3879
- const a = await this._def.in._parseAsync({
3880
- data: n.data,
3881
- path: n.path,
3882
- parent: n
3883
- });
3884
- return a.status === "aborted" ? g : a.status === "dirty" ? (t.dirty(), ce(a.value)) : this._def.out._parseAsync({
3885
- data: a.value,
3886
- path: n.path,
3887
- parent: n
3888
- });
3889
- })();
3890
- {
3891
- const s = this._def.in._parseSync({
3892
- data: n.data,
3893
- path: n.path,
3894
- parent: n
3895
- });
3896
- return s.status === "aborted" ? g : s.status === "dirty" ? (t.dirty(), {
3897
- status: "dirty",
3898
- value: s.value
3899
- }) : this._def.out._parseSync({
3900
- data: s.value,
3901
- path: n.path,
3902
- parent: n
3903
- });
3904
- }
3905
- }
3906
- static create(e, t) {
3907
- return new Fe({
3908
- in: e,
3909
- out: t,
3910
- typeName: m.ZodPipeline
3911
- });
3912
- }
3913
- }
3914
- class $e extends w {
3915
- _parse(e) {
3916
- const t = this._def.innerType._parse(e), n = (s) => (Se(s) && (s.value = Object.freeze(s.value)), s);
3917
- return Te(t) ? t.then((s) => n(s)) : n(t);
3918
- }
3919
- unwrap() {
3920
- return this._def.innerType;
3921
- }
3922
- }
3923
- $e.create = (r, e) => new $e({
3924
- innerType: r,
3925
- typeName: m.ZodReadonly,
3926
- ..._(e)
3927
- });
3928
- function ir(r, e = {}, t) {
3929
- return r ? ye.create().superRefine((n, s) => {
3930
- var a, i;
3931
- if (!r(n)) {
3932
- const o = typeof e == "function" ? e(n) : typeof e == "string" ? { message: e } : e, c = (i = (a = o.fatal) !== null && a !== void 0 ? a : t) !== null && i !== void 0 ? i : !0, u = typeof o == "string" ? { message: o } : o;
3933
- s.addIssue({ code: "custom", ...u, fatal: c });
3934
- }
3935
- }) : ye.create();
3936
- }
3937
- const Yn = {
3938
- object: T.lazycreate
3939
- };
3940
- var m;
3941
- (function(r) {
3942
- r.ZodString = "ZodString", r.ZodNumber = "ZodNumber", r.ZodNaN = "ZodNaN", r.ZodBigInt = "ZodBigInt", r.ZodBoolean = "ZodBoolean", r.ZodDate = "ZodDate", r.ZodSymbol = "ZodSymbol", r.ZodUndefined = "ZodUndefined", r.ZodNull = "ZodNull", r.ZodAny = "ZodAny", r.ZodUnknown = "ZodUnknown", r.ZodNever = "ZodNever", r.ZodVoid = "ZodVoid", r.ZodArray = "ZodArray", r.ZodObject = "ZodObject", r.ZodUnion = "ZodUnion", r.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", r.ZodIntersection = "ZodIntersection", r.ZodTuple = "ZodTuple", r.ZodRecord = "ZodRecord", r.ZodMap = "ZodMap", r.ZodSet = "ZodSet", r.ZodFunction = "ZodFunction", r.ZodLazy = "ZodLazy", r.ZodLiteral = "ZodLiteral", r.ZodEnum = "ZodEnum", r.ZodEffects = "ZodEffects", r.ZodNativeEnum = "ZodNativeEnum", r.ZodOptional = "ZodOptional", r.ZodNullable = "ZodNullable", r.ZodDefault = "ZodDefault", r.ZodCatch = "ZodCatch", r.ZodPromise = "ZodPromise", r.ZodBranded = "ZodBranded", r.ZodPipeline = "ZodPipeline", r.ZodReadonly = "ZodReadonly";
3943
- })(m || (m = {}));
3944
- const Xn = (r, e = {
3945
- message: `Input not instance of ${r.name}`
3946
- }) => ir((t) => t instanceof r, e), or = D.create, cr = K.create, Jn = ct.create, Qn = Y.create, ur = Ce.create, es = ae.create, ts = at.create, rs = Oe.create, ns = Ee.create, ss = ye.create, as = se.create, is = F.create, os = it.create, cs = L.create, us = T.create, ls = T.strictCreate, ds = Ae.create, fs = ft.create, hs = Ie.create, ps = B.create, ms = Ne.create, gs = ot.create, ys = ie.create, vs = ue.create, _s = je.create, ws = Re.create, ks = X.create, bs = Pe.create, xs = ve.create, Vt = z.create, Ss = V.create, Ts = J.create, Cs = z.createWithPreprocess, Os = Fe.create, Es = () => or().optional(), As = () => cr().optional(), Is = () => ur().optional(), Ns = {
3947
- string: (r) => D.create({ ...r, coerce: !0 }),
3948
- number: (r) => K.create({ ...r, coerce: !0 }),
3949
- boolean: (r) => Ce.create({
3950
- ...r,
3951
- coerce: !0
3952
- }),
3953
- bigint: (r) => Y.create({ ...r, coerce: !0 }),
3954
- date: (r) => ae.create({ ...r, coerce: !0 })
3955
- }, js = g;
3956
- var re = /* @__PURE__ */ Object.freeze({
3957
- __proto__: null,
3958
- defaultErrorMap: ge,
3959
- setErrorMap: jn,
3960
- getErrorMap: rt,
3961
- makeIssue: nt,
3962
- EMPTY_PATH: Rn,
3963
- addIssueToContext: f,
3964
- ParseStatus: j,
3965
- INVALID: g,
3966
- DIRTY: ce,
3967
- OK: P,
3968
- isAborted: bt,
3969
- isDirty: xt,
3970
- isValid: Se,
3971
- isAsync: Te,
3972
- get util() {
3973
- return b;
3974
- },
3975
- get objectUtil() {
3976
- return kt;
3977
- },
3978
- ZodParsedType: h,
3979
- getParsedType: H,
3980
- ZodType: w,
3981
- datetimeRegex: sr,
3982
- ZodString: D,
3983
- ZodNumber: K,
3984
- ZodBigInt: Y,
3985
- ZodBoolean: Ce,
3986
- ZodDate: ae,
3987
- ZodSymbol: at,
3988
- ZodUndefined: Oe,
3989
- ZodNull: Ee,
3990
- ZodAny: ye,
3991
- ZodUnknown: se,
3992
- ZodNever: F,
3993
- ZodVoid: it,
3994
- ZodArray: L,
3995
- ZodObject: T,
3996
- ZodUnion: Ae,
3997
- ZodDiscriminatedUnion: ft,
3998
- ZodIntersection: Ie,
3999
- ZodTuple: B,
4000
- ZodRecord: Ne,
4001
- ZodMap: ot,
4002
- ZodSet: ie,
4003
- ZodFunction: ue,
4004
- ZodLazy: je,
4005
- ZodLiteral: Re,
4006
- ZodEnum: X,
4007
- ZodNativeEnum: Pe,
4008
- ZodPromise: ve,
4009
- ZodEffects: z,
4010
- ZodTransformer: z,
4011
- ZodOptional: V,
4012
- ZodNullable: J,
4013
- ZodDefault: Ze,
4014
- ZodCatch: Me,
4015
- ZodNaN: ct,
4016
- BRAND: Kn,
4017
- ZodBranded: It,
4018
- ZodPipeline: Fe,
4019
- ZodReadonly: $e,
4020
- custom: ir,
4021
- Schema: w,
4022
- ZodSchema: w,
4023
- late: Yn,
4024
- get ZodFirstPartyTypeKind() {
4025
- return m;
4026
- },
4027
- coerce: Ns,
4028
- any: ss,
4029
- array: cs,
4030
- bigint: Qn,
4031
- boolean: ur,
4032
- date: es,
4033
- discriminatedUnion: fs,
4034
- effect: Vt,
4035
- enum: ks,
4036
- function: vs,
4037
- instanceof: Xn,
4038
- intersection: hs,
4039
- lazy: _s,
4040
- literal: ws,
4041
- map: gs,
4042
- nan: Jn,
4043
- nativeEnum: bs,
4044
- never: is,
4045
- null: ns,
4046
- nullable: Ts,
4047
- number: cr,
4048
- object: us,
4049
- oboolean: Is,
4050
- onumber: As,
4051
- optional: Ss,
4052
- ostring: Es,
4053
- pipeline: Os,
4054
- preprocess: Cs,
4055
- promise: xs,
4056
- record: ms,
4057
- set: ys,
4058
- strictObject: ls,
4059
- string: or,
4060
- symbol: ts,
4061
- transformer: Vt,
4062
- tuple: ps,
4063
- undefined: rs,
4064
- union: ds,
4065
- unknown: as,
4066
- void: os,
4067
- NEVER: js,
4068
- ZodIssueCode: l,
4069
- quotelessJson: Nn,
4070
- ZodError: Z
4071
- });
4072
- const Rs = (r) => {
4073
- const e = re.object({
4074
- offeringId: re.coerce.string(),
4075
- quantity: re.coerce.number(),
4076
- deliveryMethod: re.string(),
4077
- label: re.string()
4078
- }).partial({
4079
- label: !0
4080
- }), t = [];
4081
- return { data: r.map((s) => {
4082
- try {
4083
- return e.parse(s, { stripUnknown: !0 });
4084
- } catch {
4085
- return t.push(s), s;
4086
- }
4087
- }), errors: t };
4088
- }, Ps = (r, e) => {
4089
- const t = re.enum(["yesno", "dob"]), n = re.coerce.date();
4090
- let s = null;
4091
- try {
4092
- s = t.parse(r.toLowerCase());
4093
- } catch {
4094
- return {};
4095
- }
4096
- let a = !1;
4097
- const { success: i, data: o } = n.safeParse(e);
4098
- switch (s) {
4099
- case "yesno":
4100
- a = !!e;
4101
- break;
4102
- case "dob":
4103
- if (i) {
4104
- const c = /* @__PURE__ */ new Date(), u = new Date(o.getFullYear() + 21, o.getMonth(), o.getDate());
4105
- a = u ? u <= c : !1;
4106
- }
4107
- break;
4108
- }
4109
- return { ageGateType: s, ageGatePassed: a, ageGateDOB: o || null };
4110
- };
4111
- class Zs extends Error {
4112
- constructor(e) {
4113
- super("Invalid schema"), this.name = "SchemaValidationError", this.errors = e;
4114
- }
4115
- }
4116
- const Ms = (r, e) => {
4117
- const { data: t, errors: n } = r(e);
4118
- if (Qt(n))
4119
- return t;
4120
- throw new Zs(n);
4121
- }, Tt = (r) => {
4122
- const e = {};
4123
- for (const t in r)
4124
- r[t] !== null && r[t] !== void 0 && (e[t] = r[t]);
4125
- return e;
4126
- }, $s = {
4127
- setAgeGate: async (r, e) => {
4128
- const { ageGateType: t, ageGateValue: n } = e;
4129
- return Ps(t, n);
4130
- },
4131
- fetchPaymentToken: async (r, e) => {
4132
- const { providerName: t } = e, n = `/m/v2/payments/gateway_client_token/${t}`, s = await r.thirstieService("GET", n), a = s && s.ok ? s.data : null;
4133
- return a ? { paymentProvider: { providerName: t, token: a.token } } : {};
4134
- },
4135
- addPaymentMethod: async (r, e) => {
4136
- const { providerName: t } = r.getItem("paymentProvider"), n = Tt({
4137
- street_1: e.Street1,
4138
- street_2: e.Street2,
4139
- city: e.City,
4140
- state: e.StateCode,
4141
- zipcode: e.ZipCode,
4142
- country: e.Country
4143
- }), s = Tt({
4144
- payment_method_token: e.paymentMethodToken,
4145
- payment_type: t,
4146
- cardholder_name: e.cardholderName,
4147
- is_default: !0,
4148
- bt_device_data: "{}"
4149
- // TODO: api should not require
4150
- });
4151
- n.zipcode && (s.billing_address = n);
4152
- const i = await r.thirstieService("POST", "/m/v2/payment_methods", { data: s }), o = i && i.ok ? i.data : null;
4153
- return o ? { userWallet: { default: o } } : {};
4154
- },
4155
- createUser: async (r, e) => {
4156
- const { email: t, password: n, birthday: s, prefix: a, firstName: i, lastName: o, phoneNumber: c } = e, u = { email: t, password: n, birthday: s, prefix: a, firstName: i, lastName: o, phoneNumber: c }, d = await r.createUser(u), y = d && d.ok ? d.data : null;
4157
- if (y) {
4158
- const x = Ye(y), k = gt(y);
4159
- return { userProfile: x, session: k };
4160
- } else
4161
- return {};
4162
- },
4163
- createGuestUser: async (r, e) => {
4164
- const { email: t, birthday: n, prefix: s, firstName: a, lastName: i, phoneNumber: o, guestCheck: c } = e, u = { email: t, guest: !0, birthday: n, prefix: s, firstName: a, lastName: i, phoneNumber: o, guestCheck: c }, d = await r.createUser(u), y = d && d.ok ? d.data : null;
4165
- if (y) {
4166
- const x = Ye(y), k = gt(y);
4167
- return { userProfile: x, session: k };
4168
- } else
4169
- return {};
4170
- },
4171
- loginUser: async (r, e) => {
4172
- const { email: t, password: n } = e, s = { email: t, password: n }, a = await r.authenticateUser(s), i = a && a.ok ? a.data : null;
4173
- if (i) {
4174
- const o = Ye(i), c = gt(i);
4175
- return { userProfile: o, session: c };
4176
- } else
4177
- return {};
4178
- },
4179
- updatePassword: async (r, e) => {
4180
- if (!(void 0).isLoggedInUser)
4181
- return (void 0).onError({ code: 401, message: "must be logged in" }), {};
4182
- },
4183
- updateUserProfile: async (r, e) => {
4184
- if (!(void 0).isRegisteredUser)
4185
- return (void 0).onError({ code: 401, message: "must be logged in" }), {};
4186
- },
4187
- fetchUser: async (r, e) => {
4188
- const { userUUID: t } = e, n = `/a/v2/users/${t}`, s = await r.thirstieService("GET", n), a = s && s.ok ? s.data : null;
4189
- return a ? { userProfile: Ye({ user: a }) } : {};
4190
- },
4191
- requestPasswordReset: async (r, e) => {
4192
- throw new Error("Not implemented");
4193
- },
4194
- fetchPaymentMethods: async (r, e) => {
4195
- throw new Error("Not implemented");
4196
- },
4197
- fetchAddressBook: async (r, e) => {
4198
- throw new Error("Not implemented");
4199
- },
4200
- updateAddressBook: async (r, e) => {
4201
- throw new Error("Not implemented");
4202
- },
4203
- fetchFavorites: async (r, e) => {
4204
- throw new Error("Not implemented");
4205
- },
4206
- updateFavorites: async (r, e) => {
4207
- throw new Error("Not implemented");
4208
- },
4209
- fetchCartHistory: async (r, e) => {
4210
- throw new Error("Not implemented");
4211
- },
4212
- logoutSession: async (r, e) => {
4213
- throw new Error("Not implemented");
4214
- }
4215
- }, Xe = (r) => {
4216
- const { cart: e } = r;
4217
- return e;
4218
- }, Ds = {
4219
- fetchCurrentCart: async (r) => {
4220
- const t = await r.thirstieService("GET", "/m/v2/carts"), n = t && t.ok ? t.data : null;
4221
- return n ? { cart: Xe(n) } : {};
4222
- },
4223
- addToCart: async (r, e) => {
4224
- const { lineItemList: t } = e, n = r.getItem("cartRecipient"), s = Ms(Rs, t), a = {
4225
- recipient: n,
4226
- items: s.map((u) => {
4227
- const { offeringId: d, quantity: y, deliveryMethod: x } = u;
4228
- return { offering: { id: d }, quantity: y, delivery: { method: x } };
4229
- })
4230
- }, o = await r.thirstieService("POST", "/m/v2/carts", { data: a }), c = o && o.ok ? o.data : null;
4231
- return c ? { cart: Xe(c) } : {};
4232
- },
4233
- validateCart: async (r) => {
4234
- const e = r.getItem("cartRecipient"), t = r.getItem("cartPromoCode"), n = r.getItem("cartTipAmount"), s = {
4235
- is_tax_required: !0,
4236
- recipient: e,
4237
- promo_code: t,
4238
- tip: n,
4239
- items: [],
4240
- aux_data: {}
4241
- // no need to support, so make sure aux_data is empty
4242
- }, i = await r.thirstieService("POST", "/m/v2/carts", { data: s }), o = i && i.ok ? i.data : null;
4243
- return o ? { cart: Xe(o) } : {};
4244
- },
4245
- checkoutCart: async (r, e) => {
4246
- const t = r.getItem("cartId"), { paymentMethodFingerprint: n, paymentType: s } = e, a = {
4247
- payment_method_fingerprint: n,
4248
- payment_type: s,
4249
- psp_device_data: "{}"
4250
- }, i = `/m/v2/carts/${t}/checkout/async`, o = await r.thirstieService("POST", i, { data: a }), c = o && o.ok ? o.data : null;
4251
- return c ? { cart: Xe(c) } : {};
4252
- },
4253
- checkoutStatus: async (r, e) => {
4254
- const { cartId: t } = r.getItem("cartId");
4255
- let n = null;
4256
- const s = `/m/v2/carts/${t}/checkout/status`, a = await r.thirstieService("GET", s), i = a && a.ok ? a.data : null;
4257
- return i && (n = i.status), { checkoutStatus: n };
4258
- }
4259
- };
4260
- var Ls = {
4261
- ...$s,
4262
- ...On,
4263
- ...In,
4264
- ...Ds
4265
- };
4266
- const zs = {
4267
- // TODO: existing cart properties
4268
- cartRecipient: (r) => {
4269
- const { street1: e, street2: t, city: n, zipcode: s, state: a, country: i, latitude: o, longitude: c } = r.location, { firstName: u, lastName: d, email: y, phoneNumber: x } = r.location, k = r.userProfile, I = {
4270
- street_1: e || " ",
4271
- street_2: t,
4272
- first_name: u || k && k.firstName,
4273
- last_name: d || k && k.lastName,
4274
- phone_number: x || k && k.phoneNumber,
4275
- email: y || k && k.email,
4276
- city: n,
4277
- zipcode: s,
4278
- state: a,
4279
- country: i,
4280
- latitude: o,
4281
- longitude: c
4282
- };
4283
- return Tt(I);
4284
- },
4285
- cartPromoCode: (r) => {
4286
- const { promoCode: e } = r.cart;
4287
- return e;
4288
- },
4289
- cartTipAmount: (r) => {
4290
- const { tipAmount: e } = r.cart;
4291
- return e;
4292
- },
4293
- cartId: (r) => {
4294
- const { id: e } = r.cart;
4295
- return e;
4296
- }
4297
- }, Us = {
4298
- autocompletePredictions: (r) => {
4299
- const { autocompletePredictions: e } = r.addressSuggestions;
4300
- return e;
4301
- },
4302
- locationComponents: (r) => {
4303
- const {
4304
- latitude: e,
4305
- longitude: t,
4306
- zipcode: n,
4307
- state: s,
4308
- city: a,
4309
- country: i,
4310
- street_1: o,
4311
- street_2: c,
4312
- street_3: u
4313
- } = r.location;
4314
- return ne(Boolean, {
4315
- latitude: e,
4316
- longitude: t,
4317
- zipcode: n,
4318
- state: s,
4319
- city: a,
4320
- country: i,
4321
- street_1: o,
4322
- street_2: c,
4323
- street_3: u
4324
- });
4325
- },
4326
- formattedAddress: (r) => {
4327
- const {
4328
- zipcode: e,
4329
- state: t,
4330
- city: n,
4331
- country: s,
4332
- street_1: a
4333
- } = r.location;
4334
- let i = "";
4335
- return (a || n || t || s || e) && (i = `${a ? a + ", " : ""}${n ? n + ", " : ""}${t} ${e}, ${s || "US"}`), i;
4336
- }
4337
- };
4338
- var Vs = {
4339
- ...zs,
4340
- ...Us
4341
- };
4342
- function qs(r = {}, e = null) {
4343
- function t(s, a) {
4344
- const i = {
4345
- changeDetail: s,
4346
- newState: a
4347
- };
4348
- return e ? e(i) : !1;
4349
- }
4350
- function n(s) {
4351
- return {
4352
- get(a, i) {
4353
- if (i === "_isProxy")
4354
- return !0;
4355
- const o = Object.prototype.toString.call(a[i]).slice(8, -1).toLowerCase();
4356
- return ["object", "array"].includes(o) && !a[i]._isProxy && (a[i] = new Proxy(a[i], n())), a[i];
4357
- },
4358
- set(a, i, o) {
4359
- if (!Object.hasOwn(a, i))
4360
- throw new Error(`Access denied: ${i} ${o}`);
4361
- if (a[i] !== o) {
4362
- const c = {
4363
- prop: i,
4364
- oldValue: a[i],
4365
- newValue: o
4366
- };
4367
- a[i] = o, t(c, a);
4368
- }
4369
- return !0;
4370
- },
4371
- deleteProperty(a, i) {
4372
- return !1;
4373
- },
4374
- ownKeys(a) {
4375
- return Reflect.ownKeys(a);
4376
- }
4377
- };
4378
- }
4379
- return new Proxy(r, n());
4380
- }
4381
- var Ue, Ve, A, qe, he, U, Be, W, Ge, pe;
4382
- class Bs {
4383
- constructor(e) {
4384
- E(this, Ue, void 0);
4385
- E(this, Ve, void 0);
4386
- E(this, A, void 0);
4387
- E(this, qe, void 0);
4388
- E(this, he, void 0);
4389
- E(this, U, void 0);
4390
- E(this, Be, void 0);
4391
- E(this, W, void 0);
4392
- E(this, Ge, void 0);
4393
- E(this, pe, void 0);
4394
- const { apiKey: t, mapsKey: n, cfgEmitter: s } = e;
4395
- N(this, Ue, t), N(this, Ve, n), N(this, qe, Ls), N(this, he, Vs), N(this, W, {}), N(this, Ge, (o, c) => {
4396
- v(this, W)[o] || (v(this, W)[o] = []), v(this, W)[o].push(c);
4397
- }), N(this, pe, (o, c) => {
4398
- const { oldValue: u, newValue: d } = c;
4399
- v(this, W)[o] && v(this, W)[o].forEach((y) => {
4400
- y(u, d);
4401
- });
4402
- });
4403
- const a = s || ((o) => {
4404
- }), i = (o) => {
4405
- const { changeDetail: c } = o, { prop: u, oldValue: d, newValue: y } = c;
4406
- v(this, pe).call(this, u, { oldValue: d, newValue: y }), a(o);
4407
- };
4408
- this.onError = (o) => {
4409
- const { code: c, message: u, response: d, data: y } = o;
4410
- console.error("ThirstieClient Error", { code: c, message: u }), console.error(d, y), v(this, pe).call(this, "thirstieError", {}, { code: c, message: u });
4411
- }, N(this, A, qs({
4412
- session: {},
4413
- paymentProvider: {},
4414
- userProfile: {},
4415
- userWallet: {},
4416
- userOrderHistory: {},
4417
- userAddressBook: {},
4418
- userFavorites: {},
4419
- location: {},
4420
- // selected delivery location (cart recipient)
4421
- catalogProductLines: [],
4422
- // currently active collection (PCP/PLP content)
4423
- productLineOfferings: [],
4424
- // currently active product line offerings (PDP content)
4425
- cart: {},
4426
- addressSuggestions: {},
4427
- checkoutStatus: null,
4428
- ageGatePassed: !1,
4429
- ageGateType: null,
4430
- ageGateDOB: null,
4431
- isInCoverage: null,
4432
- isGift: !1,
4433
- locationHash: null,
4434
- isFetching: !1,
4435
- errorMessage: null,
4436
- warningMessage: null,
4437
- error: null
4438
- }, i)), N(this, U, new br(v(this, Ue))), N(this, Be, new Cn(v(this, Ve)));
4439
- }
4440
- async initSession() {
4441
- const e = await v(this, U).fetchSession();
4442
- return this.appState = {
4443
- session: v(this, U).sessionState
4444
- }, e;
4445
- }
4446
- async createUser(e) {
4447
- return this.hasSessionToken || await this.initSession(), await v(this, U).createUser(e, this.onError);
4448
- }
4449
- async authenticateUser(e) {
4450
- return this.hasSessionToken || await this.initSession(), await v(this, U).loginAnonymousSession(e);
4451
- }
4452
- /**
4453
- * GETTERS
4454
- */
4455
- get sessionToken() {
4456
- return v(this, U).sessionToken;
4457
- }
4458
- get hasSessionToken() {
4459
- return v(this, A).session && !!v(this, A).session.sessionToken;
4460
- }
4461
- get isLoggedInUser() {
4462
- return !!(v(this, A).session.sessionRef && v(this, A).session.userRef);
4463
- }
4464
- get geoService() {
4465
- return v(this, Be);
4466
- }
4467
- get appState() {
4468
- return v(this, A);
4469
- }
4470
- /**
4471
- * Get the value of a state property or a defined getter
4472
- * @param {string} propertyName name of appState property or getter function
4473
- * @returns value
4474
- */
4475
- getItem(e) {
4476
- return v(this, A)[e] === void 0 && v(this, he)[e] !== void 0 ? v(this, he)[e](v(this, A)) : v(this, A)[e];
4477
- }
4478
- /**
4479
- * Setter for state
4480
- */
4481
- set appState(e) {
4482
- try {
4483
- return Object.assign(v(this, A), e);
4484
- } catch (t) {
4485
- return console.error(t), v(this, A);
4486
- }
4487
- }
4488
- /**
4489
- * Subscribe to a property of ThirstieClient appState
4490
- * @param {string} prop Name of property to watch
4491
- * @param {callback} callback Subscription function, accept oldValue, newValue
4492
- */
4493
- watch(e, t) {
4494
- v(this, Ge).call(this, e, t);
4495
- }
4496
- /**
4497
- * Thirstie API response
4498
- * @param {boolean} ok http response status is 20x
4499
- * @param {object} data response payload
4500
- * @param {number} status HTTP status code
4501
- * @param {string} statusText HTTP status message
4502
- /**
4503
- * Invoke Thirstie API, to be used by dispatch actions
4504
- * @function thirstieService
4505
- * @param {string} method - HTTP method to invoke 'GET', 'POST', 'PUT', 'DELETE'
4506
- * @param {string} url - API url, e.g. '/m/v2/carts'
4507
- * @param {Object} options - Additional parameters to pass to fetch
4508
- * @param {Object} options.data - Payload to send with request (POST, PUT, PATCH only)
4509
- * @param {Object} options.params - Object to be converted to query string
4510
- * @returns response object from Thirstie API
4511
- */
4512
- async thirstieService(e, t, n = {}) {
4513
- this.hasSessionToken || await this.initSession(), this.appState = { isFetching: !0 };
4514
- try {
4515
- return await v(this, U).apiCaller(e, t, n, this.onError);
4516
- } catch (s) {
4517
- console.error(`thirstieService error: ${s}`);
4518
- } finally {
4519
- this.appState = { isFetching: !1 };
4520
- }
4521
- }
4522
- /**
4523
- * successCallback
4524
- * @param {object} appState ThirstieClient state object
4525
- */
4526
- /**
4527
- * customErrorCallback
4528
- * @param {string} action The name of action method
4529
- * @param {object} error Error message
4530
- */
4531
- /**
4532
- * Dispatch an action implementing specific business logic and update ThirstieClient state
4533
- * @param {string} action Name of action method, must be defined in this.#actions
4534
- * @param {object} [payload] Data to be passed to the action method
4535
- * @param {successCallback} [successCallback]
4536
- * @param {customErrorCallback} customErrorCallback
4537
- * When an error occurs:
4538
- * 1. make sure state is still valid (dispatched action responsibility)
4539
- * 2. set status so end user knows something went wrong
4540
- * 3. provide error code/message
4541
- * 4. provide tracking / troubleshooting information
4542
- * 5. log / send telemetry
4543
- * @returns Object that was used to update ThirstieClient state
4544
- */
4545
- async dispatch(e, t = null, n = null, s = null) {
4546
- const a = v(this, qe)[e];
4547
- let i = {};
4548
- if (a)
4549
- try {
4550
- this.appState = { isFetching: !0, errorMessage: null, warningMessage: null }, i = await a(this, t), n && n(this.appState);
4551
- } catch (o) {
4552
- this.handleDispatchError(e, t, o), s && s(e, o), i = { errorMessage: `error in ${e}` };
4553
- } finally {
4554
- this.appState = { isFetching: !1 }, this.appState = i;
4555
- }
4556
- else
4557
- throw new Error("Invalid action provided to dispatch");
4558
- return i;
4559
- }
4560
- handleDispatchError(e, t, n) {
4561
- const s = {
4562
- action: e,
4563
- payload: t,
4564
- sessionRef: v(this, A).session && v(this, A).session.sessionRef,
4565
- userRef: v(this, A).session && v(this, A).session.userRef
4566
- }, a = {
4567
- code: "dispatchError",
4568
- message: `error in ${e}`,
4569
- response: n,
4570
- data: s
4571
- };
4572
- this.onError(a);
4573
- }
4574
- }
4575
- Ue = new WeakMap(), Ve = new WeakMap(), A = new WeakMap(), qe = new WeakMap(), he = new WeakMap(), U = new WeakMap(), Be = new WeakMap(), W = new WeakMap(), Ge = new WeakMap(), pe = new WeakMap();
4576
- const tt = {
4577
- thirstieClient: null,
4578
- brandStyle: {}
4579
- };
4580
- async function Gs(r) {
4581
- tt.config = r;
4582
- const { APIKEY: e, MAPSKEY: t } = r, { primaryColor: n, secondaryColor: s } = r, a = new Bs({ apiKey: e, mapsKey: t });
4583
- return await a.initSession(), tt.thirstieClient = a, tt.brandStyle = { primaryColor: n, secondaryColor: s }, { thirstieClient: a };
4584
- }
4585
- function Ws() {
4586
- const { thirstieClient: r } = tt;
4587
- return { thirstieClient: r };
4588
- }
4589
- const Fs = ".th-age-gate-wrapper[data-v-4d11cee0]{min-width:300px;max-width:1280px;margin:0 auto;padding:2rem;text-align:center;border:1px solid #666}.th-age-gate-wrapper button[data-v-4d11cee0]{margin:2rem;text-align:center}", Hs = {
4590
- key: 0,
4591
- class: "th-age-gate-wrapper"
4592
- }, Ks = {
4593
- key: 1,
4594
- class: "th-age-gate-wrapper"
4595
- }, Ys = {
4596
- __name: "AgeVerification.ce",
4597
- props: {
4598
- msg: String
4599
- },
4600
- setup(r) {
4601
- const { thirstieClient: e } = Ws(), t = fr(null), n = async (s) => {
4602
- await e.dispatch("setAgeGate", { ageGateType: "yesno", ageGateValue: s }), t.value = s ? "Welcome!" : "Sorry, we can not serve you";
4603
- };
4604
- return (s, a) => t.value ? (vt(), _t("div", Ks, [
4605
- $("h3", null, wt(t.value), 1)
4606
- ])) : (vt(), _t("div", Hs, [
4607
- $("h3", null, wt(r.msg || "Are You of Legal Drinking Age?"), 1),
4608
- $("button", {
4609
- onClick: a[0] || (a[0] = (i) => n(!0))
4610
- }, "Yes"),
4611
- $("button", {
4612
- onClick: a[1] || (a[1] = (i) => n(!1))
4613
- }, "No")
4614
- ]));
4615
- }
4616
- }, Xs = /* @__PURE__ */ qt(Ys, [["styles", [Fs]], ["__scopeId", "data-v-4d11cee0"]]);
4617
- async function ea(r) {
4618
- await Gs(r), customElements.define("th-disclaimer", Nt(wr)), customElements.define("th-age-verification", Nt(Xs));
4619
- }
4620
- export {
4621
- ea as initApp
4622
- };