@useinsider/guido 3.9.1-beta.22c4bcc → 3.9.1-beta.2e19260

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.
@@ -0,0 +1,18 @@
1
+ import e from "./AiStatusPill.vue2.js";
2
+ /* empty css */
3
+ import i from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var l = function() {
5
+ var t = this, a = t._self._c, s = t._self._setupProxy;
6
+ return s.aiStatusStore.isGenerating ? a("span", { staticClass: "ml-2 d-f a-i-c f-s-1 ai-status-pill" }, [a(s.InLoading, { attrs: { "color-class": "i-c-53", size: "16" } }), a("span", { staticClass: "ml-1 t-c-53 ai-status-pill__label" }, [t._v(" " + t._s(s.generatingLabel()) + " ")]), s.aiStatusStore.hasTool ? a("span", { staticClass: "ml-1 t-c-55 ai-status-pill__tool" }, [t._v(" " + t._s(s.aiStatusStore.tool) + " ")]) : t._e()], 1) : t._e();
7
+ }, o = [], r = /* @__PURE__ */ i(
8
+ e,
9
+ l,
10
+ o,
11
+ !1,
12
+ null,
13
+ "fd1ec18d"
14
+ );
15
+ const f = r.exports;
16
+ export {
17
+ f as default
18
+ };
@@ -0,0 +1,17 @@
1
+ import { defineComponent as o } from "vue";
2
+ import { useTranslations as s } from "../../../composables/useTranslations.js";
3
+ import { useAiStatusStore as a } from "../../../stores/ai-status.js";
4
+ import { InLoading as i } from "@useinsider/design-system-vue";
5
+ const l = /* @__PURE__ */ o({
6
+ __name: "AiStatusPill",
7
+ setup(m) {
8
+ const r = a(), t = s();
9
+ return { __sfc: !0, aiStatusStore: r, trans: t, generatingLabel: () => {
10
+ const e = "newsletter.ai-generating", n = t(e);
11
+ return n === e ? "AI is generating…" : n;
12
+ }, InLoading: i };
13
+ }
14
+ });
15
+ export {
16
+ l as default
17
+ };
@@ -2,7 +2,7 @@ import r from "./MiddleSlot.vue2.js";
2
2
  import s from "../../../_virtual/_plugin-vue2_normalizer.js";
