@useinsider/guido 3.24.0-beta.88c24c1 → 3.24.0-beta.8e9f4e2

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.
Files changed (39) hide show
  1. package/README.md +6 -2
  2. package/dist/@types/config/schemas.js +9 -11
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +1 -1
  5. package/dist/composables/useActionsApi.js +2 -2
  6. package/dist/composables/useEditorTrackingIds.js +49 -0
  7. package/dist/composables/useHtmlCompiler.js +2 -0
  8. package/dist/composables/useSave.js +52 -57
  9. package/dist/composables/useSaveValidation.js +110 -118
  10. package/dist/composables/useStripo.js +70 -70
  11. package/dist/composables/validators/useUnsubscribeBlockValidator.js +33 -48
  12. package/dist/config/compiler/htmlCompilerRules.js +14 -6
  13. package/dist/config/migrator/recommendation/inferLegacyConfig.js +133 -0
  14. package/dist/config/migrator/recommendationMigrator.js +69 -63
  15. package/dist/enums/save-validation.js +1 -1
  16. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
  17. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
  18. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
  19. package/dist/guido.css +1 -1
  20. package/dist/package.json.js +4 -4
  21. package/dist/services/templateLibraryApi.js +39 -36
  22. package/dist/src/@types/config/schemas.d.ts +0 -4
  23. package/dist/src/composables/useConfig.d.ts +0 -2
  24. package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
  25. package/dist/src/composables/useSaveValidation.d.ts +1 -1
  26. package/dist/src/composables/useStripo.d.ts +1 -1
  27. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +0 -4
  28. package/dist/src/config/migrator/recommendation/inferLegacyConfig.d.ts +6 -0
  29. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +1 -1
  30. package/dist/src/config/migrator/recommendationMigrator.d.ts +1 -5
  31. package/dist/src/enums/save-validation.d.ts +1 -2
  32. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  33. package/dist/src/stores/config.d.ts +0 -20
  34. package/dist/src/utils/linkTrackingIds.d.ts +19 -0
  35. package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
  36. package/dist/utils/linkTrackingIds.js +82 -48
  37. package/dist/utils/templatePreparation.js +30 -33
  38. package/dist/utils/trimHrefWhitespace.js +10 -0
  39. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
