@useinsider/guido 3.1.1 → 3.2.0-beta.22a0c4c

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 (89) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +66 -54
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +91 -81
  5. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +7 -7
  6. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +12 -20
  7. package/dist/components/organisms/header/EditorActions.vue.js +2 -2
  8. package/dist/components/organisms/header/EditorActions.vue2.js +51 -36
  9. package/dist/components/organisms/header/RightSlot.vue.js +10 -10
  10. package/dist/components/organisms/header/RightSlot.vue2.js +16 -13
  11. package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +18 -17
  12. package/dist/composables/useHtmlCompiler.js +23 -21
  13. package/dist/composables/useHtmlValidator.js +40 -38
  14. package/dist/composables/usePreviewMode.js +20 -16
  15. package/dist/composables/useSave.js +23 -15
  16. package/dist/composables/useStripo.js +44 -41
  17. package/dist/composables/validators/useLiquidValidator.js +42 -0
  18. package/dist/config/compiler/liquidCompilerRules.js +15 -0
  19. package/dist/config/compiler/recommendationCompilerRules.js +158 -44
  20. package/dist/config/compiler/unsubscribeCompilerRules.js +37 -37
  21. package/dist/config/compiler/utils/recommendationCompilerUtils.js +52 -46
  22. package/dist/config/i18n/en/tooltips.json.js +2 -1
  23. package/dist/config/migrator/checkboxMigrator.js +5 -3
  24. package/dist/config/migrator/radioButtonMigrator.js +14 -12
  25. package/dist/config/migrator/recommendationMigrator.js +1 -1
  26. package/dist/enums/extensions/recommendationBlock.js +14 -11
  27. package/dist/enums/recommendation.js +2 -2
  28. package/dist/extensions/Blocks/CouponBlock/template.js +24 -13
  29. package/dist/extensions/Blocks/Recommendation/block.js +1 -1
  30. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  31. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +27 -11
  32. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +185 -172
  33. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +21 -18
  34. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +99 -0
  35. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +6 -6
  36. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +3 -1
  37. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +95 -93
  38. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +27 -57
  39. package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +14 -0
  40. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +75 -73
  41. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +18 -17
  42. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +29 -25
  43. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +7 -5
  44. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -29
  45. package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -7
  46. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +3 -1
  47. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -21
  48. package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -50
  49. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +6 -6
  50. package/dist/extensions/Blocks/Unsubscribe/settingsPanel.js +16 -17
  51. package/dist/extensions/DynamicContent/dynamic-content.js +17 -12
  52. package/dist/guido.css +1 -1
  53. package/dist/services/recommendationApi.js +15 -15
  54. package/dist/services/stripoApi.js +9 -9
  55. package/dist/services/templateLibraryApi.js +48 -46
  56. package/dist/src/@types/config/index.d.ts +1 -1
  57. package/dist/src/@types/config/schemas.d.ts +28 -0
  58. package/dist/src/@types/config/types.d.ts +3 -1
  59. package/dist/src/@types/generic.d.ts +0 -1
  60. package/dist/src/@types/save-as-template.d.ts +1 -0
  61. package/dist/src/composables/useConfig.d.ts +12 -0
  62. package/dist/src/composables/validators/useLiquidValidator.d.ts +3 -0
  63. package/dist/src/config/compiler/liquidCompilerRules.d.ts +2 -0
  64. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
  65. package/dist/src/enums/extensions/recommendationBlock.d.ts +3 -0
  66. package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +2 -0
  67. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +1 -0
  68. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  69. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +5 -0
  70. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +5 -0
  71. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +3 -0
  72. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.d.ts +35 -0
  73. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +3 -20
  74. package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +29 -0
  75. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  76. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  77. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +20 -3
  78. package/dist/src/services/templateLibraryApi.d.ts +1 -1
  79. package/dist/src/stores/config.d.ts +108 -0
  80. package/dist/src/stores/preview.d.ts +3 -0
  81. package/dist/src/utils/genericUtil.d.ts +1 -1
  82. package/dist/src/utils/htmlCompiler.d.ts +2 -1
  83. package/dist/static/styles/base.css.js +7 -2
  84. package/dist/stores/preview.js +4 -3
  85. package/dist/utils/genericUtil.js +42 -20
  86. package/dist/utils/htmlCompiler.js +48 -41
  87. package/dist/utils/templatePreparation.js +36 -25
  88. package/dist/utils/tooltipUtils.js +4 -5
  89. package/package.json +2 -2
