@useinsider/guido 3.1.1-beta.2144586 → 3.1.1-beta.22c7df2
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/config/compiler/recommendationCompilerRules.js +158 -44
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +49 -46
- package/dist/enums/extensions/recommendationBlock.js +14 -11
- package/dist/enums/recommendation.js +2 -2
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +324 -218
- package/dist/package.json.js +1 -1
- package/dist/services/recommendationApi.js +12 -14
- package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
- package/dist/src/enums/extensions/recommendationBlock.d.ts +3 -0
- package/dist/static/styles/components/button.css.js +16 -9
- package/dist/static/styles/components/narrow-panel.css.js +52 -0
- package/dist/utils/templatePreparation.js +34 -25
- package/package.json +3 -4
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { useRecommendation as
|
|
2
|
-
import { DUMMY_IMAGE_MAPPINGS as
|
|
3
|
-
import { prepareRecommendationBlocks as
|
|
4
|
-
const
|
|
1
|
+
import { useRecommendation as N } from "../../composables/useRecommendation.js";
|
|
2
|
+
import { DUMMY_IMAGE_MAPPINGS as C, REGEX as T, VerticalOrientation as M, CSS as E, ATTRIBUTES as R, CONDITIONS as $, HTML as h } from "../../enums/recommendation.js";
|
|
3
|
+
import { prepareRecommendationBlocks as x } from "./utils/recommendationCompilerUtils.js";
|
|
4
|
+
const w = [
|
|
5
5
|
{
|
|
6
6
|
id: "replace-images-with-variable-names",
|
|
7
7
|
description: "Replacing dummy images with variable names in recommendation module",
|
|
8
8
|
type: "custom",
|
|
9
|
-
processor: (
|
|
10
|
-
let
|
|
11
|
-
return Object.entries(
|
|
12
|
-
Object.entries(
|
|
13
|
-
|
|
9
|
+
processor: (i) => {
|
|
10
|
+
let e = i;
|
|
11
|
+
return Object.entries(C).forEach(([, p]) => {
|
|
12
|
+
Object.entries(p).forEach(([c, n]) => {
|
|
13
|
+
e = e.replaceAll(n, `{{${c}}}`);
|
|
14
14
|
});
|
|
15
|
-
}),
|
|
15
|
+
}), e;
|
|
16
16
|
},
|
|
17
17
|
priority: 50
|
|
18
18
|
},
|
|
@@ -29,21 +29,21 @@ const G = [
|
|
|
29
29
|
id: "add-recommendation-unresponsive-css",
|
|
30
30
|
description: "Adding recommendation unresponsive css",
|
|
31
31
|
type: "custom",
|
|
32
|
-
processor: (
|
|
33
|
-
const { calculateCardWidth:
|
|
34
|
-
let
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
}),
|
|
42
|
-
const
|
|
43
|
-
|
|
32
|
+
processor: (i) => {
|
|
33
|
+
const { calculateCardWidth: e, getRecommendationCampaignData: p } = N();
|
|
34
|
+
let c = i;
|
|
35
|
+
const n = c.match(T.ID);
|
|
36
|
+
if (n) {
|
|
37
|
+
const a = [];
|
|
38
|
+
if (n.forEach((s) => {
|
|
39
|
+
const d = /recommendation-id="(.*?)"/i.exec(s), _ = d ? d[1].trim() : "", A = p(_);
|
|
40
|
+
A.textTrimming && A.orientation === M && a.push(e(A));
|
|
41
|
+
}), a.length) {
|
|
42
|
+
const s = `width:${Math.min(...a)}px!important;`;
|
|
43
|
+
c = c.replace(E.REGULAR_NAME_HEIGHT, `${E.TRIMMED_NAME_HEIGHT} ${s} ${E.ELLIPSIS}`).replace(E.REGULAR_NAME_CONTAINER_HEIGHT, E.TRIMMED_NAME_CONTAINER_CSS).replace(E.RESPONSIVE_NAME_SIZE, `${E.RESPONSIVE_NAME_HEIGHT} ${s} ${E.ELLIPSIS}`).replace(E.RESPONSIVE_NAME_CONTAINER_HEIGHT, E.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
return
|
|
46
|
+
return c;
|
|
47
47
|
},
|
|
48
48
|
priority: 52
|
|
49
49
|
},
|
|
@@ -51,39 +51,153 @@ const G = [
|
|
|
51
51
|
id: "prepare-recommendations",
|
|
52
52
|
description: "Replacing product data with template variables in recommendation blocks",
|
|
53
53
|
type: "custom",
|
|
54
|
-
processor: (
|
|
54
|
+
processor: (i) => x(i),
|
|
55
55
|
priority: 48
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
id: "add-discount-conditions",
|
|
59
59
|
description: "Adding discount conditions to the recommendation block",
|
|
60
60
|
type: "custom",
|
|
61
|
-
processor: (
|
|
62
|
-
let
|
|
63
|
-
const
|
|
64
|
-
return
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
61
|
+
processor: (i) => {
|
|
62
|
+
let e = i;
|
|
63
|
+
const p = e.match(T.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: c } = N();
|
|
64
|
+
return p !== null && p.forEach((n) => {
|
|
65
|
+
const a = n.match(T.CUSTOM_FIELD);
|
|
66
|
+
if (!a)
|
|
67
67
|
return;
|
|
68
|
-
const [
|
|
69
|
-
if (!
|
|
68
|
+
const [s] = a, d = s.match(T.CUSTOM_FIELD_INDEXES_PART), _ = s.match(T.CUSTOM_FIELD_NAME_PART), A = n.match(T.ATTRIBUTE_PARAGRAPH_START_TAG);
|
|
69
|
+
if (!d || !_ || !A)
|
|
70
70
|
return;
|
|
71
|
-
const [
|
|
72
|
-
let
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
|
|
71
|
+
const [I] = d, [S] = _, [m] = A, o = S.substring(1, S.length - 2), r = m.match(T.COMPOSITION) !== null;
|
|
72
|
+
let t = s;
|
|
73
|
+
if (r) {
|
|
74
|
+
const b = I.substring(2, I.length - 3), l = c(b);
|
|
75
|
+
o === R.OMNIBUS_PRICE && (l.priceBeforeTextValue && (t = `${l.priceBeforeTextValue}${t}`), l.priceAfterTextValue && (t = `${t}${l.priceAfterTextValue}`)), o === R.OMNIBUS_DISCOUNT && (l.discountBeforeTextValue && (t = `${l.discountBeforeTextValue}${t}`), l.discountAfterTextValue && (t = `${t}${l.discountAfterTextValue}`));
|
|
76
76
|
}
|
|
77
|
-
const
|
|
78
|
-
let
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
}),
|
|
77
|
+
const u = I.substring(2);
|
|
78
|
+
let f = "";
|
|
79
|
+
o in $.IF && (f = $.IF[o].replaceAll(`{${R.DISCOUNT}}`, `${u}${R.DISCOUNT}`).replaceAll(`{${R.OMNIBUS_DISCOUNT}}`, `${u}${R.OMNIBUS_DISCOUNT}`).replaceAll(`{${R.OMNIBUS_PRICE}}`, `${u}${R.OMNIBUS_PRICE}`));
|
|
80
|
+
const g = `${m}${t}${h.PARAGRAPH_END_TAG}`, y = `${f}${r ? g : n}${$.ELSE}${m}${h.PARAGRAPH_END_TAG}${$.END_IF}`;
|
|
81
|
+
e = e.replace(n, y);
|
|
82
|
+
}), e;
|
|
83
83
|
},
|
|
84
84
|
priority: 53
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: "strip-empty-omnibus-spans",
|
|
88
|
+
description: "Remove empty omnibus text-before and text-after span elements",
|
|
89
|
+
type: "regex",
|
|
90
|
+
pattern: '<span class="omnibus-text-(?:before|after)">\\s*</span>',
|
|
91
|
+
replacement: "",
|
|
92
|
+
flags: "g",
|
|
93
|
+
priority: 54
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: "strip-recommendation-editor-attributes",
|
|
97
|
+
description: "Strip editor-only attributes from compiled recommendation output",
|
|
98
|
+
type: "regex",
|
|
99
|
+
// eslint-disable-next-line @stylistic/max-len
|
|
100
|
+
pattern: '\\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|product-attr|composition)="[^"]*"',
|
|
101
|
+
replacement: "",
|
|
102
|
+
flags: "g",
|
|
103
|
+
priority: 55
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: "strip-unused-recommendation-classes",
|
|
107
|
+
description: "Remove CSS classes not referenced by any style rule from recommendation elements",
|
|
108
|
+
type: "custom",
|
|
109
|
+
processor: (i) => {
|
|
110
|
+
let e = i.replace(
|
|
111
|
+
/ class="(?:product-card-segment|attribute-cell|recommendation-attribute-row|product-image|product-name|product-price|product-old-price|product-omnibus-price|product-omnibus-discount|product-button|recommendation-product-row|product-card-wrapper)"/g,
|
|
112
|
+
""
|
|
113
|
+
);
|
|
114
|
+
return e = e.replaceAll("es-button buy-button", "es-button"), e = e.replaceAll("ins-recommendation-product-container ", ""), e;
|
|
115
|
+
},
|
|
116
|
+
priority: 56
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: "remove-empty-mobile-layout-artifacts",
|
|
120
|
+
description: "Remove empty mobile container rows and unused mobile layout CSS",
|
|
121
|
+
type: "custom",
|
|
122
|
+
processor: (i) => {
|
|
123
|
+
let e = i;
|
|
124
|
+
return e = e.replace(
|
|
125
|
+
/<tr[^>]*class="ins-recommendation-mobile-row"[^>]*><\/tr>/g,
|
|
126
|
+
""
|
|
127
|
+
), /class="[^"]*ins-recommendation-mobile-container/.test(e) || (e = e.replace(
|
|
128
|
+
/\.ins-recommendation-mobile-container\s*\{\s*display\s*:\s*none\s*;?\s*\}/g,
|
|
129
|
+
""
|
|
130
|
+
), e = e.replace(
|
|
131
|
+
/@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
|
|
132
|
+
(p, c) => {
|
|
133
|
+
const n = c.match(/[^{}]+\{[^{}]*\}/g) || [], a = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
|
|
134
|
+
return n.every((d) => a.test(d)) ? "" : p;
|
|
135
|
+
}
|
|
136
|
+
)), e;
|
|
137
|
+
},
|
|
138
|
+
priority: 57
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: "deduplicate-inline-styles",
|
|
142
|
+
description: "Replace repeated inline styles with CSS class references within recommendation blocks",
|
|
143
|
+
type: "custom",
|
|
144
|
+
processor: (i) => {
|
|
145
|
+
const e = i.replace(
|
|
146
|
+
/<a\b[^>]*\bes-button\b[^>]*>/g,
|
|
147
|
+
(o) => o.replace(
|
|
148
|
+
/([;"]color:)([^;"]+)/g,
|
|
149
|
+
(r, t, u) => u.includes("!important") ? r : `${t}${u} !important`
|
|
150
|
+
)
|
|
151
|
+
), p = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, c = / style="([^"]*)"/g, n = /* @__PURE__ */ new Map();
|
|
152
|
+
let a = p.exec(e);
|
|
153
|
+
for (; a !== null; ) {
|
|
154
|
+
let o = c.exec(a[1]);
|
|
155
|
+
for (; o !== null; ) {
|
|
156
|
+
const [, r] = o;
|
|
157
|
+
n.set(r, (n.get(r) || 0) + 1), o = c.exec(a[1]);
|
|
158
|
+
}
|
|
159
|
+
c.lastIndex = 0, a = p.exec(e);
|
|
160
|
+
}
|
|
161
|
+
const s = /* @__PURE__ */ new Map(), d = [];
|
|
162
|
+
let _ = 0;
|
|
163
|
+
if (n.forEach((o, r) => {
|
|
164
|
+
if (o >= 6) {
|
|
165
|
+
const t = `rc${_++}`;
|
|
166
|
+
s.set(r, t), d.push(`.${t}{${r}}`);
|
|
167
|
+
}
|
|
168
|
+
}), s.size === 0) {
|
|
169
|
+
let o = e;
|
|
170
|
+
return o = o.replaceAll("<!--REC_START-->", ""), o = o.replaceAll("<!--REC_END-->", ""), o;
|
|
171
|
+
}
|
|
172
|
+
const A = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), I = (o, r) => `${o.slice(0, -1)} ${r}"`, S = /* @__PURE__ */ new Map();
|
|
173
|
+
s.forEach((o, r) => {
|
|
174
|
+
const t = A(r);
|
|
175
|
+
S.set(r, {
|
|
176
|
+
caseA: new RegExp(`(class="[^"]*")((?:[^>]*?)) style="${t}"`, "g"),
|
|
177
|
+
caseB: new RegExp(` style="${t}"((?:[^>]*?))(class="[^"]*")`, "g")
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
let m = e.replace("</style>", `${d.join("")}</style>`);
|
|
181
|
+
return m = m.replace(
|
|
182
|
+
/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
|
|
183
|
+
(o, r) => {
|
|
184
|
+
let t = r;
|
|
185
|
+
return s.forEach((u, f) => {
|
|
186
|
+
const g = S.get(f);
|
|
187
|
+
t = t.replace(
|
|
188
|
+
g.caseA,
|
|
189
|
+
(y, b, l) => I(b, u) + l
|
|
190
|
+
), t = t.replace(
|
|
191
|
+
g.caseB,
|
|
192
|
+
(y, b, l) => b + I(l, u)
|
|
193
|
+
), t = t.replaceAll(` style="${f}"`, ` class="${u}"`);
|
|
194
|
+
}), t;
|
|
195
|
+
}
|
|
196
|
+
), m = m.replaceAll("<!--REC_START-->", ""), m = m.replaceAll("<!--REC_END-->", ""), m;
|
|
197
|
+
},
|
|
198
|
+
priority: 58
|
|
85
199
|
}
|
|
86
200
|
];
|
|
87
201
|
export {
|
|
88
|
-
|
|
202
|
+
w as recommendationCompilerRules
|
|
89
203
|
};
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { useConfig as S } from "../../../composables/useConfig.js";
|
|
2
|
+
import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
|
|
3
|
+
function y(e, u, r, o, s = "") {
|
|
4
|
+
const n = `{{${s}${e}_${u}_${r}}}`, t = `{{${s}${e}_${u}_currency}}`;
|
|
4
5
|
return o === "before" ? `${t} ${n}` : `${n} ${t}`;
|
|
5
6
|
}
|
|
6
|
-
function p(e, u, r, o, n) {
|
|
7
|
+
function p(e, u, r, o, s, n) {
|
|
7
8
|
switch (u) {
|
|
8
9
|
case "productImage": {
|
|
9
10
|
const t = e.querySelector("img");
|
|
10
|
-
t && (t.setAttribute("src", `{{${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${r}_${o}_name}}`));
|
|
11
|
+
t && (t.setAttribute("src", `{{${n}${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${r}_${o}_name}}`));
|
|
11
12
|
const c = e.querySelector("a");
|
|
12
|
-
c && c.setAttribute("href", `{{${r}_${o}_url}}`);
|
|
13
|
+
c && c.setAttribute("href", `{{${n}${r}_${o}_url}}`);
|
|
13
14
|
break;
|
|
14
15
|
}
|
|
15
16
|
case "productName": {
|
|
16
17
|
const t = e.querySelector("p");
|
|
17
18
|
if (t) {
|
|
18
19
|
const c = t.querySelector("strong") || t;
|
|
19
|
-
c.textContent = `{{${r}_${o}_name}}`;
|
|
20
|
+
c.textContent = `{{${n}${r}_${o}_name}}`;
|
|
20
21
|
}
|
|
21
22
|
break;
|
|
22
23
|
}
|
|
@@ -24,7 +25,7 @@ function p(e, u, r, o, n) {
|
|
|
24
25
|
const t = e.querySelector("p");
|
|
25
26
|
if (t) {
|
|
26
27
|
const c = t.querySelector("strong") || t;
|
|
27
|
-
c.textContent =
|
|
28
|
+
c.textContent = y(r, o, "price", s, n);
|
|
28
29
|
}
|
|
29
30
|
break;
|
|
30
31
|
}
|
|
@@ -32,10 +33,11 @@ function p(e, u, r, o, n) {
|
|
|
32
33
|
const t = e.querySelector("p");
|
|
33
34
|
if (t) {
|
|
34
35
|
const c = t.querySelector("strong") || t;
|
|
35
|
-
c.textContent =
|
|
36
|
+
c.textContent = y(
|
|
36
37
|
r,
|
|
37
38
|
o,
|
|
38
39
|
"original_price",
|
|
40
|
+
s,
|
|
39
41
|
n
|
|
40
42
|
), t.setAttribute("product-attr", "discount");
|
|
41
43
|
}
|
|
@@ -43,13 +45,13 @@ function p(e, u, r, o, n) {
|
|
|
43
45
|
}
|
|
44
46
|
case "productButton": {
|
|
45
47
|
const t = e.querySelector("a");
|
|
46
|
-
t && t.setAttribute("href", `{{${r}_${o}_url}}`);
|
|
48
|
+
t && t.setAttribute("href", `{{${n}${r}_${o}_url}}`);
|
|
47
49
|
break;
|
|
48
50
|
}
|
|
49
51
|
case "productOmnibusPrice": {
|
|
50
52
|
const t = e.querySelector(".omnibus-price-value");
|
|
51
53
|
if (t) {
|
|
52
|
-
t.textContent = `{{${r}_${o}_omnibus_price}}`;
|
|
54
|
+
t.textContent = `{{${n}${r}_${o}_omnibus_price}}`;
|
|
53
55
|
const c = t.closest("p");
|
|
54
56
|
c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
|
|
55
57
|
}
|
|
@@ -58,7 +60,7 @@ function p(e, u, r, o, n) {
|
|
|
58
60
|
case "productOmnibusDiscount": {
|
|
59
61
|
const t = e.querySelector(".omnibus-discount-value");
|
|
60
62
|
if (t) {
|
|
61
|
-
t.textContent = `{{${r}_${o}_omnibus_discount}}`;
|
|
63
|
+
t.textContent = `{{${n}${r}_${o}_omnibus_discount}}`;
|
|
62
64
|
const c = t.closest("p");
|
|
63
65
|
c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
|
|
64
66
|
}
|
|
@@ -67,66 +69,67 @@ function p(e, u, r, o, n) {
|
|
|
67
69
|
default: {
|
|
68
70
|
const t = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
|
|
69
71
|
if (t) {
|
|
70
|
-
const c = t.getAttribute("product-attr"),
|
|
71
|
-
if (
|
|
72
|
-
const
|
|
73
|
-
|
|
72
|
+
const c = t.getAttribute("product-attr"), i = t.querySelector("p");
|
|
73
|
+
if (i) {
|
|
74
|
+
const a = i.querySelector("strong") || i;
|
|
75
|
+
a.textContent = `{{${n}${r}_${o}_${c}}}`;
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
break;
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
|
-
function
|
|
82
|
+
function d(e, u, r, o) {
|
|
81
83
|
e.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
|
|
82
|
-
n.querySelectorAll("[data-attribute-type]").forEach((
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
p(
|
|
86
|
-
}) : p(
|
|
84
|
+
n.querySelectorAll("[data-attribute-type]").forEach((i) => {
|
|
85
|
+
const a = i.getAttribute("data-attribute-type") || "", b = i.querySelectorAll(".attribute-cell");
|
|
86
|
+
b.length > 0 ? b.forEach((l) => {
|
|
87
|
+
p(l, a, u, t, r, o);
|
|
88
|
+
}) : p(i, a, u, t, r, o);
|
|
87
89
|
});
|
|
88
90
|
});
|
|
89
91
|
}
|
|
90
|
-
function
|
|
91
|
-
const
|
|
92
|
-
if (!
|
|
92
|
+
function q(e, u, r, o) {
|
|
93
|
+
const s = e.querySelectorAll(".recommendation-product-row");
|
|
94
|
+
if (!s.length)
|
|
93
95
|
return;
|
|
94
|
-
const [n] =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
p(
|
|
96
|
+
const [n] = s, t = n.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
97
|
+
s.forEach((i, a) => {
|
|
98
|
+
i.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
99
|
+
const m = l.getAttribute("data-attribute-type") || "";
|
|
100
|
+
l.querySelectorAll(".attribute-cell").forEach(($, f) => {
|
|
101
|
+
const A = a * c + f;
|
|
102
|
+
p($, m, u, A, r, o);
|
|
101
103
|
});
|
|
102
104
|
});
|
|
103
105
|
});
|
|
104
106
|
}
|
|
105
|
-
function
|
|
107
|
+
function g(e, u, r, o) {
|
|
106
108
|
e.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
|
|
107
|
-
|
|
109
|
+
q(n, u, r, o);
|
|
108
110
|
});
|
|
109
111
|
}
|
|
110
|
-
function
|
|
111
|
-
const
|
|
112
|
-
|
|
112
|
+
function h(e, u, r) {
|
|
113
|
+
const o = e.getAttribute("data-layout") || "grid", s = e.getAttribute("currency-alignment") || "after";
|
|
114
|
+
o === "list" ? d(e, u, s, r) : g(e, u, s, r);
|
|
113
115
|
}
|
|
114
|
-
function
|
|
116
|
+
function C(e, u) {
|
|
115
117
|
const r = e.match(/<!DOCTYPE[^>]*>/i);
|
|
116
118
|
return (r ? `${r[0]}
|
|
117
119
|
` : "") + u.documentElement.outerHTML;
|
|
118
120
|
}
|
|
119
|
-
function
|
|
121
|
+
function P(e) {
|
|
120
122
|
const u = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(u, "text/html"), o = r.querySelectorAll(".recommendation-block-v2");
|
|
121
123
|
if (!o.length)
|
|
122
124
|
return e;
|
|
123
|
-
const { buildCampaignUrl: n } =
|
|
124
|
-
return o.forEach((
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
const { buildCampaignUrl: s } = _(), { isFeatureEnabled: n } = S(), t = n("liquidSyntax") ? "reco_" : "";
|
|
126
|
+
return o.forEach((i) => {
|
|
127
|
+
var b, l;
|
|
128
|
+
const a = i.getAttribute("recommendation-id");
|
|
129
|
+
a && ((b = i.parentNode) == null || b.insertBefore(r.createComment("REC_START"), i), (l = i.parentNode) == null || l.insertBefore(r.createComment("REC_END"), i.nextSibling), s(a), h(i, a, t));
|
|
130
|
+
}), C(u, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
128
131
|
}
|
|
129
132
|
export {
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
y as formatPriceVariable,
|
|
134
|
+
P as prepareRecommendationBlocks
|
|
132
135
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const s = {
|
|
2
2
|
RECOMMENDATION_API_URL: "https://recommendationv2.api.useinsider.com"
|
|
3
|
-
}, i =
|
|
3
|
+
}, i = {
|
|
4
|
+
CLIENT_ID: "clientId"
|
|
5
|
+
}, u = [
|
|
4
6
|
{ id: 11, key: "similarViewed", name: "Viewed Together", path: "viewed-together" },
|
|
5
7
|
{ id: 12, key: "similarBought", name: "Purchased Together", path: "purchased-together" },
|
|
6
8
|
{ id: 13, key: "userBased", name: "User Based", path: "user-based" },
|
|
@@ -11,13 +13,13 @@ const s = {
|
|
|
11
13
|
{ id: 46, key: "mostValuableOfPartner", name: "Most Valuable Products", path: "most-valuable" },
|
|
12
14
|
{ id: 61, key: "mostPopular", name: "Most Popular Items", path: "most-popular" },
|
|
13
15
|
{ id: 62, key: "mostPurchased", name: "Top Sellers", path: "top-sellers" }
|
|
14
|
-
],
|
|
16
|
+
], l = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], c = [
|
|
15
17
|
{ text: "before the amount", value: "0" },
|
|
16
18
|
{ text: "after the amount", value: "1" }
|
|
17
|
-
],
|
|
19
|
+
], d = [
|
|
18
20
|
{ text: "dot(.)", value: "." },
|
|
19
21
|
{ text: "comma(,)", value: "," }
|
|
20
|
-
],
|
|
22
|
+
], p = [
|
|
21
23
|
{ text: "0", value: "0" },
|
|
22
24
|
{ text: "1", value: "1" },
|
|
23
25
|
{ text: "2", value: "2" },
|
|
@@ -46,7 +48,7 @@ const s = {
|
|
|
46
48
|
], n = [
|
|
47
49
|
{ text: "true", value: "==" },
|
|
48
50
|
{ text: "false", value: "!=" }
|
|
49
|
-
],
|
|
51
|
+
], m = (t) => {
|
|
50
52
|
if (!t)
|
|
51
53
|
return e;
|
|
52
54
|
switch (t) {
|
|
@@ -65,13 +67,14 @@ const s = {
|
|
|
65
67
|
}
|
|
66
68
|
};
|
|
67
69
|
export {
|
|
68
|
-
|
|
69
|
-
i as
|
|
70
|
+
l as PriceAttributes,
|
|
71
|
+
i as QUERY_PARAMS,
|
|
72
|
+
u as RecommendationFeedSourceMaps,
|
|
70
73
|
s as URLS,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
p as currencyDecimalCounts,
|
|
75
|
+
c as currencyLocationMaps,
|
|
76
|
+
d as currencyOperators,
|
|
77
|
+
m as getOperatorOptions,
|
|
75
78
|
a as operatorOptionsForArrayOfStrings,
|
|
76
79
|
n as operatorOptionsForBooleans,
|
|
77
80
|
o as operatorOptionsForDates,
|
|
@@ -28,8 +28,8 @@ const e = 20, s = 320, t = "vertical", m = {
|
|
|
28
28
|
ATTRIBUTE_PARAGRAPH: /<p[^>]*?product-attr="(discount|omnibus_discount|omnibus_price)"[^>]*>[\S\s]*?<\/p>/gm,
|
|
29
29
|
ATTRIBUTE_PARAGRAPH_START_TAG: /<p[^>]*?product-attr="(discount|omnibus_discount|omnibus_price)"[^>]*>/gm,
|
|
30
30
|
COMPOSITION: /composition="true"/gm,
|
|
31
|
-
CUSTOM_FIELD: /{{[0-9]+_[0-8]_(discount|omnibus_discount|omnibus_price)}}/gm,
|
|
32
|
-
CUSTOM_FIELD_INDEXES_PART: /{{[0-9]+_[0-8]_/gm,
|
|
31
|
+
CUSTOM_FIELD: /{{(?:reco_)?[0-9]+_[0-8]_(discount|omnibus_discount|omnibus_price)}}/gm,
|
|
32
|
+
CUSTOM_FIELD_INDEXES_PART: /{{(?:reco_)?[0-9]+_[0-8]_/gm,
|
|
33
33
|
CUSTOM_FIELD_NAME_PART: /_(discount|omnibus_discount|omnibus_price)}}/gm
|
|
34
34
|
}, n = {
|
|
35
35
|
PARAGRAPH_END_TAG: "</p>"
|