@useinsider/guido 2.1.0-beta.038f431 → 2.1.0-beta.07fb1d6

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 (63) hide show
  1. package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
  2. package/dist/composables/useActionsApi.js +15 -13
  3. package/dist/composables/useHtmlValidator.js +95 -87
  4. package/dist/composables/useRecommendation.js +54 -21
  5. package/dist/config/compiler/recommendationCompilerRules.js +45 -39
  6. package/dist/config/compiler/utils/recommendationCompilerUtils.js +116 -0
  7. package/dist/config/migrator/itemsBlockMigrator.js +140 -123
  8. package/dist/enums/extensions/recommendationBlock.js +1 -1
  9. package/dist/enums/recommendation.js +16 -15
  10. package/dist/extensions/Blocks/Items/block.js +19 -28
  11. package/dist/extensions/Blocks/Items/controls/button/link.js +19 -31
  12. package/dist/extensions/Blocks/Items/controls/cardComposition.js +124 -85
  13. package/dist/extensions/Blocks/Items/controls/image/link.js +19 -31
  14. package/dist/extensions/Blocks/Items/controls/name/trimming.js +28 -40
  15. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +35 -47
  16. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +49 -54
  17. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +42 -51
  18. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +23 -36
  19. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +45 -57
  20. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -60
  21. package/dist/extensions/Blocks/Items/controls/settingsControl.js +189 -196
  22. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +0 -2
  23. package/dist/extensions/Blocks/Items/extension.js +8 -9
  24. package/dist/extensions/Blocks/Items/settingsPanel.js +10 -15
  25. package/dist/extensions/Blocks/Items/template.js +181 -175
  26. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
  27. package/dist/extensions/Blocks/Recommendation/block.js +20 -18
  28. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +42 -42
  29. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +114 -102
  30. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +4 -4
  31. package/dist/extensions/Blocks/Recommendation/templates/utils.js +19 -23
  32. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +10 -10
  33. package/dist/extensions/Blocks/common-control.js +91 -92
  34. package/dist/guido.css +1 -1
  35. package/dist/services/recommendationApi.js +11 -9
  36. package/dist/services/templateLibraryApi.js +16 -13
  37. package/dist/src/composables/useRecommendation.d.ts +1 -0
  38. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
  39. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -1
  40. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -1
  41. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +5 -5
  42. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -1
  43. package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +0 -1
  44. package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +0 -1
  45. package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +0 -1
  46. package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +0 -1
  47. package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +0 -1
  48. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +0 -1
  49. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +0 -5
  50. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +10 -12
  51. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +2 -1
  52. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -1
  53. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +7 -0
  54. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -1
  55. package/dist/src/extensions/Blocks/common-control.d.ts +4 -5
  56. package/dist/static/styles/components/notification.css.js +1 -0
  57. package/dist/static/styles/components/version-history.css.js +10 -2
  58. package/dist/static/styles/components/wide-panel.css.js +18 -2
  59. package/dist/utils/pairProductVariables.js +57 -56
  60. package/dist/utils/templatePreparation.js +15 -14
  61. package/package.json +1 -1
  62. package/dist/extensions/Blocks/Items/store/items-block.js +0 -79
  63. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +0 -45
@@ -1,46 +1,46 @@
1
1
  import { ModificationDescription as b } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { DefaultConfigValues as i, SETTINGS_ENUMS as n, ItemInCartOptions as g } from "../enums/settingsEnums.js";