@@ -1,42 +1,42 @@
1
- import { useActionsApi as A } from "./useActionsApi.js";
2
- import { useBlocksConfig as F } from "./useBlocksConfig.js";
3
- import { useConfig as D } from "./useConfig.js";
4
- import { useCustomInterfaceAppearance as I } from "./useCustomInterfaceAppearance.js";
5
- import { useStripoEventHandler as P } from "./useStripoEventHandler.js";
6
- import { useToaster as U } from "./useToaster.js";
7
- import { localePatch as R } from "../config/i18n/index.js";
8
- import { displayConditions as H } from "../enums/displayConditions.js";
9
- import { useStripoApi as O } from "../services/stripoApi.js";
10
- import q from "../static/styles/customEditorStyle.css.js";
11
- import { useEditorStore as S } from "../stores/editor.js";
12
- import { dynamicContentToMergeTags as x } from "../utils/genericUtil.js";
13
- import L from "../package.json.js";
14
- const oe = (C, c) => {
15
- const { features: l, template: E } = D(), { handleError: u } = U(), { getToken: h, getCustomFonts: w, getSyncModulesStatus: b } = O(), { handleEvent: k } = P(), { getStripoBlocksConfig: T } = F(), V = async (i, n = [], r = !1) => {
16
- var f, g, y;
17
- const e = S(), { html: m, css: a } = i, { baseBlocks: o, extensions: d } = await T(), p = ((f = l.value) == null ? void 0 : f.displayConditions) ?? !0, B = ((g = l.value) == null ? void 0 : g.modulesDisabled) ?? !1, v = ((y = E.value) == null ? void 0 : y.forceRecreate) ?? !1;
1
+ import { useActionsApi as F } from "./useActionsApi.js";
2
+ import { useBlocksConfig as D } from "./useBlocksConfig.js";
3
+ import { useConfig as I } from "./useConfig.js";
4
+ import { useCustomInterfaceAppearance as P } from "./useCustomInterfaceAppearance.js";
5
+ import { useStripoEventHandler as U } from "./useStripoEventHandler.js";
6
+ import { useToaster as R } from "./useToaster.js";
7
+ import { localePatch as q } from "../config/i18n/index.js";
8
+ import { displayConditions as x } from "../enums/displayConditions.js";
9
+ import { useStripoApi as H } from "../services/stripoApi.js";
10
+ import O from "../static/styles/customEditorStyle.css.js";
11
+ import { useEditorStore as C } from "../stores/editor.js";
12
+ import { dynamicContentToMergeTags as L } from "../utils/genericUtil.js";
13
+ import $ from "../package.json.js";
14
+ const ie = (E, c) => {
15
+ const { features: l, template: h, isFeatureEnabled: u } = I(), { handleError: m } = R(), { getToken: b, getCustomFonts: w, getSyncModulesStatus: k } = H(), { handleEvent: T } = U(), { getStripoBlocksConfig: V } = D(), _ = async (i, n = [], r = !1) => {
16
+ var g, y, S;
17
+ const e = C(), { html: p, css: a } = i, { baseBlocks: o, extensions: d } = await V(), f = ((g = l.value) == null ? void 0 : g.displayConditions) ?? !0, v = ((y = l.value) == null ? void 0 : y.modulesDisabled) ?? !1, M = ((S = h.value) == null ? void 0 : S.forceRecreate) ?? !1;
18
18
  window.UIEditor.initEditor(
19
19
  document.querySelector("#guido-editor"),
20
20
  {
21
- metadata: C,
22
- html: m,
21
+ metadata: E,
22
+ html: p,
23
23
  css: a,
24
- forceRecreate: v,
24
+ forceRecreate: M,
25
25
  locale: "en",
26
26
  undoButtonSelector: "#guido__undo-button",
27
27
  redoButtonSelector: "#guido__redo-button",
28
28
  mobileViewButtonSelector: ".guido__view-option-selection-mobile",
29
29
  desktopViewButtonSelector: ".guido__view-option-selection-desktop",
30
30
  codeEditorButtonSelector: "#guido__code-button",
31
- customAppearanceMergetags: !0,
31
+ customAppearanceMergetags: !u("liquidSyntax"),
32
32
  customAppearanceMergetagsBorderColor: "#f1f3fe",
33
33
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
34
- customViewStyles: q,
35
- conditionsEnabled: p,
36
- customConditionsEnabled: p,
37
- conditionCategories: H,
34
+ customViewStyles: O,
35
+ conditionsEnabled: f,
36
+ customConditionsEnabled: f,
37
+ conditionCategories: x,
38
38
  enableXSSSecurity: !0,
39
- modulesDisabled: B,
39
+ modulesDisabled: v,
40
40
  syncModulesEnabled: r,
41
41
  messageSettingsEnabled: !0,
42
42
  displayGmailAnnotations: !0,
@@ -52,25 +52,28 @@ const oe = (C, c) => {
52
52
  },
53
53
  mergeTags: [
54
54
  {
55
- entries: x(c.preselectedDynamicContentList)
55
+ entries: L(
56
+ c.preselectedDynamicContentList,
57
+ u("liquidSyntax")
58
+ )
56
59
  }
57
60
  ],
58
61
  async onTokenRefreshRequest(t) {
59
62
  try {
60
- const s = await h();
63
+ const s = await b();
61
64
  t(s);
62
65
  } catch (s) {
63
- u(s, "Failed to refresh token");
66
+ m(s, "Failed to refresh token");
64
67
  }
65
68
  },
66
69
  onTemplateLoaded() {
67
70
  try {
68
- const { importCss: t } = I(), { activateCustomViewStyles: s, updateTimerInClonedTemplate: M } = A();
69
- t(), s(), M(), c.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
71
+ const { importCss: t } = P(), { activateCustomViewStyles: s, updateTimerInClonedTemplate: A } = F();
72
+ t(), s(), A(), c.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
70
73
  e.hasChanges = !1;
71
74
  }, 1e3);
72
75
  } catch (t) {
73
- u(t, "Failed to load custom interface appearance");
76
+ m(t, "Failed to load custom interface appearance");
74
77
  }
75
78
  },
76
79
  onCodeEditorVisibilityChanged(t) {
@@ -85,23 +88,23 @@ const oe = (C, c) => {
85
88
  onDataChanged() {
86
89
  e.hasChanges = !0;
87
90
  },
88
- onEvent: k,
91
+ onEvent: T,
89
92
  ignoreClickOutsideSelectors: [
90
93
  "#guido-dynamic-content-modal",
91
94
  ".in-on-board-wrapper",
92
95
  ".in-drawer__container"
93
96
  ],
94
97
  extensions: d,
95
- localePatch: R
98
+ localePatch: q
96
99
  }
97
100
  );
98
- }, _ = (i) => new Promise((n, r) => {
101
+ }, B = (i) => new Promise((n, r) => {
99
102
  var d;
100
103
  if (document.getElementById("UiEditorScript")) {
101
104
  i(), n();
102
105
  return;
103
106
  }
104
- const e = L.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");
107
+ const e = $.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");
105
108
  o.id = "UiEditorScript", o.type = "module", o.src = a, o.onload = () => {
106
109
  i(), n();
107
110
  }, o.onerror = () => {
@@ -109,15 +112,15 @@ const oe = (C, c) => {
109
112
  }, document.body.appendChild(o);
110
113
  });
111
114
  return { initPlugin: async (i) => {
112
- await _(async () => {
113
- const n = S(), [r, e] = await Promise.all([
115
+ await B(async () => {
116
+ const n = C(), [r, e] = await Promise.all([
114
117
  w(),
115
- b()
118
+ k()
116
119
  ]);
117
- n.syncModulesEnabled = e, await V(i, r, e);
120
+ n.syncModulesEnabled = e, await _(i, r, e);
118
121
  });
119
122
  } };
120
123
  };
121
124
  export {
122
- oe as useStripo
125
+ ie as useStripo
123
126
  };
@@ -0,0 +1,42 @@
1
+ import { ToasterTypeOptions as a } from "../../enums/toaster.js";
2
+ import { base64EncodeWithSpecialChars as u } from "../../utils/base64.js";
3
+ import { useHttp as d } from "../useHttp.js";
4
+ import { useToaster as c } from "../useToaster.js";
5
+ import { useTranslations as p } from "../useTranslations.js";
6
+ const v = () => {
7
+ const { post: i } = d(), { showToaster: e } = c(), s = p();
8
+ return { validateLiquidSyntax: async (o) => {
9
+ try {
10
+ const t = await i("/newsletter/contents/validate-syntax", [{
11
+ identifier: "default",
12
+ syntax: "liquid",
13
+ contents: {
14
+ subject: null,
15
+ preheader: null,
16
+ html: u(o),
17
+ ampHtml: null
18
+ }
19
+ }]);
20
+ if (!Array.isArray(t.data)) {
21
+ const l = t.data;
22
+ return e({
23
+ type: a.Warning,
24
+ message: l.message ?? s("journey-builder.liquid-validation-failed")
25
+ }), !1;
26
+ }
27
+ const [r] = t.data, n = Object.values((r == null ? void 0 : r.errors) ?? {});
28
+ return n.length ? (e({
29
+ type: a.Warning,
30
+ message: n[0].replace(/^line \d+:\s*/, "")
31
+ }), !1) : !0;
32
+ } catch {
33
+ return e({
34
+ type: a.Alert,
35
+ message: s("journey-builder.liquid-validation-failed")
36
+ }), !1;
37
+ }
38
+ } };
39
+ };
40
+ export {
41
+ v as useLiquidValidator
42
+ };
@@ -0,0 +1,15 @@
1
+ import { COUPON_PLACEHOLDER_LIQUID as e, COUPON_PLACEHOLDER_DEFAULT as i } from "../../extensions/Blocks/CouponBlock/template.js";
2
+ const o = [
3
+ {
4
+ id: "liquid-coupon-code",
5
+ description: "Replace legacy coupon placeholder with liquid syntax",
6
+ type: "replace",
7
+ search: i,
8
+ replacement: e,
9
+ replaceAll: !0,
10
+ priority: 50
11
+ }
12
+ ];
13
+ export {
14
+ o as liquidCompilerRules
15
+ };
@@ -1,18 +1,18 @@
1
- import { useRecommendation as f } from "../../composables/useRecommendation.js";
2
- import { DUMMY_IMAGE_MAPPINGS as P, REGEX as m, VerticalOrientation as g, CSS as e, ATTRIBUTES as a, CONDITIONS as A, HTML as h } from "../../enums/recommendation.js";
3
- import { prepareRecommendationBlocks as D } from "./utils/recommendationCompilerUtils.js";
4
- const G = [
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: (s) => {
10
- let t = s;
11
- return Object.entries(P).forEach(([, l]) => {
12
- Object.entries(l).forEach(([n, o]) => {
13
- t = t.replaceAll(o, `{{${n}}}`);
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
- }), t;
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: (s) => {
33
- const { calculateCardWidth: t, getRecommendationCampaignData: l } = f();
34
- let n = s;
35
- const o = n.match(m.ID);
36
- if (o) {
37
- const d = [];
38
- if (o.forEach((c) => {
39
- const E = /recommendation-id="(.*?)"/i.exec(c), I = E ? E[1].trim() : "", p = l(I);
40
- p.textTrimming && p.orientation === g && d.push(t(p));
41
- }), d.length) {
42
- const c = `width:${Math.min(...d)}px!important;`;
43
- n = n.replace(e.REGULAR_NAME_HEIGHT, `${e.TRIMMED_NAME_HEIGHT} ${c} ${e.ELLIPSIS}`).replace(e.REGULAR_NAME_CONTAINER_HEIGHT, e.TRIMMED_NAME_CONTAINER_CSS).replace(e.RESPONSIVE_NAME_SIZE, `${e.RESPONSIVE_NAME_HEIGHT} ${c} ${e.ELLIPSIS}`).replace(e.RESPONSIVE_NAME_CONTAINER_HEIGHT, e.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
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 n;
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: (s) => D(s),
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: (s) => {
62
- let t = s;
63
- const l = t.match(m.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: n } = f();
64
- return l !== null && l.forEach((o) => {
65
- const d = o.match(m.CUSTOM_FIELD);
66
- if (!d)
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 [c] = d, E = c.match(m.CUSTOM_FIELD_INDEXES_PART), I = c.match(m.CUSTOM_FIELD_NAME_PART), p = o.match(m.ATTRIBUTE_PARAGRAPH_START_TAG);
69
- if (!E || !I || !p)
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 [u] = E, [R] = I, [_] = p, T = R.substring(1, R.length - 2), S = _.match(m.COMPOSITION) !== null;
72
- let i = c;
73
- if (S) {
74
- const $ = u.substring(2, u.length - 3), r = n($);
75
- T === a.OMNIBUS_PRICE && (r.priceBeforeTextValue && (i = `${r.priceBeforeTextValue}${i}`), r.priceAfterTextValue && (i = `${i}${r.priceAfterTextValue}`)), T === a.OMNIBUS_DISCOUNT && (r.discountBeforeTextValue && (i = `${r.discountBeforeTextValue}${i}`), r.discountAfterTextValue && (i = `${i}${r.discountAfterTextValue}`));
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 N = u.substring(2);
78
- let M = "";
79
- T in A.IF && (M = A.IF[T].replaceAll(`{${a.DISCOUNT}}`, `${N}${a.DISCOUNT}`).replaceAll(`{${a.OMNIBUS_DISCOUNT}}`, `${N}${a.OMNIBUS_DISCOUNT}`).replaceAll(`{${a.OMNIBUS_PRICE}}`, `${N}${a.OMNIBUS_PRICE}`));
80
- const O = `${_}${i}${h.PARAGRAPH_END_TAG}`, C = `${M}${S ? O : o}${A.ELSE}${_}${h.PARAGRAPH_END_TAG}${A.END_IF}`;
81
- t = t.replace(o, C);
82
- }), t;
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
- G as recommendationCompilerRules
202
+ w as recommendationCompilerRules
89
203
  };
@@ -1,41 +1,41 @@
1
- import { usePartner as N } from "../../composables/usePartner.js";
2
- import { LINK_REGEXES as l, LINK_TYPES as S, INSIDER_ID as R, URLS as _ } from "../../enums/unsubscribe.js";
3
- import { parsePageList as U } from "../../extensions/Blocks/Unsubscribe/utils/utils.js";
4
- import { useConfigStore as B } from "../../stores/config.js";
5
- import { useDynamicContentStore as y } from "../../stores/dynamic-content.js";
6
- import { useUnsubscribeStore as L } from "../../stores/unsubscribe.js";
7
- const D = [
1
+ import { usePartner as y } from "../../composables/usePartner.js";
2
+ import { LINK_REGEXES as p, LINK_TYPES as S, INSIDER_ID as m, URLS as R } from "../../enums/unsubscribe.js";
3
+ import { parsePageList as I } from "../../extensions/Blocks/Unsubscribe/utils/utils.js";
4
+ import { useConfigStore as N } from "../../stores/config.js";
5
+ import { useDynamicContentStore as U } from "../../stores/dynamic-content.js";
6
+ import { useUnsubscribeStore as C } from "../../stores/unsubscribe.js";
7
+ const G = [
8
8
  {
9
9
  id: "add-unsubscribe-link-values",
10
10
  description: "Adding unsubscribe link values",
11
11
  type: "custom",
12
12
  processor: (t) => {
13
- const { getPartnerName: i } = N(), c = B(), n = y(), u = L(), a = c.variationId;
13
+ const { getPartnerName: i } = y(), o = N(), s = U(), d = C(), a = o.variationId;
14
14
  if (!a)
15
15
  return t;
16
16
  let e = t;
17
- const r = `/${i()}/email/${a}?user={{iid}}`;
18
- return new DOMParser().parseFromString(e, "text/html").querySelectorAll(".unsubscribe-block-v2[data-unsubscribe-page-list]").forEach((p) => {
19
- var g;
20
- const m = p.getAttribute("data-unsubscribe-page-list");
21
- if (!m)
17
+ const r = `/${i()}/email/${a}?user={{iid}}`, E = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".unsubscribe-block-v2[data-unsubscribe-page-list]");
18
+ let c = !1, l = !1;
19
+ return E.forEach((f) => {
20
+ var b;
21
+ const u = f.getAttribute("data-unsubscribe-page-list");
22
+ if (!u)
22
23
  return;
23
- const I = U(m), d = ((g = u.templates) == null ? void 0 : g.filter(
24
- (o) => I.includes(o.id)
25
- )) ?? [], E = d.some((o) => o.type === S.UNSUBSCRIBE_LINK_TYPE), b = d.some((o) => o.type === S.PREFERENCES_LINK_TYPE), f = p.outerHTML;
26
- let s = f;
27
- (E || b) && n.selectedDynamicContentList.push({
28
- text: R,
29
- value: R,
30
- fallback: ""
31
- }), E && (s = s.replace(
32
- l.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
33
- _.UNSUBSCRIBE_URL + r
34
- )), b && (s = s.replace(
35
- l.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
36
- _.PREFERENCES_URL + r
37
- )), s = s.replace(l.UNSUBSCRIBE_LINK_REGEX, ""), e = e.replace(f, s);
38
- }), e;
24
+ const _ = I(u), g = ((b = d.templates) == null ? void 0 : b.filter(
25
+ (n) => _.includes(n.id)
26
+ )) ?? [];
27
+ c = c || g.some((n) => n.type === S.UNSUBSCRIBE_LINK_TYPE), l = l || g.some((n) => n.type === S.PREFERENCES_LINK_TYPE);
28
+ }), (c || l) && (s.selectedDynamicContentList.some((u) => u.value === m) || s.selectedDynamicContentList.push({
29
+ text: m,
30
+ value: m,
31
+ fallback: ""
32
+ })), c && (e = e.replace(
33
+ p.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
34
+ R.UNSUBSCRIBE_URL + r
35
+ )), l && (e = e.replace(
36
+ p.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
37
+ R.PREFERENCES_URL + r
38
+ )), E.length && (e = e.replace(p.UNSUBSCRIBE_LINK_REGEX, "")), e;
39
39
  },
40
40
  priority: 60
41
41
  },
@@ -43,7 +43,7 @@ const D = [
43
43
  id: "remove-data-ogsb-button-styles",
44
44
  description: "Removing styles like [data-ogsb] .es-button.es-button-123 { background: red; }",
45
45
  type: "regex",
46
- pattern: l.DATA_OGSB_BUTTON_CSS_REGEX,
46
+ pattern: p.DATA_OGSB_BUTTON_CSS_REGEX,
47
47
  replacement: "",
48
48
  flags: "g",
49
49
  priority: 61
@@ -61,16 +61,16 @@ const D = [
61
61
  type: "custom",
62
62
  processor: (t) => {
63
63
  let i = t;
64
- const c = i.match(/<a[^>]+>(.*?)<\/a>/gm);
65
- return c && c.forEach((n) => {
66
- if (n.includes("insEmail=1"))
64
+ const o = i.match(/<a[^>]+>(.*?)<\/a>/gm);
65
+ return o && o.forEach((s) => {
66
+ if (s.includes("insEmail=1"))
67
67
  return;
68
- if (n.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
69
- const a = n.replace(/href=(["'`”])(.*?)\1/gm, (e) => {
68
+ if (s.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
69
+ const a = s.replace(/href=(["'`”])(.*?)\1/gm, (e) => {
70
70
  const r = e.slice(6, e.length - 1).trim();
71
71
  return e.includes("?") || e.includes("#") ? r.slice(-1) === "&" ? e.replace(r, `${r}insEmail=1`) : e.replace(r, `${r}&insEmail=1`) : e.replace(r, `${r}?insEmail=1`);
72
72
  });
73
- i = i.replace(n, a);
73
+ i = i.replace(s, a);
74
74
  }
75
75
  }), i;
76
76
  },
@@ -78,5 +78,5 @@ const D = [
78
78
  }
79
79
  ];
80
80
  export {
81
- D as unsubscribeCompilerRules
81
+ G as unsubscribeCompilerRules
82
82
  };