@faststore/api 4.3.0 → 4.4.0-dev.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.
package/dist/es/index.mjs CHANGED
@@ -1,163 +1,163 @@
1
- import { mergeTypeDefs as zn } from "@graphql-tools/merge";
2
- import { makeExecutableSchema as he, mergeSchemas as fe } from "@graphql-tools/schema";
3
- import { mapSchema as Vn, MapperKind as xn, getDirective as qn } from "@graphql-tools/utils";
4
- import { OTELAPI as M } from "@faststore/diagnostics";
5
- import { GraphQLScalarType as Se, print as ye, parse as Ie, isSchema as ve } from "graphql";
6
- import { parse as tn } from "cookie";
7
- import Oe from "isomorphic-unfetch";
8
- import rn from "dataloader";
9
- import jn from "p-limit";
10
- import Ce from "sanitize-html";
11
- import Cn from "fast-deep-equal";
12
- import be from "node:crypto";
13
- var De = /* @__PURE__ */ ((n) => (n.Accepted = "accepted", n.Denied = "denied", n.Pending = "pending", n))(De || {}), we = /* @__PURE__ */ ((n) => (n.Brand = "Brand", n.Category = "Category", n.Cluster = "Cluster", n.Collection = "Collection", n.Department = "Department", n.SubCategory = "SubCategory", n))(we || {}), Ae = /* @__PURE__ */ ((n) => (n.Boolean = "BOOLEAN", n.Range = "RANGE", n))(Ae || {}), Pe = /* @__PURE__ */ ((n) => (n.DiscountDesc = "discount_desc", n.NameAsc = "name_asc", n.NameDesc = "name_desc", n.OrdersDesc = "orders_desc", n.PriceAsc = "price_asc", n.PriceDesc = "price_desc", n.ReleaseDesc = "release_desc", n.ScoreDesc = "score_desc", n))(Pe || {}), Ee = /* @__PURE__ */ ((n) => (n.Error = "ERROR", n.Info = "INFO", n.Warning = "WARNING", n))(Ee || {}), Te = /* @__PURE__ */ ((n) => (n.Input = "Input", n.Output = "Output", n))(Te || {});
14
- const _e = () => function(e = {}) {
1
+ import { mergeTypeDefs as qe } from "@graphql-tools/merge";
2
+ import { makeExecutableSchema as vn, mergeSchemas as On } from "@graphql-tools/schema";
3
+ import { mapSchema as je, MapperKind as We, getDirective as Ge } from "@graphql-tools/utils";
4
+ import { OTELAPI as N } from "@faststore/diagnostics";
5
+ import { GraphQLScalarType as Cn, print as bn, parse as Dn, isSchema as wn } from "graphql";
6
+ import { parse as H } from "cookie";
7
+ import Pn from "isomorphic-unfetch";
8
+ import ye from "p-limit";
9
+ import te from "dataloader";
10
+ import An from "sanitize-html";
11
+ import Ie from "fast-deep-equal";
12
+ import En from "node:crypto";
13
+ var Un = /* @__PURE__ */ ((e) => (e.Accepted = "accepted", e.Denied = "denied", e.Pending = "pending", e))(Un || {}), Tn = /* @__PURE__ */ ((e) => (e.Brand = "Brand", e.Category = "Category", e.Cluster = "Cluster", e.Collection = "Collection", e.Department = "Department", e.SubCategory = "SubCategory", e))(Tn || {}), kn = /* @__PURE__ */ ((e) => (e.Boolean = "BOOLEAN", e.Range = "RANGE", e))(kn || {}), _n = /* @__PURE__ */ ((e) => (e.DiscountDesc = "discount_desc", e.NameAsc = "name_asc", e.NameDesc = "name_desc", e.OrdersDesc = "orders_desc", e.PriceAsc = "price_asc", e.PriceDesc = "price_desc", e.ReleaseDesc = "release_desc", e.ScoreDesc = "score_desc", e))(_n || {}), Fn = /* @__PURE__ */ ((e) => (e.Error = "ERROR", e.Info = "INFO", e.Warning = "WARNING", e))(Fn || {}), Rn = /* @__PURE__ */ ((e) => (e.Input = "Input", e.Output = "Output", e))(Rn || {});
14
+ const Nn = () => function(n = {}) {
15
15
  const t = process.env.FS_DISCOVERY_APP_KEY ?? "", r = process.env.FS_DISCOVERY_APP_TOKEN ?? "";
16
16
  if (!t || !r)
17
- throw new an("No authentication AppKey and AppToken passed.");
17
+ throw new re("No authentication AppKey and AppToken passed.");
18
18
  return {
19
- ...e,
19
+ ...n,
20
20
  "X-VTEX-API-AppKey": t,
21
21
  "X-VTEX-API-AppToken": r
22
22
  };
23
- }, Ue = async (n) => {
23
+ }, Ln = async (e) => {
24
24
  const {
25
- clients: { commerce: e }
26
- } = n;
25
+ clients: { commerce: n }
26
+ } = e;
27
27
  try {
28
- if ((await e.vtexid.validate())?.authStatus?.toLowerCase() !== "success")
28
+ if ((await n.vtexid.validate())?.authStatus?.toLowerCase() !== "success")
29
29
  throw new J("Authentication required");
30
30
  } catch (t) {
31
31
  const r = t.extensions?.status ?? t.status;
32
- throw r === 401 ? new J("Authentication required") : r === 403 ? new an("You are not allowed to access this resource") : new J("Authentication required");
32
+ throw r === 401 ? new J("Authentication required") : r === 403 ? new re("You are not allowed to access this resource") : new J("Authentication required");
33
33
  }
34
- }, ke = "auth", Fe = {
34
+ }, Bn = "auth", Mn = {
35
35
  typeDefs: "directive @auth on FIELD_DEFINITION",
36
- transformer: (n) => Vn(n, {
37
- [xn.OBJECT_FIELD]: (e) => {
38
- if (qn(n, e, ke)?.[0]) {
39
- const r = e.resolve;
40
- e.resolve = async (i, a, c, s) => (await Ue(c), r?.(i, a, c, s));
36
+ transformer: (e) => je(e, {
37
+ [We.OBJECT_FIELD]: (n) => {
38
+ if (Ge(e, n, Bn)?.[0]) {
39
+ const r = n.resolve;
40
+ n.resolve = async (i, a, o, s) => (await Ln(o), r?.(i, a, o, s));
41
41
  }
42
- return e;
42
+ return n;
43
43
  }
44
44
  })
45
- }, Ne = "cacheControl", Ui = (n, e) => {
45
+ }, $n = "cacheControl", ra = (e, n) => {
46
46
  const {
47
47
  scope: t = "private",
48
48
  sMaxAge: r = 0,
49
49
  staleWhileRevalidate: i = 0
50
- } = n;
51
- return `${e ? "private" : t}, s-maxage=${r}, stale-while-revalidate=${i}`;
52
- }, bn = (n, e) => typeof n == "number" && typeof e == "number" ? n > e ? e : n : typeof n == "number" ? n : e, Re = (n, e) => typeof n == "string" && typeof e == "string" ? n === "public" && e === "public" ? "public" : "private" : n || e, Le = {
50
+ } = e;
51
+ return `${n ? "private" : t}, s-maxage=${r}, stale-while-revalidate=${i}`;
52
+ }, Oe = (e, n) => typeof e == "number" && typeof n == "number" ? e > n ? n : e : typeof e == "number" ? e : n, zn = (e, n) => typeof e == "string" && typeof n == "string" ? e === "public" && n === "public" ? "public" : "private" : e || n, Vn = {
53
53
  typeDefs: "directive @cacheControl(sMaxAge: Int, staleWhileRevalidate: Int, scope: String) on FIELD_DEFINITION",
54
- transformer: (n) => Vn(n, {
55
- [xn.OBJECT_FIELD]: (e) => {
56
- const t = qn(n, e, Ne)?.[0];
54
+ transformer: (e) => je(e, {
55
+ [We.OBJECT_FIELD]: (n) => {
56
+ const t = Ge(e, n, $n)?.[0];
57
57
  if (t) {
58
- const { sMaxAge: r, staleWhileRevalidate: i, scope: a } = t, c = e.resolve;
59
- e.resolve = (s, l, d, g) => (d.cacheControl = {
60
- sMaxAge: bn(d.cacheControl?.sMaxAge, r),
61
- staleWhileRevalidate: bn(
58
+ const { sMaxAge: r, staleWhileRevalidate: i, scope: a } = t, o = n.resolve;
59
+ n.resolve = (s, l, d, g) => (d.cacheControl = {
60
+ sMaxAge: Oe(d.cacheControl?.sMaxAge, r),
61
+ staleWhileRevalidate: Oe(
62
62
  d.cacheControl?.staleWhileRevalidate,
63
63
  i
64
64
  ),
65
- scope: Re(d.cacheControl?.scope, a)
66
- }, c?.(s, l, d, g));
65
+ scope: zn(d.cacheControl?.scope, a)
66
+ }, o?.(s, l, d, g));
67
67
  }
68
- return e;
68
+ return n;
69
69
  }
70
70
  })
71
- }, Me = (n) => (e, t) => {
72
- const r = zn([
73
- ...(n ?? []).map(({ typeDefs: i }) => i),
71
+ }, xn = (e) => (n, t) => {
72
+ const r = qe([
73
+ ...(e ?? []).map(({ typeDefs: i }) => i),
74
74
  t
75
75
  ]);
76
- return (n ?? []).reduce(
76
+ return (e ?? []).reduce(
77
77
  (i, { transformer: a }) => a?.(i) ?? i,
78
- he({
78
+ vn({
79
79
  typeDefs: r,
80
- resolvers: e
80
+ resolvers: n
81
81
  })
82
82
  );
83
- }, cn = "@faststore/api", ln = "4.3.0-dev.8", Dn = {
84
- name: cn,
85
- version: ln
86
- }, Be = (n, e) => (t, r, i, a) => {
83
+ }, oe = "@faststore/api", se = "4.3.1-dev.0", Ce = {
84
+ name: oe,
85
+ version: se
86
+ }, qn = (e, n) => (t, r, i, a) => {
87
87
  if ((i?.OTEL?.enabled ?? !1) === !1)
88
- return n(t, r, i, a);
89
- const c = M.trace.getTracer(cn, ln), s = M.propagation.extract(
90
- M.context.active(),
88
+ return e(t, r, i, a);
89
+ const o = N.trace.getTracer(oe, se), s = N.propagation.extract(
90
+ N.context.active(),
91
91
  i.OTEL
92
92
  );
93
- return M.context.with(s, () => {
94
- const l = c.startSpan(e ?? "Unknown Graphql Resolver", {
93
+ return N.context.with(s, () => {
94
+ const l = o.startSpan(n ?? "Unknown Graphql Resolver", {
95
95
  startTime: Date.now(),
96
- kind: M.SpanKind.INTERNAL,
96
+ kind: N.SpanKind.INTERNAL,
97
97
  attributes: {
98
98
  timestamp: Date.now(),
99
- "@faststore_version": ln,
100
- "@faststore_package_name": cn,
99
+ "@faststore_version": se,
100
+ "@faststore_package_name": oe,
101
101
  "@faststore_account_name": i.account,
102
102
  "@faststore_environment": process.env.NODE_ENV
103
103
  }
104
104
  });
105
- if (!l) return n(t, r, i, a);
105
+ if (!l) return e(t, r, i, a);
106
106
  try {
107
- const d = n(t, r, i, a);
107
+ const d = e(t, r, i, a);
108
108
  return d instanceof Promise ? d.then((g) => (l.end(), g)) : (l.end(), d);
109
109
  } catch (d) {
110
- throw l.end(), console.error(`Error when executing resolver: ${e}`, d), d;
110
+ throw l.end(), console.error(`Error when executing resolver: ${n}`, d), d;
111
111
  }
112
112
  });
113
113
  };
114
114
  class X extends Error {
115
- constructor(e, t) {
116
- super(t), this.extensions = e, this.name = "FastStoreError";
115
+ constructor(n, t) {
116
+ super(t), this.extensions = n, this.name = "FastStoreError";
117
117
  }
118
118
  }
119
- class k extends X {
120
- constructor(e) {
121
- super({ status: 400, type: "BadRequestError" }, e);
119
+ class U extends X {
120
+ constructor(n) {
121
+ super({ status: 400, type: "BadRequestError" }, n);
122
122
  }
123
123
  }
124
124
  class J extends X {
125
- constructor(e) {
126
- super({ status: 401, type: "UnauthorizedError" }, e);
125
+ constructor(n) {
126
+ super({ status: 401, type: "UnauthorizedError" }, n);
127
127
  }
128
128
  }
129
- class an extends X {
130
- constructor(e) {
131
- super({ status: 403, type: "ForbiddenError" }, e);
129
+ class re extends X {
130
+ constructor(n) {
131
+ super({ status: 403, type: "ForbiddenError" }, n);
132
132
  }
133
133
  }
134
- class z extends X {
135
- constructor(e) {
136
- super({ status: 404, type: "NotFoundError" }, e);
134
+ class B extends X {
135
+ constructor(n) {
136
+ super({ status: 404, type: "NotFoundError" }, n);
137
137
  }
138
138
  }
139
- const ki = (n) => n?.name === "FastStoreError", Fi = (n) => n?.extensions?.type === "BadRequestError", Ni = (n) => n?.extensions?.type === "UnauthorizedError", $e = (n) => n?.extensions?.type === "ForbiddenError", ze = (n) => n?.extensions?.type === "NotFoundError", Ve = `${Dn.name}@${Dn.version}`, f = async (n, e, t) => {
140
- const r = await Oe(n, {
141
- ...e,
139
+ const ia = (e) => e?.name === "FastStoreError", aa = (e) => e?.extensions?.type === "BadRequestError", oa = (e) => e?.extensions?.type === "UnauthorizedError", jn = (e) => e?.extensions?.type === "ForbiddenError", He = (e) => e?.extensions?.type === "NotFoundError", Wn = `${Ce.name}@${Ce.version}`, y = async (e, n, t) => {
140
+ const r = await Pn(e, {
141
+ ...n,
142
142
  headers: {
143
- ...e?.headers ?? {},
144
- "User-Agent": Ve
143
+ ...n?.headers ?? {},
144
+ "User-Agent": Wn
145
145
  }
146
146
  });
147
147
  if (r.ok)
148
148
  return t?.storeCookies && t.storeCookies(r.headers), r.status !== 204 ? r.json() : void 0;
149
- console.error(n, e, r);
149
+ console.error(e, n, r);
150
150
  const i = await r.text();
151
151
  if (typeof r?.status == "number")
152
152
  switch (r.status) {
153
153
  case 400:
154
- throw new k(i);
154
+ throw new U(i);
155
155
  case 401:
156
156
  throw new J(i);
157
157
  case 403:
158
- throw new an(i);
158
+ throw new re(i);
159
159
  case 404:
160
- throw new z(i);
160
+ throw new B(i);
161
161
  default:
162
162
  throw new X(
163
163
  { status: r.status, type: "UnknownError" },
@@ -165,340 +165,340 @@ const ki = (n) => n?.name === "FastStoreError", Fi = (n) => n?.extensions?.type
165
165
  );
166
166
  }
167
167
  throw new Error(i);
168
- }, Wn = (n) => {
169
- if (!n)
170
- return n;
171
- const e = /* @__PURE__ */ new Map(), t = n.split(";"), r = [];
168
+ }, Xe = (e) => {
169
+ if (!e)
170
+ return e;
171
+ const n = /* @__PURE__ */ new Map(), t = e.split(";"), r = [];
172
172
  return t.forEach((i) => {
173
173
  const a = i.trim();
174
174
  if (a) {
175
- const c = a.indexOf("=");
176
- if (c > 0) {
177
- const s = a.substring(0, c), l = a.substring(c + 1);
178
- e.has(s) || r.push(s), e.set(s, l);
175
+ const o = a.indexOf("=");
176
+ if (o > 0) {
177
+ const s = a.substring(0, o), l = a.substring(o + 1);
178
+ n.has(s) || r.push(s), n.set(s, l);
179
179
  }
180
180
  }
181
- }), r.map((i) => `${i}=${e.get(i)}`).join("; ");
182
- }, xe = /^([^=]+)=([^;]*)/, qe = (n, e) => {
183
- const t = e.match(xe);
181
+ }), r.map((i) => `${i}=${n.get(i)}`).join("; ");
182
+ }, Gn = /^([^=]+)=([^;]*)/, Hn = (e, n) => {
183
+ const t = n.match(Gn);
184
184
  if (t) {
185
185
  const r = t[1], i = t[2];
186
- n.storage.cookies.set(r, {
186
+ e.storage.cookies.set(r, {
187
187
  value: i,
188
- setCookie: e
188
+ setCookie: n
189
189
  });
190
190
  }
191
- }, je = (n, e) => {
192
- e.getSetCookie().forEach(
193
- (t) => qe(n, t)
191
+ }, Xn = (e, n) => {
192
+ n.getSetCookie().forEach(
193
+ (t) => Hn(e, t)
194
194
  );
195
- }, We = (n) => (e) => je(n, e), Gn = (n) => {
196
- if (!n.headers?.cookie)
195
+ }, Yn = (e) => (n) => Xn(e, n), Ye = (e) => {
196
+ if (!e.headers?.cookie)
197
197
  return null;
198
- const e = Wn(n.headers.cookie), t = Array.from(n.storage.cookies.entries());
199
- return t.length === 0 ? e : t.reduce(
200
- (r, [i, { value: a }]) => Ge(
198
+ const n = Xe(e.headers.cookie), t = Array.from(e.storage.cookies.entries());
199
+ return t.length === 0 ? n : t.reduce(
200
+ (r, [i, { value: a }]) => Jn(
201
201
  r,
202
202
  i,
203
203
  a
204
204
  ),
205
- e
205
+ n
206
206
  );
207
- }, Hn = (n) => function(t) {
208
- const r = Gn(n);
207
+ }, Je = (e) => function(t) {
208
+ const r = Ye(e);
209
209
  return r ? {
210
210
  ...t,
211
211
  cookie: r
212
212
  } : t;
213
- }, Q = (n, e) => {
214
- const t = Wn(n);
215
- return tn(t)[`VtexIdclientAutCookie_${e}`] || "";
216
- }, Ge = (n, e, t) => {
217
- const r = new RegExp(`(${e})=([^;]*)`), i = n.match(r);
218
- return i ? n.replace(
213
+ }, Q = (e, n) => {
214
+ const t = Xe(e);
215
+ return H(t)[`VtexIdclientAutCookie_${n}`] || "";
216
+ }, Jn = (e, n, t) => {
217
+ const r = new RegExp(`(${n})=([^;]*)`), i = e.match(r);
218
+ return i ? e.replace(
219
219
  i[0],
220
220
  `${i[1]}=${t}`
221
- ) : `${n};${e}=${t}`;
221
+ ) : `${e};${n}=${t}`;
222
222
  };
223
- function Z(n) {
224
- return n ? JSON.parse(Buffer.from(n.split(".")[1], "base64").toString()) : null;
223
+ function Z(e) {
224
+ return e ? JSON.parse(Buffer.from(e.split(".")[1], "base64").toString()) : null;
225
225
  }
226
- const H = {
226
+ const j = {
227
227
  method: "POST",
228
228
  headers: {
229
229
  "content-type": "application/json"
230
230
  }
231
- }, He = ({ account: n, environment: e, incrementAddress: t, subDomainPrefix: r }, i) => {
232
- const a = `https://${n}.${e}.com.br`, c = We(i), s = Hn(i), l = _e(), d = new Headers(i.headers).get("x-forwarded-host") ?? i.headers?.host ?? "", g = r && r.map((o) => o + ".").find((o) => d.includes(o)) || "", u = d.replace(g, "");
231
+ }, Kn = ({ account: e, environment: n, incrementAddress: t, subDomainPrefix: r }, i) => {
232
+ const a = `https://${e}.${n}.com.br`, o = Yn(i), s = Je(i), l = Nn(), d = new Headers(i.headers).get("x-forwarded-host") ?? i.headers?.host ?? "", g = r && r.map((c) => c + ".").find((c) => d.includes(c)) || "", p = d.replace(g, "");
233
233
  return {
234
234
  catalog: {
235
- salesChannel: (o) => f(
236
- `${a}/api/catalog_system/pub/saleschannel/${o}`,
235
+ salesChannel: (c) => y(
236
+ `${a}/api/catalog_system/pub/saleschannel/${c}`,
237
237
  void 0,
238
- { storeCookies: c }
238
+ { storeCookies: o }
239
239
  ),
240
240
  brand: {
241
- list: () => f(`${a}/api/catalog_system/pub/brand/list`, void 0, {
242
- storeCookies: c
241
+ list: () => y(`${a}/api/catalog_system/pub/brand/list`, void 0, {
242
+ storeCookies: o
243
243
  })
244
244
  },
245
245
  category: {
246
- tree: (o = 3) => f(
247
- `${a}/api/catalog_system/pub/category/tree/${o}`,
246
+ tree: (c = 3) => y(
247
+ `${a}/api/catalog_system/pub/category/tree/${c}`,
248
248
  void 0,
249
- { storeCookies: c }
249
+ { storeCookies: o }
250
250
  )
251
251
  },
252
252
  portal: {
253
- pagetype: (o) => f(
254
- `${a}/api/catalog_system/pub/portal/pagetype/${o}`,
253
+ pagetype: (c) => y(
254
+ `${a}/api/catalog_system/pub/portal/pagetype/${c}`,
255
255
  void 0,
256
- { storeCookies: c }
256
+ { storeCookies: o }
257
257
  )
258
258
  },
259
259
  products: {
260
260
  crossselling: ({
261
- type: o,
262
- productId: p,
261
+ type: c,
262
+ productId: u,
263
263
  groupByProduct: m = !0
264
264
  }) => {
265
265
  const S = new URLSearchParams({
266
266
  sc: i.storage.channel.salesChannel,
267
267
  groupByProduct: m.toString()
268
268
  });
269
- return f(
270
- `${a}/api/catalog_system/pub/products/crossselling/${o}/${p}?${S}`,
269
+ return y(
270
+ `${a}/api/catalog_system/pub/products/crossselling/${c}/${u}?${S}`,
271
271
  void 0,
272
- { storeCookies: c }
272
+ { storeCookies: o }
273
273
  );
274
274
  }
275
275
  }
276
276
  },
277
277
  checkout: {
278
- simulation: (o, { salesChannel: p } = i.storage.channel) => {
278
+ simulation: (c, { salesChannel: u } = i.storage.channel) => {
279
279
  const m = new URLSearchParams({
280
- sc: p
280
+ sc: u
281
281
  }), S = s({
282
282
  "content-type": "application/json",
283
- "X-FORWARDED-HOST": u
283
+ "X-FORWARDED-HOST": p
284
284
  });
285
- return f(
285
+ return y(
286
286
  `${a}/api/checkout/pub/orderForms/simulation?${m.toString()}`,
287
287
  {
288
- ...H,
288
+ ...j,
289
289
  headers: S,
290
- body: JSON.stringify(o)
290
+ body: JSON.stringify(c)
291
291
  },
292
- { storeCookies: c }
292
+ { storeCookies: o }
293
293
  );
294
294
  },
295
295
  shippingData: ({
296
- id: o,
297
- index: p,
296
+ id: c,
297
+ index: u,
298
298
  deliveryMode: m,
299
299
  selectedAddresses: S
300
- }, I) => {
301
- const O = I ? {
300
+ }, f) => {
301
+ const I = f ? {
302
302
  startDateUtc: m?.deliveryWindow?.startDate,
303
303
  endDateUtc: m?.deliveryWindow?.endDate
304
- } : null, w = {
305
- logisticsInfo: Array.from({ length: p }, (P, b) => ({
306
- itemIndex: b,
304
+ } : null, D = {
305
+ logisticsInfo: Array.from({ length: u }, (w, O) => ({
306
+ itemIndex: O,
307
307
  selectedDeliveryChannel: m?.deliveryChannel || null,
308
308
  selectedSla: m?.deliveryMethod || null,
309
- deliveryWindow: O
309
+ deliveryWindow: I
310
310
  })),
311
311
  selectedAddresses: S,
312
312
  clearAddressIfPostalCodeNotFound: t
313
- }, _ = s({
313
+ }, E = s({
314
314
  "content-type": "application/json",
315
- "X-FORWARDED-HOST": u
315
+ "X-FORWARDED-HOST": p
316
316
  });
317
- return f(
318
- `${a}/api/checkout/pub/orderForm/${o}/attachments/shippingData`,
317
+ return y(
318
+ `${a}/api/checkout/pub/orderForm/${c}/attachments/shippingData`,
319
319
  {
320
- ...H,
321
- headers: _,
322
- body: JSON.stringify(w)
320
+ ...j,
321
+ headers: E,
322
+ body: JSON.stringify(D)
323
323
  },
324
- { storeCookies: c }
324
+ { storeCookies: o }
325
325
  );
326
326
  },
327
327
  marketingData: ({
328
- id: o,
329
- marketingData: p
328
+ id: c,
329
+ marketingData: u
330
330
  }) => {
331
331
  const m = s({
332
332
  "content-type": "application/json",
333
- "X-FORWARDED-HOST": u
333
+ "X-FORWARDED-HOST": p
334
334
  });
335
- return f(
336
- `${a}/api/checkout/pub/orderForm/${o}/attachments/marketingData`,
335
+ return y(
336
+ `${a}/api/checkout/pub/orderForm/${c}/attachments/marketingData`,
337
337
  {
338
338
  headers: m,
339
- body: JSON.stringify(p),
339
+ body: JSON.stringify(u),
340
340
  method: "POST"
341
341
  },
342
- { storeCookies: c }
342
+ { storeCookies: o }
343
343
  );
344
344
  },
345
345
  clientPreferencesData: ({
346
- id: o,
347
- clientPreferencesData: p
346
+ id: c,
347
+ clientPreferencesData: u
348
348
  }) => {
349
349
  const m = s({
350
350
  "content-type": "application/json",
351
- "X-FORWARDED-HOST": u
351
+ "X-FORWARDED-HOST": p
352
352
  });
353
- return f(
354
- `${a}/api/checkout/pub/orderForm/${o}/attachments/clientPreferencesData`,
353
+ return y(
354
+ `${a}/api/checkout/pub/orderForm/${c}/attachments/clientPreferencesData`,
355
355
  {
356
356
  headers: m,
357
- body: JSON.stringify(p),
357
+ body: JSON.stringify(u),
358
358
  method: "POST"
359
359
  },
360
- { storeCookies: c }
360
+ { storeCookies: o }
361
361
  );
362
362
  },
363
363
  orderForm: ({
364
- id: o,
365
- refreshOutdatedData: p = !0,
364
+ id: c,
365
+ refreshOutdatedData: u = !0,
366
366
  channel: m = i.storage.channel
367
367
  }) => {
368
- const { salesChannel: S } = m, I = s({
368
+ const { salesChannel: S } = m, f = s({
369
369
  "content-type": "application/json",
370
- "X-FORWARDED-HOST": u
371
- }), O = new URLSearchParams({ sc: S });
372
- o && O.set("refreshOutdatedData", p.toString());
373
- const w = `${a}/api/checkout/pub/orderForm${o ? `/${o}` : ""}?${O.toString()}`;
374
- return f(
375
- w,
370
+ "X-FORWARDED-HOST": p
371
+ }), I = new URLSearchParams({ sc: S });
372
+ c && I.set("refreshOutdatedData", u.toString());
373
+ const D = `${a}/api/checkout/pub/orderForm${c ? `/${c}` : ""}?${I.toString()}`;
374
+ return y(
375
+ D,
376
376
  {
377
- ...H,
378
- headers: I,
379
- ...o ? {} : { body: "{}" }
377
+ ...j,
378
+ headers: f,
379
+ ...c ? {} : { body: "{}" }
380
380
  },
381
- { storeCookies: c }
381
+ { storeCookies: o }
382
382
  );
383
383
  },
384
- clearOrderFormMessages: ({ id: o }) => {
385
- const p = s({
384
+ clearOrderFormMessages: ({ id: c }) => {
385
+ const u = s({
386
386
  "content-type": "application/json",
387
- "X-FORWARDED-HOST": u
387
+ "X-FORWARDED-HOST": p
388
388
  });
389
- return f(
390
- `${a}/api/checkout/pub/orderForm/${o}/messages/clear`,
389
+ return y(
390
+ `${a}/api/checkout/pub/orderForm/${c}/messages/clear`,
391
391
  {
392
- ...H,
393
- headers: p,
392
+ ...j,
393
+ headers: u,
394
394
  body: "{}"
395
395
  }
396
396
  );
397
397
  },
398
398
  updateOrderFormItems: ({
399
- id: o,
400
- orderItems: p,
399
+ id: c,
400
+ orderItems: u,
401
401
  allowOutdatedData: m = "paymentData",
402
402
  salesChannel: S = i.storage.channel.salesChannel,
403
- shouldSplitItem: I = !0
403
+ shouldSplitItem: f = !0
404
404
  }) => {
405
- const O = new URLSearchParams({
405
+ const I = new URLSearchParams({
406
406
  allowOutdatedData: m,
407
407
  sc: S
408
- }), w = s({
408
+ }), D = s({
409
409
  "content-type": "application/json",
410
- "X-FORWARDED-HOST": u
410
+ "X-FORWARDED-HOST": p
411
411
  });
412
- return f(
413
- `${a}/api/checkout/pub/orderForm/${o}/items?${O}`,
412
+ return y(
413
+ `${a}/api/checkout/pub/orderForm/${c}/items?${I}`,
414
414
  {
415
- headers: w,
415
+ headers: D,
416
416
  body: JSON.stringify({
417
- orderItems: p,
418
- noSplitItem: !I
417
+ orderItems: u,
418
+ noSplitItem: !f
419
419
  }),
420
420
  method: "PATCH"
421
421
  },
422
- { storeCookies: c }
422
+ { storeCookies: o }
423
423
  );
424
424
  },
425
425
  setCustomData: ({
426
- id: o,
427
- appId: p,
426
+ id: c,
427
+ appId: u,
428
428
  key: m,
429
429
  value: S
430
430
  }) => {
431
- const I = s({
431
+ const f = s({
432
432
  "content-type": "application/json",
433
- "X-FORWARDED-HOST": u
433
+ "X-FORWARDED-HOST": p
434
434
  });
435
- return f(
436
- `${a}/api/checkout/pub/orderForm/${o}/customData/${p}/${m}`,
435
+ return y(
436
+ `${a}/api/checkout/pub/orderForm/${c}/customData/${u}/${m}`,
437
437
  {
438
- headers: I,
438
+ headers: f,
439
439
  body: JSON.stringify({ value: S }),
440
440
  method: "PUT"
441
441
  }
442
442
  );
443
443
  },
444
444
  region: async ({
445
- postalCode: o,
446
- geoCoordinates: p,
445
+ postalCode: c,
446
+ geoCoordinates: u,
447
447
  country: m,
448
448
  salesChannel: S
449
449
  }) => {
450
- const I = new URLSearchParams({
450
+ const f = new URLSearchParams({
451
451
  country: m,
452
452
  sc: S ?? ""
453
453
  });
454
- o ? I.append("postalCode", o) : I.append(
454
+ c ? f.append("postalCode", c) : f.append(
455
455
  "geoCoordinates",
456
- `${p?.longitude};${p?.latitude}`
456
+ `${u?.longitude};${u?.latitude}`
457
457
  );
458
- const O = `${a}/api/checkout/pub/regions/?${I.toString()}`, w = s({
458
+ const I = `${a}/api/checkout/pub/regions/?${f.toString()}`, D = s({
459
459
  "content-type": "application/json",
460
- "X-FORWARDED-HOST": u
460
+ "X-FORWARDED-HOST": p
461
461
  });
462
- return f(
463
- O,
462
+ return y(
463
+ I,
464
464
  {
465
- headers: w
465
+ headers: D
466
466
  },
467
- { storeCookies: c }
467
+ { storeCookies: o }
468
468
  );
469
469
  },
470
470
  address: async ({
471
- postalCode: o,
472
- country: p
471
+ postalCode: c,
472
+ country: u
473
473
  }) => {
474
474
  const m = s({
475
475
  "content-type": "application/json",
476
- "X-FORWARDED-HOST": u
476
+ "X-FORWARDED-HOST": p
477
477
  });
478
- return f(
479
- `${a}/api/checkout/pub/postal-code/${p}/${o}`,
478
+ return y(
479
+ `${a}/api/checkout/pub/postal-code/${u}/${c}`,
480
480
  {
481
481
  headers: m
482
482
  },
483
- { storeCookies: c }
483
+ { storeCookies: o }
484
484
  );
485
485
  },
486
486
  cancelOrder: ({
487
- orderId: o,
488
- customerEmail: p,
487
+ orderId: c,
488
+ customerEmail: u,
489
489
  reason: m
490
490
  }) => {
491
491
  const S = s({
492
492
  "content-type": "application/json",
493
- "X-FORWARDED-HOST": u
493
+ "X-FORWARDED-HOST": p
494
494
  });
495
- return f(
496
- `${a}/api/checkout/pub/orders/${o}/user-cancel-request`,
495
+ return y(
496
+ `${a}/api/checkout/pub/orders/${c}/user-cancel-request`,
497
497
  {
498
498
  method: "POST",
499
499
  headers: S,
500
500
  body: JSON.stringify({
501
- customerEmail: p,
501
+ customerEmail: u,
502
502
  reason: m
503
503
  })
504
504
  },
@@ -506,217 +506,217 @@ const H = {
506
506
  );
507
507
  },
508
508
  pickupPoints: ({
509
- geoCoordinates: o
509
+ geoCoordinates: c
510
510
  }) => {
511
- if (!o)
511
+ if (!c)
512
512
  throw new Error(
513
513
  "Missing required parameter for listing pickup points."
514
514
  );
515
- const p = s({
515
+ const u = s({
516
516
  "content-type": "application/json",
517
- "X-FORWARDED-HOST": u
517
+ "X-FORWARDED-HOST": p
518
518
  });
519
- return f(
519
+ return y(
520
520
  `${a}/api/logistics-shipping/pickuppoints/_search`,
521
521
  {
522
522
  method: "POST",
523
- headers: p,
524
- body: JSON.stringify({ coordinate: o })
523
+ headers: u,
524
+ body: JSON.stringify({ coordinate: c })
525
525
  },
526
- { storeCookies: c }
526
+ { storeCookies: o }
527
527
  );
528
528
  }
529
529
  },
530
- session: (o) => {
531
- const p = new URLSearchParams(o);
532
- p.set(
530
+ session: (c) => {
531
+ const u = new URLSearchParams(c);
532
+ u.set(
533
533
  "items",
534
534
  "profile.id,profile.email,profile.firstName,profile.lastName,profile.phone,shopper.firstName,shopper.lastName,shopper.organizationManager,store.channel,store.countryCode,store.cultureInfo,store.currencyCode,store.currencySymbol,authentication.customerId,authentication.storeUserId,authentication.storeUserEmail,authentication.unitId,authentication.unitName,checkout.regionId,public.postalCode"
535
535
  );
536
536
  const m = s({
537
537
  "content-type": "application/json"
538
- }), S = tn(i?.headers?.cookie ?? "")?.vtex_session;
539
- return f(
540
- `${a}/api/sessions?${p.toString()}`,
538
+ }), S = H(i?.headers?.cookie ?? "")?.vtex_session;
539
+ return y(
540
+ `${a}/api/sessions?${u.toString()}`,
541
541
  {
542
542
  method: S ? "PATCH" : "POST",
543
543
  headers: m,
544
544
  body: "{}"
545
545
  },
546
- { storeCookies: c }
546
+ { storeCookies: o }
547
547
  );
548
548
  },
549
- subscribeToNewsletter: (o) => f(
549
+ subscribeToNewsletter: (c) => y(
550
550
  `${a}/api/dataentities/NL/documents/`,
551
551
  {
552
- ...H,
553
- body: JSON.stringify({ ...o, isNewsletterOptIn: !0 }),
552
+ ...j,
553
+ body: JSON.stringify({ ...c, isNewsletterOptIn: !0 }),
554
554
  method: "PATCH"
555
555
  },
556
- { storeCookies: c }
556
+ { storeCookies: o }
557
557
  ),
558
558
  profile: {
559
- addresses: async (o) => {
560
- const p = s({
559
+ addresses: async (c) => {
560
+ const u = s({
561
561
  "content-type": "application/json",
562
- "X-FORWARDED-HOST": u
562
+ "X-FORWARDED-HOST": p
563
563
  });
564
- return f(
565
- `${a}/api/profile-system/pvt/profiles/${o}/addresses`,
566
- { headers: p },
567
- { storeCookies: c }
564
+ return y(
565
+ `${a}/api/profile-system/pvt/profiles/${c}/addresses`,
566
+ { headers: u },
567
+ { storeCookies: o }
568
568
  );
569
569
  }
570
570
  },
571
571
  oms: {
572
- userOrder: ({ orderId: o }) => {
573
- const p = s({
572
+ userOrder: ({ orderId: c }) => {
573
+ const u = s({
574
574
  "content-type": "application/json",
575
- "X-FORWARDED-HOST": u
575
+ "X-FORWARDED-HOST": p
576
576
  });
577
- return f(
578
- `${a}/api/oms/user/orders/${o}`,
577
+ return y(
578
+ `${a}/api/oms/user/orders/${c}`,
579
579
  {
580
580
  method: "GET",
581
- headers: p
581
+ headers: u
582
582
  },
583
- { storeCookies: c }
583
+ { storeCookies: o }
584
584
  );
585
585
  },
586
586
  listUserOrders: ({
587
- page: o,
588
- status: p,
587
+ page: c,
588
+ status: u,
589
589
  dateInitial: m,
590
590
  dateFinal: S,
591
- text: I,
592
- clientEmail: O,
593
- perPage: w,
594
- pendingMyApproval: _
591
+ text: f,
592
+ clientEmail: I,
593
+ perPage: D,
594
+ pendingMyApproval: E
595
595
  }) => {
596
- const P = new URLSearchParams();
596
+ const w = new URLSearchParams();
597
597
  if (m) {
598
- const E = new Date(m).setHours(
598
+ const P = new Date(m).setHours(
599
599
  0,
600
600
  0,
601
601
  0,
602
602
  0
603
603
  );
604
- m = new Date(E).toISOString();
604
+ m = new Date(P).toISOString();
605
605
  }
606
606
  if (S) {
607
- const E = new Date(S).setHours(
607
+ const P = new Date(S).setHours(
608
608
  23,
609
609
  59,
610
610
  59,
611
611
  999
612
612
  );
613
- S = new Date(E).toISOString();
613
+ S = new Date(P).toISOString();
614
614
  }
615
- I && P.append("text", I), p && p.length > 0 && P.append("status", p.filter(Boolean).join(",")), m && S ? P.append(
615
+ f && w.append("text", f), u && u.length > 0 && w.append("status", u.filter(Boolean).join(",")), m && S ? w.append(
616
616
  "creation_date",
617
617
  `creationDate:[${m} TO ${S}]`
618
- ) : m ? P.append("creation_date", `creationDate:[${m} TO *]`) : S && P.append("creation_date", `creationDate:[* TO ${S}]`), O && P.append("clientEmail", O), o && P.append("page", o.toString()), w && P.append("per_page", w.toString()), _ && P.append("my_pending_approvals", String(!0));
619
- const b = s({
618
+ ) : m ? w.append("creation_date", `creationDate:[${m} TO *]`) : S && w.append("creation_date", `creationDate:[* TO ${S}]`), I && w.append("clientEmail", I), c && w.append("page", c.toString()), D && w.append("per_page", D.toString()), E && w.append("my_pending_approvals", String(!0));
619
+ const O = s({
620
620
  "content-type": "application/json",
621
- "X-FORWARDED-HOST": u
621
+ "X-FORWARDED-HOST": p
622
622
  });
623
- return f(
624
- `${a}/api/oms/user/orders?${P.toString()}`,
623
+ return y(
624
+ `${a}/api/oms/user/orders?${w.toString()}`,
625
625
  {
626
626
  method: "GET",
627
- headers: b
627
+ headers: O
628
628
  },
629
- { storeCookies: c }
629
+ { storeCookies: o }
630
630
  );
631
631
  },
632
632
  getCommercialAuthorizationsByOrderId: ({
633
- orderId: o
633
+ orderId: c
634
634
  }) => {
635
- const p = s({
635
+ const u = s({
636
636
  "content-type": "application/json",
637
- "X-FORWARDED-HOST": u
637
+ "X-FORWARDED-HOST": p
638
638
  });
639
- return f(
640
- `${a}/${n}/commercial-authorizations/order/${o}`,
639
+ return y(
640
+ `${a}/${e}/commercial-authorizations/order/${c}`,
641
641
  {
642
642
  method: "GET",
643
- headers: p
643
+ headers: u
644
644
  },
645
- { storeCookies: c }
645
+ { storeCookies: o }
646
646
  );
647
647
  },
648
648
  processOrderAuthorization: async ({
649
- orderAuthorizationId: o,
650
- dimensionId: p,
649
+ orderAuthorizationId: c,
650
+ dimensionId: u,
651
651
  ruleId: m,
652
652
  approved: S
653
653
  }) => {
654
- const I = s({
654
+ const f = s({
655
655
  "content-type": "application/json",
656
- "X-FORWARDED-HOST": u
657
- }), _ = {
656
+ "X-FORWARDED-HOST": p
657
+ }), E = {
658
658
  params: {
659
659
  ruleId: m,
660
- dimensionId: p,
660
+ dimensionId: u,
661
661
  score: S ? 100 : 0
662
662
  }
663
663
  };
664
- return f(
665
- `${a}/${n}/commercial-authorizations/${o}/callback`,
664
+ return y(
665
+ `${a}/${e}/commercial-authorizations/${c}/callback`,
666
666
  {
667
667
  method: "POST",
668
- headers: I,
669
- body: JSON.stringify(_)
668
+ headers: f,
669
+ body: JSON.stringify(E)
670
670
  },
671
- { storeCookies: c }
671
+ { storeCookies: o }
672
672
  );
673
673
  }
674
674
  },
675
675
  units: {
676
676
  getUnitByUserId: ({
677
- userId: o
677
+ userId: c
678
678
  }) => {
679
- const p = s({
679
+ const u = s({
680
680
  "content-type": "application/json",
681
- "X-FORWARDED-HOST": u
681
+ "X-FORWARDED-HOST": p
682
682
  });
683
- return f(
684
- `${a}/api/units/v1/${o}/unit`,
683
+ return y(
684
+ `${a}/api/units/v1/${c}/unit`,
685
685
  {
686
686
  method: "GET",
687
- headers: p
687
+ headers: u
688
688
  },
689
689
  {}
690
690
  );
691
691
  },
692
692
  getOrgUnitById: ({
693
- orgUnitId: o
693
+ orgUnitId: c
694
694
  }) => {
695
- const p = s({
695
+ const u = s({
696
696
  "content-type": "application/json",
697
- "X-FORWARDED-HOST": u
697
+ "X-FORWARDED-HOST": p
698
698
  });
699
- return f(
700
- `${a}/api/units/v1/${o}`,
699
+ return y(
700
+ `${a}/api/units/v1/${c}`,
701
701
  {
702
702
  method: "GET",
703
- headers: p
703
+ headers: u
704
704
  },
705
705
  {}
706
706
  );
707
707
  },
708
708
  getScopesByOrgUnit: ({
709
- orgUnitId: o
709
+ orgUnitId: c
710
710
  }) => {
711
- const p = s({
711
+ const u = s({
712
712
  "content-type": "application/json",
713
- "X-FORWARDED-HOST": u
713
+ "X-FORWARDED-HOST": p
714
714
  });
715
- return f(
716
- `${a}/api/units/v1/${o}/scopes`,
715
+ return y(
716
+ `${a}/api/units/v1/${c}/scopes`,
717
717
  {
718
718
  method: "GET",
719
- headers: p
719
+ headers: u
720
720
  },
721
721
  {}
722
722
  );
@@ -724,49 +724,49 @@ const H = {
724
724
  },
725
725
  licenseManager: {
726
726
  getUserById: ({
727
- userId: o
727
+ userId: c
728
728
  }) => {
729
- const p = s({
729
+ const u = s({
730
730
  "content-type": "application/json",
731
- "X-FORWARDED-HOST": u
731
+ "X-FORWARDED-HOST": p
732
732
  });
733
- return f(
734
- `${a}/api/license-manager/users/${o}`,
733
+ return y(
734
+ `${a}/api/license-manager/users/${c}`,
735
735
  {
736
736
  method: "GET",
737
- headers: p
737
+ headers: u
738
738
  },
739
739
  {}
740
740
  );
741
741
  },
742
742
  getUserByEmail: ({
743
- email: o
743
+ email: c
744
744
  }) => {
745
- const p = s({
745
+ const u = s({
746
746
  "content-type": "application/json",
747
- "X-FORWARDED-HOST": u
747
+ "X-FORWARDED-HOST": p
748
748
  });
749
- return f(
750
- `${a}/api/license-manager/pvt/users/${o}`,
749
+ return y(
750
+ `${a}/api/license-manager/pvt/users/${c}`,
751
751
  {
752
752
  method: "GET",
753
- headers: p
753
+ headers: u
754
754
  },
755
755
  {}
756
756
  );
757
757
  },
758
758
  getUserRoles: ({
759
- userId: o
759
+ userId: c
760
760
  }) => {
761
- const p = s({
761
+ const u = s({
762
762
  "content-type": "application/json",
763
- "X-FORWARDED-HOST": u
763
+ "X-FORWARDED-HOST": p
764
764
  });
765
- return f(
766
- `${a}/api/license-manager/storefront/users/${o}/roles`,
765
+ return y(
766
+ `${a}/api/license-manager/storefront/users/${c}/roles`,
767
767
  {
768
768
  method: "GET",
769
- headers: p
769
+ headers: u
770
770
  },
771
771
  {}
772
772
  );
@@ -774,39 +774,39 @@ const H = {
774
774
  },
775
775
  masterData: {
776
776
  getContractById: ({
777
- contractId: o
777
+ contractId: c
778
778
  }) => {
779
- if (!o)
780
- throw new k("Missing contractId to fetch CL fields.");
781
- const p = l({
779
+ if (!c)
780
+ throw new U("Missing contractId to fetch CL fields.");
781
+ const u = l({
782
782
  Accept: "application/json",
783
783
  "content-type": "application/json",
784
- "X-FORWARDED-HOST": u
784
+ "X-FORWARDED-HOST": p
785
785
  });
786
- return f(
787
- `${a}/api/dataentities/CL/documents/${o}?_fields=_all`,
786
+ return y(
787
+ `${a}/api/dataentities/CL/documents/${c}?_fields=_all`,
788
788
  {
789
789
  method: "GET",
790
- headers: p
790
+ headers: u
791
791
  },
792
792
  {}
793
793
  );
794
794
  },
795
795
  getShopperById: ({
796
- userId: o
796
+ userId: c
797
797
  }) => {
798
- if (!o)
799
- throw new k("Missing userId to fetch shopper name.");
800
- const p = l({
798
+ if (!c)
799
+ throw new U("Missing userId to fetch shopper name.");
800
+ const u = l({
801
801
  Accept: "application/json",
802
802
  "content-type": "application/json",
803
- "X-FORWARDED-HOST": u
804
- }), m = o.replace(/-/g, "");
805
- return f(
806
- `${a}/api/dataentities/shopper/search?_where=(userId=${m} OR userId=${o})&_fields=_all&_schema=v1`,
803
+ "X-FORWARDED-HOST": p
804
+ }), m = c.replace(/-/g, "");
805
+ return y(
806
+ `${a}/api/dataentities/shopper/search?_where=(userId=${m} OR userId=${c})&_fields=_all&_schema=v1`,
807
807
  {
808
808
  method: "GET",
809
- headers: p
809
+ headers: u
810
810
  },
811
811
  {}
812
812
  );
@@ -814,48 +814,48 @@ const H = {
814
814
  },
815
815
  vtexid: {
816
816
  validate: () => {
817
- const o = s({
817
+ const c = s({
818
818
  "content-type": "application/json",
819
- "X-FORWARDED-HOST": u
820
- }), p = Q(Gn(i) ?? "", n);
821
- return f(
819
+ "X-FORWARDED-HOST": p
820
+ }), u = Q(Ye(i) ?? "", e);
821
+ return y(
822
822
  `${a}/api/vtexid/credential/validate`,
823
823
  {
824
- headers: o,
825
- body: JSON.stringify({ token: p }),
824
+ headers: c,
825
+ body: JSON.stringify({ token: u }),
826
826
  method: "POST"
827
827
  },
828
- { storeCookies: c }
828
+ { storeCookies: o }
829
829
  );
830
830
  }
831
831
  },
832
832
  orderEntry: {
833
833
  uploadFile: ({
834
- fileBuffer: o,
835
- fileName: p,
834
+ fileBuffer: c,
835
+ fileName: u,
836
836
  mimeType: m
837
837
  }) => {
838
838
  const S = s({
839
839
  "content-type": "application/json",
840
- "X-FORWARDED-HOST": u
841
- }), I = `----FastStoreUploadBoundary${Date.now()}`, O = `\r
842
- `, _ = /^[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_+]*$/.test(m) ? m : "application/octet-stream", P = p.replaceAll(/[\r\n"]/g, "_"), b = [
843
- `--${I}`,
844
- `Content-Disposition: form-data; name="file"; filename="${P}"`,
845
- `Content-Type: ${_}`,
840
+ "X-FORWARDED-HOST": p
841
+ }), f = `----FastStoreUploadBoundary${Date.now()}`, I = `\r
842
+ `, E = /^[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_+]*$/.test(m) ? m : "application/octet-stream", w = u.replaceAll(/[\r\n"]/g, "_"), O = [
843
+ `--${f}`,
844
+ `Content-Disposition: form-data; name="file"; filename="${w}"`,
845
+ `Content-Type: ${E}`,
846
846
  "",
847
847
  ""
848
- ].join(O), E = `${O}--${I}--${O}`, h = Buffer.from(b), v = Buffer.from(E), C = new Uint8Array(
849
- h.byteLength + o.byteLength + v.byteLength
848
+ ].join(I), P = `${I}--${f}--${I}`, h = Buffer.from(O), b = Buffer.from(P), C = new Uint8Array(
849
+ h.byteLength + c.byteLength + b.byteLength
850
850
  );
851
- let D = 0;
852
- return C.set(h, D), D += h.byteLength, C.set(o, D), D += o.byteLength, C.set(v, D), f(
853
- `${a}/api/order-entry/upload?an=${n}`,
851
+ let A = 0;
852
+ return C.set(h, A), A += h.byteLength, C.set(c, A), A += c.byteLength, C.set(b, A), y(
853
+ `${a}/api/order-entry/upload?an=${e}`,
854
854
  {
855
855
  method: "POST",
856
856
  headers: {
857
857
  ...S,
858
- "content-type": `multipart/form-data; boundary=${I}`
858
+ "content-type": `multipart/form-data; boundary=${f}`
859
859
  },
860
860
  body: C.buffer
861
861
  },
@@ -863,362 +863,622 @@ const H = {
863
863
  );
864
864
  },
865
865
  startOperation: ({
866
- objectKey: o,
867
- orderFormId: p,
866
+ objectKey: c,
867
+ orderFormId: u,
868
868
  sessionToken: m
869
869
  }) => {
870
870
  const S = s({
871
871
  "content-type": "application/json",
872
- "X-FORWARDED-HOST": u
873
- }), I = JSON.stringify({
874
- objectKey: o,
875
- orderFormId: p,
872
+ "X-FORWARDED-HOST": p
873
+ }), f = JSON.stringify({
874
+ objectKey: c,
875
+ orderFormId: u,
876
876
  operation: "CreateCart",
877
877
  ...m ? { sessionToken: m } : {}
878
878
  });
879
- return f(
880
- `${a}/api/order-entry/operation?an=${n}`,
879
+ return y(
880
+ `${a}/api/order-entry/operation?an=${e}`,
881
881
  {
882
882
  method: "POST",
883
883
  headers: S,
884
- body: I
884
+ body: f
885
885
  },
886
886
  {}
887
887
  );
888
888
  },
889
889
  getOperation: ({
890
- operationId: o
890
+ operationId: c
891
891
  }) => {
892
- const p = s({
892
+ const u = s({
893
893
  "content-type": "application/json",
894
- "X-FORWARDED-HOST": u
894
+ "X-FORWARDED-HOST": p
895
895
  });
896
- return f(
897
- `${a}/api/order-entry/operation/${o}?an=${n}`,
896
+ return y(
897
+ `${a}/api/order-entry/operation/${c}?an=${e}`,
898
898
  {
899
899
  method: "GET",
900
- headers: p
900
+ headers: u
901
901
  },
902
902
  {}
903
903
  );
904
904
  },
905
905
  createOrderForm: () => {
906
- const o = s({
906
+ const c = s({
907
907
  "content-type": "application/json",
908
- "X-FORWARDED-HOST": u
908
+ "X-FORWARDED-HOST": p
909
909
  });
910
- return f(
910
+ return y(
911
911
  `${a}/api/checkout/pub/orderForm?sc=${i.storage.channel.salesChannel}`,
912
912
  {
913
913
  method: "POST",
914
- headers: o,
914
+ headers: c,
915
915
  body: "{}"
916
916
  },
917
917
  {}
918
918
  );
919
919
  },
920
920
  getOrderFormItems: ({
921
- orderFormId: o
921
+ orderFormId: c
922
922
  }) => {
923
- const p = s({
923
+ const u = s({
924
924
  "content-type": "application/json",
925
- "X-FORWARDED-HOST": u
925
+ "X-FORWARDED-HOST": p
926
926
  });
927
- return f(
928
- `${a}/api/checkout/pub/orderForm/${o}`,
927
+ return y(
928
+ `${a}/api/checkout/pub/orderForm/${c}`,
929
929
  {
930
930
  method: "GET",
931
- headers: p
931
+ headers: u
932
932
  },
933
933
  {}
934
934
  );
935
935
  }
936
936
  }
937
937
  };
938
- }, dn = "trade-policy", un = "region-id", pn = "fuzzy", gn = "operator", mn = "pickupPoint", Xn = "shipping", Yn = "delivery-options", Jn = "in-stock", Xe = /* @__PURE__ */ new Set([
939
- dn,
940
- un,
941
- pn,
942
- gn,
943
- mn,
944
- Xn,
945
- Yn,
946
- Jn
947
- ]), Ye = (n) => n.key === "fuzzy" && (n.value === "0" || n.value === "1" || n.value === "auto"), Je = (n) => n.key === "operator" && (n.value === "and" || n.value === "or"), Ke = ({
948
- account: n,
949
- environment: e,
938
+ }, ce = "fuzzy", le = "operator", de = "pickupPoint", be = "shipping", De = "delivery-options", Qn = "in-stock", Zn = "trade-policy", et = "region-id", nt = /* @__PURE__ */ new Set([
939
+ Zn,
940
+ et,
941
+ ce,
942
+ le,
943
+ de
944
+ ]), tt = /* @__PURE__ */ new Set([
945
+ "zip-code",
946
+ "pickupPoint",
947
+ "country",
948
+ "coordinates",
949
+ "deliveryZonesHash",
950
+ "pickupPointsHash"
951
+ ]), rt = /* @__PURE__ */ new Set(["productClusterIds"]), we = (e) => encodeURI(decodeURI(e)), it = (e) => encodeURIComponent(
952
+ decodeURIComponent(e).normalize("NFD").replaceAll(/[\u0300-\u036f]/g, "")
953
+ ), at = /^pickup-in-point-(.+)$/;
954
+ function Ke(e) {
955
+ if (!e)
956
+ return {};
957
+ try {
958
+ const t = H(e).vtex_segment;
959
+ if (!t)
960
+ return {};
961
+ const r = Buffer.from(t, "base64").toString("utf-8");
962
+ return JSON.parse(r);
963
+ } catch {
964
+ return {};
965
+ }
966
+ }
967
+ function ot(e) {
968
+ const n = {}, t = {}, r = [];
969
+ for (const i of e.split(";")) {
970
+ const a = i.indexOf("=");
971
+ if (a < 0) continue;
972
+ const o = i.slice(0, a), s = i.slice(a + 1);
973
+ !o || !s || (tt.has(o) ? n[o] = s : rt.has(o) ? t[o] = s : r.push({ key: o, value: s }));
974
+ }
975
+ return { shipping: n, queryParams: t, extraFacets: r };
976
+ }
977
+ function st(e) {
978
+ const n = typeof e.facets == "string" ? e.facets : "", { shipping: t, queryParams: r, extraFacets: i } = ot(n);
979
+ return {
980
+ segmentParams: {
981
+ sc: e.channel,
982
+ regionId: e.regionId,
983
+ country: e.countryCode ?? t.country,
984
+ locale: e.cultureInfo,
985
+ "zip-code": t["zip-code"],
986
+ coordinates: t.coordinates,
987
+ pickupPoint: t.pickupPoint,
988
+ deliveryZonesHash: t.deliveryZonesHash,
989
+ pickupPointHash: t.pickupPointsHash,
990
+ utmSource: e.utm_source ?? void 0,
991
+ utmCampaign: e.utm_campaign ?? void 0,
992
+ utmiCampaign: e.utmi_campaign ?? void 0,
993
+ campaigns: typeof e.campaigns == "string" ? e.campaigns : void 0,
994
+ priceTables: e.priceTables ?? void 0,
995
+ productClusterIds: r.productClusterIds
996
+ },
997
+ extraFacets: i
998
+ };
999
+ }
1000
+ function Qe(e, n) {
1001
+ const t = [
1002
+ ["sc", n.sc],
1003
+ ["regionId", n.regionId],
1004
+ ["country", n.country],
1005
+ ["locale", n.locale],
1006
+ ["zip-code", n["zip-code"]],
1007
+ ["coordinates", n.coordinates],
1008
+ ["pickupPoint", n.pickupPoint],
1009
+ ["deliveryZonesHash", n.deliveryZonesHash],
1010
+ ["pickupPointHash", n.pickupPointHash],
1011
+ ["utmSource", n.utmSource],
1012
+ ["utmCampaign", n.utmCampaign],
1013
+ ["utmiCampaign", n.utmiCampaign],
1014
+ ["campaigns", n.campaigns],
1015
+ ["priceTables", n.priceTables],
1016
+ ["productClusterId", n.productClusterIds]
1017
+ ];
1018
+ for (const [r, i] of t)
1019
+ i != null && i !== "" && e.append(r, String(i));
1020
+ }
1021
+ function Ze(e) {
1022
+ return at.exec(e)?.[1];
1023
+ }
1024
+ function ct(e) {
1025
+ const n = e.find((r) => r.key === "shipping"), t = n ? Ze(n.value) : void 0;
1026
+ if (t !== void 0)
1027
+ try {
1028
+ return decodeURIComponent(t);
1029
+ } catch {
1030
+ return t;
1031
+ }
1032
+ }
1033
+ function lt(e, n) {
1034
+ const t = ct(
1035
+ n
1036
+ );
1037
+ return t === void 0 ? e : {
1038
+ ...e,
1039
+ pickupPoint: t
1040
+ };
1041
+ }
1042
+ function dt(e) {
1043
+ return e.map((n) => n.key !== "shipping" || Ze(n.value) === void 0 ? n : { ...n, value: "pickup-in-point" });
1044
+ }
1045
+ function ut(e, n) {
1046
+ let t = [...e];
1047
+ const r = t.some((i) => i.key === "shipping");
1048
+ for (const i of n)
1049
+ (!r || i.key !== "shipping") && t.push(i);
1050
+ return t.some((i) => i.key === "shipping" && i.value === "ignore") && (t = t.filter((i) => i.key !== "shipping")), dt(t);
1051
+ }
1052
+ function pt(e) {
1053
+ return e.reduce((n, t) => {
1054
+ let { key: r, value: i } = t;
1055
+ return r === "priceRange" && (r = "price", i = i.replace(" TO ", ":")), r === "ft" ? n : `${n}${we(r)}/${it(we(i)).replaceAll(/ |%20/g, "-")}/`;
1056
+ }, "");
1057
+ }
1058
+ const gt = (e) => e.key === "fuzzy" && (e.value === "0" || e.value === "1" || e.value === "auto"), mt = (e) => e.key === "operator" && (e.value === "and" || e.value === "or");
1059
+ function ht(e, n) {
1060
+ const { segmentParams: t, extraFacets: r } = st(e ?? {}), i = n?.salesChannel ?? t.sc, a = n?.regionId ?? t.regionId, o = n?.locale ?? t.locale ?? "";
1061
+ return {
1062
+ segmentParams: {
1063
+ ...t,
1064
+ ...i ? { sc: i } : {},
1065
+ ...a ? { regionId: a } : {},
1066
+ locale: o
1067
+ },
1068
+ extraFacets: r
1069
+ };
1070
+ }
1071
+ function ft(e, n) {
1072
+ const t = e.filter(({ key: l }) => !nt.has(l)), r = e.find(
1073
+ ({ key: l, value: d }) => l === be && d !== "all-delivery-methods"
1074
+ ) ?? null, i = e.find(
1075
+ ({ key: l, value: d }) => l === De && d !== "all-delivery-options"
1076
+ ) ?? null, a = [...t], o = a.some(
1077
+ ({ key: l }) => l === be
1078
+ ), s = a.some(
1079
+ ({ key: l }) => l === De
1080
+ );
1081
+ return r !== null && !o && a.push(r), i !== null && !s && a.push(i), ut(a, n);
1082
+ }
1083
+ function St(e, n) {
1084
+ const t = e.find(({ key: a }) => a === ce) ?? null, r = e.find(({ key: a }) => a === le) ?? null, i = e.find(({ key: a }) => a === de) ?? null;
1085
+ t && gt(t) && n.append(ce, t.value), r && mt(r) && n.append(le, r.value), i && n.append(de, i.value);
1086
+ }
1087
+ function Pe(e, n, t, r) {
1088
+ const {
1089
+ query: i = "",
1090
+ page: a,
1091
+ count: o,
1092
+ sort: s,
1093
+ selectedFacets: l = [],
1094
+ showInvisibleItems: d,
1095
+ sponsoredCount: g,
1096
+ hideUnavailableItems: p,
1097
+ allowRedirect: c = !1
1098
+ } = e, u = new URLSearchParams();
1099
+ if (r.includePagination && a !== void 0 && o !== void 0) {
1100
+ const f = a * o, I = o === 0 ? f : f + o - 1;
1101
+ u.append("from", f.toString()), u.append("to", I.toString());
1102
+ }
1103
+ i && u.append("query", i), r.includeSort && s && u.append("sort", s);
1104
+ const m = lt(
1105
+ t.segmentParams,
1106
+ l
1107
+ );
1108
+ if (Qe(u, m ?? t.segmentParams), St(l, u), d && u.append("show-invisible-items", "true"), n?.hideUnavailableItems !== void 0) {
1109
+ const f = l.find(({ key: D }) => D === Qn), I = f ? f.value : p?.toString() ?? n.hideUnavailableItems.toString();
1110
+ u.append("hideUnavailableItems", I);
1111
+ }
1112
+ n?.simulationBehavior !== void 0 && u.append("simulationBehavior", n.simulationBehavior.toString()), n?.showSponsored !== void 0 && u.append("showSponsored", n.showSponsored.toString()), g !== void 0 && u.append("sponsoredCount", g.toString()), c !== void 0 && u.append("allowRedirect", c.toString());
1113
+ const S = pt(
1114
+ ft(l, t.extraFacets)
1115
+ );
1116
+ return { params: u, path: S };
1117
+ }
1118
+ function yt(e, n) {
1119
+ const { field: t, value: r, hideUnavailableItems: i, showInvisibleItems: a } = e, o = new URLSearchParams({
1120
+ field: t ?? "",
1121
+ value: r ?? ""
1122
+ });
1123
+ return Qe(o, n), i && o.append("hideUnavailableItems", "true"), a && o.append("show-invisible-items", "true"), o;
1124
+ }
1125
+ function W(e, n) {
1126
+ return {
1127
+ path: e,
1128
+ params: n,
1129
+ toString() {
1130
+ const t = n.toString();
1131
+ return e ? t ? `${e}?${t}` : e : t ? `?${t}` : "";
1132
+ }
1133
+ };
1134
+ }
1135
+ function G(e) {
1136
+ const { endpoint: n, segment: t, defaults: r, args: i = {} } = e, a = ht(t, r);
1137
+ switch (n) {
1138
+ case "product-search":
1139
+ case "facets": {
1140
+ const { params: o, path: s } = Pe(
1141
+ i,
1142
+ r,
1143
+ a,
1144
+ { includePagination: !0, includeSort: !0 }
1145
+ );
1146
+ return W(s, o);
1147
+ }
1148
+ case "catalog-count": {
1149
+ const { params: o, path: s } = Pe(
1150
+ i,
1151
+ r,
1152
+ a,
1153
+ { includePagination: !1, includeSort: !1 }
1154
+ );
1155
+ return W(s, o);
1156
+ }
1157
+ case "products": {
1158
+ const o = yt(i, a.segmentParams);
1159
+ return W("", o);
1160
+ }
1161
+ case "search-suggestions": {
1162
+ const o = new URLSearchParams({
1163
+ query: i.query?.toString() ?? "",
1164
+ locale: r?.locale ?? a.segmentParams.locale ?? ""
1165
+ });
1166
+ return W("", o);
1167
+ }
1168
+ case "top-searches": {
1169
+ const o = new URLSearchParams({
1170
+ locale: r?.locale ?? a.segmentParams.locale ?? ""
1171
+ });
1172
+ return W("", o);
1173
+ }
1174
+ default: {
1175
+ const o = n;
1176
+ throw new Error(`Unknown intelligent-search endpoint: ${o}`);
1177
+ }
1178
+ }
1179
+ }
1180
+ const It = 10;
1181
+ function vt(e) {
1182
+ const { regionId: n, seller: t } = e.storage.channel;
1183
+ return (t ? Buffer.from(`SW#${t}`).toString("base64") : void 0) ?? (n || void 0);
1184
+ }
1185
+ function Ot(e) {
1186
+ return Ke(e.headers?.cookie).cultureInfo ?? e.storage.locale;
1187
+ }
1188
+ const Ct = ({
1189
+ account: e,
1190
+ environment: n,
950
1191
  hideUnavailableItems: t,
951
1192
  simulationBehavior: r,
952
1193
  showSponsored: i,
953
1194
  subDomainPrefix: a
954
- }, c) => {
955
- const s = `https://${n}.${e}.com.br/api/io`, l = Hn(c), d = new Headers(c.headers).get("x-forwarded-host") ?? c.headers?.host ?? "", g = a && a.map((h) => h + ".").find((h) => d.includes(h)) || "", u = d.replace(g, ""), o = l({
1195
+ }, o) => {
1196
+ const s = `https://${e}.${n}.com.br`, l = Je(o), d = Ke(o.headers?.cookie), g = () => ({
1197
+ salesChannel: o.storage.channel.salesChannel,
1198
+ regionId: vt(o),
1199
+ locale: Ot(o),
1200
+ hideUnavailableItems: t,
1201
+ simulationBehavior: r,
1202
+ showSponsored: i
1203
+ }), p = new Headers(o.headers).get("x-forwarded-host") ?? o.headers?.host ?? "", c = a && a.map((h) => h + ".").find((h) => p.includes(h)) || "", u = p.replace(c, ""), m = l({
956
1204
  "content-type": "application/json",
957
1205
  "X-FORWARDED-HOST": u
958
- }), p = () => {
959
- const { salesChannel: h } = c.storage.channel;
960
- return h ? {
961
- key: dn,
962
- value: h
963
- } : null;
964
- }, m = () => {
965
- const { regionId: h, seller: v } = c.storage.channel, D = (v ? Buffer.from(`SW#${v}`).toString("base64") : null) ?? h;
966
- return D ? {
967
- key: un,
968
- value: D
969
- } : null;
970
- }, S = (h) => {
971
- const v = h.filter(
972
- ({ key: T }) => !Xe.has(T)
973
- ), C = h.find(
974
- ({ key: T, value: F }) => T === Xn && F !== "all-delivery-methods"
975
- ) ?? null, D = h.find(
976
- ({ key: T, value: F }) => T === Yn && F !== "all-delivery-options"
977
- ) ?? null, y = h.find(({ key: T }) => T === dn) ?? p(), A = h.find(({ key: T }) => T === un) ?? m();
978
- return C !== null && v.push(C), D !== null && v.push(D), y !== null && v.push(y), A !== null && v.push(A), v;
979
- }, I = (h, v) => {
980
- const C = h.find(({ key: A }) => A === pn) ?? null, D = h.find(({ key: A }) => A === gn) ?? null, y = h.find(({ key: A }) => A === mn) ?? null;
981
- C && Ye(C) && v.append(pn, C.value), D && Je(D) && v.append(gn, D.value), y && v.append(mn, y.value);
982
- }, O = ({
983
- query: h = "",
984
- page: v,
985
- count: C,
986
- sort: D = "",
987
- selectedFacets: y = [],
988
- type: A,
989
- showInvisibleItems: T,
990
- sponsoredCount: F,
991
- hideUnavailableItems: U,
992
- allowRedirect: G = !1
1206
+ }), S = ({ type: h, ...b }) => {
1207
+ const C = h === "facets" ? "facets" : "product-search", A = G({
1208
+ endpoint: C,
1209
+ segment: d,
1210
+ defaults: g(),
1211
+ args: b
1212
+ });
1213
+ return y(
1214
+ `${s}/api/intelligent-search/v1/${C}/${A.path}?${A.params.toString()}`,
1215
+ { headers: m }
1216
+ );
1217
+ }, f = (h) => S({ ...h, type: "product_search" }), I = ({
1218
+ field: h,
1219
+ value: b,
1220
+ hideUnavailableItems: C,
1221
+ showInvisibleItems: A
993
1222
  }) => {
994
- const N = new URLSearchParams({
995
- page: (v + 1).toString(),
996
- count: C !== 0 ? C.toString() : "1",
997
- query: h,
998
- sort: D,
999
- locale: c.storage.locale
1223
+ const v = G({
1224
+ endpoint: "products",
1225
+ segment: d,
1226
+ defaults: g(),
1227
+ args: {
1228
+ field: h,
1229
+ value: b,
1230
+ hideUnavailableItems: C,
1231
+ showInvisibleItems: A
1232
+ }
1000
1233
  });
1001
- if (I(y, N), T && N.append("show-invisible-items", "true"), t !== void 0) {
1002
- const x = y.find(
1003
- ({ key: me }) => me === Jn
1004
- ), on = x ? x.value : U?.toString() ?? t.toString();
1005
- N.append("hideUnavailableItems", on);
1006
- }
1007
- r !== void 0 && N.append("simulationBehavior", r.toString()), i !== void 0 && N.append("showSponsored", i.toString()), F !== void 0 && N.append("sponsoredCount", F.toString()), G !== void 0 && N.append("allowRedirect", G.toString());
1008
- const $ = S(y).map(({ key: x, value: on }) => `${x}/${on}`).join("/");
1009
- return f(
1010
- `${s}/_v/api/intelligent-search/${A}/${$}?${N.toString()}`,
1011
- { headers: o }
1234
+ return y(
1235
+ `${s}/api/intelligent-search/v1/products?${v.params.toString()}`,
1236
+ { headers: m }
1012
1237
  );
1013
1238
  };
1014
1239
  return {
1015
- facets: (h) => O({ ...h, type: "facets" }),
1016
- products: (h) => O({ ...h, type: "product_search" }),
1240
+ facets: (h) => S({ ...h, type: "facets" }),
1241
+ products: f,
1242
+ fetchProduct: I,
1243
+ productsByIdentifier: async ({
1244
+ field: h,
1245
+ values: b,
1246
+ showInvisibleItems: C,
1247
+ hideUnavailableItems: A
1248
+ }) => {
1249
+ const v = ye(It);
1250
+ return (await Promise.all(
1251
+ b.map(
1252
+ (_) => v(async () => {
1253
+ try {
1254
+ return await I({
1255
+ field: h,
1256
+ value: _,
1257
+ hideUnavailableItems: A,
1258
+ showInvisibleItems: C
1259
+ });
1260
+ } catch {
1261
+ return null;
1262
+ }
1263
+ })
1264
+ )
1265
+ )).filter(
1266
+ (_) => _ !== null
1267
+ );
1268
+ },
1017
1269
  suggestedTerms: (h) => {
1018
- const v = new URLSearchParams({
1019
- query: h.query?.toString() ?? "",
1020
- locale: c.storage.locale
1270
+ const b = G({
1271
+ endpoint: "search-suggestions",
1272
+ segment: d,
1273
+ defaults: g(),
1274
+ args: { query: h.query }
1021
1275
  });
1022
- return f(
1023
- `${s}/_v/api/intelligent-search/search_suggestions?${v.toString()}`,
1024
- { headers: o }
1276
+ return y(
1277
+ `${s}/api/intelligent-search/v1/search-suggestions?${b.params.toString()}`,
1278
+ { headers: m }
1025
1279
  );
1026
1280
  },
1027
1281
  topSearches: () => {
1028
- const h = new URLSearchParams({
1029
- locale: c.storage.locale
1282
+ const h = G({
1283
+ endpoint: "top-searches",
1284
+ segment: d,
1285
+ defaults: g()
1030
1286
  });
1031
- return f(
1032
- `${s}/_v/api/intelligent-search/top_searches?${h.toString()}`,
1033
- { headers: o }
1287
+ return y(
1288
+ `${s}/api/intelligent-search/v1/top-searches?${h.params.toString()}`,
1289
+ { headers: m }
1034
1290
  );
1035
1291
  },
1036
1292
  productCount: (h) => {
1037
- const v = new URLSearchParams();
1038
- return h?.query && v.append("query", h.query.toString()), f(
1039
- `${s}/_v/api/intelligent-search/catalog_count?${v.toString()}`,
1040
- { headers: o }
1293
+ const b = G({
1294
+ endpoint: "catalog-count",
1295
+ segment: d,
1296
+ defaults: g(),
1297
+ args: h
1298
+ });
1299
+ return y(
1300
+ `${s}/api/intelligent-search/v1/catalog-count/${b.path}?${b.params.toString()}`,
1301
+ { headers: m }
1041
1302
  );
1042
1303
  }
1043
1304
  };
1044
- }, Qe = (n, e) => {
1045
- const t = Ke(n, e), r = He(n, e);
1305
+ }, bt = (e, n) => {
1306
+ const t = Ct(e, n), r = Kn(e, n);
1046
1307
  return {
1047
1308
  search: t,
1048
1309
  commerce: r
1049
1310
  };
1050
- }, Ze = 20, nt = /* @__PURE__ */ new Set([
1311
+ }, Dt = 20, wt = /* @__PURE__ */ new Set([
1051
1312
  "brand",
1052
1313
  "category",
1053
1314
  "department",
1054
1315
  "subcategory",
1055
1316
  "collection",
1056
1317
  "cluster"
1057
- ]), j = (n) => typeof n.pageType == "string" && nt.has(n.pageType.toLowerCase()), et = (n, e) => {
1058
- const t = jn(Ze), r = async (i) => Promise.all(
1318
+ ]), z = (e) => typeof e.pageType == "string" && wt.has(e.pageType.toLowerCase()), Pt = (e, n) => {
1319
+ const t = ye(Dt), r = async (i) => Promise.all(
1059
1320
  i.map(
1060
1321
  (a) => t(async () => {
1061
- const c = await e.commerce.catalog.portal.pagetype(a);
1062
- if (j(c))
1063
- return c;
1064
- throw new z(
1065
- `Catalog returned ${c.pageType} for slug: ${a}. This usually happens when there is more than one category with the same name in the same category tree level.`
1322
+ const o = await n.commerce.catalog.portal.pagetype(a);
1323
+ if (z(o))
1324
+ return o;
1325
+ throw new B(
1326
+ `Catalog returned ${o.pageType} for slug: ${a}. This usually happens when there is more than one category with the same name in the same category tree level.`
1066
1327
  );
1067
1328
  })
1068
1329
  )
1069
1330
  );
1070
- return new rn(r, {
1331
+ return new te(r, {
1071
1332
  // DataLoader is being used to cache requests, not to batch them
1072
1333
  batch: !1
1073
1334
  });
1074
- }, tt = (n, e) => {
1075
- const t = async (r) => Promise.all(r.map((i) => e.commerce.catalog.salesChannel(i)));
1076
- return new rn(t);
1077
- }, rt = 1, it = (n, e) => {
1078
- const t = jn(rt), r = async (a) => {
1079
- const c = a.reduce((u, { items: o }) => [...u, o], []), s = [...c.flat()], l = await e.commerce.checkout.simulation({
1335
+ }, At = (e, n) => {
1336
+ const t = async (r) => Promise.all(r.map((i) => n.commerce.catalog.salesChannel(i)));
1337
+ return new te(t);
1338
+ }, Et = 1, Ut = (e, n) => {
1339
+ const t = ye(Et), r = async (a) => {
1340
+ const o = a.reduce((p, { items: c }) => [...p, c], []), s = [...o.flat()], l = await n.commerce.checkout.simulation({
1080
1341
  country: a[0].country,
1081
1342
  postalCode: a[0].postalCode,
1082
1343
  items: s
1083
1344
  }), d = l.items.reduce(
1084
- (u, o) => {
1085
- const p = o.requestIndex;
1086
- return typeof p == "number" && p < u.length && (u[p] = o), u;
1345
+ (p, c) => {
1346
+ const u = c.requestIndex;
1347
+ return typeof u == "number" && u < p.length && (p[u] = c), p;
1087
1348
  },
1088
1349
  Array(s.length).fill(null)
1089
- ), g = c.reduce(
1090
- (u, o) => [...u, o.length + u[u.length - 1]],
1350
+ ), g = o.reduce(
1351
+ (p, c) => [...p, c.length + p[p.length - 1]],
1091
1352
  [0]
1092
1353
  );
1093
- return c.map((u, o) => ({
1354
+ return o.map((p, c) => ({
1094
1355
  ...l,
1095
- items: d.slice(g[o], g[o + 1]).filter((p) => !!p)
1356
+ items: d.slice(g[c], g[c + 1]).filter((u) => !!u)
1096
1357
  }));
1097
1358
  }, i = async (a) => t(r, a);
1098
- return new rn(i, {
1359
+ return new te(i, {
1099
1360
  maxBatchSize: 50
1100
1361
  });
1101
- }, at = (n, e) => Ce(n, e);
1102
- function ot(n) {
1362
+ }, Tt = (e, n) => An(e, n);
1363
+ function kt(e) {
1103
1364
  return {
1104
- ...n,
1105
- description: n.description ? at(n.description) : n.description
1365
+ ...e,
1366
+ description: e.description ? Tt(e.description) : e.description
1106
1367
  };
1107
1368
  }
1108
- const B = (n, e) => ({
1109
- ...n,
1110
- isVariantOf: ot(e)
1111
- }), st = ({ flags: n }, e) => {
1369
+ const L = (e, n) => ({
1370
+ ...e,
1371
+ isVariantOf: kt(n)
1372
+ }), _t = ({ flags: e }, n) => {
1112
1373
  const t = async (r) => {
1113
1374
  const i = r.map((g) => g.split("-")[0]), a = r.some(
1114
1375
  (g) => g.split("-")[1] === "invisibleItems"
1115
- ), { products: c } = await e.search.products({
1116
- query: `sku:${i.join(";")}`,
1117
- page: 0,
1118
- count: i.length,
1376
+ ), s = (await n.search.productsByIdentifier({
1377
+ field: "sku",
1378
+ values: i,
1119
1379
  showInvisibleItems: a,
1120
- ...n?.enableUnavailableItemsOnCart && {
1380
+ ...e?.enableUnavailableItemsOnCart && {
1121
1381
  hideUnavailableItems: !1
1122
1382
  }
1123
- }), s = c.reduce(
1124
- (g, u) => {
1125
- for (const o of u.items)
1126
- g[o.itemId] = B(o, u);
1383
+ })).reduce(
1384
+ (g, p) => {
1385
+ for (const c of p.items)
1386
+ g[c.itemId] = L(c, p);
1127
1387
  return g;
1128
1388
  },
1129
1389
  {}
1130
1390
  ), l = i.map((g) => s[g]), d = i.filter((g) => !s[g]);
1131
1391
  if (d.length > 0)
1132
- throw new z(
1392
+ throw new B(
1133
1393
  `Search API did not found the following skus: ${d.join(",")}`
1134
1394
  );
1135
1395
  return l;
1136
1396
  };
1137
- return new rn(t, {
1397
+ return new te(t, {
1138
1398
  maxBatchSize: 99
1139
1399
  // Max allowed batch size of Search API
1140
1400
  });
1141
- }, ct = (n, { clients: e }) => {
1142
- const t = st(n, e), r = it(n, e), i = et(n, e), a = tt(n, e);
1401
+ }, Ft = (e, { clients: n }) => {
1402
+ const t = _t(e, n), r = Ut(e, n), i = Pt(e, n), a = At(e, n);
1143
1403
  return {
1144
1404
  skuLoader: t,
1145
1405
  simulationLoader: r,
1146
1406
  collectionLoader: i,
1147
1407
  salesChannelLoader: a
1148
1408
  };
1149
- }, V = (n) => n.AvailableQuantity > 0, W = (n) => n.spotPrice ?? 0, lt = (n) => n.Price ?? 0, wn = (n) => n ? "https://schema.org/InStock" : "https://schema.org/OutOfStock", Kn = (n, e) => V(n) && !V(e) ? -1 : !V(n) && V(e) ? 1 : W(n) - W(e), dt = (n) => n === "available", q = (n, e = 0, t = 1) => {
1150
- const r = e / t;
1151
- return Math.round((n + r) * 100) / 100;
1152
- }, ut = (n, e = { includeTaxes: !1 }) => {
1153
- const t = n.filter(V), r = t[t.length - 1], i = r ? W(r) : 0;
1154
- return e.includeTaxes ? q(i, r?.Tax, r?.product?.unitMultiplier) : i;
1155
- }, An = (n, e = { includeTaxes: !1 }) => {
1156
- const [t] = n.filter(V), r = t ? W(t) : 0;
1157
- return e.includeTaxes ? q(r, t?.Tax, t?.product?.unitMultiplier) : r;
1158
- }, pt = {
1159
- highPrice: (n) => ut(n),
1160
- lowPrice: (n) => An(n),
1161
- lowPriceWithTaxes: (n) => An(n, { includeTaxes: !0 }),
1162
- offerCount: (n) => n.length,
1163
- priceCurrency: async (n, e, t) => {
1409
+ }, M = (e) => e.AvailableQuantity > 0, V = (e) => e.spotPrice ?? 0, Rt = (e) => e.Price ?? 0, Ae = (e) => e ? "https://schema.org/InStock" : "https://schema.org/OutOfStock", en = (e, n) => M(e) && !M(n) ? -1 : !M(e) && M(n) ? 1 : V(e) - V(n), Nt = (e) => e === "available", $ = (e, n = 0, t = 1) => {
1410
+ const r = n / t;
1411
+ return Math.round((e + r) * 100) / 100;
1412
+ }, Lt = (e, n = { includeTaxes: !1 }) => {
1413
+ const t = e.filter(M), r = t[t.length - 1], i = r ? V(r) : 0;
1414
+ return n.includeTaxes ? $(i, r?.Tax, r?.product?.unitMultiplier) : i;
1415
+ }, Ee = (e, n = { includeTaxes: !1 }) => {
1416
+ const [t] = e.filter(M), r = t ? V(t) : 0;
1417
+ return n.includeTaxes ? $(r, t?.Tax, t?.product?.unitMultiplier) : r;
1418
+ }, Bt = {
1419
+ highPrice: (e) => Lt(e),
1420
+ lowPrice: (e) => Ee(e),
1421
+ lowPriceWithTaxes: (e) => Ee(e, { includeTaxes: !0 }),
1422
+ offerCount: (e) => e.length,
1423
+ priceCurrency: async (e, n, t) => {
1164
1424
  const {
1165
1425
  loaders: { salesChannelLoader: r },
1166
1426
  storage: { channel: i }
1167
1427
  } = t;
1168
1428
  return (await r.load(i.salesChannel)).CurrencyCode ?? "";
1169
1429
  },
1170
- offers: (n) => n
1171
- }, gt = {
1430
+ offers: (e) => e
1431
+ }, Mt = {
1172
1432
  ratingValue: () => 5,
1173
1433
  reviewCount: () => 0
1174
- }, Pn = "ÁÄÂÀÃÅČÇĆĎÉĚËÈÊẼĔȆÍÌÎÏŇÑÓÖÒÔÕØŘŔŠŤÚŮÜÙÛÝŸŽáäâàãåčçćďéěëèêẽĕȇíìîïňñóöòôõøðřŕšťúůüùûýÿžþÞĐđ߯a", mt = "AAAAAACCCDEEEEEEEEIIIINNOOOOOORRSTUUUUUYYZaaaaaacccdeeeeeeeeiiiinnooooooorrstuuuuuyyzbBDdBAa", ht = (n) => {
1175
- let e = n.slice(0);
1176
- for (let t = 0; t < Pn.length; t++)
1177
- e = e.replace(new RegExp(Pn.charAt(t), "g"), mt.charAt(t));
1178
- return e;
1179
- }, ft = (n) => n.replace(/[·/_,:]/, "-");
1180
- function Qn(n) {
1181
- const t = n.replace(/,/g, "").replace(/[*+~.()'"!:@&\[\]`/ %$#?{}><=_^]/g, "-");
1182
- return ft(ht(t)).toLowerCase();
1183
- }
1184
- const K = (n) => n.type === "brand" || j(n) && n.pageType.toLowerCase() === "brand", hn = (n) => j(n) && n.pageType.toLowerCase() === "collection", sn = (n) => K(n) || hn(n) ? Qn(n.name) : j(n) ? new URL(`https://${n.url}`).pathname.slice(1).toLowerCase() : new URL(n.url).pathname.slice(1).toLowerCase(), Zn = {
1185
- id: ({ id: n }) => n.toString(),
1186
- slug: (n) => sn(n),
1187
- seo: (n) => K(n) || j(n) ? {
1188
- title: n.title ?? n.name,
1189
- description: n.metaTagDescription
1434
+ }, Ue = "ÁÄÂÀÃÅČÇĆĎÉĚËÈÊẼĔȆÍÌÎÏŇÑÓÖÒÔÕØŘŔŠŤÚŮÜÙÛÝŸŽáäâàãåčçćďéěëèêẽĕȇíìîïňñóöòôõøðřŕšťúůüùûýÿžþÞĐđ߯a", $t = "AAAAAACCCDEEEEEEEEIIIINNOOOOOORRSTUUUUUYYZaaaaaacccdeeeeeeeeiiiinnooooooorrstuuuuuyyzbBDdBAa", zt = (e) => {
1435
+ let n = e.slice(0);
1436
+ for (let t = 0; t < Ue.length; t++)
1437
+ n = n.replace(new RegExp(Ue.charAt(t), "g"), $t.charAt(t));
1438
+ return n;
1439
+ }, Vt = (e) => e.replace(/[·/_,:]/, "-");
1440
+ function nn(e) {
1441
+ const t = e.replace(/,/g, "").replace(/[*+~.()'"!:@&\[\]`/ %$#?{}><=_^]/g, "-");
1442
+ return Vt(zt(t)).toLowerCase();
1443
+ }
1444
+ const K = (e) => e.type === "brand" || z(e) && e.pageType.toLowerCase() === "brand", ue = (e) => z(e) && e.pageType.toLowerCase() === "collection", ae = (e) => K(e) || ue(e) ? nn(e.name) : z(e) ? new URL(`https://${e.url}`).pathname.slice(1).toLowerCase() : new URL(e.url).pathname.slice(1).toLowerCase(), tn = {
1445
+ id: ({ id: e }) => e.toString(),
1446
+ slug: (e) => ae(e),
1447
+ seo: (e) => K(e) || z(e) ? {
1448
+ title: e.title ?? e.name,
1449
+ description: e.metaTagDescription
1190
1450
  } : {
1191
- title: n.Title,
1192
- description: n.MetaTagDescription
1451
+ title: e.Title,
1452
+ description: e.MetaTagDescription
1193
1453
  },
1194
- type: (n) => K(n) ? "Brand" : j(n) ? n.pageType : n.level === 0 ? "Department" : "Category",
1195
- meta: (n) => {
1196
- const e = sn(n);
1197
- return K(n) ? {
1198
- selectedFacets: [{ key: "brand", value: e }]
1199
- } : hn(n) ? {
1200
- selectedFacets: [{ key: "productclusterids", value: n.id }]
1454
+ type: (e) => K(e) ? "Brand" : z(e) ? e.pageType : e.level === 0 ? "Department" : "Category",
1455
+ meta: (e) => {
1456
+ const n = ae(e);
1457
+ return K(e) ? {
1458
+ selectedFacets: [{ key: "brand", value: n }]
1459
+ } : ue(e) ? {
1460
+ selectedFacets: [{ key: "productclusterids", value: e.id }]
1201
1461
  } : {
1202
- selectedFacets: e.split("/").map((t, r) => ({
1462
+ selectedFacets: n.split("/").map((t, r) => ({
1203
1463
  key: `category-${r + 1}`,
1204
1464
  value: t
1205
1465
  }))
1206
1466
  };
1207
1467
  },
1208
- breadcrumbList: async (n, e, t) => {
1468
+ breadcrumbList: async (e, n, t) => {
1209
1469
  const {
1210
1470
  loaders: { collectionLoader: r }
1211
- } = t, a = sn(n).split("/").filter((l) => !!l), c = a.map(
1471
+ } = t, a = ae(e).split("/").filter((l) => !!l), o = a.map(
1212
1472
  (l, d) => a.slice(0, d + 1).join("/")
1213
1473
  ), s = await Promise.all(
1214
- c.map(async (l) => {
1474
+ o.map(async (l) => {
1215
1475
  const d = await r.load(l);
1216
1476
  return { slug: l, ...d };
1217
1477
  })
1218
1478
  );
1219
1479
  return {
1220
1480
  itemListElement: s.map((l, d) => ({
1221
- item: hn(l) ? `/${l.slug}` : new URL(
1481
+ item: ue(l) ? `/${l.slug}` : new URL(
1222
1482
  `https://${l.url}`
1223
1483
  ).pathname.toLowerCase(),
1224
1484
  name: l.name,
@@ -1227,17 +1487,17 @@ const K = (n) => n.type === "brand" || j(n) && n.pageType.toLowerCase() === "bra
1227
1487
  numberOfItems: s.length
1228
1488
  };
1229
1489
  }
1230
- }, ne = {
1490
+ }, rn = {
1231
1491
  buy: "whoboughtalsobought",
1232
1492
  view: "whosawalsosaw",
1233
1493
  similars: "similars",
1234
1494
  viewAndBought: "whosawalsobought",
1235
1495
  accessories: "accessories",
1236
1496
  suggestions: "suggestions"
1237
- }, En = ({ key: n, value: e }) => {
1238
- switch (n) {
1497
+ }, Te = ({ key: e, value: n }) => {
1498
+ switch (e) {
1239
1499
  case "price":
1240
- return { key: n, value: e.replace("-to-", ":") };
1500
+ return { key: e, value: n.replace("-to-", ":") };
1241
1501
  case "channel":
1242
1502
  case "locale":
1243
1503
  case "buy":
@@ -1248,124 +1508,124 @@ const K = (n) => n.type === "brand" || j(n) && n.pageType.toLowerCase() === "bra
1248
1508
  case "suggestions":
1249
1509
  return [];
1250
1510
  default:
1251
- return { key: n, value: e };
1511
+ return { key: e, value: n };
1252
1512
  }
1253
- }, Tn = (n) => {
1254
- const e = n.split(":").map(Number);
1255
- return e.length !== 2 || Number.isNaN(e[0]) || Number.isNaN(e[1]) ? null : e;
1256
- }, St = (n) => typeof ne[n] == "string", yt = (n) => {
1257
- const e = n?.filter(
1258
- (t) => St(t.key)
1513
+ }, ke = (e) => {
1514
+ const n = e.split(":").map(Number);
1515
+ return n.length !== 2 || Number.isNaN(n[0]) || Number.isNaN(n[1]) ? null : n;
1516
+ }, xt = (e) => typeof rn[e] == "string", qt = (e) => {
1517
+ const n = e?.filter(
1518
+ (t) => xt(t.key)
1259
1519
  );
1260
- if (Array.isArray(e) && e.length > 1)
1261
- throw new k(
1262
- `You passed ${e.length} cross selling facets but only one is allowed. Please leave one of the following facet: ${e.map((t) => t.key).join(",")}`
1520
+ if (Array.isArray(n) && n.length > 1)
1521
+ throw new U(
1522
+ `You passed ${n.length} cross selling facets but only one is allowed. Please leave one of the following facet: ${n.map((t) => t.key).join(",")}`
1263
1523
  );
1264
- return e?.[0] ?? null;
1265
- }, It = (n) => n?.find((e) => e.key === "slug")?.value ?? null, vt = (n) => n?.find((e) => e.key === "id")?.value ?? null, _n = (n) => n?.find((e) => e.key === "locale")?.value ?? null, Un = (n) => n?.find((e) => e.key === "channel")?.value ?? null, fn = (n, e) => {
1524
+ return n?.[0] ?? null;
1525
+ }, jt = (e) => e?.find((n) => n.key === "slug")?.value ?? null, Wt = (e) => e?.find((n) => n.key === "id")?.value ?? null, _e = (e) => e?.find((n) => n.key === "locale")?.value ?? null, Fe = (e) => e?.find((n) => n.key === "channel")?.value ?? null, pe = (e, n) => {
1266
1526
  let t = 0;
1267
- for (let r = 1; r < n.length; r++)
1268
- e(n[t], n[r]) > 0 && (t = r);
1269
- return n[t];
1270
- }, Ot = {
1271
- __resolveType: ({ type: n, values: e }) => n !== "TEXT" && n !== "DELIVERY" ? "StoreFacetRange" : !e || e.length === 0 ? "StoreFacetBoolean" : e.every((t) => t.range) ? "StoreFacetRange" : "StoreFacetBoolean"
1272
- }, Ct = {
1273
- key: ({ key: n }) => n,
1274
- label: ({ name: n }) => n,
1275
- values: ({ values: n }) => n.sort((e, t) => e.name.localeCompare(t.name))
1276
- }, bt = {
1277
- key: ({ key: n }) => n,
1278
- label: ({ name: n }) => n,
1279
- min: ({ values: n, key: e }, t, { storage: { searchArgs: r } }) => {
1280
- const i = Tn(
1281
- r?.selectedFacets?.find((s) => s.key === e)?.value ?? ""
1282
- ), c = fn(n, (s, l) => s.range.from - l.range.from)?.range?.from ?? 0;
1527
+ for (let r = 1; r < e.length; r++)
1528
+ n(e[t], e[r]) > 0 && (t = r);
1529
+ return e[t];
1530
+ }, Gt = {
1531
+ __resolveType: ({ type: e, values: n }) => e !== "TEXT" && e !== "DELIVERY" ? "StoreFacetRange" : !n || n.length === 0 ? "StoreFacetBoolean" : n.every((t) => t.range) ? "StoreFacetRange" : "StoreFacetBoolean"
1532
+ }, Ht = {
1533
+ key: ({ key: e }) => e,
1534
+ label: ({ name: e }) => e,
1535
+ values: ({ values: e }) => e.sort((n, t) => n.name.localeCompare(t.name))
1536
+ }, Xt = {
1537
+ key: ({ key: e }) => e,
1538
+ label: ({ name: e }) => e,
1539
+ min: ({ values: e, key: n }, t, { storage: { searchArgs: r } }) => {
1540
+ const i = ke(
1541
+ r?.selectedFacets?.find((s) => s.key === n)?.value ?? ""
1542
+ ), o = pe(e, (s, l) => s.range.from - l.range.from)?.range?.from ?? 0;
1283
1543
  return {
1284
- selected: i?.[0] ?? c,
1285
- absolute: c
1544
+ selected: i?.[0] ?? o,
1545
+ absolute: o
1286
1546
  };
1287
1547
  },
1288
- max: ({ values: n, key: e }, t, { storage: { searchArgs: r } }) => {
1289
- const i = Tn(
1290
- r?.selectedFacets?.find((s) => s.key === e)?.value ?? ""
1291
- ), c = fn(n, (s, l) => l.range.to - s.range.to)?.range?.to ?? 0;
1548
+ max: ({ values: e, key: n }, t, { storage: { searchArgs: r } }) => {
1549
+ const i = ke(
1550
+ r?.selectedFacets?.find((s) => s.key === n)?.value ?? ""
1551
+ ), o = pe(e, (s, l) => l.range.to - s.range.to)?.range?.to ?? 0;
1292
1552
  return {
1293
- selected: i?.[1] ?? c,
1294
- absolute: c
1553
+ selected: i?.[1] ?? o,
1554
+ absolute: o
1295
1555
  };
1296
1556
  }
1297
- }, Dt = {
1298
- value: ({ value: n }) => n,
1299
- label: ({ name: n }) => n || "unknown",
1300
- selected: ({ selected: n }) => n,
1301
- quantity: ({ quantity: n }) => n
1302
- }, wt = async (n, { data: e }, { clients: { commerce: t } }) => {
1303
- if (!e?.orderId)
1304
- throw new k("Missing orderId");
1305
- return { data: (await t.checkout.cancelOrder(e))?.data };
1557
+ }, Yt = {
1558
+ value: ({ value: e }) => e,
1559
+ label: ({ name: e }) => e || "unknown",
1560
+ selected: ({ selected: e }) => e,
1561
+ quantity: ({ quantity: e }) => e
1562
+ }, Jt = async (e, { data: n }, { clients: { commerce: t } }) => {
1563
+ if (!n?.orderId)
1564
+ throw new U("Missing orderId");
1565
+ return { data: (await t.checkout.cancelOrder(n))?.data };
1306
1566
  };
1307
- function ee(n) {
1308
- if (!n || n.status !== "pending")
1567
+ function an(e) {
1568
+ if (!e || e.status !== "pending")
1309
1569
  return null;
1310
- for (const e of n.dimensionStatus) {
1311
- if (e.status !== "pending")
1570
+ for (const n of e.dimensionStatus) {
1571
+ if (n.status !== "pending")
1312
1572
  continue;
1313
- const t = e.ruleCollection.find(
1573
+ const t = n.ruleCollection.find(
1314
1574
  (r) => r.status === "pending" && r.isUserNextAuthorizer
1315
1575
  );
1316
1576
  if (t)
1317
1577
  return {
1318
1578
  rule: t,
1319
- orderAuthorizationId: n.id,
1320
- dimensionId: e.id
1579
+ orderAuthorizationId: e.id,
1580
+ dimensionId: n.id
1321
1581
  };
1322
1582
  }
1323
1583
  return null;
1324
1584
  }
1325
- function At(n) {
1326
- if (!n || n.status !== "pending") return !1;
1327
- const e = n.dimensionStatus.filter((t) => t.status === "pending").flatMap((t) => t.ruleCollection).filter((t) => t.status === "pending");
1328
- return e.length === 0 ? !1 : e.every((t) => !t.isUserNextAuthorizer);
1585
+ function Kt(e) {
1586
+ if (!e || e.status !== "pending") return !1;
1587
+ const n = e.dimensionStatus.filter((t) => t.status === "pending").flatMap((t) => t.ruleCollection).filter((t) => t.status === "pending");
1588
+ return n.length === 0 ? !1 : n.every((t) => !t.isUserNextAuthorizer);
1329
1589
  }
1330
- const Pt = async (n, { data: e }, { clients: { commerce: t } }) => {
1331
- const r = await t.oms.processOrderAuthorization(e), i = ee(r);
1590
+ const Qt = async (e, { data: n }, { clients: { commerce: t } }) => {
1591
+ const r = await t.oms.processOrderAuthorization(n), i = an(r);
1332
1592
  return {
1333
- isPendingForOtherAuthorizer: !i && At(r),
1593
+ isPendingForOtherAuthorizer: !i && Kt(r),
1334
1594
  ruleForAuthorization: i
1335
1595
  };
1336
- }, Et = async (n, { data: e }, { clients: { commerce: t } }) => {
1337
- if (!e?.objectKey)
1338
- throw new k("Missing objectKey");
1339
- const r = e.orderFormId || (await t.orderEntry.createOrderForm()).orderFormId;
1596
+ }, Zt = async (e, { data: n }, { clients: { commerce: t } }) => {
1597
+ if (!n?.objectKey)
1598
+ throw new U("Missing objectKey");
1599
+ const r = n.orderFormId || (await t.orderEntry.createOrderForm()).orderFormId;
1340
1600
  return t.orderEntry.startOperation({
1341
- objectKey: e.objectKey,
1601
+ objectKey: n.objectKey,
1342
1602
  orderFormId: r,
1343
- sessionToken: e.sessionToken ?? void 0
1603
+ sessionToken: n.sessionToken ?? void 0
1344
1604
  });
1345
- }, Tt = async (n, { data: e }, { clients: { commerce: t } }) => ({ id: (await t.subscribeToNewsletter(e))?.Id }), _t = async (n, { data: e }, { clients: { commerce: t } }) => {
1346
- const { fileContent: r, fileName: i, mimeType: a } = e;
1605
+ }, er = async (e, { data: n }, { clients: { commerce: t } }) => ({ id: (await t.subscribeToNewsletter(n))?.Id }), nr = async (e, { data: n }, { clients: { commerce: t } }) => {
1606
+ const { fileContent: r, fileName: i, mimeType: a } = n;
1347
1607
  if (!r || !i || !a)
1348
- throw new k(
1608
+ throw new U(
1349
1609
  "Missing required fields: fileContent, fileName, mimeType"
1350
1610
  );
1351
- const c = r.replaceAll(/\s/g, ""), s = 5 * 1024 * 1024;
1352
- if (Math.floor(c.length * 3 / 4) > s)
1353
- throw new k("File exceeds maximum allowed size of 5MB");
1611
+ const o = r.replaceAll(/\s/g, ""), s = 5 * 1024 * 1024;
1612
+ if (Math.floor(o.length * 3 / 4) > s)
1613
+ throw new U("File exceeds maximum allowed size of 5MB");
1354
1614
  if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(
1355
- c
1615
+ o
1356
1616
  ))
1357
- throw new k("Invalid Base64 fileContent");
1358
- const g = Buffer.from(c, "base64");
1617
+ throw new U("Invalid Base64 fileContent");
1618
+ const g = Buffer.from(o, "base64");
1359
1619
  return await t.orderEntry.uploadFile({
1360
1620
  fileBuffer: g,
1361
1621
  fileName: i,
1362
1622
  mimeType: a
1363
1623
  });
1364
1624
  };
1365
- class nn {
1366
- static parse(e) {
1625
+ class ee {
1626
+ static parse(n) {
1367
1627
  try {
1368
- const t = JSON.parse(e);
1628
+ const t = JSON.parse(n);
1369
1629
  return {
1370
1630
  seller: t.seller ?? "",
1371
1631
  regionId: t.regionId ?? "",
@@ -1376,49 +1636,49 @@ class nn {
1376
1636
  throw console.error(t), new Error("Malformed channel string");
1377
1637
  }
1378
1638
  }
1379
- static stringify(e) {
1380
- return JSON.stringify(e);
1639
+ static stringify(n) {
1640
+ return JSON.stringify(n);
1381
1641
  }
1382
1642
  }
1383
- const Sn = (n, e) => {
1384
- n.storage.channel = nn.parse(e);
1385
- }, yn = (n, e) => {
1386
- n.storage.locale = e;
1387
- }, te = (n) => be.createHash("md5").update(n).digest("hex"), Y = {
1643
+ const ge = (e, n) => {
1644
+ e.storage.channel = ee.parse(n);
1645
+ }, me = (e, n) => {
1646
+ e.storage.locale = n;
1647
+ }, on = (e) => En.createHash("md5").update(e).digest("hex"), Y = {
1388
1648
  attachment: "ATTACHMENT",
1389
1649
  specification: "SPECIFICATION",
1390
1650
  attribute: "ATTRIBUTE"
1391
1651
  };
1392
- function re(n) {
1652
+ function sn(e) {
1393
1653
  return {
1394
- name: n.name,
1395
- value: n.content,
1654
+ name: e.name,
1655
+ value: e.content,
1396
1656
  valueReference: Y.attachment
1397
1657
  };
1398
1658
  }
1399
- function Ut(n) {
1659
+ function tr(e) {
1400
1660
  return {
1401
- propertyID: n.id,
1402
- name: n.name,
1403
- value: n.value,
1661
+ propertyID: e.id,
1662
+ name: e.name,
1663
+ value: e.value,
1404
1664
  valueReference: {
1405
1665
  valueReference: Y.attribute,
1406
- visible: n.visible
1666
+ visible: e.visible
1407
1667
  }
1408
1668
  };
1409
1669
  }
1410
- function ie(n) {
1411
- return te(
1412
- `${n.name}:${JSON.stringify(n.value)}:${n.valueReference}`
1670
+ function cn(e) {
1671
+ return on(
1672
+ `${e.name}:${JSON.stringify(e.value)}:${e.valueReference}`
1413
1673
  );
1414
1674
  }
1415
- const kt = (n) => {
1416
- const e = n.postalCode, t = n.geoCoordinates, r = {
1417
- addressType: n.addressType || null,
1418
- postalCode: e || null,
1675
+ const rr = (e) => {
1676
+ const n = e.postalCode, t = e.geoCoordinates, r = {
1677
+ addressType: e.addressType || null,
1678
+ postalCode: n || null,
1419
1679
  city: null,
1420
1680
  state: null,
1421
- country: n.country || null,
1681
+ country: e.country || null,
1422
1682
  street: null,
1423
1683
  number: null,
1424
1684
  neighborhood: null,
@@ -1431,10 +1691,10 @@ const kt = (n) => {
1431
1691
  r.geoCoordinates = i !== null && a !== null ? [a, i] : [];
1432
1692
  }
1433
1693
  return [r];
1434
- }, Ft = (n, e, t) => {
1435
- const r = e.postalCode, i = e.geoCoordinates, a = n?.shippingData?.availableAddresses ?? [], c = n?.shippingData?.selectedAddresses ?? [];
1436
- if (!t && c.length > 0)
1437
- return [c[0]];
1694
+ }, ir = (e, n, t) => {
1695
+ const r = n.postalCode, i = n.geoCoordinates, a = e?.shippingData?.availableAddresses ?? [], o = e?.shippingData?.selectedAddresses ?? [];
1696
+ if (!t && o.length > 0)
1697
+ return [o[0]];
1438
1698
  if (t && a.length > 0)
1439
1699
  for (const s of a) {
1440
1700
  if (r && i && (s.postalCode === r || s.geoCoordinates[0] === i.longitude && s.geoCoordinates[1] === i.latitude))
@@ -1445,88 +1705,88 @@ const kt = (n) => {
1445
1705
  return [s];
1446
1706
  }
1447
1707
  return null;
1448
- }, ae = (n, e) => {
1449
- if (!Nt(e))
1708
+ }, ln = (e, n) => {
1709
+ if (!ar(n))
1450
1710
  return { updateShipping: !1, addressChanged: !1 };
1451
- if (!Bt(n))
1711
+ if (!lr(e))
1452
1712
  return { updateShipping: !1, addressChanged: !1 };
1453
- const [t] = n?.shippingData?.selectedAddresses ?? [];
1454
- if (Rt(t, e.postalCode) || Lt(t, e.geoCoordinates) || Mt(t, e.addressType))
1713
+ const [t] = e?.shippingData?.selectedAddresses ?? [];
1714
+ if (or(t, n.postalCode) || sr(t, n.geoCoordinates) || cr(t, n.addressType))
1455
1715
  return { updateShipping: !0, addressChanged: !0 };
1456
- const { logisticsInfo: r } = n.shippingData;
1457
- return $t(r, e) ? { updateShipping: !0, addressChanged: !1 } : { updateShipping: !1, addressChanged: !1 };
1458
- }, Nt = (n) => !!n.postalCode || n.geoCoordinates?.latitude && n.geoCoordinates?.longitude, Rt = (n, e) => typeof e == "string" && n?.postalCode !== e, Lt = (n, e) => typeof e?.latitude == "number" && typeof e?.longitude == "number" && (n?.geoCoordinates[0] !== e?.longitude || n?.geoCoordinates[1] !== e?.latitude), Mt = (n, e) => typeof e == "string" && n?.addressType !== e, Bt = (n) => n.items.length !== 0, $t = (n, e) => {
1459
- const t = e?.deliveryMode?.deliveryChannel, r = e?.deliveryMode?.deliveryMethod, { startDate: i, endDate: a } = e?.deliveryMode?.deliveryWindow || {};
1460
- return n.some(
1461
- ({ selectedDeliveryChannel: c, selectedSla: s, slas: l }) => {
1462
- const d = t && c !== t, g = r && s !== r;
1463
- return l?.some((u) => d && u.deliveryChannel === t || g && u.id === r ? !0 : i && a && u.deliveryChannel === t && u.id === r && (!u?.deliveryWindow || u?.deliveryWindow?.startDateUtc !== i || u?.deliveryWindow?.endDateUtc !== a) && u.availableDeliveryWindows?.some(
1464
- (o) => o?.startDateUtc === i && o?.endDateUtc === a
1716
+ const { logisticsInfo: r } = e.shippingData;
1717
+ return dr(r, n) ? { updateShipping: !0, addressChanged: !1 } : { updateShipping: !1, addressChanged: !1 };
1718
+ }, ar = (e) => !!e.postalCode || e.geoCoordinates?.latitude && e.geoCoordinates?.longitude, or = (e, n) => typeof n == "string" && e?.postalCode !== n, sr = (e, n) => typeof n?.latitude == "number" && typeof n?.longitude == "number" && (e?.geoCoordinates[0] !== n?.longitude || e?.geoCoordinates[1] !== n?.latitude), cr = (e, n) => typeof n == "string" && e?.addressType !== n, lr = (e) => e.items.length !== 0, dr = (e, n) => {
1719
+ const t = n?.deliveryMode?.deliveryChannel, r = n?.deliveryMode?.deliveryMethod, { startDate: i, endDate: a } = n?.deliveryMode?.deliveryWindow || {};
1720
+ return e.some(
1721
+ ({ selectedDeliveryChannel: o, selectedSla: s, slas: l }) => {
1722
+ const d = t && o !== t, g = r && s !== r;
1723
+ return l?.some((p) => d && p.deliveryChannel === t || g && p.id === r ? !0 : i && a && p.deliveryChannel === t && p.id === r && (!p?.deliveryWindow || p?.deliveryWindow?.startDateUtc !== i || p?.deliveryWindow?.endDateUtc !== a) && p.availableDeliveryWindows?.some(
1724
+ (c) => c?.startDateUtc === i && c?.endDateUtc === a
1465
1725
  ));
1466
1726
  }
1467
1727
  );
1468
- }, oe = (n) => n.valueReference === Y.attachment, In = (n) => [
1469
- n.itemOffered.sku,
1470
- n.seller.identifier,
1471
- n.price < 0.01 ? "Gift" : void 0,
1472
- n.itemOffered.additionalProperty?.filter(oe).map(ie).join("-")
1473
- ].filter(Boolean).join("::"), en = (n, e) => ({
1474
- listPrice: n.listPrice / 100,
1475
- price: n.sellingPrice / 100,
1476
- quantity: n.quantity,
1477
- seller: { identifier: n.seller },
1728
+ }, dn = (e) => e.valueReference === Y.attachment, he = (e) => [
1729
+ e.itemOffered.sku,
1730
+ e.seller.identifier,
1731
+ e.price < 0.01 ? "Gift" : void 0,
1732
+ e.itemOffered.additionalProperty?.filter(dn).map(cn).join("-")
1733
+ ].filter(Boolean).join("::"), ne = (e, n) => ({
1734
+ listPrice: e.listPrice / 100,
1735
+ price: e.sellingPrice / 100,
1736
+ quantity: e.quantity,
1737
+ seller: { identifier: e.seller },
1478
1738
  itemOffered: {
1479
- sku: n.id,
1739
+ sku: e.id,
1480
1740
  image: [],
1481
- name: n.name,
1482
- additionalProperty: n.attachments.map(re)
1483
- },
1484
- index: e
1485
- }), zt = (n) => ({
1486
- quantity: n.quantity,
1487
- seller: n.seller.identifier,
1488
- id: n.itemOffered.sku,
1489
- index: n.index,
1490
- attachments: (n.itemOffered.additionalProperty?.filter(oe) ?? []).map((e) => ({
1491
1741
  name: e.name,
1492
- content: e.value
1742
+ additionalProperty: e.attachments.map(sn)
1743
+ },
1744
+ index: n
1745
+ }), ur = (e) => ({
1746
+ quantity: e.quantity,
1747
+ seller: e.seller.identifier,
1748
+ id: e.itemOffered.sku,
1749
+ index: e.index,
1750
+ attachments: (e.itemOffered.additionalProperty?.filter(dn) ?? []).map((n) => ({
1751
+ name: n.name,
1752
+ content: n.value
1493
1753
  }))
1494
- }), kn = (n) => n.reduce((e, t) => {
1495
- const r = In(t);
1496
- return e.has(r) || e.set(r, []), e.get(r)?.push(t), e;
1497
- }, /* @__PURE__ */ new Map()), Vt = (n, e) => {
1754
+ }), Re = (e) => e.reduce((n, t) => {
1755
+ const r = he(t);
1756
+ return n.has(r) || n.set(r, []), n.get(r)?.push(t), n;
1757
+ }, /* @__PURE__ */ new Map()), pr = (e, n) => {
1498
1758
  const t = (s, l) => ({
1499
1759
  ...s,
1500
1760
  itemOffered: {
1501
1761
  sku: s.itemOffered.sku
1502
1762
  },
1503
1763
  index: l
1504
- }), r = e.items.map(en).map(t), i = n.acceptedOffer.map(t), a = n.orderNumber === e.orderFormId, c = Cn(r, i);
1505
- return a && c;
1764
+ }), r = n.items.map(ne).map(t), i = e.acceptedOffer.map(t), a = e.orderNumber === n.orderFormId, o = Ie(r, i);
1765
+ return a && o;
1506
1766
  };
1507
- function se(n, e) {
1508
- return n?.some(
1509
- (t) => t.parentItemIndex !== null && t.parentItemIndex !== void 0 && n[t.parentItemIndex]?.id === e
1767
+ function un(e, n) {
1768
+ return e?.some(
1769
+ (t) => t.parentItemIndex !== null && t.parentItemIndex !== void 0 && e[t.parentItemIndex]?.id === n
1510
1770
  );
1511
1771
  }
1512
- function ce(n, e) {
1513
- return n?.some(
1514
- (t) => t.id === e && t.parentItemIndex !== null
1772
+ function pn(e, n) {
1773
+ return e?.some(
1774
+ (t) => t.id === n && t.parentItemIndex !== null
1515
1775
  );
1516
1776
  }
1517
- const Fn = (n) => {
1518
- const e = n.items.reduce(
1777
+ const Ne = (e) => {
1778
+ const n = e.items.reduce(
1519
1779
  (t, r, i) => {
1520
- const a = ce(n.items, r.id) || se(n.items, r.id) ? `${In(en(r))}::${i}` : In(en(r));
1780
+ const a = pn(e.items, r.id) || un(e.items, r.id) ? `${he(ne(r))}::${i}` : he(ne(r));
1521
1781
  return t[a] || (t[a] = []), t[a].push(r), t;
1522
1782
  },
1523
1783
  {}
1524
1784
  );
1525
1785
  return {
1526
- ...n,
1527
- items: Object.values(e).map((t) => {
1528
- const [r] = t, i = t.reduce((c, s) => c + s.quantity, 0), a = t.reduce(
1529
- (c, s) => c + (s?.priceDefinition?.total ?? (s?.quantity ?? 0) * (s?.sellingPrice ?? 0)),
1786
+ ...e,
1787
+ items: Object.values(n).map((t) => {
1788
+ const [r] = t, i = t.reduce((o, s) => o + s.quantity, 0), a = t.reduce(
1789
+ (o, s) => o + (s?.priceDefinition?.total ?? (s?.quantity ?? 0) * (s?.sellingPrice ?? 0)),
1530
1790
  0
1531
1791
  );
1532
1792
  return {
@@ -1536,37 +1796,37 @@ const Fn = (n) => {
1536
1796
  };
1537
1797
  })
1538
1798
  };
1539
- }, Nn = async (n, e, t) => ({
1799
+ }, Le = async (e, n, t) => ({
1540
1800
  order: {
1541
- orderNumber: n.orderFormId,
1542
- acceptedOffer: n.items.map(async (r) => ({
1801
+ orderNumber: e.orderFormId,
1802
+ acceptedOffer: e.items.map(async (r) => ({
1543
1803
  ...r,
1544
- product: await e.load(`${r.id}-invisibleItems`)
1804
+ product: await n.load(`${r.id}-invisibleItems`)
1545
1805
  })),
1546
1806
  shouldSplitItem: t
1547
1807
  },
1548
- messages: n.messages.map(({ text: r, status: i }) => ({
1808
+ messages: e.messages.map(({ text: r, status: i }) => ({
1549
1809
  text: r,
1550
1810
  status: i.toUpperCase()
1551
1811
  }))
1552
- }), le = ({ items: n }, e) => {
1553
- const t = n.map((r) => ({
1812
+ }), gn = ({ items: e }, n) => {
1813
+ const t = e.map((r) => ({
1554
1814
  id: r.id,
1555
1815
  quantity: r.quantity,
1556
1816
  seller: r.seller,
1557
1817
  attachments: r.attachments
1558
1818
  // customizations
1559
1819
  }));
1560
- return te(
1561
- JSON.stringify({ sessionId: e?.id ?? "", items: t })
1820
+ return on(
1821
+ JSON.stringify({ sessionId: n?.id ?? "", items: t })
1562
1822
  );
1563
- }, Rn = async (n, e, t) => {
1823
+ }, Be = async (e, n, t) => {
1564
1824
  try {
1565
- return await e.checkout.setCustomData({
1566
- id: n.orderFormId,
1825
+ return await n.checkout.setCustomData({
1826
+ id: e.orderFormId,
1567
1827
  appId: "faststore",
1568
1828
  key: "cartEtag",
1569
- value: le(n, t)
1829
+ value: gn(e, t)
1570
1830
  });
1571
1831
  } catch (r) {
1572
1832
  throw console.error(
@@ -1576,92 +1836,92 @@ const Fn = (n) => {
1576
1836
  More info at: https://developers.vtex.com/vtex-rest-api/docs/customizable-fields-with-checkout-api`
1577
1837
  ), r;
1578
1838
  }
1579
- }, xt = (n, e) => {
1580
- const r = n.customData?.customApps.find(
1839
+ }, gr = (e, n) => {
1840
+ const r = e.customData?.customApps.find(
1581
1841
  (a) => a.id === "faststore"
1582
1842
  )?.fields?.cartEtag;
1583
- return r == null ? !0 : le(n, e) !== r;
1584
- }, qt = async (n, { clients: { commerce: e } }) => e.checkout.clearOrderFormMessages({
1585
- id: n
1586
- }), Ln = async (n, e, { clients: { commerce: t } }) => {
1587
- if (!e)
1588
- return n;
1589
- const { updateShipping: r, addressChanged: i } = ae(
1590
- n,
1591
- e
1843
+ return r == null ? !0 : gn(e, n) !== r;
1844
+ }, mr = async (e, { clients: { commerce: n } }) => n.checkout.clearOrderFormMessages({
1845
+ id: e
1846
+ }), Me = async (e, n, { clients: { commerce: t } }) => {
1847
+ if (!n)
1848
+ return e;
1849
+ const { updateShipping: r, addressChanged: i } = ln(
1850
+ e,
1851
+ n
1592
1852
  );
1593
1853
  if (r) {
1594
- const a = Ft(n, e, i), s = a || kt(e);
1595
- return !!e.deliveryMode?.deliveryWindow && await t.checkout.shippingData(
1854
+ const a = ir(e, n, i), s = a || rr(n);
1855
+ return !!n.deliveryMode?.deliveryWindow && await t.checkout.shippingData(
1596
1856
  {
1597
- id: n.orderFormId,
1598
- index: n.items.length,
1599
- deliveryMode: e.deliveryMode,
1857
+ id: e.orderFormId,
1858
+ index: e.items.length,
1859
+ deliveryMode: n.deliveryMode,
1600
1860
  selectedAddresses: s
1601
1861
  },
1602
1862
  !1
1603
1863
  ), t.checkout.shippingData(
1604
1864
  {
1605
- id: n.orderFormId,
1606
- index: n.items.length,
1607
- deliveryMode: e.deliveryMode,
1865
+ id: e.orderFormId,
1866
+ index: e.items.length,
1867
+ deliveryMode: n.deliveryMode,
1608
1868
  selectedAddresses: s
1609
1869
  },
1610
1870
  !0
1611
1871
  );
1612
1872
  }
1613
- return n;
1614
- }, jt = (n, e) => {
1615
- if (!n)
1873
+ return e;
1874
+ }, hr = (e, n) => {
1875
+ if (!e)
1616
1876
  return "";
1617
- const r = tn(n)[e];
1877
+ const r = H(e)[n];
1618
1878
  return r ? r.split("=")[1] : "";
1619
- }, Wt = async (n, { cart: { order: e }, session: t }, r) => {
1620
- const i = jt(
1879
+ }, fr = async (e, { cart: { order: n }, session: t }, r) => {
1880
+ const i = hr(
1621
1881
  r.headers.cookie,
1622
1882
  "checkout.vtex.com"
1623
1883
  ), {
1624
1884
  clients: { commerce: a },
1625
- loaders: { skuLoader: c }
1885
+ loaders: { skuLoader: o }
1626
1886
  } = r, s = t?.channel, l = t?.locale;
1627
- s && Sn(r, s), l && yn(r, l);
1887
+ s && ge(r, s), l && me(r, l);
1628
1888
  const d = await a.checkout.orderForm({
1629
1889
  id: i || void 0,
1630
1890
  channel: r.storage.channel
1631
1891
  }), g = d.orderFormId;
1632
- d.messages.length !== 0 && await qt(g, r);
1633
- const u = tn(r?.headers?.cookie ?? "")?.vtex_session, o = Z(u), { acceptedOffer: p, shouldSplitItem: m } = e;
1634
- if (xt(d, o)) {
1635
- const y = await Rn(
1892
+ d.messages.length !== 0 && await mr(g, r);
1893
+ const p = H(r?.headers?.cookie ?? "")?.vtex_session, c = Z(p), { acceptedOffer: u, shouldSplitItem: m } = n;
1894
+ if (gr(d, c)) {
1895
+ const v = await Be(
1636
1896
  d,
1637
1897
  a,
1638
- o
1639
- ).then(Fn);
1898
+ c
1899
+ ).then(Ne);
1640
1900
  if (g)
1641
- return Nn(y, c, m);
1901
+ return Le(v, o, m);
1642
1902
  }
1643
- const I = kn(p), O = kn(d.items.map(en)), w = Array.from(O.entries()), _ = Array.from(I.entries()), { itemsToAdd: P, itemsToUpdate: b } = _.reduce(
1644
- (y, [A, T]) => {
1645
- const F = O.get(A);
1646
- if (!F)
1647
- return T.forEach(($) => y.itemsToAdd.push($)), y;
1648
- const [U, ...G] = F;
1649
- if (ce(d.items, U.itemOffered.sku) || se(d.items, U.itemOffered.sku))
1650
- return y.itemsToUpdate.push(U), y;
1651
- const N = T.reduce(($, x) => $ + x.quantity, 0);
1652
- return y.itemsToUpdate.push({
1653
- ...U,
1654
- quantity: N
1655
- }), G.forEach(($) => y.itemsToUpdate.push({ ...$, quantity: 0 })), y;
1903
+ const f = Re(u), I = Re(d.items.map(ne)), D = Array.from(I.entries()), E = Array.from(f.entries()), { itemsToAdd: w, itemsToUpdate: O } = E.reduce(
1904
+ (v, [T, _]) => {
1905
+ const x = I.get(T);
1906
+ if (!x)
1907
+ return _.forEach((q) => v.itemsToAdd.push(q)), v;
1908
+ const [k, ...ve] = x;
1909
+ if (pn(d.items, k.itemOffered.sku) || un(d.items, k.itemOffered.sku))
1910
+ return v.itemsToUpdate.push(k), v;
1911
+ const ie = _.reduce((q, In) => q + In.quantity, 0);
1912
+ return v.itemsToUpdate.push({
1913
+ ...k,
1914
+ quantity: ie
1915
+ }), ve.forEach((q) => v.itemsToUpdate.push({ ...q, quantity: 0 })), v;
1656
1916
  },
1657
1917
  {
1658
1918
  itemsToAdd: [],
1659
1919
  itemsToUpdate: []
1660
1920
  }
1661
- ), E = w.filter(([y]) => !I.has(y)).flatMap(([, y]) => y.map((A) => ({ ...A, quantity: 0 }))), h = [...P, ...b, ...E].map(
1662
- zt
1663
- ), { updateShipping: v } = t ? ae(d, t) : { updateShipping: !1 };
1664
- if (h.length === 0 && !v)
1921
+ ), P = D.filter(([v]) => !f.has(v)).flatMap(([, v]) => v.map((T) => ({ ...T, quantity: 0 }))), h = [...w, ...O, ...P].map(
1922
+ ur
1923
+ ), { updateShipping: b } = t ? ln(d, t) : { updateShipping: !1 };
1924
+ if (h.length === 0 && !b)
1665
1925
  return null;
1666
1926
  let C;
1667
1927
  h.length > 0 ? C = await a.checkout.updateOrderFormItems({
@@ -1669,41 +1929,41 @@ const Fn = (n) => {
1669
1929
  orderItems: h,
1670
1930
  shouldSplitItem: m
1671
1931
  }).then(
1672
- (y) => Ln(y, t, r)
1673
- ) : C = await Ln(
1932
+ (v) => Me(v, t, r)
1933
+ ) : C = await Me(
1674
1934
  d,
1675
1935
  t,
1676
1936
  r
1677
- ), C = await Promise.resolve(C).then((y) => {
1937
+ ), C = await Promise.resolve(C).then((v) => {
1678
1938
  if (t?.marketingData) {
1679
- const A = {
1680
- ...y.marketingData,
1939
+ const T = {
1940
+ ...v.marketingData,
1681
1941
  ...t.marketingData
1682
1942
  };
1683
1943
  return a.checkout.marketingData({
1684
1944
  id: d.orderFormId,
1685
- marketingData: A
1945
+ marketingData: T
1686
1946
  });
1687
1947
  }
1688
- return y;
1689
- }).then((y) => l && y.clientPreferencesData?.locale !== l ? a.checkout.clientPreferencesData({
1690
- id: y.orderFormId,
1948
+ return v;
1949
+ }).then((v) => l && v.clientPreferencesData?.locale !== l ? a.checkout.clientPreferencesData({
1950
+ id: v.orderFormId,
1691
1951
  clientPreferencesData: {
1692
- ...y.clientPreferencesData,
1952
+ ...v.clientPreferencesData,
1693
1953
  locale: l
1694
1954
  }
1695
- }) : y).then((y) => Rn(y, a, o)).then(Fn);
1696
- const D = Cn(
1955
+ }) : v).then((v) => Be(v, a, c)).then(Ne);
1956
+ const A = Ie(
1697
1957
  d.messages,
1698
1958
  C.messages
1699
1959
  );
1700
- return Vt(e, C) && D ? null : Nn(C, c, m);
1960
+ return pr(n, C) && A ? null : Le(C, o, m);
1701
1961
  };
1702
- async function Gt(n, e, t) {
1962
+ async function Sr(e, n, t) {
1703
1963
  try {
1704
- const r = await n.commerce.checkout.address({
1964
+ const r = await e.commerce.checkout.address({
1705
1965
  postalCode: t,
1706
- country: e
1966
+ country: n
1707
1967
  }), i = r.geoCoordinates ? {
1708
1968
  latitude: r.geoCoordinates[1],
1709
1969
  longitude: r.geoCoordinates[0]
@@ -1711,77 +1971,77 @@ async function Gt(n, e, t) {
1711
1971
  return { city: r.city, geoCoordinates: i };
1712
1972
  } catch (r) {
1713
1973
  throw console.error(
1714
- `Error while getting geo coordinates for the current postal code (${t}) and country (${e}).
1974
+ `Error while getting geo coordinates for the current postal code (${t}) and country (${n}).
1715
1975
  `
1716
1976
  ), r;
1717
1977
  }
1718
1978
  }
1719
- const Ht = async (n, { session: e, search: t }, { clients: r, headers: i, account: a }) => {
1720
- const c = nn.parse(e.channel ?? ""), s = String(e.postalCode ?? ""), l = e.country ?? "";
1721
- let d = e.city ?? null, g = e.geoCoordinates ?? null;
1979
+ const yr = async (e, { session: n, search: t }, { clients: r, headers: i, account: a }) => {
1980
+ const o = ee.parse(n.channel ?? ""), s = String(n.postalCode ?? ""), l = n.country ?? "";
1981
+ let d = n.city ?? null, g = n.geoCoordinates ?? null;
1722
1982
  if ((!d || !g) && s !== "" && l !== "") {
1723
- const U = await Gt(
1983
+ const k = await Sr(
1724
1984
  r,
1725
1985
  l,
1726
1986
  s
1727
1987
  );
1728
- d = U.city, g = U.geoCoordinates;
1988
+ d = k.city, g = k.geoCoordinates;
1729
1989
  }
1730
- const o = new URLSearchParams(t);
1731
- o.has("facets") && o.delete("facets");
1732
- const p = o.get("sc") ?? c.salesChannel;
1733
- o.set("sc", p), s && o.set("postalCode", s), l && o.set("country", l), g && o.set(
1990
+ const c = new URLSearchParams(t);
1991
+ c.has("facets") && c.delete("facets");
1992
+ const u = c.get("sc") ?? o.salesChannel;
1993
+ c.set("sc", u), s && c.set("postalCode", s), l && c.set("country", l), g && c.set(
1734
1994
  "geoCoordinates",
1735
1995
  `${g.longitude},${g.latitude}`
1736
1996
  // long,lat is the format expected
1737
- ), o.set("locale", e.locale);
1738
- const { marketingData: m } = e, S = {
1739
- utmCampaign: o.get("utm_campaign") ?? m?.utmCampaign ?? "",
1740
- utmMedium: o.get("utm_medium") ?? m?.utmMedium ?? "",
1741
- utmSource: o.get("utm_source") ?? m?.utmSource ?? "",
1742
- utmiCampaign: o.get("utmi_cp") ?? m?.utmiCampaign ?? "",
1743
- utmiPage: o.get("utmi_p") ?? m?.utmiPage ?? "",
1744
- utmiPart: o.get("utmi_pc") ?? m?.utmiPart ?? ""
1745
- }, I = Z(Q(i?.cookie ?? "", a));
1746
- let O = !1;
1747
- if (I)
1997
+ ), c.set("locale", n.locale);
1998
+ const { marketingData: m } = n, S = {
1999
+ utmCampaign: c.get("utm_campaign") ?? m?.utmCampaign ?? "",
2000
+ utmMedium: c.get("utm_medium") ?? m?.utmMedium ?? "",
2001
+ utmSource: c.get("utm_source") ?? m?.utmSource ?? "",
2002
+ utmiCampaign: c.get("utmi_cp") ?? m?.utmiCampaign ?? "",
2003
+ utmiPage: c.get("utmi_p") ?? m?.utmiPage ?? "",
2004
+ utmiPart: c.get("utmi_pc") ?? m?.utmiPart ?? ""
2005
+ }, f = Z(Q(i?.cookie ?? "", a));
2006
+ let I = !1;
2007
+ if (f)
1748
2008
  try {
1749
- O = (await r.commerce.vtexid.validate())?.authStatus?.toLowerCase() === "success";
1750
- } catch (U) {
1751
- console.warn("JWT validation failed:", U), O = !1;
2009
+ I = (await r.commerce.vtexid.validate())?.authStatus?.toLowerCase() === "success";
2010
+ } catch (k) {
2011
+ console.warn("JWT validation failed:", k), I = !1;
1752
2012
  }
1753
- const w = O ? I?.isRepresentative : !1, _ = O ? I?.customerId : void 0, P = O ? I?.unitId : void 0, b = await r.commerce.session(o.toString()).catch(() => null), E = b?.namespaces.profile ?? null, h = b?.namespaces.shopper ?? null, v = b?.namespaces.store ?? null, C = b?.namespaces.authentication ?? null, D = b?.namespaces.checkout ?? null, y = b?.namespaces.public ?? null;
1754
- let A = null;
1755
- if (w && E?.id?.value)
2013
+ const D = I ? f?.isRepresentative : !1, E = I ? f?.customerId : void 0, w = I ? f?.unitId : void 0, O = await r.commerce.session(c.toString()).catch(() => null), P = O?.namespaces.profile ?? null, h = O?.namespaces.shopper ?? null, b = O?.namespaces.store ?? null, C = O?.namespaces.authentication ?? null, A = O?.namespaces.checkout ?? null, v = O?.namespaces.public ?? null;
2014
+ let T = null;
2015
+ if (D && P?.id?.value)
1756
2016
  try {
1757
- A = await r.commerce.masterData.getContractById({
1758
- contractId: E.id.value
2017
+ T = await r.commerce.masterData.getContractById({
2018
+ contractId: P.id.value
1759
2019
  });
1760
2020
  } catch {
1761
2021
  console.error(
1762
- `Error while getting contract data for profile ID (${E.id.value}).
2022
+ `Error while getting contract data for profile ID (${P.id.value}).
1763
2023
  `
1764
2024
  );
1765
2025
  }
1766
- let T;
1767
- c.seller && (s || g) && (T = (await r.commerce.checkout.region({
2026
+ let _;
2027
+ o.seller && (s || g) && (_ = (await r.commerce.checkout.region({
1768
2028
  postalCode: s,
1769
2029
  geoCoordinates: g,
1770
2030
  country: l,
1771
- salesChannel: p
1772
- }))?.[0]?.sellers.find((N) => c.seller === N.id));
1773
- const F = {
1774
- ...e,
2031
+ salesChannel: u
2032
+ }))?.[0]?.sellers.find((ie) => o.seller === ie.id));
2033
+ const x = {
2034
+ ...n,
1775
2035
  currency: {
1776
- code: v?.currencyCode?.value ?? e.currency.code,
1777
- symbol: v?.currencySymbol?.value ?? e.currency.symbol
2036
+ code: b?.currencyCode?.value ?? n.currency.code,
2037
+ symbol: b?.currencySymbol?.value ?? n.currency.symbol
1778
2038
  },
1779
- country: v?.countryCode?.value ?? l,
1780
- channel: nn.stringify({
1781
- salesChannel: v?.channel?.value ?? c.salesChannel,
1782
- regionId: D?.regionId?.value ?? c.regionId,
1783
- seller: T?.id,
1784
- hasOnlyDefaultSalesChannel: !v?.channel?.value
2039
+ country: b?.countryCode?.value ?? l,
2040
+ channel: ee.stringify({
2041
+ salesChannel: b?.channel?.value ?? o.salesChannel,
2042
+ regionId: A?.regionId?.value ?? o.regionId,
2043
+ seller: _?.id,
2044
+ hasOnlyDefaultSalesChannel: !b?.channel?.value
1785
2045
  }),
1786
2046
  /**
1787
2047
  * B2B data structure in Session:
@@ -1789,222 +2049,222 @@ const Ht = async (n, { session: e, search: t }, { clients: r, headers: i, accoun
1789
2049
  * - Unit data: `authentication` namespace
1790
2050
  * - Contract data: `profile` namespace (those info will be available inside Faststore's Session `person` object)
1791
2051
  */
1792
- b2b: w ? {
1793
- isRepresentative: w ?? !1,
1794
- customerId: C?.customerId?.value ?? _ ?? "",
2052
+ b2b: D ? {
2053
+ isRepresentative: D ?? !1,
2054
+ customerId: C?.customerId?.value ?? E ?? "",
1795
2055
  unitName: C?.unitName?.value ?? "",
1796
- unitId: C?.unitId?.value ?? P ?? "",
2056
+ unitId: C?.unitId?.value ?? w ?? "",
1797
2057
  firstName: typeof h?.firstName?.value == "string" ? h.firstName.value : "",
1798
2058
  lastName: typeof h?.lastName?.value == "string" ? h.lastName.value : "",
1799
2059
  userName: `${typeof h?.firstName?.value == "string" ? h.firstName.value : ""} ${typeof h?.lastName?.value == "string" ? h.lastName.value : ""}`.trim(),
1800
2060
  userEmail: C?.storeUserEmail.value ?? "",
1801
- savedPostalCode: y?.postalCode?.value ?? "",
1802
- contractName: A?.corporateName ?? "",
2061
+ savedPostalCode: v?.postalCode?.value ?? "",
2062
+ contractName: T?.corporateName ?? "",
1803
2063
  organizationManager: h?.organizationManager?.value ?? !1
1804
2064
  } : null,
1805
2065
  marketingData: S,
1806
- person: E?.id ? {
1807
- id: E.id?.value ?? "",
1808
- email: E.email?.value ?? "",
1809
- givenName: E.firstName?.value ?? "",
1810
- familyName: E.lastName?.value ?? ""
2066
+ person: P?.id ? {
2067
+ id: P.id?.value ?? "",
2068
+ email: P.email?.value ?? "",
2069
+ givenName: P.firstName?.value ?? "",
2070
+ familyName: P.lastName?.value ?? ""
1811
2071
  } : null,
1812
2072
  geoCoordinates: g?.latitude && g?.longitude && g || null,
1813
2073
  city: d
1814
2074
  };
1815
- return Cn(e, F) ? null : F;
1816
- }, Xt = {
1817
- validateCart: Wt,
1818
- validateSession: Ht,
1819
- subscribeToNewsletter: Tt,
1820
- cancelOrder: wt,
1821
- processOrderAuthorization: Pt,
1822
- uploadFileToOrderEntry: _t,
1823
- startOrderEntryOperation: Et
2075
+ return Ie(n, x) ? null : x;
2076
+ }, Ir = {
2077
+ validateCart: fr,
2078
+ validateSession: yr,
2079
+ subscribeToNewsletter: er,
2080
+ cancelOrder: Jt,
2081
+ processOrderAuthorization: Qt,
2082
+ uploadFileToOrderEntry: nr,
2083
+ startOrderEntryOperation: Zt
1824
2084
  };
1825
- var vn;
1826
- (function(n) {
1827
- n.NAME = "Name", n.DOCUMENT = "Document", n.OPERATION_DEFINITION = "OperationDefinition", n.VARIABLE_DEFINITION = "VariableDefinition", n.SELECTION_SET = "SelectionSet", n.FIELD = "Field", n.ARGUMENT = "Argument", n.FRAGMENT_SPREAD = "FragmentSpread", n.INLINE_FRAGMENT = "InlineFragment", n.FRAGMENT_DEFINITION = "FragmentDefinition", n.VARIABLE = "Variable", n.INT = "IntValue", n.FLOAT = "FloatValue", n.STRING = "StringValue", n.BOOLEAN = "BooleanValue", n.NULL = "NullValue", n.ENUM = "EnumValue", n.LIST = "ListValue", n.OBJECT = "ObjectValue", n.OBJECT_FIELD = "ObjectField", n.DIRECTIVE = "Directive", n.NAMED_TYPE = "NamedType", n.LIST_TYPE = "ListType", n.NON_NULL_TYPE = "NonNullType", n.SCHEMA_DEFINITION = "SchemaDefinition", n.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", n.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", n.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", n.FIELD_DEFINITION = "FieldDefinition", n.INPUT_VALUE_DEFINITION = "InputValueDefinition", n.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", n.UNION_TYPE_DEFINITION = "UnionTypeDefinition", n.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", n.ENUM_VALUE_DEFINITION = "EnumValueDefinition", n.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", n.DIRECTIVE_DEFINITION = "DirectiveDefinition", n.SCHEMA_EXTENSION = "SchemaExtension", n.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", n.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", n.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", n.UNION_TYPE_EXTENSION = "UnionTypeExtension", n.ENUM_TYPE_EXTENSION = "EnumTypeExtension", n.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension";
1828
- })(vn || (vn = {}));
1829
- const Yt = (n) => typeof n == "string" ? de(n) : null;
1830
- function de(n) {
2085
+ var fe;
2086
+ (function(e) {
2087
+ e.NAME = "Name", e.DOCUMENT = "Document", e.OPERATION_DEFINITION = "OperationDefinition", e.VARIABLE_DEFINITION = "VariableDefinition", e.SELECTION_SET = "SelectionSet", e.FIELD = "Field", e.ARGUMENT = "Argument", e.FRAGMENT_SPREAD = "FragmentSpread", e.INLINE_FRAGMENT = "InlineFragment", e.FRAGMENT_DEFINITION = "FragmentDefinition", e.VARIABLE = "Variable", e.INT = "IntValue", e.FLOAT = "FloatValue", e.STRING = "StringValue", e.BOOLEAN = "BooleanValue", e.NULL = "NullValue", e.ENUM = "EnumValue", e.LIST = "ListValue", e.OBJECT = "ObjectValue", e.OBJECT_FIELD = "ObjectField", e.DIRECTIVE = "Directive", e.NAMED_TYPE = "NamedType", e.LIST_TYPE = "ListType", e.NON_NULL_TYPE = "NonNullType", e.SCHEMA_DEFINITION = "SchemaDefinition", e.OPERATION_TYPE_DEFINITION = "OperationTypeDefinition", e.SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition", e.OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition", e.FIELD_DEFINITION = "FieldDefinition", e.INPUT_VALUE_DEFINITION = "InputValueDefinition", e.INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition", e.UNION_TYPE_DEFINITION = "UnionTypeDefinition", e.ENUM_TYPE_DEFINITION = "EnumTypeDefinition", e.ENUM_VALUE_DEFINITION = "EnumValueDefinition", e.INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition", e.DIRECTIVE_DEFINITION = "DirectiveDefinition", e.SCHEMA_EXTENSION = "SchemaExtension", e.SCALAR_TYPE_EXTENSION = "ScalarTypeExtension", e.OBJECT_TYPE_EXTENSION = "ObjectTypeExtension", e.INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension", e.UNION_TYPE_EXTENSION = "UnionTypeExtension", e.ENUM_TYPE_EXTENSION = "EnumTypeExtension", e.INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension";
2088
+ })(fe || (fe = {}));
2089
+ const vr = (e) => typeof e == "string" ? mn(e) : null;
2090
+ function mn(e) {
1831
2091
  try {
1832
- return JSON.parse(n);
2092
+ return JSON.parse(e);
1833
2093
  } catch {
1834
- return n;
2094
+ return e;
1835
2095
  }
1836
2096
  }
1837
- const Jt = (n) => typeof n == "object" ? JSON.stringify(n) : typeof n == "string" ? n : null, Kt = new Se({
2097
+ const Or = (e) => typeof e == "object" ? JSON.stringify(e) : typeof e == "string" ? e : null, Cr = new Cn({
1838
2098
  name: "ObjectOrString",
1839
2099
  description: "A string or the string representation of an object (a stringified object).",
1840
- parseValue: Yt,
1841
- serialize: Jt,
1842
- parseLiteral(n) {
1843
- return n.kind === vn.STRING ? de(n.value) : null;
2100
+ parseValue: vr,
2101
+ serialize: Or,
2102
+ parseLiteral(e) {
2103
+ return e.kind === fe.STRING ? mn(e.value) : null;
1844
2104
  }
1845
- }), L = (n) => "Price" in n && "seller" in n && "product" in n, R = (n) => "skuName" in n, Qt = {
1846
- priceCurrency: async (n, e, t) => {
2105
+ }), R = (e) => "Price" in e && "seller" in e && "product" in e, F = (e) => "skuName" in e, br = {
2106
+ priceCurrency: async (e, n, t) => {
1847
2107
  const {
1848
2108
  loaders: { salesChannelLoader: r },
1849
2109
  storage: { channel: i }
1850
2110
  } = t;
1851
2111
  return (await r.load(i.salesChannel)).CurrencyCode ?? "";
1852
2112
  },
1853
- priceValidUntil: (n) => L(n) ? n.PriceValidUntil ?? "" : R(n) ? n.priceValidUntil ?? "" : null,
2113
+ priceValidUntil: (e) => R(e) ? e.PriceValidUntil ?? "" : F(e) ? e.priceValidUntil ?? "" : null,
1854
2114
  itemCondition: () => "https://schema.org/NewCondition",
1855
- availability: async (n) => L(n) ? wn(V(n)) : R(n) ? wn(dt(n.availability)) : null,
1856
- seller: (n, e, t) => L(n) ? {
1857
- identifier: t.storage.channel?.seller || n.seller.sellerId || ""
1858
- } : R(n) ? {
1859
- identifier: n.seller
2115
+ availability: async (e) => R(e) ? Ae(M(e)) : F(e) ? Ae(Nt(e.availability)) : null,
2116
+ seller: (e, n, t) => R(e) ? {
2117
+ identifier: t.storage.channel?.seller || e.seller.sellerId || ""
2118
+ } : F(e) ? {
2119
+ identifier: e.seller
1860
2120
  } : null,
1861
- price: (n) => L(n) ? W(n) : R(n) ? n.sellingPrice / 100 : null,
1862
- priceWithTaxes: (n) => L(n) ? q(W(n), n?.Tax, n.product.unitMultiplier) : R(n) ? q(
1863
- n.sellingPrice / 100,
1864
- n.tax / 100,
1865
- n.unitMultiplier
2121
+ price: (e) => R(e) ? V(e) : F(e) ? e.sellingPrice / 100 : null,
2122
+ priceWithTaxes: (e) => R(e) ? $(V(e), e?.Tax, e.product.unitMultiplier) : F(e) ? $(
2123
+ e.sellingPrice / 100,
2124
+ e.tax / 100,
2125
+ e.unitMultiplier
1866
2126
  ) : null,
1867
- sellingPrice: (n) => L(n) ? lt(n) : R(n) ? n.sellingPrice / 100 : null,
1868
- listPrice: (n) => L(n) ? n.ListPrice ?? 0 : R(n) ? n.listPrice / 100 : null,
1869
- listPriceWithTaxes: (n) => L(n) ? q(
1870
- n.ListPrice ?? 0,
1871
- n?.Tax,
1872
- n.product.unitMultiplier
1873
- ) : R(n) ? q(n.listPrice / 100, n.tax / 100, n.unitMultiplier) : null,
1874
- itemOffered: (n) => L(n) ? n.product : R(n) ? {
1875
- ...n.product,
1876
- attachmentsValues: n.attachments
2127
+ sellingPrice: (e) => R(e) ? Rt(e) : F(e) ? e.sellingPrice / 100 : null,
2128
+ listPrice: (e) => R(e) ? e.ListPrice ?? 0 : F(e) ? e.listPrice / 100 : null,
2129
+ listPriceWithTaxes: (e) => R(e) ? $(
2130
+ e.ListPrice ?? 0,
2131
+ e?.Tax,
2132
+ e.product.unitMultiplier
2133
+ ) : F(e) ? $(e.listPrice / 100, e.tax / 100, e.unitMultiplier) : null,
2134
+ itemOffered: (e) => R(e) ? e.product : F(e) ? {
2135
+ ...e.product,
2136
+ attachmentsValues: e.attachments
1877
2137
  } : null,
1878
- quantity: (n) => L(n) ? n.AvailableQuantity ?? 0 : R(n) ? n.quantity : null,
1879
- isGift: (n) => R(n) ? n.isGift ?? !1 : null
1880
- }, Zt = ({ linkText: n }) => `/${n}/p`, nr = ({
1881
- offer: n,
1882
- seller: e,
2138
+ quantity: (e) => R(e) ? e.AvailableQuantity ?? 0 : F(e) ? e.quantity : null,
2139
+ isGift: (e) => F(e) ? e.isGift ?? !1 : null
2140
+ }, Dr = ({ linkText: e }) => `/${e}/p`, wr = ({
2141
+ offer: e,
2142
+ seller: n,
1883
2143
  product: t
1884
2144
  }) => ({
1885
- ...n,
2145
+ ...e,
1886
2146
  product: t,
1887
- seller: e
1888
- }), er = {
2147
+ seller: n
2148
+ }), Pr = {
1889
2149
  imageText: "image",
1890
2150
  imageUrl: "https://storecomponents.vtexassets.com/assets/faststore/images/image___117a6d3e229a96ad0e0d0876352566e2.svg",
1891
2151
  imageLabel: "label"
1892
- }, ue = (n, e) => `${n}-${e}`, tr = (n, e) => `/${ue(n, e)}/p`, rr = (n) => Array.isArray(n) && n.length > 0 ? n : null;
1893
- function pe(n) {
1894
- return n.replace(/^\/+|\/+$/g, "");
2152
+ }, hn = (e, n) => `${e}-${n}`, Ar = (e, n) => `/${hn(e, n)}/p`, Er = (e) => Array.isArray(e) && e.length > 0 ? e : null;
2153
+ function fn(e) {
2154
+ return e.replace(/^\/+|\/+$/g, "");
1895
2155
  }
1896
- const ir = (n, e) => {
1897
- const t = n.findIndex((r) => pe(r).split("/").at(-1) === e);
2156
+ const Ur = (e, n) => {
2157
+ const t = e.findIndex((r) => fn(r).split("/").at(-1) === n);
1898
2158
  return t < 0 ? 0 : t;
1899
- }, ar = {
1900
- productID: ({ itemId: n }) => n,
1901
- name: ({ isVariantOf: n, name: e }) => e ?? n.productName,
1902
- slug: ({ isVariantOf: { linkText: n }, itemId: e }) => ue(n, e),
1903
- description: ({ isVariantOf: { description: n } }) => n,
1904
- seo: ({ isVariantOf: n }) => ({
1905
- title: n.productTitle || n.productName,
1906
- description: n.metaTagDescription || n.description,
1907
- canonical: Zt(n)
2159
+ }, Tr = {
2160
+ productID: ({ itemId: e }) => e,
2161
+ name: ({ isVariantOf: e, name: n }) => n ?? e.productName,
2162
+ slug: ({ isVariantOf: { linkText: e }, itemId: n }) => hn(e, n),
2163
+ description: ({ isVariantOf: { description: e } }) => e,
2164
+ seo: ({ isVariantOf: e }) => ({
2165
+ title: e.productTitle || e.productName,
2166
+ description: e.metaTagDescription || e.description,
2167
+ canonical: Dr(e)
1908
2168
  }),
1909
- brand: ({ isVariantOf: { brand: n } }) => ({ name: n }),
1910
- unitMultiplier: ({ unitMultiplier: n }) => n,
2169
+ brand: ({ isVariantOf: { brand: e } }) => ({ name: e }),
2170
+ unitMultiplier: ({ unitMultiplier: e }) => e,
1911
2171
  breadcrumbList: ({
1912
2172
  isVariantOf: {
1913
- categories: n,
1914
- productName: e,
2173
+ categories: e,
2174
+ productName: n,
1915
2175
  linkText: t,
1916
2176
  categoryId: r,
1917
2177
  categoriesIds: i
1918
2178
  },
1919
2179
  itemId: a
1920
2180
  }) => {
1921
- const c = ir(i, r), s = n[c], l = pe(s).split("/");
2181
+ const o = Ur(i, r), s = e[o], l = fn(s).split("/");
1922
2182
  return {
1923
2183
  itemListElement: [
1924
2184
  ...l.map((d, g) => {
1925
- const u = `/${l.slice(0, g + 1).map(Qn).join("/")}/`;
2185
+ const p = `/${l.slice(0, g + 1).map(nn).join("/")}/`;
1926
2186
  return {
1927
2187
  name: d,
1928
- item: u,
2188
+ item: p,
1929
2189
  position: g + 1
1930
2190
  };
1931
2191
  }),
1932
2192
  {
1933
- name: e,
1934
- item: tr(t, a),
2193
+ name: n,
2194
+ item: Ar(t, a),
1935
2195
  position: l.length + 1
1936
2196
  }
1937
2197
  ],
1938
2198
  numberOfItems: l.length
1939
2199
  };
1940
2200
  },
1941
- image: ({ images: n }, e) => {
1942
- const t = (rr(n) ?? [er]).map(
2201
+ image: ({ images: e }, n) => {
2202
+ const t = (Er(e) ?? [Pr]).map(
1943
2203
  ({ imageUrl: s, imageText: l, imageLabel: d }) => ({
1944
2204
  alternateName: l ?? "",
1945
2205
  url: s.replace("vteximg.com.br", "vtexassets.com"),
1946
2206
  keywords: d
1947
2207
  })
1948
2208
  );
1949
- if (typeof e != "object")
2209
+ if (typeof n != "object")
1950
2210
  return t;
1951
- let { context: r, limit: i } = e;
2211
+ let { context: r, limit: i } = n;
1952
2212
  const a = r !== "generic";
1953
2213
  i = i || -1, i = i <= -1 ? void 0 : i;
1954
- let c = a ? t.filter(
2214
+ let o = a ? t.filter(
1955
2215
  ({ keywords: s }) => s === r
1956
2216
  ) : t;
1957
- return c = c.length === 0 ? t : c, c.slice(0, i);
2217
+ return o = o.length === 0 ? t : o, o.slice(0, i);
1958
2218
  },
1959
- sku: ({ itemId: n }) => n,
1960
- gtin: ({ ean: n, referenceId: e }) => n || (e[0]?.Value ?? ""),
1961
- mpn: ({ isVariantOf: { manufacturerCode: n } }) => n ?? "",
2219
+ sku: ({ itemId: e }) => e,
2220
+ gtin: ({ ean: e, referenceId: n }) => e || (n[0]?.Value ?? ""),
2221
+ mpn: ({ isVariantOf: { manufacturerCode: e } }) => e ?? "",
1962
2222
  review: () => [],
1963
2223
  aggregateRating: () => ({}),
1964
- offers: (n) => n.sellers.map(
1965
- (e) => nr({
1966
- offer: e.commertialOffer,
1967
- seller: e,
1968
- product: n
2224
+ offers: (e) => e.sellers.map(
2225
+ (n) => wr({
2226
+ offer: n.commertialOffer,
2227
+ seller: n,
2228
+ product: e
1969
2229
  })
1970
- ).sort(Kn),
1971
- isVariantOf: (n) => n,
2230
+ ).sort(en),
2231
+ isVariantOf: (e) => e,
1972
2232
  additionalProperty: ({
1973
2233
  // Search uses the name variations for specifications
1974
- variations: n = [],
1975
- attachmentsValues: e = [],
2234
+ variations: e = [],
2235
+ attachmentsValues: n = [],
1976
2236
  attributes: t = []
1977
2237
  }) => {
1978
- const r = n.flatMap(
1979
- ({ name: c, values: s }) => s.map((l) => ({
1980
- name: c,
2238
+ const r = e.flatMap(
2239
+ ({ name: o, values: s }) => s.map((l) => ({
2240
+ name: o,
1981
2241
  value: l,
1982
2242
  valueReference: Y.specification
1983
2243
  }))
1984
- ), i = e.map(
1985
- re
1986
- ), a = t.map(Ut);
2244
+ ), i = n.map(
2245
+ sn
2246
+ ), a = t.map(tr);
1987
2247
  return [
1988
2248
  ...r,
1989
2249
  ...i,
1990
2250
  ...a
1991
2251
  ];
1992
2252
  },
1993
- hasSpecifications: ({ isVariantOf: n }) => !!n.skuSpecifications?.length,
1994
- skuSpecifications: ({ isVariantOf: { skuSpecifications: n } }) => n ?? [],
1995
- specificationGroups: ({ isVariantOf: { specificationGroups: n } }) => n,
1996
- releaseDate: ({ isVariantOf: { releaseDate: n } }) => n ?? "",
1997
- advertisement: ({ isVariantOf: { advertisement: n } }) => n,
1998
- deliveryPromiseBadges: ({ isVariantOf: { deliveryPromisesBadges: n } }) => n
1999
- }, or = /* @__PURE__ */ new Set(["allSpecifications"]), sr = {
2000
- hasVariant: (n) => n.isVariantOf.items.map((e) => B(e, n.isVariantOf)),
2001
- productGroupID: ({ isVariantOf: n }) => n.productId,
2002
- name: (n) => n.isVariantOf.productName,
2003
- skuVariants: (n) => n,
2004
- additionalProperty: ({ isVariantOf: { specificationGroups: n } }) => n.filter(
2005
- (e) => !or.has(e.name)
2253
+ hasSpecifications: ({ isVariantOf: e }) => !!e.skuSpecifications?.length,
2254
+ skuSpecifications: ({ isVariantOf: { skuSpecifications: e } }) => e ?? [],
2255
+ specificationGroups: ({ isVariantOf: { specificationGroups: e } }) => e,
2256
+ releaseDate: ({ isVariantOf: { releaseDate: e } }) => e ?? "",
2257
+ advertisement: ({ isVariantOf: { advertisement: e } }) => e,
2258
+ deliveryPromiseBadges: ({ isVariantOf: { deliveryPromisesBadges: e } }) => e
2259
+ }, kr = /* @__PURE__ */ new Set(["allSpecifications"]), _r = {
2260
+ hasVariant: (e) => e.isVariantOf.items.map((n) => L(n, e.isVariantOf)),
2261
+ productGroupID: ({ isVariantOf: e }) => e.productId,
2262
+ name: (e) => e.isVariantOf.productName,
2263
+ skuVariants: (e) => e,
2264
+ additionalProperty: ({ isVariantOf: { specificationGroups: e } }) => e.filter(
2265
+ (n) => !kr.has(n.name)
2006
2266
  ).flatMap(
2007
- ({ specifications: e }) => e.flatMap(
2267
+ ({ specifications: n }) => n.flatMap(
2008
2268
  ({ name: t, values: r }) => r.map((i) => ({
2009
2269
  name: t,
2010
2270
  value: i,
@@ -2012,19 +2272,19 @@ const ir = (n, e) => {
2012
2272
  }))
2013
2273
  )
2014
2274
  )
2015
- }, cr = {
2016
- propertyID: (n) => n.propertyID || ie(n),
2017
- name: ({ name: n }) => n,
2018
- value: ({ value: n }) => n,
2019
- valueReference: ({ valueReference: n }) => n
2020
- }, lr = async (n, { operationId: e }, { clients: { commerce: t } }) => {
2021
- if (!e)
2022
- throw new k("Missing operationId");
2023
- return t.orderEntry.getOperation({ operationId: e });
2024
- }, dr = async (n, { orderFormId: e }, { clients: { commerce: t } }) => {
2025
- if (!e)
2026
- throw new k("Missing orderFormId");
2027
- const { items: r } = await t.orderEntry.getOrderFormItems({ orderFormId: e });
2275
+ }, Fr = {
2276
+ propertyID: (e) => e.propertyID || cn(e),
2277
+ name: ({ name: e }) => e,
2278
+ value: ({ value: e }) => e,
2279
+ valueReference: ({ valueReference: e }) => e
2280
+ }, Rr = async (e, { operationId: n }, { clients: { commerce: t } }) => {
2281
+ if (!n)
2282
+ throw new U("Missing operationId");
2283
+ return t.orderEntry.getOperation({ operationId: n });
2284
+ }, Nr = async (e, { orderFormId: n }, { clients: { commerce: t } }) => {
2285
+ if (!n)
2286
+ throw new U("Missing orderFormId");
2287
+ const { items: r } = await t.orderEntry.getOrderFormItems({ orderFormId: n });
2028
2288
  return (r ?? []).map((i) => ({
2029
2289
  id: i.id,
2030
2290
  name: i.name,
@@ -2036,18 +2296,18 @@ const ir = (n, e) => {
2036
2296
  seller: i.seller,
2037
2297
  unitMultiplier: i.unitMultiplier ?? 1
2038
2298
  }));
2039
- }, On = (n) => {
2040
- const e = n.flatMap(
2299
+ }, Se = (e) => {
2300
+ const n = e.flatMap(
2041
2301
  (r) => r.sellers.map((i) => ({
2042
2302
  offer: i.commertialOffer,
2043
2303
  sku: r
2044
2304
  }))
2045
- ), t = fn(
2046
- e,
2047
- ({ offer: r }, { offer: i }) => Kn(r, i)
2305
+ ), t = pe(
2306
+ n,
2307
+ ({ offer: r }, { offer: i }) => en(r, i)
2048
2308
  );
2049
- return t ? t.sku : n[0];
2050
- }, ur = (n) => n !== "" && !Number.isNaN(Number(n)), pr = {
2309
+ return t ? t.sku : e[0];
2310
+ }, Lr = (e) => e !== "" && !Number.isNaN(Number(e)), $e = {
2051
2311
  price_desc: "price:desc",
2052
2312
  price_asc: "price:asc",
2053
2313
  orders_desc: "orders:desc",
@@ -2056,94 +2316,114 @@ const ir = (n, e) => {
2056
2316
  release_desc: "release:desc",
2057
2317
  discount_desc: "discount:desc",
2058
2318
  score_desc: ""
2059
- }, gr = {
2060
- product: async (n, { locator: e }, t) => {
2061
- const r = Un(e), i = _n(e), a = vt(e), c = It(e);
2062
- r && Sn(t, r), i && yn(t, i);
2319
+ }, Sn = "Invalid SkuId", Br = "Slug was set but the fetched sku does not satisfy the slug condition.", Mr = (e) => He(e) || e instanceof Error && (e.message === Sn || e.message.startsWith(Br)), $r = {
2320
+ product: async (e, { locator: n }, t) => {
2321
+ const r = Fe(n), i = _e(n), a = Wt(n), o = jt(n);
2322
+ r && ge(t, r), i && me(t, i);
2063
2323
  const {
2064
2324
  loaders: { skuLoader: s },
2065
2325
  clients: { commerce: l, search: d }
2066
2326
  } = t;
2067
2327
  try {
2068
- const g = a ?? c?.split("-").pop() ?? "";
2069
- if (!ur(g))
2070
- throw new Error("Invalid SkuId");
2071
- const u = await s.load(g);
2072
- if (c && u.isVariantOf.linkText && !c.startsWith(u.isVariantOf.linkText))
2328
+ const g = a ?? o?.split("-").pop() ?? "";
2329
+ if (!Lr(g))
2330
+ throw new Error(Sn);
2331
+ const p = await s.load(g);
2332
+ if (o && p.isVariantOf.linkText && !o.startsWith(p.isVariantOf.linkText))
2073
2333
  throw new Error(
2074
- `Slug was set but the fetched sku does not satisfy the slug condition. slug: ${c}, linkText: ${u.isVariantOf.linkText}`
2334
+ `Slug was set but the fetched sku does not satisfy the slug condition. slug: ${o}, linkText: ${p.isVariantOf.linkText}`
2075
2335
  );
2076
- return u;
2077
- } catch {
2078
- if (c == null)
2079
- throw new k("Missing slug or id");
2080
- const u = await l.catalog.portal.pagetype(`${c}/p`);
2081
- if (u.pageType !== "Product" || !u.id)
2082
- throw new z(`No product found for slug ${c}`);
2083
- const {
2084
- products: [o]
2085
- } = await d.products({
2086
- page: 0,
2087
- count: 1,
2088
- query: `product:${u.id}`,
2089
- // Manually disabling this flag to prevent regionalization issues
2090
- hideUnavailableItems: !1
2091
- });
2092
- if (!o)
2093
- throw new z(`No product found for id ${u.id}`);
2094
- const p = On(o.items);
2095
- return B(p, o);
2336
+ return p;
2337
+ } catch (g) {
2338
+ if (!Mr(g))
2339
+ throw g;
2340
+ if (o == null)
2341
+ throw new U("Missing slug or id");
2342
+ const p = await l.catalog.portal.pagetype(`${o}/p`);
2343
+ if (p.pageType !== "Product" || !p.id)
2344
+ throw new B(`No product found for slug ${o}`);
2345
+ const c = await d.fetchProduct({
2346
+ field: "id",
2347
+ value: String(p.id)
2348
+ }).catch(() => null);
2349
+ if (!c)
2350
+ throw new B(`No product found for id ${p.id}`);
2351
+ const u = Se(c.items);
2352
+ return L(u, c);
2096
2353
  }
2097
2354
  },
2098
- collection: (n, { slug: e }, t) => {
2355
+ collection: (e, { slug: n }, t) => {
2099
2356
  const {
2100
2357
  loaders: { collectionLoader: r }
2101
2358
  } = t;
2102
- return r.load(e);
2359
+ return r.load(n);
2103
2360
  },
2104
- search: async (n, {
2105
- first: e,
2361
+ search: async (e, {
2362
+ first: n,
2106
2363
  after: t,
2107
2364
  sort: r,
2108
2365
  term: i,
2109
2366
  selectedFacets: a,
2110
- sponsoredCount: c
2367
+ sponsoredCount: o
2111
2368
  }, s) => {
2112
- const l = Un(a), d = _n(a), g = yt(a);
2113
- l && Sn(s, l), d && yn(s, d);
2114
- let u = i;
2115
- g && (u = `product:${(await s.clients.commerce.catalog.products.crossselling(
2116
- {
2117
- type: ne[g.key],
2369
+ const l = Fe(a), d = _e(a), g = qt(a);
2370
+ l && ge(s, l), d && me(s, d);
2371
+ const p = t ? Number(t) : 0, c = {
2372
+ page: Math.ceil(p / n) || 0,
2373
+ count: n,
2374
+ query: i ?? void 0,
2375
+ sort: $e[r ?? "score_desc"] ?? $e.score_desc,
2376
+ selectedFacets: a?.flatMap(Te) ?? [],
2377
+ sponsoredCount: o ?? void 0
2378
+ };
2379
+ if (g) {
2380
+ const S = (await s.clients.commerce.catalog.products.crossselling({
2381
+ type: rn[g.key],
2118
2382
  productId: g.value
2119
- }
2120
- )).map((I) => I.productId).slice(0, e).join(";")}`);
2121
- const o = t ? Number(t) : 0, p = {
2122
- page: Math.ceil(o / e) || 0,
2123
- count: e,
2124
- query: u ?? void 0,
2125
- sort: pr[r ?? "score_desc"],
2126
- selectedFacets: a?.flatMap(En) ?? [],
2127
- sponsoredCount: c ?? void 0
2128
- }, m = s.clients.search.products(p);
2129
- return { searchArgs: p, productSearchPromise: m };
2383
+ })).map((I) => I.productId).slice(0, n), f = s.clients.search.productsByIdentifier({ field: "id", values: S }).then((I) => ({
2384
+ products: I,
2385
+ recordsFiltered: I.length,
2386
+ pagination: {
2387
+ count: I.length,
2388
+ current: { index: 0, proxyURL: "" },
2389
+ before: [],
2390
+ after: [],
2391
+ perPage: n,
2392
+ next: { index: 0, proxyURL: "" },
2393
+ previous: { index: 0, proxyURL: "" },
2394
+ first: { index: 0, proxyURL: "" },
2395
+ last: { index: 0, proxyURL: "" }
2396
+ },
2397
+ sampling: !1,
2398
+ options: { sorts: [], counts: [] },
2399
+ translated: !1,
2400
+ locale: "",
2401
+ query: "",
2402
+ operator: "and",
2403
+ fuzzy: "0",
2404
+ searchId: ""
2405
+ }));
2406
+ return { searchArgs: c, productSearchPromise: f };
2407
+ }
2408
+ const u = s.clients.search.products(c);
2409
+ return { searchArgs: c, productSearchPromise: u };
2130
2410
  },
2131
- allProducts: async (n, { first: e, after: t }, r) => {
2411
+ allProducts: async (e, { first: n, after: t }, r) => {
2132
2412
  const {
2133
2413
  clients: { search: i }
2134
- } = r, a = t ? Number(t) : 0, c = await i.products({
2135
- page: Math.ceil(a / e),
2136
- count: e
2137
- }), s = c.products.flatMap(
2138
- (l) => l.items.map((d) => B(d, l))
2414
+ } = r, a = t ? Number(t) : 0, o = await i.products({
2415
+ page: Math.ceil(a / n),
2416
+ count: n
2417
+ }), s = o.products.flatMap(
2418
+ (l) => l.items.map((d) => L(d, l))
2139
2419
  ).filter((l) => l.sellers.length > 0);
2140
2420
  return {
2141
2421
  pageInfo: {
2142
- hasNextPage: c.pagination.after.length > 0,
2143
- hasPreviousPage: c.pagination.before.length > 0,
2422
+ hasNextPage: o.pagination.after.length > 0,
2423
+ hasPreviousPage: o.pagination.before.length > 0,
2144
2424
  startCursor: "0",
2145
- endCursor: c.recordsFiltered.toString(),
2146
- totalCount: c.recordsFiltered
2425
+ endCursor: o.recordsFiltered.toString(),
2426
+ totalCount: o.recordsFiltered
2147
2427
  },
2148
2428
  // after + index is bigger than after+first itself because of the array flat() above
2149
2429
  edges: s.map((l, d) => ({
@@ -2152,86 +2432,82 @@ const ir = (n, e) => {
2152
2432
  }))
2153
2433
  };
2154
2434
  },
2155
- products: async (n, { productIds: e }, t) => {
2435
+ products: async (e, { productIds: n }, t) => {
2156
2436
  const {
2157
2437
  clients: { search: r }
2158
2438
  } = t;
2159
- if (!e.length)
2160
- return [];
2161
- const i = `id:${e.join(";")}`;
2162
- return (await r.products({
2163
- page: 0,
2164
- count: e.length,
2165
- query: i
2166
- })).products.flatMap(
2167
- (c) => c.items.map((s) => B(s, c))
2439
+ return n.length ? (await r.productsByIdentifier({
2440
+ field: "id",
2441
+ values: n
2442
+ })).flatMap(
2443
+ (a) => a.items.map((o) => L(o, a))
2168
2444
  ).filter(
2169
- (c) => e.includes(c.itemId) && c.sellers.length > 0
2170
- );
2445
+ (a) => n.includes(a.itemId) && a.sellers.length > 0
2446
+ ) : [];
2171
2447
  },
2172
- allCollections: async (n, { first: e, after: t }, r) => {
2448
+ allCollections: async (e, { first: n, after: t }, r) => {
2173
2449
  const {
2174
2450
  clients: { commerce: i }
2175
- } = r, a = t ? Number(t) : 0, [c, s] = await Promise.all([
2451
+ } = r, a = t ? Number(t) : 0, [o, s] = await Promise.all([
2176
2452
  i.catalog.brand.list(),
2177
2453
  i.catalog.category.tree()
2178
- ]), l = [], d = (o, p) => {
2179
- l.push({ ...o, level: p });
2180
- for (const m of o.children)
2181
- d(m, p + 1);
2454
+ ]), l = [], d = (c, u) => {
2455
+ l.push({ ...c, level: u });
2456
+ for (const m of c.children)
2457
+ d(m, u + 1);
2182
2458
  };
2183
- for (const o of s)
2184
- d(o, 0);
2185
- const u = [
2186
- ...c.filter((o) => o.isActive).map((o) => ({ ...o, type: "brand" })),
2459
+ for (const c of s)
2460
+ d(c, 0);
2461
+ const p = [
2462
+ ...o.filter((c) => c.isActive).map((c) => ({ ...c, type: "brand" })),
2187
2463
  ...l
2188
- ].filter((o) => !!Zn.slug(o, null, r, null));
2464
+ ].filter((c) => !!tn.slug(c, null, r, null));
2189
2465
  return {
2190
2466
  pageInfo: {
2191
- hasNextPage: u.length - a > e,
2467
+ hasNextPage: p.length - a > n,
2192
2468
  hasPreviousPage: a > 0,
2193
2469
  startCursor: "0",
2194
- endCursor: (Math.min(e, u.length - a) - 1).toString(),
2195
- totalCount: u.length
2470
+ endCursor: (Math.min(n, p.length - a) - 1).toString(),
2471
+ totalCount: p.length
2196
2472
  },
2197
- edges: u.slice(a, a + e).map((o, p) => ({
2198
- node: o,
2199
- cursor: (a + p).toString()
2473
+ edges: p.slice(a, a + n).map((c, u) => ({
2474
+ node: c,
2475
+ cursor: (a + u).toString()
2200
2476
  }))
2201
2477
  };
2202
2478
  },
2203
- shipping: async (n, { country: e, items: t, postalCode: r }, i) => {
2479
+ shipping: async (e, { country: n, items: t, postalCode: r }, i) => {
2204
2480
  const {
2205
2481
  loaders: { simulationLoader: a },
2206
- clients: { commerce: c }
2482
+ clients: { commerce: o }
2207
2483
  } = i, [s, l] = await Promise.all([
2208
- a.load({ country: e, items: t, postalCode: r }),
2209
- c.checkout.address({ postalCode: r, country: e })
2484
+ a.load({ country: n, items: t, postalCode: r }),
2485
+ o.checkout.address({ postalCode: r, country: n })
2210
2486
  ]);
2211
2487
  return {
2212
2488
  ...s,
2213
2489
  address: l
2214
2490
  };
2215
2491
  },
2216
- redirect: async (n, { term: e, selectedFacets: t }, r) => {
2217
- if (!e && (!t || !t.length))
2492
+ redirect: async (e, { term: n, selectedFacets: t }, r) => {
2493
+ if (!n && (!t || !t.length))
2218
2494
  return null;
2219
2495
  const { redirect: i } = await r.clients.search.products({
2220
2496
  page: 1,
2221
2497
  count: 1,
2222
- query: e ?? void 0,
2223
- selectedFacets: t?.flatMap(En) ?? [],
2498
+ query: n ?? void 0,
2499
+ selectedFacets: t?.flatMap(Te) ?? [],
2224
2500
  allowRedirect: !0
2225
2501
  });
2226
2502
  return {
2227
2503
  url: i
2228
2504
  };
2229
2505
  },
2230
- sellers: async (n, { postalCode: e, geoCoordinates: t, country: r, salesChannel: i }, a) => {
2506
+ sellers: async (e, { postalCode: n, geoCoordinates: t, country: r, salesChannel: i }, a) => {
2231
2507
  const {
2232
- clients: { commerce: c }
2233
- } = a, l = (await c.checkout.region({
2234
- postalCode: e,
2508
+ clients: { commerce: o }
2509
+ } = a, l = (await o.checkout.region({
2510
+ postalCode: n,
2235
2511
  geoCoordinates: t,
2236
2512
  country: r,
2237
2513
  salesChannel: i
@@ -2241,10 +2517,10 @@ const ir = (n, e) => {
2241
2517
  sellers: g
2242
2518
  };
2243
2519
  },
2244
- profile: async (n, { id: e }, t) => {
2520
+ profile: async (e, { id: n }, t) => {
2245
2521
  const {
2246
2522
  clients: { commerce: r }
2247
- } = t, i = await r.profile.addresses(e);
2523
+ } = t, i = await r.profile.addresses(n);
2248
2524
  function a(s) {
2249
2525
  return !s || Object.keys(s).length === 0 ? [] : Object.values(s).map(
2250
2526
  (l) => JSON.parse(l)
@@ -2252,27 +2528,27 @@ const ir = (n, e) => {
2252
2528
  }
2253
2529
  return { addresses: a(i) };
2254
2530
  },
2255
- productCount: async (n, { term: e }, t) => {
2531
+ productCount: async (e, { term: n }, t) => {
2256
2532
  const {
2257
2533
  clients: { search: r }
2258
2534
  } = t;
2259
2535
  return await r.productCount({
2260
- query: e ?? void 0
2536
+ query: n ?? void 0
2261
2537
  });
2262
2538
  },
2263
- userOrder: async (n, { orderId: e }, t) => {
2539
+ userOrder: async (e, { orderId: n }, t) => {
2264
2540
  try {
2265
- if (!e)
2266
- throw new k("Missing orderId");
2541
+ if (!n)
2542
+ throw new U("Missing orderId");
2267
2543
  const {
2268
2544
  clients: { commerce: r }
2269
- } = t, i = await r.oms.userOrder({ orderId: e });
2545
+ } = t, i = await r.oms.userOrder({ orderId: n });
2270
2546
  if (!i)
2271
- throw new z(`No order found for id ${e}`);
2547
+ throw new B(`No order found for id ${n}`);
2272
2548
  let a = null;
2273
2549
  try {
2274
- const l = await r.oms.getCommercialAuthorizationsByOrderId({ orderId: e });
2275
- a = ee(l);
2550
+ const l = await r.oms.getCommercialAuthorizationsByOrderId({ orderId: n });
2551
+ a = an(l);
2276
2552
  } catch {
2277
2553
  }
2278
2554
  const s = (await r.masterData.getShopperById({
@@ -2310,16 +2586,16 @@ const ir = (n, e) => {
2310
2586
  } catch {
2311
2587
  a = { message: i };
2312
2588
  }
2313
- const c = a?.message || i;
2314
- throw ze(r) ? new z(`No order found for id ${e}. ${c}.`) : $e(r) ? new an(
2315
- `You are forbidden to interact with order with id ${e}. ${c}.`
2589
+ const o = a?.message || i;
2590
+ throw He(r) ? new B(`No order found for id ${n}. ${o}.`) : jn(r) ? new re(
2591
+ `You are forbidden to interact with order with id ${n}. ${o}.`
2316
2592
  ) : r;
2317
2593
  }
2318
2594
  },
2319
- listUserOrders: async (n, e, t) => {
2595
+ listUserOrders: async (e, n, t) => {
2320
2596
  const {
2321
2597
  clients: { commerce: r }
2322
- } = t, i = await r.oms.listUserOrders(e);
2598
+ } = t, i = await r.oms.listUserOrders(n);
2323
2599
  return {
2324
2600
  list: i.list?.map((a) => ({
2325
2601
  orderId: a.orderId,
@@ -2336,11 +2612,11 @@ const ir = (n, e) => {
2336
2612
  paging: i.paging
2337
2613
  };
2338
2614
  },
2339
- validateUser: async (n, e, t) => ({
2615
+ validateUser: async (e, n, t) => ({
2340
2616
  isValid: !0
2341
2617
  }),
2342
2618
  // only b2b users
2343
- userDetails: async (n, e, t) => {
2619
+ userDetails: async (e, n, t) => {
2344
2620
  const {
2345
2621
  account: r,
2346
2622
  headers: i,
@@ -2349,27 +2625,27 @@ const ir = (n, e) => {
2349
2625
  a.session("").catch(() => null),
2350
2626
  s ? a.masterData.getShopperById({ userId: s }).catch(() => null) : Promise.resolve(null),
2351
2627
  s ? a.licenseManager.getUserRoles({ userId: s }).catch(() => null) : Promise.resolve(null)
2352
- ]), u = d?.[0], o = l?.namespaces.authentication ?? null, p = `${(u?.firstName ?? "").trim()} ${(u?.lastName ?? "").trim()}`.trim();
2628
+ ]), p = d?.[0], c = l?.namespaces.authentication ?? null, u = `${(p?.firstName ?? "").trim()} ${(p?.lastName ?? "").trim()}`.trim();
2353
2629
  return {
2354
- username: o?.storeUserEmail?.value ?? "",
2355
- name: p,
2356
- email: o?.storeUserEmail?.value ?? "",
2357
- phone: u?.phone ?? "",
2630
+ username: c?.storeUserEmail?.value ?? "",
2631
+ name: u,
2632
+ email: c?.storeUserEmail?.value ?? "",
2633
+ phone: p?.phone ?? "",
2358
2634
  role: g?.Roles?.map((m) => m.Name) ?? [],
2359
- orgUnit: o?.unitName?.value ?? ""
2635
+ orgUnit: c?.unitName?.value ?? ""
2360
2636
  };
2361
2637
  },
2362
2638
  // If isRepresentative, return b2b information.
2363
2639
  // If not, return b2c user information
2364
- accountProfile: async (n, e, t) => {
2640
+ accountProfile: async (e, n, t) => {
2365
2641
  const {
2366
2642
  account: r,
2367
2643
  headers: i,
2368
2644
  clients: { commerce: a }
2369
- } = t, c = Z(Q(i?.cookie ?? "", r));
2370
- if (!c?.userId)
2645
+ } = t, o = Z(Q(i?.cookie ?? "", r));
2646
+ if (!o?.userId)
2371
2647
  return null;
2372
- if (c?.isRepresentative) {
2648
+ if (o?.isRepresentative) {
2373
2649
  const l = await a.session("").catch(() => null);
2374
2650
  if (!l)
2375
2651
  return null;
@@ -2384,7 +2660,7 @@ const ir = (n, e) => {
2384
2660
  };
2385
2661
  }
2386
2662
  const s = await a.licenseManager.getUserById({
2387
- userId: c?.userId
2663
+ userId: o?.userId
2388
2664
  }).catch(() => null);
2389
2665
  return {
2390
2666
  name: s?.name || "",
@@ -2393,17 +2669,17 @@ const ir = (n, e) => {
2393
2669
  // createdAt: '',
2394
2670
  };
2395
2671
  },
2396
- pickupPoints: async (n, { geoCoordinates: e }, t) => {
2672
+ pickupPoints: async (e, { geoCoordinates: n }, t) => {
2397
2673
  const {
2398
2674
  clients: { commerce: r }
2399
2675
  } = t;
2400
2676
  return await r.checkout.pickupPoints({
2401
- geoCoordinates: e
2677
+ geoCoordinates: n
2402
2678
  });
2403
2679
  },
2404
- orderEntryOperation: lr,
2405
- orderFormItems: dr
2406
- }, mr = {
2680
+ orderEntryOperation: Rr,
2681
+ orderFormItems: Nr
2682
+ }, zr = {
2407
2683
  reviewRating: () => ({
2408
2684
  ratingValue: 5,
2409
2685
  bestRating: 5
@@ -2411,43 +2687,43 @@ const ir = (n, e) => {
2411
2687
  author: () => ({
2412
2688
  name: ""
2413
2689
  })
2414
- }, hr = (n, e, t) => e ? n.key === "category-1" : t ? n.key === "brand" : !1, fr = {
2415
- suggestions: async (n, e, t) => {
2690
+ }, Vr = (e, n, t) => n ? e.key === "category-1" : t ? e.key === "brand" : !1, xr = {
2691
+ suggestions: async (e, n, t) => {
2416
2692
  const {
2417
2693
  clients: { search: r }
2418
- } = t, { searchArgs: i } = n;
2694
+ } = t, { searchArgs: i } = e;
2419
2695
  if (!i.query)
2420
2696
  return {
2421
- terms: (await r.topSearches()).searches.map((u) => ({
2422
- value: u.term,
2423
- count: u.count
2697
+ terms: (await r.topSearches()).searches.map((p) => ({
2698
+ value: p.term,
2699
+ count: p.count
2424
2700
  })),
2425
2701
  products: []
2426
2702
  };
2427
- const { productSearchPromise: a } = n, [c, s] = await Promise.all([
2703
+ const { productSearchPromise: a } = e, [o, s] = await Promise.all([
2428
2704
  r.suggestedTerms(i),
2429
2705
  a
2430
2706
  ]), l = s.products.map((g) => {
2431
- const u = On(g.items);
2432
- return u && B(u, g);
2433
- }).filter((g) => !!g), { searches: d } = c;
2707
+ const p = Se(g.items);
2708
+ return p && L(p, g);
2709
+ }).filter((g) => !!g), { searches: d } = o;
2434
2710
  return {
2435
2711
  terms: d.map((g) => ({ value: g.term, count: g.count })),
2436
2712
  products: l
2437
2713
  };
2438
2714
  },
2439
- products: async ({ productSearchPromise: n }) => {
2440
- const e = await n, t = e.products.map((r) => {
2441
- const i = On(r.items);
2442
- return i && B(i, r);
2715
+ products: async ({ productSearchPromise: e }) => {
2716
+ const n = await e, t = n.products.map((r) => {
2717
+ const i = Se(r.items);
2718
+ return i && L(i, r);
2443
2719
  }).filter((r) => !!r);
2444
2720
  return {
2445
2721
  pageInfo: {
2446
- hasNextPage: e.pagination.after.length > 0,
2447
- hasPreviousPage: e.pagination.before.length > 0,
2722
+ hasNextPage: n.pagination.after.length > 0,
2723
+ hasPreviousPage: n.pagination.before.length > 0,
2448
2724
  startCursor: "0",
2449
- endCursor: e.recordsFiltered.toString(),
2450
- totalCount: e.recordsFiltered
2725
+ endCursor: n.recordsFiltered.toString(),
2726
+ totalCount: n.recordsFiltered
2451
2727
  },
2452
2728
  edges: t.map((r, i) => ({
2453
2729
  node: r,
@@ -2455,31 +2731,31 @@ const ir = (n, e) => {
2455
2731
  }))
2456
2732
  };
2457
2733
  },
2458
- facets: async ({ searchArgs: n }, e, t) => {
2734
+ facets: async ({ searchArgs: e }, n, t) => {
2459
2735
  const {
2460
2736
  clients: { search: r }
2461
2737
  } = t;
2462
- t.storage.searchArgs = n;
2463
- const { facets: i = [] } = await r.facets(n), a = !n.query, c = n.selectedFacets?.length ? n.selectedFacets[0].key === "category-1" : !1, s = n.selectedFacets?.length ? n.selectedFacets[0].key === "brand" : !1;
2738
+ t.storage.searchArgs = e;
2739
+ const { facets: i = [] } = await r.facets(e), a = !e.query, o = e.selectedFacets?.length ? e.selectedFacets[0].key === "category-1" : !1, s = e.selectedFacets?.length ? e.selectedFacets[0].key === "brand" : !1;
2464
2740
  return i.filter(
2465
- (d) => !a || !hr(d, c, s)
2741
+ (d) => !a || !Vr(d, o, s)
2466
2742
  );
2467
2743
  },
2468
- metadata: async ({ productSearchPromise: n }) => {
2469
- const e = await n;
2744
+ metadata: async ({ productSearchPromise: e }) => {
2745
+ const n = await e;
2470
2746
  return {
2471
- isTermMisspelled: e.correction?.misspelled ?? !1,
2472
- logicalOperator: e.operator,
2473
- fuzzy: e.fuzzy
2747
+ isTermMisspelled: n.correction?.misspelled ?? !1,
2748
+ logicalOperator: n.operator,
2749
+ fuzzy: n.fuzzy
2474
2750
  };
2475
2751
  },
2476
- searchId: async ({ productSearchPromise: n }) => (await n).searchId
2477
- }, Sr = {
2478
- title: ({ title: n }) => n ?? "",
2479
- description: ({ description: n }) => n ?? "",
2480
- canonical: ({ canonical: n }) => n ?? "",
2752
+ searchId: async ({ productSearchPromise: e }) => (await e).searchId
2753
+ }, qr = {
2754
+ title: ({ title: e }) => e ?? "",
2755
+ description: ({ description: e }) => e ?? "",
2756
+ canonical: ({ canonical: e }) => e ?? "",
2481
2757
  titleTemplate: () => ""
2482
- }, yr = ["bd", "d", "h", "m"], Ir = (n) => yr.includes(n), vr = {
2758
+ }, jr = ["bd", "d", "h", "m"], Wr = (e) => jr.includes(e), Gr = {
2483
2759
  bd: {
2484
2760
  0: "Today",
2485
2761
  1: "In 1 business day",
@@ -2500,86 +2776,86 @@ const ir = (n, e) => {
2500
2776
  1: "In 1 minute",
2501
2777
  other: "Up to # minutes"
2502
2778
  }
2503
- }, ge = (n) => {
2504
- const [e, t] = [n.split(/\D+/)[0], n.split(/[0-9]+/)[1]], r = e !== "" && !Number.isNaN(Number(e)), i = Ir(t);
2779
+ }, yn = (e) => {
2780
+ const [n, t] = [e.split(/\D+/)[0], e.split(/[0-9]+/)[1]], r = n !== "" && !Number.isNaN(Number(n)), i = Wr(t);
2505
2781
  if (!r || !i)
2506
2782
  return "";
2507
- const a = Number(e) < 2 ? Number(e) : "other";
2508
- return vr[t][a].replace("#", e) ?? "";
2509
- }, Or = {
2510
- carrier: (n) => n?.friendlyName ?? n?.name ?? "",
2511
- price: (n) => n?.price ? n.price / 100 : n?.price,
2512
- localizedEstimates: (n) => n?.shippingEstimate ? ge(n.shippingEstimate) : ""
2513
- }, Mn = "skuvariation";
2514
- function Bn(n, e) {
2515
- const t = `${Mn}${e}`.toLowerCase(), r = n.find(
2783
+ const a = Number(n) < 2 ? Number(n) : "other";
2784
+ return Gr[t][a].replace("#", n) ?? "";
2785
+ }, Hr = {
2786
+ carrier: (e) => e?.friendlyName ?? e?.name ?? "",
2787
+ price: (e) => e?.price ? e.price / 100 : e?.price,
2788
+ localizedEstimates: (e) => e?.shippingEstimate ? yn(e.shippingEstimate) : ""
2789
+ }, ze = "skuvariation";
2790
+ function Ve(e, n) {
2791
+ const t = `${ze}${n}`.toLowerCase(), r = e.find(
2516
2792
  (a) => a.imageLabel === t
2517
2793
  );
2518
2794
  if (r)
2519
2795
  return r;
2520
- const i = n.find(
2521
- (a) => a.imageLabel === Mn
2796
+ const i = e.find(
2797
+ (a) => a.imageLabel === ze
2522
2798
  );
2523
- return i || n[0];
2799
+ return i || e[0];
2524
2800
  }
2525
- function Cr(n, e, t) {
2801
+ function Xr(e, n, t) {
2526
2802
  const r = {};
2527
- return n.forEach((i) => {
2803
+ return e.forEach((i) => {
2528
2804
  const a = i.variations;
2529
2805
  if (a.length === 0)
2530
2806
  return;
2531
- const c = `${e}-${a.find(
2532
- (l) => l.name === e
2533
- )?.values[0] ?? ""}`, s = a.reduce((l, d) => d.name === e ? l : l + `-${d.name}-${d.values[0]}`, c);
2807
+ const o = `${n}-${a.find(
2808
+ (l) => l.name === n
2809
+ )?.values[0] ?? ""}`, s = a.reduce((l, d) => d.name === n ? l : l + `-${d.name}-${d.values[0]}`, o);
2534
2810
  r[s] = `${t}-${i.itemId}`;
2535
2811
  }), r;
2536
2812
  }
2537
- function $n(n) {
2538
- const e = {};
2539
- return n.forEach((t) => {
2540
- e[t.name] = t.values[0];
2541
- }), e;
2542
- }
2543
- function br(n) {
2544
- const e = {};
2545
- return n?.forEach((t) => {
2546
- e[t.field.originalName ?? t.field.name] = t.values.map((r) => r.originalName ?? r.name);
2547
- }), e;
2548
- }
2549
- function Dr(n, e) {
2550
- return Number.isNaN(Number(n) - Number(e)) ? n < e ? -1 : n > e ? 1 : 0 : Number(n) - Number(e);
2551
- }
2552
- function wr(n) {
2553
- const e = n;
2554
- for (const t in n)
2555
- n[t].every(
2813
+ function xe(e) {
2814
+ const n = {};
2815
+ return e.forEach((t) => {
2816
+ n[t.name] = t.values[0];
2817
+ }), n;
2818
+ }
2819
+ function Yr(e) {
2820
+ const n = {};
2821
+ return e?.forEach((t) => {
2822
+ n[t.field.originalName ?? t.field.name] = t.values.map((r) => r.originalName ?? r.name);
2823
+ }), n;
2824
+ }
2825
+ function Jr(e, n) {
2826
+ return Number.isNaN(Number(e) - Number(n)) ? e < n ? -1 : e > n ? 1 : 0 : Number(e) - Number(n);
2827
+ }
2828
+ function Kr(e) {
2829
+ const n = e;
2830
+ for (const t in e)
2831
+ e[t].every(
2556
2832
  (i) => !Number.isNaN(Number(i.value))
2557
- ) && n[t].sort((i, a) => Dr(i.value, a.value));
2558
- return e;
2833
+ ) && e[t].sort((i, a) => Jr(i.value, a.value));
2834
+ return n;
2559
2835
  }
2560
- function Ar(n, e, t) {
2836
+ function Qr(e, n, t) {
2561
2837
  const r = {}, i = /* @__PURE__ */ new Set();
2562
- return n.forEach((a) => {
2838
+ return e.forEach((a) => {
2563
2839
  if (a.variations.length === 0)
2564
2840
  return;
2565
- const c = a.variations.find(
2566
- (l) => l.name === e
2841
+ const o = a.variations.find(
2842
+ (l) => l.name === n
2567
2843
  );
2568
- if (!(c?.values[0] === t)) {
2569
- const l = `${e}-${c?.values[0]}`;
2570
- if (!c || i.has(l))
2844
+ if (!(o?.values[0] === t)) {
2845
+ const l = `${n}-${o?.values[0]}`;
2846
+ if (!o || i.has(l))
2571
2847
  return;
2572
2848
  i.add(l);
2573
- const d = Bn(
2849
+ const d = Ve(
2574
2850
  a.images,
2575
- e
2851
+ n
2576
2852
  ), g = {
2577
2853
  src: d.imageUrl,
2578
2854
  alt: d.imageLabel ?? "",
2579
- label: `${e}: ${c.values[0]}`,
2580
- value: c.values[0]
2855
+ label: `${n}: ${o.values[0]}`,
2856
+ value: o.values[0]
2581
2857
  };
2582
- r[c.name] ? r[c.name].push(g) : r[c.name] = [g];
2858
+ r[o.name] ? r[o.name].push(g) : r[o.name] = [g];
2583
2859
  return;
2584
2860
  }
2585
2861
  a.variations.forEach((l) => {
@@ -2587,108 +2863,108 @@ function Ar(n, e, t) {
2587
2863
  if (i.has(d))
2588
2864
  return;
2589
2865
  i.add(d);
2590
- const g = Bn(
2866
+ const g = Ve(
2591
2867
  a.images,
2592
2868
  l.name
2593
- ), u = {
2869
+ ), p = {
2594
2870
  src: g.imageUrl,
2595
2871
  alt: g.imageText ?? "",
2596
2872
  label: `${l.name}: ${l.values[0]}`,
2597
2873
  value: l.values[0]
2598
2874
  };
2599
- r[l.name] ? r[l.name].push(u) : r[l.name] = [u];
2875
+ r[l.name] ? r[l.name].push(p) : r[l.name] = [p];
2600
2876
  });
2601
- }), wr(r);
2602
- }
2603
- const Pr = {
2604
- activeVariations: (n) => $n(n.variations),
2605
- allVariantsByName: (n) => br(n.isVariantOf.skuSpecifications),
2606
- slugsMap: (n, e) => Cr(
2607
- n.isVariantOf.items,
2608
- e.dominantVariantName ?? n.variations[0]?.name,
2609
- n.isVariantOf.linkText
2877
+ }), Kr(r);
2878
+ }
2879
+ const Zr = {
2880
+ activeVariations: (e) => xe(e.variations),
2881
+ allVariantsByName: (e) => Yr(e.isVariantOf.skuSpecifications),
2882
+ slugsMap: (e, n) => Xr(
2883
+ e.isVariantOf.items,
2884
+ n.dominantVariantName ?? e.variations[0]?.name,
2885
+ e.isVariantOf.linkText
2610
2886
  ),
2611
- availableVariations: (n, e) => {
2612
- const t = e.dominantVariantName ?? n.variations[0]?.name, i = $n(n.variations)[t];
2613
- return Ar(
2614
- n.isVariantOf.items,
2887
+ availableVariations: (e, n) => {
2888
+ const t = n.dominantVariantName ?? e.variations[0]?.name, i = xe(e.variations)[t];
2889
+ return Qr(
2890
+ e.isVariantOf.items,
2615
2891
  t,
2616
2892
  i
2617
2893
  );
2618
2894
  },
2619
- allVariantProducts: (n) => n.isVariantOf.items.map((e) => B(e, n.isVariantOf))
2620
- }, Er = {
2895
+ allVariantProducts: (e) => e.isVariantOf.items.map((n) => L(n, e.isVariantOf))
2896
+ }, ei = {
2621
2897
  "pickup-in-point": "Pickup",
2622
2898
  delivery: "Delivery",
2623
2899
  pickup: "Pickup",
2624
2900
  "take-away": "Take away",
2625
2901
  "": ""
2626
- }, Tr = {
2627
- deliveryOptionsData: (n) => {
2628
- const { shippingData: e, items: t } = n, r = e?.logisticsInfo || [], i = e?.selectedAddresses || e?.availableAddresses || [e?.address], a = r.reduce(
2902
+ }, ni = {
2903
+ deliveryOptionsData: (e) => {
2904
+ const { shippingData: n, items: t } = e, r = n?.logisticsInfo || [], i = n?.selectedAddresses || n?.availableAddresses || [n?.address], a = r.reduce(
2629
2905
  (d, g) => {
2630
- const u = g?.selectedSla || "", o = g?.selectedDeliveryChannel || g?.deliveryChannel || "", p = g?.deliveryCompany || "", m = g?.deliveryWindow, S = g?.pickupStoreInfo, I = g?.shippingEstimate || "", O = g?.shippingEstimate ? ge(g?.shippingEstimate) : "", w = g?.shippingEstimateDate || "", _ = g?.addressId || "", P = g?.itemIndex ?? 0, b = t?.[P], E = b?.seller || "", h = `${u}|${o}|${p}|${E}|${I}|${w}|${_}|${m?.startDateUtc}|${m?.endDateUtc}`, v = i?.find(
2631
- (T) => T?.addressId === _
2632
- ), C = `${Er[o] || ""} ${O} ${v?.neighborhood ? `to ${v?.neighborhood}` : ""}`.trim(), { taxPriceTagsTotal: D, taxPriceTags: y } = _r(
2633
- b?.priceTags ?? []
2634
- ), A = (b?.sellingPrice ?? 0) * (b?.quantity ?? 0) + (b?.tax ?? 0) + (D ?? 0);
2906
+ const p = g?.selectedSla || "", c = g?.selectedDeliveryChannel || g?.deliveryChannel || "", u = g?.deliveryCompany || "", m = g?.deliveryWindow, S = g?.pickupStoreInfo, f = g?.shippingEstimate || "", I = g?.shippingEstimate ? yn(g?.shippingEstimate) : "", D = g?.shippingEstimateDate || "", E = g?.addressId || "", w = g?.itemIndex ?? 0, O = t?.[w], P = O?.seller || "", h = `${p}|${c}|${u}|${P}|${f}|${D}|${E}|${m?.startDateUtc}|${m?.endDateUtc}`, b = i?.find(
2907
+ (_) => _?.addressId === E
2908
+ ), C = `${ei[c] || ""} ${I} ${b?.neighborhood ? `to ${b?.neighborhood}` : ""}`.trim(), { taxPriceTagsTotal: A, taxPriceTags: v } = ti(
2909
+ O?.priceTags ?? []
2910
+ ), T = (O?.sellingPrice ?? 0) * (O?.quantity ?? 0) + (O?.tax ?? 0) + (A ?? 0);
2635
2911
  return d[h] || (d[h] = {
2636
2912
  // static fields
2637
- selectedSla: u,
2638
- deliveryChannel: o,
2639
- deliveryCompany: p,
2913
+ selectedSla: p,
2914
+ deliveryChannel: c,
2915
+ deliveryCompany: u,
2640
2916
  deliveryWindow: m,
2641
- shippingEstimate: I,
2642
- shippingEstimateDate: w,
2643
- seller: E,
2644
- friendlyShippingEstimate: O,
2917
+ shippingEstimate: f,
2918
+ shippingEstimateDate: D,
2919
+ seller: P,
2920
+ friendlyShippingEstimate: I,
2645
2921
  friendlyDeliveryOptionName: C,
2646
- address: v,
2922
+ address: b,
2647
2923
  pickupStoreInfo: S,
2648
2924
  // dynamic fields
2649
2925
  quantityOfDifferentItems: 0,
2650
2926
  total: 0,
2651
2927
  items: []
2652
2928
  }), d[h] && (d[h].items?.push({
2653
- id: b?.id || "",
2654
- uniqueId: b?.uniqueId || "",
2655
- name: b?.name || "",
2656
- quantity: b?.quantity || 0,
2657
- price: b?.price || 0,
2658
- sellingPrice: b?.sellingPrice || 0,
2659
- imageUrl: b?.imageUrl || "",
2660
- taxPriceTags: y ?? [],
2661
- taxPriceTagsTotal: D ?? 0,
2662
- tax: b?.tax || 0,
2663
- total: A
2664
- }), d[h].quantityOfDifferentItems = (d[h].quantityOfDifferentItems ?? 0) + 1, d[h].total = (d[h].total ?? 0) + A), d;
2929
+ id: O?.id || "",
2930
+ uniqueId: O?.uniqueId || "",
2931
+ name: O?.name || "",
2932
+ quantity: O?.quantity || 0,
2933
+ price: O?.price || 0,
2934
+ sellingPrice: O?.sellingPrice || 0,
2935
+ imageUrl: O?.imageUrl || "",
2936
+ taxPriceTags: v ?? [],
2937
+ taxPriceTagsTotal: A ?? 0,
2938
+ tax: O?.tax || 0,
2939
+ total: T
2940
+ }), d[h].quantityOfDifferentItems = (d[h].quantityOfDifferentItems ?? 0) + 1, d[h].total = (d[h].total ?? 0) + T), d;
2665
2941
  },
2666
2942
  {}
2667
- ), c = Object.values(a), s = e?.contactInformation?.[0], l = {
2668
- name: `${s?.firstName ?? ""} ${s?.lastName ?? ""}`.trim() || c?.[0]?.address?.receiverName || "",
2943
+ ), o = Object.values(a), s = n?.contactInformation?.[0], l = {
2944
+ name: `${s?.firstName ?? ""} ${s?.lastName ?? ""}`.trim() || o?.[0]?.address?.receiverName || "",
2669
2945
  email: s?.email || "",
2670
2946
  phone: s?.phone || ""
2671
2947
  };
2672
2948
  return {
2673
- deliveryOptions: c,
2949
+ deliveryOptions: o,
2674
2950
  contact: l
2675
2951
  };
2676
2952
  },
2677
- customFields: (n) => {
2678
- const e = n?.customData?.customFields || [];
2953
+ customFields: (e) => {
2954
+ const n = e?.customData?.customFields || [];
2679
2955
  return Object.values(
2680
- e.reduce(
2956
+ n.reduce(
2681
2957
  (t, r) => {
2682
- const i = r?.linkedEntity?.type || "", a = r?.linkedEntity?.id || "", c = `${i}|${a || ""}`;
2683
- return t[c] || (t[c] = { type: i, id: a, fields: [] }), t[c].fields.push(...r?.fields || []), t;
2958
+ const i = r?.linkedEntity?.type || "", a = r?.linkedEntity?.id || "", o = `${i}|${a || ""}`;
2959
+ return t[o] || (t[o] = { type: i, id: a, fields: [] }), t[o].fields.push(...r?.fields || []), t;
2684
2960
  },
2685
2961
  {}
2686
2962
  )
2687
2963
  ) || [];
2688
2964
  }
2689
2965
  };
2690
- function _r(n) {
2691
- const t = n.filter(
2966
+ function ti(e) {
2967
+ const t = e.filter(
2692
2968
  (i) => i?.name?.includes("TAX")
2693
2969
  ), r = t.reduce(
2694
2970
  (i, a) => i + (a.rawValue ? a.rawValue * 100 : 0),
@@ -2699,28 +2975,28 @@ function _r(n) {
2699
2975
  taxPriceTagsTotal: r
2700
2976
  };
2701
2977
  }
2702
- const Ur = {
2703
- StoreCollection: Zn,
2704
- StoreAggregateOffer: pt,
2705
- StoreProduct: ar,
2706
- StoreSeo: Sr,
2707
- StoreFacet: Ot,
2708
- StoreFacetBoolean: Ct,
2709
- StoreFacetRange: bt,
2710
- StoreFacetValueBoolean: Dt,
2711
- StoreOffer: Qt,
2712
- StoreAggregateRating: gt,
2713
- StoreReview: mr,
2714
- StoreProductGroup: sr,
2715
- StoreSearchResult: fr,
2716
- StorePropertyValue: cr,
2717
- SkuVariants: Pr,
2718
- ShippingSLA: Or,
2719
- UserOrderResult: Tr,
2720
- ObjectOrString: Kt,
2721
- Query: gr,
2722
- Mutation: Xt
2723
- }, kr = () => Ur, Fr = `"""
2978
+ const ri = {
2979
+ StoreCollection: tn,
2980
+ StoreAggregateOffer: Bt,
2981
+ StoreProduct: Tr,
2982
+ StoreSeo: qr,
2983
+ StoreFacet: Gt,
2984
+ StoreFacetBoolean: Ht,
2985
+ StoreFacetRange: Xt,
2986
+ StoreFacetValueBoolean: Yt,
2987
+ StoreOffer: br,
2988
+ StoreAggregateRating: Mt,
2989
+ StoreReview: zr,
2990
+ StoreProductGroup: _r,
2991
+ StoreSearchResult: xr,
2992
+ StorePropertyValue: Fr,
2993
+ SkuVariants: Zr,
2994
+ ShippingSLA: Hr,
2995
+ UserOrderResult: ni,
2996
+ ObjectOrString: Cr,
2997
+ Query: $r,
2998
+ Mutation: Ir
2999
+ }, ii = () => ri, ai = `"""
2724
3000
  Address information.
2725
3001
  """
2726
3002
  type Address {
@@ -2765,7 +3041,7 @@ type Address {
2765
3041
  """
2766
3042
  geoCoordinates: [Float]
2767
3043
  }
2768
- `, Nr = `"""
3044
+ `, oi = `"""
2769
3045
  Advertisement information about a specific product in a campaign
2770
3046
  """
2771
3047
  type Advertisement {
@@ -2790,7 +3066,7 @@ type Advertisement {
2790
3066
  """
2791
3067
  adResponseId: String!
2792
3068
  }
2793
- `, Rr = `"""
3069
+ `, si = `"""
2794
3070
  Aggregate offer information, for a given SKU that is available to be fulfilled by multiple sellers.
2795
3071
  """
2796
3072
  type StoreAggregateOffer {
@@ -2819,7 +3095,7 @@ type StoreAggregateOffer {
2819
3095
  """
2820
3096
  offers: [StoreOffer!]!
2821
3097
  }
2822
- `, Lr = `"""
3098
+ `, ci = `"""
2823
3099
  Average rating, based on multiple ratings or reviews.
2824
3100
  """
2825
3101
  type StoreAggregateRating {
@@ -2832,7 +3108,7 @@ type StoreAggregateRating {
2832
3108
  """
2833
3109
  reviewCount: Int!
2834
3110
  }
2835
- `, Mr = `"""
3111
+ `, li = `"""
2836
3112
  information about the author of a product review or rating.
2837
3113
  """
2838
3114
  type StoreAuthor {
@@ -2841,7 +3117,7 @@ type StoreAuthor {
2841
3117
  """
2842
3118
  name: String!
2843
3119
  }
2844
- `, Br = `"""
3120
+ `, di = `"""
2845
3121
  Brand of a given product.
2846
3122
  """
2847
3123
  type StoreBrand {
@@ -2850,7 +3126,7 @@ type StoreBrand {
2850
3126
  """
2851
3127
  name: String!
2852
3128
  }
2853
- `, $r = `"""
3129
+ `, ui = `"""
2854
3130
  Item of a list.
2855
3131
  """
2856
3132
  type StoreListItem {
@@ -2881,7 +3157,7 @@ type StoreBreadcrumbList {
2881
3157
  """
2882
3158
  numberOfItems: Int!
2883
3159
  }
2884
- `, zr = `"""
3160
+ `, pi = `"""
2885
3161
  Shopping cart message.
2886
3162
  """
2887
3163
  type StoreCartMessage {
@@ -2918,7 +3194,7 @@ input IStoreCart {
2918
3194
  """
2919
3195
  order: IStoreOrder!
2920
3196
  }
2921
- `, Vr = `"""
3197
+ `, gi = `"""
2922
3198
  Product collection type. Possible values are \`Department\`, \`Category\`, \`Brand\`, \`Cluster\`, \`SubCategory\` or \`Collection\`.
2923
3199
  """
2924
3200
  enum StoreCollectionType {
@@ -3001,7 +3277,7 @@ type StoreCollection {
3001
3277
  """
3002
3278
  type: StoreCollectionType!
3003
3279
  }
3004
- `, xr = `"""
3280
+ `, mi = `"""
3005
3281
  Delivery Promise badge.
3006
3282
  """
3007
3283
  type DeliveryPromiseBadge {
@@ -3010,7 +3286,7 @@ type DeliveryPromiseBadge {
3010
3286
  """
3011
3287
  typeName: String
3012
3288
  }
3013
- `, qr = `union StoreFacet = StoreFacetRange | StoreFacetBoolean
3289
+ `, hi = `union StoreFacet = StoreFacetRange | StoreFacetBoolean
3014
3290
 
3015
3291
  """
3016
3292
  Search facet range information.
@@ -3087,7 +3363,7 @@ type StoreFacetValueBoolean {
3087
3363
  """
3088
3364
  quantity: Int
3089
3365
  }
3090
- `, jr = `"""
3366
+ `, fi = `"""
3091
3367
  Image.
3092
3368
  """
3093
3369
  type StoreImage {
@@ -3114,7 +3390,7 @@ input IStoreImage {
3114
3390
  """
3115
3391
  alternateName: String!
3116
3392
  }
3117
- `, Wr = `type Mutation {
3393
+ `, Si = `type Mutation {
3118
3394
  """
3119
3395
  Checks for changes between the cart presented in the UI and the cart stored in the ecommerce platform. If changes are detected, it returns the cart stored on the platform. Otherwise, it returns \`null\`.
3120
3396
  """
@@ -3152,7 +3428,7 @@ input IStoreImage {
3152
3428
  data: IOrderEntryOperation!
3153
3429
  ): StoreOrderEntryOperationResult @auth
3154
3430
  }
3155
- `, Gr = `"""
3431
+ `, yi = `"""
3156
3432
  Newsletter information.
3157
3433
  """
3158
3434
  type PersonNewsletter {
@@ -3175,8 +3451,8 @@ input IPersonNewsletter {
3175
3451
  """
3176
3452
  email: String!
3177
3453
  }
3178
- `, Hr = `scalar ObjectOrString
3179
- `, Xr = `"""
3454
+ `, Ii = `scalar ObjectOrString
3455
+ `, vi = `"""
3180
3456
  Offer information.
3181
3457
  """
3182
3458
  type StoreOffer {
@@ -3259,7 +3535,7 @@ input IStoreOffer {
3259
3535
  """
3260
3536
  quantity: Int!
3261
3537
  }
3262
- `, Yr = `"""
3538
+ `, Oi = `"""
3263
3539
  Information of a specific order.
3264
3540
  """
3265
3541
  type StoreOrder {
@@ -3294,7 +3570,7 @@ input IStoreOrder {
3294
3570
  """
3295
3571
  shouldSplitItem: Boolean
3296
3572
  }
3297
- `, Jr = `"""
3573
+ `, Ci = `"""
3298
3574
  Commercial Authorization response.
3299
3575
  """
3300
3576
  type CommercialAuthorizationResponse {
@@ -3693,7 +3969,7 @@ type ProcessOrderAuthorizationRule {
3693
3969
  """
3694
3970
  rule: CommercialAuthorizationRule!
3695
3971
  }
3696
- `, Kr = `"""
3972
+ `, bi = `"""
3697
3973
  Input for uploading a file to the Order Entry Service.
3698
3974
  The file is transmitted as a Base64-encoded string so it can travel
3699
3975
  through the standard GraphQL JSON pipeline without multipart support.
@@ -3754,7 +4030,7 @@ type StoreOrderFormCartItem {
3754
4030
  seller: String!
3755
4031
  unitMultiplier: Float
3756
4032
  }
3757
- `, Qr = `"""
4033
+ `, Di = `"""
3758
4034
  Organization.
3759
4035
  """
3760
4036
  type StoreOrganization {
@@ -3773,7 +4049,7 @@ input IStoreOrganization {
3773
4049
  """
3774
4050
  identifier: String!
3775
4051
  }
3776
- `, Zr = `"""
4052
+ `, wi = `"""
3777
4053
  Whenever you make a query that allows for pagination, such as \`allProducts\` or \`allCollections\`, you can check \`StorePageInfo\` to learn more about the complete set of items and use it to paginate your queries.
3778
4054
  """
3779
4055
  type StorePageInfo {
@@ -3798,7 +4074,7 @@ type StorePageInfo {
3798
4074
  """
3799
4075
  totalCount: Int!
3800
4076
  }
3801
- `, ni = `"""
4077
+ `, Pi = `"""
3802
4078
  Input type for setting a new password.
3803
4079
  """
3804
4080
  input ISetPassword {
@@ -3841,7 +4117,7 @@ type SetPasswordResponse {
3841
4117
  """
3842
4118
  message: String
3843
4119
  }
3844
- `, ei = `"""
4120
+ `, Ai = `"""
3845
4121
  Client profile data.
3846
4122
  """
3847
4123
  type StorePerson {
@@ -3884,7 +4160,7 @@ input IStorePerson {
3884
4160
  """
3885
4161
  familyName: String!
3886
4162
  }
3887
- `, ti = `type PickupPointAddress {
4163
+ `, Ei = `type PickupPointAddress {
3888
4164
  """
3889
4165
  Address city.
3890
4166
  """
@@ -3963,7 +4239,7 @@ type PickupPoints {
3963
4239
  """
3964
4240
  pickupPointsHash: String
3965
4241
  }
3966
- `, ri = `"""
4242
+ `, Ui = `"""
3967
4243
  Product information. Products are variants within product groups, equivalent to VTEX [SKUs](https://help.vtex.com/en/tutorial/what-is-an-sku--1K75s4RXAQyOuGUYKMM68u#). For example, you may have a **Shirt** product group with associated products such as **Blue shirt size L**, **Green shirt size XL** and so on.
3968
4244
  """
3969
4245
  type StoreProduct {
@@ -4112,7 +4388,7 @@ input IStoreProduct {
4112
4388
  """
4113
4389
  additionalProperty: [IStorePropertyValue!]
4114
4390
  }
4115
- `, ii = `"""
4391
+ `, Ti = `"""
4116
4392
  Product group information. Product groups are catalog entities that may contain variants. They are equivalent to VTEX [Products](https://help.vtex.com/en/tutorial/what-is-a-product--2zrB2gFCHyQokCKKE8kuAw#), whereas each variant is equivalent to a VTEX [SKU](https://help.vtex.com/en/tutorial/what-is-an-sku--1K75s4RXAQyOuGUYKMM68u#). For example, you may have a **Shirt** product group with associated products such as **Blue shirt size L**, **Green shirt size XL** and so on.
4117
4393
  """
4118
4394
  type StoreProductGroup {
@@ -4139,7 +4415,7 @@ type StoreProductGroup {
4139
4415
  """
4140
4416
  skuVariants: SkuVariants
4141
4417
  }
4142
- `, ai = `type Profile {
4418
+ `, ki = `type Profile {
4143
4419
  """
4144
4420
  Collection of user's address
4145
4421
  """
@@ -4200,7 +4476,7 @@ type ProfileAddress {
4200
4476
  """
4201
4477
  geoCoordinate: [Float]
4202
4478
  }
4203
- `, oi = `"""
4479
+ `, _i = `"""
4204
4480
  Properties that can be associated with products and products groups.
4205
4481
  """
4206
4482
  type StorePropertyValue {
@@ -4240,7 +4516,7 @@ input IStorePropertyValue {
4240
4516
  """
4241
4517
  valueReference: ObjectOrString!
4242
4518
  }
4243
- `, si = `"""
4519
+ `, Fi = `"""
4244
4520
  Each product edge contains a \`node\`, with product information, and a \`cursor\`, that can be used as a reference for pagination.
4245
4521
  """
4246
4522
  type StoreProductEdge {
@@ -4802,7 +5078,7 @@ type StoreAccountProfile {
4802
5078
  email: String
4803
5079
  id: String
4804
5080
  }
4805
- `, ci = `"""
5081
+ `, Ri = `"""
4806
5082
  Information of a given review rating.
4807
5083
  """
4808
5084
  type StoreReviewRating {
@@ -4829,7 +5105,7 @@ type StoreReview {
4829
5105
  """
4830
5106
  author: StoreAuthor!
4831
5107
  }
4832
- `, li = `"""
5108
+ `, Ni = `"""
4833
5109
  Search Engine Optimization (SEO) tags data.
4834
5110
  """
4835
5111
  type StoreSeo {
@@ -4850,7 +5126,7 @@ type StoreSeo {
4850
5126
  """
4851
5127
  canonical: String!
4852
5128
  }
4853
- `, di = `"""
5129
+ `, Li = `"""
4854
5130
  Currency information.
4855
5131
  """
4856
5132
  type StoreCurrency {
@@ -5125,7 +5401,7 @@ input IStoreSession {
5125
5401
  """
5126
5402
  refreshAfter: String
5127
5403
  }
5128
- `, ui = `"""
5404
+ `, Bi = `"""
5129
5405
  Shipping Simulation item input.
5130
5406
  """
5131
5407
  input IShippingItem {
@@ -5456,7 +5732,7 @@ type MessageFields {
5456
5732
  """
5457
5733
  skuName: String
5458
5734
  }
5459
- `, pi = `type SkuVariants {
5735
+ `, Mi = `type SkuVariants {
5460
5736
  """
5461
5737
  SKU property values for the current SKU.
5462
5738
  """
@@ -5551,7 +5827,7 @@ Example:
5551
5827
  \`\`\`
5552
5828
  """
5553
5829
  scalar FormattedVariants
5554
- `, gi = `"""
5830
+ `, $i = `"""
5555
5831
  Status used to indicate a message type. For instance, a shopping cart informative or error message.
5556
5832
  """
5557
5833
  enum StoreStatus {
@@ -5559,7 +5835,7 @@ enum StoreStatus {
5559
5835
  WARNING
5560
5836
  ERROR
5561
5837
  }
5562
- `, mi = `scalar JSONObject
5838
+ `, zi = `scalar JSONObject
5563
5839
 
5564
5840
  type UserOrder {
5565
5841
  orderId: String
@@ -6383,95 +6659,95 @@ type UserOrderBudgetAllocationLinkedEntity {
6383
6659
  type: String
6384
6660
  id: String
6385
6661
  }
6386
- `, hi = /* @__PURE__ */ Object.assign({
6387
- "./address.graphql": Fr,
6388
- "./advertisement.graphql": Nr,
6389
- "./aggregateOffer.graphql": Rr,
6390
- "./aggregateRating.graphql": Lr,
6391
- "./author.graphql": Mr,
6392
- "./brand.graphql": Br,
6393
- "./breadcrumb.graphql": $r,
6394
- "./cart.graphql": zr,
6395
- "./collection.graphql": Vr,
6396
- "./deliveryPromisesBadge.graphql": xr,
6397
- "./facet.graphql": qr,
6398
- "./image.graphql": jr,
6399
- "./mutation.graphql": Wr,
6400
- "./newsletter.graphql": Gr,
6401
- "./objectOrString.graphql": Hr,
6402
- "./offer.graphql": Xr,
6403
- "./order.graphql": Yr,
6404
- "./orderCommercialAuthorizaton.graphql": Jr,
6405
- "./orderEntry.graphql": Kr,
6406
- "./organization.graphql": Qr,
6407
- "./pageInfo.graphql": Zr,
6408
- "./password.graphql": ni,
6409
- "./person.graphql": ei,
6410
- "./pickupPoints.graphql": ti,
6411
- "./product.graphql": ri,
6412
- "./productGroup.graphql": ii,
6413
- "./profile.graphql": ai,
6414
- "./propertyValue.graphql": oi,
6415
- "./query.graphql": si,
6416
- "./review.graphql": ci,
6417
- "./seo.graphql": li,
6418
- "./session.graphql": di,
6419
- "./shipping.graphql": ui,
6420
- "./skuVariants.graphql": pi,
6421
- "./status.graphql": gi,
6422
- "./userOrder.graphql": mi
6423
- }), fi = ye(
6424
- Object.values(hi).map((n) => Ie(n)).reduce(
6425
- (n, e) => zn([n, e], { sort: !0 })
6662
+ `, Vi = /* @__PURE__ */ Object.assign({
6663
+ "./address.graphql": ai,
6664
+ "./advertisement.graphql": oi,
6665
+ "./aggregateOffer.graphql": si,
6666
+ "./aggregateRating.graphql": ci,
6667
+ "./author.graphql": li,
6668
+ "./brand.graphql": di,
6669
+ "./breadcrumb.graphql": ui,
6670
+ "./cart.graphql": pi,
6671
+ "./collection.graphql": gi,
6672
+ "./deliveryPromisesBadge.graphql": mi,
6673
+ "./facet.graphql": hi,
6674
+ "./image.graphql": fi,
6675
+ "./mutation.graphql": Si,
6676
+ "./newsletter.graphql": yi,
6677
+ "./objectOrString.graphql": Ii,
6678
+ "./offer.graphql": vi,
6679
+ "./order.graphql": Oi,
6680
+ "./orderCommercialAuthorizaton.graphql": Ci,
6681
+ "./orderEntry.graphql": bi,
6682
+ "./organization.graphql": Di,
6683
+ "./pageInfo.graphql": wi,
6684
+ "./password.graphql": Pi,
6685
+ "./person.graphql": Ai,
6686
+ "./pickupPoints.graphql": Ei,
6687
+ "./product.graphql": Ui,
6688
+ "./productGroup.graphql": Ti,
6689
+ "./profile.graphql": ki,
6690
+ "./propertyValue.graphql": _i,
6691
+ "./query.graphql": Fi,
6692
+ "./review.graphql": Ri,
6693
+ "./seo.graphql": Ni,
6694
+ "./session.graphql": Li,
6695
+ "./shipping.graphql": Bi,
6696
+ "./skuVariants.graphql": Mi,
6697
+ "./status.graphql": $i,
6698
+ "./userOrder.graphql": zi
6699
+ }), xi = bn(
6700
+ Object.values(Vi).map((e) => Dn(e)).reduce(
6701
+ (e, n) => qe([e, n], { sort: !0 })
6426
6702
  )
6427
- ), Si = fi, Ri = async (n) => M.context.with(
6428
- M.propagation.extract(M.context.active(), n.OTEL),
6429
- () => (e) => (e.storage = {
6430
- channel: nn.parse(n.channel),
6431
- flags: n.flags ?? {},
6432
- locale: n.locale,
6703
+ ), qi = xi, sa = async (e) => N.context.with(
6704
+ N.propagation.extract(N.context.active(), e.OTEL),
6705
+ () => (n) => (n.storage = {
6706
+ channel: ee.parse(e.channel),
6707
+ flags: e.flags ?? {},
6708
+ locale: e.locale,
6433
6709
  cookies: /* @__PURE__ */ new Map()
6434
- }, e.clients = Qe(n, e), e.loaders = ct(n, e), e.account = n.account, e.OTEL = n.OTEL, e.discoveryConfig = n.discoveryConfig, e)
6710
+ }, n.clients = bt(e, n), n.loaders = Ft(e, n), n.account = e.account, n.OTEL = e.OTEL, n.discoveryConfig = e.discoveryConfig, n)
6435
6711
  );
6436
- function yi() {
6437
- const n = kr(), e = {};
6438
- for (const [t, r] of Object.entries(n))
6439
- e[t] = Object.fromEntries(
6440
- Object.entries(r).map(([i, a]) => typeof a != "function" ? [i, a] : [i, Be(a, `${t}(${i})`)])
6712
+ function ji() {
6713
+ const e = ii(), n = {};
6714
+ for (const [t, r] of Object.entries(e))
6715
+ n[t] = Object.fromEntries(
6716
+ Object.entries(r).map(([i, a]) => typeof a != "function" ? [i, a] : [i, qn(a, `${t}(${i})`)])
6441
6717
  );
6442
- return e;
6718
+ return n;
6443
6719
  }
6444
- function Li(n) {
6445
- const t = Me([
6446
- Le,
6447
- Fe
6448
- ])(yi(), Si);
6449
- return n && ve(n) ? fe({
6450
- schemas: [t, n]
6720
+ function ca(e) {
6721
+ const t = xn([
6722
+ Vn,
6723
+ Mn
6724
+ ])(ji(), qi);
6725
+ return e && wn(e) ? On({
6726
+ schemas: [t, e]
6451
6727
  }) : t;
6452
6728
  }
6453
6729
  export {
6454
- Fe as AuthDirective,
6455
- k as BadRequestError,
6456
- Le as CacheControlDirective,
6457
- De as CommercialAuthorizationStatus,
6730
+ Mn as AuthDirective,
6731
+ U as BadRequestError,
6732
+ Vn as CacheControlDirective,
6733
+ Un as CommercialAuthorizationStatus,
6458
6734
  X as FastStoreError,
6459
- an as ForbiddenError,
6460
- Ri as GraphqlVtexContextFactory,
6461
- Li as GraphqlVtexSchema,
6462
- z as NotFoundError,
6463
- we as StoreCollectionType,
6464
- Ae as StoreFacetType,
6465
- Pe as StoreSort,
6466
- Ee as StoreStatus,
6735
+ re as ForbiddenError,
6736
+ sa as GraphqlVtexContextFactory,
6737
+ ca as GraphqlVtexSchema,
6738
+ B as NotFoundError,
6739
+ Tn as StoreCollectionType,
6740
+ kn as StoreFacetType,
6741
+ _n as StoreSort,
6742
+ Fn as StoreStatus,
6467
6743
  J as UnauthorizedError,
6468
- Te as UserOrderInvoiceType,
6469
- Fi as isBadRequestError,
6470
- ki as isFastStoreError,
6471
- $e as isForbiddenError,
6472
- ze as isNotFoundError,
6473
- Ni as isUnauthorizedError,
6474
- Ui as stringifyCacheControl,
6475
- Si as typeDefs,
6476
- Me as withDirectives
6744
+ Rn as UserOrderInvoiceType,
6745
+ aa as isBadRequestError,
6746
+ ia as isFastStoreError,
6747
+ jn as isForbiddenError,
6748
+ He as isNotFoundError,
6749
+ oa as isUnauthorizedError,
6750
+ ra as stringifyCacheControl,
6751
+ qi as typeDefs,
6752
+ xn as withDirectives
6477
6753
  };