@useinsider/guido 3.4.1-beta.8f6f02b → 3.4.1-beta.a125d94

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,109 +1,109 @@
1
- var x = Object.defineProperty;
2
- var T = (l, e, t) => e in l ? x(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
- var b = (l, e, t) => T(l, typeof e != "symbol" ? e + "" : e, t);
4
- import S from "../../extensions/Blocks/RadioButton/template.js";
5
- class B {
1
+ var S = Object.defineProperty;
2
+ var I = (p, t, e) => t in p ? S(p, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : p[t] = e;
3
+ var y = (p, t, e) => I(p, typeof t != "symbol" ? t + "" : t, e);
4
+ import R from "../../extensions/Blocks/RadioButton/template.js";
5
+ const L = /font-weight\s*:\s*[^;]*;?/gi, _ = /font-style\s*:\s*[^;]*;?/gi, f = /;\s*;/g, E = /^;|;$/g, x = /display\s*:\s*inline/gi, A = /display\s*:/i, B = /font-weight\s*:\s*bold/i, $ = /font-style\s*:\s*italic/i, N = /^<(?:strong|b)\b/i, O = /^<(?:em|i)\b/i;
6
+ class H {
6
7
  constructor() {
7
- b(this, "parser");
8
+ y(this, "parser");
8
9
  this.parser = new DOMParser();
9
10
  }
10
- migrate(e) {
11
+ migrate(t) {
11
12
  try {
12
- const t = this.parser.parseFromString(e, "text/html"), s = t.querySelectorAll("td.radio-button-block"), i = t.querySelectorAll("td.radio-button-v2");
13
- if (s.length === 0 && i.length === 0)
14
- return e;
15
- let o = !1;
16
- return s.forEach((r) => {
13
+ const e = this.parser.parseFromString(t, "text/html"), o = e.querySelectorAll("td.radio-button-block"), n = e.querySelectorAll("td.radio-button-v2");
14
+ if (o.length === 0 && n.length === 0)
15
+ return t;
16
+ let i = !1;
17
+ return o.forEach((r) => {
17
18
  if (r.classList.contains("radio-button-v2"))
18
19
  return;
19
- const n = r.getAttribute("id"), a = this.extractTextFromElement(r, "ins-title"), g = this.extractTextFromElement(r, "ins-description"), c = this.extractTextFromElement(r, "ins-subscribe"), u = this.extractTextFromElement(r, "ins-unsubscribe"), p = this.buildTextBlock(a), d = this.buildTextBlock(g), y = this.buildTextBlock({ ...c, classList: "" }), f = this.buildTextBlock({ ...u, classList: "" }), h = S.replace("{-{-TITLE-}-}", p).replace("{-{-DESCRIPTION-}-}", d).replace("{-{-YES-}-}", y).replace("{-{-NO-}-}", f), m = this.parser.parseFromString(
20
+ const s = r.getAttribute("id"), c = this.extractTextFromElement(r, "ins-title"), u = this.extractTextFromElement(r, "ins-description"), l = this.extractTextFromElement(r, "ins-subscribe"), a = this.extractTextFromElement(r, "ins-unsubscribe"), d = this.buildTextBlock(c), m = this.buildTextBlock(u), T = this.buildTextBlock({ ...l, classList: "" }), b = this.buildTextBlock({ ...a, classList: "" }), h = R.replace("{-{-TITLE-}-}", d).replace("{-{-DESCRIPTION-}-}", m).replace("{-{-YES-}-}", T).replace("{-{-NO-}-}", b), g = this.parser.parseFromString(
20
21
  `<table id="tempDoc"><tbody><tr>${h}</tr></tbody></table>`,
21
22
  "text/html"
22
23
  ).querySelector(".radio-button-v2");
23
- m && r.parentNode && (m.setAttribute("id", n || ""), r.parentNode.replaceChild(m, r), o = !0);
24
- }), o = this.healRadioButtonV2(t) || o, o ? t.documentElement.outerHTML : e;
25
- } catch (t) {
26
- return console.error("RadioButtonMigrator failed:", t), e;
24
+ g && r.parentNode && (g.setAttribute("id", s || ""), r.parentNode.replaceChild(g, r), i = !0);
25
+ }), i = this.healRadioButtonV2(e) || i, i ? e.documentElement.outerHTML : t;
26
+ } catch (e) {
27
+ return console.error("RadioButtonMigrator failed:", e), t;
27
28
  }
28
29
  }
29
- healRadioButtonV2(e) {
30
- let t = !1;
31
- return e.querySelectorAll("td.radio-button-v2").forEach((s) => {
32
- var d;
33
- s.classList.contains("radio-button-block") || (s.classList.add("radio-button-block"), t = !0);
34
- const i = s.querySelector("input#radioYes"), o = s.querySelector("input#radioNo");
35
- if (!i || !o)
30
+ healRadioButtonV2(t) {
31
+ let e = !1;
32
+ return t.querySelectorAll("td.radio-button-v2").forEach((o) => {
33
+ var m;
34
+ o.classList.contains("radio-button-block") || (o.classList.add("radio-button-block"), e = !0);
35
+ const n = o.querySelector("input#radioYes"), i = o.querySelector("input#radioNo");
36
+ if (!n || !i)
36
37
  return;
37
- const r = ((d = i.parentElement) == null ? void 0 : d.querySelector(":scope > p")) || null;
38
- if (!r && !i.hasAttribute("align"))
38
+ const r = ((m = n.parentElement) == null ? void 0 : m.querySelector(":scope > p")) || null;
39
+ if (!r && !n.hasAttribute("align"))
39
40
  return;
40
- const n = i.closest("tr"), a = o.closest("tr");
41
- if (!n || !a || n === a || !n.parentNode)
41
+ const s = n.closest("tr"), c = i.closest("tr");
42
+ if (!s || !c || s === c || !s.parentNode)
42
43
  return;
43
- const g = (r == null ? void 0 : r.innerHTML.trim()) || "Yes", c = a.cloneNode(!0), u = c.querySelector("input#radioNo"), p = c.querySelector("p");
44
- u && (u.setAttribute("id", "radioYes"), u.removeAttribute("align")), p && (p.innerHTML = g), n.parentNode.replaceChild(c, n), t = !0;
45
- }), t;
44
+ const u = (r == null ? void 0 : r.innerHTML.trim()) || "Yes", l = c.cloneNode(!0), a = l.querySelector("input#radioNo"), d = l.querySelector("p");
45
+ a && (a.setAttribute("id", "radioYes"), a.removeAttribute("align")), d && (d.innerHTML = u), s.parentNode.replaceChild(l, s), e = !0;
46
+ }), e;
46
47
  }
47
- extractTextFromElement(e, t) {
48
- var d, y;
49
- const s = e.querySelector(`.${t}`);
50
- if (!s)
48
+ extractTextFromElement(t, e) {
49
+ var u, l;
50
+ const o = e === "ins-title" ? "Title" : "Description", n = t.querySelector(`.${e}`);
51
+ if (!n)
51
52
  return {
52
- text: t === "ins-title" ? "Title" : "Description",
53
- isBold: !1,
54
- isItalic: !1,
53
+ paragraphs: [{ innerHtml: o, isBold: !1, isItalic: !1, styles: "" }],
55
54
  align: "left",
56
- styles: "",
57
55
  classList: ""
58
56
  };
59
- const i = s.querySelector("p");
60
- if (!i)
61
- return {
62
- text: ((d = s.textContent) == null ? void 0 : d.trim()) || (t === "ins-title" ? "Title" : "Description"),
57
+ const i = Array.from(n.querySelectorAll("p")), r = n.getAttribute("align") || ((u = i[0]) == null ? void 0 : u.getAttribute("align")) || "left", s = n.getAttribute("class") || "";
58
+ return i.length === 0 ? {
59
+ paragraphs: [{
60
+ innerHtml: ((l = n.textContent) == null ? void 0 : l.trim()) || o,
63
61
  isBold: !1,
64
62
  isItalic: !1,
65
- align: s.getAttribute("align") || "left",
66
- styles: "",
67
- classList: ""
63
+ styles: ""
64
+ }],
65
+ align: r,
66
+ classList: ""
67
+ } : { paragraphs: i.map((a) => {
68
+ const d = a.getAttribute("style") || "", m = B.test(d) || !!a.querySelector("b, strong"), T = $.test(d) || !!a.querySelector("i, em"), b = this.removeFontEmphasisProperties(d);
69
+ return {
70
+ // Legacy parity: empty <p> → fallback placeholder; <p><br></p> is not empty.
71
+ innerHtml: a.innerHTML.trim() || o,
72
+ isBold: m,
73
+ isItalic: T,
74
+ styles: this.convertInlineToBlock(b)
68
75
  };
69
- const o = ((y = i.textContent) == null ? void 0 : y.trim()) || (t === "ins-title" ? "Title" : "Description"), r = i.getAttribute("style") || "", n = s.getAttribute("align") || i.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(r) || !!i.querySelector("b, strong"), g = /font-style\s*:\s*italic/i.test(r) || !!i.querySelector("i, em"), c = this.removeStyleProperties(r, ["font-weight", "font-style"]), u = this.convertInlineToBlock(c), p = s.getAttribute("class") || "";
70
- return {
71
- text: o,
72
- isBold: a,
73
- isItalic: g,
74
- align: n,
75
- styles: u,
76
- classList: p
77
- };
76
+ }), align: r, classList: s };
78
77
  }
79
- buildTextBlock(e) {
80
- let t = e.text;
81
- e.isBold && e.isItalic ? t = `<strong path="1,0"><em path="1,0,0">${t}</em></strong>` : e.isBold ? t = `<strong path="1,0">${t}</strong>` : e.isItalic && (t = `<em path="1,0">${t}</em>`);
82
- const s = e.align ? ` align="${e.align}"` : "", i = e.styles ? ` style="${e.styles.replaceAll('"', "'")}"` : "";
78
+ buildTextBlock(t) {
79
+ const e = t.align ? ` align="${t.align}"` : "", o = t.paragraphs.map((n, i) => {
80
+ const r = i + 1;
81
+ let s = n.innerHtml;
82
+ const c = n.isBold && !N.test(s), u = n.isItalic && !O.test(s);
83
+ c && u ? s = `<strong path="${r},0"><em path="${r},0,0">${s}</em></strong>` : c ? s = `<strong path="${r},0">${s}</strong>` : u && (s = `<em path="${r},0">${s}</em>`);
84
+ const l = n.styles ? ` style="${n.styles.replaceAll('"', "'")}"` : "";
85
+ return `<p path="${r}"${l}>${s}</p>`;
86
+ }).join(`
87
+ `);
83
88
  return `
84
- <td class="esd-block-text ${e.classList}" ${s}>
85
- <p path="1" ${i}>
86
- ${t}
87
- </p>
89
+ <td class="esd-block-text ${t.classList}" ${e}>
90
+ ${o}
88
91
  </td>
89
92
  `;
90
93
  }
91
- removeStyleProperties(e, t) {
92
- return e ? t.reduce((i, o) => {
93
- const r = new RegExp(`${o}\\s*:\\s*[^;]*;?`, "gi");
94
- return i.replace(r, "");
95
- }, e).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
94
+ removeFontEmphasisProperties(t) {
95
+ return t ? t.replace(L, "").replace(_, "").replace(f, ";").replace(E, "").trim() : "";
96
96
  }
97
- convertInlineToBlock(e) {
98
- if (!e)
97
+ convertInlineToBlock(t) {
98
+ if (!t)
99
99
  return "";
100
- let t = e.replace(/display\s*:\s*inline/gi, "display: block");
101
- return /display\s*:/i.test(t) || (t = t ? `${t}; display: block` : "display: block"), t.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
100
+ let e = t.replace(x, "display: block");
101
+ return A.test(e) || (e = e ? `${e}; display: block` : "display: block"), e.replace(f, ";").replace(E, "").trim();
102
102
  }
103
103
  }
104
- function L(l) {
105
- return new B().migrate(l);
104
+ function C(p) {
105
+ return new H().migrate(p);
106
106
  }
107
107
  export {
108
- L as migrateRadioButton
108
+ C as migrateRadioButton
109
109
  };
@@ -1,27 +1,27 @@
1
- var B = Object.defineProperty;
2
- var C = (a, s, t) => s in a ? B(a, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[s] = t;
3
- var p = (a, s, t) => C(a, typeof s != "symbol" ? s + "" : s, t);
4
- import { BlockId as R } from "../../../enums/block.js";
1
+ var k = Object.defineProperty;
2
+ var B = (r, n, t) => n in r ? k(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
3
+ var g = (r, n, t) => B(r, typeof n != "symbol" ? n + "" : n, t);
4
+ import { BlockId as _ } from "../../../enums/block.js";
5
5
  import { getMigrationBannerHtml as b } from "../../../utils/migrationBannerHtml.js";
6
- import { Block as A, BlockCompositionType as y, ModificationDescription as f } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
- import { regenerateMobileProductRows as D } from "./controls/main/utils.js";
8
- import { ensureMobileCssRulesExist as h, setMobileLayoutOptOut as I, hasMobileLayoutOptOut as E } from "./controls/mobileLayout/cssRules.js";
9
- import { RecommendationConfigService as c } from "./services/configService.js";
10
- import { useRecommendationExtensionStore as g } from "./store/recommendation.js";
11
- import { getDefaultTemplate as N } from "./templates/grid/template.js";
12
- const k = R.Recommendation, m = "recommendation-block-v2", u = "recommendation-id";
13
- let _ = !1;
14
- class q extends A {
6
+ import { Block as R, BlockCompositionType as y, ModificationDescription as C } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
+ import { regenerateMobileProductRows as A } from "./controls/main/utils.js";
8
+ import { ensureMobileCssRulesExist as d, setMobileLayoutOptOut as p, hasMobileLayoutOptOut as D } from "./controls/mobileLayout/cssRules.js";
9
+ import { RecommendationConfigService as s } from "./services/configService.js";
10
+ import { useRecommendationExtensionStore as f } from "./store/recommendation.js";
11
+ import { getDefaultTemplate as E } from "./templates/grid/template.js";
12
+ const h = _.Recommendation, l = "recommendation-block-v2", m = "recommendation-id";
13
+ let I = !1;
14
+ class q extends R {
15
15
  constructor() {
16
16
  super();
17
17
  /**
18
18
  * Stores the ID generated in getTemplate() so onCreated() can reuse it.
19
19
  * This avoids generating a new (different) ID in onCreated().
20
20
  */
21
- p(this, "_pendingBlockId", null);
21
+ g(this, "_pendingBlockId", null);
22
22
  }
23
23
  getId() {
24
- return k;
24
+ return h;
25
25
  }
26
26
  getIcon() {
27
27
  return "recommendation-icon";
@@ -39,7 +39,7 @@ class q extends A {
39
39
  }
40
40
  getSettingsPanelTitleHtml() {
41
41
  return b(
42
- k,
42
+ h,
43
43
  this.api.translate("Recommendation Block"),
44
44
  this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
45
45
  );
@@ -59,7 +59,7 @@ class q extends A {
59
59
  */
60
60
  getTemplate() {
61
61
  const t = this._generateNextId();
62
- return this._pendingBlockId = t, N(t);
62
+ return this._pendingBlockId = t, E(t);
63
63
  }
64
64
  /**
65
65
  * Called when a new block is dropped into the template
@@ -70,26 +70,24 @@ class q extends A {
70
70
  */
71
71
  onCreated(t) {
72
72
  const e = this._getRecommendationId(t);
73
- if (e !== null && e > 0) {
74
- this._detectDuplicate(e) && this._handleDuplicate(t, e);
73
+ if (e !== null && e > 0)
75
74
  return;
76
- }
77
75
  const i = this._pendingBlockId ?? this._generateNextId();
78
76
  this._pendingBlockId = null, this._assignRecommendationId(t, i);
79
- const { config: n, wasFreshDrop: o } = c.initializeConfig(
77
+ const { config: o, wasFreshDrop: c } = s.initializeConfig(
80
78
  this.api,
81
79
  t,
82
80
  { recommendationId: i }
83
- ), r = g();
84
- if (r.setCurrentBlock(i), o) {
85
- h(this.api);
86
- const l = this._getBlockElement(t);
87
- l && (I(this.api, l, !0), D({
81
+ ), a = f();
82
+ if (a.setCurrentBlock(i), c) {
83
+ d(this.api);
84
+ const u = this._getBlockElement(t);
85
+ u && (p(this.api, u, !0), A({
88
86
  currentNode: t,
89
87
  documentModifier: this.api.getDocumentModifier()
90
88
  }));
91
89
  }
92
- r.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 });
90
+ a.patchCurrentBlockConfig({ language: o.language }, { triggerRefetch: !1 });
93
91
  }
94
92
  /**
95
93
  * Called when the document changes or template is loaded
@@ -102,20 +100,20 @@ class q extends A {
102
100
  if (!(!t || !("getNodeConfig" in t))) {
103
101
  if (!this._getRecommendationId(t)) {
104
102
  const e = this._generateNextId();
105
- this._assignRecommendationId(t, e), c.hasConfig(t) && c.updateConfig(
103
+ this._assignRecommendationId(t, e), s.hasConfig(t) && s.updateConfig(
106
104
  this.api,
107
105
  t,
108
106
  { recommendationId: e },
109
107
  "Assign recommendation ID to legacy block"
110
108
  );
111
109
  }
112
- c.needsMigration(t) && this._migrateFromLegacy(t);
110
+ s.needsMigration(t) && this._migrateFromLegacy(t);
113
111
  try {
114
- _ || (h(this.api), _ = !0);
115
- const e = c.getConfig(t), i = this._getBlockElement(t);
112
+ I || (d(this.api), I = !0);
113
+ const e = s.getConfig(t), i = this._getBlockElement(t);
116
114
  if (i) {
117
- const n = !e.mobileLayoutEnabled;
118
- E(i) !== n && I(this.api, i, n);
115
+ const o = !e.mobileLayoutEnabled;
116
+ D(i) !== o && p(this.api, i, o);
119
117
  }
120
118
  } catch {
121
119
  }
@@ -129,7 +127,7 @@ class q extends A {
129
127
  */
130
128
  onDelete(t) {
131
129
  const e = this._getRecommendationId(t);
132
- e && g().removeBlockState(e);
130
+ e && f().removeBlockState(e);
133
131
  }
134
132
  /**
135
133
  * Generates the next unique recommendation ID by scanning all existing blocks
@@ -139,59 +137,16 @@ class q extends A {
139
137
  let t = 0;
140
138
  try {
141
139
  const e = this.api.getDocumentRoot();
142
- e && "querySelectorAll" in e && e.querySelectorAll(`.${m}`).forEach((n) => {
143
- if ("getAttribute" in n) {
144
- const o = n.getAttribute(u), r = o ? parseInt(o) : 0;
145
- r > t && (t = r);
140
+ e && "querySelectorAll" in e && e.querySelectorAll(`.${l}`).forEach((o) => {
141
+ if ("getAttribute" in o) {
142
+ const c = o.getAttribute(m), a = c ? parseInt(c) : 0;
143
+ a > t && (t = a);
146
144
  }
147
145
  });
148
146
  } catch {
149
147
  }
150
148
  return t + 1;
151
149
  }
152
- /** True when another block already holds the same id — Stripo's duplication signal. */
153
- _detectDuplicate(t) {
154
- try {
155
- const e = this.api.getDocumentRoot();
156
- if (e && "querySelectorAll" in e)
157
- return e.querySelectorAll(
158
- `.${m}[${u}="${t}"]`
159
- ).length > 1;
160
- } catch {
161
- }
162
- return !1;
163
- }
164
- /** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
165
- _handleDuplicate(t, e) {
166
- const i = this._generateNextId(), n = this._getBlockElement(t);
167
- this._assignRecommendationId(t, i), n && this._reassignInstanceClass(n, e, i), c.hasConfig(t) && c.updateConfig(
168
- this.api,
169
- t,
170
- { recommendationId: i },
171
- `Reassign recommendation ID on duplicate (was ${e})`
172
- );
173
- const o = g();
174
- o.cloneBlockState(e, i), o.setCurrentBlock(i);
175
- }
176
- /**
177
- * Rewrites `ins-recommendation-v3-block-{id}` on the clone — the instance
178
- * class scopes per-block CSS rules, so leaving the source's class would
179
- * make stylistic edits leak between source and clone.
180
- */
181
- _reassignInstanceClass(t, e, i) {
182
- if (!("getAttribute" in t))
183
- return;
184
- const n = t.getAttribute("class");
185
- if (!n)
186
- return;
187
- const o = `ins-recommendation-v3-block-${e}`, r = `ins-recommendation-v3-block-${i}`;
188
- if (!n.includes(o))
189
- return;
190
- const l = n.replace(o, r), d = this.api.getDocumentModifier();
191
- d.modifyHtml(t).setAttribute("class", l), d.apply(new f(
192
- `Reassign recommendation instance class ${o} -> ${r}`
193
- ));
194
- }
195
150
  /**
196
151
  * Assigns a recommendation-id attribute to the block element.
197
152
  * The instance class (ins-recommendation-v3-block-{id}) is embedded in the template
@@ -202,8 +157,8 @@ class q extends A {
202
157
  const i = this._getBlockElement(t);
203
158
  if (!i)
204
159
  return;
205
- const n = this.api.getDocumentModifier();
206
- n.modifyHtml(i).setAttribute(u, e.toString()), n.apply(new f(`Assign recommendation ID ${e}`));
160
+ const o = this.api.getDocumentModifier();
161
+ o.modifyHtml(i).setAttribute(m, e.toString()), o.apply(new C(`Assign recommendation ID ${e}`));
207
162
  }
208
163
  /**
209
164
  * Gets the recommendation-id from a block node
@@ -212,11 +167,11 @@ class q extends A {
212
167
  const e = this._getBlockElement(t);
213
168
  if (!e || !("getAttribute" in e))
214
169
  return null;
215
- const i = e.getAttribute(u);
170
+ const i = e.getAttribute(m);
216
171
  if (!i)
217
172
  return null;
218
- const n = parseInt(i);
219
- return Number.isNaN(n) ? null : n;
173
+ const o = parseInt(i);
174
+ return Number.isNaN(o) ? null : o;
220
175
  }
221
176
  /**
222
177
  * Gets the block element (the element with BLOCK_CLASS)
@@ -224,19 +179,19 @@ class q extends A {
224
179
  _getBlockElement(t) {
225
180
  if ("getAttribute" in t) {
226
181
  const e = t.getAttribute("class");
227
- if (e && e.includes(m))
182
+ if (e && e.includes(l))
228
183
  return t;
229
184
  }
230
- return "querySelector" in t ? t.querySelector(`.${m}`) ?? null : null;
185
+ return "querySelector" in t ? t.querySelector(`.${l}`) ?? null : null;
231
186
  }
232
187
  /**
233
188
  * Migrate configuration from legacy format
234
189
  */
235
190
  _migrateFromLegacy(t) {
236
- c.migrateFromDataAttributes(this.api, t);
191
+ s.migrateFromDataAttributes(this.api, t);
237
192
  }
238
193
  }
239
194
  export {
240
- k as BLOCK_ID,
195
+ h as BLOCK_ID,
241
196
  q as RecommendationBlock
242
197
  };
@@ -1,16 +1,16 @@
1
- import { getRecommendationFeedSourceMaps as g, getOperatorOptions as R, PriceAttributes as C } from "../../../../enums/extensions/recommendationBlock.js";
2
- import { useRecommendationApi as y } from "../../../../services/recommendationApi.js";
1
+ import { getRecommendationFeedSourceMaps as g, getOperatorOptions as R, PriceAttributes as y } from "../../../../enums/extensions/recommendationBlock.js";
2
+ import { useRecommendationApi as C } from "../../../../services/recommendationApi.js";
3
3
  import { useConfigStore as G } from "../../../../stores/config.js";
4
4
  import { defineStore as P } from "pinia";
5
5
  import { DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
6
6
  import { EXCLUDED_ALGORITHM_IDS as D } from "../constants/defaultConfig.js";
7
7
  import { getDefaultProducts as S } from "../templates/utils.js";
8
8
  import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
9
- import { isFilterValid as v } from "../validation/filterSchema.js";
10
- import { isConfigValid as w } from "../validation/requiredFields.js";
11
- const h = y();
9
+ import { isFilterValid as w } from "../validation/filterSchema.js";
10
+ import { isConfigValid as v } from "../validation/requiredFields.js";
11
+ const h = C();
12
12
  let m = null, u = null, d = null;
13
- function I() {
13
+ function k() {
14
14
  return {
15
15
  cardsInRow: F,
16
16
  currencySettings: {
@@ -38,9 +38,9 @@ function I() {
38
38
  customAttributes: []
39
39
  };
40
40
  }
41
- function k() {
41
+ function I() {
42
42
  return {
43
- recommendationConfigs: I(),
43
+ recommendationConfigs: k(),
44
44
  recommendationProducts: [],
45
45
  filterStatus: !1,
46
46
  filterSelectionDrawerStatus: !1,
@@ -69,7 +69,7 @@ const N = () => ({
69
69
  * This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
70
70
  */
71
71
  recommendationConfigs(t) {
72
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : I();
72
+ return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : k();
73
73
  },
74
74
  /**
75
75
  * Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
@@ -133,7 +133,7 @@ const N = () => ({
133
133
  getFilterList() {
134
134
  return Object.values(this.filterList).map((t) => {
135
135
  let e;
136
- return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : C.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
136
+ return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : y.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
137
137
  text: t.displayName,
138
138
  value: e,
139
139
  type: t.attributeType
@@ -155,7 +155,7 @@ const N = () => ({
155
155
  setCurrentBlock(t) {
156
156
  this.blockStates[t] || (this.blockStates = {
157
157
  ...this.blockStates,
158
- [t]: k()
158
+ [t]: I()
159
159
  }), this.currentRecommendationId = t;
160
160
  },
161
161
  /**
@@ -174,25 +174,6 @@ const N = () => ({
174
174
  this.currentRecommendationId = n.length > 0 ? n[0] : null;
175
175
  }
176
176
  },
177
- /**
178
- * Deep-clones a block's state and mirrors its campaign URL under a new id.
179
- * Invoked from `onCreated` when a duplicate is detected (SD-142352).
180
- */
181
- cloneBlockState(t, e) {
182
- const r = this.blockStates[t];
183
- if (r) {
184
- const o = structuredClone(r);
185
- o.recommendationConfigs.id = e, this.blockStates = {
186
- ...this.blockStates,
187
- [e]: o
188
- };
189
- }
190
- const n = t.toString(), c = e.toString(), i = this.recommendationCampaignUrls[n];
191
- i && (this.recommendationCampaignUrls = {
192
- ...this.recommendationCampaignUrls,
193
- [c]: i
194
- });
195
- },
196
177
  /**
197
178
  * Marks a block as initialized (initial API data has been fetched).
198
179
  * Automatically cleaned up when removeBlockState deletes the block entry.
@@ -223,7 +204,7 @@ const N = () => ({
223
204
  decimalCount: String(e.currencyDecimalCount),
224
205
  decimalSeparator: r(e.currencyDecimalSeparator, ","),
225
206
  thousandSeparator: r(e.currencyThousandSeparator, ".")
226
- }, c = !this.blockStates[t], i = c ? k() : this.blockStates[t];
207
+ }, c = !this.blockStates[t], i = c ? I() : this.blockStates[t];
227
208
  i.recommendationConfigs = {
228
209
  ...i.recommendationConfigs,
229
210
  strategy: e.strategy,
@@ -378,7 +359,7 @@ const N = () => ({
378
359
  const n = [...e.recommendationConfigs.filters];
379
360
  n[r] = {
380
361
  ...t,
381
- isValid: v(t)
362
+ isValid: w(t)
382
363
  }, e.recommendationConfigs.filters = n;
383
364
  }
384
365
  },
@@ -424,7 +405,7 @@ const N = () => ({
424
405
  * every block's recommendationConfigs across user edits.
425
406
  */
426
407
  hasInvalidBlock() {
427
- return Object.values(this.blockStates).some((t) => !w(t.recommendationConfigs, this));
408
+ return Object.values(this.blockStates).some((t) => !v(t.recommendationConfigs, this));
428
409
  },
429
410
  // ====================================================================
430
411
  // Per-Block Product Fetching
@@ -60,16 +60,6 @@ export declare class RecommendationBlock extends Block {
60
60
  * in the document and finding the maximum existing ID + 1.
61
61
  */
62
62
  private _generateNextId;
63
- /** True when another block already holds the same id — Stripo's duplication signal. */
64
- private _detectDuplicate;
65
- /** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
66
- private _handleDuplicate;
67
- /**
68
- * Rewrites `ins-recommendation-v3-block-{id}` on the clone — the instance
69
- * class scopes per-block CSS rules, so leaving the source's class would
70
- * make stylistic edits leak between source and clone.
71
- */
72
- private _reassignInstanceClass;
73
63
  /**
74
64
  * Assigns a recommendation-id attribute to the block element.
75
65
  * The instance class (ins-recommendation-v3-block-{id}) is embedded in the template
@@ -216,11 +216,6 @@ export declare const useRecommendationExtensionStore: import("pinia").StoreDefin
216
216
  * Resets currentRecommendationId if it was the deleted block.
217
217
  */
218
218
  removeBlockState(id: number): void;
219
- /**
220
- * Deep-clones a block's state and mirrors its campaign URL under a new id.
221
- * Invoked from `onCreated` when a duplicate is detected (SD-142352).
222
- */
223
- cloneBlockState(sourceId: number, newId: number): void;
224
219
  /**
225
220
  * Marks a block as initialized (initial API data has been fetched).
226
221
  * Automatically cleaned up when removeBlockState deletes the block entry.
@@ -1,87 +1,79 @@
1
- import { useActionsApi as C } from "../composables/useActionsApi.js";
2
- import { useHtmlCompiler as T } from "../composables/useHtmlCompiler.js";
3
- import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as s } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
1
+ import { useActionsApi as T } from "../composables/useActionsApi.js";
2
+ import { useHtmlCompiler as C } from "../composables/useHtmlCompiler.js";
3
+ import { DEFAULT_CURRENCY as l, DEFAULT_NODE_CONFIG as a } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
4
4
  import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { DATA_ATTRIBUTES as S } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
- import { parsePageList as D } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
- import { useDynamicContentStore as P } from "../stores/dynamic-content.js";
8
- import { useUnsubscribeStore as w } from "../stores/unsubscribe.js";
9
- function E(i, o) {
10
- const t = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${S.PAGE_LIST}]`), c = [];
11
- return t.forEach((r) => {
12
- const a = r.getAttribute(S.PAGE_LIST);
13
- a && c.push(...D(a));
14
- }), o.filter((r) => c.includes(r));
5
+ import { DATA_ATTRIBUTES as y } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
6
+ import { parsePageList as P } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
7
+ import { useDynamicContentStore as D } from "../stores/dynamic-content.js";
8
+ import { useUnsubscribeStore as E } from "../stores/unsubscribe.js";
9
+ function U(i, r) {
10
+ const s = new DOMParser().parseFromString(i, "text/html").querySelectorAll(`[${y.PAGE_LIST}]`), c = [];
11
+ return s.forEach((t) => {
12
+ const o = t.getAttribute(y.PAGE_LIST);
13
+ o && c.push(...P(o));
14
+ }), r.filter((t) => c.includes(t));
15
15
  }
16
- async function U(i) {
16
+ function F(i) {
17
17
  const m = new DOMParser().parseFromString(i, "text/html").querySelectorAll(".recommendation-block-v2");
18
18
  if (m.length === 0)
19
19
  return;
20
- const l = b();
21
- m.forEach((t) => {
22
- var g, f, u, n, y;
23
- const c = t.getAttribute("recommendation-id"), r = c ? Number(c) : NaN;
24
- if (!Number.isFinite(r))
20
+ const d = b();
21
+ m.forEach((s) => {
22
+ var g, f, u, n, S;
23
+ const c = s.getAttribute("recommendation-id"), t = c ? Number(c) : NaN;
24
+ if (!Number.isFinite(t))
25
25
  return;
26
- const a = t.getAttribute("esd-ext-config");
27
- if (!a)
26
+ const o = s.getAttribute("esd-ext-config");
27
+ if (!o)
28
28
  return;
29
29
  let e;
30
30
  try {
31
- e = JSON.parse(a);
31
+ e = JSON.parse(o);
32
32
  } catch {
33
33
  return;
34
34
  }
35
35
  if (!e || typeof e != "object" || Array.isArray(e))
36
36
  return;
37
37
  const p = {
38
- strategy: e.strategy ?? s.strategy,
39
- language: e.language ?? s.language,
40
- size: e.size ?? s.size,
38
+ strategy: e.strategy ?? a.strategy,
39
+ language: e.language ?? a.language,
40
+ size: e.size ?? a.size,
41
41
  // Spread the default arrays so each block gets a fresh reference
42
42
  // instead of sharing the singleton in DEFAULT_NODE_CONFIG.
43
- productIds: e.productIds ?? [...s.productIds],
44
- filters: e.filters ?? [...s.filters],
45
- shuffleProducts: e.shuffleProducts ?? s.shuffleProducts,
46
- currencyCode: ((g = e.currency) == null ? void 0 : g.code) ?? d.code,
47
- currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? d.alignment,
48
- currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ?? d.decimalCount,
49
- currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ?? d.decimalSeparator,
50
- currencyThousandSeparator: ((y = e.currency) == null ? void 0 : y.thousandSeparator) ?? d.thousandSeparator
43
+ productIds: e.productIds ?? [...a.productIds],
44
+ filters: e.filters ?? [...a.filters],
45
+ shuffleProducts: e.shuffleProducts ?? a.shuffleProducts,
46
+ currencyCode: ((g = e.currency) == null ? void 0 : g.code) ?? l.code,
47
+ currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? l.alignment,
48
+ currencyDecimalCount: ((u = e.currency) == null ? void 0 : u.decimalCount) ?? l.decimalCount,
49
+ currencyDecimalSeparator: ((n = e.currency) == null ? void 0 : n.decimalSeparator) ?? l.decimalSeparator,
50
+ currencyThousandSeparator: ((S = e.currency) == null ? void 0 : S.thousandSeparator) ?? l.thousandSeparator
51
51
  };
52
- l.seedBlockUrlConfig(r, p);
52
+ d.seedBlockUrlConfig(t, p);
53
53
  });
54
- try {
55
- await l.fetchRecommendationCreateData();
56
- } catch (t) {
57
- console.warn(
58
- "Recommendation reference data pre-load failed; validator will skip the availability check.",
59
- t
60
- );
61
- }
62
54
  }
63
55
  const _ = () => {
64
- const i = P(), o = w(), { getCompiledEmail: m, getTemplateData: l } = C(), { compileHtml: t } = T();
56
+ const i = D(), r = E(), { getCompiledEmail: m, getTemplateData: d } = T(), { compileHtml: s } = C();
65
57
  return {
66
58
  prepareTemplateDetails: async () => {
67
- const { html: r, ampHtml: a = "", ampErrors: e = [] } = await m({
59
+ const { html: t, ampHtml: o = "", ampErrors: e = [] } = await m({
68
60
  minimize: !0,
69
61
  resetDataSavedFlag: !1
70
- }), { html: p, css: g, syncModulesIds: f = [] } = await l();
71
- o.selectedUnsubscribePages.length && await o.fetchTemplates(), await U(p);
72
- const { compiledHtml: u, stats: n, appliedRules: y } = t(r), h = i.getSelectedDynamicContentList, A = b();
62
+ }), { html: p, css: g, syncModulesIds: f = [] } = await d();
63
+ r.selectedUnsubscribePages.length && await r.fetchTemplates(), F(p);
64
+ const { compiledHtml: u, stats: n, appliedRules: S } = s(t), h = i.getSelectedDynamicContentList, A = b();
73
65
  return console.debug("HTML Compilation Stats:", {
74
66
  originalSize: n.originalSize,
75
67
  compiledSize: n.compiledSize,
76
68
  reduction: `${n.reductionPercentage.toFixed(2)}%`,
77
- appliedRules: y,
69
+ appliedRules: S,
78
70
  executionTime: `${n.executionTime.toFixed(2)}ms`
79
71
  }), {
80
72
  dynamicContentList: h,
81
73
  compiledHtml: u,
82
74
  rawHtml: p,
83
75
  css: g,
84
- ampHtml: a,
76
+ ampHtml: o,
85
77
  ampErrors: e,
86
78
  modules: f.map(Number),
87
79
  recommendation: {
@@ -89,8 +81,8 @@ const _ = () => {
89
81
  configs: {}
90
82
  },
91
83
  unsubscribe: {
92
- status: o.unsubscribePagesStatus,
93
- config: E(u, o.selectedUnsubscribePages)
84
+ status: r.unsubscribePagesStatus,
85
+ config: U(u, r.selectedUnsubscribePages)
94
86
  }
95
87
  };
96
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.4.1-beta.8f6f02b",
3
+ "version": "3.4.1-beta.a125d94",
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",