@useinsider/guido 3.17.0 → 3.18.0-beta.41e529d

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 (120) hide show
  1. package/README.md +6 -5
  2. package/dist/@types/config/schemas.js +10 -7
  3. package/dist/components/Guido.vue.js +10 -10
  4. package/dist/components/Guido.vue2.js +86 -78
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +21 -0
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +131 -0
  7. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
  8. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
  9. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue.js +17 -0
  10. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +57 -0
  11. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +19 -0
  12. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +63 -0
  13. package/dist/composables/useCustomInterfaceAppearance.js +56 -38
  14. package/dist/composables/useLegacyStrategyConversion.js +52 -0
  15. package/dist/composables/useModuleRepair.js +33 -0
  16. package/dist/composables/useRecommendation.js +41 -34
  17. package/dist/composables/useSave.js +30 -29
  18. package/dist/composables/useStripo.js +15 -15
  19. package/dist/composables/useSyncModuleExtractor.js +15 -13
  20. package/dist/composables/validators/useSyncModuleBlockValidator.js +24 -0
  21. package/dist/config/i18n/en/labels.json.js +1 -1
  22. package/dist/config/migrator/index.js +9 -8
  23. package/dist/config/migrator/recommendation/compositionMapper.js +20 -20
  24. package/dist/config/migrator/recommendation/extractors.js +29 -24
  25. package/dist/config/migrator/recommendation/htmlBuilder.js +116 -130
  26. package/dist/config/migrator/recommendation/settingsMapper.js +17 -17
  27. package/dist/config/migrator/recommendationMigrator.js +31 -25
  28. package/dist/config/migrator/recommendationTitleMigrator.js +119 -0
  29. package/dist/enums/academy.js +2 -1
  30. package/dist/enums/date.js +5 -3
  31. package/dist/enums/extensions/recommendationBlock.js +4 -1
  32. package/dist/extensions/Blocks/Items/block.js +118 -49
  33. package/dist/extensions/Blocks/Items/constants/currency.js +25 -0
  34. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
  35. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -11
  36. package/dist/extensions/Blocks/Items/template.js +153 -152
  37. package/dist/extensions/Blocks/Items/utils/constants.js +4 -0
  38. package/dist/extensions/Blocks/Recommendation/block.js +35 -29
  39. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +1 -1
  40. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  41. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +29 -27
  42. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +35 -28
  43. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +309 -236
  44. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +242 -180
  45. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +159 -0
  46. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +1 -0
  47. package/dist/extensions/Blocks/Recommendation/controls/title/index.js +44 -0
  48. package/dist/extensions/Blocks/Recommendation/extension.js +31 -29
  49. package/dist/extensions/Blocks/Recommendation/services/configService.js +54 -36
  50. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +23 -4
  51. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +217 -80
  52. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -3
  53. package/dist/extensions/Blocks/Recommendation/templates/titleRows.js +33 -0
  54. package/dist/extensions/Blocks/Recommendation/templates/utils.js +85 -107
  55. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +58 -0
  56. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +22 -0
  57. package/dist/extensions/Blocks/Recommendation/utils/recommendationBlockCount.js +10 -6
  58. package/dist/extensions/Blocks/common-control.js +22 -19
  59. package/dist/guido.css +1 -1
  60. package/dist/services/recommendationApi.js +81 -33
  61. package/dist/src/@types/config/schemas.d.ts +6 -0
  62. package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
  63. package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
  64. package/dist/src/components/organisms/extensions/recommendation/RemoveStrategyModal.vue.d.ts +2 -0
  65. package/dist/src/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.d.ts +15 -0
  66. package/dist/src/composables/useConfig.d.ts +4 -0
  67. package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
  68. package/dist/src/composables/useModuleRepair.d.ts +18 -0
  69. package/dist/src/composables/useRecommendation.d.ts +1 -0
  70. package/dist/src/composables/useSyncModuleExtractor.d.ts +2 -0
  71. package/dist/src/composables/validators/useSyncModuleBlockValidator.d.ts +3 -0
  72. package/dist/src/config/migrator/recommendation/extractors.d.ts +8 -0
  73. package/dist/src/config/migrator/recommendationTitleMigrator.d.ts +5 -0
  74. package/dist/src/enums/academy.d.ts +1 -0
  75. package/dist/src/enums/date.d.ts +1 -0
  76. package/dist/src/enums/extensions/recommendationBlock.d.ts +3 -0
  77. package/dist/src/extensions/Blocks/Items/block.d.ts +35 -0
  78. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +43 -0
  79. package/dist/src/extensions/Blocks/Items/utils/constants.d.ts +6 -0
  80. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +2 -1
  81. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +7 -0
  82. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +3 -6
  83. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +2 -2
  84. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +12 -0
  85. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +11 -0
  86. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -0
  87. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +44 -8
  88. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +17 -0
  89. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +1 -0
  90. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +86 -0
  91. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +12 -1
  92. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +229 -10
  93. package/dist/src/extensions/Blocks/Recommendation/templates/titleRows.d.ts +13 -0
  94. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +7 -0
  95. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +39 -0
  96. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +31 -0
  97. package/dist/src/extensions/Blocks/Recommendation/utils/recommendationBlockCount.d.ts +6 -2
  98. package/dist/src/extensions/Blocks/common-control.d.ts +4 -1
  99. package/dist/src/mock/api/recommendation-strategies.d.ts +2 -0
  100. package/dist/src/services/recommendationApi.d.ts +5 -1
  101. package/dist/src/stores/config.d.ts +178 -0
  102. package/dist/src/stores/save-as-template.d.ts +4 -3
  103. package/dist/src/utils/genericUtil.d.ts +5 -0
  104. package/dist/src/utils/itemsCurrencyRepair.d.ts +17 -0
  105. package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
  106. package/dist/static/assets/icons/line-change.svg.js +5 -0
  107. package/dist/static/assets/icons/line-delete.svg.js +5 -0
  108. package/dist/static/assets/icons/line-info.svg.js +5 -0
  109. package/dist/static/assets/icons/line-plus.svg.js +5 -0
  110. package/dist/static/styles/components/recommendation-strategy.css.js +220 -0
  111. package/dist/static/styles/customEditorStyle.css.js +3 -1
  112. package/dist/stores/config.js +66 -59
  113. package/dist/utils/dateUtil.js +23 -10
  114. package/dist/utils/genericUtil.js +28 -27
  115. package/dist/utils/itemsCurrencyRepair.js +39 -0
  116. package/dist/utils/pairProductVariables.js +58 -58
  117. package/dist/utils/templatePreparation.js +35 -34
  118. package/package.json +3 -2
  119. package/dist/composables/useModuleDynamicContentRepair.js +0 -37
  120. package/dist/src/composables/useModuleDynamicContentRepair.d.ts +0 -13
