@useinsider/guido 3.20.2-beta.87fb8ae → 3.21.0-beta.0df5409

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 (87) hide show
  1. package/dist/components/Guido.vue.js +1 -1
  2. package/dist/components/Guido.vue2.js +65 -64
  3. package/dist/components/organisms/AutoSaveController.vue2.js +10 -9
  4. package/dist/components/organisms/header/EditorActions.vue.js +4 -4
  5. package/dist/components/organisms/header/EditorActions.vue2.js +53 -51
  6. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +3 -3
  7. package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +23 -22
  8. package/dist/composables/useActionsApi.js +80 -63
  9. package/dist/composables/useAutoSave.js +46 -44
  10. package/dist/composables/useGuidoStateBridge.js +3 -3
  11. package/dist/composables/useSave.js +26 -23
  12. package/dist/composables/useSaveValidation.js +113 -114
  13. package/dist/composables/useSaveValidationRollout.js +17 -6
  14. package/dist/composables/useStripo.js +11 -10
  15. package/dist/extensions/Blocks/Items/block.js +43 -42
  16. package/dist/extensions/Blocks/Recommendation/block.js +33 -29
  17. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +78 -83
  18. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +1 -2
  19. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +2 -12
  20. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +104 -86
  21. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +222 -210
  22. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +48 -50
  23. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +16 -21
  24. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +44 -40
  25. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +14 -19
  26. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +104 -102
  27. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +18 -23
  28. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +312 -286
  29. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +24 -20
  30. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +6 -7
  31. package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +8 -8
  32. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +113 -151
  33. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +9 -5
  34. package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +20 -11
  35. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +1 -1
  36. package/dist/extensions/Blocks/Recommendation/utils/currencySettings.js +25 -0
  37. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +106 -50
  38. package/dist/extensions/Blocks/Unsubscribe/block.js +70 -75
  39. package/dist/guido.css +1 -1
  40. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +271 -192
  41. package/dist/package.json.js +1 -1
  42. package/dist/services/settingsApi.js +11 -0
  43. package/dist/src/components/Guido.vue.d.ts +1 -1
  44. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
  45. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
  46. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
  47. package/dist/src/composables/useActionsApi.d.ts +5 -1
  48. package/dist/src/composables/useAutoSave.d.ts +4 -1
  49. package/dist/src/composables/useSaveValidationRollout.d.ts +1 -0
  50. package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +1 -0
  51. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +8 -0
  52. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +40 -0
  53. package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +1 -0
  54. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
  55. package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +1 -0
  56. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +11 -0
  57. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -6
  58. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +7 -0
  59. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +2 -0
  60. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +5 -5
  61. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -11
  62. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +6 -3
  63. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +6 -5
  64. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -3
  65. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +21 -9
  66. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +19 -13
  67. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +7 -0
  68. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +7 -0
  69. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +7 -0
  70. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +7 -0
  71. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +7 -0
  72. package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +10 -8
  73. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +9 -5
  74. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +7 -0
  75. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
  76. package/dist/src/extensions/Blocks/Recommendation/utils/currencySettings.d.ts +6 -0
  77. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +13 -13
  78. package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +1 -6
  79. package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +1 -0
  80. package/dist/src/extensions/Blocks/controlFactories.d.ts +22 -0
  81. package/dist/src/services/settingsApi.d.ts +6 -0
  82. package/dist/src/stores/editor.d.ts +3 -1
  83. package/dist/src/stores/setup-settings.d.ts +4 -0
  84. package/dist/static/styles/components/button.css.js +5 -0
  85. package/dist/stores/editor.js +5 -0
  86. package/dist/stores/setup-settings.js +10 -0
  87. package/package.json +4 -4
