@useinsider/guido 3.21.2-beta.4b0fed7 → 3.21.2-beta.4c14c74

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 (45) hide show
  1. package/dist/composables/useSave.js +75 -68
  2. package/dist/composables/validators/useHtmlDocumentCountValidator.js +22 -0
  3. package/dist/config/compiler/utils/recommendationCompilerUtils.js +22 -22
  4. package/dist/config/migrator/recommendation/compositionMapper.js +49 -56
  5. package/dist/config/migrator/recommendation/extractors.js +29 -68
  6. package/dist/config/migrator/recommendation/htmlBuilder.js +200 -283
  7. package/dist/config/migrator/recommendation/settingsMapper.js +32 -35
  8. package/dist/config/migrator/recommendationMigrator.js +29 -32
  9. package/dist/extensions/Blocks/Items/controls/button/link.js +14 -17
  10. package/dist/extensions/Blocks/Items/controls/cardComposition.js +14 -17
  11. package/dist/extensions/Blocks/Items/controls/image/link.js +14 -17
  12. package/dist/extensions/Blocks/Items/controls/name/trimming.js +9 -10
  13. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +24 -25
  14. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -13
  15. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +29 -30
  16. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +15 -16
  17. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +25 -26
  18. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +27 -28
  19. package/dist/extensions/Blocks/Items/controls/settingsControl.js +75 -80
  20. package/dist/extensions/Blocks/Recommendation/block.js +24 -33
  21. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +3 -3
  22. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +7 -7
  23. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +13 -13
  24. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +229 -208
  25. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
  26. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +8 -8
  27. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +15 -15
  28. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +12 -12
  29. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +10 -10
  30. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +1 -1
  31. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +2 -1
  32. package/dist/extensions/Blocks/common-control.js +62 -55
  33. package/dist/services/templateLibraryApi.js +36 -31
  34. package/dist/src/composables/validators/useHtmlDocumentCountValidator.d.ts +3 -0
  35. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +1 -3
  36. package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -20
  37. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +0 -1
  38. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -1
  39. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +11 -4
  40. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +2 -3
  41. package/dist/src/extensions/Blocks/common-control.d.ts +2 -0
  42. package/dist/src/utils/templatePreparation.d.ts +2 -1
  43. package/dist/utils/pairProductVariables.js +98 -90
  44. package/dist/utils/templatePreparation.js +30 -30
  45. package/package.json +1 -1