3
- function d() {
2
+ import { DefaultConfigValues as o, SETTINGS_ENUMS as n, ItemInCartOptions as g } from "../enums/settingsEnums.js";
3
+ function _() {
4
4
  return String(Date.now() + Math.floor(Math.random() * 1e3));
5
5
  }
6
- const E = (o) => o.replace(/\$/g, "$$$$");
6
+ const E = (r) => r.replace(/\$/g, "$$$$");
7
7
  function S() {
8
8
  return {
9
9
  initialized: !0,
10
- blockInstanceId: d(),
10
+ blockInstanceId: _(),
11
11
  source: n.ITEMS_TYPE.CART_ITEMS,
12
12
  type: n.ITEMS_TYPE.CART_ITEMS,
13
- itemsSelectValue: i.cartItemsSelectControlValue,
13
+ itemsSelectValue: o.cartItemsSelectControlValue,
14
14
  orientation: n.ORIENTATION.VERTICAL,
15
- nameTrimming: i.productNameTrimmingControlValue === "1",
16
- priceHideDiscount: i.productPriceHideDiscountControlValue === "1",
17
- priceFormatted: i.productPriceFormattedControlValue === "1",
15
+ nameTrimming: o.productNameTrimmingControlValue === "1",
16
+ priceHideDiscount: o.productPriceHideDiscountControlValue === "1",
17
+ priceFormatted: o.productPriceFormattedControlValue === "1",
18
18
  priceSinglePrice: !1,
19
- priceCurrencySymbol: i.productPriceCurrencySymbolControlValue,
20
- priceCurrencyLocation: i.productPriceCurrencyLocationControlValue,
19
+ priceCurrencySymbol: o.productPriceCurrencySymbolControlValue,
20
+ priceCurrencyLocation: o.productPriceCurrencyLocationControlValue,
21
21
  priceOrientation: "horizontal",
22
- quantityControlEnabled: i.productQuantityControlEnabled === "1",
23
- buttonLink: i.productButtonLinkControlValue,
24
- imageLink: i.productImageLinkControlValue,
22
+ quantityControlEnabled: o.productQuantityControlEnabled === "1",
23
+ buttonLink: o.productButtonLinkControlValue,
24
+ imageLink: o.productImageLinkControlValue,
25
25
  buttonLabel: "Buy",
26
26
  buttonFullWidth: !0,
27
27
  // Default to full width (es-fw class)
28
- imageVisible: i.productImageVisible === "1",
29
- nameVisible: i.productNameVisible === "1",
30
- quantityVisible: i.productQuantityVisible === "1",
31
- priceVisible: i.productPriceVisible === "1",
32
- originalPriceVisible: i.productOriginalPriceVisible === "1",
33
- buttonVisible: i.productButtonVisible === "1"
28
+ imageVisible: o.productImageVisible === "1",
29
+ nameVisible: o.productNameVisible === "1",
30
+ quantityVisible: o.productQuantityVisible === "1",
31
+ priceVisible: o.productPriceVisible === "1",
32
+ originalPriceVisible: o.productOriginalPriceVisible === "1",
33
+ buttonVisible: o.productButtonVisible === "1"
34
34
  };
35
35
  }
36
- function s(o) {
37
- if (!o)
36
+ function p(r) {
37
+ if (!r)
38
38
  return null;
39
- const t = o.closest(".items-block-v2");
40
- return t || o.closest(".esd-cart-items-block");
39
+ const t = r.closest(".items-block-v2");
40
+ return t || r.closest(".esd-cart-items-block");
41
41
  }
42
- function m(o) {
43
- return o ? {
42
+ function m(r) {
43
+ return r ? {
44
44
  CartItems: n.ITEMS_TYPE.CART_ITEMS,
45
45
  BrowsedItems: n.ITEMS_TYPE.BROWSED_ITEMS,
46
46
  PurchasedItems: n.ITEMS_TYPE.PURCHASED_ITEMS,
@@ -48,34 +48,34 @@ function m(o) {
48
48
  CART_ITEMS: n.ITEMS_TYPE.CART_ITEMS,
49
49
  BROWSED_ITEMS: n.ITEMS_TYPE.BROWSED_ITEMS,
50
50
  PURCHASED_ITEMS: n.ITEMS_TYPE.PURCHASED_ITEMS
51
- }[o] || n.ITEMS_TYPE.CART_ITEMS : n.ITEMS_TYPE.CART_ITEMS;
51
+ }[r] || n.ITEMS_TYPE.CART_ITEMS : n.ITEMS_TYPE.CART_ITEMS;
52
52
  }
53
- function I(o, t) {
54
- if (!o)
55
- return i.cartItemsSelectControlValue;
56
- if (o.includes("{{"))
57
- return o;
58
- if (/^\d+$/.test(o)) {
59
- const e = parseInt(o) - 1, r = g[t];
60
- if (r && r[e])
61
- return r[e].value;
53
+ function I(r, t) {
54
+ if (!r)
55
+ return o.cartItemsSelectControlValue;
56
+ if (r.includes("{{"))
57
+ return r;
58
+ if (/^\d+$/.test(r)) {
59
+ const e = parseInt(r) - 1, i = g[t];
60
+ if (i && i[e])
61
+ return i[e].value;
62
62
  }
63
- return i.cartItemsSelectControlValue;
63
+ return o.cartItemsSelectControlValue;
64
64
  }
65
- function C(o) {
66
- const t = o.querySelector("esd-config-block");
65
+ function C(r) {
66
+ const t = r.querySelector("esd-config-block");
67
67
  if (!t)
68
68
  return null;
69
- const e = (c, a) => c == null ? a : c === "1" || c === "true", r = (c, a) => c || a, l = t.getAttribute("data-type"), u = m(l), _ = t.getAttribute("data-cart_items_select_control_value"), p = I(_, u);
69
+ const e = (c, s) => c == null ? s : c === "1" || c === "true", i = (c, s) => c || s, u = t.getAttribute("data-type"), a = m(u), d = t.getAttribute("data-cart_items_select_control_value"), l = I(d, a);
70
70
  return {
71
71
  initialized: e(t.getAttribute("data-initialized"), !1),
72
- blockInstanceId: r(
72
+ blockInstanceId: i(
73
73
  t.getAttribute("data-block-instance-id"),
74
- d()
74
+ _()
75
75
  ),
76
- source: u,
77
- type: u,
78
- itemsSelectValue: p,
76
+ source: a,
77
+ type: a,
78
+ itemsSelectValue: l,
79
79
  orientation: t.getAttribute("data-card_orientation_control_value") || n.ORIENTATION.VERTICAL,
80
80
  nameTrimming: e(
81
81
  t.getAttribute("data-product_name_control_trim"),
@@ -93,28 +93,28 @@ function C(o) {
93
93
  t.getAttribute("data-product_price_control_single_price"),
94
94
  !1
95
95
  ),
96
- priceCurrencySymbol: r(
97
- t.getAttribute("data-product_price_currency_symbol"),
98
- i.productPriceCurrencySymbolControlValue
96
+ priceCurrencySymbol: i(
97
+ t.getAttribute("data-product_price_control_currency_symbol"),
98
+ o.productPriceCurrencySymbolControlValue
99
99
  ),
100
- priceCurrencyLocation: r(
100
+ priceCurrencyLocation: i(
101
101
  t.getAttribute("data-product_price_currency_location"),
102
- i.productPriceCurrencyLocationControlValue
102
+ o.productPriceCurrencyLocationControlValue
103
103
  ),
104
104
  priceOrientation: t.getAttribute("data-product_original_price_control_orientation") || "horizontal",
105
105
  quantityControlEnabled: e(
106
106
  t.getAttribute("data-product_quantity_control_enabled"),
107
107
  !0
108
108
  ),
109
- buttonLink: r(
109
+ buttonLink: i(
110
110
  t.getAttribute("data-product_button_link"),
111
- i.productButtonLinkControlValue
111
+ o.productButtonLinkControlValue
112
112
  ),
113
- imageLink: r(
113
+ imageLink: i(
114
114
  t.getAttribute("data-product_image_link"),
115
- i.productImageLinkControlValue
115
+ o.productImageLinkControlValue
116
116
  ),
117
- buttonLabel: r(
117
+ buttonLabel: i(
118
118
  t.getAttribute("data-product_button_control_label"),
119
119
  "Buy"
120
120
  ),
@@ -149,28 +149,28 @@ function C(o) {
149
149
  )
150
150
  };
151
151
  }
152
- function y(o) {
153
- const t = s(o);
152
+ function y(r) {
153
+ const t = p(r);
154
154
  if (!t)
155
155
  return null;
156
156
  const e = t.getNodeConfig();
157
157
  if (e && e.initialized)
158
158
  return e;
159
- const r = C(t);
160
- return r || null;
159
+ const i = C(t);
160
+ return i || null;
161
161
  }
162
- function A(o, t, e) {
163
- const r = s(o);
164
- if (!r)
162
+ function A(r, t, e, i) {
163
+ const u = p(r);
164
+ if (!u)
165
165
  return;
166
- const u = { ...r.getNodeConfig() || {}, ...e };
167
- t.getDocumentModifier().modifyHtml(r).setNodeConfig(u).apply(new b("Update Items block configuration"));
166
+ const d = { ...u.getNodeConfig() || {}, ...e }, l = i ?? t.getDocumentModifier();
167
+ l.modifyHtml(u).setNodeConfig(d), i || l.apply(new b("Update Items block configuration"));
168
168
  }
169
169
  export {
170
170
  E as escapeReplacement,
171
- d as generateBlockInstanceId,
171
+ _ as generateBlockInstanceId,
172
172
  S as getDefaultItemsBlockConfig,
173
173
  y as getItemsBlockConfig,
174
- s as getItemsBlockContainer,
174
+ p as getItemsBlockContainer,
175
175
  A as setItemsBlockConfig
176
176
  };
@@ -1,11 +1,11 @@
1
1
  var u = Object.defineProperty;
2
- var p = (r, i, t) => i in r ? u(r, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[i] = t;
3
- var g = (r, i, t) => p(r, typeof i != "symbol" ? i + "" : i, t);
2
+ var p = (r, o, t) => o in r ? u(r, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[o] = t;
3
+ var g = (r, o, t) => p(r, typeof o != "symbol" ? o + "" : o, t);
4
4
  import { Block as f, BlockCompositionType as I, ModificationDescription as h } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { RecommendationConfigService as s } from "./services/configService.js";
5
+ import { RecommendationConfigService as c } from "./services/configService.js";
6
6
  import { useRecommendationExtensionStore as d } from "./store/recommendation.js";
7
7
  import { getDefaultTemplate as _ } from "./templates/grid/template.js";
8
- const k = "recommendation-block", c = "ins-recommendation-v3-block-v2", m = "recommendation-id";
8
+ const k = "recommendation-block", s = "ins-recommendation-v3-block-v2", a = "recommendation-id";
9
9
  class b extends f {
10
10
  constructor() {
11
11
  super();
@@ -50,7 +50,9 @@ class b extends f {
50
50
  */
51
51
  onCreated(t) {
52
52
  const e = this._pendingBlockId ?? this._generateNextId();
53
- this._pendingBlockId = null, this._assignRecommendationId(t, e), s.initializeConfig(this.api, t, { recommendationId: e }), d().setCurrentBlock(e);
53
+ this._pendingBlockId = null, this._assignRecommendationId(t, e);
54
+ const n = c.initializeConfig(this.api, t, { recommendationId: e }), i = d();
55
+ i.setCurrentBlock(e), i.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 });
54
56
  }
55
57
  /**
56
58
  * Called when the document changes or template is loaded
@@ -63,14 +65,14 @@ class b extends f {
63
65
  if (!(!t || !("getNodeConfig" in t))) {
64
66
  if (!this._getRecommendationId(t)) {
65
67
  const e = this._generateNextId();
66
- this._assignRecommendationId(t, e), s.hasConfig(t) && s.updateConfig(
68
+ this._assignRecommendationId(t, e), c.hasConfig(t) && c.updateConfig(
67
69
  this.api,
68
70
  t,
69
71
  { recommendationId: e },
70
72
  "Assign recommendation ID to legacy block"
71
73
  );
72
74
  }
73
- s.needsMigration(t) && this._migrateFromLegacy(t);
75
+ c.needsMigration(t) && this._migrateFromLegacy(t);
74
76
  }
75
77
  }
76
78
  /**
@@ -91,9 +93,9 @@ class b extends f {
91
93
  let t = 0;
92
94
  try {
93
95
  const e = this.api.getDocumentRoot();
94
- e && "querySelectorAll" in e && e.querySelectorAll(`.${c}`).forEach((o) => {
95
- if ("getAttribute" in o) {
96
- const a = o.getAttribute(m), l = a ? parseInt(a) : 0;
96
+ e && "querySelectorAll" in e && e.querySelectorAll(`.${s}`).forEach((i) => {
97
+ if ("getAttribute" in i) {
98
+ const m = i.getAttribute(a), l = m ? parseInt(m) : 0;
97
99
  l > t && (t = l);
98
100
  }
99
101
  });
@@ -111,8 +113,8 @@ class b extends f {
111
113
  const n = this._getBlockElement(t);
112
114
  if (!n)
113
115
  return;
114
- const o = this.api.getDocumentModifier();
115
- o.modifyHtml(n).setAttribute(m, e.toString()), o.apply(new h(`Assign recommendation ID ${e}`));
116
+ const i = this.api.getDocumentModifier();
117
+ i.modifyHtml(n).setAttribute(a, e.toString()), i.apply(new h(`Assign recommendation ID ${e}`));
116
118
  }
117
119
  /**
118
120
  * Gets the recommendation-id from a block node
@@ -121,11 +123,11 @@ class b extends f {
121
123
  const e = this._getBlockElement(t);
122
124
  if (!e || !("getAttribute" in e))
123
125
  return null;
124
- const n = e.getAttribute(m);
126
+ const n = e.getAttribute(a);
125
127
  if (!n)
126
128
  return null;
127
- const o = parseInt(n);
128
- return Number.isNaN(o) ? null : o;
129
+ const i = parseInt(n);
130
+ return Number.isNaN(i) ? null : i;
129
131
  }
130
132
  /**
131
133
  * Gets the block element (the element with BLOCK_CLASS)
@@ -133,16 +135,16 @@ class b extends f {
133
135
  _getBlockElement(t) {
134
136
  if ("getAttribute" in t) {
135
137
  const e = t.getAttribute("class");
136
- if (e && e.includes(c))
138
+ if (e && e.includes(s))
137
139
  return t;
138
140
  }
139
- return "querySelector" in t ? t.querySelector(`.${c}`) : null;
141
+ return "querySelector" in t ? t.querySelector(`.${s}`) : null;
140
142
  }
141
143
  /**
142
144
  * Migrate configuration from legacy format
143
145
  */
144
146
  _migrateFromLegacy(t) {
145
- s.migrateFromDataAttributes(this.api, t);
147
+ c.migrateFromDataAttributes(this.api, t);
146
148
  }
147
149
  }
148
150
  export {
@@ -1,6 +1,6 @@
1
1
  var d = Object.defineProperty;
2
- var m = (l, n, t) => n in l ? d(l, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[n] = t;
3
- var i = (l, n, t) => m(l, typeof n != "symbol" ? n + "" : n, t);
2
+ var m = (c, s, t) => s in c ? d(c, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[s] = t;
3
+ var n = (c, s, t) => m(c, typeof s != "symbol" ? s + "" : s, t);
4
4
  import { CommonControl as h } from "../../../common-control.js";
5
5
  import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
6
6
  import { AlgorithmControl as f } from "./algorithm.js";
@@ -15,36 +15,34 @@ import { ProductLayoutControl as _ } from "./productLayout.js";
15
15
  import { PRODUCT_LAYOUT_CONTROL_ID as K } from "./productLayout.js";
16
16
  import { ShuffleControl as N } from "./shuffle.js";
17
17
  import { SHUFFLE_CONTROL_ID as J } from "./shuffle.js";
18
- import { regenerateProductRowsWithStyles as P, getBlockElement as b, updateProductContentInPlace as y } from "./utils.js";
19
- import { formatProductPrice as X, getCardComposition as Z, getCurrentLayout as tt, reapplySpacing as et, regenerateProductRows as ot, setCurrencyAttributes as rt, updatePricesInPlace as it, updateSingleProductContent as nt } from "./utils.js";
20
- import { useDebounceFn as c } from "../../../../../node_modules/@vueuse/shared/index.js";
21
- const T = "recommendation-id", L = "ui-elements-recommendation-block";
22
- class x extends h {
18
+ import { regenerateProductRowsWithStyles as b, getBlockElement as P, updateProductContentInPlace as y } from "./utils.js";
19
+ import { formatProductPrice as X, getCardComposition as Z, getCurrentLayout as tt, reapplySpacing as et, regenerateProductRows as ot, setCurrencyAttributes as rt, updatePricesInPlace as nt, updateSingleProductContent as it } from "./utils.js";
20
+ import { useDebounceFn as a } from "../../../../../node_modules/@vueuse/shared/index.js";
21
+ const I = "recommendation-id", T = "ui-elements-recommendation-block";
22
+ class B extends h {
23
23
  constructor() {
24
24
  super(...arguments);
25
- i(this, "store", C());
26
- i(this, "storeUnsubscription", () => {
25
+ n(this, "store", C());
26
+ n(this, "storeUnsubscription", () => {
27
27
  });
28
- // Track if initial data has been fetched per block ID to avoid redundant API calls
29
- i(this, "initializedBlocks", /* @__PURE__ */ new Map());
30
28
  // Sub-control instances for lifecycle management
31
- i(this, "algorithmControl", null);
32
- i(this, "localeControl", null);
33
- i(this, "currencyControl", null);
34
- i(this, "productLayoutControl", null);
35
- i(this, "filtersControl", null);
36
- i(this, "shuffleControl", null);
29
+ n(this, "algorithmControl", null);
30
+ n(this, "localeControl", null);
31
+ n(this, "currencyControl", null);
32
+ n(this, "productLayoutControl", null);
33
+ n(this, "filtersControl", null);
34
+ n(this, "shuffleControl", null);
37
35
  /**
38
36
  * Debounced product fetch to prevent rapid API calls during config changes
39
37
  */
40
- i(this, "_debouncedFetchProducts", c(() => {
38
+ n(this, "_debouncedFetchProducts", a(() => {
41
39
  this.store.fetchRecommendationProducts();
42
40
  }, 500));
43
41
  /**
44
42
  * Debounced regeneration when products arrive from API
45
43
  * Tries in-place update first to preserve styles, falls back to full regeneration
46
44
  */
47
- i(this, "_debouncedRegenerateWithProducts", c(() => {
45
+ n(this, "_debouncedRegenerateWithProducts", a(() => {
48
46
  const t = this.store.recommendationProducts;
49
47
  if (!this.currentNode || !this.api)
50
48
  return;
@@ -57,7 +55,7 @@ class x extends h {
57
55
  }, 100));
58
56
  }
59
57
  getId() {
60
- return L;
58
+ return T;
61
59
  }
62
60
  getTemplate() {
63
61
  return this.algorithmControl = new f(), this.localeControl = new R(), this.currencyControl = new p(), this.productLayoutControl = new _(), this.filtersControl = new g(), this.shuffleControl = new N(), `
@@ -72,8 +70,9 @@ class x extends h {
72
70
  `;
73
71
  }
74
72
  async onRender() {
73
+ var e;
75
74
  const t = this._getRecommendationIdFromNode(this.currentNode) ?? this.store.currentRecommendationId;
76
- if (t !== null && this.store.setCurrentBlock(t), this._listenStateUpdates(), t !== null && this.initializedBlocks.get(t)) {
75
+ if (t !== null && this.store.setCurrentBlock(t), this._listenStateUpdates(), t !== null && ((e = this.store.blockStates[t]) != null && e.isInitialized)) {
77
76
  this._initializeSubControls();
78
77
  return;
79
78
  }
@@ -88,16 +87,17 @@ class x extends h {
88
87
  console.warn("[Recommendation] Cannot regenerate - missing currentNode or api");
89
88
  return;
90
89
  }
91
- P({
90
+ b({
92
91
  currentNode: this.currentNode,
93
92
  documentModifier: this.api.getDocumentModifier(),
94
93
  products: t
95
94
  });
96
95
  }
97
96
  onTemplateNodeUpdated(t) {
97
+ var i;
98
98
  super.onTemplateNodeUpdated(t);
99
99
  const e = this._getRecommendationIdFromNode(t);
100
- e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && !this.initializedBlocks.get(e) && this._fetchBlockData(e), [
100
+ e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && !((i = this.store.blockStates[e]) != null && i.isInitialized) && this._fetchBlockData(e), [
101
101
  this.algorithmControl,
102
102
  this.localeControl,
103
103
  this.currencyControl,
@@ -105,8 +105,8 @@ class x extends h {
105
105
  this.filtersControl,
106
106
  this.shuffleControl
107
107
  ].forEach((r) => {
108
- var s;
109
- r != null && r.api && (r.currentNode = t, (s = r.onTemplateNodeUpdated) == null || s.call(r, t));
108
+ var l;
109
+ r != null && r.api && (r.currentNode = t, (l = r.onTemplateNodeUpdated) == null || l.call(r, t));
110
110
  });
111
111
  }
112
112
  onDestroy() {
@@ -145,30 +145,30 @@ class x extends h {
145
145
  * Marks the block as initialized to prevent redundant fetches on re-selection.
146
146
  */
147
147
  async _fetchBlockData(t) {
148
- t !== null && this.initializedBlocks.set(t, !0), (await Promise.allSettled([
148
+ t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
149
149
  this.store.fetchRecommendationFilters(),
150
150
  this.store.fetchRecommendationCreateData(),
151
151
  this.store.fetchRecommendationProducts()
152
- ])).forEach((o, r) => {
152
+ ])).forEach((o, i) => {
153
153
  o.status === "rejected" && console.warn(`Recommendation block: ${[
154
154
  "fetchRecommendationFilters",
155
155
  "fetchRecommendationCreateData",
156
156
  "fetchRecommendationProducts"
157
- ][r]} failed`, o.reason);
157
+ ][i]} failed`, o.reason);
158
158
  });
159
159
  }
160
160
  /**
161
161
  * Reads the recommendation-id attribute from the block element within the node
162
162
  */
163
163
  _getRecommendationIdFromNode(t) {
164
- const e = b(t);
164
+ const e = P(t);
165
165
  if (!e || !("getAttribute" in e))
166
166
  return null;
167
- const o = e.getAttribute(T);
167
+ const o = e.getAttribute(I);
168
168
  if (!o)
169
169
  return null;
170
- const r = parseInt(o);
171
- return Number.isNaN(r) ? null : r;
170
+ const i = parseInt(o);
171
+ return Number.isNaN(i) ? null : i;
172
172
  }
173
173
  /**
174
174
  * Listen to store changes that require product refresh or regeneration.
@@ -181,17 +181,17 @@ class x extends h {
181
181
  const { store: t } = this;
182
182
  let e = t.recommendationProducts, o = t.$state.configVersion;
183
183
  this.storeUnsubscription = t.$subscribe(() => {
184
- const r = t.$state.configVersion;
185
- r !== o && (o = r, this._debouncedFetchProducts());
186
- const s = t.recommendationProducts, a = s !== e, u = Array.isArray(s) && s.length > 0;
187
- a && u && (e = s, this._debouncedRegenerateWithProducts());
184
+ const i = t.$state.configVersion;
185
+ i !== o && (o = i, this._debouncedFetchProducts());
186
+ const r = t.recommendationProducts, l = r !== e, u = Array.isArray(r) && r.length > 0;
187
+ l && u && (e = r, this._debouncedRegenerateWithProducts());
188
188
  });
189
189
  }
190
190
  }
191
191
  export {
192
192
  M as ALGORITHM_CONTROL_ID,
193
193
  f as AlgorithmControl,
194
- L as CONTROL_BLOCK_ID,
194
+ T as CONTROL_BLOCK_ID,
195
195
  W as CURRENCY_CONTROL_ID,
196
196
  p as CurrencyControl,
197
197
  H as FILTERS_CONTROL_ID,
@@ -200,18 +200,18 @@ export {
200
200
  R as LocaleControl,
201
201
  K as PRODUCT_LAYOUT_CONTROL_ID,
202
202
  _ as ProductLayoutControl,
203
- x as RecommendationBlockControl,
203
+ B as RecommendationBlockControl,
204
204
  J as SHUFFLE_CONTROL_ID,
205
205
  N as ShuffleControl,
206
206
  X as formatProductPrice,
207
- b as getBlockElement,
207
+ P as getBlockElement,
208
208
  Z as getCardComposition,
209
209
  tt as getCurrentLayout,
210
210
  et as reapplySpacing,
211
211
  ot as regenerateProductRows,
212
- P as regenerateProductRowsWithStyles,
212
+ b as regenerateProductRowsWithStyles,
213
213
  rt as setCurrencyAttributes,
214
- it as updatePricesInPlace,
214
+ nt as updatePricesInPlace,
215
215
  y as updateProductContentInPlace,
216
- nt as updateSingleProductContent
216
+ it as updateSingleProductContent
217
217
  };