@@ -1,72 +1,75 @@
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 {
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 {
38
39
  constructor() {
39
40
  super(...arguments);
40
- i(this, "store", I());
41
- i(this, "storeUnsubscription", () => {
41
+ s(this, "store", S());
42
+ s(this, "storeUnsubscription", () => {
43
+ });
44
+ s(this, "unregisterConfigFlush", () => {
42
45
  });
43
46
  // A config change waiting to reach the node config. Deferred so it can ride the
44
47
  // re-render's single apply() — one user action must cost one undo press.
45
- i(this, "pendingNodeConfigWrite", null);
46
- i(this, "pendingConfigFlushTimer", null);
48
+ s(this, "pendingNodeConfigWrite", null);
49
+ s(this, "pendingConfigFlushTimer", null);
47
50
  // What the panel still owes the block it watches — finished outside the panel on teardown
48
51
  // and block switch. A new generation tells debounced work queued for the old one to stand down.
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);
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);
54
57
  // Sub-control instances for lifecycle management
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);
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);
66
69
  /**
67
70
  * Debounced product fetch to prevent rapid API calls during config changes
68
71
  */
69
- i(this, "_debouncedFetchProducts", C(async (e, t) => {
72
+ s(this, "_debouncedFetchProducts", y(async (e, t) => {
70
73
  if (t !== this.panelGeneration)
71
74
  return;
72
75
  const o = this._getBlockConfigVersion(e);
@@ -87,7 +90,7 @@ class he extends P {
87
90
  * count. The store pads products to the configured size, so in-place only
88
91
  * fails when the size actually changed.
89
92
  */
90
- i(this, "_debouncedRegenerateWithProducts", C((e) => {
93
+ s(this, "_debouncedRegenerateWithProducts", y((e) => {
91
94
  if (e !== this.panelGeneration || !this.currentNode || !this.api)
92
95
  return;
93
96
  const t = this._getRecommendationIdFromNode(this.currentNode), o = this.store.currentRecommendationId;
@@ -106,7 +109,7 @@ class he extends P {
106
109
  }, 100));
107
110
  }
108
111
  getId() {
109
- return z;
112
+ return q;
110
113
  }
111
114
  get _subControls() {
112
115
  return [
@@ -124,10 +127,10 @@ class he extends P {
124
127
  }
125
128
  getTemplate() {
126
129
  var e;
127
- return this.rrsEnabled = g().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
130
+ return this.rrsEnabled = m().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
128
131
  var o;
129
132
  return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(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) => {
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) => {
131
134
  t && (t.api = this.api);
132
135
  }), `
133
136
  <div class="recommendation-controls-container">
@@ -145,16 +148,16 @@ class he extends P {
145
148
  `;
146
149
  }
147
150
  _showControlsForBlock(e) {
148
- var s;
149
- const t = (s = this.getContainer()) == null ? void 0 : s.querySelector(".recommendation-controls-container");
151
+ var i;
152
+ const t = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
150
153
  if (!t)
151
154
  return;
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;
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;
153
156
  t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", r);
154
157
  }
155
158
  async onRender() {
156
159
  var o;
157
- T(this.api);
160
+ F(this.api), this.unregisterConfigFlush(), this.unregisterConfigFlush = L(() => this._flushPendingNodeConfig());
158
161
  const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
159
162
  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
163
  this._initializeSubControls();
@@ -174,7 +177,7 @@ class he extends P {
174
177
  });
175
178
  }
176
179
  onDestroy() {
177
- this.panelGeneration++, this.isPanelAlive = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this._subControls.forEach((e) => {
180
+ this.panelGeneration++, this.isPanelAlive = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this.unregisterConfigFlush(), this._subControls.forEach((e) => {
178
181
  var t;
179
182
  return (t = e == null ? void 0 : e.onDestroy) == null ? void 0 : t.call(e);
180
183
  });
@@ -219,45 +222,66 @@ class he extends P {
219
222
  const t = this.store.blockStates[e];
220
223
  if (!t)
221
224
  return;
222
- const o = JSON.stringify(l.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
225
+ const o = JSON.stringify(d.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
223
226
  t.syncedConfigFingerprint = o, n !== o && ((r = this.pendingNodeConfigWrite) == null ? void 0 : r.blockId) !== e && this._syncNodeConfigToStore();
224
227
  }
225
228
  /** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
226
229
  _isPendingStrategyIdChange() {
227
- const e = this.pendingNodeConfigWrite;
228
- return e ? l.getConfig(this.currentNode).strategyId !== e.updates.strategyId : !1;
230
+ const e = this._pendingUpdates();
231
+ return e !== null && d.getConfig(this.currentNode).strategyId !== e.strategyId;
229
232
  }
230
233
  _capturePendingNodeConfigWrite() {
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
- });
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();
236
247
  }
237
248
  _getNodeConfigUpdates(e) {
238
- const { filters: t, strategy: o, strategyId: n, size: r, nodeConfigVersion: s } = e, { partnerName: d } = g();
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();
239
260
  return {
240
261
  filters: t,
241
262
  strategy: o,
242
263
  strategyId: n,
243
264
  size: r,
244
- configVersion: s,
245
- ...d.value ? { partnerName: d.value } : {}
265
+ productIds: i,
266
+ language: a,
267
+ shuffleProducts: c,
268
+ currency: B(g),
269
+ configVersion: P,
270
+ ...f.value ? { partnerName: f.value } : {}
246
271
  };
247
272
  }
248
273
  /**
249
274
  * Accumulates the pending write into `documentModifier` without applying, so the
250
275
  * caller's apply() commits config and re-render as ONE undo entry.
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
276
+ * @returns the undo label, null when only stamps moved; undefined when nothing was staged
257
277
  */
258
278
  _stagePendingNodeConfig(e) {
259
- const t = this.pendingNodeConfigWrite;
260
- return !t || !this.currentNode ? !1 : (l.stageConfig(e, this.currentNode, t.updates), !0);
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();
261
285
  }
262
286
  /**
263
287
  * Arms the guaranteed fallback write, once the product fetch has settled. The
@@ -272,30 +296,25 @@ class he extends P {
272
296
  _clearConfigFlush() {
273
297
  this.pendingConfigFlushTimer !== null && (clearTimeout(this.pendingConfigFlushTimer), this.pendingConfigFlushTimer = null);
274
298
  }
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
- */
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.
280
301
  _flushPendingNodeConfig() {
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
- );
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";
294
308
  }
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;
295
314
  }
296
315
  _syncNodeConfigToStore() {
297
316
  var n;
298
- const e = l.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
317
+ const e = d.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
299
318
  this.store.patchCurrentBlockConfig({
300
319
  strategy: e.strategy,
301
320
  strategyId: e.strategyId,
@@ -314,15 +333,7 @@ class he extends P {
314
333
  shuffleProducts: e.shuffleProducts,
315
334
  priceMovedToNextLine: e.priceMovedToNextLine,
316
335
  priceHideIfSameAsDiscounted: e.priceHideIfSameAsDiscounted,
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
- }
336
+ currencySettings: p(e.currency)
326
337
  }, { triggerRefetch: !1 });
327
338
  }
328
339
  /**
@@ -369,51 +380,41 @@ class he extends P {
369
380
  _applySmartDefaults() {
370
381
  if (!this.currentNode || !this.api)
371
382
  return;
372
- const e = l.getConfig(this.currentNode), t = {};
383
+ const e = d.getConfig(this.currentNode), t = {};
373
384
  let o = null, n = null, r = null;
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,
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,
380
391
  code: o,
381
392
  symbol: o
382
393
  }));
383
394
  }
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));
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));
389
400
  }
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));
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));
395
406
  }
396
- !o && !n && !r || (l.updateConfig(
407
+ !o && !n && !r || (d.updateConfig(
397
408
  this.api,
398
409
  this.currentNode,
399
410
  t,
400
411
  "Applied smart defaults"
401
- ), o && t.currency && V({
412
+ ), o && t.currency && z({
402
413
  currentNode: this.currentNode,
403
414
  documentModifier: this.api.getDocumentModifier(),
404
415
  currency: t.currency
405
416
  }), this.store.patchCurrentBlockConfig({
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
- } : {},
417
+ ...o && t.currency ? { currencySettings: p(t.currency) } : {},
417
418
  ...n ? { strategy: n } : {},
418
419
  ...r ? { language: r } : {}
419
420
  }, { triggerRefetch: !1 }));
@@ -422,10 +423,10 @@ class he extends P {
422
423
  * Reads the recommendation-id attribute from the block element within the node
423
424
  */
424
425
  _getRecommendationIdFromNode(e) {
425
- const t = x(e);
426
+ const t = $(e);
426
427
  if (!t || !("getAttribute" in t))
427
428
  return null;
428
- const o = t.getAttribute(k);
429
+ const o = t.getAttribute(O);
429
430
  if (!o)
430
431
  return null;
431
432
  const n = parseInt(o);
@@ -435,20 +436,18 @@ class he extends P {
435
436
  * Lands what the panel still owes its block before it stops watching it: the config now, the
436
437
  * products through a block-scoped refresh. Never throws — it runs from Stripo's teardown.
437
438
  */
438
- _finishBlockOutsidePanel({ blockId: e, fetchedConfigVersion: t, hasUnrenderedProducts: o } = this._trackedBlockSnapshot()) {
439
+ _finishBlockOutsidePanel(e = this._trackedBlockSnapshot()) {
440
+ var r;
441
+ const { blockId: t, fetchedConfigVersion: o, hasUnrenderedProducts: n } = e;
439
442
  try {
440
- this._flushPendingNodeConfig();
441
- const n = e === null ? void 0 : this.store.blockStates[e];
442
- if (e === null || !n)
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);
443
446
  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);
447
+ }
448
+ this._flushPendingNodeConfig();
449
+ } catch (i) {
450
+ console.error("[recommendation] finishing the block outside the panel failed", i);
452
451
  }
453
452
  }
454
453
  _trackedBlockSnapshot() {
@@ -459,7 +458,7 @@ class he extends P {
459
458
  };
460
459
  }
461
460
  _refreshOutsidePanel(e, t) {
462
- S(e, {
461
+ T(e, {
463
462
  pickUpdates: (o) => this._getNodeConfigUpdates(o),
464
463
  description: "Update recommendation configuration",
465
464
  fetch: t
@@ -477,20 +476,32 @@ class he extends P {
477
476
  _regenerateWithProducts() {
478
477
  if (!this.currentNode || !this.api)
479
478
  return;
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());
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);
483
486
  return;
484
487
  }
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
- });
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);
494
505
  }
495
506
  /**
496
507
  * Listen to store changes that require product refresh or regeneration.
@@ -511,51 +522,52 @@ class he extends P {
511
522
  this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this.storeUnsubscription = e.$subscribe(() => {
512
523
  const n = e.currentRecommendationId;
513
524
  if (n !== this.trackedBlockId) {
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);
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);
516
527
  return;
517
528
  }
518
529
  const r = this._getBlockConfigVersion(n);
519
530
  r !== o && (o = r, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts(n, 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));
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));
522
533
  });
523
534
  }
524
535
  }
525
536
  export {
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
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
561
573
  };