@@ -1,79 +1,79 @@
1
- var N = Object.defineProperty;
2
- var y = (u, c, e) => c in u ? N(u, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[c] = e;
3
- var r = (u, c, e) => y(u, typeof c != "symbol" ? c + "" : c, e);
1
+ var _ = Object.defineProperty;
2
+ var N = (u, c, e) => c in u ? _(u, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[c] = e;
3
+ var s = (u, c, e) => N(u, typeof c != "symbol" ? c + "" : c, e);
4
4
  import { useConfig as g } from "../../../../../composables/useConfig.js";
5
- import { ModificationDescription as P } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
- import { CommonControl as R } from "../../../common-control.js";
7
- import { RRS_CONFIG_VERSION as I, DEFAULT_NODE_CONFIG as m } from "../../constants/defaultConfig.js";
8
- import { RECOMMENDATION_ID_ATTR as k } from "../../constants/selectors.js";
9
- import { RecommendationConfigService as d } from "../../services/configService.js";
10
- import { useRecommendationExtensionStore as S } from "../../store/recommendation.js";
11
- import { refreshBlockOutsidePanel as T } from "../../utils/blockRefresh.js";
12
- import { registerNodeConfigWriter as O, writeBlockConfigOutsidePanel as C, hasEditedConfigChange as b, pickConfigDescription as B, isProductIdsChange as F, PRODUCT_IDS_DESCRIPTION as D } from "../../utils/nodeConfigWriter.js";
13
- import { AlgorithmControl as L } from "./algorithm.js";
14
- import { ALGORITHM_CONTROL_ID as Ne } from "./algorithm.js";
15
- import { CurrencyControl as E } from "./currency.js";
16
- import { CURRENCY_CONTROL_ID as Pe } from "./currency.js";
17
- import { FiltersControl as U } from "./filters.js";
18
- import { FILTERS_CONTROL_ID as Ie } from "./filters.js";
19
- import { LayoutOrientationControl as v } from "./layoutOrientation.js";
20
- import { LAYOUT_ORIENTATION_CONTROL_ID as Se } from "./layoutOrientation.js";
21
- import { LocaleControl as w } from "./locale.js";
22
- import { LOCALE_CONTROL_ID as Oe } from "./locale.js";
5
+ import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { CommonControl as P } from "../../../common-control.js";
7
+ import { RRS_CONFIG_VERSION as R, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
8
+ import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
9
+ import { RecommendationConfigService as l } from "../../services/configService.js";
10
+ import { useRecommendationExtensionStore as k } from "../../store/recommendation.js";
11
+ import { refreshBlockOutsidePanel as S } from "../../utils/blockRefresh.js";
12
+ import { registerNodeConfigWriter as T, writeBlockConfigOutsidePanel as m, hasEditedConfigChange as O, pickConfigDescription as b, isProductIdsChange as B, PRODUCT_IDS_DESCRIPTION as L } from "../../utils/nodeConfigWriter.js";
13
+ import { AlgorithmControl as E } from "./algorithm.js";
14
+ import { ALGORITHM_CONTROL_ID as _e } from "./algorithm.js";
15
+ import { CurrencyControl as F } from "./currency.js";
16
+ import { CURRENCY_CONTROL_ID as ye } from "./currency.js";
17
+ import { FiltersControl as D } from "./filters.js";
18
+ import { FILTERS_CONTROL_ID as Re } from "./filters.js";
19
+ import { LayoutOrientationControl as U } from "./layoutOrientation.js";
20
+ import { LAYOUT_ORIENTATION_CONTROL_ID as ke } from "./layoutOrientation.js";
21
+ import { LocaleControl as v } from "./locale.js";
22
+ import { LOCALE_CONTROL_ID as Te } from "./locale.js";
23
23
  import { PricePlacementControl as A } from "./pricePlacement.js";
24
- import { PRICE_PLACEMENT_CONTROL_ID as Be } from "./pricePlacement.js";
25
- import { ProductCountControl as V } from "./productCount.js";
26
- import { PRODUCT_COUNT_CONTROL_ID as De } from "./productCount.js";
27
- import { ProductLayoutControl as W } from "./productLayout.js";
28
- import { PRODUCT_LAYOUT_CONTROL_ID as Ee } from "./productLayout.js";
29
- import { ShuffleControl as x } from "./shuffle.js";
30
- import { SHUFFLE_CONTROL_ID as ve } from "./shuffle.js";
31
- import { StrategyControl as M } from "./strategy.js";
24
+ import { PRICE_PLACEMENT_CONTROL_ID as be } from "./pricePlacement.js";
25
+ import { ProductCountControl as w } from "./productCount.js";
26
+ import { PRODUCT_COUNT_CONTROL_ID as Le } from "./productCount.js";
27
+ import { ProductLayoutControl as V } from "./productLayout.js";
28
+ import { PRODUCT_LAYOUT_CONTROL_ID as Fe } from "./productLayout.js";
29
+ import { ShuffleControl as W } from "./shuffle.js";
30
+ import { SHUFFLE_CONTROL_ID as Ue } from "./shuffle.js";
31
+ import { StrategyControl as x } from "./strategy.js";
32
32
  import { STRATEGY_CONTROL_ID as Ae } from "./strategy.js";
33
- import { setCurrencyAttributes as G, getBlockElement as z, isPartnerManagedBlock as $, updateProductContentInPlace as H, regenerateProductRowsWithStyles as Y } from "./utils.js";
34
- import { adjustProductsToSize as We, formatProductPrice as xe, getCardComposition as Me, getCurrentLayout as Ge, getMainContainerTbody as ze, regenerateMobileProductRows as $e, updatePricesInPlace as He, updateSingleProductContent as Ye } from "./utils.js";
35
- import { useDebounceFn as p } from "../../../../../node_modules/@vueuse/shared/index.js";
36
- const h = "Update recommendation filters", j = "ui-elements-recommendation-block";
37
- class Ce extends R {
33
+ import { setCurrencyAttributes as M, getBlockElement as G, isPartnerManagedBlock as $, updateProductContentInPlace as z, regenerateProductRowsWithStyles as H } from "./utils.js";
34
+ import { adjustProductsToSize as Ve, formatProductPrice as We, getCardComposition as xe, getCurrentLayout as Me, getMainContainerTbody as Ge, regenerateMobileProductRows as $e, updatePricesInPlace as ze, updateSingleProductContent as He } from "./utils.js";
35
+ import { useDebounceFn as C } from "../../../../../node_modules/@vueuse/shared/index.js";
36
+ const f = "Update recommendation filters", Y = "ui-elements-recommendation-block";
37
+ class me extends P {
38
38
  constructor() {
39
39
  super(...arguments);
40
- r(this, "store", S());
41
- r(this, "storeUnsubscription", () => {
40
+ s(this, "store", k());
41
+ s(this, "storeUnsubscription", () => {
42
42
  });
43
43
  // A config change waiting to reach the node config. Deferred so it can ride the
44
44
  // re-render's single apply() — one user action must cost one undo press.
45
- r(this, "pendingNodeConfigWrite", null);
46
- r(this, "pendingConfigFlushTimer", null);
45
+ s(this, "pendingNodeConfigWrite", null);
46
+ s(this, "pendingConfigFlushTimer", null);
47
47
  // What the panel still owes the block it watches — finished outside the panel on teardown
48
48
  // and block switch. A new generation tells debounced work queued for the old one to stand down.
49
- r(this, "trackedBlockId", null);
50
- r(this, "fetchedConfigVersion", 0);
51
- r(this, "hasUnrenderedProducts", !1);
52
- r(this, "panelGeneration", 0);
53
- r(this, "isPanelAlive", !0);
49
+ s(this, "trackedBlockId", null);
50
+ s(this, "fetchedConfigVersion", 0);
51
+ s(this, "hasUnrenderedProducts", !1);
52
+ s(this, "panelGeneration", 0);
53
+ s(this, "isPanelAlive", !0);
54
54
  // Sub-control instances for lifecycle management
55
- r(this, "algorithmControl", null);
56
- r(this, "localeControl", null);
57
- r(this, "currencyControl", null);
58
- r(this, "productCountControl", null);
59
- r(this, "productLayoutControl", null);
60
- r(this, "filtersControl", null);
61
- r(this, "shuffleControl", null);
62
- r(this, "pricePlacementControl", null);
63
- r(this, "layoutOrientationControl", null);
64
- r(this, "strategyControl", null);
65
- r(this, "rrsEnabled", !1);
55
+ s(this, "algorithmControl", null);
56
+ s(this, "localeControl", null);
57
+ s(this, "currencyControl", null);
58
+ s(this, "productCountControl", null);
59
+ s(this, "productLayoutControl", null);
60
+ s(this, "filtersControl", null);
61
+ s(this, "shuffleControl", null);
62
+ s(this, "pricePlacementControl", null);
63
+ s(this, "layoutOrientationControl", null);
64
+ s(this, "strategyControl", null);
65
+ s(this, "rrsEnabled", !1);
66
66
  /**
67
67
  * Debounced product fetch to prevent rapid API calls during config changes
68
68
  */
69
- r(this, "_debouncedFetchProducts", p(async (e, t) => {
69
+ s(this, "_debouncedFetchProducts", C(async (e, t) => {
70
70
  if (t !== this.panelGeneration)
71
71
  return;
72
- const o = this._getBlockConfigVersion(e);
72
+ const n = this._getBlockConfigVersion(e);
73
73
  try {
74
- await (e === null ? this.store.fetchRecommendationProducts() : this.store.fetchRecommendationProductsForBlock(e)), t === this.panelGeneration && (this.fetchedConfigVersion = Math.max(this.fetchedConfigVersion, o));
74
+ await (e === null ? this.store.fetchRecommendationProducts() : this.store.fetchRecommendationProductsForBlock(e)), t === this.panelGeneration && (this.fetchedConfigVersion = Math.max(this.fetchedConfigVersion, n));
75
75
  } finally {
76
- t === this.panelGeneration && o === this._getBlockConfigVersion(e) && this._scheduleConfigFlush();
76
+ t === this.panelGeneration && n === this._getBlockConfigVersion(e) && this._scheduleConfigFlush();
77
77
  }
78
78
  }, 500));
79
79
  /**
@@ -87,11 +87,11 @@ class Ce extends R {
87
87
  * count. The store pads products to the configured size, so in-place only
88
88
  * fails when the size actually changed.
89
89
  */
90
- r(this, "_debouncedRegenerateWithProducts", p((e) => {
90
+ s(this, "_debouncedRegenerateWithProducts", C((e) => {
91
91
  if (e !== this.panelGeneration || !this.currentNode || !this.api)
92
92
  return;
93
- const t = this._getRecommendationIdFromNode(this.currentNode), o = this.store.currentRecommendationId;
94
- if (t === null || o === null || t === o || !this.store.blockStates[t]) {
93
+ const t = this._getRecommendationIdFromNode(this.currentNode), n = this.store.currentRecommendationId;
94
+ if (t === null || n === null || t === n || !this.store.blockStates[t]) {
95
95
  this.hasUnrenderedProducts = !1, this._regenerateWithProducts();
96
96
  return;
97
97
  }
@@ -100,13 +100,13 @@ class Ce extends R {
100
100
  try {
101
101
  this._regenerateWithProducts();
102
102
  } finally {
103
- this.store.setCurrentBlock(o);
103
+ this.store.setCurrentBlock(n);
104
104
  }
105
105
  }
106
106
  }, 100));
107
107
  }
108
108
  getId() {
109
- return j;
109
+ return Y;
110
110
  }
111
111
  get _subControls() {
112
112
  return [
@@ -125,9 +125,9 @@ class Ce extends R {
125
125
  getTemplate() {
126
126
  var e;
127
127
  return this.rrsEnabled = g().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
128
- var o;
129
- return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
130
- }), this.algorithmControl = new L(), this.localeControl = new w(), this.currencyControl = new E(), this.productCountControl = new V(), this.productLayoutControl = new W(), this.filtersControl = new U(), this.shuffleControl = new x(), this.pricePlacementControl = new A(), this.layoutOrientationControl = new v(), this.strategyControl = this.rrsEnabled ? new M() : null, this._subControls.forEach((t) => {
128
+ var n;
129
+ return (n = t == null ? void 0 : t.onDestroy) == null ? void 0 : n.call(t);
130
+ }), this.algorithmControl = new E(), this.localeControl = new v(), this.currencyControl = new F(), this.productCountControl = new w(), this.productLayoutControl = new V(), this.filtersControl = new D(), this.shuffleControl = new W(), this.pricePlacementControl = new A(), this.layoutOrientationControl = new U(), this.strategyControl = this.rrsEnabled ? new x() : null, this._subControls.forEach((t) => {
131
131
  t && (t.api = this.api);
132
132
  }), `
133
133
  <div class="recommendation-controls-container">
@@ -145,36 +145,29 @@ class Ce extends R {
145
145
  `;
146
146
  }
147
147
  _showControlsForBlock(e) {
148
- var s;
149
- const t = (s = this.getContainer()) == null ? void 0 : s.querySelector(".recommendation-controls-container");
148
+ var r;
149
+ const t = (r = this.getContainer()) == null ? void 0 : r.querySelector(".recommendation-controls-container");
150
150
  if (!t)
151
151
  return;
152
- const o = this._getRecommendationIdFromNode(e) === null ? null : d.getConfig(e), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= I), i = this.rrsEnabled && !!o && !n;
153
- t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", i);
152
+ const n = this._getRecommendationIdFromNode(e) === null ? null : l.getConfig(e), o = this.rrsEnabled && !!n && (!!(n != null && n.strategyId) || ((n == null ? void 0 : n.configVersion) ?? 0) >= R), i = this.rrsEnabled && !!n && !o;
153
+ t.classList.toggle("strategy-block", o), t.classList.toggle("legacy-strategy-block", i);
154
154
  }
155
- async onRender() {
156
- var o;
157
- O(this.api);
158
- const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
159
- if (t !== null && this.store.setCurrentBlock(t), e !== null && this._syncNodeConfigIfChanged(e), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender()), t !== null && ((o = this.store.blockStates[t]) != null && o.isInitialized)) {
160
- this._initializeSubControls();
161
- return;
162
- }
163
- await this._fetchBlockData(t), this._initializeSubControls();
155
+ onRender() {
156
+ T(this.api), this.forgetLastPanelNode(), this._listenStateUpdates();
164
157
  }
165
158
  onTemplateNodeUpdated(e) {
166
- var o;
159
+ var n;
167
160
  super.onTemplateNodeUpdated(e);
168
161
  const t = this._getRecommendationIdFromNode(e);
169
- t !== null && t !== this.store.currentRecommendationId && this.store.setCurrentBlock(t), t !== null && this._syncNodeConfigIfChanged(t), this._showControlsForBlock(e), t !== null && !((o = this.store.blockStates[t]) != null && o.isInitialized) && this._fetchBlockData(t).then(() => {
162
+ t !== null && t !== this.store.currentRecommendationId && this.store.setCurrentBlock(t), t !== null && this._syncNodeConfigIfChanged(t), this._showControlsForBlock(e), this._renderWithPanelNode(t), t !== null && !((n = this.store.blockStates[t]) != null && n.isInitialized) && this._fetchBlockData(t).then(() => {
170
163
  this._initializeSubControls();
171
- }), this._subControls.forEach((n) => {
164
+ }), this._subControls.forEach((o) => {
172
165
  var i;
173
- n != null && n.api && (n.currentNode = e, (i = n.onTemplateNodeUpdated) == null || i.call(n, e));
166
+ o != null && o.api && (o.currentNode = e, (i = o.onTemplateNodeUpdated) == null || i.call(o, e));
174
167
  });
175
168
  }
176
169
  onDestroy() {
177
- this.panelGeneration++, this.isPanelAlive = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this._subControls.forEach((e) => {
170
+ this.panelGeneration++, this.isPanelAlive = !1, this.isAwaitingPanelNode = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this._subControls.forEach((e) => {
178
171
  var t;
179
172
  return (t = e == null ? void 0 : e.onDestroy) == null ? void 0 : t.call(e);
180
173
  });
@@ -184,11 +177,23 @@ class Ce extends R {
184
177
  * Each sub-control manages its own form values and event listeners
185
178
  */
186
179
  _initializeSubControls() {
187
- this._subControls.forEach((e) => {
180
+ this.currentNode && this._subControls.forEach((e) => {
188
181
  var t;
189
182
  e && (e.api = this.api, e.currentNode = this.currentNode, (t = e.onRender) == null || t.call(e));
190
183
  });
191
184
  }
185
+ // The panel's own node, not the store's last focused block, decides what to render; the caller
186
+ // fetches an uninitialized block once its config is synced.
187
+ _renderWithPanelNode(e) {
188
+ var t;
189
+ if (!(!this.isAwaitingPanelNode || e === null)) {
190
+ if (this.isAwaitingPanelNode = !1, (t = this.store.blockStates[e]) != null && t.isInitialized) {
191
+ this._initializeSubControls();
192
+ return;
193
+ }
194
+ this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender());
195
+ }
196
+ }
192
197
  /**
193
198
  * Syncs persisted node config into the Pinia store's block state.
194
199
  *
@@ -219,13 +224,13 @@ class Ce extends R {
219
224
  const t = this.store.blockStates[e];
220
225
  if (!t)
221
226
  return;
222
- const o = JSON.stringify(d.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
223
- t.syncedConfigFingerprint = o, n !== o && ((i = this.pendingNodeConfigWrite) == null ? void 0 : i.blockId) !== e && this._syncNodeConfigToStore();
227
+ const n = JSON.stringify(l.getConfig(this.currentNode)), o = t.syncedConfigFingerprint;
228
+ t.syncedConfigFingerprint = n, o !== n && ((i = this.pendingNodeConfigWrite) == null ? void 0 : i.blockId) !== e && this._syncNodeConfigToStore();
224
229
  }
225
230
  /** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
226
231
  _isPendingStrategyIdChange() {
227
232
  const e = this.pendingNodeConfigWrite;
228
- return e ? d.getConfig(this.currentNode).strategyId !== e.updates.strategyId : !1;
233
+ return e ? l.getConfig(this.currentNode).strategyId !== e.updates.strategyId : !1;
229
234
  }
230
235
  _capturePendingNodeConfigWrite() {
231
236
  const e = this.store.currentRecommendationId, t = e === null ? void 0 : this.store.blockStates[e];
@@ -240,15 +245,15 @@ class Ce extends R {
240
245
  return !e || t !== null && e.blockId !== t ? null : e;
241
246
  }
242
247
  _getNodeConfigUpdates(e) {
243
- const { filters: t, strategy: o, strategyId: n, size: i, productIds: s, nodeConfigVersion: l } = e, { partnerName: a } = g();
248
+ const { filters: t, strategy: n, strategyId: o, size: i, productIds: r, nodeConfigVersion: h } = e, { partnerName: d } = g();
244
249
  return {
245
250
  filters: t,
246
- strategy: o,
247
- strategyId: n,
251
+ strategy: n,
252
+ strategyId: o,
248
253
  size: i,
249
- productIds: s,
250
- configVersion: l,
251
- ...a.value ? { partnerName: a.value } : {}
254
+ productIds: r,
255
+ configVersion: h,
256
+ ...d.value ? { partnerName: d.value } : {}
252
257
  };
253
258
  }
254
259
  /**
@@ -263,7 +268,7 @@ class Ce extends R {
263
268
  */
264
269
  _stagePendingNodeConfig(e) {
265
270
  const t = this._pendingWriteForNode();
266
- return !t || !this.currentNode ? !1 : (d.stageConfig(e, this.currentNode, t.updates), !0);
271
+ return !t || !this.currentNode ? !1 : (l.stageConfig(e, this.currentNode, t.updates), !0);
267
272
  }
268
273
  /**
269
274
  * Arms the guaranteed fallback write, once the product fetch has settled. The
@@ -287,15 +292,15 @@ class Ce extends R {
287
292
  const e = this.pendingNodeConfigWrite;
288
293
  if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !(!e || !this.api)) {
289
294
  if (e.blockId !== this.store.currentRecommendationId || !this.currentNode) {
290
- const { blockId: t, updates: o } = e;
291
- !C(t, o, h) && this.store.blockStates[t] && console.error("[recommendation] pending config write did not reach a node", { blockId: t });
295
+ const { blockId: t, updates: n } = e;
296
+ !m(t, n, f) && this.store.blockStates[t] && console.error("[recommendation] pending config write did not reach a node", { blockId: t });
292
297
  return;
293
298
  }
294
- b(this.currentNode, e.updates) && d.updateConfig(
299
+ O(this.currentNode, e.updates) && l.updateConfig(
295
300
  this.api,
296
301
  this.currentNode,
297
302
  e.updates,
298
- B(this.currentNode, e.updates, h)
303
+ b(this.currentNode, e.updates, f)
299
304
  );
300
305
  }
301
306
  }
@@ -306,12 +311,12 @@ class Ce extends R {
306
311
  /** The Product Ids label when the pending write moves the node's ids; the caller's default otherwise. */
307
312
  _pendingDescription() {
308
313
  const e = this._pendingWriteForNode();
309
- if (!(!e || !this.currentNode || !F(this.currentNode, e.updates)))
310
- return D;
314
+ if (!(!e || !this.currentNode || !B(this.currentNode, e.updates)))
315
+ return L;
311
316
  }
312
317
  _syncNodeConfigToStore() {
313
- var n;
314
- const e = d.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
318
+ var o;
319
+ const e = l.getConfig(this.currentNode), t = this.store.currentRecommendationId, n = t !== null && ((o = this.store.blockStates[t]) == null ? void 0 : o.isInitialized);
315
320
  this.store.patchCurrentBlockConfig({
316
321
  strategy: e.strategy,
317
322
  strategyId: e.strategyId,
@@ -326,7 +331,7 @@ class Ce extends R {
326
331
  // Only sync filters from node config during initial load.
327
332
  // After initialization, the Pinia store is the source of truth
328
333
  // for filters (edited via the filter drawer).
329
- ...o ? {} : { filters: e.filters },
334
+ ...n ? {} : { filters: e.filters },
330
335
  shuffleProducts: e.shuffleProducts,
331
336
  priceMovedToNextLine: e.priceMovedToNextLine,
332
337
  priceHideIfSameAsDiscounted: e.priceHideIfSameAsDiscounted,
@@ -347,74 +352,90 @@ class Ce extends R {
347
352
  * 2. Smart defaults for new blocks (currency, algorithm) — sequential
348
353
  * 3. Product data with correct defaults — sequential
349
354
  *
350
- * Shared by onRender() and onTemplateNodeUpdated() to avoid duplication.
355
+ * Called from onTemplateNodeUpdated() once the node config is synced.
351
356
  * Marks the block as initialized to prevent redundant fetches on re-selection.
352
357
  */
353
358
  async _fetchBlockData(e) {
354
359
  if (e !== null && this.store.markBlockInitialized(e), (await Promise.allSettled([
355
360
  this.store.fetchRecommendationCreateData(),
356
361
  this.store.fetchRecommendationFilters()
357
- ])).forEach((n, i) => {
358
- n.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][i]} failed`, n.reason);
362
+ ])).forEach((o, i) => {
363
+ o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][i]} failed`, o.reason);
359
364
  }), e !== null && this.store.currentRecommendationId !== e) {
360
365
  this._refreshOutsidePanel(e, !0);
361
366
  return;
362
367
  }
363
368
  this._applySmartDefaults();
364
- const o = this._getBlockConfigVersion(e);
369
+ const n = this._getBlockConfigVersion(e);
365
370
  try {
366
371
  await this.store.fetchRecommendationProducts();
367
- } catch (n) {
368
- console.warn("Recommendation block: fetchRecommendationProducts failed", n);
372
+ } catch (o) {
373
+ console.warn("Recommendation block: fetchRecommendationProducts failed", o);
369
374
  }
370
- e !== null && !this._isPanelOn(e) && this._refreshOutsidePanel(e, this._getBlockConfigVersion(e) !== o);
375
+ e !== null && !this._isPanelOn(e) && this._refreshOutsidePanel(e, this._getBlockConfigVersion(e) !== n);
371
376
  }
372
377
  _isPanelOn(e) {
373
378
  return this.isPanelAlive && this.store.currentRecommendationId === e;
374
379
  }
375
380
  /**
376
- * Falls back to the first available option when the block's currency or locale is not offered (a new block on
377
- * the hard-coded default, or a block copied from another account). The algorithm falls back only on new blocks.
381
+ * Applies smart defaults for newly dropped blocks.
382
+ *
383
+ * For new blocks (config still matches hardcoded defaults), validates that
384
+ * the default currency and algorithm are available from the API response.
385
+ * If not, falls back to the first available option.
386
+ *
387
+ * Saved templates with user-customized config are left unchanged because
388
+ * their values won't match the hardcoded defaults.
378
389
  */
379
390
  _applySmartDefaults() {
380
391
  if (!this.currentNode || !this.api)
381
392
  return;
382
- const e = d.getConfig(this.currentNode), t = {};
383
- let o = null, n = null, i = null;
384
- const { currencyList: s } = this.store;
385
- if (s.length > 0 && !s.some((a) => a.value === `price.${e.currency.code}`) && (o = s[0].value.replace("price.", ""), t.currency = {
386
- ...e.currency,
387
- code: o,
388
- symbol: o
389
- }), e.strategy === m.strategy) {
390
- const a = this.store.getActivePredictiveAlgorithms;
391
- a.length > 0 && (a.some(
392
- (_) => _.value === m.strategy
393
- ) || (n = a[0].value, t.strategy = n));
393
+ const e = l.getConfig(this.currentNode), t = {};
394
+ let n = null, o = null, i = null;
395
+ if (e.currency.code === a.currency.code) {
396
+ const { currencyList: r } = this.store;
397
+ r.length > 0 && (r.some(
398
+ (d) => d.value === `price.${a.currency.code}`
399
+ ) || (n = r[0].value.replace("price.", ""), t.currency = {
400
+ ...a.currency,
401
+ code: n,
402
+ symbol: n
403
+ }));
404
+ }
405
+ if (e.strategy === a.strategy) {
406
+ const r = this.store.getActivePredictiveAlgorithms;
407
+ r.length > 0 && (r.some(
408
+ (d) => d.value === a.strategy
409
+ ) || (o = r[0].value, t.strategy = o));
410
+ }
411
+ if (e.language === a.language) {
412
+ const r = this.store.getLanguages;
413
+ r.length > 0 && (r.some(
414
+ (d) => d.value === a.language
415
+ ) || (i = r[0].value, t.language = i));
394
416
  }
395
- const l = this.store.getLanguages;
396
- l.length > 0 && !l.some((a) => a.value === e.language) && (i = l[0].value, t.language = i), !(!o && !n && !i) && (d.updateConfig(
417
+ !n && !o && !i || (l.updateConfig(
397
418
  this.api,
398
419
  this.currentNode,
399
420
  t,
400
421
  "Applied smart defaults"
401
- ), o && t.currency && G({
422
+ ), n && t.currency && M({
402
423
  currentNode: this.currentNode,
403
424
  documentModifier: this.api.getDocumentModifier(),
404
425
  currency: t.currency
405
426
  }), this.store.patchCurrentBlockConfig({
406
- ...o && t.currency ? {
427
+ ...n ? {
407
428
  currencySettings: {
408
- name: o,
409
- value: o,
410
- symbol: o,
411
- alignment: t.currency.alignment === "before" ? "0" : "1",
412
- decimalCount: t.currency.decimalCount.toString(),
413
- decimalSeparator: t.currency.decimalSeparator,
414
- thousandSeparator: t.currency.thousandSeparator
429
+ name: n,
430
+ value: n,
431
+ symbol: n,
432
+ alignment: a.currency.alignment === "before" ? "0" : "1",
433
+ decimalCount: a.currency.decimalCount.toString(),
434
+ decimalSeparator: a.currency.decimalSeparator,
435
+ thousandSeparator: a.currency.thousandSeparator
415
436
  }
416
437
  } : {},
417
- ...n ? { strategy: n } : {},
438
+ ...o ? { strategy: o } : {},
418
439
  ...i ? { language: i } : {}
419
440
  }, { triggerRefetch: !1 }));
420
441
  }
@@ -422,33 +443,33 @@ class Ce extends R {
422
443
  * Reads the recommendation-id attribute from the block element within the node
423
444
  */
424
445
  _getRecommendationIdFromNode(e) {
425
- const t = z(e);
446
+ const t = G(e);
426
447
  if (!t || !("getAttribute" in t))
427
448
  return null;
428
- const o = t.getAttribute(k);
429
- if (!o)
449
+ const n = t.getAttribute(I);
450
+ if (!n)
430
451
  return null;
431
- const n = parseInt(o);
432
- return Number.isNaN(n) ? null : n;
452
+ const o = parseInt(n);
453
+ return Number.isNaN(o) ? null : o;
433
454
  }
434
455
  /**
435
456
  * Lands what the panel still owes its block before it stops watching it: the config now, the
436
457
  * products through a block-scoped refresh. Never throws — it runs from Stripo's teardown.
437
458
  */
438
- _finishBlockOutsidePanel({ blockId: e, fetchedConfigVersion: t, hasUnrenderedProducts: o } = this._trackedBlockSnapshot()) {
459
+ _finishBlockOutsidePanel({ blockId: e, fetchedConfigVersion: t, hasUnrenderedProducts: n } = this._trackedBlockSnapshot()) {
439
460
  try {
440
461
  this._flushPendingNodeConfig();
441
- const n = e === null ? void 0 : this.store.blockStates[e];
442
- if (e === null || !n)
462
+ const o = e === null ? void 0 : this.store.blockStates[e];
463
+ if (e === null || !o)
443
464
  return;
444
- const i = t !== n.configVersion;
445
- i && !C(
465
+ const i = t !== o.configVersion;
466
+ i && !m(
446
467
  e,
447
- this._getNodeConfigUpdates(n.recommendationConfigs),
448
- h
449
- ) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (i || o) && this._refreshOutsidePanel(e, i);
450
- } catch (n) {
451
- console.error("[recommendation] finishing the block outside the panel failed", n);
468
+ this._getNodeConfigUpdates(o.recommendationConfigs),
469
+ f
470
+ ) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (i || n) && this._refreshOutsidePanel(e, i);
471
+ } catch (o) {
472
+ console.error("[recommendation] finishing the block outside the panel failed", o);
452
473
  }
453
474
  }
454
475
  _trackedBlockSnapshot() {
@@ -459,14 +480,14 @@ class Ce extends R {
459
480
  };
460
481
  }
461
482
  _refreshOutsidePanel(e, t) {
462
- T(e, {
463
- pickUpdates: (o) => this._getNodeConfigUpdates(o),
483
+ S(e, {
484
+ pickUpdates: (n) => this._getNodeConfigUpdates(n),
464
485
  description: "Update recommendation configuration",
465
486
  fetch: t
466
- }).then((o) => {
467
- !o && this.store.blockStates[e] && console.error("[recommendation] refresh outside the panel did not reach a node", { blockId: e });
468
- }).catch((o) => {
469
- console.error("[recommendation] refresh outside the panel failed", o);
487
+ }).then((n) => {
488
+ !n && this.store.blockStates[e] && console.error("[recommendation] refresh outside the panel did not reach a node", { blockId: e });
489
+ }).catch((n) => {
490
+ console.error("[recommendation] refresh outside the panel failed", n);
470
491
  });
471
492
  }
472
493
  _getBlockConfigVersion(e) {
@@ -481,25 +502,25 @@ class Ce extends R {
481
502
  this.hasUnrenderedProducts = !0;
482
503
  return;
483
504
  }
484
- const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(), o = this._pendingDescription(), n = this._stagePendingNodeConfig(t);
505
+ const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(), n = this._pendingDescription(), o = this._stagePendingNodeConfig(t);
485
506
  if ($(this.currentNode)) {
486
- n && (t.apply(
487
- new P(o ?? "Update recommendation configuration")
507
+ o && (t.apply(
508
+ new y(n ?? "Update recommendation configuration")
488
509
  ), this._consumePendingNodeConfig());
489
510
  return;
490
511
  }
491
- H({
512
+ z({
492
513
  currentNode: this.currentNode,
493
514
  documentModifier: t,
494
515
  products: e,
495
- description: o,
496
- onApplied: n ? () => this._consumePendingNodeConfig() : void 0
497
- }) || Y({
516
+ description: n,
517
+ onApplied: o ? () => this._consumePendingNodeConfig() : void 0
518
+ }) || H({
498
519
  currentNode: this.currentNode,
499
520
  documentModifier: t,
500
521
  products: e,
501
- description: o
502
- }) && n && this._consumePendingNodeConfig();
522
+ description: n
523
+ }) && o && this._consumePendingNodeConfig();
503
524
  }
504
525
  // Spent only once it landed with the cards (never when another block's write stayed unstaged):
505
526
  // kept alive, it blocks the store resync an Undo needs and the flush writes the undone ids back.
@@ -521,55 +542,55 @@ class Ce extends R {
521
542
  */
522
543
  _listenStateUpdates() {
523
544
  const { store: e } = this;
524
- let t = e.recommendationProducts, o = this._getBlockConfigVersion(e.currentRecommendationId);
525
- this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this.storeUnsubscription = e.$subscribe(() => {
526
- const n = e.currentRecommendationId;
527
- if (n !== this.trackedBlockId) {
528
- const f = this._trackedBlockSnapshot();
529
- this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(f);
545
+ let t = e.recommendationProducts, n = this._getBlockConfigVersion(e.currentRecommendationId);
546
+ this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion = n, this.hasUnrenderedProducts = !1, this.storeUnsubscription = e.$subscribe(() => {
547
+ const o = e.currentRecommendationId;
548
+ if (o !== this.trackedBlockId) {
549
+ const p = this._trackedBlockSnapshot();
550
+ this.panelGeneration++, this.trackedBlockId = o, t = e.recommendationProducts, n = this._getBlockConfigVersion(o), this.fetchedConfigVersion = n, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(p);
530
551
  return;
531
552
  }
532
- const i = this._getBlockConfigVersion(n);
533
- i !== o && (o = i, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts(n, this.panelGeneration));
534
- const s = e.recommendationProducts, l = s !== t, a = Array.isArray(s) && s.length > 0;
535
- l && a && (t = s, this.hasUnrenderedProducts = !0, this._debouncedRegenerateWithProducts(this.panelGeneration));
553
+ const i = this._getBlockConfigVersion(o);
554
+ i !== n && (n = i, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts(o, this.panelGeneration));
555
+ const r = e.recommendationProducts, h = r !== t, d = Array.isArray(r) && r.length > 0;
556
+ h && d && (t = r, this.hasUnrenderedProducts = !0, this._debouncedRegenerateWithProducts(this.panelGeneration));
536
557
  });
537
558
  }
538
559
  }
539
560
  export {
540
- Ne as ALGORITHM_CONTROL_ID,
541
- L as AlgorithmControl,
542
- j as CONTROL_BLOCK_ID,
543
- Pe as CURRENCY_CONTROL_ID,
544
- E as CurrencyControl,
545
- Ie as FILTERS_CONTROL_ID,
546
- U as FiltersControl,
547
- Se as LAYOUT_ORIENTATION_CONTROL_ID,
548
- Oe as LOCALE_CONTROL_ID,
549
- v as LayoutOrientationControl,
550
- w as LocaleControl,
551
- Be as PRICE_PLACEMENT_CONTROL_ID,
552
- De as PRODUCT_COUNT_CONTROL_ID,
553
- Ee as PRODUCT_LAYOUT_CONTROL_ID,
561
+ _e as ALGORITHM_CONTROL_ID,
562
+ E as AlgorithmControl,
563
+ Y as CONTROL_BLOCK_ID,
564
+ ye as CURRENCY_CONTROL_ID,
565
+ F as CurrencyControl,
566
+ Re as FILTERS_CONTROL_ID,
567
+ D as FiltersControl,
568
+ ke as LAYOUT_ORIENTATION_CONTROL_ID,
569
+ Te as LOCALE_CONTROL_ID,
570
+ U as LayoutOrientationControl,
571
+ v as LocaleControl,
572
+ be as PRICE_PLACEMENT_CONTROL_ID,
573
+ Le as PRODUCT_COUNT_CONTROL_ID,
574
+ Fe as PRODUCT_LAYOUT_CONTROL_ID,
554
575
  A as PricePlacementControl,
555
- V as ProductCountControl,
556
- W as ProductLayoutControl,
557
- Ce as RecommendationBlockControl,
558
- ve as SHUFFLE_CONTROL_ID,
576
+ w as ProductCountControl,
577
+ V as ProductLayoutControl,
578
+ me as RecommendationBlockControl,
579
+ Ue as SHUFFLE_CONTROL_ID,
559
580
  Ae as STRATEGY_CONTROL_ID,
560
- x as ShuffleControl,
561
- M as StrategyControl,
562
- We as adjustProductsToSize,
563
- xe as formatProductPrice,
564
- z as getBlockElement,
565
- Me as getCardComposition,
566
- Ge as getCurrentLayout,
567
- ze as getMainContainerTbody,
581
+ W as ShuffleControl,
582
+ x as StrategyControl,
583
+ Ve as adjustProductsToSize,
584
+ We as formatProductPrice,
585
+ G as getBlockElement,
586
+ xe as getCardComposition,
587
+ Me as getCurrentLayout,
588
+ Ge as getMainContainerTbody,
568
589
  $ as isPartnerManagedBlock,
569
590
  $e as regenerateMobileProductRows,
570
- Y as regenerateProductRowsWithStyles,
571
- G as setCurrencyAttributes,
572
- He as updatePricesInPlace,
573
- H as updateProductContentInPlace,
574
- Ye as updateSingleProductContent
591
+ H as regenerateProductRowsWithStyles,
592
+ M as setCurrencyAttributes,
593
+ ze as updatePricesInPlace,
594
+ z as updateProductContentInPlace,
595
+ He as updateSingleProductContent
575
596
  };