@useinsider/guido 3.21.0-beta.0df5409 → 3.21.0-beta.23f347e

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 (44) hide show
  1. package/dist/composables/useActionsApi.js +63 -80
  2. package/dist/composables/useGuidoStateBridge.js +3 -3
  3. package/dist/composables/useStripo.js +8 -8
  4. package/dist/config/compiler/htmlCompilerRules.js +1 -1
  5. package/dist/extensions/Blocks/Recommendation/block.js +29 -33
  6. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +83 -78
  7. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +2 -1
  8. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +12 -2
  9. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +86 -104
  10. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +210 -222
  11. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +50 -48
  12. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +21 -16
  13. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +40 -44
  14. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +19 -14
  15. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +119 -112
  16. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +23 -18
  17. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +231 -257
  18. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +20 -24
  19. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +7 -6
  20. package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +8 -8
  21. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +151 -113
  22. package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +11 -20
  23. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +1 -1
  24. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +50 -106
  25. package/dist/package.json.js +1 -1
  26. package/dist/src/composables/useActionsApi.d.ts +1 -5
  27. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -1
  28. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +6 -3
  29. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +5 -5
  30. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +11 -5
  31. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +3 -6
  32. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +5 -6
  33. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +8 -8
  34. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +11 -21
  35. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +13 -19
  36. package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +8 -10
  37. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +5 -9
  38. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +13 -13
  39. package/dist/src/stores/editor.d.ts +1 -3
  40. package/dist/static/styles/components/tabs.css.js +5 -0
  41. package/dist/stores/editor.js +0 -5
  42. package/package.json +2 -2
  43. package/dist/extensions/Blocks/Recommendation/utils/currencySettings.js +0 -25
  44. package/dist/src/extensions/Blocks/Recommendation/utils/currencySettings.d.ts +0 -6
