@faststore/api 4.0.1-dev.2 → 4.1.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/index.mjs CHANGED
@@ -1,26 +1,26 @@
1
1
  import { mergeTypeDefs as Vn } from "@graphql-tools/merge";
2
2
  import { makeExecutableSchema as me, mergeSchemas as he } from "@graphql-tools/schema";
3
- import { mapSchema as xn, MapperKind as qn, getDirective as Wn } from "@graphql-tools/utils";
3
+ import { mapSchema as xn, MapperKind as qn, getDirective as jn } from "@graphql-tools/utils";
4
4
  import { OTELAPI as L } from "@faststore/diagnostics";
5
5
  import { GraphQLScalarType as fe, print as Se, parse as ye, isSchema as Ie } from "graphql";
6
- import { parse as nn } from "cookie";
6
+ import { parse as tn } from "cookie";
7
7
  import ve from "isomorphic-unfetch";
8
- import en from "dataloader";
9
- import jn from "p-limit";
8
+ import rn from "dataloader";
9
+ import Wn from "p-limit";
10
10
  import Oe from "sanitize-html";
11
- import vn from "fast-deep-equal";
11
+ import Cn from "fast-deep-equal";
12
12
  import Ce from "node:crypto";
13
- var be = /* @__PURE__ */ ((n) => (n.Accepted = "accepted", n.Denied = "denied", n.Pending = "pending", n))(be || {}), De = /* @__PURE__ */ ((n) => (n.Brand = "Brand", n.Category = "Category", n.Cluster = "Cluster", n.Collection = "Collection", n.Department = "Department", n.SubCategory = "SubCategory", n))(De || {}), we = /* @__PURE__ */ ((n) => (n.Boolean = "BOOLEAN", n.Range = "RANGE", n))(we || {}), Ae = /* @__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))(Ae || {}), Pe = /* @__PURE__ */ ((n) => (n.Error = "ERROR", n.Info = "INFO", n.Warning = "WARNING", n))(Pe || {}), ke = /* @__PURE__ */ ((n) => (n.Input = "Input", n.Output = "Output", n))(ke || {});
14
- const _e = () => function(e = {}) {
13
+ var be = /* @__PURE__ */ ((n) => (n.Accepted = "accepted", n.Denied = "denied", n.Pending = "pending", n))(be || {}), De = /* @__PURE__ */ ((n) => (n.Brand = "Brand", n.Category = "Category", n.Cluster = "Cluster", n.Collection = "Collection", n.Department = "Department", n.SubCategory = "SubCategory", n))(De || {}), we = /* @__PURE__ */ ((n) => (n.Boolean = "BOOLEAN", n.Range = "RANGE", n))(we || {}), Ae = /* @__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))(Ae || {}), Pe = /* @__PURE__ */ ((n) => (n.Error = "ERROR", n.Info = "INFO", n.Warning = "WARNING", n))(Pe || {}), Ue = /* @__PURE__ */ ((n) => (n.Input = "Input", n.Output = "Output", n))(Ue || {});
14
+ const ke = () => function(e = {}) {
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 tn("No authentication AppKey and AppToken passed.");
17
+ throw new an("No authentication AppKey and AppToken passed.");
18
18
  return {
19
19
  ...e,
20
20
  "X-VTEX-API-AppKey": t,
21
21
  "X-VTEX-API-AppToken": r
22
22
  };
23
- }, Ue = async (n) => {
23
+ }, _e = async (n) => {
24
24
  const {
25
25
  clients: { commerce: e }
26
26
  } = n;
@@ -29,15 +29,15 @@ const _e = () => function(e = {}) {
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 tn("You are not allowed to access this resource") : new J("Authentication required");
32
+ throw r === 401 ? new J("Authentication required") : r === 403 ? new an("You are not allowed to access this resource") : new J("Authentication required");
33
33
  }
34
34
  }, Te = "auth", Ee = {
35
35
  typeDefs: "directive @auth on FIELD_DEFINITION",
36
36
  transformer: (n) => xn(n, {
37
37
  [qn.OBJECT_FIELD]: (e) => {
38
- if (Wn(n, e, Te)?.[0]) {
38
+ if (jn(n, e, Te)?.[0]) {
39
39
  const r = e.resolve;
40
- e.resolve = async (i, a, o, s) => (await Ue(o), r?.(i, a, o, s));
40
+ e.resolve = async (i, a, o, s) => (await _e(o), r?.(i, a, o, s));
41
41
  }
42
42
  return e;
43
43
  }
@@ -53,7 +53,7 @@ const _e = () => function(e = {}) {
53
53
  typeDefs: "directive @cacheControl(sMaxAge: Int, staleWhileRevalidate: Int, scope: String) on FIELD_DEFINITION",
54
54
  transformer: (n) => xn(n, {
55
55
  [qn.OBJECT_FIELD]: (e) => {
56
- const t = Wn(n, e, Ne)?.[0];
56
+ const t = jn(n, e, Ne)?.[0];
57
57
  if (t) {
58
58
  const { sMaxAge: r, staleWhileRevalidate: i, scope: a } = t, o = e.resolve;
59
59
  e.resolve = (s, c, d, p) => (d.cacheControl = {
@@ -80,13 +80,13 @@ const _e = () => function(e = {}) {
80
80
  resolvers: e
81
81
  })
82
82
  );
83
- }, on = "@faststore/api", sn = "4.0.1-dev.1", wn = {
84
- name: on,
85
- version: sn
83
+ }, cn = "@faststore/api", ln = "4.1.0-dev.0", wn = {
84
+ name: cn,
85
+ version: ln
86
86
  }, Be = (n, e) => (t, r, i, a) => {
87
87
  if ((i?.OTEL?.enabled ?? !1) === !1)
88
88
  return n(t, r, i, a);
89
- const o = L.trace.getTracer(on, sn), s = L.propagation.extract(
89
+ const o = L.trace.getTracer(cn, ln), s = L.propagation.extract(
90
90
  L.context.active(),
91
91
  i.OTEL
92
92
  );
@@ -96,8 +96,8 @@ const _e = () => function(e = {}) {
96
96
  kind: L.SpanKind.INTERNAL,
97
97
  attributes: {
98
98
  timestamp: Date.now(),
99
- "@faststore_version": sn,
100
- "@faststore_package_name": on,
99
+ "@faststore_version": ln,
100
+ "@faststore_package_name": cn,
101
101
  "@faststore_account_name": i.account,
102
102
  "@faststore_environment": process.env.NODE_ENV
103
103
  }
@@ -126,7 +126,7 @@ class J extends X {
126
126
  super({ status: 401, type: "UnauthorizedError" }, e);
127
127
  }
128
128
  }
129
- class tn extends X {
129
+ class an extends X {
130
130
  constructor(e) {
131
131
  super({ status: 403, type: "ForbiddenError" }, e);
132
132
  }
@@ -136,7 +136,7 @@ class $ extends X {
136
136
  super({ status: 404, type: "NotFoundError" }, e);
137
137
  }
138
138
  }
139
- const ki = (n) => n?.name === "FastStoreError", _i = (n) => n?.extensions?.type === "BadRequestError", Ui = (n) => n?.extensions?.type === "UnauthorizedError", Me = (n) => n?.extensions?.type === "ForbiddenError", $e = (n) => n?.extensions?.type === "NotFoundError", ze = `${wn.name}@${wn.version}`, I = async (n, e, t) => {
139
+ const Ui = (n) => n?.name === "FastStoreError", ki = (n) => n?.extensions?.type === "BadRequestError", _i = (n) => n?.extensions?.type === "UnauthorizedError", Me = (n) => n?.extensions?.type === "ForbiddenError", $e = (n) => n?.extensions?.type === "NotFoundError", ze = `${wn.name}@${wn.version}`, I = async (n, e, t) => {
140
140
  const r = await ve(n, {
141
141
  ...e,
142
142
  headers: {
@@ -155,7 +155,7 @@ const ki = (n) => n?.name === "FastStoreError", _i = (n) => n?.extensions?.type
155
155
  case 401:
156
156
  throw new J(i);
157
157
  case 403:
158
- throw new tn(i);
158
+ throw new an(i);
159
159
  case 404:
160
160
  throw new $(i);
161
161
  default:
@@ -192,7 +192,7 @@ const ki = (n) => n?.name === "FastStoreError", _i = (n) => n?.extensions?.type
192
192
  e.getSetCookie().forEach(
193
193
  (t) => xe(n, t)
194
194
  );
195
- }, We = (n) => (e) => qe(n, e), je = (n) => {
195
+ }, je = (n) => (e) => qe(n, e), We = (n) => {
196
196
  if (!n.headers?.cookie)
197
197
  return null;
198
198
  const e = Gn(n.headers.cookie), t = Array.from(n.storage.cookies.entries());
@@ -204,22 +204,22 @@ const ki = (n) => n?.name === "FastStoreError", _i = (n) => n?.extensions?.type
204
204
  ),
205
205
  e
206
206
  );
207
- }, On = (n) => function(t) {
208
- const r = je(n);
207
+ }, bn = (n) => function(t) {
208
+ const r = We(n);
209
209
  return r ? {
210
210
  ...t,
211
211
  cookie: r
212
212
  } : t;
213
- }, Cn = (n, e) => {
213
+ }, Q = (n, e) => {
214
214
  const t = Gn(n);
215
- return nn(t)[`VtexIdclientAutCookie_${e}`] || "";
215
+ return tn(t)[`VtexIdclientAutCookie_${e}`] || "";
216
216
  }, Ge = (n) => {
217
- const e = On(n);
217
+ const e = bn(n);
218
218
  return function(r, i) {
219
219
  const a = e({
220
220
  "content-type": "application/json",
221
221
  "X-FORWARDED-HOST": r
222
- }), o = Cn(
222
+ }), o = Q(
223
223
  n?.headers?.cookie ?? "",
224
224
  i
225
225
  );
@@ -232,7 +232,7 @@ const ki = (n) => n?.name === "FastStoreError", _i = (n) => n?.extensions?.type
232
232
  `${i[1]}=${t}`
233
233
  ) : `${n};${e}=${t}`;
234
234
  };
235
- function bn(n) {
235
+ function Z(n) {
236
236
  return n ? JSON.parse(Buffer.from(n.split(".")[1], "base64").toString()) : null;
237
237
  }
238
238
  const H = {
@@ -241,7 +241,7 @@ const H = {
241
241
  "content-type": "application/json"
242
242
  }
243
243
  }, Xe = ({ account: n, environment: e, incrementAddress: t, subDomainPrefix: r }, i) => {
244
- const a = `https://${n}.${e}.com.br`, o = We(i), s = On(i), c = Ge(i), d = _e(), p = new Headers(i.headers).get("x-forwarded-host") ?? i.headers?.host ?? "", m = r && r.map((l) => l + ".").find((l) => p.includes(l)) || "", u = p.replace(m, "");
244
+ const a = `https://${n}.${e}.com.br`, o = je(i), s = bn(i), c = Ge(i), d = ke(), p = new Headers(i.headers).get("x-forwarded-host") ?? i.headers?.host ?? "", m = r && r.map((l) => l + ".").find((l) => p.includes(l)) || "", u = p.replace(m, "");
245
245
  return {
246
246
  catalog: {
247
247
  salesChannel: (l) => I(
@@ -314,8 +314,8 @@ const H = {
314
314
  startDateUtc: f?.deliveryWindow?.startDate,
315
315
  endDateUtc: f?.deliveryWindow?.endDate
316
316
  } : null, A = {
317
- logisticsInfo: Array.from({ length: g }, (v, k) => ({
318
- itemIndex: k,
317
+ logisticsInfo: Array.from({ length: g }, (v, U) => ({
318
+ itemIndex: U,
319
319
  selectedDeliveryChannel: f?.deliveryChannel || null,
320
320
  selectedSla: f?.deliveryMethod || null,
321
321
  deliveryWindow: D
@@ -543,11 +543,11 @@ const H = {
543
543
  const g = new URLSearchParams(l);
544
544
  g.set(
545
545
  "items",
546
- "profile.id,profile.email,profile.firstName,profile.lastName,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"
546
+ "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"
547
547
  );
548
548
  const f = s({
549
549
  "content-type": "application/json"
550
- }), S = nn(i?.headers?.cookie ?? "")?.vtex_session;
550
+ }), S = tn(i?.headers?.cookie ?? "")?.vtex_session;
551
551
  return I(
552
552
  `${a}/api/sessions?${g.toString()}`,
553
553
  {
@@ -622,7 +622,7 @@ const H = {
622
622
  "creation_date",
623
623
  `creationDate:[${f} TO ${S}]`
624
624
  ) : f ? v.append("creation_date", `creationDate:[${f} TO *]`) : S && v.append("creation_date", `creationDate:[* TO ${S}]`), D && v.append("clientEmail", D), l && v.append("page", l.toString()), A && v.append("per_page", A.toString()), T && v.append("my_pending_approvals", String(!0));
625
- const k = s({
625
+ const U = s({
626
626
  "content-type": "application/json",
627
627
  "X-FORWARDED-HOST": u
628
628
  });
@@ -630,7 +630,7 @@ const H = {
630
630
  `${a}/api/oms/user/orders?${v.toString()}`,
631
631
  {
632
632
  method: "GET",
633
- headers: k
633
+ headers: U
634
634
  },
635
635
  { storeCookies: o }
636
636
  );
@@ -739,6 +739,19 @@ const H = {
739
739
  },
740
740
  {}
741
741
  );
742
+ },
743
+ getUserRoles: ({
744
+ userId: l
745
+ }) => {
746
+ const g = c(u, n);
747
+ return I(
748
+ `${a}/api/license-manager/storefront/users/${l}/roles`,
749
+ {
750
+ method: "GET",
751
+ headers: g
752
+ },
753
+ {}
754
+ );
742
755
  }
743
756
  },
744
757
  masterData: {
@@ -798,12 +811,12 @@ const H = {
798
811
  }
799
812
  }
800
813
  };
801
- }, cn = "trade-policy", ln = "region-id", dn = "fuzzy", un = "operator", pn = "pickupPoint", Hn = "shipping", Xn = "delivery-options", Yn = "in-stock", Ye = /* @__PURE__ */ new Set([
802
- cn,
803
- ln,
814
+ }, dn = "trade-policy", un = "region-id", pn = "fuzzy", gn = "operator", mn = "pickupPoint", Hn = "shipping", Xn = "delivery-options", Yn = "in-stock", Ye = /* @__PURE__ */ new Set([
804
815
  dn,
805
816
  un,
806
817
  pn,
818
+ gn,
819
+ mn,
807
820
  Hn,
808
821
  Xn,
809
822
  Yn
@@ -815,60 +828,60 @@ const H = {
815
828
  showSponsored: i,
816
829
  subDomainPrefix: a
817
830
  }, o) => {
818
- const s = `https://${n}.${e}.com.br/api/io`, c = On(o), d = new Headers(o.headers).get("x-forwarded-host") ?? o.headers?.host ?? "", p = a && a.map((h) => h + ".").find((h) => d.includes(h)) || "", m = d.replace(p, ""), u = c({
831
+ const s = `https://${n}.${e}.com.br/api/io`, c = bn(o), d = new Headers(o.headers).get("x-forwarded-host") ?? o.headers?.host ?? "", p = a && a.map((h) => h + ".").find((h) => d.includes(h)) || "", m = d.replace(p, ""), u = c({
819
832
  "content-type": "application/json",
820
833
  "X-FORWARDED-HOST": m
821
834
  }), l = () => {
822
835
  const { salesChannel: h } = o.storage.channel;
823
836
  return h ? {
824
- key: cn,
837
+ key: dn,
825
838
  value: h
826
839
  } : null;
827
840
  }, g = () => {
828
- const { regionId: h, seller: C } = o.storage.channel, _ = (C ? Buffer.from(`SW#${C}`).toString("base64") : null) ?? h;
829
- return _ ? {
830
- key: ln,
831
- value: _
841
+ const { regionId: h, seller: C } = o.storage.channel, k = (C ? Buffer.from(`SW#${C}`).toString("base64") : null) ?? h;
842
+ return k ? {
843
+ key: un,
844
+ value: k
832
845
  } : null;
833
846
  }, f = (h) => {
834
847
  const C = h.filter(
835
848
  ({ key: P }) => !Ye.has(P)
836
849
  ), b = h.find(
837
850
  ({ key: P, value: E }) => P === Hn && E !== "all-delivery-methods"
838
- ) ?? null, _ = h.find(
851
+ ) ?? null, k = h.find(
839
852
  ({ key: P, value: E }) => P === Xn && E !== "all-delivery-options"
840
- ) ?? null, y = h.find(({ key: P }) => P === cn) ?? l(), w = h.find(({ key: P }) => P === ln) ?? g();
841
- return b !== null && C.push(b), _ !== null && C.push(_), y !== null && C.push(y), w !== null && C.push(w), C;
853
+ ) ?? null, y = h.find(({ key: P }) => P === dn) ?? l(), w = h.find(({ key: P }) => P === un) ?? g();
854
+ return b !== null && C.push(b), k !== null && C.push(k), y !== null && C.push(y), w !== null && C.push(w), C;
842
855
  }, S = (h, C) => {
843
- const b = h.find(({ key: w }) => w === dn) ?? null, _ = h.find(({ key: w }) => w === un) ?? null, y = h.find(({ key: w }) => w === pn) ?? null;
844
- b && Je(b) && C.append(dn, b.value), _ && Ke(_) && C.append(un, _.value), y && C.append(pn, y.value);
856
+ const b = h.find(({ key: w }) => w === pn) ?? null, k = h.find(({ key: w }) => w === gn) ?? null, y = h.find(({ key: w }) => w === mn) ?? null;
857
+ b && Je(b) && C.append(pn, b.value), k && Ke(k) && C.append(gn, k.value), y && C.append(mn, y.value);
845
858
  }, O = ({
846
859
  query: h = "",
847
860
  page: C,
848
861
  count: b,
849
- sort: _ = "",
862
+ sort: k = "",
850
863
  selectedFacets: y = [],
851
864
  type: w,
852
865
  showInvisibleItems: P,
853
866
  sponsoredCount: E,
854
- hideUnavailableItems: U,
867
+ hideUnavailableItems: _,
855
868
  allowRedirect: G = !1
856
869
  }) => {
857
870
  const N = new URLSearchParams({
858
871
  page: (C + 1).toString(),
859
872
  count: b !== 0 ? b.toString() : "1",
860
873
  query: h,
861
- sort: _,
874
+ sort: k,
862
875
  locale: o.storage.locale
863
876
  });
864
877
  if (S(y, N), P && N.append("show-invisible-items", "true"), t !== void 0) {
865
878
  const x = y.find(
866
879
  ({ key: ge }) => ge === Yn
867
- ), rn = x ? x.value : U?.toString() ?? t.toString();
868
- N.append("hideUnavailableItems", rn);
880
+ ), on = x ? x.value : _?.toString() ?? t.toString();
881
+ N.append("hideUnavailableItems", on);
869
882
  }
870
883
  r !== void 0 && N.append("simulationBehavior", r.toString()), i !== void 0 && N.append("showSponsored", i.toString()), E !== void 0 && N.append("sponsoredCount", E.toString()), G !== void 0 && N.append("allowRedirect", G.toString());
871
- const M = f(y).map(({ key: x, value: rn }) => `${x}/${rn}`).join("/");
884
+ const M = f(y).map(({ key: x, value: on }) => `${x}/${on}`).join("/");
872
885
  return I(
873
886
  `${s}/_v/api/intelligent-search/${w}/${M}?${N.toString()}`,
874
887
  { headers: u }
@@ -917,12 +930,12 @@ const H = {
917
930
  "subcategory",
918
931
  "collection",
919
932
  "cluster"
920
- ]), W = (n) => typeof n.pageType == "string" && et.has(n.pageType.toLowerCase()), tt = (n, e) => {
921
- const t = jn(nt), r = async (i) => Promise.all(
933
+ ]), j = (n) => typeof n.pageType == "string" && et.has(n.pageType.toLowerCase()), tt = (n, e) => {
934
+ const t = Wn(nt), r = async (i) => Promise.all(
922
935
  i.map(
923
936
  (a) => t(async () => {
924
937
  const o = await e.commerce.catalog.portal.pagetype(a);
925
- if (W(o))
938
+ if (j(o))
926
939
  return o;
927
940
  throw new $(
928
941
  `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.`
@@ -930,15 +943,15 @@ const H = {
930
943
  })
931
944
  )
932
945
  );
933
- return new en(r, {
946
+ return new rn(r, {
934
947
  // DataLoader is being used to cache requests, not to batch them
935
948
  batch: !1
936
949
  });
937
950
  }, rt = (n, e) => {
938
951
  const t = async (r) => Promise.all(r.map((i) => e.commerce.catalog.salesChannel(i)));
939
- return new en(t);
952
+ return new rn(t);
940
953
  }, it = 1, at = (n, e) => {
941
- const t = jn(it), r = async (a) => {
954
+ const t = Wn(it), r = async (a) => {
942
955
  const o = a.reduce((m, { items: u }) => [...m, u], []), s = [...o.flat()], c = await e.commerce.checkout.simulation({
943
956
  country: a[0].country,
944
957
  postalCode: a[0].postalCode,
@@ -958,7 +971,7 @@ const H = {
958
971
  items: d.slice(p[u], p[u + 1]).filter((l) => !!l)
959
972
  }));
960
973
  }, i = async (a) => t(r, a);
961
- return new en(i, {
974
+ return new rn(i, {
962
975
  maxBatchSize: 50
963
976
  });
964
977
  }, ot = (n, e) => Oe(n, e);
@@ -997,7 +1010,7 @@ const B = (n, e) => ({
997
1010
  );
998
1011
  return c;
999
1012
  };
1000
- return new en(t, {
1013
+ return new rn(t, {
1001
1014
  maxBatchSize: 99
1002
1015
  // Max allowed batch size of Search API
1003
1016
  });
@@ -1009,14 +1022,14 @@ const B = (n, e) => ({
1009
1022
  collectionLoader: i,
1010
1023
  salesChannelLoader: a
1011
1024
  };
1012
- }, z = (n) => n.AvailableQuantity > 0, j = (n) => n.spotPrice ?? 0, dt = (n) => n.Price ?? 0, An = (n) => n ? "https://schema.org/InStock" : "https://schema.org/OutOfStock", Jn = (n, e) => z(n) && !z(e) ? -1 : !z(n) && z(e) ? 1 : j(n) - j(e), ut = (n) => n === "available", q = (n, e = 0, t = 1) => {
1025
+ }, z = (n) => n.AvailableQuantity > 0, W = (n) => n.spotPrice ?? 0, dt = (n) => n.Price ?? 0, An = (n) => n ? "https://schema.org/InStock" : "https://schema.org/OutOfStock", Jn = (n, e) => z(n) && !z(e) ? -1 : !z(n) && z(e) ? 1 : W(n) - W(e), ut = (n) => n === "available", q = (n, e = 0, t = 1) => {
1013
1026
  const r = e / t;
1014
1027
  return Math.round((n + r) * 100) / 100;
1015
1028
  }, pt = (n, e = { includeTaxes: !1 }) => {
1016
- const t = n.filter(z), r = t[t.length - 1], i = r ? j(r) : 0;
1029
+ const t = n.filter(z), r = t[t.length - 1], i = r ? W(r) : 0;
1017
1030
  return e.includeTaxes ? q(i, r?.Tax, r?.product?.unitMultiplier) : i;
1018
1031
  }, Pn = (n, e = { includeTaxes: !1 }) => {
1019
- const [t] = n.filter(z), r = t ? j(t) : 0;
1032
+ const [t] = n.filter(z), r = t ? W(t) : 0;
1020
1033
  return e.includeTaxes ? q(r, t?.Tax, t?.product?.unitMultiplier) : r;
1021
1034
  }, gt = {
1022
1035
  highPrice: (n) => pt(n),
@@ -1034,32 +1047,32 @@ const B = (n, e) => ({
1034
1047
  }, mt = {
1035
1048
  ratingValue: () => 5,
1036
1049
  reviewCount: () => 0
1037
- }, kn = "ÁÄÂÀÃÅČÇĆĎÉĚËÈÊẼĔȆÍÌÎÏŇÑÓÖÒÔÕØŘŔŠŤÚŮÜÙÛÝŸŽáäâàãåčçćďéěëèêẽĕȇíìîïňñóöòôõøðřŕšťúůüùûýÿžþÞĐđ߯a", ht = "AAAAAACCCDEEEEEEEEIIIINNOOOOOORRSTUUUUUYYZaaaaaacccdeeeeeeeeiiiinnooooooorrstuuuuuyyzbBDdBAa", ft = (n) => {
1050
+ }, Un = "ÁÄÂÀÃÅČÇĆĎÉĚËÈÊẼĔȆÍÌÎÏŇÑÓÖÒÔÕØŘŔŠŤÚŮÜÙÛÝŸŽáäâàãåčçćďéěëèêẽĕȇíìîïňñóöòôõøðřŕšťúůüùûýÿžþÞĐđ߯a", ht = "AAAAAACCCDEEEEEEEEIIIINNOOOOOORRSTUUUUUYYZaaaaaacccdeeeeeeeeiiiinnooooooorrstuuuuuyyzbBDdBAa", ft = (n) => {
1038
1051
  let e = n.slice(0);
1039
- for (let t = 0; t < kn.length; t++)
1040
- e = e.replace(new RegExp(kn.charAt(t), "g"), ht.charAt(t));
1052
+ for (let t = 0; t < Un.length; t++)
1053
+ e = e.replace(new RegExp(Un.charAt(t), "g"), ht.charAt(t));
1041
1054
  return e;
1042
1055
  }, St = (n) => n.replace(/[·/_,:]/, "-");
1043
1056
  function Kn(n) {
1044
1057
  const t = n.replace(/,/g, "").replace(/[*+~.()'"!:@&\[\]`/ %$#?{}><=_^]/g, "-");
1045
1058
  return St(ft(t)).toLowerCase();
1046
1059
  }
1047
- const K = (n) => n.type === "brand" || W(n) && n.pageType.toLowerCase() === "brand", gn = (n) => W(n) && n.pageType.toLowerCase() === "collection", an = (n) => K(n) || gn(n) ? Kn(n.name) : W(n) ? new URL(`https://${n.url}`).pathname.slice(1).toLowerCase() : new URL(n.url).pathname.slice(1).toLowerCase(), Qn = {
1060
+ 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) ? Kn(n.name) : j(n) ? new URL(`https://${n.url}`).pathname.slice(1).toLowerCase() : new URL(n.url).pathname.slice(1).toLowerCase(), Qn = {
1048
1061
  id: ({ id: n }) => n.toString(),
1049
- slug: (n) => an(n),
1050
- seo: (n) => K(n) || W(n) ? {
1062
+ slug: (n) => sn(n),
1063
+ seo: (n) => K(n) || j(n) ? {
1051
1064
  title: n.title ?? n.name,
1052
1065
  description: n.metaTagDescription
1053
1066
  } : {
1054
1067
  title: n.Title,
1055
1068
  description: n.MetaTagDescription
1056
1069
  },
1057
- type: (n) => K(n) ? "Brand" : W(n) ? n.pageType : n.level === 0 ? "Department" : "Category",
1070
+ type: (n) => K(n) ? "Brand" : j(n) ? n.pageType : n.level === 0 ? "Department" : "Category",
1058
1071
  meta: (n) => {
1059
- const e = an(n);
1072
+ const e = sn(n);
1060
1073
  return K(n) ? {
1061
1074
  selectedFacets: [{ key: "brand", value: e }]
1062
- } : gn(n) ? {
1075
+ } : hn(n) ? {
1063
1076
  selectedFacets: [{ key: "productclusterids", value: n.id }]
1064
1077
  } : {
1065
1078
  selectedFacets: e.split("/").map((t, r) => ({
@@ -1071,7 +1084,7 @@ const K = (n) => n.type === "brand" || W(n) && n.pageType.toLowerCase() === "bra
1071
1084
  breadcrumbList: async (n, e, t) => {
1072
1085
  const {
1073
1086
  loaders: { collectionLoader: r }
1074
- } = t, a = an(n).split("/").filter((c) => !!c), o = a.map(
1087
+ } = t, a = sn(n).split("/").filter((c) => !!c), o = a.map(
1075
1088
  (c, d) => a.slice(0, d + 1).join("/")
1076
1089
  ), s = await Promise.all(
1077
1090
  o.map(async (c) => {
@@ -1081,7 +1094,7 @@ const K = (n) => n.type === "brand" || W(n) && n.pageType.toLowerCase() === "bra
1081
1094
  );
1082
1095
  return {
1083
1096
  itemListElement: s.map((c, d) => ({
1084
- item: gn(c) ? `/${c.slug}` : new URL(
1097
+ item: hn(c) ? `/${c.slug}` : new URL(
1085
1098
  `https://${c.url}`
1086
1099
  ).pathname.toLowerCase(),
1087
1100
  name: c.name,
@@ -1097,7 +1110,7 @@ const K = (n) => n.type === "brand" || W(n) && n.pageType.toLowerCase() === "bra
1097
1110
  viewAndBought: "whosawalsobought",
1098
1111
  accessories: "accessories",
1099
1112
  suggestions: "suggestions"
1100
- }, _n = ({ key: n, value: e }) => {
1113
+ }, kn = ({ key: n, value: e }) => {
1101
1114
  switch (n) {
1102
1115
  case "price":
1103
1116
  return { key: n, value: e.replace("-to-", ":") };
@@ -1113,7 +1126,7 @@ const K = (n) => n.type === "brand" || W(n) && n.pageType.toLowerCase() === "bra
1113
1126
  default:
1114
1127
  return { key: n, value: e };
1115
1128
  }
1116
- }, Un = (n) => {
1129
+ }, _n = (n) => {
1117
1130
  const e = n.split(":").map(Number);
1118
1131
  return e.length !== 2 || Number.isNaN(e[0]) || Number.isNaN(e[1]) ? null : e;
1119
1132
  }, yt = (n) => typeof Zn[n] == "string", It = (n) => {
@@ -1125,7 +1138,7 @@ const K = (n) => n.type === "brand" || W(n) && n.pageType.toLowerCase() === "bra
1125
1138
  `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(",")}`
1126
1139
  );
1127
1140
  return e?.[0] ?? null;
1128
- }, vt = (n) => n?.find((e) => e.key === "slug")?.value ?? null, Ot = (n) => n?.find((e) => e.key === "id")?.value ?? null, Tn = (n) => n?.find((e) => e.key === "locale")?.value ?? null, En = (n) => n?.find((e) => e.key === "channel")?.value ?? null, mn = (n, e) => {
1141
+ }, vt = (n) => n?.find((e) => e.key === "slug")?.value ?? null, Ot = (n) => n?.find((e) => e.key === "id")?.value ?? null, Tn = (n) => n?.find((e) => e.key === "locale")?.value ?? null, En = (n) => n?.find((e) => e.key === "channel")?.value ?? null, fn = (n, e) => {
1129
1142
  let t = 0;
1130
1143
  for (let r = 1; r < n.length; r++)
1131
1144
  e(n[t], n[r]) > 0 && (t = r);
@@ -1140,18 +1153,18 @@ const K = (n) => n.type === "brand" || W(n) && n.pageType.toLowerCase() === "bra
1140
1153
  key: ({ key: n }) => n,
1141
1154
  label: ({ name: n }) => n,
1142
1155
  min: ({ values: n, key: e }, t, { storage: { searchArgs: r } }) => {
1143
- const i = Un(
1156
+ const i = _n(
1144
1157
  r?.selectedFacets?.find((s) => s.key === e)?.value ?? ""
1145
- ), o = mn(n, (s, c) => s.range.from - c.range.from)?.range?.from ?? 0;
1158
+ ), o = fn(n, (s, c) => s.range.from - c.range.from)?.range?.from ?? 0;
1146
1159
  return {
1147
1160
  selected: i?.[0] ?? o,
1148
1161
  absolute: o
1149
1162
  };
1150
1163
  },
1151
1164
  max: ({ values: n, key: e }, t, { storage: { searchArgs: r } }) => {
1152
- const i = Un(
1165
+ const i = _n(
1153
1166
  r?.selectedFacets?.find((s) => s.key === e)?.value ?? ""
1154
- ), o = mn(n, (s, c) => c.range.to - s.range.to)?.range?.to ?? 0;
1167
+ ), o = fn(n, (s, c) => c.range.to - s.range.to)?.range?.to ?? 0;
1155
1168
  return {
1156
1169
  selected: i?.[1] ?? o,
1157
1170
  absolute: o
@@ -1190,14 +1203,14 @@ function Pt(n) {
1190
1203
  const e = n.dimensionStatus.filter((t) => t.status === "pending").flatMap((t) => t.ruleCollection).filter((t) => t.status === "pending");
1191
1204
  return e.length === 0 ? !1 : e.every((t) => !t.isUserNextAuthorizer);
1192
1205
  }
1193
- const kt = async (n, { data: e }, { clients: { commerce: t } }) => {
1206
+ const Ut = async (n, { data: e }, { clients: { commerce: t } }) => {
1194
1207
  const r = await t.oms.processOrderAuthorization(e), i = ne(r);
1195
1208
  return {
1196
1209
  isPendingForOtherAuthorizer: !i && Pt(r),
1197
1210
  ruleForAuthorization: i
1198
1211
  };
1199
- }, _t = async (n, { data: e }, { clients: { commerce: t } }) => ({ id: (await t.subscribeToNewsletter(e))?.Id });
1200
- class Q {
1212
+ }, kt = async (n, { data: e }, { clients: { commerce: t } }) => ({ id: (await t.subscribeToNewsletter(e))?.Id });
1213
+ class nn {
1201
1214
  static parse(e) {
1202
1215
  try {
1203
1216
  const t = JSON.parse(e);
@@ -1215,9 +1228,9 @@ class Q {
1215
1228
  return JSON.stringify(e);
1216
1229
  }
1217
1230
  }
1218
- const hn = (n, e) => {
1219
- n.storage.channel = Q.parse(e);
1220
- }, fn = (n, e) => {
1231
+ const Sn = (n, e) => {
1232
+ n.storage.channel = nn.parse(e);
1233
+ }, yn = (n, e) => {
1221
1234
  n.storage.locale = e;
1222
1235
  }, ee = (n) => Ce.createHash("md5").update(n).digest("hex"), Y = {
1223
1236
  attachment: "ATTACHMENT",
@@ -1231,7 +1244,7 @@ function te(n) {
1231
1244
  valueReference: Y.attachment
1232
1245
  };
1233
1246
  }
1234
- function Ut(n) {
1247
+ function _t(n) {
1235
1248
  return {
1236
1249
  propertyID: n.id,
1237
1250
  name: n.name,
@@ -1300,12 +1313,12 @@ const Tt = (n) => {
1300
1313
  ));
1301
1314
  }
1302
1315
  );
1303
- }, ae = (n) => n.valueReference === Y.attachment, Sn = (n) => [
1316
+ }, ae = (n) => n.valueReference === Y.attachment, In = (n) => [
1304
1317
  n.itemOffered.sku,
1305
1318
  n.seller.identifier,
1306
1319
  n.price < 0.01 ? "Gift" : void 0,
1307
1320
  n.itemOffered.additionalProperty?.filter(ae).map(re).join("-")
1308
- ].filter(Boolean).join("::"), Z = (n, e) => ({
1321
+ ].filter(Boolean).join("::"), en = (n, e) => ({
1309
1322
  listPrice: n.listPrice / 100,
1310
1323
  price: n.sellingPrice / 100,
1311
1324
  quantity: n.quantity,
@@ -1327,7 +1340,7 @@ const Tt = (n) => {
1327
1340
  content: e.value
1328
1341
  }))
1329
1342
  }), Nn = (n) => n.reduce((e, t) => {
1330
- const r = Sn(t);
1343
+ const r = In(t);
1331
1344
  return e.has(r) || e.set(r, []), e.get(r)?.push(t), e;
1332
1345
  }, /* @__PURE__ */ new Map()), zt = (n, e) => {
1333
1346
  const t = (s, c) => ({
@@ -1336,7 +1349,7 @@ const Tt = (n) => {
1336
1349
  sku: s.itemOffered.sku
1337
1350
  },
1338
1351
  index: c
1339
- }), r = e.items.map(Z).map(t), i = n.acceptedOffer.map(t), a = n.orderNumber === e.orderFormId, o = vn(r, i);
1352
+ }), r = e.items.map(en).map(t), i = n.acceptedOffer.map(t), a = n.orderNumber === e.orderFormId, o = Cn(r, i);
1340
1353
  return a && o;
1341
1354
  };
1342
1355
  function oe(n, e) {
@@ -1352,7 +1365,7 @@ function se(n, e) {
1352
1365
  const Fn = (n) => {
1353
1366
  const e = n.items.reduce(
1354
1367
  (t, r, i) => {
1355
- const a = se(n.items, r.id) || oe(n.items, r.id) ? `${Sn(Z(r))}::${i}` : Sn(Z(r));
1368
+ const a = se(n.items, r.id) || oe(n.items, r.id) ? `${In(en(r))}::${i}` : In(en(r));
1356
1369
  return t[a] || (t[a] = []), t[a].push(r), t;
1357
1370
  },
1358
1371
  {}
@@ -1449,9 +1462,9 @@ const Fn = (n) => {
1449
1462
  }, qt = (n, e) => {
1450
1463
  if (!n)
1451
1464
  return "";
1452
- const r = nn(n)[e];
1465
+ const r = tn(n)[e];
1453
1466
  return r ? r.split("=")[1] : "";
1454
- }, Wt = async (n, { cart: { order: e }, session: t }, r) => {
1467
+ }, jt = async (n, { cart: { order: e }, session: t }, r) => {
1455
1468
  const i = qt(
1456
1469
  r.headers.cookie,
1457
1470
  "checkout.vtex.com"
@@ -1459,13 +1472,13 @@ const Fn = (n) => {
1459
1472
  clients: { commerce: a },
1460
1473
  loaders: { skuLoader: o }
1461
1474
  } = r, s = t?.channel, c = t?.locale;
1462
- s && hn(r, s), c && fn(r, c);
1475
+ s && Sn(r, s), c && yn(r, c);
1463
1476
  const d = await a.checkout.orderForm({
1464
1477
  id: i || void 0,
1465
1478
  channel: r.storage.channel
1466
1479
  }), p = d.orderFormId;
1467
1480
  d.messages.length !== 0 && await xt(p, r);
1468
- const m = nn(r?.headers?.cookie ?? "")?.vtex_session, u = bn(m), { acceptedOffer: l, shouldSplitItem: g } = e;
1481
+ const m = tn(r?.headers?.cookie ?? "")?.vtex_session, u = Z(m), { acceptedOffer: l, shouldSplitItem: g } = e;
1469
1482
  if (Vt(d, u)) {
1470
1483
  const y = await Ln(
1471
1484
  d,
@@ -1475,17 +1488,17 @@ const Fn = (n) => {
1475
1488
  if (p)
1476
1489
  return Rn(y, o, g);
1477
1490
  }
1478
- const S = Nn(l), O = Nn(d.items.map(Z)), D = Array.from(O.entries()), A = Array.from(S.entries()), { itemsToAdd: T, itemsToUpdate: v } = A.reduce(
1491
+ const S = Nn(l), O = Nn(d.items.map(en)), D = Array.from(O.entries()), A = Array.from(S.entries()), { itemsToAdd: T, itemsToUpdate: v } = A.reduce(
1479
1492
  (y, [w, P]) => {
1480
1493
  const E = O.get(w);
1481
1494
  if (!E)
1482
1495
  return P.forEach((M) => y.itemsToAdd.push(M)), y;
1483
- const [U, ...G] = E;
1484
- if (se(d.items, U.itemOffered.sku) || oe(d.items, U.itemOffered.sku))
1485
- return y.itemsToUpdate.push(U), y;
1496
+ const [_, ...G] = E;
1497
+ if (se(d.items, _.itemOffered.sku) || oe(d.items, _.itemOffered.sku))
1498
+ return y.itemsToUpdate.push(_), y;
1486
1499
  const N = P.reduce((M, x) => M + x.quantity, 0);
1487
1500
  return y.itemsToUpdate.push({
1488
- ...U,
1501
+ ..._,
1489
1502
  quantity: N
1490
1503
  }), G.forEach((M) => y.itemsToUpdate.push({ ...M, quantity: 0 })), y;
1491
1504
  },
@@ -1493,7 +1506,7 @@ const Fn = (n) => {
1493
1506
  itemsToAdd: [],
1494
1507
  itemsToUpdate: []
1495
1508
  }
1496
- ), k = D.filter(([y]) => !S.has(y)).flatMap(([, y]) => y.map((w) => ({ ...w, quantity: 0 }))), h = [...T, ...v, ...k].map(
1509
+ ), U = D.filter(([y]) => !S.has(y)).flatMap(([, y]) => y.map((w) => ({ ...w, quantity: 0 }))), h = [...T, ...v, ...U].map(
1497
1510
  $t
1498
1511
  ), { updateShipping: C } = t ? ie(d, t) : { updateShipping: !1 };
1499
1512
  if (h.length === 0 && !C)
@@ -1528,13 +1541,13 @@ const Fn = (n) => {
1528
1541
  locale: c
1529
1542
  }
1530
1543
  }) : y).then((y) => Ln(y, a, u)).then(Fn);
1531
- const _ = vn(
1544
+ const k = Cn(
1532
1545
  d.messages,
1533
1546
  b.messages
1534
1547
  );
1535
- return zt(e, b) && _ ? null : Rn(b, o, g);
1548
+ return zt(e, b) && k ? null : Rn(b, o, g);
1536
1549
  };
1537
- async function jt(n, e, t) {
1550
+ async function Wt(n, e, t) {
1538
1551
  try {
1539
1552
  const r = await n.commerce.checkout.address({
1540
1553
  postalCode: t,
@@ -1552,15 +1565,15 @@ async function jt(n, e, t) {
1552
1565
  }
1553
1566
  }
1554
1567
  const Gt = async (n, { session: e, search: t }, { clients: r, headers: i, account: a }) => {
1555
- const o = Q.parse(e.channel ?? ""), s = String(e.postalCode ?? ""), c = e.country ?? "";
1568
+ const o = nn.parse(e.channel ?? ""), s = String(e.postalCode ?? ""), c = e.country ?? "";
1556
1569
  let d = e.city ?? null, p = e.geoCoordinates ?? null;
1557
1570
  if ((!d || !p) && s !== "" && c !== "") {
1558
- const U = await jt(
1571
+ const _ = await Wt(
1559
1572
  r,
1560
1573
  c,
1561
1574
  s
1562
1575
  );
1563
- d = U.city, p = U.geoCoordinates;
1576
+ d = _.city, p = _.geoCoordinates;
1564
1577
  }
1565
1578
  const u = new URLSearchParams(t);
1566
1579
  u.has("facets") && u.delete("facets");
@@ -1577,24 +1590,24 @@ const Gt = async (n, { session: e, search: t }, { clients: r, headers: i, accoun
1577
1590
  utmiCampaign: u.get("utmi_cp") ?? g?.utmiCampaign ?? "",
1578
1591
  utmiPage: u.get("utmi_p") ?? g?.utmiPage ?? "",
1579
1592
  utmiPart: u.get("utmi_pc") ?? g?.utmiPart ?? ""
1580
- }, S = bn(Cn(i?.cookie ?? "", a));
1593
+ }, S = Z(Q(i?.cookie ?? "", a));
1581
1594
  let O = !1;
1582
1595
  if (S)
1583
1596
  try {
1584
1597
  O = (await r.commerce.vtexid.validate())?.authStatus?.toLowerCase() === "success";
1585
- } catch (U) {
1586
- console.warn("JWT validation failed:", U), O = !1;
1598
+ } catch (_) {
1599
+ console.warn("JWT validation failed:", _), O = !1;
1587
1600
  }
1588
- const D = O ? S?.isRepresentative : !1, A = O ? S?.customerId : void 0, T = O ? S?.unitId : void 0, v = await r.commerce.session(u.toString()).catch(() => null), k = v?.namespaces.profile ?? null, h = v?.namespaces.shopper ?? null, C = v?.namespaces.store ?? null, b = v?.namespaces.authentication ?? null, _ = v?.namespaces.checkout ?? null, y = v?.namespaces.public ?? null;
1601
+ const D = O ? S?.isRepresentative : !1, A = O ? S?.customerId : void 0, T = O ? S?.unitId : void 0, v = await r.commerce.session(u.toString()).catch(() => null), U = v?.namespaces.profile ?? null, h = v?.namespaces.shopper ?? null, C = v?.namespaces.store ?? null, b = v?.namespaces.authentication ?? null, k = v?.namespaces.checkout ?? null, y = v?.namespaces.public ?? null;
1589
1602
  let w = null;
1590
- if (D && k?.id?.value)
1603
+ if (D && U?.id?.value)
1591
1604
  try {
1592
1605
  w = await r.commerce.masterData.getContractById({
1593
- contractId: k.id.value
1606
+ contractId: U.id.value
1594
1607
  });
1595
1608
  } catch {
1596
1609
  console.error(
1597
- `Error while getting contract data for profile ID (${k.id.value}).
1610
+ `Error while getting contract data for profile ID (${U.id.value}).
1598
1611
  `
1599
1612
  );
1600
1613
  }
@@ -1612,9 +1625,9 @@ const Gt = async (n, { session: e, search: t }, { clients: r, headers: i, accoun
1612
1625
  symbol: C?.currencySymbol?.value ?? e.currency.symbol
1613
1626
  },
1614
1627
  country: C?.countryCode?.value ?? c,
1615
- channel: Q.stringify({
1628
+ channel: nn.stringify({
1616
1629
  salesChannel: C?.channel?.value ?? o.salesChannel,
1617
- regionId: _?.regionId?.value ?? o.regionId,
1630
+ regionId: k?.regionId?.value ?? o.regionId,
1618
1631
  seller: P?.id,
1619
1632
  hasOnlyDefaultSalesChannel: !C?.channel?.value
1620
1633
  }),
@@ -1638,27 +1651,27 @@ const Gt = async (n, { session: e, search: t }, { clients: r, headers: i, accoun
1638
1651
  organizationManager: h?.organizationManager?.value ?? !1
1639
1652
  } : null,
1640
1653
  marketingData: f,
1641
- person: k?.id ? {
1642
- id: k.id?.value ?? "",
1643
- email: k.email?.value ?? "",
1644
- givenName: k.firstName?.value ?? "",
1645
- familyName: k.lastName?.value ?? ""
1654
+ person: U?.id ? {
1655
+ id: U.id?.value ?? "",
1656
+ email: U.email?.value ?? "",
1657
+ givenName: U.firstName?.value ?? "",
1658
+ familyName: U.lastName?.value ?? ""
1646
1659
  } : null,
1647
1660
  geoCoordinates: p?.latitude && p?.longitude && p || null,
1648
1661
  city: d
1649
1662
  };
1650
- return vn(e, E) ? null : E;
1663
+ return Cn(e, E) ? null : E;
1651
1664
  }, Ht = {
1652
- validateCart: Wt,
1665
+ validateCart: jt,
1653
1666
  validateSession: Gt,
1654
- subscribeToNewsletter: _t,
1667
+ subscribeToNewsletter: kt,
1655
1668
  cancelOrder: At,
1656
- processOrderAuthorization: kt
1669
+ processOrderAuthorization: Ut
1657
1670
  };
1658
- var yn;
1671
+ var vn;
1659
1672
  (function(n) {
1660
1673
  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";
1661
- })(yn || (yn = {}));
1674
+ })(vn || (vn = {}));
1662
1675
  const Xt = (n) => typeof n == "string" ? le(n) : null;
1663
1676
  function le(n) {
1664
1677
  try {
@@ -1673,7 +1686,7 @@ const Yt = (n) => typeof n == "object" ? JSON.stringify(n) : typeof n == "string
1673
1686
  parseValue: Xt,
1674
1687
  serialize: Yt,
1675
1688
  parseLiteral(n) {
1676
- return n.kind === yn.STRING ? le(n.value) : null;
1689
+ return n.kind === vn.STRING ? le(n.value) : null;
1677
1690
  }
1678
1691
  }), R = (n) => "Price" in n && "seller" in n && "product" in n, F = (n) => "skuName" in n, Kt = {
1679
1692
  priceCurrency: async (n, e, t) => {
@@ -1691,8 +1704,8 @@ const Yt = (n) => typeof n == "object" ? JSON.stringify(n) : typeof n == "string
1691
1704
  } : F(n) ? {
1692
1705
  identifier: n.seller
1693
1706
  } : null,
1694
- price: (n) => R(n) ? j(n) : F(n) ? n.sellingPrice / 100 : null,
1695
- priceWithTaxes: (n) => R(n) ? q(j(n), n?.Tax, n.product.unitMultiplier) : F(n) ? q(
1707
+ price: (n) => R(n) ? W(n) : F(n) ? n.sellingPrice / 100 : null,
1708
+ priceWithTaxes: (n) => R(n) ? q(W(n), n?.Tax, n.product.unitMultiplier) : F(n) ? q(
1696
1709
  n.sellingPrice / 100,
1697
1710
  n.tax / 100,
1698
1711
  n.unitMultiplier
@@ -1816,7 +1829,7 @@ const rr = (n, e) => {
1816
1829
  }))
1817
1830
  ), i = e.map(
1818
1831
  te
1819
- ), a = t.map(Ut);
1832
+ ), a = t.map(_t);
1820
1833
  return [
1821
1834
  ...r,
1822
1835
  ...i,
@@ -1850,13 +1863,13 @@ const rr = (n, e) => {
1850
1863
  name: ({ name: n }) => n,
1851
1864
  value: ({ value: n }) => n,
1852
1865
  valueReference: ({ valueReference: n }) => n
1853
- }, In = (n) => {
1866
+ }, On = (n) => {
1854
1867
  const e = n.flatMap(
1855
1868
  (r) => r.sellers.map((i) => ({
1856
1869
  offer: i.commertialOffer,
1857
1870
  sku: r
1858
1871
  }))
1859
- ), t = mn(
1872
+ ), t = fn(
1860
1873
  e,
1861
1874
  ({ offer: r }, { offer: i }) => Jn(r, i)
1862
1875
  );
@@ -1873,7 +1886,7 @@ const rr = (n, e) => {
1873
1886
  }, dr = {
1874
1887
  product: async (n, { locator: e }, t) => {
1875
1888
  const r = En(e), i = Tn(e), a = Ot(e), o = vt(e);
1876
- r && hn(t, r), i && fn(t, i);
1889
+ r && Sn(t, r), i && yn(t, i);
1877
1890
  const {
1878
1891
  loaders: { skuLoader: s },
1879
1892
  clients: { commerce: c, search: d }
@@ -1905,7 +1918,7 @@ const rr = (n, e) => {
1905
1918
  });
1906
1919
  if (!u)
1907
1920
  throw new $(`No product found for id ${m.id}`);
1908
- const l = In(u.items);
1921
+ const l = On(u.items);
1909
1922
  return B(l, u);
1910
1923
  }
1911
1924
  },
@@ -1924,7 +1937,7 @@ const rr = (n, e) => {
1924
1937
  sponsoredCount: o
1925
1938
  }, s) => {
1926
1939
  const c = En(a), d = Tn(a), p = It(a);
1927
- c && hn(s, c), d && fn(s, d);
1940
+ c && Sn(s, c), d && yn(s, d);
1928
1941
  let m = i;
1929
1942
  p && (m = `product:${(await s.clients.commerce.catalog.products.crossselling(
1930
1943
  {
@@ -1937,7 +1950,7 @@ const rr = (n, e) => {
1937
1950
  count: e,
1938
1951
  query: m ?? void 0,
1939
1952
  sort: lr[r ?? "score_desc"],
1940
- selectedFacets: a?.flatMap(_n) ?? [],
1953
+ selectedFacets: a?.flatMap(kn) ?? [],
1941
1954
  sponsoredCount: o ?? void 0
1942
1955
  }, g = s.clients.search.products(l);
1943
1956
  return { searchArgs: l, productSearchPromise: g };
@@ -2034,7 +2047,7 @@ const rr = (n, e) => {
2034
2047
  page: 1,
2035
2048
  count: 1,
2036
2049
  query: e ?? void 0,
2037
- selectedFacets: t?.flatMap(_n) ?? [],
2050
+ selectedFacets: t?.flatMap(kn) ?? [],
2038
2051
  allowRedirect: !0
2039
2052
  });
2040
2053
  return {
@@ -2125,7 +2138,7 @@ const rr = (n, e) => {
2125
2138
  a = { message: i };
2126
2139
  }
2127
2140
  const o = a?.message || i;
2128
- throw $e(r) ? new $(`No order found for id ${e}. ${o}.`) : Me(r) ? new tn(
2141
+ throw $e(r) ? new $(`No order found for id ${e}. ${o}.`) : Me(r) ? new an(
2129
2142
  `You are forbidden to interact with order with id ${e}. ${o}.`
2130
2143
  ) : r;
2131
2144
  }
@@ -2156,14 +2169,21 @@ const rr = (n, e) => {
2156
2169
  // only b2b users
2157
2170
  userDetails: async (n, e, t) => {
2158
2171
  const {
2159
- clients: { commerce: r }
2160
- } = t, i = await r.session("").catch(() => null), a = i?.namespaces.shopper ?? null, o = i?.namespaces.authentication ?? null;
2172
+ account: r,
2173
+ headers: i,
2174
+ clients: { commerce: a }
2175
+ } = t, s = Z(Q(i?.cookie ?? "", r))?.userId ?? "", [c, d, p] = await Promise.all([
2176
+ a.session("").catch(() => null),
2177
+ s ? a.masterData.getShopperById({ userId: s }).catch(() => null) : Promise.resolve(null),
2178
+ s ? a.licenseManager.getUserRoles({ userId: s }).catch(() => null) : Promise.resolve(null)
2179
+ ]), m = d?.[0], u = c?.namespaces.authentication ?? null, l = `${(m?.firstName ?? "").trim()} ${(m?.lastName ?? "").trim()}`.trim();
2161
2180
  return {
2162
- name: a?.firstName?.value ?? "",
2163
- email: o?.storeUserEmail.value ?? "",
2164
- role: ["Admin"],
2165
- // TODO change when implemented roles,
2166
- orgUnit: o?.unitName?.value ?? ""
2181
+ username: u?.storeUserEmail?.value ?? "",
2182
+ name: l,
2183
+ email: u?.storeUserEmail?.value ?? "",
2184
+ phone: m?.phone ?? "",
2185
+ role: p?.Roles?.map((g) => g.Name) ?? [],
2186
+ orgUnit: u?.unitName?.value ?? ""
2167
2187
  };
2168
2188
  },
2169
2189
  // If isRepresentative, return b2b information.
@@ -2173,7 +2193,7 @@ const rr = (n, e) => {
2173
2193
  account: r,
2174
2194
  headers: i,
2175
2195
  clients: { commerce: a }
2176
- } = t, o = bn(Cn(i?.cookie ?? "", r));
2196
+ } = t, o = Z(Q(i?.cookie ?? "", r));
2177
2197
  if (!o?.userId)
2178
2198
  return null;
2179
2199
  if (o?.isRepresentative) {
@@ -2233,7 +2253,7 @@ const rr = (n, e) => {
2233
2253
  r.suggestedTerms(i),
2234
2254
  a
2235
2255
  ]), c = s.products.map((p) => {
2236
- const m = In(p.items);
2256
+ const m = On(p.items);
2237
2257
  return m && B(m, p);
2238
2258
  }).filter((p) => !!p), { searches: d } = o;
2239
2259
  return {
@@ -2243,7 +2263,7 @@ const rr = (n, e) => {
2243
2263
  },
2244
2264
  products: async ({ productSearchPromise: n }) => {
2245
2265
  const e = await n, t = e.products.map((r) => {
2246
- const i = In(r.items);
2266
+ const i = On(r.items);
2247
2267
  return i && B(i, r);
2248
2268
  }).filter((r) => !!r);
2249
2269
  return {
@@ -2432,11 +2452,11 @@ const Dr = {
2432
2452
  deliveryOptionsData: (n) => {
2433
2453
  const { shippingData: e, items: t } = n, r = e?.logisticsInfo || [], i = e?.selectedAddresses || e?.availableAddresses || [e?.address], a = r.reduce(
2434
2454
  (d, p) => {
2435
- const m = p?.selectedSla || "", u = p?.selectedDeliveryChannel || p?.deliveryChannel || "", l = p?.deliveryCompany || "", g = p?.deliveryWindow, f = p?.pickupStoreInfo, S = p?.shippingEstimate || "", O = p?.shippingEstimate ? pe(p?.shippingEstimate) : "", D = p?.shippingEstimateDate || "", A = p?.addressId || "", T = p?.itemIndex ?? 0, v = t?.[T], k = v?.seller || "", h = `${m}|${u}|${l}|${k}|${S}|${D}|${A}|${g?.startDateUtc}|${g?.endDateUtc}`, C = i?.find(
2455
+ const m = p?.selectedSla || "", u = p?.selectedDeliveryChannel || p?.deliveryChannel || "", l = p?.deliveryCompany || "", g = p?.deliveryWindow, f = p?.pickupStoreInfo, S = p?.shippingEstimate || "", O = p?.shippingEstimate ? pe(p?.shippingEstimate) : "", D = p?.shippingEstimateDate || "", A = p?.addressId || "", T = p?.itemIndex ?? 0, v = t?.[T], U = v?.seller || "", h = `${m}|${u}|${l}|${U}|${S}|${D}|${A}|${g?.startDateUtc}|${g?.endDateUtc}`, C = i?.find(
2436
2456
  (P) => P?.addressId === A
2437
- ), b = `${wr[u] || ""} ${O} ${C?.neighborhood ? `to ${C?.neighborhood}` : ""}`.trim(), { taxPriceTagsTotal: _, taxPriceTags: y } = Pr(
2457
+ ), b = `${wr[u] || ""} ${O} ${C?.neighborhood ? `to ${C?.neighborhood}` : ""}`.trim(), { taxPriceTagsTotal: k, taxPriceTags: y } = Pr(
2438
2458
  v?.priceTags ?? []
2439
- ), w = (v?.sellingPrice ?? 0) * (v?.quantity ?? 0) + (v?.tax ?? 0) + (_ ?? 0);
2459
+ ), w = (v?.sellingPrice ?? 0) * (v?.quantity ?? 0) + (v?.tax ?? 0) + (k ?? 0);
2440
2460
  return d[h] || (d[h] = {
2441
2461
  // static fields
2442
2462
  selectedSla: m,
@@ -2445,7 +2465,7 @@ const Dr = {
2445
2465
  deliveryWindow: g,
2446
2466
  shippingEstimate: S,
2447
2467
  shippingEstimateDate: D,
2448
- seller: k,
2468
+ seller: U,
2449
2469
  friendlyShippingEstimate: O,
2450
2470
  friendlyDeliveryOptionName: b,
2451
2471
  address: C,
@@ -2463,7 +2483,7 @@ const Dr = {
2463
2483
  sellingPrice: v?.sellingPrice || 0,
2464
2484
  imageUrl: v?.imageUrl || "",
2465
2485
  taxPriceTags: y ?? [],
2466
- taxPriceTagsTotal: _ ?? 0,
2486
+ taxPriceTagsTotal: k ?? 0,
2467
2487
  tax: v?.tax || 0,
2468
2488
  total: w
2469
2489
  }), d[h].quantityOfDifferentItems = (d[h].quantityOfDifferentItems ?? 0) + 1, d[h].total = (d[h].total ?? 0) + w), d;
@@ -2504,7 +2524,7 @@ function Pr(n) {
2504
2524
  taxPriceTagsTotal: r
2505
2525
  };
2506
2526
  }
2507
- const kr = {
2527
+ const Ur = {
2508
2528
  StoreCollection: Qn,
2509
2529
  StoreAggregateOffer: gt,
2510
2530
  StoreProduct: ir,
@@ -2525,7 +2545,7 @@ const kr = {
2525
2545
  ObjectOrString: Jt,
2526
2546
  Query: dr,
2527
2547
  Mutation: Ht
2528
- }, _r = () => kr, Ur = `"""
2548
+ }, kr = () => Ur, _r = `"""
2529
2549
  Address information.
2530
2550
  """
2531
2551
  type Address {
@@ -2966,8 +2986,8 @@ input IPersonNewsletter {
2966
2986
  """
2967
2987
  email: String!
2968
2988
  }
2969
- `, Wr = `scalar ObjectOrString
2970
- `, jr = `"""
2989
+ `, jr = `scalar ObjectOrString
2990
+ `, Wr = `"""
2971
2991
  Offer information.
2972
2992
  """
2973
2993
  type StoreOffer {
@@ -4489,6 +4509,10 @@ type SellerInfo {
4489
4509
  User details information.
4490
4510
  """
4491
4511
  type StoreUserDetails {
4512
+ """
4513
+ User's username (login). May differ from email when Alternative Login is enabled.
4514
+ """
4515
+ username: String
4492
4516
  """
4493
4517
  User's name.
4494
4518
  """
@@ -4498,6 +4522,10 @@ type StoreUserDetails {
4498
4522
  """
4499
4523
  email: String
4500
4524
  """
4525
+ User's phone number.
4526
+ """
4527
+ phone: String
4528
+ """
4501
4529
  User's role.
4502
4530
  """
4503
4531
  role: [String]
@@ -6097,7 +6125,7 @@ type UserOrderBudgetAllocationLinkedEntity {
6097
6125
  id: String
6098
6126
  }
6099
6127
  `, ui = /* @__PURE__ */ Object.assign({
6100
- "./address.graphql": Ur,
6128
+ "./address.graphql": _r,
6101
6129
  "./advertisement.graphql": Tr,
6102
6130
  "./aggregateOffer.graphql": Er,
6103
6131
  "./aggregateRating.graphql": Nr,
@@ -6111,8 +6139,8 @@ type UserOrderBudgetAllocationLinkedEntity {
6111
6139
  "./image.graphql": Vr,
6112
6140
  "./mutation.graphql": xr,
6113
6141
  "./newsletter.graphql": qr,
6114
- "./objectOrString.graphql": Wr,
6115
- "./offer.graphql": jr,
6142
+ "./objectOrString.graphql": jr,
6143
+ "./offer.graphql": Wr,
6116
6144
  "./order.graphql": Gr,
6117
6145
  "./orderCommercialAuthorizaton.graphql": Hr,
6118
6146
  "./organization.graphql": Xr,
@@ -6139,14 +6167,14 @@ type UserOrderBudgetAllocationLinkedEntity {
6139
6167
  ), gi = pi, Ti = async (n) => L.context.with(
6140
6168
  L.propagation.extract(L.context.active(), n.OTEL),
6141
6169
  () => (e) => (e.storage = {
6142
- channel: Q.parse(n.channel),
6170
+ channel: nn.parse(n.channel),
6143
6171
  flags: n.flags ?? {},
6144
6172
  locale: n.locale,
6145
6173
  cookies: /* @__PURE__ */ new Map()
6146
6174
  }, e.clients = Ze(n, e), e.loaders = lt(n, e), e.account = n.account, e.OTEL = n.OTEL, e.discoveryConfig = n.discoveryConfig, e)
6147
6175
  );
6148
6176
  function mi() {
6149
- const n = _r(), e = {};
6177
+ const n = kr(), e = {};
6150
6178
  for (const [t, r] of Object.entries(n))
6151
6179
  e[t] = Object.fromEntries(
6152
6180
  Object.entries(r).map(([i, a]) => typeof a != "function" ? [i, a] : [i, Be(a, `${t}(${i})`)])
@@ -6168,7 +6196,7 @@ export {
6168
6196
  Re as CacheControlDirective,
6169
6197
  be as CommercialAuthorizationStatus,
6170
6198
  X as FastStoreError,
6171
- tn as ForbiddenError,
6199
+ an as ForbiddenError,
6172
6200
  Ti as GraphqlVtexContextFactory,
6173
6201
  Ei as GraphqlVtexSchema,
6174
6202
  $ as NotFoundError,
@@ -6177,12 +6205,12 @@ export {
6177
6205
  Ae as StoreSort,
6178
6206
  Pe as StoreStatus,
6179
6207
  J as UnauthorizedError,
6180
- ke as UserOrderInvoiceType,
6181
- _i as isBadRequestError,
6182
- ki as isFastStoreError,
6208
+ Ue as UserOrderInvoiceType,
6209
+ ki as isBadRequestError,
6210
+ Ui as isFastStoreError,
6183
6211
  Me as isForbiddenError,
6184
6212
  $e as isNotFoundError,
6185
- Ui as isUnauthorizedError,
6213
+ _i as isUnauthorizedError,
6186
6214
  Pi as stringifyCacheControl,
6187
6215
  gi as typeDefs,
6188
6216
  Le as withDirectives