@azzas/azzas-tracker-web 2.0.0-preview.8 → 2.0.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.
@@ -319,7 +319,7 @@ var AzzasTracker = (() => {
319
319
  name: "notify_me",
320
320
  hasEcommerce: false,
321
321
  destinations: ["DataLayer"],
322
- requiredParams: ["brand", "line_items", "size", "item_ref"]
322
+ requiredParams: ["brand", "size", "item_ref"]
323
323
  },
324
324
  REFINE_RESULTS: {
325
325
  name: "refine_results",
@@ -1071,7 +1071,7 @@ var AzzasTracker = (() => {
1071
1071
  "store": "https://www.animale.com.br",
1072
1072
  "checkout": "https://secure.animale.com.br"
1073
1073
  },
1074
- "farm": {
1074
+ "lojafarm": {
1075
1075
  "store": "https://lojafarm.myvtex.com"
1076
1076
  },
1077
1077
  "mariafilo": {
@@ -1089,23 +1089,23 @@ var AzzasTracker = (() => {
1089
1089
  "bynv": {
1090
1090
  "store": "https://bynv.myvtex.com"
1091
1091
  },
1092
- "fabula": {
1092
+ "lojafabula": {
1093
1093
  "store": "https://lojafabula.myvtex.com"
1094
1094
  }
1095
1095
  };
1096
1096
  async function getUserInfo(context) {
1097
- var _a, _b, _c, _d, _e;
1098
- const domain = (_a = PROD_DOMAINS[context.account || "animale"]) == null ? void 0 : _a[context.platform || "store"];
1099
- if (!domain) return { customer: { email: context.userEmail, id: context == null ? void 0 : context.userId }, address: null };
1097
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I;
1098
+ const domain = (_e = PROD_DOMAINS[(_b = (_a = context == null ? void 0 : context.meta) == null ? void 0 : _a.user_info) == null ? void 0 : _b.account]) == null ? void 0 : _e[(_d = (_c = context == null ? void 0 : context.meta) == null ? void 0 : _c.user_info) == null ? void 0 : _d.platform];
1099
+ if (!domain) return { customer: { email: (_g = (_f = context == null ? void 0 : context.meta) == null ? void 0 : _f.user_info) == null ? void 0 : _g.userEmail, id: (_i = (_h = context == null ? void 0 : context.meta) == null ? void 0 : _h.user_info) == null ? void 0 : _i.userId }, address: null };
1100
1100
  try {
1101
1101
  const api = `${domain}/_v/user-info`;
1102
1102
  const response = await fetch(api, {
1103
1103
  method: "POST",
1104
- body: JSON.stringify({ email: context.userEmail })
1104
+ body: JSON.stringify({ email: (_k = (_j = context == null ? void 0 : context.meta) == null ? void 0 : _j.user_info) == null ? void 0 : _k.userEmail })
1105
1105
  });
1106
1106
  if (response.status !== 200) {
1107
- if ((context == null ? void 0 : context.manuallyInfo) && ((_b = context.manuallyInfo) == null ? void 0 : _b.cpf)) {
1108
- const { cpf, birthDate, phone, firstName, lastName, email, email_optin } = context.manuallyInfo;
1107
+ if (((_m = (_l = context == null ? void 0 : context.meta) == null ? void 0 : _l.user_info) == null ? void 0 : _m.manuallyInfo) && ((_p = (_o = (_n = context == null ? void 0 : context.meta) == null ? void 0 : _n.user_info) == null ? void 0 : _o.manuallyInfo) == null ? void 0 : _p.cpf)) {
1108
+ const { cpf, birthDate, phone, firstName, lastName, email, email_optin } = (_r = (_q = context == null ? void 0 : context.meta) == null ? void 0 : _q.user_info) == null ? void 0 : _r.manuallyInfo;
1109
1109
  const document3 = cpf == null ? void 0 : cpf.replace(/\D/g, "");
1110
1110
  const hashedDocument2 = await documentToHash(document3);
1111
1111
  return {
@@ -1123,15 +1123,15 @@ var AzzasTracker = (() => {
1123
1123
  }
1124
1124
  };
1125
1125
  }
1126
- return { customer: { email: context.userEmail, id: context == null ? void 0 : context.userId }, address: null };
1126
+ return { customer: { email: (_t = (_s = context == null ? void 0 : context.meta) == null ? void 0 : _s.user_info) == null ? void 0 : _t.userEmail, id: (_v = (_u = context == null ? void 0 : context.meta) == null ? void 0 : _u.user_info) == null ? void 0 : _v.userId }, address: null };
1127
1127
  }
1128
1128
  const res = await response.json();
1129
- const document2 = (_d = (_c = res == null ? void 0 : res.customer) == null ? void 0 : _c.document) == null ? void 0 : _d.replace(/\D/g, "");
1129
+ const document2 = (_x = (_w = res == null ? void 0 : res.customer) == null ? void 0 : _w.document) == null ? void 0 : _x.replace(/\D/g, "");
1130
1130
  const hashedDocument = await documentToHash(document2);
1131
1131
  return { ...res, customer: { ...res.customer, cpf: hashedDocument, document: document2 } };
1132
1132
  } catch (_) {
1133
- if ((context == null ? void 0 : context.manuallyInfo) && ((_e = context.manuallyInfo) == null ? void 0 : _e.cpf)) {
1134
- const { cpf, birthDate, phone, firstName, lastName, email, email_optin } = context.manuallyInfo;
1133
+ if (((_z = (_y = context == null ? void 0 : context.meta) == null ? void 0 : _y.user_info) == null ? void 0 : _z.manuallyInfo) && ((_C = (_B = (_A = context == null ? void 0 : context.meta) == null ? void 0 : _A.user_info) == null ? void 0 : _B.manuallyInfo) == null ? void 0 : _C.cpf)) {
1134
+ const { cpf, birthDate, phone, firstName, lastName, email, email_optin } = (_E = (_D = context == null ? void 0 : context.meta) == null ? void 0 : _D.user_info) == null ? void 0 : _E.manuallyInfo;
1135
1135
  const document2 = cpf == null ? void 0 : cpf.replace(/\D/g, "");
1136
1136
  const hashedDocument = await documentToHash(document2);
1137
1137
  return {
@@ -1149,7 +1149,7 @@ var AzzasTracker = (() => {
1149
1149
  }
1150
1150
  };
1151
1151
  }
1152
- return { customer: { email: context.userEmail, id: context == null ? void 0 : context.userId }, address: null };
1152
+ return { customer: { email: (_G = (_F = context == null ? void 0 : context.meta) == null ? void 0 : _F.user_info) == null ? void 0 : _G.userEmail, id: (_I = (_H = context == null ? void 0 : context.meta) == null ? void 0 : _H.user_info) == null ? void 0 : _I.userId }, address: null };
1153
1153
  }
1154
1154
  }
1155
1155
 
@@ -1356,8 +1356,13 @@ var AzzasTracker = (() => {
1356
1356
  };
1357
1357
 
1358
1358
  // src/params/adapters/meta/index.ts
1359
- var metaAdapters = {
1359
+ var metaAdapter = {
1360
1360
  user_info: getUserInfo,
1361
+ brand: (context, config2) => {
1362
+ if (config2 == null ? void 0 : config2.brand) return config2.brand;
1363
+ if (context == null ? void 0 : context.meta.brand) return context.meta.brand;
1364
+ return null;
1365
+ },
1361
1366
  content_type: (context) => {
1362
1367
  return context.meta.content_type || null;
1363
1368
  },
@@ -1379,7 +1384,7 @@ var AzzasTracker = (() => {
1379
1384
  return context.meta.search_term || null;
1380
1385
  },
1381
1386
  search_found: (context) => {
1382
- return context.meta.search_found || null;
1387
+ return context.meta.search_found || false;
1383
1388
  },
1384
1389
  search_quantity: (context) => {
1385
1390
  return context.meta.search_quantity || 0;
@@ -1393,17 +1398,14 @@ var AzzasTracker = (() => {
1393
1398
  creative_slot: (context) => {
1394
1399
  return context.meta.creative_slot || null;
1395
1400
  },
1396
- size: (context) => {
1397
- return context.size || null;
1398
- },
1399
1401
  item_ref: (context) => {
1400
- return context.itemRef || null;
1402
+ return context.meta.item_ref || null;
1401
1403
  },
1402
1404
  method: (context) => {
1403
- return context.method || null;
1405
+ return context.meta.method || null;
1404
1406
  },
1405
1407
  type: (context) => {
1406
- return context.type || null;
1408
+ return context.meta.type || null;
1407
1409
  },
1408
1410
  color: (context) => {
1409
1411
  return context.meta.color || null;
@@ -1416,6 +1418,9 @@ var AzzasTracker = (() => {
1416
1418
  },
1417
1419
  ordering: (context) => {
1418
1420
  return context.meta.ordering || null;
1421
+ },
1422
+ size: (context) => {
1423
+ return context.meta.size || null;
1419
1424
  }
1420
1425
  };
1421
1426
 
@@ -1475,7 +1480,7 @@ var AzzasTracker = (() => {
1475
1480
  var IN_STOCK_SCHEMA = "https://schema.org/InStock";
1476
1481
  var LIST_PRICE_SCHEMA = "https://schema.org/ListPrice";
1477
1482
  var decoAdapter = {
1478
- ...metaAdapters,
1483
+ ...metaAdapter,
1479
1484
  // global adapters
1480
1485
  items: (context) => {
1481
1486
  if (context == null ? void 0 : context.items) return context.items;
@@ -1526,7 +1531,7 @@ var AzzasTracker = (() => {
1526
1531
  line_items: (context) => {
1527
1532
  if (context == null ? void 0 : context.line_items) return context.line_items;
1528
1533
  if (context == null ? void 0 : context.products) {
1529
- return context.products.map((item) => item == null ? void 0 : item.inProductGroupWithID).filter((id) => Boolean(id));
1534
+ return context.products.map((item) => item == null ? void 0 : item.inProductGroupWithID).filter((id) => Boolean(id)).join();
1530
1535
  }
1531
1536
  return null;
1532
1537
  },
@@ -1564,8 +1569,108 @@ var AzzasTracker = (() => {
1564
1569
  }
1565
1570
  };
1566
1571
 
1567
- // src/params/adapters/headless/utils.ts
1572
+ // src/params/adapters/reserva/utils.ts
1568
1573
  var getItemCategory5 = (item) => {
1574
+ var _a, _b, _c;
1575
+ const categories = (_b = (_a = item == null ? void 0 : item.similarItems) == null ? void 0 : _a[0]) == null ? void 0 : _b.categories;
1576
+ if (!(categories == null ? void 0 : categories.length)) return "Cole\xE7\xE3o";
1577
+ const match = (_c = categories.join(" ").match(/outlet|bazar|sale/i)) == null ? void 0 : _c[0].toLowerCase();
1578
+ return match != null ? match : "Cole\xE7\xE3o";
1579
+ };
1580
+ var getItemCategory23 = (item) => {
1581
+ var _a, _b, _c, _d;
1582
+ const AVOID_CATEGORIES = /^(outlet|bazar|sale|coleção)$/i;
1583
+ const categories = (_c = (_b = (_a = item == null ? void 0 : item.similarItems) == null ? void 0 : _a[0]) == null ? void 0 : _b.categories) != null ? _c : [];
1584
+ const validHierarchy = categories.filter((c) => c && !AVOID_CATEGORIES.test(c));
1585
+ const deepest = (_d = validHierarchy[validHierarchy.length - 1]) != null ? _d : "";
1586
+ return capitalize(deepest);
1587
+ };
1588
+
1589
+ // src/params/adapters/reserva/index.ts
1590
+ var reservaAdapter = {
1591
+ ...metaAdapter,
1592
+ // global adapters
1593
+ items: (context) => {
1594
+ if (context == null ? void 0 : context.items) return context.items;
1595
+ if (context == null ? void 0 : context.products) {
1596
+ return context.products.map((item) => {
1597
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E;
1598
+ const COLOR_REGEX = /^[^_]+_/;
1599
+ const listPrice = (_b = (_a = item == null ? void 0 : item.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b[0].listPrice;
1600
+ const refIdValue = (_e = (_d = (_c = item.additionalProperty) == null ? void 0 : _c.find((i) => i.name === "RefId")) == null ? void 0 : _d.value) == null ? void 0 : _e.replace(/_\d+$/, "");
1601
+ return {
1602
+ quantity: 1,
1603
+ index: (_f = item == null ? void 0 : item.index) != null ? _f : 0,
1604
+ item_brand: (_i = (_h = (_g = item.brand) == null ? void 0 : _g.name) == null ? void 0 : _h.toLowerCase()) != null ? _i : null,
1605
+ item_name: (_j = item.isVariantOf.name) != null ? _j : null,
1606
+ price: (_l = (_k = item.offers) == null ? void 0 : _k.lowPrice) != null ? _l : null,
1607
+ discount: Math.round((Number(listPrice) - Number((_m = item == null ? void 0 : item.offers) == null ? void 0 : _m.lowPrice)) * 100) / 100,
1608
+ item_variant: ((_o = (_n = item == null ? void 0 : item.name) == null ? void 0 : _n.split(" - ")[0]) == null ? void 0 : _o.replace(COLOR_REGEX, "").replace(/_/g, " ")) || null,
1609
+ // cor
1610
+ item_variant2: (_q = (_p = item == null ? void 0 : item.name) == null ? void 0 : _p.split(" - ")[1]) != null ? _q : null,
1611
+ // tamanho
1612
+ item_shipping_tier: "",
1613
+ item_ref: refIdValue != null ? refIdValue : null,
1614
+ item_category: (_r = getItemCategory5(item)) != null ? _r : null,
1615
+ item_category2: (_s = getItemCategory23(item)) != null ? _s : null,
1616
+ item_id: (_t = item == null ? void 0 : item.id) != null ? _t : null,
1617
+ item_sku: (_u = item == null ? void 0 : item.sku) != null ? _u : null,
1618
+ item_url: (_w = (_v = item == null ? void 0 : item.seo) == null ? void 0 : _v.canonical) != null ? _w : null,
1619
+ image_url: (_y = resizeVtexImage2((_x = item == null ? void 0 : item.image) == null ? void 0 : _x[0].url)) != null ? _y : null,
1620
+ seller_id: (_D = (_C = (_B = (_A = (_z = item.offers) == null ? void 0 : _z.offers) == null ? void 0 : _A[0]) == null ? void 0 : _B.seller) == null ? void 0 : _C.identifier) != null ? _D : null,
1621
+ item_list_name: (_E = item == null ? void 0 : item.item_list_name) != null ? _E : null
1622
+ };
1623
+ });
1624
+ }
1625
+ return null;
1626
+ },
1627
+ brand: (context, config2) => {
1628
+ if (config2 == null ? void 0 : config2.brand) return config2.brand;
1629
+ if (context == null ? void 0 : context.brand) return context.brand;
1630
+ if (context == null ? void 0 : context.products) {
1631
+ return normalizeBrand2(context.products.map((p) => {
1632
+ var _a;
1633
+ return (_a = p == null ? void 0 : p.brand) == null ? void 0 : _a.name;
1634
+ }));
1635
+ }
1636
+ return null;
1637
+ },
1638
+ line_items: (context) => {
1639
+ if (context == null ? void 0 : context.line_items) return context.line_items;
1640
+ if (context == null ? void 0 : context.products) {
1641
+ return context.products.map((item) => item == null ? void 0 : item.id).filter((id) => Boolean(id)).join();
1642
+ }
1643
+ return null;
1644
+ },
1645
+ value: (context) => {
1646
+ if (context == null ? void 0 : context.value) return context.value;
1647
+ if (context == null ? void 0 : context.products) {
1648
+ return context.products.map((item) => {
1649
+ var _a;
1650
+ return (_a = item.offers) == null ? void 0 : _a.lowPrice;
1651
+ }).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
1652
+ }
1653
+ return null;
1654
+ },
1655
+ available_grid: (context) => {
1656
+ if (context == null ? void 0 : context.available_grid) return context.available_grid;
1657
+ if (context == null ? void 0 : context.products) {
1658
+ const sizes = context.products.filter((product) => {
1659
+ var _a, _b;
1660
+ return (_b = (_a = product.offers) == null ? void 0 : _a.offers) == null ? void 0 : _b.some((o) => o.availability === "https://schema.org/InStock");
1661
+ }).map((product) => {
1662
+ var _a;
1663
+ return (_a = product.name) == null ? void 0 : _a.split(" - ")[1];
1664
+ }).filter((name) => Boolean(name));
1665
+ const result = sortSizes(sizes).join(",").trim();
1666
+ return result || null;
1667
+ }
1668
+ return null;
1669
+ }
1670
+ };
1671
+
1672
+ // src/params/adapters/headless/utils.ts
1673
+ var getItemCategory6 = (item) => {
1569
1674
  const keywords = ["outlet", "bazar", "sale"];
1570
1675
  const regex = new RegExp(keywords.join("|"), "i");
1571
1676
  const value = item == null ? void 0 : item.categories;
@@ -1578,7 +1683,7 @@ var AzzasTracker = (() => {
1578
1683
  }
1579
1684
  return "Cole\xE7\xE3o";
1580
1685
  };
1581
- var getItemCategory23 = (item) => {
1686
+ var getItemCategory24 = (item) => {
1582
1687
  var _a, _b, _c;
1583
1688
  const avoidList = /outlet|bazar|sale/i;
1584
1689
  const lastCategory = (_b = (_a = item.categories) == null ? void 0 : _a[item.categories.length - 1]) != null ? _b : "";
@@ -1608,8 +1713,8 @@ var AzzasTracker = (() => {
1608
1713
  item_variant2: (_k = (_j = (_i = item.items[0]) == null ? void 0 : _i.name) == null ? void 0 : _j.split(" - ")[1]) != null ? _k : null,
1609
1714
  item_ref: (_l = item.productReference) != null ? _l : null,
1610
1715
  // sem ref no retorno do IS na multi-lib produtos PDC
1611
- item_category: getItemCategory5(item),
1612
- item_category2: (_m = getItemCategory23(item)) != null ? _m : null,
1716
+ item_category: getItemCategory6(item),
1717
+ item_category2: (_m = getItemCategory24(item)) != null ? _m : null,
1613
1718
  item_id: (_n = item == null ? void 0 : item.productId) != null ? _n : null,
1614
1719
  item_sku: (_p = (_o = item.items) == null ? void 0 : _o[0].itemId) != null ? _p : null,
1615
1720
  item_url: (_q = item.link) != null ? _q : null,
@@ -1635,7 +1740,7 @@ var AzzasTracker = (() => {
1635
1740
  line_items: (context) => {
1636
1741
  if (context == null ? void 0 : context.line_items) return context.line_items;
1637
1742
  if (context == null ? void 0 : context.products) {
1638
- return context.products.map((item) => item.productId).filter((id) => Boolean(id));
1743
+ return context.products.map((item) => item.productId).filter((id) => Boolean(id)).join();
1639
1744
  }
1640
1745
  return null;
1641
1746
  },
@@ -1670,8 +1775,8 @@ var AzzasTracker = (() => {
1670
1775
  item_variant2: (_i = (_h = ((_g = item.additionalProperty) != null ? _g : []).find((p) => p.name === "Tamanho")) == null ? void 0 : _h.value) != null ? _i : null,
1671
1776
  item_ref: null,
1672
1777
  // sem ref no retorno do IS na multi-lib produtos PDC
1673
- item_category: getItemCategory5(item),
1674
- item_category2: (_j = getItemCategory23(item)) != null ? _j : null,
1778
+ item_category: getItemCategory6(item),
1779
+ item_category2: (_j = getItemCategory24(item)) != null ? _j : null,
1675
1780
  item_id: (_k = item.isVariantOf.productGroupID) != null ? _k : null,
1676
1781
  item_sku: (_l = item.sku) != null ? _l : null,
1677
1782
  item_url: null,
@@ -1694,7 +1799,7 @@ var AzzasTracker = (() => {
1694
1799
  line_items: (context) => {
1695
1800
  if (context == null ? void 0 : context.line_items) return context.line_items;
1696
1801
  if (context == null ? void 0 : context.products) {
1697
- return context.products.map((item) => item.id).filter((id) => Boolean(id));
1802
+ return context.products.map((item) => item.id).filter((id) => Boolean(id)).join();
1698
1803
  }
1699
1804
  return null;
1700
1805
  },
@@ -1710,7 +1815,7 @@ var AzzasTracker = (() => {
1710
1815
 
1711
1816
  // src/params/adapters/headless/index.ts
1712
1817
  var headlessAdapter = {
1713
- ...metaAdapters,
1818
+ ...metaAdapter,
1714
1819
  // global adapters
1715
1820
  brand: (context, config2) => {
1716
1821
  if (context.zone === "PDP") {
@@ -1778,7 +1883,7 @@ var AzzasTracker = (() => {
1778
1883
 
1779
1884
  // src/params/adapters/pickup/index.ts
1780
1885
  var pickupAdapter = {
1781
- ...metaAdapters,
1886
+ ...metaAdapter,
1782
1887
  flag_pickup: (context) => {
1783
1888
  var _a;
1784
1889
  return (_a = context == null ? void 0 : context.flag_pickup) != null ? _a : null;
@@ -1809,7 +1914,15 @@ var AzzasTracker = (() => {
1809
1914
  };
1810
1915
 
1811
1916
  // src/params/adapters/orderForm/utils.ts
1812
- var getItemCategory6 = (item) => {
1917
+ var getOrderFormItems = (orderForm) => {
1918
+ const idSelected = orderForm == null ? void 0 : orderForm.selected;
1919
+ const isMultipleRemove = orderForm == null ? void 0 : orderForm.multipleRemove;
1920
+ return idSelected ? orderForm.items.filter((item) => item.id === idSelected).map((i) => {
1921
+ if (isMultipleRemove) return i;
1922
+ return { ...i, quantity: 1 };
1923
+ }) : orderForm.items;
1924
+ };
1925
+ var getItemCategory7 = (item) => {
1813
1926
  var _a;
1814
1927
  const categories = item == null ? void 0 : item.productCategories;
1815
1928
  if (!categories) return "Cole\xE7\xE3o";
@@ -1817,7 +1930,7 @@ var AzzasTracker = (() => {
1817
1930
  const match = (_a = text.match(/outlet|bazar|sale/i)) == null ? void 0 : _a[0].toLowerCase();
1818
1931
  return match != null ? match : "Cole\xE7\xE3o";
1819
1932
  };
1820
- var getItemCategory24 = (item) => {
1933
+ var getItemCategory25 = (item) => {
1821
1934
  var _a, _b;
1822
1935
  const AVOID_CATEGORIES = /outlet|bazar|sale/i;
1823
1936
  const categories = Object.values((_a = item == null ? void 0 : item.productCategories) != null ? _a : {});
@@ -1833,38 +1946,53 @@ var AzzasTracker = (() => {
1833
1946
  const selectedSla = (_c = info == null ? void 0 : info.slas) == null ? void 0 : _c.find((sla) => sla.id === info.selectedSla);
1834
1947
  return ((_d = selectedSla == null ? void 0 : selectedSla.pickupStoreInfo) == null ? void 0 : _d.friendlyName) ? `retirada em loja: ${selectedSla.pickupStoreInfo.friendlyName}` : (selectedSla == null ? void 0 : selectedSla.name) ? `Receba em casa: ${selectedSla.name}` : null;
1835
1948
  }
1836
- var getOrderFormItems = (orderForm) => {
1837
- const idSelected = orderForm == null ? void 0 : orderForm.selected;
1838
- return idSelected ? orderForm.items.filter((item) => item.id === idSelected) : orderForm.items;
1949
+ var getPaymentType2 = (context) => {
1950
+ var _a, _b, _c, _d;
1951
+ if (context.payment_type) return context.payment_type;
1952
+ if (!context.orderForm) return null;
1953
+ const giftCards = ((_a = context.orderForm.paymentData) == null ? void 0 : _a.giftCards) || [];
1954
+ if (giftCards.some((g) => g == null ? void 0 : g.inUse)) return "vale";
1955
+ const payments = ((_b = context.orderForm.paymentData) == null ? void 0 : _b.payments) || [];
1956
+ const systems = ((_c = context.orderForm.paymentData) == null ? void 0 : _c.paymentSystems) || [];
1957
+ if (!payments.length || !systems.length) return null;
1958
+ const selectedPayment = payments.find((p) => p == null ? void 0 : p.paymentSystem) || payments[0];
1959
+ const id = String((selectedPayment == null ? void 0 : selectedPayment.paymentSystem) || "").trim();
1960
+ if (!id) return null;
1961
+ const system = systems.find((s) => String(s.id) === id);
1962
+ const name = ((_d = system == null ? void 0 : system.name) == null ? void 0 : _d.toLowerCase()) || "";
1963
+ const match = paymentTypeMap.find(([key]) => name.includes(key));
1964
+ return match ? match[1] : null;
1839
1965
  };
1840
1966
 
1841
1967
  // src/params/adapters/orderForm/index.ts
1842
1968
  var orderFormAdapter = {
1843
- ...metaAdapters,
1969
+ ...metaAdapter,
1844
1970
  items: (context) => {
1845
1971
  if (context == null ? void 0 : context.items) return context.items;
1846
1972
  if ((context == null ? void 0 : context.orderForm) && (context == null ? void 0 : context.orderForm.items)) {
1847
1973
  return getOrderFormItems(context.orderForm).map((item, index) => {
1848
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
1974
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
1975
+ const color = context.brand === "carolbassi" ? null : (_c = (_b = (_a = item == null ? void 0 : item.skuName) == null ? void 0 : _a.split(" - ")[0]) == null ? void 0 : _b.split("_").pop()) == null ? void 0 : _c.trim();
1976
+ const size = context.brand === "carolbassi" ? item == null ? void 0 : item.skuName : (_e = (_d = item == null ? void 0 : item.skuName) == null ? void 0 : _d.split(" - ")[1]) == null ? void 0 : _e.trim();
1849
1977
  return {
1850
- quantity: (_a = item == null ? void 0 : item.quantity) != null ? _a : 1,
1851
- index: (_d = (_c = (_b = context == null ? void 0 : context.orderForm) == null ? void 0 : _b.index) != null ? _c : index) != null ? _d : null,
1852
- item_brand: (_f = (_e = item.additionalInfo) == null ? void 0 : _e.brandName) != null ? _f : null,
1853
- item_name: (_g = item == null ? void 0 : item.name.replace(item == null ? void 0 : item.skuName, "").trim()) != null ? _g : null,
1854
- price: (item == null ? void 0 : item.price) / 100,
1978
+ quantity: (_f = item == null ? void 0 : item.quantity) != null ? _f : 1,
1979
+ index: (_h = (_g = context == null ? void 0 : context.orderForm) == null ? void 0 : _g.index) != null ? _h : index + 1,
1980
+ item_brand: (_j = (_i = item.additionalInfo) == null ? void 0 : _i.brandName) != null ? _j : null,
1981
+ item_name: (_k = item == null ? void 0 : item.name.replace(item == null ? void 0 : item.skuName, "").trim()) != null ? _k : null,
1982
+ price: (item == null ? void 0 : item.sellingPrice) / 100,
1855
1983
  discount: ((item == null ? void 0 : item.listPrice) - (item == null ? void 0 : item.sellingPrice)) / 100,
1856
- item_variant: (_k = (_j = (_i = (_h = item == null ? void 0 : item.skuName) == null ? void 0 : _h.split(" - ")[0]) == null ? void 0 : _i.split("_").pop()) == null ? void 0 : _j.trim()) != null ? _k : null,
1857
- item_variant2: (_n = (_m = (_l = item == null ? void 0 : item.skuName) == null ? void 0 : _l.split(" - ")[1]) == null ? void 0 : _m.trim()) != null ? _n : null,
1984
+ item_variant: color != null ? color : null,
1985
+ item_variant2: size != null ? size : null,
1858
1986
  item_shipping_tier: getItemShippingTier2(context.orderForm, item),
1859
1987
  item_ref: (item == null ? void 0 : item.productRefId) || (item == null ? void 0 : item.refId.replace(/_\d+$/, "")) || null,
1860
- item_category: (_o = getItemCategory6(item)) != null ? _o : null,
1861
- item_category2: (_p = getItemCategory24(item)) != null ? _p : null,
1862
- item_id: (_q = item == null ? void 0 : item.productId) != null ? _q : null,
1863
- item_sku: (_r = item == null ? void 0 : item.id) != null ? _r : null,
1864
- item_url: (_s = item.detailUrl) != null ? _s : null,
1865
- image_url: (_t = resizeVtexImage2(item.imageUrl)) != null ? _t : null,
1866
- seller_id: (_u = item == null ? void 0 : item.seller) != null ? _u : null,
1867
- item_list_name: (_w = (_v = context == null ? void 0 : context.orderForm) == null ? void 0 : _v.item_list_name) != null ? _w : null
1988
+ item_category: (_l = getItemCategory7(item)) != null ? _l : null,
1989
+ item_category2: (_m = getItemCategory25(item)) != null ? _m : null,
1990
+ item_id: (_n = item == null ? void 0 : item.productId) != null ? _n : null,
1991
+ item_sku: (_o = item == null ? void 0 : item.id) != null ? _o : null,
1992
+ item_url: (_p = item.detailUrl) != null ? _p : null,
1993
+ image_url: (_q = resizeVtexImage2(item.imageUrl)) != null ? _q : null,
1994
+ seller_id: (_r = item == null ? void 0 : item.seller) != null ? _r : null,
1995
+ item_list_name: (_t = (_s = context == null ? void 0 : context.orderForm) == null ? void 0 : _s.item_list_name) != null ? _t : null
1868
1996
  };
1869
1997
  });
1870
1998
  }
@@ -1882,26 +2010,22 @@ var AzzasTracker = (() => {
1882
2010
  var _a;
1883
2011
  if (context == null ? void 0 : context.line_items) return context.line_items;
1884
2012
  if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
1885
- return getOrderFormItems(context.orderForm).map((item) => item == null ? void 0 : item.productId).filter((id) => Boolean(id));
2013
+ return getOrderFormItems(context.orderForm).map((item) => item == null ? void 0 : item.productId).filter((id) => Boolean(id)).join();
1886
2014
  },
1887
2015
  value: (context) => {
1888
2016
  var _a;
1889
2017
  if (context == null ? void 0 : context.value) return context.value;
1890
2018
  if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
1891
- return getOrderFormItems(context.orderForm).map((item) => (item == null ? void 0 : item.price) / 100 * item.quantity).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
2019
+ return getOrderFormItems(context.orderForm).map((item) => (item == null ? void 0 : item.sellingPrice) / 100 * item.quantity).filter((price) => price !== void 0).reduce((sum, price) => sum + price, 0);
1892
2020
  },
1893
- payment_type: getPaymentType,
2021
+ payment_type: getPaymentType2,
1894
2022
  total_discount: (context) => {
1895
- var _a, _b;
2023
+ var _a, _b, _c;
1896
2024
  if (context == null ? void 0 : context.total_discount) return context.total_discount;
1897
2025
  if (!((_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.items)) return null;
1898
- const totalsList = ((_b = context.orderForm) == null ? void 0 : _b.totalizers) || [];
1899
- const totalDiscount = getOrderFormItems(context.orderForm).reduce((acc, item) => {
1900
- const unitDiscount = Math.max(0, item.listPrice - item.sellingPrice);
1901
- return acc + unitDiscount * item.quantity;
1902
- }, 0);
1903
- const discounts = totalsList.find((t) => t.id === "Discounts");
1904
- return Math.abs(((discounts == null ? void 0 : discounts.value) || 0) + totalDiscount) / 100 || null;
2026
+ const totalizers = (_b = context == null ? void 0 : context.orderForm) == null ? void 0 : _b.totalizers;
2027
+ const productDiscount = ((_c = totalizers.find((t) => t.id === "Discounts")) == null ? void 0 : _c.value) || 0;
2028
+ return Math.abs(productDiscount) / 100 || null;
1905
2029
  },
1906
2030
  subtotal: (context) => {
1907
2031
  var _a, _b;
@@ -1909,17 +2033,6 @@ var AzzasTracker = (() => {
1909
2033
  const subtotal = totalsList.filter((t) => t.id === "Items").reduce((acc, t) => acc + (t.value || 0), 0) / 100 || 0;
1910
2034
  return subtotal;
1911
2035
  },
1912
- coupon_message: (context) => {
1913
- var _a;
1914
- if (context.couponMessage) return context.couponMessage;
1915
- const messages = ((_a = context.orderForm) == null ? void 0 : _a.messages) || [];
1916
- if (messages.length === 0) return null;
1917
- const couponMessages = messages.filter(
1918
- (msg) => msg.text.toLowerCase().includes("cupom")
1919
- );
1920
- if (couponMessages.length === 0) return null;
1921
- return couponMessages.map((msg) => msg.text).join(" | ");
1922
- },
1923
2036
  zipcode: (context) => {
1924
2037
  var _a;
1925
2038
  return (_a = context.meta.zipcode) != null ? _a : null;
@@ -1963,7 +2076,7 @@ var AzzasTracker = (() => {
1963
2076
  var _a2, _b2;
1964
2077
  const selected = (_a2 = item.slas) == null ? void 0 : _a2.find((sla) => sla.id === item.selectedSla);
1965
2078
  return total + ((_b2 = selected == null ? void 0 : selected.price) != null ? _b2 : 0);
1966
- }, 0);
2079
+ }, 0) / 100;
1967
2080
  },
1968
2081
  shipping_tier: (context) => {
1969
2082
  var _a, _b, _c;
@@ -2002,6 +2115,15 @@ var AzzasTracker = (() => {
2002
2115
  var _a, _b;
2003
2116
  return ((_b = (_a = context.orderForm) == null ? void 0 : _a.orderGroup) == null ? void 0 : _b.toString()) || null;
2004
2117
  },
2118
+ coupon_message: (context) => {
2119
+ var _a;
2120
+ if (context.couponMessage) return context.couponMessage;
2121
+ const messages = ((_a = context.orderForm) == null ? void 0 : _a.messages) || [];
2122
+ if (messages.length === 0) return "C\xF3digo de desconto aplicado com sucesso";
2123
+ const couponMessages = messages.filter((msg) => msg.text.toLowerCase().includes("cupom"));
2124
+ if (couponMessages.length === 0) return "C\xF3digo de desconto aplicado com sucesso";
2125
+ return couponMessages.map((msg) => msg.text).join(" | ");
2126
+ },
2005
2127
  coupon: (context) => {
2006
2128
  var _a, _b;
2007
2129
  return context.appliedCoupon || ((_b = (_a = context == null ? void 0 : context.orderForm) == null ? void 0 : _a.marketingData) == null ? void 0 : _b.coupon) || null;
@@ -2014,9 +2136,11 @@ var AzzasTracker = (() => {
2014
2136
  // src/formatter.ts
2015
2137
  var adapters = {
2016
2138
  DECO: decoAdapter,
2139
+ RESERVA: reservaAdapter,
2017
2140
  HEADLESS: headlessAdapter,
2018
2141
  PICKUP: pickupAdapter,
2019
- ORDERFORM: orderFormAdapter
2142
+ ORDERFORM: orderFormAdapter,
2143
+ META: metaAdapter
2020
2144
  };
2021
2145
  async function getParameters(context, eventName, config2) {
2022
2146
  var _a;