@useinsider/guido 3.18.2-beta.45f708c → 3.18.2-beta.4d2b065

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 (58) hide show
  1. package/README.md +21 -3
  2. package/dist/@types/config/schemas.js +59 -51
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +72 -70
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +7 -9
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +51 -66
  7. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
  8. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
  9. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +40 -24
  10. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -26
  11. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
  12. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
  13. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +3 -3
  14. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +20 -21
  15. package/dist/composables/useCustomInterfaceAppearance.js +47 -53
  16. package/dist/composables/useHtmlValidator.js +79 -84
  17. package/dist/composables/useLegacyStrategyConversion.js +61 -0
  18. package/dist/composables/useRecommendation.js +35 -40
  19. package/dist/composables/useStripo.js +30 -30
  20. package/dist/enums/extensions/recommendationBlock.js +41 -39
  21. package/dist/extensions/Blocks/Recommendation/block.js +39 -43
  22. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +20 -21
  23. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +80 -84
  24. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +94 -82
  25. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +97 -96
  26. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +144 -179
  27. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
  28. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +16 -26
  29. package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +12 -21
  30. package/dist/guido.css +1 -1
  31. package/dist/services/recommendationApi.js +46 -37
  32. package/dist/src/@types/config/schemas.d.ts +16 -0
  33. package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
  34. package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
  35. package/dist/src/composables/useConfig.d.ts +4 -0
  36. package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
  37. package/dist/src/enums/extensions/recommendationBlock.d.ts +5 -3
  38. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +0 -1
  39. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  40. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -2
  41. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +1 -8
  42. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +6 -7
  43. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +70 -76
  44. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
  45. package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +0 -4
  46. package/dist/src/services/recommendationApi.d.ts +2 -1
  47. package/dist/src/stores/config.d.ts +322 -0
  48. package/dist/src/stores/onboarding.d.ts +421 -0
  49. package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
  50. package/dist/static/assets/icons/line-info.svg.js +5 -0
  51. package/dist/static/styles/components/recommendation-strategy.css.js +74 -39
  52. package/dist/stores/config.js +74 -60
  53. package/dist/stores/onboarding.js +6 -1
  54. package/dist/utils/templatePreparation.js +55 -55
  55. package/package.json +5 -5
  56. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +0 -24
  57. package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +0 -14
  58. package/dist/static/styles/components/skeleton.css.js +0 -23
@@ -1,12 +1,12 @@
1
1
  var m = Object.defineProperty;