- import { ToasterTypeOptions as i } from "../../enums/toaster.js";
2
- import { MERGE_TAGS as p, PAGE_TYPES as u } from "../../enums/unsubscribe.js";
3
- import { UNSUBSCRIBE_BLOCK_SELECTOR as l, DATA_ATTRIBUTES as c } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
4
- import { useToaster as E } from "../useToaster.js";
5
- import { useTranslations as b } from "../useTranslations.js";
1
+ import { ToasterTypeOptions as c } from "../../enums/toaster.js";
2
+ import { PAGE_TYPES as u } from "../../enums/unsubscribe.js";
3
+ import { UNSUBSCRIBE_BLOCK_SELECTOR as i, DATA_ATTRIBUTES as a } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
4
+ import { useToaster as p } from "../useToaster.js";
5
+ import { useTranslations as l } from "../useTranslations.js";
6
6
  const T = [
7
7
  {
8
8
  pageType: u.GLOBAL_UNSUBSCRIBE,
@@ -12,52 +12,37 @@ const T = [
12
12
  pageType: u.SUBSCRIPTION_PREFERENCE_CENTER,
13
13
  messageKey: "unsubscription-preference.duplicate-pref-center"
14
14
  }
15
- ], g = "unsubscription-preference.duplicate-both", _ = "unsubscription-preference.select-page-to-continue", m = "newsletter.sfmc-remove-unsubscribe-link", f = Object.values(p).map((e) => e.slice(2, -2).replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), U = new RegExp(
16
- `{{\\s*(?:${f})\\s*}}|(?:%|%25)(?:asm_[a-z_]+_raw_url|unsub)(?:%|%25)`,
17
- "i"
18
- );
19
- function S(e) {
20
- return U.test(e);
15
+ ], g = "unsubscription-preference.duplicate-both", E = "unsubscription-preference.select-page-to-continue";
16
+ function m(r) {
17
+ const s = new DOMParser().parseFromString(r, "text/html"), t = /* @__PURE__ */ new Map();
18
+ return s.querySelectorAll(i).forEach((n) => {
19
+ const e = Number(n.getAttribute(a.PAGE_TYPE));
20
+ t.set(e, (t.get(e) ?? 0) + 1);
21
+ }), T.filter((n) => (t.get(n.pageType) ?? 0) > 1);
21
22
  }
22
- function A(e) {
23
- const t = new DOMParser().parseFromString(e, "text/html"), s = /* @__PURE__ */ new Map();
24
- return t.querySelectorAll(l).forEach((r) => {
25
- const n = Number(r.getAttribute(c.PAGE_TYPE));
26
- s.set(n, (s.get(n) ?? 0) + 1);
27
- }), T.filter((r) => (s.get(r.pageType) ?? 0) > 1);
28
- }
29
- function B(e) {
30
- const t = new DOMParser().parseFromString(e, "text/html");
31
- return Array.from(t.querySelectorAll(l)).filter((s) => {
32
- const r = s.getAttribute(c.PAGE_TYPE), n = s.getAttribute(c.PAGE_LIST);
33
- return !r || !n;
23
+ function b(r) {
24
+ const s = new DOMParser().parseFromString(r, "text/html");
25
+ return Array.from(s.querySelectorAll(i)).filter((t) => {
26
+ const n = t.getAttribute(a.PAGE_TYPE), e = t.getAttribute(a.PAGE_LIST);
27
+ return !n || !e;
34
28
  }).length;
35
29
  }
36
- const I = () => {
37
- const { showToaster: e } = E(), t = b();
38
- return {
39
- validateUnsubscribeBlockUniqueness: (o) => {
40
- const a = A(o);
41
- return a.length ? (e({
42
- type: i.Error,
43
- message: t(a.length > 1 ? g : a[0].messageKey)
44
- }), !1) : !0;
45
- },
46
- validateUnsubscribeBlockHasTemplate: (o) => B(o) === 0 ? !0 : (e({
47
- type: i.Warning,
48
- message: t(_)
49
- }), !1),
50
- validateNoInsiderUnsubscribeCode: (o, a = !1) => S(o) ? (a || e({
51
- type: i.Warning,
52
- message: t(m)
53
- }), !1) : !0
54
- };
30
+ const y = () => {
31
+ const { showToaster: r } = p(), s = l();
32
+ return { validateUnsubscribeBlockUniqueness: (e) => {
33
+ const o = m(e);
34
+ return o.length ? (r({
35
+ type: c.Error,
36
+ message: s(o.length > 1 ? g : o[0].messageKey)
37
+ }), !1) : !0;
38
+ }, validateUnsubscribeBlockHasTemplate: (e) => b(e) === 0 ? !0 : (r({
39
+ type: c.Warning,
40
+ message: s(E)
41
+ }), !1) };
55
42
  };
56
43
  export {
57
- _ as EMPTY_BLOCK_KEY,
58
- m as EXTERNALLY_MANAGED_UNSUBSCRIBE_KEY,
59
- B as countUnsubBlocksWithoutPage,
60
- A as findDuplicateUnsubPageTypes,
61
- S as hasInsiderUnsubscribeCode,
62
- I as useUnsubscribeBlockValidator
44
+ E as EMPTY_BLOCK_KEY,
45
+ b as countUnsubBlocksWithoutPage,
46
+ m as findDuplicateUnsubPageTypes,
47
+ y as useUnsubscribeBlockValidator
63
48
  };
@@ -1,5 +1,6 @@
1
- import { stripFontTags as p } from "../../utils/stripFontTags.js";
2
- const d = [
1
+ import { stripFontTags as c } from "../../utils/stripFontTags.js";
2
+ import { trimHrefWhitespace as l } from "../../utils/trimHrefWhitespace.js";
3
+ const f = [
3
4
  {
4
5
  id: "fix-url-encoding-start",
5
6
  description: "Replace {%22 with %7B%22 to fix URL encoding",
@@ -58,9 +59,16 @@ const d = [
58
59
  id: "strip-font-tags",
59
60
  description: 'Unwrap browser-translate-injected <font dir="auto"> tags, keeping inner content; other <font> elements are left intact.',
60
61
  type: "custom",
61
- processor: (e) => p(e),
62
+ processor: (e) => c(e),
62
63
  priority: 15
63
64
  },
65
+ {
66
+ id: "trim-href-whitespace",
67
+ description: "Trim leading/trailing whitespace and &nbsp; from every href value",
68
+ type: "custom",
69
+ processor: (e) => l(e),
70
+ priority: 16
71
+ },
64
72
  {
65
73
  id: "remove-apty-iframe",
66
74
  description: "Cleanup Apty Iframe Code",
@@ -157,8 +165,8 @@ const d = [
157
165
  processor: (e) => {
158
166
  const t = (i) => i.toString(16).padStart(2, "0");
159
167
  return e.replace(/rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/gi, (i, o, n, r) => {
160
- const [s, a, c] = [Number(o), Number(n), Number(r)];
161
- return s > 255 || a > 255 || c > 255 ? i : `#${t(s)}${t(a)}${t(c)}`;
168
+ const [s, a, p] = [Number(o), Number(n), Number(r)];
169
+ return s > 255 || a > 255 || p > 255 ? i : `#${t(s)}${t(a)}${t(p)}`;
162
170
  }).replace(/#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3\b/gi, "#$1$2$3");
163
171
  },
164
172
  priority: 44
@@ -200,5 +208,5 @@ const d = [
200
208
  }
201
209
  ];
202
210
  export {
203
- d as defaultHtmlCompilerRules
211
+ f as defaultHtmlCompilerRules
204
212
  };
@@ -0,0 +1,133 @@
1
+ import { MAX_PRODUCTS_PER_ROW as _ } from "../../../extensions/Blocks/Recommendation/constants/layout.js";
2
+ const T = "td.product-card", x = '[class*="ext-product-"]', d = ".ext-ins-attr p[product-attr]", y = ".ext-ins-attr", S = ["font-family", "font-size", "font-weight", "font-style"], l = [
3
+ ["p_image", ".ext-product-image"],
4
+ ["p_name", ".ext-product-name"],
5
+ ["p_price", ".ext-product-price"],
6
+ ["p_original_price", ".ext-product-original-price"],
7
+ ["p_omnibus_price", ".ext-product-omnibus-price", !0],
8
+ ["p_omnibus_discount", ".ext-product-omnibus-discount", !0],
9
+ ["p_button", ".ext-product-button"]
10
+ ], a = l.map(([, t]) => t).join(", ");
11
+ function s(t, e) {
12
+ const n = new RegExp(`(?:^|;)\\s*${e}\\s*:\\s*([^;]+)`, "i"), r = ((t == null ? void 0 : t.getAttribute("style")) ?? "").match(n);
13
+ return (r == null ? void 0 : r[1].trim()) || void 0;
14
+ }
15
+ function p(t) {
16
+ return /^none\b/.test(s(t, "display") ?? "");
17
+ }
18
+ function h(t) {
19
+ return p(t) || p(t.closest("tr"));
20
+ }
21
+ function f(t) {
22
+ const e = {};
23
+ return S.forEach((n) => {
24
+ const r = s(t, n);
25
+ r && (e[n] = r);
26
+ }), Object.keys(e).length > 0 ? e : void 0;
27
+ }
28
+ function g(t) {
29
+ return Object.keys(t).length > 0 ? t : void 0;
30
+ }
31
+ function m(t) {
32
+ const e = t.querySelector("p") ?? t, n = f(e), r = s(e, "color"), i = t.getAttribute("align") ?? s(e, "text-align"), o = s(e, "line-height");
33
+ return g({
34
+ ...n ? { textStyle: n } : {},
35
+ ...r ? { textColor: { color: r } } : {},
36
+ ...i ? { textAlign: { align: i } } : {},
37
+ ...o ? { textLineSpacing: { lineSpacing: o } } : {}
38
+ });
39
+ }
40
+ function A(t) {
41
+ var u;
42
+ const e = t.querySelector("a") ?? t, n = (u = e.textContent) == null ? void 0 : u.trim(), r = s(e, "background-color") ?? s(e, "background"), i = s(e, "color"), o = f(e), c = t.getAttribute("align");
43
+ return g({
44
+ ...n ? { buttonText: { text: n } } : {},
45
+ ...r ? { buttonColor: { color: r } } : {},
46
+ ...i ? { textButtonColor: { color: i } } : {},
47
+ ...o ? { buttonStyle: o } : {},
48
+ ...c ? { buttonAlign: { align: c } } : {}
49
+ });
50
+ }
51
+ function C(t) {
52
+ const e = t.querySelector("img"), n = Number(e == null ? void 0 : e.getAttribute("width")), r = Number(e == null ? void 0 : e.getAttribute("height")), i = { ...n > 0 ? { width: n } : {}, ...r > 0 ? { height: r } : {} };
53
+ return Object.keys(i).length > 0 ? { imageSize: i } : void 0;
54
+ }
55
+ function R(t, e) {
56
+ switch (t) {
57
+ case "p_image":
58
+ return C(e);
59
+ case "p_button":
60
+ return A(e);
61
+ default:
62
+ return m(e);
63
+ }
64
+ }
65
+ function L(t, e) {
66
+ const n = Array.from(t.querySelectorAll(`[class*="show-recommendation-${e}-"]`));
67
+ return n.length > 0 ? n : Array.from(t.querySelectorAll(T));
68
+ }
69
+ function w(t, e) {
70
+ const n = (o) => e.filter((c) => o.contains(c)).length;
71
+ let r = e[0].parentElement;
72
+ for (; r && r !== t && n(r) < 2; )
73
+ r = r.parentElement;
74
+ if (!r || r === t)
75
+ return e.length === 1 ? 1 : void 0;
76
+ const i = r.tagName === "TBODY" || r.tagName === "TABLE" ? 1 : n(r);
77
+ return Math.min(i, _);
78
+ }
79
+ function v(t) {
80
+ const e = Array.from(t.querySelectorAll(x)).filter((n) => !n.matches(a) && !n.closest(a) && !n.querySelector(a)).flatMap((n) => Array.from(n.classList).filter((r) => r.startsWith("ext-product-")));
81
+ return [...new Set(e)];
82
+ }
83
+ function O(t, e, n) {
84
+ const r = t.closest(y) ?? t, i = m(r);
85
+ return {
86
+ variable: `p_attribute_${e}`,
87
+ variableType: "p_attribute",
88
+ value: t.getAttribute("product-attr") ?? "",
89
+ positionIdx: n,
90
+ hidden: h(r),
91
+ ...i ? { theme: i } : {}
92
+ };
93
+ }
94
+ function N(t) {
95
+ const e = /* @__PURE__ */ new Set(), n = [];
96
+ let r = 0;
97
+ t.querySelectorAll(`${a}, ${d}`).forEach((o) => {
98
+ if (o.matches(d)) {
99
+ n.push(O(o, r, n.length)), r += 1;
100
+ return;
101
+ }
102
+ const c = l.find(
103
+ ([b, E]) => !e.has(b) && o.matches(E)
104
+ );
105
+ if (!c)
106
+ return;
107
+ const u = R(c[0], o);
108
+ e.add(c[0]), n.push({
109
+ variable: c[0],
110
+ positionIdx: n.length,
111
+ hidden: h(o),
112
+ ...u ? { theme: u } : {}
113
+ });
114
+ });
115
+ const i = l.filter(([o, , c]) => !c && !e.has(o)).map(([o]) => ({ variable: o, hidden: !0 }));
116
+ return [...n, ...i];
117
+ }
118
+ function q(t, e) {
119
+ const n = L(t, e);
120
+ if (n.length === 0)
121
+ return null;
122
+ const r = v(n[0]);
123
+ return r.length > 0 ? (console.warn(
124
+ `[RecommendationMigrator] Block id=${e} — legacy card cells the rebuild cannot map: ${r.join(", ")}`
125
+ ), null) : {
126
+ totalCount: n.length,
127
+ rowCount: w(t, n),
128
+ composition: { variables: N(n[0]) }
129
+ };
130
+ }
131
+ export {
132
+ q as inferLegacyConfig
133
+ };
@@ -1,59 +1,63 @@
1
- import { BlockId as b } from "../../enums/block.js";
2
- import { DEFAULT_NODE_CONFIG as C } from "../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
3
- import { ATTR_RECOMMENDATION_TITLE as f } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
4
- import { useTemplateStore as M } from "../../stores/template.js";
5
- import { mapComposition as x } from "./recommendation/compositionMapper.js";
6
- import { isPriceOnNextLine as R, extractCurrencyFromBlock as h, isOldPriceFirst as S, withRenderedTextTheme as w, extractTitleText as E, hasEmptyTitle as L, hasVisibleTitle as B, extractCardBgColor as P, isPartnerManagedBlock as A, extractRenderedBlockPadding as H } from "./recommendation/extractors.js";
7
- import { buildBlockHtml as N } from "./recommendation/htmlBuilder.js";
8
- import { parseRecommendationId as O, parseLegacyConfig as F } from "./recommendation/parseLegacyConfig.js";
9
- import { mapSettings as I } from "./recommendation/settingsMapper.js";
10
- import { mapBlockPadding as _ } from "./recommendation/themeMapper.js";
11
- const k = 'td[esd-dev-product-config][class*="ins-recommendation-v3-block-"]:not(.recommendation-block-v2), td.product-block[esd-handler-name*="EmailRecommendationV3"][esd-dev-product-config]:not(.recommendation-block-v2)';
12
- function $(c, e, m) {
13
- var l, g, p;
14
- const t = O(e);
1
+ import { BlockId as R } from "../../enums/block.js";
2
+ import { DEFAULT_NODE_CONFIG as h } from "../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
3
+ import { ATTR_RECOMMENDATION_TITLE as u } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
4
+ import { useTemplateStore as x } from "../../stores/template.js";
5
+ import { mapComposition as b } from "./recommendation/compositionMapper.js";
6
+ import { isPriceOnNextLine as L, extractCurrencyFromBlock as A, isOldPriceFirst as E, withRenderedTextTheme as B, extractTitleText as O, hasEmptyTitle as S, hasVisibleTitle as w, extractCardBgColor as N, isPartnerManagedBlock as P, extractRenderedBlockPadding as H } from "./recommendation/extractors.js";
7
+ import { buildBlockHtml as I } from "./recommendation/htmlBuilder.js";
8
+ import { inferLegacyConfig as _ } from "./recommendation/inferLegacyConfig.js";
9
+ import { parseRecommendationId as F, parseLegacyConfig as $ } from "./recommendation/parseLegacyConfig.js";
10
+ import { mapSettings as D } from "./recommendation/settingsMapper.js";
11
+ import { mapBlockPadding as G } from "./recommendation/themeMapper.js";
12
+ const T = ":not(.recommendation-block-v2):not([esd-ext-config])", k = `td[class*="ins-recommendation-v3-block-"]${T}, td.product-block[esd-handler-name*="EmailRecommendationV3"]${T}`, U = "esd-dev-product-config";
13
+ function V(c, e, m) {
14
+ var p, g, f;
15
+ const t = F(e);
15
16
  if (t === null)
16
17
  return console.warn(
17
18
  "[RecommendationMigrator] Skipping block — missing/invalid `ins-recommendation-v3-campaign-id`"
18
19
  ), !1;
19
- const r = F(e);
20
- if (!r)
20
+ const s = e.hasAttribute(U), a = s ? $(e) : _(e, t);
21
+ if (!a)
21
22
  return console.warn(
22
- `[RecommendationMigrator] Aborting block id=${t} — \`esd-dev-product-config\` missing or unable to be parsed`
23
+ `[RecommendationMigrator] Aborting block id=${t} — \`esd-dev-product-config\` empty or unparsable, or the rendered markup could not be inferred`
23
24
  ), !1;
24
- const o = m[String(t)] ?? {}, n = {
25
- ...o,
26
- currencySettings: o.currencySettings ?? h(e),
27
- isPriceMovedToNextLine: o.isPriceMovedToNextLine ?? R(e)
28
- }, a = I(n, r, t), i = x(
29
- w((l = r.composition) == null ? void 0 : l.variables, e),
30
- { oldPriceFirst: S(e) }
31
- ), u = E(e);
32
- L(e) ? i.visibility[f] = !1 : i.titleVariable || (i.visibility[f] = B(e));
33
- const y = P(e), T = {
34
- ...a,
25
+ s || console.info(
26
+ `[RecommendationMigrator] Block id=${t} has no \`esd-dev-product-config\` — rebuilt from its rendered markup`
27
+ );
28
+ const n = m[String(t)] ?? {}, r = {
29
+ ...n,
30
+ currencySettings: n.currencySettings ?? A(e),
31
+ isPriceMovedToNextLine: n.isPriceMovedToNextLine ?? L(e)
32
+ }, i = D(r, a, t), o = b(
33
+ B((p = a.composition) == null ? void 0 : p.variables, e),
34
+ { oldPriceFirst: E(e) }
35
+ ), y = O(e);
36
+ S(e) ? o.visibility[u] = !1 : o.titleVariable || (o.visibility[u] = w(e));
37
+ const C = N(e), v = {
38
+ ...i,
35
39
  strategyId: "",
36
- composition: i.composition,
37
- visibility: i.visibility,
38
- previousTitleHtml: C.previousTitleHtml,
39
- textTrimming: i.anyTextTrimming
40
- }, s = A(e), v = `
40
+ composition: o.composition,
41
+ visibility: o.visibility,
42
+ previousTitleHtml: h.previousTitleHtml,
43
+ textTrimming: o.anyTextTrimming
44
+ }, d = P(e), M = `
41
45
  <table>
42
46
  <tbody>
43
47
  <tr>
44
48
  <td class="esd-structure" align="left">
45
49
  <table width="100%" cellpadding="0" cellspacing="0">
46
50
  <tbody>
47
- <tr>${N({
48
- nodeConfig: T,
49
- composition: i,
50
- cardBg: y,
51
- titleText: u,
51
+ <tr>${I({
52
+ nodeConfig: v,
53
+ composition: o,
54
+ cardBg: C,
55
+ titleText: y,
52
56
  legacyId: e.getAttribute("id") ?? void 0,
53
57
  legacyBgColor: e.getAttribute("bgcolor") ?? void 0,
54
- preserveInnerHtml: s ? e.innerHTML : void 0,
55
- skipCompile: s,
56
- blockPadding: _(((p = (g = r.theme) == null ? void 0 : g.blockPadding) == null ? void 0 : p.desktop) ?? H(e))
58
+ preserveInnerHtml: d ? e.innerHTML : void 0,
59
+ skipCompile: d,
60
+ blockPadding: G(((f = (g = a.theme) == null ? void 0 : g.blockPadding) == null ? void 0 : f.desktop) ?? H(e))
57
61
  })}</tr>
58
62
  </tbody>
59
63
  </table>
@@ -61,40 +65,42 @@ function $(c, e, m) {
61
65
  </tr>
62
66
  </tbody>
63
67
  </table>
64
- `, d = c.parseFromString(v, "text/html").querySelector("td.esd-structure");
65
- return !d || !e.parentNode ? (console.warn(
68
+ `, l = c.parseFromString(M, "text/html").querySelector("td.esd-structure");
69
+ return !l || !e.parentNode ? (console.warn(
66
70
  `[RecommendationMigrator] Aborting block id=${t} — failed to construct new HTML element`
67
- ), !1) : (e.parentNode.replaceChild(d, e), !0);
71
+ ), !1) : (e.parentNode.replaceChild(l, e), !0);
68
72
  }
69
- function X(c, e = {}) {
73
+ function oe(c, e = {}) {
70
74
  const m = new DOMParser();
71
75
  let t;
72
76
  try {
73
77
  t = m.parseFromString(c, "text/html");
74
- } catch (n) {
75
- return console.error("[RecommendationMigrator] Failed to parse template:", n), c;
78
+ } catch (r) {
79
+ return console.error("[RecommendationMigrator] Failed to parse template:", r), c;
76
80
  }
77
- const r = Array.from(t.querySelectorAll(k));
81
+ const s = Array.from(t.querySelectorAll(k)), a = s.filter((r) => {
82
+ var i;
83
+ return !((i = r.parentElement) != null && i.closest(".recommendation-block-v2")) && !s.some((o) => o !== r && o.contains(r));
84
+ });
85
+ let n = 0;
86
+ a.forEach((r) => {
87
+ try {
88
+ V(m, r, e) && (n += 1);
89
+ } catch (i) {
90
+ console.error("[RecommendationMigrator] Unexpected error migrating block:", i);
91
+ }
92
+ });
78
93
  try {
79
- M().$patch((a) => {
80
- a.migrations = {
81
- ...a.migrations,
82
- [b.Recommendation]: r.length
94
+ x().$patch((i) => {
95
+ i.migrations = {
96
+ ...i.migrations,
97
+ [R.Recommendation]: n
83
98
  };
84
99
  });
85
100
  } catch {
86
101
  }
87
- if (r.length === 0)
88
- return c;
89
- let o = 0;
90
- return r.forEach((n) => {
91
- try {
92
- $(m, n, e) && (o += 1);
93
- } catch (a) {
94
- console.error("[RecommendationMigrator] Unexpected error migrating block:", a);
95
- }
96
- }), o > 0 && console.info(`[RecommendationMigrator] Migrated ${o} legacy Recommendation block(s)`), t.documentElement.outerHTML;
102
+ return n === 0 ? c : (console.info(`[RecommendationMigrator] Migrated ${n} legacy Recommendation block(s)`), t.documentElement.outerHTML);
97
103
  }
98
104
  export {
99
- X as migrateRecommendation
105
+ oe as migrateRecommendation
100
106
  };
@@ -1,4 +1,4 @@
1
- var n = /* @__PURE__ */ ((s) => (s.CouponTagModified = "coupon-tag-modified", s.DuplicateUnsubBlock = "duplicate-unsub-block", s.UnsubBlockMissingTemplate = "unsub-block-missing-template", s.LiquidSyntax = "liquid-syntax", s.InvalidLinks = "invalid-links", s.LinkCheckInProgress = "link-check-in-progress", s.CustomFieldScript = "custom-field-script", s.EmptyHtml = "empty-html", s.MismatchedBraces = "mismatched-braces", s.InvalidDynamicTag = "invalid-dynamic-tag", s.InvalidCustomField = "invalid-custom-field", s.ConditionsSyntax = "conditions-syntax", s.WrongEqualityOperator = "wrong-equality-operator", s.MissingIfEndif = "missing-if-endif", s.ConditionTagSpacing = "condition-tag-spacing", s.BracesInsideIfTag = "braces-inside-if-tag", s.RecommendationRequiredFields = "recommendation-required-fields", s.RecommendationFilters = "recommendation-filters", s.InvalidImageType = "invalid-image-type", s.CheckboxUnsubGroup = "checkbox-unsub-group", s.RadioButtonUnsubGroup = "radio-button-unsub-group", s.ExternallyManagedUnsubscribe = "externally-managed-unsubscribe", s))(n || {});
1
+ var n = /* @__PURE__ */ ((s) => (s.CouponTagModified = "coupon-tag-modified", s.DuplicateUnsubBlock = "duplicate-unsub-block", s.UnsubBlockMissingTemplate = "unsub-block-missing-template", s.LiquidSyntax = "liquid-syntax", s.InvalidLinks = "invalid-links", s.LinkCheckInProgress = "link-check-in-progress", s.CustomFieldScript = "custom-field-script", s.EmptyHtml = "empty-html", s.MismatchedBraces = "mismatched-braces", s.InvalidDynamicTag = "invalid-dynamic-tag", s.InvalidCustomField = "invalid-custom-field", s.ConditionsSyntax = "conditions-syntax", s.WrongEqualityOperator = "wrong-equality-operator", s.MissingIfEndif = "missing-if-endif", s.ConditionTagSpacing = "condition-tag-spacing", s.BracesInsideIfTag = "braces-inside-if-tag", s.RecommendationRequiredFields = "recommendation-required-fields", s.RecommendationFilters = "recommendation-filters", s.InvalidImageType = "invalid-image-type", s.CheckboxUnsubGroup = "checkbox-unsub-group", s.RadioButtonUnsubGroup = "radio-button-unsub-group", s))(n || {});
2
2
  export {
3
3
  n as SaveValidationRule
4
4
  };
@@ -17,9 +17,9 @@ import { CurrencyControl as U } from "./currency.js";
17
17
  import { CURRENCY_CONTROL_ID as Ie } from "./currency.js";
18
18
  import { FiltersControl as v } from "./filters.js";
19
19
  import { FILTERS_CONTROL_ID as ke } from "./filters.js";
20
- import { LayoutOrientationControl as A } from "./layoutOrientation.js";
20
+ import { LayoutOrientationControl as w } from "./layoutOrientation.js";
21
21
  import { LAYOUT_ORIENTATION_CONTROL_ID as Oe } from "./layoutOrientation.js";
22
- import { LocaleControl as w } from "./locale.js";
22
+ import { LocaleControl as A } from "./locale.js";
23
23
  import { LOCALE_CONTROL_ID as Be } from "./locale.js";
24
24
  import { PricePlacementControl as V } from "./pricePlacement.js";
25
25
  import { PRICE_PLACEMENT_CONTROL_ID as Le } from "./pricePlacement.js";
@@ -28,7 +28,7 @@ import { PRODUCT_COUNT_CONTROL_ID as Ee } from "./productCount.js";
28
28
  import { ProductLayoutControl as x } from "./productLayout.js";
29
29
  import { PRODUCT_LAYOUT_CONTROL_ID as ve } from "./productLayout.js";
30
30
  import { ShuffleControl as M } from "./shuffle.js";
31
- import { SHUFFLE_CONTROL_ID as we } from "./shuffle.js";
31
+ import { SHUFFLE_CONTROL_ID as Ae } from "./shuffle.js";
32
32
  import { StrategyControl as G } from "./strategy.js";
33
33
  import { STRATEGY_CONTROL_ID as We } from "./strategy.js";
34
34
  import { setCurrencyAttributes as $, getBlockElement as z, isPartnerManagedBlock as H, updateProductContentInPlace as Y, regenerateProductRowsWithStyles as j } from "./utils.js";
@@ -128,7 +128,7 @@ class _e extends I {
128
128
  return this.rrsEnabled = f().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
129
129
  var o;
130
130
  return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
131
- }), this.algorithmControl = new E(), this.localeControl = new w(), this.currencyControl = new U(), this.productCountControl = new W(), this.productLayoutControl = new x(), this.filtersControl = new v(), this.shuffleControl = new M(), this.pricePlacementControl = new V(), this.layoutOrientationControl = new A(), this.strategyControl = this.rrsEnabled ? new G() : null, this._subControls.forEach((t) => {
131
+ }), this.algorithmControl = new E(), this.localeControl = new A(), this.currencyControl = new U(), this.productCountControl = new W(), this.productLayoutControl = new x(), this.filtersControl = new v(), this.shuffleControl = new M(), this.pricePlacementControl = new V(), this.layoutOrientationControl = new w(), this.strategyControl = this.rrsEnabled ? new G() : null, this._subControls.forEach((t) => {
132
132
  t && (t.api = this.api);
133
133
  }), `
134
134
  <div class="recommendation-controls-container">
@@ -452,7 +452,9 @@ class _e extends I {
452
452
  e,
453
453
  this._getNodeConfigUpdates(n.recommendationConfigs),
454
454
  h
455
- ) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (i || o) && this._refreshOutsidePanel(e, i);
455
+ ) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e });
456
+ const s = o && n.drawnProducts !== n.recommendationProducts;
457
+ (i || s) && this._refreshOutsidePanel(e, i);
456
458
  } catch (n) {
457
459
  console.error("[recommendation] finishing the block outside the panel failed", n);
458
460
  }
@@ -552,8 +554,8 @@ export {
552
554
  v as FiltersControl,
553
555
  Oe as LAYOUT_ORIENTATION_CONTROL_ID,
554
556
  Be as LOCALE_CONTROL_ID,
555
- A as LayoutOrientationControl,
556
- w as LocaleControl,
557
+ w as LayoutOrientationControl,
558
+ A as LocaleControl,
557
559
  Le as PRICE_PLACEMENT_CONTROL_ID,
558
560
  Ee as PRODUCT_COUNT_CONTROL_ID,
559
561
  ve as PRODUCT_LAYOUT_CONTROL_ID,
@@ -561,7 +563,7 @@ export {
561
563
  W as ProductCountControl,
562
564
  x as ProductLayoutControl,
563
565
  _e as RecommendationBlockControl,
564
- we as SHUFFLE_CONTROL_ID,
566
+ Ae as SHUFFLE_CONTROL_ID,
565
567
  We as STRATEGY_CONTROL_ID,
566
568
  M as ShuffleControl,
567
569
  G as StrategyControl,