@@ -0,0 +1,57 @@
1
+ import { defineComponent as u, computed as n } from "vue";
2
+ import y from "../../../wrappers/WpModal.vue.js";
3
+ import { useToaster as f } from "../../../../composables/useToaster.js";
4
+ import { useTranslations as _ } from "../../../../composables/useTranslations.js";
5
+ import { ToasterTypeOptions as v } from "../../../../enums/toaster.js";
6
+ import { useRecommendationExtensionStore as T } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
7
+ import { commitBlockChangeOutsidePanel as h } from "../../../../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
8
+ import { escapeHtml as R } from "../../../../utils/htmlEscape.js";
9
+ const P = /* @__PURE__ */ u({
10
+ __name: "RemoveStrategyModal",
11
+ setup(S) {
12
+ const t = _(), e = T(), { showToaster: a } = f(), i = n(() => ({
13
+ cancelOrBackButton: {
14
+ type: "secondary",
15
+ labelText: t("products.cancel"),
16
+ styling: "ghost"
17
+ },
18
+ primaryButton: {
19
+ type: "danger",
20
+ labelText: t("discovery-strategy.remove")
21
+ }
22
+ })), m = n(() => {
23
+ var o;
24
+ const { strategyId: r } = e.recommendationConfigs;
25
+ return ((o = e.assignedStrategy) == null ? void 0 : o.name) || `#${r}`;
26
+ }), s = "__STRATEGY_NAME__", d = n(() => t("email-editor.remove-strategy-confirm-message", { strategyName: s }).split(s)), c = () => {
27
+ e.closeRemoveStrategyModal();
28
+ };
29
+ return { __sfc: !0, trans: t, store: e, showToaster: a, footerButtonOptions: i, strategyName: m, NAME_TOKEN: s, messageParts: d, close: c, handleConfirm: async () => {
30
+ const r = m.value, o = e.currentRecommendationId;
31
+ e.removeStrategy(), c();
32
+ const { strategyId: l, size: g } = e.recommendationConfigs;
33
+ if (a({
34
+ type: v.Success,
35
+ // The toast renders through a sanitizing v-html, so the name is escaped first.
36
+ message: t("email-editor.strategy-removed-success", {
37
+ strategyName: `<b>${R(r)}</b>`
38
+ })
39
+ }), o !== null) {
40
+ try {
41
+ await e.fetchRecommendationProducts();
42
+ } catch (p) {
43
+ console.error("[RemoveStrategyModal] product refetch failed", p);
44
+ }
45
+ h(
46
+ o,
47
+ { strategyId: l, size: g },
48
+ e.recommendationProducts,
49
+ "Removed recommendation strategy"
50
+ );
51
+ }
52
+ }, WpModal: y };
53
+ }
54
+ });
55
+ export {
56
+ P as default
57
+ };
@@ -0,0 +1,19 @@
1
+ import r from "./StrategyInfoBoxContent.vue2.js";
2
+ import _ from "../../../../_virtual/_plugin-vue2_normalizer.js";
3
+ var c = function() {
4
+ var t = this, s = t._self._c, n = t._self._setupProxy;
5
+ return s("div", { staticClass: "d-f f-d-c mt-3" }, t._l(n.details, function(e, a) {
6
+ return s("div", { key: e.title, staticClass: "d-f f-d-c", class: { "mt-2": a > 0 } }, [s("span", { staticClass: "f-s-1 f-w-600 l-h-1 t-c-52 mb-12" }, [t._v(t._s(e.title))]), s("span", { staticClass: "f-s-1 l-h-6 t-c-55 w-b-b-w" }, [t._v(t._s(e.value))])]);
7
+ }), 0);
8
+ }, f = [], l = /* @__PURE__ */ _(
9
+ r,
10
+ c,
11
+ f,
12
+ !1,
13
+ null,
14
+ null
15
+ );
16
+ const p = l.exports;
17
+ export {
18
+ p as default
19
+ };
@@ -0,0 +1,63 @@
1
+ import { defineComponent as f, computed as i } from "vue";
2
+ import { useTranslations as _ } from "../../../../composables/useTranslations.js";
3
+ import { asText as c } from "../../../../utils/genericUtil.js";
4
+ const j = /* @__PURE__ */ f({
5
+ __name: "StrategyInfoBoxContent",
6
+ props: {
7
+ strategy: null
8
+ },
9
+ setup(p) {
10
+ const a = p, n = _(), s = i(() => n("recommendation-strategy.none")), u = i(() => {
11
+ const e = c(a.strategy.algorithm) === "MIXED" ? n("discovery-strategy.mixed-algorithm") : n("discovery-strategy.single-algorithm"), t = c(a.strategy.algorithm_used).split(",").map((r) => r.trim()).filter(Boolean).map((r) => n(`recommendation-algorithm-names.${r.replaceAll("_", "-").toLowerCase()}`));
12
+ return t.length ? `${e} · ${t.join(", ")}` : e;
13
+ }), d = i(() => [
14
+ [a.strategy.exclude_view, "discovery-strategy.exclude-recently-view-items"],
15
+ [a.strategy.exclude_purchase, "discovery-strategy.exclude-recently-purchased-items"],
16
+ [a.strategy.exclude_cart, "discovery-strategy.exclude-recently-added-cart-items"]
17
+ ].filter(([e]) => Number(e) === 1).map(([, e]) => n(e)).join(", ") || s.value), l = (e) => {
18
+ const t = c(e).trim();
19
+ if (!t)
20
+ return "";
21
+ let r;
22
+ try {
23
+ r = JSON.parse(t);
24
+ } catch {
25
+ return t;
26
+ }
27
+ if (Array.isArray(r))
28
+ return r.length ? String(r.length) : "";
29
+ if (r && typeof r == "object") {
30
+ const o = Object.keys(r).length;
31
+ return o ? String(o) : "";
32
+ }
33
+ return t;
34
+ }, m = i(() => l(a.strategy.manual_merchandising) || l(a.strategy.manual_merchandising_products) || s.value), g = (e) => {
35
+ if (Array.isArray(e))
36
+ return e.length;
37
+ const { conditionList: t } = e ?? {};
38
+ return Array.isArray(t) ? t.length : 1;
39
+ }, y = i(() => {
40
+ const e = a.strategy.filters;
41
+ if (!e)
42
+ return s.value;
43
+ try {
44
+ const t = typeof e == "string" ? JSON.parse(e) : e;
45
+ if (!t || typeof t != "object")
46
+ return s.value;
47
+ const r = Object.values(t).reduce((o, v) => o + g(v), 0);
48
+ return r ? String(r) : s.value;
49
+ } catch {
50
+ return s.value;
51
+ }
52
+ }), h = i(() => [
53
+ { title: n("gpt-app-builder.algorithms-and-method"), value: u.value },
54
+ { title: n("gpt-app-builder.exclusions"), value: d.value },
55
+ { title: n("discovery-strategy.filters"), value: y.value },
56
+ { title: n("action-builder.manual-merchandising"), value: m.value }
57
+ ]);
58
+ return { __sfc: !0, props: a, trans: n, none: s, algorithmsAndMethod: u, exclusions: d, asMerchandising: l, manualMerchandising: m, conditionsIn: g, filters: y, details: h };
59
+ }
60
+ });
61
+ export {
62
+ j as default
63
+ };
@@ -1,53 +1,71 @@
1
- import S from "../static/styles/base.css.js";
2
- import m from "../static/styles/components/alert-message.css.js";
3
- import e from "../static/styles/components/amp-block.css.js";
4
- import i from "../static/styles/components/base-input.css.js";
5
- import p from "../static/styles/components/button-group.css.js";
6
- import n from "../static/styles/components/button.css.js";
7
- import s from "../static/styles/components/combobox.css.js";
8
- import C from "../static/styles/components/counter.css.js";
9
- import f from "../static/styles/components/dropdown-menu.css.js";
10
- import a from "../static/styles/components/loader.css.js";
11
- import u from "../static/styles/components/narrow-panel.css.js";
12
- import c from "../static/styles/components/popup.css.js";
13
- import d from "../static/styles/components/switcher.css.js";
14
- import l from "../static/styles/components/tabs.css.js";
15
- import h from "../static/styles/components/tools.css.js";
16
- import w from "../static/styles/components/version-history.css.js";
17
- import y from "../static/styles/components/wide-panel.css.js";
18
- import B from "../static/styles/variables.css.js";
19
- const b = [
20
- B,
1
+ import i from "../static/assets/icons/filled-arrow-rising.svg.js";
2
+ import n from "../static/assets/icons/line-change.svg.js";
3
+ import S from "../static/assets/icons/line-delete.svg.js";
4
+ import p from "../static/assets/icons/line-info.svg.js";
5
+ import s from "../static/assets/icons/line-plus.svg.js";
6
+ import f from "../static/styles/base.css.js";
7
+ import C from "../static/styles/components/alert-message.css.js";
8
+ import a from "../static/styles/components/amp-block.css.js";
9
+ import c from "../static/styles/components/base-input.css.js";
10
+ import l from "../static/styles/components/button-group.css.js";
11
+ import u from "../static/styles/components/button.css.js";
12
+ import d from "../static/styles/components/combobox.css.js";
13
+ import I from "../static/styles/components/counter.css.js";
14
+ import g from "../static/styles/components/dropdown-menu.css.js";
15
+ import h from "../static/styles/components/loader.css.js";
16
+ import w from "../static/styles/components/narrow-panel.css.js";
17
+ import $ from "../static/styles/components/popup.css.js";
18
+ import y from "../static/styles/components/recommendation-strategy.css.js";
19
+ import b from "../static/styles/components/switcher.css.js";
20
+ import B from "../static/styles/components/tabs.css.js";
21
+ import A from "../static/styles/components/tools.css.js";
22
+ import P from "../static/styles/components/version-history.css.js";
23
+ import R from "../static/styles/components/wide-panel.css.js";
24
+ import x from "../static/styles/variables.css.js";
25
+ function o(t, r) {
26
+ return `--guido-icon-${t}: url("data:image/svg+xml,${encodeURIComponent(r.trim())}");`;
27
+ }
28
+ const V = `:host {
29
+ ${o("line-change", n)}
30
+ ${o("line-delete", S)}
31
+ ${o("filled-arrow-rising", i)}
32
+ ${o("line-info", p)}
33
+ ${o("line-plus", s)}
34
+ }`, D = [
35
+ x,
21
36
  // Must be on top
22
- S,
37
+ V,
38
+ f,
23
39
  // Must be on top
24
- m,
25
- e,
26
- i,
27
- p,
28
- n,
29
- s,
30
40
  C,
31
- f,
32
41
  a,
33
- u,
34
42
  c,
35
- d,
36
43
  l,
44
+ u,
45
+ d,
46
+ I,
47
+ g,
37
48
  h,
38
49
  w,
50
+ $,
51
+ b,
52
+ B,
53
+ A,
54
+ P,
55
+ R,
39
56
  y
57
+ // Last: overrides button.css / wide-panel.css defaults
40
58
  ].join(`
41
59
 
42
- `), v = () => ({ importCss: () => {
43
- const o = new CSSStyleSheet();
44
- o.replaceSync(b);
45
- const r = document.querySelector("ui-editor");
46
- if (!r)
60
+ `), ro = () => ({ importCss: () => {
61
+ const r = new CSSStyleSheet();
62
+ r.replaceSync(D);
63
+ const e = document.querySelector("ui-editor");
64
+ if (!e)
47
65
  return;
48
- const t = r.shadowRoot;
49
- t && (t.adoptedStyleSheets = [o]);
66
+ const m = e.shadowRoot;
67
+ m && (m.adoptedStyleSheets = [r]);
50
68
  } });
51
69
  export {
52
- v as useCustomInterfaceAppearance
70
+ ro as useCustomInterfaceAppearance
53
71
  };
@@ -0,0 +1,52 @@
1
+ import { useRecommendation as l } from "./useRecommendation.js";
2
+ import { useToaster as u } from "./useToaster.js";
3
+ import { useTranslations as p } from "./useTranslations.js";
4
+ import { ToasterTypeOptions as f } from "../enums/toaster.js";
5
+ import "../extensions/Blocks/Recommendation/constants/selectors.js";
6
+ import { CURRENT_CONFIG_VERSION as S } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
7
+ import { useRecommendationExtensionStore as C } from "../extensions/Blocks/Recommendation/store/recommendation.js";
8
+ import { buildLegacyMigrationPayload as L } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js";
9
+ import { commitBlockChangeOutsidePanel as v } from "../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
10
+ import { useConfigStore as I } from "../stores/config.js";
11
+ const x = () => {
12
+ const t = C(), a = I(), { buildCampaignUrl: n } = l(), { showToaster: i } = u(), c = p();
13
+ return { convertLegacyStrategy: async () => {
14
+ const o = t.currentRecommendationId;
15
+ if (o === null || !t.isLegacyStrategyBlock || t.legacyConversionLoading)
16
+ return "";
17
+ const { strategy: s, productIds: m, filters: g } = t.recommendationConfigs, d = L({
18
+ blockId: o,
19
+ url: n(String(o)),
20
+ campaignId: a.campaignId,
21
+ variationId: a.variationId,
22
+ strategy: s,
23
+ productIds: m,
24
+ filters: g,
25
+ attributes: t.getFilterList
26
+ });
27
+ let e;
28
+ try {
29
+ e = await t.convertLegacyStrategy(d);
30
+ } catch (r) {
31
+ return console.error("[useLegacyStrategyConversion] migration failed", r), i({
32
+ type: f.Error,
33
+ message: c("email-editor.legacy-strategy-update-failed")
34
+ }), "";
35
+ }
36
+ const { size: y } = t.recommendationConfigs;
37
+ try {
38
+ await t.fetchRecommendationProducts();
39
+ } catch (r) {
40
+ console.error("[useLegacyStrategyConversion] product refetch failed", r);
41
+ }
42
+ return v(
43
+ o,
44
+ { strategyId: e, size: y, configVersion: S },
45
+ t.recommendationProducts,
46
+ "Converted legacy recommendation strategy"
47
+ ), t.openLegacyStrategyUpdatedModal(), e;
48
+ } };
49
+ };
50
+ export {
51
+ x as useLegacyStrategyConversion
52
+ };
@@ -0,0 +1,33 @@
1
+ import { useConfig as C } from "./useConfig.js";
2
+ import { useToaster as T } from "./useToaster.js";
3
+ import { useTranslations as g } from "./useTranslations.js";
4
+ import { ToasterTypeOptions as D } from "../enums/toaster.js";
5
+ import { buildDynamicContentLookup as f, convertModuleDynamicContent as h } from "../utils/dynamicContentConverter.js";
6
+ import { flattenDynamicContentList as O } from "../utils/genericUtil.js";
7
+ import { repairItemsCurrencyAttributes as M } from "../utils/itemsCurrencyRepair.js";
8
+ const N = "dynamic-content.unresolved-attributes-on-drop", R = () => {
9
+ const { template: p, isFeatureEnabled: m } = C(), { showToaster: a } = T(), y = g();
10
+ return { handleModuleAdd: (e, o) => {
11
+ var s, l, u;
12
+ try {
13
+ if ((e == null ? void 0 : e.action) !== "ADD" && (e == null ? void 0 : e.action) !== "COPY")
14
+ return;
15
+ const t = (s = o == null ? void 0 : o.getTargetNode) == null ? void 0 : s.call(o), r = (l = t == null ? void 0 : t.getOuterHTML) == null ? void 0 : l.call(t);
16
+ if (!t || typeof r != "string")
17
+ return;
18
+ let n = M(r);
19
+ const c = f(O((u = p.value) == null ? void 0 : u.dynamicContentList));
20
+ let i = [];
21
+ c.size > 0 && ({ html: n, unresolved: i } = h(n, c, m("liquidSyntax"))), n !== r && o.modifyHtml(t).replaceWith(n), i.length > 0 && a({
22
+ type: D.Warning,
23
+ message: y(N)
24
+ });
25
+ } catch (t) {
26
+ console.error("Failed to repair module on add:", t);
27
+ }
28
+ } };
29
+ };
30
+ export {
31
+ N as UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY,
32
+ R as useModuleRepair
33
+ };
@@ -1,22 +1,22 @@
1
- import { getRecommendationFeedSourceMaps as I, URLS as R } from "../enums/extensions/recommendationBlock.js";
2
- import { MinDeviceViewport as C, DefaultPadding as b } from "../enums/recommendation.js";
1
+ import { getRecommendationFeedSourceMaps as y, URLS as I } from "../enums/extensions/recommendationBlock.js";
2
+ import { MinDeviceViewport as C, DefaultPadding as R } from "../enums/recommendation.js";
3
3
  import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
- import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
5
- import { getPartnerRecommendationParams as y } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
4
+ import { generateCompleteFilterQuery as b } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
5
+ import { getPartnerRecommendationParams as h } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
6
6
  import { sanitizeProductIds as x } from "../extensions/Blocks/Recommendation/utils/productIds.js";
7
7
  import { useConfigStore as P } from "../stores/config.js";
8
8
  const B = () => ({
9
9
  calculateCardWidth: ({
10
- mobileLeftPadding: a,
11
- mobileRightPadding: s,
12
- cardsInRow: c,
10
+ mobileLeftPadding: i,
11
+ mobileRightPadding: c,
12
+ cardsInRow: s,
13
13
  unresponsive: n
14
14
  }) => {
15
- const r = n ? c : 1, e = a + s + (r - 1) * b;
16
- return (C - e) / r;
15
+ const o = n ? s : 1, e = i + c + (o - 1) * R;
16
+ return (C - e) / o;
17
17
  },
18
- getRecommendationCampaignData: (a) => {
19
- const s = l(), c = Number(a), n = s.blockStates[c];
18
+ getRecommendationCampaignData: (i) => {
19
+ const c = l(), s = Number(i), n = c.blockStates[s];
20
20
  if (!n)
21
21
  return {
22
22
  textTrimming: !1,
@@ -30,47 +30,54 @@ const B = () => ({
30
30
  discountBeforeTextValue: "",
31
31
  discountAfterTextValue: ""
32
32
  };
33
- const { recommendationConfigs: r } = n, e = r.orientation === "grid" ? "vertical" : "horizontal";
33
+ const { recommendationConfigs: o } = n, e = o.orientation === "grid" ? "vertical" : "horizontal";
34
34
  return {
35
- textTrimming: r.textTrimming,
35
+ textTrimming: o.textTrimming,
36
36
  orientation: e,
37
37
  mobileLeftPadding: 0,
38
38
  mobileRightPadding: 0,
39
- cardsInRow: r.cardsInRow,
40
- unresponsive: r.unresponsive,
39
+ cardsInRow: o.cardsInRow,
40
+ unresponsive: o.unresponsive,
41
41
  priceBeforeTextValue: "",
42
42
  priceAfterTextValue: "",
43
43
  discountBeforeTextValue: "",
44
44
  discountAfterTextValue: ""
45
45
  };
46
46
  },
47
- buildCampaignUrl: (a, s) => {
47
+ buildCampaignUrl: (i, c) => {
48
48
  var m;
49
- const c = l(), n = P(), r = Number(a);
49
+ const s = l(), n = P(), o = Number(i);
50
50
  let e;
51
- if (s)
52
- e = s;
51
+ if (c)
52
+ e = c;
53
53
  else {
54
- const i = c.blockStates[r];
55
- if (!i)
54
+ const a = s.blockStates[o];
55
+ if (!a)
56
56
  return "";
57
- const { recommendationConfigs: o } = i;
57
+ const { recommendationConfigs: r } = a;
58
58
  e = {
59
- strategy: o.strategy,
60
- language: o.language,
61
- currencyCode: o.currencySettings.value,
62
- size: o.size,
63
- productIds: o.productIds,
64
- filters: o.filters,
65
- shuffleProducts: o.shuffleProducts
59
+ strategy: r.strategy,
60
+ strategyId: r.strategyId,
61
+ language: r.language,
62
+ currencyCode: r.currencySettings.value,
63
+ size: r.size,
64
+ productIds: r.productIds,
65
+ filters: r.filters,
66
+ shuffleProducts: r.shuffleProducts
66
67
  };
67
68
  }
68
- const f = ((m = I().find((i) => i.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
69
+ if (e.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy"))
70
+ return s.recommendationCampaignUrls[i] = {
71
+ strategyId: e.strategyId,
72
+ locale: e.language,
73
+ currency: e.currencyCode
74
+ }, "";
75
+ const g = ((m = y().find((a) => a.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
69
76
  t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", n.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", n.variationId), e.strategy === "manualMerchandising" ? t.set("productId", x(e.productIds)) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
70
- const g = e.filters.filter((i) => i.isValid), d = h(g);
71
- d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(n.partnerName, e.strategy)).forEach(([i, o]) => t.set(i, o));
72
- const p = decodeURIComponent(t.toString()), u = `${R.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
73
- return c.recommendationCampaignUrls[a] = u, u;
77
+ const f = e.filters.filter((a) => a.isValid), d = b(f);
78
+ d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(h(n.partnerName, e.strategy)).forEach(([a, r]) => t.set(a, r));
79
+ const p = decodeURIComponent(t.toString()), u = `${I.RECOMMENDATION_API_URL}/v2/${g}?${p}`;
80
+ return s.recommendationCampaignUrls[i] = u, u;
74
81
  }
75
82
  });
76
83
  export {
@@ -1,51 +1,52 @@
1
- import { useActionsApi as T } from "./useActionsApi.js";
2
- import { useConfig as k } from "./useConfig.js";
3
- import { useSaveStart as B, useSaveComplete as E } from "./useGuidoActions.js";
4
- import { useSyncModuleExtractor as q } from "./useSyncModuleExtractor.js";
5
- import { ToasterTypeOptions as C } from "../enums/toaster.js";
1
+ import { useActionsApi as x } from "./useActionsApi.js";
2
+ import { useConfig as T } from "./useConfig.js";
3
+ import { useSaveStart as E, useSaveComplete as q } from "./useGuidoActions.js";
4
+ import { useSyncModuleExtractor as C } from "./useSyncModuleExtractor.js";
5
+ import { ToasterTypeOptions as M } from "../enums/toaster.js";
6
6
  import { useStripoApi as D } from "../services/stripoApi.js";
7
7
  import { useTemplatePreparation as L } from "../utils/templatePreparation.js";
8
8
  import { useAllowlist as P } from "./useAllowlist.js";
9
9
  import { useHtmlValidator as U } from "./useHtmlValidator.js";
10
10
  import { useToaster as A } from "./useToaster.js";
11
- import { useCouponBlockValidator as M } from "./validators/useCouponBlockValidator.js";
12
- import { useLiquidValidator as h } from "./validators/useLiquidValidator.js";
13
- import { useUnsubscribeBlockValidator as F } from "./validators/useUnsubscribeBlockValidator.js";
14
- const $ = () => {
15
- const n = B(), l = E(), { validateHtml: c } = U(), { validateLiquidSyntax: d } = h(), { validateCouponBlockTags: m } = M(), { validateUnsubscribeBlockUniqueness: u, validateUnsubscribeBlockHasTemplate: p } = F(), { callbacks: e, isFeatureEnabled: a } = k(), { extractSyncModuleData: f } = q(), { setSyncModuleUnsubscriptionPages: v } = D(), { editorSave: S } = T(), { showToaster: b } = A(), { getBlockedDomains: w, resolveToast: V } = P();
16
- return { save: async (y = !1, s = !1) => {
11
+ import { useCouponBlockValidator as h } from "./validators/useCouponBlockValidator.js";
12
+ import { useLiquidValidator as F } from "./validators/useLiquidValidator.js";
13
+ import { useSyncModuleBlockValidator as O } from "./validators/useSyncModuleBlockValidator.js";
14
+ import { useUnsubscribeBlockValidator as W } from "./validators/useUnsubscribeBlockValidator.js";
15
+ const it = () => {
16
+ const l = E(), n = q(), { validateHtml: c } = U(), { validateLiquidSyntax: d } = F(), { validateCouponBlockTags: m } = h(), { validateUnsubscribeBlockUniqueness: u, validateUnsubscribeBlockHasTemplate: p } = W(), { validateSyncModuleBlocks: f } = O(), { callbacks: a, isFeatureEnabled: s } = T(), { extractSyncModuleData: v } = C(), { setSyncModuleUnsubscriptionPages: S } = D(), { editorSave: b } = x(), { showToaster: w } = A(), { getBlockedDomains: V, resolveToast: y } = P();
17
+ return { save: async (H = !1, e = !1) => {
17
18
  var r;
18
- n();
19
- const { prepareTemplateDetails: H } = L(), t = await H();
20
- if (!m(t.compiledHtml) || !u(t.compiledHtml) || !p(t.compiledHtml))
19
+ l();
20
+ const { prepareTemplateDetails: k } = L(), t = await k();
21
+ if (!f(t.rawHtml, e) || !m(t.compiledHtml) || !u(t.compiledHtml) || !p(t.compiledHtml))
21
22
  return;
22
- if (a("liquidSyntax")) {
23
+ if (s("liquidSyntax")) {
23
24
  if (!await d(t.compiledHtml))
24
25
  return;
25
26
  } else if (!await c(t.compiledHtml, t.dynamicContentList, !0))
26
27
  return;
27
- if ((r = e.value) != null && r.externalValidation && !await e.value.externalValidation(t))
28
+ if ((r = a.value) != null && r.externalValidation && !await a.value.externalValidation(t))
28
29
  return;
29
- if (a("allowlistEnabled")) {
30
- const i = await w(t.compiledHtml, t.css);
31
- if (i.length) {
32
- if (!s) {
33
- const o = await V(i);
34
- o != null && o.message && b({
35
- type: C.Warning,
36
- message: o.message,
37
- actionButton: o.actionButton
30
+ if (s("allowlistEnabled")) {
31
+ const o = await V(t.compiledHtml, t.css);
32
+ if (o.length) {
33
+ if (!e) {
34
+ const i = await y(o);
35
+ i != null && i.message && w({
36
+ type: M.Warning,
37
+ message: i.message,
38
+ actionButton: i.actionButton
38
39
  });
39
40
  }
40
41
  return;
41
42
  }
42
43
  }
43
- if (!await S())
44
+ if (!await b())
44
45
  return;
45
- const { unsubscribePayload: g, stripoModules: x } = f(t.rawHtml);
46
- return await v(g), t.modules = x, y || l({ ...t, silent: s }), t;
46
+ const { unsubscribePayload: B, stripoModules: g } = v(t.rawHtml);
47
+ return await S(B), t.modules = g, H || n({ ...t, silent: e }), t;
47
48
  } };
48
49
  };
49
50
  export {
50
- $ as useSave
51
+ it as useSave
51
52
  };
@@ -3,7 +3,7 @@ import { useBlocksConfig as O } from "./useBlocksConfig.js";
3
3
  import { useConfig as q } from "./useConfig.js";
4
4
  import { useCustomInterfaceAppearance as H } from "./useCustomInterfaceAppearance.js";
5
5
  import { useFullStoryBridge as N } from "./useFullStoryBridge.js";
6
- import { useModuleDynamicContentRepair as j } from "./useModuleDynamicContentRepair.js";
6
+ import { useModuleRepair as j } from "./useModuleRepair.js";
7
7
  import { useStripoEventHandler as z } from "./useStripoEventHandler.js";
8
8
  import { useStripoNotifications as $ } from "./useStripoNotifications.js";
9
9
  import { useToaster as G } from "./useToaster.js";
@@ -17,13 +17,13 @@ import { buildMergeTagEntries as W, flattenDynamicContentList as Y } from "../ut
17
17
  import Z from "../package.json.js";
18
18
  let n = null;
19
19
  const Ce = () => {
20
- const { features: c, template: u, isFeatureEnabled: m } = q(), { handleError: p, showToaster: k } = G(), { getToken: M, getCustomFonts: T, getSyncModulesStatus: v } = K(), { handleEvent: B } = z(), { handleModuleAdd: F } = j(), { getStripoBlocksConfig: A } = O(), { getStripoNotifications: V } = $(), f = () => n || (n = new Promise((i, s) => {
21
- var l;
20
+ const { features: c, template: u, isFeatureEnabled: m } = q(), { handleError: p, showToaster: k } = G(), { getToken: B, getCustomFonts: M, getSyncModulesStatus: T } = K(), { handleEvent: v } = z(), { handleModuleAdd: F } = j(), { getStripoBlocksConfig: A } = O(), { getStripoNotifications: V } = $(), f = () => n || (n = new Promise((i, s) => {
21
+ var d;
22
22
  if (document.getElementById("UiEditorScript")) {
23
23
  i();
24
24
  return;
25
25
  }
26
- const o = Z.guido, r = `https://email-static.useinsider.com/guido/${(l = o == null ? void 0 : o.stripo) == null ? void 0 : l.version}/UIEditor.js`, e = document.createElement("script");
26
+ const o = Z.guido, r = `https://email-static.useinsider.com/guido/${(d = o == null ? void 0 : o.stripo) == null ? void 0 : d.version}/UIEditor.js`, e = document.createElement("script");
27
27
  e.id = "UiEditorScript", e.type = "module", e.src = r, e.onload = () => i(), e.onerror = () => {
28
28
  e.remove(), s(new Error(`Failed to load Stripo UIEditor script from S3: ${r}`));
29
29
  }, document.body.appendChild(e);
@@ -31,12 +31,12 @@ const Ce = () => {
31
31
  n = null;
32
32
  }), n), _ = async (i, s, o, a = [], r = !1) => {
33
33
  var y, E, h, C;
34
- const e = b(), { html: l, css: D } = i, { baseBlocks: g, extensions: R } = await A(), S = ((y = c.value) == null ? void 0 : y.displayConditions) ?? !0, P = ((E = c.value) == null ? void 0 : E.modulesDisabled) ?? !1, U = ((h = u.value) == null ? void 0 : h.forceRecreate) ?? !1;
34
+ const e = b(), { html: d, css: D } = i, { baseBlocks: g, extensions: R } = await A(), S = ((y = c.value) == null ? void 0 : y.displayConditions) ?? !0, P = ((E = c.value) == null ? void 0 : E.modulesDisabled) ?? !1, U = !!d || (((h = u.value) == null ? void 0 : h.forceRecreate) ?? !1);
35
35
  await window.UIEditor.initEditor(
36
36
  document.querySelector("#guido-editor"),
37
37
  {
38
38
  metadata: s,
39
- html: l,
39
+ html: d,
40
40
  css: D,
41
41
  forceRecreate: U,
42
42
  locale: "en",
@@ -80,16 +80,16 @@ const Ce = () => {
80
80
  ],
81
81
  async onTokenRefreshRequest(t) {
82
82
  try {
83
- const d = await M();
84
- t(d);
85
- } catch (d) {
86
- p(d, "Failed to refresh token");
83
+ const l = await B();
84
+ t(l);
85
+ } catch (l) {
86
+ p(l, "Failed to refresh token");
87
87
  }
88
88
  },
89
89
  onTemplateLoaded() {
90
90
  try {
91
- const { importCss: t } = H(), { activateCustomViewStyles: d, updateTimerInClonedTemplate: I } = L(), { injectFullStory: x } = N();
92
- t(), d(), x(), I(), o.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
91
+ const { importCss: t } = H(), { activateCustomViewStyles: l, updateTimerInClonedTemplate: I } = L(), { injectFullStory: x } = N();
92
+ t(), l(), x(), I(), o.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
93
93
  e.hasChanges = !1;
94
94
  }, 1e3);
95
95
  } catch (t) {
@@ -108,7 +108,7 @@ const Ce = () => {
108
108
  onDataChanged() {
109
109
  e.hasChanges = !0;
110
110
  },
111
- onEvent: B,
111
+ onEvent: v,
112
112
  onModuleAdd: F,
113
113
  notifications: V(),
114
114
  ignoreClickOutsideSelectors: [
@@ -126,8 +126,8 @@ const Ce = () => {
126
126
  try {
127
127
  await f();
128
128
  const [r, e] = await Promise.all([
129
- T(),
130
- v()
129
+ M(),
130
+ T()
131
131
  ]);
132
132
  a.syncModulesEnabled = e, await _(i, s, o, r, e);
133
133
  } catch {