@@ -1,75 +1,72 @@
1
- var k = Object.defineProperty;
2
- var I = (h, l, e) => l in h ? k(h, l, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[l] = e;
3
- var s = (h, l, e) => I(h, typeof l != "symbol" ? l + "" : l, e);
4
- import { useConfig as m } from "../../../../../composables/useConfig.js";
5
- import { ModificationDescription as C } 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 b, DEFAULT_NODE_CONFIG as u } from "../../constants/defaultConfig.js";
8
- import { RECOMMENDATION_ID_ATTR as O } 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 { toCurrencyConfig as B, toCurrencySettings as p } from "../../utils/currencySettings.js";
13
- import { registerNodeConfigWriter as F, registerPendingConfigFlush as L, stageConfigChange as _, describeConfigChange as N, writeBlockConfigOutsidePanel as U } from "../../utils/nodeConfigWriter.js";
14
- import { AlgorithmControl as E } from "./algorithm.js";
15
- import { ALGORITHM_CONTROL_ID as Pe } from "./algorithm.js";
16
- import { CurrencyControl as D } from "./currency.js";
17
- import { CURRENCY_CONTROL_ID as Ie } from "./currency.js";
18
- import { FiltersControl as v } from "./filters.js";
19
- import { FILTERS_CONTROL_ID as be } from "./filters.js";
20
- import { LayoutOrientationControl as w } from "./layoutOrientation.js";
21
- import { LAYOUT_ORIENTATION_CONTROL_ID as Se } from "./layoutOrientation.js";
22
- import { LocaleControl as A } from "./locale.js";
23
- import { LOCALE_CONTROL_ID as Be } from "./locale.js";
24
- import { PricePlacementControl as V } from "./pricePlacement.js";
25
- import { PRICE_PLACEMENT_CONTROL_ID as Le } from "./pricePlacement.js";
26
- import { ProductCountControl as x } from "./productCount.js";
27
- import { PRODUCT_COUNT_CONTROL_ID as Ee } from "./productCount.js";
28
- import { ProductLayoutControl as W } from "./productLayout.js";
29
- import { PRODUCT_LAYOUT_CONTROL_ID as ve } from "./productLayout.js";
30
- import { ShuffleControl as M } from "./shuffle.js";
31
- import { SHUFFLE_CONTROL_ID as Ae } from "./shuffle.js";
32
- import { StrategyControl as G } from "./strategy.js";
33
- import { STRATEGY_CONTROL_ID as xe } from "./strategy.js";
34
- import { setCurrencyAttributes as z, getBlockElement as $, isPartnerManagedBlock as H, updateProductContentInPlace as Y, regenerateProductRowsWithStyles as j } from "./utils.js";
35
- import { adjustProductsToSize as Me, formatProductPrice as Ge, getCardComposition as ze, getCurrencyAttributesFromBlock as $e, getCurrentLayout as He, getMainContainerTbody as Ye, regenerateMobileProductRows as je, updatePricesInPlace as qe, updateSingleProductContent as Je } from "./utils.js";
36
- import { useDebounceFn as y } from "../../../../../node_modules/@vueuse/shared/index.js";
37
- const q = "ui-elements-recommendation-block";
38
- class _e extends R {
1
+ var _ = Object.defineProperty;
2
+ var y = (h, c, e) => c in h ? _(h, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[c] = e;
3
+ var i = (h, c, e) => y(h, typeof c != "symbol" ? c + "" : c, e);
4
+ import { useConfig as g } from "../../../../../composables/useConfig.js";
5
+ import { ModificationDescription as N } 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 k } from "../../constants/selectors.js";
9
+ import { RecommendationConfigService as l } from "../../services/configService.js";
10
+ import { useRecommendationExtensionStore as I } from "../../store/recommendation.js";
11
+ import { refreshBlockOutsidePanel as S } from "../../utils/blockRefresh.js";
12
+ import { registerNodeConfigWriter as T, writeBlockConfigOutsidePanel as m, hasEditedConfigChange as b } from "../../utils/nodeConfigWriter.js";
13
+ import { AlgorithmControl as O } from "./algorithm.js";
14
+ import { ALGORITHM_CONTROL_ID as me } from "./algorithm.js";
15
+ import { CurrencyControl as B } from "./currency.js";
16
+ import { CURRENCY_CONTROL_ID as pe } from "./currency.js";
17
+ import { FiltersControl as L } from "./filters.js";
18
+ import { FILTERS_CONTROL_ID as ye } from "./filters.js";
19
+ import { LayoutOrientationControl as E } from "./layoutOrientation.js";
20
+ import { LAYOUT_ORIENTATION_CONTROL_ID as Pe } from "./layoutOrientation.js";
21
+ import { LocaleControl as F } from "./locale.js";
22
+ import { LOCALE_CONTROL_ID as ke } from "./locale.js";
23
+ import { PricePlacementControl as D } from "./pricePlacement.js";
24
+ import { PRICE_PLACEMENT_CONTROL_ID as Se } from "./pricePlacement.js";
25
+ import { ProductCountControl as U } from "./productCount.js";
26
+ import { PRODUCT_COUNT_CONTROL_ID as be } from "./productCount.js";
27
+ import { ProductLayoutControl as v } from "./productLayout.js";
28
+ import { PRODUCT_LAYOUT_CONTROL_ID as Be } from "./productLayout.js";
29
+ import { ShuffleControl as w } from "./shuffle.js";
30
+ import { SHUFFLE_CONTROL_ID as Ee } from "./shuffle.js";
31
+ import { StrategyControl as A } from "./strategy.js";
32
+ import { STRATEGY_CONTROL_ID as De } from "./strategy.js";
33
+ import { setCurrencyAttributes as V, getBlockElement as x, isPartnerManagedBlock as W, updateProductContentInPlace as M, regenerateProductRowsWithStyles as G } from "./utils.js";
34
+ import { adjustProductsToSize as ve, formatProductPrice as we, getCardComposition as Ae, getCurrentLayout as Ve, getMainContainerTbody as xe, regenerateMobileProductRows as We, updatePricesInPlace as Me, updateSingleProductContent as Ge } from "./utils.js";
35
+ import { useDebounceFn as C } from "../../../../../node_modules/@vueuse/shared/index.js";
36
+ const f = "Update recommendation filters", z = "ui-elements-recommendation-block";
37
+ class he extends P {
39
38
  constructor() {
40
39
  super(...arguments);
41
- s(this, "store", S());
42
- s(this, "storeUnsubscription", () => {
43
- });
44
- s(this, "unregisterConfigFlush", () => {
40
+ i(this, "store", I());
41
+ i(this, "storeUnsubscription", () => {
45
42
  });
46
43
  // A config change waiting to reach the node config. Deferred so it can ride the
47
44
  // re-render's single apply() — one user action must cost one undo press.
48
- s(this, "pendingNodeConfigWrite", null);
49
- s(this, "pendingConfigFlushTimer", null);
45
+ i(this, "pendingNodeConfigWrite", null);
46
+ i(this, "pendingConfigFlushTimer", null);
50
47
  // What the panel still owes the block it watches — finished outside the panel on teardown
51
48
  // and block switch. A new generation tells debounced work queued for the old one to stand down.
52
- s(this, "trackedBlockId", null);
53
- s(this, "fetchedConfigVersion", 0);
54
- s(this, "hasUnrenderedProducts", !1);
55
- s(this, "panelGeneration", 0);
56
- s(this, "isPanelAlive", !0);
49
+ i(this, "trackedBlockId", null);
50
+ i(this, "fetchedConfigVersion", 0);
51
+ i(this, "hasUnrenderedProducts", !1);
52
+ i(this, "panelGeneration", 0);
53
+ i(this, "isPanelAlive", !0);
57
54
  // Sub-control instances for lifecycle management
58
- s(this, "algorithmControl", null);
59
- s(this, "localeControl", null);
60
- s(this, "currencyControl", null);
61
- s(this, "productCountControl", null);
62
- s(this, "productLayoutControl", null);
63
- s(this, "filtersControl", null);
64
- s(this, "shuffleControl", null);
65
- s(this, "pricePlacementControl", null);
66
- s(this, "layoutOrientationControl", null);
67
- s(this, "strategyControl", null);
68
- s(this, "rrsEnabled", !1);
55
+ i(this, "algorithmControl", null);
56
+ i(this, "localeControl", null);
57
+ i(this, "currencyControl", null);
58
+ i(this, "productCountControl", null);
59
+ i(this, "productLayoutControl", null);
60
+ i(this, "filtersControl", null);
61
+ i(this, "shuffleControl", null);
62
+ i(this, "pricePlacementControl", null);
63
+ i(this, "layoutOrientationControl", null);
64
+ i(this, "strategyControl", null);
65
+ i(this, "rrsEnabled", !1);
69
66
  /**
70
67
  * Debounced product fetch to prevent rapid API calls during config changes
71
68
  */
72
- s(this, "_debouncedFetchProducts", y(async (e, t) => {
69
+ i(this, "_debouncedFetchProducts", C(async (e, t) => {
73
70
  if (t !== this.panelGeneration)
74
71
  return;
75
72
  const o = this._getBlockConfigVersion(e);
@@ -90,7 +87,7 @@ class _e extends R {
90
87
  * count. The store pads products to the configured size, so in-place only
91
88
  * fails when the size actually changed.
92
89
  */
93
- s(this, "_debouncedRegenerateWithProducts", y((e) => {
90
+ i(this, "_debouncedRegenerateWithProducts", C((e) => {
94
91
  if (e !== this.panelGeneration || !this.currentNode || !this.api)
95
92
  return;
96
93
  const t = this._getRecommendationIdFromNode(this.currentNode), o = this.store.currentRecommendationId;
@@ -109,7 +106,7 @@ class _e extends R {
109
106
  }, 100));
110
107
  }
111
108
  getId() {
112
- return q;
109
+ return z;
113
110
  }
114
111
  get _subControls() {
115
112
  return [
@@ -127,10 +124,10 @@ class _e extends R {
127
124
  }
128
125
  getTemplate() {
129
126
  var e;
130
- return this.rrsEnabled = m().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
127
+ return this.rrsEnabled = g().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
131
128
  var o;
132
129
  return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
133
- }), this.algorithmControl = new E(), this.localeControl = new A(), this.currencyControl = new D(), this.productCountControl = new x(), this.productLayoutControl = new W(), this.filtersControl = new v(), this.shuffleControl = new M(), this.pricePlacementControl = new V(), this.layoutOrientationControl = new w(), this.strategyControl = this.rrsEnabled ? new G() : null, this._subControls.forEach((t) => {
130
+ }), this.algorithmControl = new O(), this.localeControl = new F(), this.currencyControl = new B(), this.productCountControl = new U(), this.productLayoutControl = new v(), this.filtersControl = new L(), this.shuffleControl = new w(), this.pricePlacementControl = new D(), this.layoutOrientationControl = new E(), this.strategyControl = this.rrsEnabled ? new A() : null, this._subControls.forEach((t) => {
134
131
  t && (t.api = this.api);
135
132
  }), `
136
133
  <div class="recommendation-controls-container">
@@ -148,16 +145,16 @@ class _e extends R {
148
145
  `;
149
146
  }
150
147
  _showControlsForBlock(e) {
151
- var i;
152
- const t = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
148
+ var s;
149
+ const t = (s = this.getContainer()) == null ? void 0 : s.querySelector(".recommendation-controls-container");
153
150
  if (!t)
154
151
  return;
155
- 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) >= b), r = this.rrsEnabled && !!o && !n;
152
+ const o = this._getRecommendationIdFromNode(e) === null ? null : l.getConfig(e), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= R), r = this.rrsEnabled && !!o && !n;
156
153
  t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", r);
157
154
  }
158
155
  async onRender() {
159
156
  var o;
160
- F(this.api), this.unregisterConfigFlush(), this.unregisterConfigFlush = L(() => this._flushPendingNodeConfig());
157
+ T(this.api);
161
158
  const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
162
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)) {
163
160
  this._initializeSubControls();
@@ -177,7 +174,7 @@ class _e extends R {
177
174
  });
178
175
  }
179
176
  onDestroy() {
180
- this.panelGeneration++, this.isPanelAlive = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this.unregisterConfigFlush(), this._subControls.forEach((e) => {
177
+ this.panelGeneration++, this.isPanelAlive = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this._subControls.forEach((e) => {
181
178
  var t;
182
179
  return (t = e == null ? void 0 : e.onDestroy) == null ? void 0 : t.call(e);
183
180
  });
@@ -222,66 +219,45 @@ class _e extends R {
222
219
  const t = this.store.blockStates[e];
223
220
  if (!t)
224
221
  return;
225
- const o = JSON.stringify(d.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
222
+ const o = JSON.stringify(l.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
226
223
  t.syncedConfigFingerprint = o, n !== o && ((r = this.pendingNodeConfigWrite) == null ? void 0 : r.blockId) !== e && this._syncNodeConfigToStore();
227
224
  }
228
225
  /** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
229
226
  _isPendingStrategyIdChange() {
230
- const e = this._pendingUpdates();
231
- return e !== null && d.getConfig(this.currentNode).strategyId !== e.strategyId;
227
+ const e = this.pendingNodeConfigWrite;
228
+ return e ? l.getConfig(this.currentNode).strategyId !== e.updates.strategyId : !1;
232
229
  }
233
230
  _capturePendingNodeConfigWrite() {
234
- const e = this.store.currentRecommendationId;
235
- !this.currentNode || !this.api || e === null || !this.store.blockStates[e] || (this.pendingNodeConfigWrite = { blockId: e });
236
- }
237
- // Read at write time, not at capture: a display-only edit (currency symbol) patches the store
238
- // without a version bump while the write waits, and a snapshot would stage the older value over it.
239
- _pendingUpdates() {
240
- const e = this.pendingNodeConfigWrite, t = e ? this.store.blockStates[e.blockId] : void 0;
241
- return t ? this._getNodeConfigUpdates(t.recommendationConfigs) : null;
242
- }
243
- // Another block's pending write must never be staged on, or drive the redraw of, the panel node.
244
- _pendingUpdatesForCurrentNode() {
245
- var e;
246
- return !this.currentNode || ((e = this.pendingNodeConfigWrite) == null ? void 0 : e.blockId) !== this._getRecommendationIdFromNode(this.currentNode) ? null : this._pendingUpdates();
231
+ const e = this.store.currentRecommendationId, t = e === null ? void 0 : this.store.blockStates[e];
232
+ !this.currentNode || !this.api || e === null || !t || (this.pendingNodeConfigWrite = {
233
+ blockId: e,
234
+ updates: this._getNodeConfigUpdates(t.recommendationConfigs)
235
+ });
247
236
  }
248
237
  _getNodeConfigUpdates(e) {
249
- const {
250
- filters: t,
251
- strategy: o,
252
- strategyId: n,
253
- size: r,
254
- productIds: i,
255
- language: a,
256
- shuffleProducts: c,
257
- currencySettings: g,
258
- nodeConfigVersion: P
259
- } = e, { partnerName: f } = m();
238
+ const { filters: t, strategy: o, strategyId: n, size: r, nodeConfigVersion: s } = e, { partnerName: d } = g();
260
239
  return {
261
240
  filters: t,
262
241
  strategy: o,
263
242
  strategyId: n,
264
243
  size: r,
265
- productIds: i,
266
- language: a,
267
- shuffleProducts: c,
268
- currency: B(g),
269
- configVersion: P,
270
- ...f.value ? { partnerName: f.value } : {}
244
+ configVersion: s,
245
+ ...d.value ? { partnerName: d.value } : {}
271
246
  };
272
247
  }
273
248
  /**
274
249
  * Accumulates the pending write into `documentModifier` without applying, so the
275
250
  * caller's apply() commits config and re-render as ONE undo entry.
276
- * @returns the undo label, null when only stamps moved; undefined when nothing was staged
251
+ *
252
+ * Deliberately does not consume the pending record: the product helpers call
253
+ * apply() only when they actually changed something, so this batch may never be
254
+ * committed and the flush has to stay able to write it standalone.
255
+ * @param documentModifier - The batch to accumulate into
256
+ * @returns Whether anything was staged
277
257
  */
278
258
  _stagePendingNodeConfig(e) {
279
- const t = this._pendingUpdatesForCurrentNode();
280
- if (!(!t || !this.currentNode))
281
- return _(e, this.currentNode, t), N(d.getConfig(this.currentNode), t);
282
- }
283
- _consumePendingNodeConfig() {
284
- this.pendingNodeConfigWrite = null, this._clearConfigFlush();
259
+ const t = this.pendingNodeConfigWrite;
260
+ return !t || !this.currentNode ? !1 : (l.stageConfig(e, this.currentNode, t.updates), !0);
285
261
  }
286
262
  /**
287
263
  * Arms the guaranteed fallback write, once the product fetch has settled. The
@@ -296,25 +272,30 @@ class _e extends R {
296
272
  _clearConfigFlush() {
297
273
  this.pendingConfigFlushTimer !== null && (clearTimeout(this.pendingConfigFlushTimer), this.pendingConfigFlushTimer = null);
298
274
  }
299
- // Writes the deferred change standalone when its batch never committed. Targets a LIVE node:
300
- // a captured one is a snapshot the intervening re-render staled, and saveConfig swallows that.
275
+ /**
276
+ * Writes the deferred change standalone when the batch it was staged into never
277
+ * committed. Always targets a LIVE node — a captured one is an immutable snapshot
278
+ * the intervening re-render staled, and saveConfig swallows that failure.
279
+ */
301
280
  _flushPendingNodeConfig() {
302
- const e = this.pendingNodeConfigWrite, t = this._pendingUpdates();
303
- if (this._consumePendingNodeConfig(), !e || !t || !this.api)
304
- return !1;
305
- if (!(e.blockId === this.store.currentRecommendationId && e.blockId === this._getRecommendationIdFromNode(this.currentNode)) || !this.currentNode) {
306
- const { blockId: i } = e, a = U(i, t);
307
- return a === "missing" && this.store.blockStates[i] && console.error("[recommendation] pending config write did not reach a node", { blockId: i }), a === "applied";
281
+ const e = this.pendingNodeConfigWrite;
282
+ if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !(!e || !this.api)) {
283
+ if (e.blockId !== this.store.currentRecommendationId || !this.currentNode) {
284
+ const { blockId: t, updates: o } = e;
285
+ !m(t, o, f) && this.store.blockStates[t] && console.error("[recommendation] pending config write did not reach a node", { blockId: t });
286
+ return;
287
+ }
288
+ b(this.currentNode, e.updates) && l.updateConfig(
289
+ this.api,
290
+ this.currentNode,
291
+ e.updates,
292
+ f
293
+ );
308
294
  }
309
- const n = N(d.getConfig(this.currentNode), t);
310
- if (n === null)
311
- return !1;
312
- const r = this.api.getDocumentModifier();
313
- return _(r, this.currentNode, t), r.apply(new C(n)), !0;
314
295
  }
315
296
  _syncNodeConfigToStore() {
316
297
  var n;
317
- const e = d.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
298
+ const e = l.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
318
299
  this.store.patchCurrentBlockConfig({
319
300
  strategy: e.strategy,
320
301
  strategyId: e.strategyId,
@@ -333,7 +314,15 @@ class _e extends R {
333
314
  shuffleProducts: e.shuffleProducts,
334
315
  priceMovedToNextLine: e.priceMovedToNextLine,
335
316
  priceHideIfSameAsDiscounted: e.priceHideIfSameAsDiscounted,
336
- currencySettings: p(e.currency)
317
+ currencySettings: {
318
+ name: e.currency.code,
319
+ value: e.currency.code,
320
+ symbol: e.currency.symbol,
321
+ alignment: e.currency.alignment === "before" ? "0" : "1",
322
+ decimalCount: e.currency.decimalCount.toString(),
323
+ decimalSeparator: e.currency.decimalSeparator,
324
+ thousandSeparator: e.currency.thousandSeparator
325
+ }
337
326
  }, { triggerRefetch: !1 });
338
327
  }
339
328
  /**
@@ -380,41 +369,51 @@ class _e extends R {
380
369
  _applySmartDefaults() {
381
370
  if (!this.currentNode || !this.api)
382
371
  return;
383
- const e = d.getConfig(this.currentNode), t = {};
372
+ const e = l.getConfig(this.currentNode), t = {};
384
373
  let o = null, n = null, r = null;
385
- if (e.currency.code === u.currency.code) {
386
- const { currencyList: i } = this.store;
387
- i.length > 0 && (i.some(
388
- (c) => c.value === `price.${u.currency.code}`
389
- ) || (o = i[0].value.replace("price.", ""), t.currency = {
390
- ...u.currency,
374
+ if (e.currency.code === a.currency.code) {
375
+ const { currencyList: s } = this.store;
376
+ s.length > 0 && (s.some(
377
+ (u) => u.value === `price.${a.currency.code}`
378
+ ) || (o = s[0].value.replace("price.", ""), t.currency = {
379
+ ...a.currency,
391
380
  code: o,
392
381
  symbol: o
393
382
  }));
394
383
  }
395
- if (e.strategy === u.strategy) {
396
- const i = this.store.getActivePredictiveAlgorithms;
397
- i.length > 0 && (i.some(
398
- (c) => c.value === u.strategy
399
- ) || (n = i[0].value, t.strategy = n));
384
+ if (e.strategy === a.strategy) {
385
+ const s = this.store.getActivePredictiveAlgorithms;
386
+ s.length > 0 && (s.some(
387
+ (u) => u.value === a.strategy
388
+ ) || (n = s[0].value, t.strategy = n));
400
389
  }
401
- if (e.language === u.language) {
402
- const i = this.store.getLanguages;
403
- i.length > 0 && (i.some(
404
- (c) => c.value === u.language
405
- ) || (r = i[0].value, t.language = r));
390
+ if (e.language === a.language) {
391
+ const s = this.store.getLanguages;
392
+ s.length > 0 && (s.some(
393
+ (u) => u.value === a.language
394
+ ) || (r = s[0].value, t.language = r));
406
395
  }
407
- !o && !n && !r || (d.updateConfig(
396
+ !o && !n && !r || (l.updateConfig(
408
397
  this.api,
409
398
  this.currentNode,
410
399
  t,
411
400
  "Applied smart defaults"
412
- ), o && t.currency && z({
401
+ ), o && t.currency && V({
413
402
  currentNode: this.currentNode,
414
403
  documentModifier: this.api.getDocumentModifier(),
415
404
  currency: t.currency
416
405
  }), this.store.patchCurrentBlockConfig({
417
- ...o && t.currency ? { currencySettings: p(t.currency) } : {},
406
+ ...o ? {
407
+ currencySettings: {
408
+ name: o,
409
+ value: o,
410
+ symbol: o,
411
+ alignment: a.currency.alignment === "before" ? "0" : "1",
412
+ decimalCount: a.currency.decimalCount.toString(),
413
+ decimalSeparator: a.currency.decimalSeparator,
414
+ thousandSeparator: a.currency.thousandSeparator
415
+ }
416
+ } : {},
418
417
  ...n ? { strategy: n } : {},
419
418
  ...r ? { language: r } : {}
420
419
  }, { triggerRefetch: !1 }));
@@ -423,10 +422,10 @@ class _e extends R {
423
422
  * Reads the recommendation-id attribute from the block element within the node
424
423
  */
425
424
  _getRecommendationIdFromNode(e) {
426
- const t = $(e);
425
+ const t = x(e);
427
426
  if (!t || !("getAttribute" in t))
428
427
  return null;
429
- const o = t.getAttribute(O);
428
+ const o = t.getAttribute(k);
430
429
  if (!o)
431
430
  return null;
432
431
  const n = parseInt(o);
@@ -436,18 +435,20 @@ class _e extends R {
436
435
  * Lands what the panel still owes its block before it stops watching it: the config now, the
437
436
  * products through a block-scoped refresh. Never throws — it runs from Stripo's teardown.
438
437
  */
439
- _finishBlockOutsidePanel(e = this._trackedBlockSnapshot()) {
440
- var r;
441
- const { blockId: t, fetchedConfigVersion: o, hasUnrenderedProducts: n } = e;
438
+ _finishBlockOutsidePanel({ blockId: e, fetchedConfigVersion: t, hasUnrenderedProducts: o } = this._trackedBlockSnapshot()) {
442
439
  try {
443
- const i = t === null ? void 0 : this.store.blockStates[t], a = i !== void 0 && o !== i.configVersion;
444
- if (t !== null && i && (a || n)) {
445
- ((r = this.pendingNodeConfigWrite) == null ? void 0 : r.blockId) === t && this._consumePendingNodeConfig(), this._flushPendingNodeConfig(), this._refreshOutsidePanel(t, a);
446
- return;
447
- }
448
440
  this._flushPendingNodeConfig();
449
- } catch (i) {
450
- console.error("[recommendation] finishing the block outside the panel failed", i);
441
+ const n = e === null ? void 0 : this.store.blockStates[e];
442
+ if (e === null || !n)
443
+ return;
444
+ const r = t !== n.configVersion;
445
+ r && !m(
446
+ e,
447
+ this._getNodeConfigUpdates(n.recommendationConfigs),
448
+ f
449
+ ) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (r || o) && this._refreshOutsidePanel(e, r);
450
+ } catch (n) {
451
+ console.error("[recommendation] finishing the block outside the panel failed", n);
451
452
  }
452
453
  }
453
454
  _trackedBlockSnapshot() {
@@ -458,7 +459,7 @@ class _e extends R {
458
459
  };
459
460
  }
460
461
  _refreshOutsidePanel(e, t) {
461
- T(e, {
462
+ S(e, {
462
463
  pickUpdates: (o) => this._getNodeConfigUpdates(o),
463
464
  description: "Update recommendation configuration",
464
465
  fetch: t
@@ -476,32 +477,20 @@ class _e extends R {
476
477
  _regenerateWithProducts() {
477
478
  if (!this.currentNode || !this.api)
478
479
  return;
479
- const { currentNode: e } = this, t = this.store.recommendationProducts, o = this.api.getDocumentModifier(), n = this._pendingUpdatesForCurrentNode() ?? void 0, r = this._stagePendingNodeConfig(o), i = (g) => {
480
- (r || g) && o.apply(
481
- new C(r ?? "Updated recommendation products")
482
- ), r !== void 0 && this._consumePendingNodeConfig();
483
- };
484
- if (H(e)) {
485
- i(!1);
480
+ const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(t);
481
+ if (W(this.currentNode)) {
482
+ o && (t.apply(new N("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
486
483
  return;
487
484
  }
488
- let a = !1;
489
- Y({
490
- currentNode: e,
491
- documentModifier: o,
492
- products: t,
493
- stageOnly: !0,
494
- configOverrides: n,
495
- onChanged: () => {
496
- a = !0;
497
- }
498
- }) || (a = j({
499
- currentNode: e,
500
- documentModifier: o,
501
- products: t,
502
- stageOnly: !0,
503
- configOverrides: n
504
- })), i(a);
485
+ M({
486
+ currentNode: this.currentNode,
487
+ documentModifier: t,
488
+ products: e
489
+ }) || G({
490
+ currentNode: this.currentNode,
491
+ documentModifier: t,
492
+ products: e
493
+ });
505
494
  }
506
495
  /**
507
496
  * Listen to store changes that require product refresh or regeneration.
@@ -522,52 +511,51 @@ class _e extends R {
522
511
  this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this.storeUnsubscription = e.$subscribe(() => {
523
512
  const n = e.currentRecommendationId;
524
513
  if (n !== this.trackedBlockId) {
525
- const g = this._trackedBlockSnapshot();
526
- this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(g);
514
+ const p = this._trackedBlockSnapshot();
515
+ this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(p);
527
516
  return;
528
517
  }
529
518
  const r = this._getBlockConfigVersion(n);
530
519
  r !== o && (o = r, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts(n, this.panelGeneration));
531
- const i = e.recommendationProducts, a = i !== t, c = Array.isArray(i) && i.length > 0;
532
- a && c && (t = i, this.hasUnrenderedProducts = !0, this._debouncedRegenerateWithProducts(this.panelGeneration));
520
+ const s = e.recommendationProducts, d = s !== t, u = Array.isArray(s) && s.length > 0;
521
+ d && u && (t = s, this.hasUnrenderedProducts = !0, this._debouncedRegenerateWithProducts(this.panelGeneration));
533
522
  });
534
523
  }
535
524
  }
536
525
  export {
537
- Pe as ALGORITHM_CONTROL_ID,
538
- E as AlgorithmControl,
539
- q as CONTROL_BLOCK_ID,
540
- Ie as CURRENCY_CONTROL_ID,
541
- D as CurrencyControl,
542
- be as FILTERS_CONTROL_ID,
543
- v as FiltersControl,
544
- Se as LAYOUT_ORIENTATION_CONTROL_ID,
545
- Be as LOCALE_CONTROL_ID,
546
- w as LayoutOrientationControl,
547
- A as LocaleControl,
548
- Le as PRICE_PLACEMENT_CONTROL_ID,
549
- Ee as PRODUCT_COUNT_CONTROL_ID,
550
- ve as PRODUCT_LAYOUT_CONTROL_ID,
551
- V as PricePlacementControl,
552
- x as ProductCountControl,
553
- W as ProductLayoutControl,
554
- _e as RecommendationBlockControl,
555
- Ae as SHUFFLE_CONTROL_ID,
556
- xe as STRATEGY_CONTROL_ID,
557
- M as ShuffleControl,
558
- G as StrategyControl,
559
- Me as adjustProductsToSize,
560
- Ge as formatProductPrice,
561
- $ as getBlockElement,
562
- ze as getCardComposition,
563
- $e as getCurrencyAttributesFromBlock,
564
- He as getCurrentLayout,
565
- Ye as getMainContainerTbody,
566
- H as isPartnerManagedBlock,
567
- je as regenerateMobileProductRows,
568
- j as regenerateProductRowsWithStyles,
569
- z as setCurrencyAttributes,
570
- qe as updatePricesInPlace,
571
- Y as updateProductContentInPlace,
572
- Je as updateSingleProductContent
526
+ me as ALGORITHM_CONTROL_ID,
527
+ O as AlgorithmControl,
528
+ z as CONTROL_BLOCK_ID,
529
+ pe as CURRENCY_CONTROL_ID,
530
+ B as CurrencyControl,
531
+ ye as FILTERS_CONTROL_ID,
532
+ L as FiltersControl,
533
+ Pe as LAYOUT_ORIENTATION_CONTROL_ID,
534
+ ke as LOCALE_CONTROL_ID,
535
+ E as LayoutOrientationControl,
536
+ F as LocaleControl,
537
+ Se as PRICE_PLACEMENT_CONTROL_ID,
538
+ be as PRODUCT_COUNT_CONTROL_ID,
539
+ Be as PRODUCT_LAYOUT_CONTROL_ID,
540
+ D as PricePlacementControl,
541
+ U as ProductCountControl,
542
+ v as ProductLayoutControl,
543
+ he as RecommendationBlockControl,
544
+ Ee as SHUFFLE_CONTROL_ID,
545
+ De as STRATEGY_CONTROL_ID,
546
+ w as ShuffleControl,
547
+ A as StrategyControl,
548
+ ve as adjustProductsToSize,
549
+ we as formatProductPrice,
550
+ x as getBlockElement,
551
+ Ae as getCardComposition,
552
+ Ve as getCurrentLayout,
553
+ xe as getMainContainerTbody,
554
+ W as isPartnerManagedBlock,
555
+ We as regenerateMobileProductRows,
556
+ G as regenerateProductRowsWithStyles,
557
+ V as setCurrencyAttributes,
558
+ Me as updatePricesInPlace,
559
+ M as updateProductContentInPlace,
560
+ Ge as updateSingleProductContent
573
561
  };