@useinsider/guido 3.21.2-beta.eea8885 → 3.21.3-beta.936209b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,108 +1,100 @@
1
- import { ITEMS_CURRENCY_ATTR as U, isCustomCurrencySymbol as Y } from "../extensions/Blocks/Items/constants/currency.js";
2
- import { productPairs as M } from "../extensions/Blocks/Items/enums/productEnums.js";
3
- import { escapeReplacement as B } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
4
- import { preserveTextStyles as L } from "./preserveTextStyles.js";
5
- import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
6
- const q = {
1
+ import { ITEMS_CURRENCY_ATTR as x, isCustomCurrencySymbol as Y } from "../extensions/Blocks/Items/constants/currency.js";
2
+ import { productPairs as w } from "../extensions/Blocks/Items/enums/productEnums.js";
3
+ import { escapeReplacement as X } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
4
+ import { preserveTextStyles as P } from "./preserveTextStyles.js";
5
+ import { unwrapProductNameLinks as v } from "./unwrapProductNameLink.js";
6
+ const O = {
7
7
  CART_ITEMS: "ins_apr",
8
8
  BROWSED_ITEMS: "browsed_item",
9
9
  PURCHASED_ITEMS: "purchased_item"
10
- }, W = ($) => $.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
11
- function v($, C, A) {
12
- let d = C;
13
- for (; d > 0 && /\s/.test($[d - 1]); )
14
- d -= 1;
15
- return A.some((E) => $.endsWith(E, d));
10
+ }, q = (S) => S.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
11
+ function B(S, y, b) {
12
+ let h = y;
13
+ for (; h > 0 && /\s/.test(S[h - 1]); )
14
+ h -= 1;
15
+ return b.some((I) => S.endsWith(I, h));
16
16
  }
17
- const j = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
18
- function Q($, C) {
19
- var d;
20
- const A = $.ownerDocument.createTreeWalker($, NodeFilter.SHOW_COMMENT);
21
- for (let E = A.nextNode(); E; E = A.nextNode())
22
- (d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(j, (k, P) => `${P}href="${C}"`));
23
- }
24
- function et($) {
25
- const C = W($), A = new DOMParser().parseFromString(C, "text/html");
26
- X(A);
27
- const d = M.PAIRS_FOR_EXTENSION;
28
- Object.entries(d).forEach(([o, p]) => {
29
- A.querySelectorAll(".ins-product-td").forEach((r) => {
30
- const _ = r.getAttribute("data-number") || "1", y = r.getAttribute("data-type") || "CART_ITEMS";
31
- r.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
32
- var S, I, O, x;
33
- const m = t.getAttribute("data-type") || y, n = t.getAttribute("data-number") || _, f = p[m];
17
+ function Z(S) {
18
+ const y = q(S), b = new DOMParser().parseFromString(y, "text/html");
19
+ v(b);
20
+ const h = w.PAIRS_FOR_EXTENSION;
21
+ Object.entries(h).forEach(([n, d]) => {
22
+ b.querySelectorAll(".ins-product-td").forEach((r) => {
23
+ const E = r.getAttribute("data-number") || "1", m = r.getAttribute("data-type") || "CART_ITEMS";
24
+ r.querySelectorAll(`[product-attr="${n}"]`).forEach((t) => {
25
+ var $, F, D, N;
26
+ const g = t.getAttribute("data-type") || m, o = t.getAttribute("data-number") || E, f = d[g];
34
27
  if (f)
35
- switch (o) {
28
+ switch (n) {
36
29
  case "imageSrc": {
37
- let e = null, s = null;
38
- if (t.tagName === "IMG" ? (e = t, s = e.closest("a")) : (e = t.querySelector("img"), s = t.querySelector("a") || t.closest("a")), !e)
30
+ let e = null, a = null;
31
+ if (t.tagName === "IMG" ? (e = t, a = e.closest("a")) : (e = t.querySelector("img"), a = t.querySelector("a") || t.closest("a")), !e)
39
32
  break;
40
33
  const l = f.DEFAULT, c = f.ATTR;
41
34
  if (l && e.src) {
42
- const a = e.src;
43
- l.some((g) => {
44
- const u = g.split("/").pop() || "", H = a.split("/").pop() || "";
45
- return a.includes(g) || a.includes(u) || H === u;
46
- }) && (e.src = `{{${c}_${n}}}`);
35
+ const s = e.src;
36
+ l.some((R) => {
37
+ const u = R.split("/").pop() || "", H = s.split("/").pop() || "";
38
+ return s.includes(R) || s.includes(u) || H === u;
39
+ }) && (e.src = `{{${c}_${o}}}`);
47
40
  }
48
- const i = (I = (S = d.name) == null ? void 0 : S[m]) == null ? void 0 : I.ATTR;
49
- if (i && e.setAttribute("alt", `{{${i}_${n}}}`), s) {
50
- const a = (O = d.itemLink) == null ? void 0 : O[m];
51
- if (a) {
52
- const b = a.HREF, g = a.DEFAULT_HREF || "#!", u = s.href;
53
- (u === "#" || u === "" || u.endsWith("#!") || u.endsWith(g) || u === `${window.location.href}${g}` || !u || u === window.location.href) && (s.href = `{{${b}_${n}}}`);
41
+ const i = (F = ($ = h.name) == null ? void 0 : $[g]) == null ? void 0 : F.ATTR;
42
+ if (i && e.setAttribute("alt", `{{${i}_${o}}}`), a) {
43
+ const s = (D = h.itemLink) == null ? void 0 : D[g];
44
+ if (s) {
45
+ const _ = s.HREF, R = s.DEFAULT_HREF || "#!", u = a.href;
46
+ (u === "#" || u === "" || u.endsWith("#!") || u.endsWith(R) || u === `${window.location.href}${R}` || !u || u === window.location.href) && (a.href = `{{${_}_${o}}}`);
54
47
  }
55
48
  }
56
49
  break;
57
50
  }
58
51
  case "name": {
59
- const e = f, s = e.ATTR, l = e.DEFAULT_HREF || "#!", c = e.HREF;
60
- t.textContent && (t.innerHTML = L(t, `{{${s}_${n}}}`));
52
+ const e = f, a = e.ATTR, l = e.DEFAULT_HREF || "#!", c = e.HREF;
53
+ t.textContent && (t.innerHTML = P(t, `{{${a}_${o}}}`));
61
54
  const i = t.closest("a") || (t.tagName === "A" ? t : null);
62
55
  if (i && c) {
63
- const a = i.href, b = `${window.location.href}${l}`;
64
- (a === b || a.endsWith(l)) && (i.href = `{{${c}_${n}}}`);
56
+ const s = i.href, _ = `${window.location.href}${l}`;
57
+ (s === _ || s.endsWith(l)) && (i.href = `{{${c}_${o}}}`);
65
58
  }
66
59
  break;
67
60
  }
68
61
  case "price":
69
62
  case "originalPrice": {
70
- const e = f, s = t.getAttribute("data-formated"), l = t.getAttribute("data-single_price"), c = s === "true", i = l === "true", a = t.getAttribute(U.POSITION) || "before";
71
- let b;
72
- i ? b = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : b = c ? e.PRICE_FORMATTED : e.PRICE;
73
- const g = e.CURRENCY;
74
- let u = `{{${b}_${n}}}`;
75
- const H = (t.getAttribute(U.SYMBOL) || "").trim(), G = Y(H);
76
- let F = "";
77
- G ? F = H : g && (F = `{{${g}_${n}}}`), F && (u = a === "after" ? `${u} ${F}` : `${F} ${u}`), t.innerHTML = L(t, u);
63
+ const e = f, a = t.getAttribute("data-formated"), l = t.getAttribute("data-single_price"), c = a === "true", i = l === "true", s = t.getAttribute(x.POSITION) || "before";
64
+ let _;
65
+ i ? _ = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : _ = c ? e.PRICE_FORMATTED : e.PRICE;
66
+ const R = e.CURRENCY;
67
+ let u = `{{${_}_${o}}}`;
68
+ const H = (t.getAttribute(x.SYMBOL) || "").trim(), G = Y(H);
69
+ let C = "";
70
+ G ? C = H : R && (C = `{{${R}_${o}}}`), C && (u = s === "after" ? `${u} ${C}` : `${C} ${u}`), t.innerHTML = P(t, u);
78
71
  break;
79
72
  }
80
73
  case "quantity": {
81
- const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (x = t.textContent) == null ? void 0 : x.trim();
82
- c && l.includes(c) && (t.innerHTML = L(t, `{{${s}_${n}}}`));
74
+ const e = f, a = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (N = t.textContent) == null ? void 0 : N.trim();
75
+ c && l.includes(c) && (t.innerHTML = P(t, `{{${a}_${o}}}`));
83
76
  break;
84
77
  }
85
78
  case "button": {
86
- const e = f, s = e.HREF, l = e.DEFAULT_HREF || "#!", c = t.tagName === "A" ? t : t.querySelector("a");
79
+ const e = f, a = e.HREF, l = e.DEFAULT_HREF || "#!", c = t.tagName === "A" ? t : t.querySelector("a");
87
80
  if (c) {
88
- const i = c.href || "", a = `${window.location.href}${l}`;
89
- (i === "" || i === "#" || i === a || i.endsWith(l) || i.endsWith("#!") || i === window.location.href) && (c.href = `{{${s}_${n}}}`);
81
+ const i = c.href || "", s = `${window.location.href}${l}`;
82
+ (i === "" || i === "#" || i === s || i.endsWith(l) || i.endsWith("#!") || i === window.location.href) && (c.href = `{{${a}_${o}}}`);
90
83
  }
91
- Q(t, `{{${s}_${n}}}`);
92
84
  break;
93
85
  }
94
86
  case "itemLink": {
95
- const e = f, s = e.HREF, l = e.DEFAULT_HREF || "#!", c = t;
87
+ const e = f, a = e.HREF, l = e.DEFAULT_HREF || "#!", c = t;
96
88
  if (c.href) {
97
- const i = c.href, a = `${window.location.href}${l}`;
98
- (i === a || i.endsWith(l)) && (c.href = `{{${s}_${n}}}`);
89
+ const i = c.href, s = `${window.location.href}${l}`;
90
+ (i === s || i.endsWith(l)) && (c.href = `{{${a}_${o}}}`);
99
91
  }
100
92
  break;
101
93
  }
102
94
  default: {
103
95
  if ("ATTR" in f) {
104
96
  const e = f.ATTR;
105
- t.textContent && (t.innerHTML = L(t, `{{${e}_${n}}}`));
97
+ t.textContent && (t.innerHTML = P(t, `{{${e}_${o}}}`));
106
98
  }
107
99
  break;
108
100
  }
@@ -110,49 +102,49 @@ function et($) {
110
102
  });
111
103
  });
112
104
  });
113
- const E = C.match(/<!DOCTYPE[^>]*>/i), k = E ? `${E[0]}
114
- ` : "", P = A.querySelectorAll(".ins-product-td"), N = [];
115
- P.forEach((o) => {
116
- const p = o.getAttribute("data-type") || "CART_ITEMS", T = o.getAttribute("data-number") || "1", r = o.outerHTML;
117
- N.push({
118
- element: o,
105
+ const I = y.match(/<!DOCTYPE[^>]*>/i), U = I ? `${I[0]}
106
+ ` : "", W = b.querySelectorAll(".ins-product-td"), M = [];
107
+ W.forEach((n) => {
108
+ const d = n.getAttribute("data-type") || "CART_ITEMS", p = n.getAttribute("data-number") || "1", r = n.outerHTML;
109
+ M.push({
110
+ element: n,
119
111
  outerHtml: r,
120
- type: p,
121
- number: T
112
+ type: d,
113
+ number: p
122
114
  });
123
115
  });
124
- let h = k + A.documentElement.outerHTML;
125
- N.reverse().forEach(({ outerHtml: o, type: p, number: T }) => {
126
- const r = q[p], _ = r ? `${r}_total_product_kind` : "";
127
- if (_) {
128
- const R = parseInt(T) - 1, n = `${`{% if ${_} > ${R} %}`}${o}{% endif %}`;
129
- h = h.replace(o, B(n));
116
+ let A = U + b.documentElement.outerHTML;
117
+ M.reverse().forEach(({ outerHtml: n, type: d, number: p }) => {
118
+ const r = O[d], E = r ? `${r}_total_product_kind` : "";
119
+ if (E) {
120
+ const T = parseInt(p) - 1, o = `${`{% if ${E} > ${T} %}`}${n}{% endif %}`;
121
+ A = A.replace(n, X(o));
130
122
  }
131
123
  });
132
- const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Set();
133
- return V.forEach((o) => {
124
+ const V = b.querySelectorAll('[product-attr="originalPrice"][data-type]'), L = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set();
125
+ return V.forEach((n) => {
134
126
  var t;
135
- const p = o.getAttribute("data-number"), T = o.getAttribute("data-type");
136
- if (!p || !q[T])
127
+ const d = n.getAttribute("data-number"), p = n.getAttribute("data-type");
128
+ if (!d || !O[p])
137
129
  return;
138
- const r = o.closest(".product-original-price-class");
139
- if (!r || D.has(r))
130
+ const r = n.closest(".product-original-price-class");
131
+ if (!r || k.has(r))
140
132
  return;
141
- D.add(r);
142
- const _ = r.outerHTML, y = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), R = w.get(_) ?? { number: p, type: T, wrap: [] };
143
- R.wrap.push(y !== "false"), w.set(_, R);
144
- }), w.forEach(({ number: o, type: p, wrap: T }, r) => {
145
- if (r.includes("{% if") || !T.some(Boolean))
133
+ k.add(r);
134
+ const E = r.outerHTML, m = (t = n.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), T = L.get(E) ?? { number: d, type: p, wrap: [] };
135
+ T.wrap.push(m !== "false"), L.set(E, T);
136
+ }), L.forEach(({ number: n, type: d, wrap: p }, r) => {
137
+ if (r.includes("{% if") || !p.some(Boolean))
146
138
  return;
147
- const _ = M.PAIRS_FOR_EXTENSION.price[p].PRICE, y = M.PAIRS_FOR_EXTENSION.originalPrice[p].PRICE, R = `{% if ${_}_${o} != ${y}_${o} %}`, t = [R, W(R)];
148
- let m = "", n = 0, f = 0, S = h.indexOf(r);
149
- for (; S !== -1; ) {
150
- const I = T[f] === !0 && !v(h, S, t);
151
- m += h.slice(n, S) + (I ? `${R}${r}{% endif %}` : r), n = S + r.length, f += 1, S = h.indexOf(r, n);
139
+ const E = w.PAIRS_FOR_EXTENSION.price[d].PRICE, m = w.PAIRS_FOR_EXTENSION.originalPrice[d].PRICE, T = `{% if ${E}_${n} != ${m}_${n} %}`, t = [T, q(T)];
140
+ let g = "", o = 0, f = 0, $ = A.indexOf(r);
141
+ for (; $ !== -1; ) {
142
+ const F = p[f] === !0 && !B(A, $, t);
143
+ g += A.slice(o, $) + (F ? `${T}${r}{% endif %}` : r), o = $ + r.length, f += 1, $ = A.indexOf(r, o);
152
144
  }
153
- h = m + h.slice(n);
154
- }), h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
145
+ A = g + A.slice(o);
146
+ }), A.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
155
147
  }
156
148
  export {
157
- et as pairProductVariables
149
+ Z as pairProductVariables
158
150
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.21.2-beta.eea8885",
3
+ "version": "3.21.3-beta.936209b",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",