2
- var C = (g, c, t) => c in g ? m(g, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[c] = t;
3
- var n = (g, c, t) => C(g, typeof c != "symbol" ? c + "" : c, t);
2
+ var C = (g, l, t) => l in g ? m(g, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[l] = t;
3
+ var r = (g, l, t) => C(g, typeof l != "symbol" ? l + "" : l, t);
4
4
  import { useConfig as p } from "../../../../../composables/useConfig.js";
5
5
  import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
6
  import { CommonControl as N } from "../../../common-control.js";
7
- import { RRS_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
7
+ import { CURRENT_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
8
8
  import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
9
- import { RecommendationConfigService as l } from "../../services/configService.js";
9
+ import { RecommendationConfigService as c } from "../../services/configService.js";
10
10
  import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
11
11
  import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
12
12
  import { AlgorithmControl as T } from "./algorithm.js";
@@ -14,7 +14,7 @@ import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
14
14
  import { CurrencyControl as P } from "./currency.js";
15
15
  import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
16
16
  import { FiltersControl as S } from "./filters.js";
17
- import { FILTERS_CONTROL_ID as ft } from "./filters.js";
17
+ import { FILTERS_CONTROL_ID as ht } from "./filters.js";
18
18
  import { LayoutOrientationControl as O } from "./layoutOrientation.js";
19
19
  import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
20
20
  import { LocaleControl as L } from "./locale.js";
@@ -29,36 +29,36 @@ import { ShuffleControl as D } from "./shuffle.js";
29
29
  import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
30
30
  import { StrategyControl as w } from "./strategy.js";
31
31
  import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
32
- import { setCurrencyAttributes as A, getBlockElement as v, isPartnerManagedBlock as x, updateProductContentInPlace as B, regenerateProductRowsWithStyles as U } from "./utils.js";
33
- import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as vt, updatePricesInPlace as xt, updateSingleProductContent as Bt } from "./utils.js";
34
- import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
35
- const W = "ui-elements-recommendation-block";
32
+ import { setCurrencyAttributes as A, getBlockElement as B, isPartnerManagedBlock as v, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
33
+ import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as Bt, updatePricesInPlace as vt, updateSingleProductContent as xt } from "./utils.js";
34
+ import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
35
+ const $ = "ui-elements-recommendation-block";
36
36
  class at extends N {
37
37
  constructor() {
38
38
  super(...arguments);
39
- n(this, "store", R());
40
- n(this, "storeUnsubscription", () => {
39
+ r(this, "store", R());
40
+ r(this, "storeUnsubscription", () => {
41
41
  });
42
42
  // A config change waiting to reach the node config. Deferred so it can ride the
43
43
  // re-render's single apply() — one user action must cost one undo press.
44
- n(this, "pendingNodeConfigWrite", null);
45
- n(this, "pendingConfigFlushTimer", null);
44
+ r(this, "pendingNodeConfigWrite", null);
45
+ r(this, "pendingConfigFlushTimer", null);
46
46
  // Sub-control instances for lifecycle management
47
- n(this, "algorithmControl", null);
48
- n(this, "localeControl", null);
49
- n(this, "currencyControl", null);
50
- n(this, "productCountControl", null);
51
- n(this, "productLayoutControl", null);
52
- n(this, "filtersControl", null);
53
- n(this, "shuffleControl", null);
54
- n(this, "pricePlacementControl", null);
55
- n(this, "layoutOrientationControl", null);
56
- n(this, "strategyControl", null);
57
- n(this, "rrsEnabled", !1);
47
+ r(this, "algorithmControl", null);
48
+ r(this, "localeControl", null);
49
+ r(this, "currencyControl", null);
50
+ r(this, "productCountControl", null);
51
+ r(this, "productLayoutControl", null);
52
+ r(this, "filtersControl", null);
53
+ r(this, "shuffleControl", null);
54
+ r(this, "pricePlacementControl", null);
55
+ r(this, "layoutOrientationControl", null);
56
+ r(this, "strategyControl", null);
57
+ r(this, "rrsEnabled", !1);
58
58
  /**
59
59
  * Debounced product fetch to prevent rapid API calls during config changes
60
60
  */
61
- n(this, "_debouncedFetchProducts", h(async () => {
61
+ r(this, "_debouncedFetchProducts", f(async () => {
62
62
  try {
63
63
  await this.store.fetchRecommendationProducts();
64
64
  } finally {
@@ -76,16 +76,16 @@ class at extends N {
76
76
  * count. The store pads products to the configured size, so in-place only
77
77
  * fails when the size actually changed.
78
78
  */
79
- n(this, "_debouncedRegenerateWithProducts", h(() => {
79
+ r(this, "_debouncedRegenerateWithProducts", f(() => {
80
80
  const t = this.store.recommendationProducts;
81
81
  if (!this.currentNode || !this.api)
82
82
  return;
83
83
  const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
84
- if (x(this.currentNode)) {
84
+ if (v(this.currentNode)) {
85
85
  o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
86
86
  return;
87
87
  }
88
- B({
88
+ x({
89
89
  currentNode: this.currentNode,
90
90
  documentModifier: e,
91
91
  products: t
@@ -97,7 +97,7 @@ class at extends N {
97
97
  }, 100));
98
98
  }
99
99
  getId() {
100
- return W;
100
+ return $;
101
101
  }
102
102
  get _subControls() {
103
103
  return [
@@ -140,14 +140,14 @@ class at extends N {
140
140
  const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
141
141
  if (!e)
142
142
  return;
143
- const o = this._getRecommendationIdFromNode(t) === null ? null : l.getConfig(t), r = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _);
144
- e.classList.toggle("strategy-block", r);
143
+ const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _), s = this.rrsEnabled && !!o && !n;
144
+ e.classList.toggle("strategy-block", n), e.classList.toggle("legacy-strategy-block", s);
145
145
  }
146
146
  async onRender() {
147
147
  var o;
148
148
  b(this.api);
149
149
  const t = this._getRecommendationIdFromNode(this.currentNode), e = t ?? this.store.currentRecommendationId;
150
- if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), t !== null && this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender()), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
150
+ if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
151
151
  this._initializeSubControls();
152
152
  return;
153
153
  }
@@ -159,9 +159,9 @@ class at extends N {
159
159
  const e = this._getRecommendationIdFromNode(t);
160
160
  e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && this._syncNodeConfigIfChanged(e), this._showControlsForBlock(t), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
161
161
  this._initializeSubControls();
162
- }), this._subControls.forEach((r) => {
163
- var i;
164
- r != null && r.api && (r.currentNode = t, (i = r.onTemplateNodeUpdated) == null || i.call(r, t));
162
+ }), this._subControls.forEach((n) => {
163
+ var s;
164
+ n != null && n.api && (n.currentNode = t, (s = n.onTemplateNodeUpdated) == null || s.call(n, t));
165
165
  });
166
166
  }
167
167
  onDestroy() {
@@ -209,23 +209,18 @@ class at extends N {
209
209
  const e = this.store.blockStates[t];
210
210
  if (!e)
211
211
  return;
212
- const o = JSON.stringify(l.getConfig(this.currentNode)), r = e.syncedConfigFingerprint;
213
- e.syncedConfigFingerprint = o, r !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
214
- }
215
- /** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
216
- _isPendingStrategyIdChange() {
217
- const t = this.pendingNodeConfigWrite;
218
- return t ? l.getConfig(this.currentNode).strategyId !== t.updates.strategyId : !1;
212
+ const o = JSON.stringify(c.getConfig(this.currentNode)), n = e.syncedConfigFingerprint;
213
+ e.syncedConfigFingerprint = o, n !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
219
214
  }
220
215
  _capturePendingNodeConfigWrite() {
221
216
  const t = this.store.currentRecommendationId;
222
217
  if (!this.currentNode || !this.api || t === null)
223
218
  return;
224
- const { filters: e, strategy: o, strategyId: r, size: i } = this.store.recommendationConfigs;
219
+ const { filters: e, strategyId: o, size: n, nodeConfigVersion: s } = this.store.recommendationConfigs;
225
220
  this.pendingNodeConfigWrite = {
226
221
  blockId: t,
227
222
  node: this.currentNode,
228
- updates: { filters: e, strategy: o, strategyId: r, size: i }
223
+ updates: { filters: e, strategyId: o, size: n, configVersion: s }
229
224
  };
230
225
  }
231
226
  /**
@@ -240,7 +235,7 @@ class at extends N {
240
235
  */
241
236
  _stagePendingNodeConfig(t) {
242
237
  const e = this.pendingNodeConfigWrite;
243
- return !e || !this.currentNode ? !1 : (l.stageConfig(t, this.currentNode, e.updates), !0);
238
+ return !e || !this.currentNode ? !1 : (c.stageConfig(t, this.currentNode, e.updates), !0);
244
239
  }
245
240
  /**
246
241
  * Arms the guaranteed fallback write, once the product fetch has settled. The
@@ -264,15 +259,16 @@ class at extends N {
264
259
  const t = this.pendingNodeConfigWrite;
265
260
  if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
266
261
  return;
267
- const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = l.getConfig(e);
268
- JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size || l.updateConfig(this.api, e, t.updates, "Update recommendation filters");
262
+ const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = c.getConfig(e);
263
+ JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
269
264
  }
270
265
  _syncNodeConfigToStore() {
271
- var r;
272
- const t = l.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
266
+ var n;
267
+ const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
273
268
  this.store.patchCurrentBlockConfig({
274
269
  strategy: t.strategy,
275
270
  strategyId: t.strategyId,
271
+ nodeConfigVersion: t.configVersion,
276
272
  language: t.language,
277
273
  size: t.size,
278
274
  productIds: t.productIds,
@@ -311,8 +307,8 @@ class at extends N {
311
307
  t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
312
308
  this.store.fetchRecommendationCreateData(),
313
309
  this.store.fetchRecommendationFilters()
314
- ])).forEach((o, r) => {
315
- o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][r]} failed`, o.reason);
310
+ ])).forEach((o, n) => {
311
+ o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][n]} failed`, o.reason);
316
312
  }), this._applySmartDefaults();
317
313
  try {
318
314
  await this.store.fetchRecommendationProducts();
@@ -333,31 +329,31 @@ class at extends N {
333
329
  _applySmartDefaults() {
334
330
  if (!this.currentNode || !this.api)
335
331
  return;
336
- const t = l.getConfig(this.currentNode), e = {};
337
- let o = null, r = null, i = null;
332
+ const t = c.getConfig(this.currentNode), e = {};
333
+ let o = null, n = null, s = null;
338
334
  if (t.currency.code === a.currency.code) {
339
- const { currencyList: s } = this.store;
340
- s.length > 0 && (s.some(
335
+ const { currencyList: i } = this.store;
336
+ i.length > 0 && (i.some(
341
337
  (d) => d.value === `price.${a.currency.code}`
342
- ) || (o = s[0].value.replace("price.", ""), e.currency = {
338
+ ) || (o = i[0].value.replace("price.", ""), e.currency = {
343
339
  ...a.currency,
344
340
  code: o,
345
341
  symbol: o
346
342
  }));
347
343
  }
348
344
  if (t.strategy === a.strategy) {
349
- const s = this.store.getActivePredictiveAlgorithms;
350
- s.length > 0 && (s.some(
345
+ const i = this.store.getActivePredictiveAlgorithms;
346
+ i.length > 0 && (i.some(
351
347
  (d) => d.value === a.strategy
352
- ) || (r = s[0].value, e.strategy = r));
348
+ ) || (n = i[0].value, e.strategy = n));
353
349
  }
354
350
  if (t.language === a.language) {
355
- const s = this.store.getLanguages;
356
- s.length > 0 && (s.some(
351
+ const i = this.store.getLanguages;
352
+ i.length > 0 && (i.some(
357
353
  (d) => d.value === a.language
358
- ) || (i = s[0].value, e.language = i));
354
+ ) || (s = i[0].value, e.language = s));
359
355
  }
360
- !o && !r && !i || (l.updateConfig(
356
+ !o && !n && !s || (c.updateConfig(
361
357
  this.api,
362
358
  this.currentNode,
363
359
  e,
@@ -378,22 +374,22 @@ class at extends N {
378
374
  thousandSeparator: a.currency.thousandSeparator
379
375
  }
380
376
  } : {},
381
- ...r ? { strategy: r } : {},
382
- ...i ? { language: i } : {}
377
+ ...n ? { strategy: n } : {},
378
+ ...s ? { language: s } : {}
383
379
  }, { triggerRefetch: !1 }));
384
380
  }
385
381
  /**
386
382
  * Reads the recommendation-id attribute from the block element within the node
387
383
  */
388
384
  _getRecommendationIdFromNode(t) {
389
- const e = v(t);
385
+ const e = B(t);
390
386
  if (!e || !("getAttribute" in e))
391
387
  return null;
392
388
  const o = e.getAttribute(I);
393
389
  if (!o)
394
390
  return null;
395
- const r = parseInt(o);
396
- return Number.isNaN(r) ? null : r;
391
+ const n = parseInt(o);
392
+ return Number.isNaN(n) ? null : n;
397
393
  }
398
394
  /**
399
395
  * Listen to store changes that require product refresh or regeneration.
@@ -410,27 +406,27 @@ class at extends N {
410
406
  */
411
407
  _listenStateUpdates() {
412
408
  const { store: t } = this;
413
- let e = t.recommendationProducts, o = t.$state.configVersion, r = t.currentRecommendationId;
409
+ let e = t.recommendationProducts, o = t.$state.configVersion, n = t.currentRecommendationId;
414
410
  this.storeUnsubscription = t.$subscribe(() => {
415
- const i = t.currentRecommendationId;
416
- if (i !== r) {
417
- r = i, e = t.recommendationProducts, o = t.$state.configVersion;
411
+ const s = t.currentRecommendationId;
412
+ if (s !== n) {
413
+ n = s, e = t.recommendationProducts, o = t.$state.configVersion;
418
414
  return;
419
415
  }
420
- const s = t.$state.configVersion;
421
- s !== o && (o = s, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
422
- const u = t.recommendationProducts, d = u !== e, f = Array.isArray(u) && u.length > 0;
423
- d && f && (e = u, this._debouncedRegenerateWithProducts());
416
+ const i = t.$state.configVersion;
417
+ i !== o && (o = i, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
418
+ const u = t.recommendationProducts, d = u !== e, h = Array.isArray(u) && u.length > 0;
419
+ d && h && (e = u, this._debouncedRegenerateWithProducts());
424
420
  });
425
421
  }
426
422
  }
427
423
  export {
428
424
  ut as ALGORITHM_CONTROL_ID,
429
425
  T as AlgorithmControl,
430
- W as CONTROL_BLOCK_ID,
426
+ $ as CONTROL_BLOCK_ID,
431
427
  gt as CURRENCY_CONTROL_ID,
432
428
  P as CurrencyControl,
433
- ft as FILTERS_CONTROL_ID,
429
+ ht as FILTERS_CONTROL_ID,
434
430
  S as FiltersControl,
435
431
  Ct as LAYOUT_ORIENTATION_CONTROL_ID,
436
432
  yt as LOCALE_CONTROL_ID,
@@ -449,15 +445,15 @@ export {
449
445
  w as StrategyControl,
450
446
  Et as adjustProductsToSize,
451
447
  Ft as formatProductPrice,
452
- v as getBlockElement,
448
+ B as getBlockElement,
453
449
  Dt as getCardComposition,
454
450
  wt as getCurrentLayout,
455
451
  At as getMainContainerTbody,
456
- x as isPartnerManagedBlock,
457
- vt as regenerateMobileProductRows,
452
+ v as isPartnerManagedBlock,
453
+ Bt as regenerateMobileProductRows,
458
454
  U as regenerateProductRowsWithStyles,
459
455
  A as setCurrencyAttributes,
460
- xt as updatePricesInPlace,
461
- B as updateProductContentInPlace,
462
- Bt as updateSingleProductContent
456
+ vt as updatePricesInPlace,
457
+ x as updateProductContentInPlace,
458
+ xt as updateSingleProductContent
463
459
  };
@@ -1,60 +1,49 @@
1
- var u = Object.defineProperty;
2
- var S = (o, n, t) => n in o ? u(o, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[n] = t;
3
- var r = (o, n, t) => S(o, typeof n != "symbol" ? n + "" : n, t);
4
- import { ACADEMY_LINKS as _ } from "../../../../../enums/academy.js";
5
- import { useOnboardingStore as f } from "../../../../../stores/onboarding.js";
6
- import { CommonControl as v } from "../../../common-control.js";
7
- import { RRS_CONFIG_VERSION as b } from "../../constants/defaultConfig.js";
8
- import { RecommendationConfigService as h } from "../../services/configService.js";
9
- import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
10
- const k = "recommendation-strategy-control";
11
- class I extends v {
1
+ var p = Object.defineProperty;
2
+ var v = (i, s, t) => s in i ? p(i, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[s] = t;
3
+ var r = (i, s, t) => v(i, typeof s != "symbol" ? s + "" : s, t);
4
+ import { useLegacyStrategyConversion as _ } from "../../../../../composables/useLegacyStrategyConversion.js";
5
+ import { ACADEMY_LINKS as b } from "../../../../../enums/academy.js";
6
+ import { useOnboardingStore as S } from "../../../../../stores/onboarding.js";
7
+ import { CommonControl as f } from "../../../common-control.js";
8
+ import { useRecommendationExtensionStore as $ } from "../../store/recommendation.js";
9
+ const C = "recommendation-strategy-control";
10
+ class N extends f {
12
11
  constructor() {
13
12
  super(...arguments);
14
- r(this, "store", C());
15
- r(this, "onboardingStore", f());
13
+ r(this, "store", $());
14
+ r(this, "onboardingStore", S());
15
+ r(this, "legacyConversion", _());
16
16
  r(this, "storeUnsubscription", () => {
17
17
  });
18
18
  r(this, "listeners", []);
19
19
  r(this, "lastPaintedState", null);
20
20
  }
21
21
  getId() {
22
- return k;
22
+ return C;
23
23
  }
24
24
  getTemplate() {
25
25
  const t = this.api.translate(
26
26
  "You can assign a recommendation strategy by selecting an existing one or creating a new one to show specific content."
27
- ), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
27
+ ), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy"), o = this.api.translate("Legacy Strategy"), n = this.api.translate(
28
+ "Note that this is an older version of the Recommendation Strategy. We recommend you update it to the new Recommendation Strategy for an improved experience."
29
+ );
28
30
  return `
29
31
  <div class="strategy-control-container">
30
- <div data-strategy-loading-state>
31
- <div class="strategy-control-header">
32
- <span class="guido-skeleton guido-skeleton--strategy-title"></span>
33
- </div>
34
- <div class="strategy-control-description-row">
35
- <span class="guido-skeleton guido-skeleton--strategy-description"></span>
36
- </div>
37
- <div class="strategy-control-skeleton-row">
38
- <span class="guido-skeleton guido-skeleton--strategy-cta"></span>
39
- <span class="guido-skeleton guido-skeleton--strategy-cta"></span>
40
- </div>
32
+ <div class="strategy-control-header">
33
+ <h3 class="strategy-control-title">${this.api.translate("Recommendation Strategy")}</h3>
41
34
  </div>
42
- <div data-strategy-content style="display: none;">
43
- <div class="strategy-control-header">
44
- <h3 class="strategy-control-title">${this.api.translate("Recommendation Strategy")}</h3>
45
- </div>
46
- <div class="strategy-control-description-row">
47
- <p class="strategy-control-description">
48
- ${t}
49
- ${e}
50
- <a
51
- href="${_.EMAIL_RECOMMENDATION_BLOCK}"
52
- target="_blank"
53
- rel="noopener noreferrer">${a}</a>.
54
- </p>
55
- </div>
56
- <div data-strategy-empty-state style="display: none;">
57
- ${this._GuTwoColumns([
35
+ <div class="strategy-control-description-row">
36
+ <p class="strategy-control-description">
37
+ ${t}
38
+ ${e}
39
+ <a
40
+ href="${b.EMAIL_RECOMMENDATION_BLOCK}"
41
+ target="_blank"
42
+ rel="noopener noreferrer">${a}</a>.
43
+ </p>
44
+ </div>
45
+ <div data-strategy-empty-state>
46
+ ${this._GuTwoColumns([
58
47
  this._GuButton({
59
48
  name: "assignStrategy",
60
49
  label: this.api.translate("Assign Strategy"),
@@ -65,28 +54,53 @@ class I extends v {
65
54
  name: "createStrategy",
66
55
  label: this.api.translate("Create New Strategy"),
67
56
  id: "guido__btn-create-strategy",
68
- className: "strategy-control-cta primary"
57
+ className: "strategy-control-cta primary",
58
+ disabled: !0
69
59
  })
70
60
  ], "strategy-control-cta-row")}
71
- </div>
72
- <div data-strategy-assigned-state style="display: none;">
73
- <div class="strategy-control-name-band">
74
- <span class="strategy-control-name" data-strategy-name></span>
75
- <span
76
- class="guido-skeleton guido-skeleton--strategy-name" data-strategy-name-skeleton></span>
61
+ </div>
62
+ <div data-strategy-legacy-state style="display: none;">
63
+ <div class="strategy-control-notice-row">
64
+ <div class="strategy-control-notice">
65
+ <p class="strategy-control-notice-text">${n}</p>
77
66
  </div>
78
- <div class="strategy-control-actions">
79
- ${this._strategyAction({
67
+ </div>
68
+ <div class="strategy-control-name-band">
69
+ <span class="strategy-control-name">${o}</span>
70
+ ${this._strategyAction({
71
+ id: "guido__btn-update-legacy-strategy",
72
+ label: this.api.translate("Update"),
73
+ modifier: "update"
74
+ })}
75
+ </div>
76
+ <div class="strategy-control-actions">
77
+ ${this._strategyAction({
78
+ id: "guido__btn-change-legacy-strategy",
79
+ label: this.api.translate("Change"),
80
+ modifier: "change"
81
+ })}
82
+ ${this._strategyAction({
83
+ id: "guido__btn-remove-legacy-strategy",
84
+ label: this.api.translate("Remove"),
85
+ modifier: "remove"
86
+ })}
87
+ </div>
88
+ </div>
89
+ <div data-strategy-assigned-state style="display: none;">
90
+ <div class="strategy-control-name-band">
91
+ <span class="strategy-control-name" data-strategy-name></span>
92
+ </div>
93
+ <div class="strategy-control-actions">
94
+ ${this._strategyAction({
80
95
  id: "guido__btn-change-strategy",
81
96
  label: this.api.translate("Change"),
82
97
  modifier: "change"
83
98
  })}
84
- ${this._strategyAction({
99
+ ${this._strategyAction({
85
100
  id: "guido__btn-remove-strategy",
86
101
  label: this.api.translate("Remove"),
87
102
  modifier: "remove"
88
103
  })}
89
- </div>
90
104
  </div>
91
105
  </div>
92
106
  </div>
@@ -103,54 +117,52 @@ class I extends v {
103
117
  `;
104
118
  }
105
119
  onRender() {
106
- this._teardown(), this.store.strategyPanelOpen = !0, this._setupButtonListeners(), this._renderState(), this.storeUnsubscription = this.store.$subscribe(() => {
120
+ this._teardown(), this._setupButtonListeners(), this._renderState(), this.storeUnsubscription = this.store.$subscribe(() => {
107
121
  this._renderState();
108
- }), this.store.recommendationConfigs.strategyId && !this.store.strategiesFetched && this.store.fetchStrategies().catch(() => {
122
+ }), this.store.recommendationConfigs.strategyId && !this.store.strategies.length && this.store.fetchStrategies().catch(() => {
109
123
  });
110
- }
111
- /**
112
- * Whether the document itself says this block has no strategy.
113
- *
114
- * Read the node, not the store: when the main control cannot resolve the block id off the
115
- * node it never syncs the persisted config, so the store still holds defaults (empty
116
- * strategyId) for an assigned block.
117
- */
118
- _isNodeUnassigned() {
119
- if (!h.hasConfig(this.currentNode))
120
- return !1;
121
- const t = h.getConfig(this.currentNode);
122
- return !t.strategyId && (t.configVersion ?? 0) >= b;
124
+ const t = this.store.currentRecommendationId, e = t !== null && !!this.store.blockStates[t], a = this.store.isLegacyStrategyBlock;
125
+ e && !this.store.recommendationConfigs.strategyId && !a && this.onboardingStore.startOnboarding("recommendationStrategyOnboarding"), e && a && this.onboardingStore.startOnboarding("recommendationLegacyStrategyOnboarding");
123
126
  }
124
127
  onDestroy() {
125
128
  this._teardown();
126
129
  }
127
130
  _teardown() {
128
- this.store.strategyPanelOpen = !1, this.storeUnsubscription(), this.storeUnsubscription = () => {
131
+ this.storeUnsubscription(), this.storeUnsubscription = () => {
129
132
  }, this.lastPaintedState = null, this.listeners.forEach(({ element: t, handler: e }) => t.removeEventListener("click", e)), this.listeners = [];
130
133
  }
131
134
  _setupButtonListeners() {
132
135
  const t = this.getContainer();
133
136
  if (!t)
134
137
  return;
135
- const e = (a, i) => {
136
- const s = t.querySelector(a);
137
- s && (s.addEventListener("click", i), this.listeners.push({ element: s, handler: i }));
138
+ const e = (a, o) => {
139
+ const n = t.querySelector(a);
140
+ n && (n.addEventListener("click", o), this.listeners.push({ element: n, handler: o }));
138
141
  };
139
- e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-create-strategy", () => this.store.openStrategyCreation()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal());
142
+ e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-legacy-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal()), e("#guido__btn-remove-legacy-strategy", () => this.store.openRemoveStrategyModal()), e("#guido__btn-update-legacy-strategy", () => {
143
+ this.legacyConversion.convertLegacyStrategy();
144
+ });
140
145
  }
141
146
  _renderState() {
142
- var p;
143
- const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((p = this.store.assignedStrategy) == null ? void 0 : p.name) ?? "" : "", a = !!t && !e && (this.store.strategiesLoading || !this.store.strategiesSettled), i = `${t}\0${e}\0${a}`;
144
- if (i === this.lastPaintedState)
147
+ var h;
148
+ const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((h = this.store.assignedStrategy) == null ? void 0 : h.name) ?? "" : "", a = this.store.legacyConversionLoading, o = this.store.isLegacyStrategyBlock, n = `${t}\0${e}\0${a}\0${o}`;
149
+ if (n === this.lastPaintedState)
150
+ return;
151
+ const c = this.getContainer();
152
+ if (!c)
145
153
  return;
146
- const s = this.getContainer();
147
- if (!s)
154
+ const d = c.querySelector("[data-strategy-empty-state]"), y = c.querySelector("[data-strategy-assigned-state]"), g = c.querySelector("[data-strategy-legacy-state]"), m = c.querySelector("[data-strategy-name]");
155
+ if (!d || !y || !g)
148
156
  return;
149
- const c = s.querySelector("[data-strategy-empty-state]"), g = s.querySelector("[data-strategy-assigned-state]"), l = s.querySelector("[data-strategy-loading-state]"), y = s.querySelector("[data-strategy-content]"), d = s.querySelector("[data-strategy-name]"), m = s.querySelector("[data-strategy-name-skeleton]");
150
- !c || !g || (l && (l.style.display = "none"), y && (y.style.display = ""), c.style.display = t ? "none" : "", g.style.display = t ? "" : "none", !t && this._isNodeUnassigned() && this.onboardingStore.startOnboarding("recommendationStrategyOnboarding"), d && (d.style.display = a ? "none" : "", t && !a && (d.textContent = e || `#${t}`)), m && (m.style.display = a ? "block" : "none"), this.lastPaintedState = i);
157
+ const u = t ? y : o ? g : d;
158
+ [d, y, g].forEach((l) => {
159
+ l.style.display = l === u ? "" : "none";
160
+ }), g.querySelectorAll("button").forEach((l) => {
161
+ l.disabled = a;
162
+ }), g.classList.toggle("is-converting", a), m && t && (m.textContent = e || `#${t}`), this.lastPaintedState = n;
151
163
  }
152
164
  }
153
165
  export {
154
- k as STRATEGY_CONTROL_ID,
155
- I as StrategyControl
166
+ C as STRATEGY_CONTROL_ID,
167
+ N as StrategyControl
156
168
  };