3
3
  var t = function() {
4
4
  var o = this, e = o._self._c, i = o._self._setupProxy;
5
- return e("div", { staticClass: "d-f a-i-c" }, [i.editorStore.isVersionHistoryOpen ? e("div", { staticClass: "d-f" }, [e(i.VersionHistory), e(i.VersionHistoryViewOptions)], 1) : i.editorStore.isPreviewModeOpen ? e("div", { staticClass: "d-f" }, [e(i.EmailSizeIndicator), e(i.AmpToggle)], 1) : o._e(), e(i.EditorToolbar, { directives: [{ name: "show", rawName: "v-show", value: i.editorStore.isEditorToolbarVisible, expression: "editorStore.isEditorToolbarVisible" }] })], 1);
5
+ return e("div", { staticClass: "d-f a-i-c" }, [i.editorStore.isVersionHistoryOpen ? e("div", { staticClass: "d-f" }, [e(i.VersionHistory), e(i.VersionHistoryViewOptions)], 1) : i.editorStore.isPreviewModeOpen ? e("div", { staticClass: "d-f" }, [e(i.EmailSizeIndicator), e(i.AmpToggle)], 1) : o._e(), e(i.EditorToolbar, { directives: [{ name: "show", rawName: "v-show", value: i.editorStore.isEditorToolbarVisible, expression: "editorStore.isEditorToolbarVisible" }] }), e(i.AiStatusPill)], 1);
6
6
  }, a = [], n = /* @__PURE__ */ s(
7
7
  r,
8
8
  t,
@@ -2,15 +2,16 @@ import { defineComponent as o } from "vue";
2
2
  import r from "../email-preview/amp/AmpToggle.vue.js";
3
3
  import t from "../email-preview/desktop-preview/EmailSizeIndicator.vue.js";
4
4
  import { useEditorStore as i } from "../../../stores/editor.js";
5
- import e from "./EditorToolbar.vue.js";
6
- import m from "./version-history/VersionHistory.vue.js";
7
- import p from "./version-history/ViewOptions.vue.js";
8
- const S = /* @__PURE__ */ o({
5
+ import e from "./AiStatusPill.vue.js";
6
+ import m from "./EditorToolbar.vue.js";
7
+ import p from "./version-history/VersionHistory.vue.js";
8
+ import s from "./version-history/ViewOptions.vue.js";
9
+ const V = /* @__PURE__ */ o({
9
10
  __name: "MiddleSlot",
10
- setup(s) {
11
- return { __sfc: !0, editorStore: i(), AmpToggle: r, EmailSizeIndicator: t, EditorToolbar: e, VersionHistory: m, VersionHistoryViewOptions: p };
11
+ setup(f) {
12
+ return { __sfc: !0, editorStore: i(), AmpToggle: r, EmailSizeIndicator: t, AiStatusPill: e, EditorToolbar: m, VersionHistory: p, VersionHistoryViewOptions: s };
12
13
  }
13
14
  });
14
15
  export {
15
- S as default
16
+ V as default
16
17
  };
@@ -0,0 +1,12 @@
1
+ import { useAiStatusStore as r } from "../stores/ai-status.js";
2
+ const o = () => {
3
+ const t = r();
4
+ return { setGenerating: (e = "") => {
5
+ t.$patch({ isGenerating: !0, tool: e });
6
+ }, clear: () => {
7
+ t.$patch({ isGenerating: !1, tool: "" });
8
+ } };
9
+ };
10
+ export {
11
+ o as useAiStatus
12
+ };
@@ -1,70 +1,79 @@
1
- import { useEmailTemplateApplier as w, resetEmailTemplateApplier as _ } from "./useEmailTemplateApplier.js";
2
- import { useToaster as I } from "./useToaster.js";
3
- import { useTranslations as P } from "./useTranslations.js";
4
- import { ToasterTypeOptions as S } from "../enums/toaster.js";
5
- import { getActivePinia as v } from "pinia";
6
- import { watch as B, onUnmounted as D } from "vue";
7
- const x = "email_template", L = "chat", M = "guido:debug:ai", R = () => {
1
+ import { useAiStatus as P } from "./useAiStatus.js";
2
+ import { useEmailTemplateApplier as v, resetEmailTemplateApplier as B } from "./useEmailTemplateApplier.js";
3
+ import { useToaster as D } from "./useToaster.js";
4
+ import { useTranslations as m } from "./useTranslations.js";
5
+ import { ToasterTypeOptions as x } from "../enums/toaster.js";
6
+ import { getActivePinia as L } from "pinia";
7
+ import { watch as M, onUnmounted as R } from "vue";
8
+ const k = "email_template", C = "chat", G = "guido:debug:ai", U = () => {
8
9
  if (typeof window > "u")
9
10
  return !1;
10
11
  try {
11
- return window.localStorage.getItem(M) === "1";
12
+ return window.localStorage.getItem(G) === "1";
12
13
  } catch {
13
14
  return !1;
14
15
  }
15
- }, H = () => {
16
- const c = v();
17
- if (!c)
16
+ }, N = () => {
17
+ const a = L();
18
+ if (!a)
18
19
  return;
19
- const l = c._s, p = l == null ? void 0 : l.get(L);
20
+ const l = a._s, p = l == null ? void 0 : l.get(C);
20
21
  if (!p)
21
22
  return;
22
- const { markPending: d, applyTemplate: f, applyTemplateDebounced: T } = w(), { showToaster: h } = I(), y = P(), A = (r, t) => {
23
- const e = y(r);
24
- return e === r ? t : e;
25
- }, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), u = R(), E = (r, t) => {
26
- u && console.debug(`[guido:cortex] msg=${r ?? "?"} type=${(t == null ? void 0 : t.type) ?? "?"}`, t);
27
- }, b = (r) => {
28
- if (r.blueprintType !== x)
23
+ const { markPending: A, applyTemplate: E, applyTemplateDebounced: h } = v(), { showToaster: y } = D(), u = P(), b = m(), w = (o, r) => {
24
+ const t = b(o);
25
+ return t === o ? r : t;
26
+ }, i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), f = U(), _ = (o, r) => {
27
+ f && console.debug(`[guido:cortex] msg=${o ?? "?"} type=${(r == null ? void 0 : r.type) ?? "?"}`, r);
28
+ }, S = (o) => {
29
+ if (o.blueprintType !== k)
29
30
  return;
30
- const t = r.blueprintId, e = r.blueprintData;
31
- if (!t || !(e != null && e.html))
31
+ const r = o.blueprintId, t = o.blueprintData;
32
+ if (!r || !(t != null && t.html))
32
33
  return;
33
- if (!r.applyRequested) {
34
- d(t);
34
+ if (!o.applyRequested) {
35
+ A(r);
35
36
  return;
36
37
  }
37
- const o = i.get(t);
38
- o === void 0 ? (i.set(t, e.html), f(t, e)) : o !== e.html && (i.set(t, e.html), T(t, e));
39
- }, s = (r) => r === void 0 || a.has(r) ? !1 : (a.add(r), h({
40
- type: S.Alert,
41
- message: A("newsletter.ai-template-failed", "AI couldn't generate the template. Please try again.")
42
- }), !0), m = B(
38
+ const e = i.get(r);
39
+ e === void 0 ? (i.set(r, t.html), E(r, t)) : e !== t.html && (i.set(r, t.html), h(r, t));
40
+ }, d = (o) => o === void 0 || c.has(o) ? !1 : (c.add(o), y({
41
+ type: x.Alert,
42
+ message: w("newsletter.ai-template-failed", "AI couldn't generate the template. Please try again.")
43
+ }), !0), I = M(
43
44
  () => p.messages,
44
- (r) => {
45
- Array.isArray(r) && r.forEach((t) => {
45
+ (o) => {
46
+ if (!Array.isArray(o))
47
+ return;
48
+ let r = null;
49
+ o.forEach((t) => {
46
50
  const e = t == null ? void 0 : t.id;
47
- (t == null ? void 0 : t.isError) === !0 && s(e) && u && console.debug(`[guido:cortex] message-level error id=${e}`, t);
48
- const o = t == null ? void 0 : t.segments;
49
- Array.isArray(o) && o.forEach((n) => {
51
+ (t == null ? void 0 : t.isError) === !0 && d(e) && f && console.debug(`[guido:cortex] message-level error id=${e}`, t);
52
+ const s = t == null ? void 0 : t.segments;
53
+ Array.isArray(s) && s.forEach((n) => {
50
54
  if (n)
51
- switch (E(e, n), n.type) {
55
+ switch (_(e, n), n.type) {
52
56
  case "blueprint":
53
- b(n);
57
+ S(n);
54
58
  break;
55
59
  case "error":
56
- s(e);
60
+ d(e);
57
61
  break;
62
+ case "tool": {
63
+ const T = n;
64
+ T.isRunning === !0 && (t == null ? void 0 : t.isError) !== !0 && (t == null ? void 0 : t.isCancelled) !== !0 && (r = T.name ?? "");
65
+ break;
66
+ }
58
67
  }
59
68
  });
60
- });
69
+ }), r !== null ? u.setGenerating(r) : u.clear();
61
70
  },
62
71
  { deep: !0, immediate: !0 }
63
72
  );
64
- D(() => {
65
- m(), i.clear(), a.clear(), _();
73
+ R(() => {
74
+ I(), i.clear(), c.clear(), u.clear(), B();
66
75
  });
67
76
  };
68
77
  export {
69
- H as useCortexBlueprintBridge
78
+ N as useCortexBlueprintBridge
70
79
  };
@@ -10,17 +10,17 @@ import { en as h } from "../config/i18n/en/index.js";
10
10
  import { ToasterTypeOptions as L } from "../enums/toaster.js";
11
11
  import { useStripoApi as $ } from "../services/stripoApi.js";
12
12
  import G from "../static/styles/customEditorStyle.css.js";
13
- import { useEditorStore as E } from "../stores/editor.js";
13
+ import { useEditorStore as C } from "../stores/editor.js";
14
14
  import { dynamicContentToMergeTags as J } from "../utils/genericUtil.js";
15
15
  import N from "../package.json.js";
16
- const ce = (C, l) => {
17
- const { features: c, template: w, isFeatureEnabled: u } = R(), { handleError: m, showToaster: b } = H(), { getToken: k, getCustomFonts: T, getSyncModulesStatus: B } = $(), { handleEvent: F } = q(), { getStripoBlocksConfig: v } = U(), V = async (s, r = [], i = !1) => {
16
+ const ce = (E, l) => {
17
+ const { features: c, template: w, isFeatureEnabled: u } = R(), { handleError: m, showToaster: b } = H(), { getToken: T, getCustomFonts: k, getSyncModulesStatus: B } = $(), { handleEvent: F } = q(), { getStripoBlocksConfig: v } = U(), V = async (s, r = [], i = !1) => {
18
18
  var g, S, y;
19
- const e = E(), { html: p, css: a } = s, { baseBlocks: o, extensions: d } = await v(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0, A = ((S = c.value) == null ? void 0 : S.modulesDisabled) ?? !1, M = ((y = w.value) == null ? void 0 : y.forceRecreate) ?? !1;
19
+ const e = C(), { html: p, css: a } = s, { baseBlocks: t, extensions: d } = await v(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0, A = ((S = c.value) == null ? void 0 : S.modulesDisabled) ?? !1, M = ((y = w.value) == null ? void 0 : y.forceRecreate) ?? !1;
20
20
  await window.UIEditor.initEditor(
21
21
  document.querySelector("#guido-editor"),
22
22
  {
23
- metadata: C,
23
+ metadata: E,
24
24
  html: p,
25
25
  css: a,
26
26
  forceRecreate: M,
@@ -42,13 +42,12 @@ const ce = (C, l) => {
42
42
  messageSettingsEnabled: !0,
43
43
  displayGmailAnnotations: !0,
44
44
  displayHiddenPreheader: !1,
45
- keepModuleStylesEnabled: !0,
46
45
  displayTitle: !1,
47
46
  displayUTM: !1,
48
47
  selectElementAfterDrop: !0,
49
48
  sameFontSizeForOutlook: !0,
50
49
  allowedScriptSourceDomains: "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com",
51
- ...o ? { baseBlocks: o } : {},
50
+ ...t ? { baseBlocks: t } : {},
52
51
  editorFonts: {
53
52
  showDefaultStandardFonts: !0,
54
53
  showDefaultNotStandardFonts: !0,
@@ -62,32 +61,32 @@ const ce = (C, l) => {
62
61
  )
63
62
  }
64
63
  ],
65
- async onTokenRefreshRequest(t) {
64
+ async onTokenRefreshRequest(o) {
66
65
  try {
67
- const n = await k();
68
- t(n);
66
+ const n = await T();
67
+ o(n);
69
68
  } catch (n) {
70
69
  m(n, "Failed to refresh token");
71
70
  }
72
71
  },
73
72
  onTemplateLoaded() {
74
73
  try {
75
- const { importCss: t } = x(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: P } = I(), { injectFullStory: D } = O();
76
- t(), n(), D(), P(), l.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
74
+ const { importCss: o } = x(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: P } = I(), { injectFullStory: D } = O();
75
+ o(), n(), D(), P(), l.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
77
76
  e.hasChanges = !1;
78
77
  }, 1e3);
79
- } catch (t) {
80
- m(t, "Failed to load custom interface appearance");
78
+ } catch (o) {
79
+ m(o, "Failed to load custom interface appearance");
81
80
  }
82
81
  },
83
- onCodeEditorVisibilityChanged(t) {
84
- e.isCodeEditorOpen = t;
82
+ onCodeEditorVisibilityChanged(o) {
83
+ e.isCodeEditorOpen = o;
85
84
  },
86
- onEditorVisualModeChanged(t) {
87
- e.editorVisualMode = t.toLowerCase();
85
+ onEditorVisualModeChanged(o) {
86
+ e.editorVisualMode = o.toLowerCase();
88
87
  },
89
- onVersionHistoryVisibilityChanged(t) {
90
- e.isVersionHistoryOpen = t;
88
+ onVersionHistoryVisibilityChanged(o) {
89
+ e.isVersionHistoryOpen = o;
91
90
  },
92
91
  onDataChanged() {
93
92
  e.hasChanges = !0;
@@ -108,19 +107,19 @@ const ce = (C, l) => {
108
107
  Promise.resolve(s()).then(r, i);
109
108
  return;
110
109
  }
111
- const e = N.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, o = document.createElement("script");
112
- o.id = "UiEditorScript", o.type = "module", o.src = a, o.onload = () => {
110
+ const e = N.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, t = document.createElement("script");
111
+ t.id = "UiEditorScript", t.type = "module", t.src = a, t.onload = () => {
113
112
  Promise.resolve(s()).then(r, i);
114
- }, o.onerror = () => {
113
+ }, t.onerror = () => {
115
114
  i(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
116
- }, document.body.appendChild(o);
115
+ }, document.body.appendChild(t);
117
116
  });
118
117
  return { initPlugin: async (s) => {
119
- const r = E();
118
+ const r = C();
120
119
  try {
121
120
  await _(async () => {
122
121
  const [i, e] = await Promise.all([
123
- T(),
122
+ k(),
124
123
  B()
125
124
  ]);
126
125
  r.syncModulesEnabled = e, await V(s, i, e);
@@ -1,189 +1,176 @@
1
- import { useConfig as q } from "../../../composables/useConfig.js";
2
- import { useRecommendation as C } from "../../../composables/useRecommendation.js";
3
- import { CSS_CLASS_RECO_BUTTON as E } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
- import { useRecommendationExtensionStore as w } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { isIgnoredRecommendationBlock as P } from "./recommendationIgnoreUtils.js";
6
- function f(t, o, e, n, s = "") {
7
- const i = `{{${s}${t}_${o}_${e}}}`, r = `{{${s}${t}_${o}_currency}}`;
8
- return n === "before" ? `${r} ${i}` : `${i} ${r}`;
1
+ import { useConfig as _ } from "../../../composables/useConfig.js";
2
+ import { useRecommendation as q } from "../../../composables/useRecommendation.js";
3
+ import { CSS_CLASS_RECO_BUTTON as C } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
+ import { useRecommendationExtensionStore as E } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { isIgnoredRecommendationBlock as w } from "./recommendationIgnoreUtils.js";
6
+ function P(t, r, e, n, s = "") {
7
+ const c = `{{${s}${t}_${r}_${e}}}`, o = `{{${s}${t}_${r}_currency}}`;
8
+ return n === "before" ? `${o} ${c}` : `${c} ${o}`;
9
9
  }
10
10
  function m(t) {
11
- let o = t;
12
- for (; o.children.length === 1; )
13
- [o] = o.children;
14
- return o;
11
+ let r = t;
12
+ for (; r.children.length === 1; )
13
+ [r] = r.children;
14
+ return r;
15
15
  }
16
- function h(t, o, e, n, s, i) {
17
- switch (o) {
16
+ function b(t, r, e, n, s, c) {
17
+ switch (r) {
18
18
  case "productImage": {
19
- const r = t.querySelector("img");
20
- r && (r.setAttribute("src", `{{${i}${e}_${n}_image_url}}`), r.setAttribute("alt", `{{${i}${e}_${n}_name}}`));
21
- const c = t.querySelector("a");
22
- c && (c.setAttribute("href", `{{${i}${e}_${n}_url}}`), c.classList.add(E));
19
+ const o = t.querySelector("img");
20
+ o && (o.setAttribute("src", `{{${c}${e}_${n}_image_url}}`), o.setAttribute("alt", `{{${c}${e}_${n}_name}}`));
21
+ const i = t.querySelector("a");
22
+ i && (i.setAttribute("href", `{{${c}${e}_${n}_url}}`), i.classList.add(C));
23
23
  break;
24
24
  }
25
25
  case "productName": {
26
- const r = t.querySelector("p");
27
- r && (m(r).textContent = `{{${i}${e}_${n}_name}}`);
28
- break;
29
- }
30
- case "productPrice": {
31
- const r = t.querySelector(".product-price p") ?? t.querySelector("p");
32
- r && (m(r).textContent = f(
33
- e,
34
- n,
35
- "price",
36
- s,
37
- i
38
- ));
39
- const c = t.querySelector(".product-old-price p");
40
- c && (m(c).textContent = f(
41
- e,
42
- n,
43
- "original_price",
44
- s,
45
- i
46
- ));
26
+ const o = t.querySelector("p");
27
+ o && (m(o).textContent = `{{${c}${e}_${n}_name}}`);
47
28
  break;
48
29
  }
30
+ // Inline mode ("Move to next line" OFF) merges BOTH prices into one row
31
+ // anchored on whichever attribute comes first in the composition, so
32
+ // substitute by cell content, not by the row's anchor (SD-145161).
33
+ case "productPrice":
49
34
  case "productOldPrice": {
50
- const r = t.querySelector("p");
51
- r && (m(r).textContent = f(
52
- e,
53
- n,
54
- "original_price",
55
- s,
56
- i
57
- ));
35
+ const o = (d, l) => {
36
+ d && (m(d).textContent = P(
37
+ e,
38
+ n,
39
+ l,
40
+ s,
41
+ c
42
+ ));
43
+ }, i = t.querySelector(".product-price p"), a = t.querySelector(".product-old-price p"), u = !i && !a ? t.querySelector("p") : null;
44
+ o(i ?? (r === "productPrice" ? u : null), "price"), o(a ?? (r === "productOldPrice" ? u : null), "original_price");
58
45
  break;
59
46
  }
60
47
  case "productButton": {
61
- const r = t.querySelector("a");
62
- r && r.setAttribute("href", `{{${i}${e}_${n}_url}}`);
48
+ const o = t.querySelector("a");
49
+ o && o.setAttribute("href", `{{${c}${e}_${n}_url}}`);
63
50
  break;
64
51
  }
65
52
  case "productOmnibusPrice": {
66
- const r = t.querySelector(".omnibus-price-value");
67
- if (r) {
68
- r.textContent = `{{${i}${e}_${n}_omnibus_price}}`;
69
- const c = r.closest("p");
70
- c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
53
+ const o = t.querySelector(".omnibus-price-value");
54
+ if (o) {
55
+ o.textContent = `{{${c}${e}_${n}_omnibus_price}}`;
56
+ const i = o.closest("p");
57
+ i && (i.setAttribute("product-attr", "omnibus_price"), i.setAttribute("composition", "true"));
71
58
  }
72
59
  break;
73
60
  }
74
61
  case "productOmnibusDiscount": {
75
- const r = t.querySelector(".omnibus-discount-value");
76
- if (r) {
77
- r.textContent = `{{${i}${e}_${n}_omnibus_discount}}`;
78
- const c = r.closest("p");
79
- c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
62
+ const o = t.querySelector(".omnibus-discount-value");
63
+ if (o) {
64
+ o.textContent = `{{${c}${e}_${n}_omnibus_discount}}`;
65
+ const i = o.closest("p");
66
+ i && (i.setAttribute("product-attr", "omnibus_discount"), i.setAttribute("composition", "true"));
80
67
  }
81
68
  break;
82
69
  }
83
70
  default: {
84
- const r = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
85
- if (r) {
86
- const c = r.getAttribute("product-attr"), l = r.querySelector("p");
87
- l && (m(l).textContent = `{{${i}${e}_${n}_${c}}}`);
71
+ const o = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
72
+ if (o) {
73
+ const i = o.getAttribute("product-attr"), a = o.querySelector("p");
74
+ a && (m(a).textContent = `{{${c}${e}_${n}_${i}}}`);
88
75
  }
89
76
  break;
90
77
  }
91
78
  }
92
79
  }
93
- function R(t, o, e, n) {
94
- t.querySelectorAll(".recommendation-product-row").forEach((i, r) => {
95
- i.querySelectorAll("[data-attribute-type]").forEach((l) => {
96
- const u = l.getAttribute("data-attribute-type") || "", p = l.querySelectorAll(".attribute-cell");
97
- p.length > 0 ? p.forEach((a) => {
98
- h(a, u, o, r, e, n);
99
- }) : h(l, u, o, r, e, n);
80
+ function R(t, r, e, n) {
81
+ t.querySelectorAll(".recommendation-product-row").forEach((c, o) => {
82
+ c.querySelectorAll("[data-attribute-type]").forEach((a) => {
83
+ const u = a.getAttribute("data-attribute-type") || "", d = a.querySelectorAll(".attribute-cell");
84
+ d.length > 0 ? d.forEach((l) => {
85
+ b(l, u, r, o, e, n);
86
+ }) : b(a, u, r, o, e, n);
100
87
  });
101
88
  });
102
89
  }
103
- function W(t, o, e, n) {
90
+ function W(t, r, e, n) {
104
91
  const s = t.querySelectorAll(".recommendation-product-row");
105
92
  if (!s.length)
106
93
  return;
107
- const [i] = s, r = i.querySelector("[data-attribute-type]"), c = r ? r.querySelectorAll(".attribute-cell").length : 1;
108
- s.forEach((l, u) => {
109
- l.querySelectorAll("[data-attribute-type]").forEach((a) => {
110
- const d = a.getAttribute("data-attribute-type") || "";
111
- a.querySelectorAll(".attribute-cell").forEach((S, _) => {
112
- const g = u * c + _;
113
- h(S, d, o, g, e, n);
94
+ const [c] = s, o = c.querySelector("[data-attribute-type]"), i = o ? o.querySelectorAll(".attribute-cell").length : 1;
95
+ s.forEach((a, u) => {
96
+ a.querySelectorAll("[data-attribute-type]").forEach((l) => {
97
+ const p = l.getAttribute("data-attribute-type") || "";
98
+ l.querySelectorAll(".attribute-cell").forEach(($, S) => {
99
+ const g = u * i + S;
100
+ b($, p, r, g, e, n);
114
101
  });
115
102
  });
116
103
  });
117
104
  }
118
- function v(t, o, e, n) {
119
- t.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
120
- W(i, o, e, n);
105
+ function v(t, r, e, n) {
106
+ t.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
107
+ W(c, r, e, n);
121
108
  });
122
109
  }
123
- function O(t, o, e) {
110
+ function O(t, r, e) {
124
111
  const n = t.getAttribute("data-layout") || "grid", s = t.getAttribute("currency-alignment") || "after";
125
- n === "list" ? R(t, o, s, e) : v(t, o, s, e);
112
+ n === "list" ? R(t, r, s, e) : v(t, r, s, e);
126
113
  }
127
- function b(t, o, e) {
128
- const n = new RegExp(`${o}\\s*:\\s*(\\d+)\\s*px`, "i"), s = t.match(n);
114
+ function f(t, r, e) {
115
+ const n = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), s = t.match(n);
129
116
  return s ? parseInt(s[1]) : e;
130
117
  }
131
- function A(t) {
132
- const o = t.trim();
133
- return o.endsWith("%") ? parseFloat(o) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(o) && parseInt(o) > 0;
118
+ function y(t) {
119
+ const r = t.trim();
120
+ return r.endsWith("%") ? parseFloat(r) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(r) && parseInt(r) > 0;
134
121
  }
135
- function $(t) {
136
- const o = t.getAttribute("width");
137
- if (o && A(o))
138
- return o.trim();
122
+ function A(t) {
123
+ const r = t.getAttribute("width");
124
+ if (r && y(r))
125
+ return r.trim();
139
126
  const e = (t.getAttribute("style") || "").match(/(?:^|[;\s])width\s*:\s*(\d+(?:\.\d+)?(?:px|%))/i);
140
- return e && A(e[1]) ? e[1] : null;
127
+ return e && y(e[1]) ? e[1] : null;
141
128
  }
142
- function T(t, o) {
129
+ function M(t, r) {
143
130
  let e = t.parentElement;
144
- for (; e && e !== o; ) {
145
- if (e.tagName === "TD" && $(e))
131
+ for (; e && e !== r; ) {
132
+ if (e.tagName === "TD" && A(e))
146
133
  return e;
147
134
  e = e.parentElement;
148
135
  }
149
136
  return null;
150
137
  }
151
- function M(t) {
152
- const o = t.getAttribute("style") || "", e = b(o, "width", 600), n = b(o, "padding", 0) * 2, s = Math.max(0, e - n);
153
- s !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
154
- if (i.hasAttribute("width"))
138
+ function T(t) {
139
+ const r = t.getAttribute("style") || "", e = f(r, "width", 600), n = f(r, "padding", 0) * 2, s = Math.max(0, e - n);
140
+ s !== 0 && t.querySelectorAll("img.adapt-img").forEach((c) => {
141
+ if (c.hasAttribute("width"))
155
142
  return;
156
- const r = T(i, t);
157
- if (!r)
143
+ const o = M(c, t);
144
+ if (!o)
158
145
  return;
159
- const c = $(r), l = b(r.getAttribute("style") || "", "padding", 0) * 2, u = c.endsWith("%") ? Math.floor(s * parseFloat(c) / 100) : parseInt(c), p = Math.max(1, u - l);
160
- i.setAttribute("width", String(p));
161
- const a = i.getAttribute("style") || "";
162
- if (!/\bwidth\s*:\s*\d/i.test(a)) {
163
- const d = a && !a.trim().endsWith(";") ? "; " : "";
164
- i.setAttribute("style", `${a}${d}width: ${p}px`);
146
+ const i = A(o), a = f(o.getAttribute("style") || "", "padding", 0) * 2, u = i.endsWith("%") ? Math.floor(s * parseFloat(i) / 100) : parseInt(i), d = Math.max(1, u - a);
147
+ c.setAttribute("width", String(d));
148
+ const l = c.getAttribute("style") || "";
149
+ if (!/\bwidth\s*:\s*\d/i.test(l)) {
150
+ const p = l && !l.trim().endsWith(";") ? "; " : "";
151
+ c.setAttribute("style", `${l}${p}width: ${d}px`);
165
152
  }
166
153
  });
167
154
  }
168
- function B(t, o) {
155
+ function B(t, r) {
169
156
  const e = t.match(/<!DOCTYPE[^>]*>/i);
170
157
  return (e ? `${e[0]}
171
- ` : "") + o.documentElement.outerHTML;
158
+ ` : "") + r.documentElement.outerHTML;
172
159
  }
173
160
  function G(t) {
174
- const o = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(o, "text/html"), n = e.querySelectorAll(".recommendation-block-v2");
161
+ const r = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(r, "text/html"), n = e.querySelectorAll(".recommendation-block-v2");
175
162
  if (!n.length)
176
163
  return t;
177
- const { buildCampaignUrl: s } = C(), i = w();
178
- i.recommendationCampaignUrls = {};
179
- const { isFeatureEnabled: r } = q(), c = r("liquidSyntax") ? "reco_" : "";
164
+ const { buildCampaignUrl: s } = q(), c = E();
165
+ c.recommendationCampaignUrls = {};
166
+ const { isFeatureEnabled: o } = _(), i = o("liquidSyntax") ? "reco_" : "";
180
167
  return n.forEach((u) => {
181
- var a, d;
182
- const p = u.getAttribute("recommendation-id");
183
- p && ((a = u.parentNode) == null || a.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((y) => y.remove()), s(p), P(u) || O(u, p, c), M(u));
184
- }), B(o, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
168
+ var l, p;
169
+ const d = u.getAttribute("recommendation-id");
170
+ d && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((h) => h.remove()), s(d), w(u) || O(u, d, i), T(u));
171
+ }), B(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
185
172
  }
186
173
  export {
187
- f as formatPriceVariable,
174
+ P as formatPriceVariable,
188
175
  G as prepareRecommendationBlocks
189
176
  };