@useinsider/guido 3.17.0-beta.a0d17c2 → 3.17.0-beta.a2334c9

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 (27) hide show
  1. package/dist/components/Guido.vue.js +4 -4
  2. package/dist/components/Guido.vue2.js +48 -46
  3. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +7 -7
  4. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +80 -55
  5. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
  6. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
  7. package/dist/composables/useLegacyStrategyConversion.js +52 -0
  8. package/dist/enums/extensions/recommendationBlock.js +2 -1
  9. package/dist/extensions/Blocks/Recommendation/block.js +12 -11
  10. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +14 -13
  11. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +92 -90
  12. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +62 -28
  13. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +90 -49
  14. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +58 -0
  15. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +9 -9
  16. package/dist/guido.css +1 -1
  17. package/dist/services/recommendationApi.js +61 -52
  18. package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
  19. package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
  20. package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -0
  21. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +2 -0
  22. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +1 -0
  23. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +54 -1
  24. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +39 -0
  25. package/dist/src/services/recommendationApi.d.ts +2 -1
  26. package/dist/static/styles/components/recommendation-strategy.css.js +33 -3
  27. package/package.json +1 -1
@@ -1,11 +1,11 @@
1
- const c = ".recommendation-block-v2", n = ".ins-recommendation-product-container", _ = ".ins-recommendation-desktop-container", R = ".ins-recommendation-mobile-container", r = ".ins-recommendation-mobile-row", e = "reco-v3-button", A = "ins-skip-compile", E = {
1
+ const c = ".recommendation-block-v2", n = ".ins-recommendation-product-container", _ = ".ins-recommendation-desktop-container", R = ".ins-recommendation-mobile-container", e = ".ins-recommendation-mobile-row", r = "reco-v3-button", A = "ins-skip-compile", E = {
2
2
  CURRENCY: "currency",
3
3
  SYMBOL: "currency-symbol",
4
4
  ALIGNMENT: "currency-alignment",
5
5
  THOUSAND_SEPARATOR: "currency-thousand-separator",
6
6
  DECIMAL_SEPARATOR: "currency-decimal-separator",
7
7
  DECIMAL_COUNT: "currency-decimal-count"
8
- }, s = "productImage", O = "productName", i = "productPrice", C = "productOldPrice", S = "productOmnibusPrice", I = "productOmnibusDiscount", a = "productButton", u = "recommendationTitle", T = "ins-recommendation-title", m = `.${T}`, L = "customAttr:", d = "data-custom-attributes", U = "data-card-composition", N = "product-attr", t = "recommendation-attribute-row", P = `.${t}`, D = "data-attribute-type", p = "data-visibility", B = "spacer", M = "product_attribute.", o = /* @__PURE__ */ new Set([
8
+ }, s = "productImage", O = "productName", i = "productPrice", C = "productOldPrice", S = "productOmnibusPrice", I = "productOmnibusDiscount", a = "productButton", m = "recommendationTitle", T = "ins-recommendation-title", u = `.${T}`, L = "customAttr:", d = "data-custom-attributes", U = "data-card-composition", N = "recommendation-id", D = "product-attr", t = "recommendation-attribute-row", P = `.${t}`, p = "data-attribute-type", B = "data-visibility", M = "spacer", l = "product_attribute.", o = /* @__PURE__ */ new Set([
9
9
  "name",
10
10
  // productName
11
11
  "price",
@@ -20,18 +20,18 @@ const c = ".recommendation-block-v2", n = ".ins-recommendation-product-container
20
20
  // productOmnibusPrice
21
21
  "omnibus_discount"
22
22
  // productOmnibusDiscount
23
- ]), l = /* @__PURE__ */ new Set([
23
+ ]), b = /* @__PURE__ */ new Set([
24
24
  ...o,
25
25
  "currency",
26
26
  "discount"
27
27
  ]);
28
28
  export {
29
29
  L as ATTR_CUSTOM_PREFIX,
30
- D as ATTR_DATA_ATTRIBUTE_TYPE,
30
+ p as ATTR_DATA_ATTRIBUTE_TYPE,
31
31
  U as ATTR_DATA_CARD_COMPOSITION,
32
32
  d as ATTR_DATA_CUSTOM_ATTRIBUTES,
33
- p as ATTR_DATA_VISIBILITY,
34
- N as ATTR_PRODUCT_ATTR,
33
+ B as ATTR_DATA_VISIBILITY,
34
+ D as ATTR_PRODUCT_ATTR,
35
35
  a as ATTR_PRODUCT_BUTTON,
36
36
  s as ATTR_PRODUCT_IMAGE,
37
37
  O as ATTR_PRODUCT_NAME,
@@ -39,21 +39,22 @@ export {
39
39
  I as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
40
40
  S as ATTR_PRODUCT_OMNIBUS_PRICE,
41
41
  i as ATTR_PRODUCT_PRICE,
42
- u as ATTR_RECOMMENDATION_TITLE,
42
+ m as ATTR_RECOMMENDATION_TITLE,
43
43
  c as BLOCK_ROOT_SELECTOR,
44
44
  o as BUILT_IN_DEFAULT_ATTRIBUTES,
45
45
  n as CONTAINER_SELECTOR,
46
46
  t as CSS_CLASS_ATTRIBUTE_ROW,
47
- e as CSS_CLASS_RECO_BUTTON,
47
+ r as CSS_CLASS_RECO_BUTTON,
48
48
  A as CSS_CLASS_SKIP_COMPILE,
49
- B as CSS_CLASS_SPACER,
49
+ M as CSS_CLASS_SPACER,
50
50
  T as CSS_CLASS_TITLE_CELL,
51
51
  E as CURRENCY_ATTR,
52
52
  _ as DESKTOP_CONTAINER_SELECTOR,
53
53
  R as MOBILE_CONTAINER_SELECTOR,
54
- r as MOBILE_ROW_SELECTOR,
55
- M as PRODUCT_ATTRIBUTE_PREFIX,
56
- l as RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES,
54
+ e as MOBILE_ROW_SELECTOR,
55
+ l as PRODUCT_ATTRIBUTE_PREFIX,
56
+ N as RECOMMENDATION_ID_ATTR,
57
+ b as RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES,
57
58
  P as SELECTOR_ATTRIBUTE_ROW,
58
- m as SELECTOR_TITLE_CELL
59
+ u as SELECTOR_TITLE_CELL
59
60
  };
@@ -1,41 +1,42 @@
1
1
  var m = Object.defineProperty;
2
- var C = (h, l, t) => l in h ? m(h, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[l] = t;
3
- var r = (h, l, t) => C(h, typeof l != "symbol" ? l + "" : l, 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
7
  import { CURRENT_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
8
+ import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
8
9
  import { RecommendationConfigService as c } from "../../services/configService.js";
9
- import { useRecommendationExtensionStore as I } from "../../store/recommendation.js";
10
- import { registerNodeConfigWriter as R } from "../../utils/nodeConfigWriter.js";
11
- import { AlgorithmControl as b } from "./algorithm.js";
12
- import { ALGORITHM_CONTROL_ID as ct } from "./algorithm.js";
13
- import { CurrencyControl as T } from "./currency.js";
14
- import { CURRENCY_CONTROL_ID as dt } from "./currency.js";
15
- import { FiltersControl as P } from "./filters.js";
16
- import { FILTERS_CONTROL_ID as ft } from "./filters.js";
17
- import { LayoutOrientationControl as S } from "./layoutOrientation.js";
18
- import { LAYOUT_ORIENTATION_CONTROL_ID as mt } from "./layoutOrientation.js";
19
- import { LocaleControl as O } from "./locale.js";
20
- import { LOCALE_CONTROL_ID as pt } from "./locale.js";
21
- import { PricePlacementControl as L } from "./pricePlacement.js";
22
- import { PRICE_PLACEMENT_CONTROL_ID as Nt } from "./pricePlacement.js";
23
- import { ProductCountControl as E } from "./productCount.js";
24
- import { PRODUCT_COUNT_CONTROL_ID as It } from "./productCount.js";
25
- import { ProductLayoutControl as k } from "./productLayout.js";
26
- import { PRODUCT_LAYOUT_CONTROL_ID as bt } from "./productLayout.js";
27
- import { ShuffleControl as D } from "./shuffle.js";
28
- import { SHUFFLE_CONTROL_ID as Pt } from "./shuffle.js";
29
- import { StrategyControl as F } from "./strategy.js";
30
- import { STRATEGY_CONTROL_ID as Ot } from "./strategy.js";
31
- import { setCurrencyAttributes as w, getBlockElement as A, isPartnerManagedBlock as v, updateProductContentInPlace as x, regenerateProductRowsWithStyles as B } from "./utils.js";
32
- import { adjustProductsToSize as Et, formatProductPrice as kt, getCardComposition as Dt, getCurrentLayout as Ft, getMainContainerTbody as wt, regenerateMobileProductRows as At, updatePricesInPlace as vt, updateSingleProductContent as xt } from "./utils.js";
10
+ import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
11
+ import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
12
+ import { AlgorithmControl as T } from "./algorithm.js";
13
+ import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
14
+ import { CurrencyControl as P } from "./currency.js";
15
+ import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
16
+ import { FiltersControl as S } from "./filters.js";
17
+ import { FILTERS_CONTROL_ID as ht } from "./filters.js";
18
+ import { LayoutOrientationControl as O } from "./layoutOrientation.js";
19
+ import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
20
+ import { LocaleControl as L } from "./locale.js";
21
+ import { LOCALE_CONTROL_ID as yt } from "./locale.js";
22
+ import { PricePlacementControl as E } from "./pricePlacement.js";
23
+ import { PRICE_PLACEMENT_CONTROL_ID as _t } from "./pricePlacement.js";
24
+ import { ProductCountControl as k } from "./productCount.js";
25
+ import { PRODUCT_COUNT_CONTROL_ID as Rt } from "./productCount.js";
26
+ import { ProductLayoutControl as D } from "./productLayout.js";
27
+ import { PRODUCT_LAYOUT_CONTROL_ID as Tt } from "./productLayout.js";
28
+ import { ShuffleControl as F } from "./shuffle.js";
29
+ import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
30
+ import { StrategyControl as w } from "./strategy.js";
31
+ import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
32
+ import { setCurrencyAttributes as A, getBlockElement as B, isPartnerManagedBlock as v, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
33
+ import { adjustProductsToSize as kt, formatProductPrice as Dt, getCardComposition as Ft, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as Bt, updatePricesInPlace as vt, updateSingleProductContent as xt } from "./utils.js";
33
34
  import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
34
- const U = "recommendation-id", $ = "ui-elements-recommendation-block";
35
- class st extends N {
35
+ const $ = "ui-elements-recommendation-block";
36
+ class at extends N {
36
37
  constructor() {
37
38
  super(...arguments);
38
- r(this, "store", I());
39
+ r(this, "store", R());
39
40
  r(this, "storeUnsubscription", () => {
40
41
  });
41
42
  // blockId -> fingerprint of the node config as it looked at the last sync.
@@ -90,7 +91,7 @@ class st extends N {
90
91
  currentNode: this.currentNode,
91
92
  documentModifier: e,
92
93
  products: t
93
- }) || B({
94
+ }) || U({
94
95
  currentNode: this.currentNode,
95
96
  documentModifier: e,
96
97
  products: t
@@ -119,7 +120,7 @@ class st extends N {
119
120
  return this.rrsEnabled = p().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
120
121
  var o;
121
122
  return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
122
- }), this.algorithmControl = new b(), this.localeControl = new O(), this.currencyControl = new T(), this.productCountControl = new E(), this.productLayoutControl = new k(), this.filtersControl = new P(), this.shuffleControl = new D(), this.pricePlacementControl = new L(), this.layoutOrientationControl = new S(), this.strategyControl = this.rrsEnabled ? new F() : null, this._subControls.forEach((e) => {
123
+ }), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new k(), this.productLayoutControl = new D(), this.filtersControl = new S(), this.shuffleControl = new F(), this.pricePlacementControl = new E(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((e) => {
123
124
  e && (e.api = this.api);
124
125
  }), `
125
126
  <div class="recommendation-controls-container">
@@ -141,12 +142,12 @@ class st extends N {
141
142
  const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
142
143
  if (!e)
143
144
  return;
144
- 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) >= _);
145
- e.classList.toggle("strategy-block", n);
145
+ 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;
146
+ e.classList.toggle("strategy-block", n), e.classList.toggle("legacy-strategy-block", s);
146
147
  }
147
148
  async onRender() {
148
149
  var o;
149
- R(this.api);
150
+ b(this.api);
150
151
  const t = this._getRecommendationIdFromNode(this.currentNode), e = t ?? this.store.currentRecommendationId;
151
152
  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)) {
152
153
  this._initializeSubControls();
@@ -161,8 +162,8 @@ class st extends N {
161
162
  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(() => {
162
163
  this._initializeSubControls();
163
164
  }), this._subControls.forEach((n) => {
164
- var i;
165
- n != null && n.api && (n.currentNode = t, (i = n.onTemplateNodeUpdated) == null || i.call(n, t));
165
+ var s;
166
+ n != null && n.api && (n.currentNode = t, (s = n.onTemplateNodeUpdated) == null || s.call(n, t));
166
167
  });
167
168
  }
168
169
  onDestroy() {
@@ -209,11 +210,11 @@ class st extends N {
209
210
  const t = this.store.currentRecommendationId;
210
211
  if (!this.currentNode || !this.api || t === null)
211
212
  return;
212
- const { filters: e, strategyId: o, size: n } = this.store.recommendationConfigs;
213
+ const { filters: e, strategyId: o, size: n, nodeConfigVersion: s } = this.store.recommendationConfigs;
213
214
  this.pendingNodeConfigWrite = {
214
215
  blockId: t,
215
216
  node: this.currentNode,
216
- updates: { filters: e, strategyId: o, size: n }
217
+ updates: { filters: e, strategyId: o, size: n, configVersion: s }
217
218
  };
218
219
  }
219
220
  /**
@@ -261,6 +262,7 @@ class st extends N {
261
262
  this.store.patchCurrentBlockConfig({
262
263
  strategy: t.strategy,
263
264
  strategyId: t.strategyId,
265
+ nodeConfigVersion: t.configVersion,
264
266
  language: t.language,
265
267
  size: t.size,
266
268
  productIds: t.productIds,
@@ -322,35 +324,35 @@ class st extends N {
322
324
  if (!this.currentNode || !this.api)
323
325
  return;
324
326
  const t = c.getConfig(this.currentNode), e = {};
325
- let o = null, n = null, i = null;
327
+ let o = null, n = null, s = null;
326
328
  if (t.currency.code === a.currency.code) {
327
- const { currencyList: s } = this.store;
328
- s.length > 0 && (s.some(
329
+ const { currencyList: i } = this.store;
330
+ i.length > 0 && (i.some(
329
331
  (d) => d.value === `price.${a.currency.code}`
330
- ) || (o = s[0].value.replace("price.", ""), e.currency = {
332
+ ) || (o = i[0].value.replace("price.", ""), e.currency = {
331
333
  ...a.currency,
332
334
  code: o,
333
335
  symbol: o
334
336
  }));
335
337
  }
336
338
  if (t.strategy === a.strategy) {
337
- const s = this.store.getActivePredictiveAlgorithms;
338
- s.length > 0 && (s.some(
339
+ const i = this.store.getActivePredictiveAlgorithms;
340
+ i.length > 0 && (i.some(
339
341
  (d) => d.value === a.strategy
340
- ) || (n = s[0].value, e.strategy = n));
342
+ ) || (n = i[0].value, e.strategy = n));
341
343
  }
342
344
  if (t.language === a.language) {
343
- const s = this.store.getLanguages;
344
- s.length > 0 && (s.some(
345
+ const i = this.store.getLanguages;
346
+ i.length > 0 && (i.some(
345
347
  (d) => d.value === a.language
346
- ) || (i = s[0].value, e.language = i));
348
+ ) || (s = i[0].value, e.language = s));
347
349
  }
348
- !o && !n && !i || (c.updateConfig(
350
+ !o && !n && !s || (c.updateConfig(
349
351
  this.api,
350
352
  this.currentNode,
351
353
  e,
352
354
  "Applied smart defaults"
353
- ), o && e.currency && w({
355
+ ), o && e.currency && A({
354
356
  currentNode: this.currentNode,
355
357
  documentModifier: this.api.getDocumentModifier(),
356
358
  currency: e.currency
@@ -367,17 +369,17 @@ class st extends N {
367
369
  }
368
370
  } : {},
369
371
  ...n ? { strategy: n } : {},
370
- ...i ? { language: i } : {}
372
+ ...s ? { language: s } : {}
371
373
  }, { triggerRefetch: !1 }));
372
374
  }
373
375
  /**
374
376
  * Reads the recommendation-id attribute from the block element within the node
375
377
  */
376
378
  _getRecommendationIdFromNode(t) {
377
- const e = A(t);
379
+ const e = B(t);
378
380
  if (!e || !("getAttribute" in e))
379
381
  return null;
380
- const o = e.getAttribute(U);
382
+ const o = e.getAttribute(I);
381
383
  if (!o)
382
384
  return null;
383
385
  const n = parseInt(o);
@@ -400,51 +402,51 @@ class st extends N {
400
402
  const { store: t } = this;
401
403
  let e = t.recommendationProducts, o = t.$state.configVersion, n = t.currentRecommendationId;
402
404
  this.storeUnsubscription = t.$subscribe(() => {
403
- const i = t.currentRecommendationId;
404
- if (i !== n) {
405
- n = i, e = t.recommendationProducts, o = t.$state.configVersion;
405
+ const s = t.currentRecommendationId;
406
+ if (s !== n) {
407
+ n = s, e = t.recommendationProducts, o = t.$state.configVersion;
406
408
  return;
407
409
  }
408
- const s = t.$state.configVersion;
409
- s !== o && (o = s, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
410
- const u = t.recommendationProducts, d = u !== e, g = Array.isArray(u) && u.length > 0;
411
- d && g && (e = u, this._debouncedRegenerateWithProducts());
410
+ const i = t.$state.configVersion;
411
+ i !== o && (o = i, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
412
+ const u = t.recommendationProducts, d = u !== e, h = Array.isArray(u) && u.length > 0;
413
+ d && h && (e = u, this._debouncedRegenerateWithProducts());
412
414
  });
413
415
  }
414
416
  }
415
417
  export {
416
- ct as ALGORITHM_CONTROL_ID,
417
- b as AlgorithmControl,
418
+ ut as ALGORITHM_CONTROL_ID,
419
+ T as AlgorithmControl,
418
420
  $ as CONTROL_BLOCK_ID,
419
- dt as CURRENCY_CONTROL_ID,
420
- T as CurrencyControl,
421
- ft as FILTERS_CONTROL_ID,
422
- P as FiltersControl,
423
- mt as LAYOUT_ORIENTATION_CONTROL_ID,
424
- pt as LOCALE_CONTROL_ID,
425
- S as LayoutOrientationControl,
426
- O as LocaleControl,
427
- Nt as PRICE_PLACEMENT_CONTROL_ID,
428
- It as PRODUCT_COUNT_CONTROL_ID,
429
- bt as PRODUCT_LAYOUT_CONTROL_ID,
430
- L as PricePlacementControl,
431
- E as ProductCountControl,
432
- k as ProductLayoutControl,
433
- st as RecommendationBlockControl,
434
- Pt as SHUFFLE_CONTROL_ID,
435
- Ot as STRATEGY_CONTROL_ID,
436
- D as ShuffleControl,
437
- F as StrategyControl,
438
- Et as adjustProductsToSize,
439
- kt as formatProductPrice,
440
- A as getBlockElement,
441
- Dt as getCardComposition,
442
- Ft as getCurrentLayout,
443
- wt as getMainContainerTbody,
421
+ gt as CURRENCY_CONTROL_ID,
422
+ P as CurrencyControl,
423
+ ht as FILTERS_CONTROL_ID,
424
+ S as FiltersControl,
425
+ Ct as LAYOUT_ORIENTATION_CONTROL_ID,
426
+ yt as LOCALE_CONTROL_ID,
427
+ O as LayoutOrientationControl,
428
+ L as LocaleControl,
429
+ _t as PRICE_PLACEMENT_CONTROL_ID,
430
+ Rt as PRODUCT_COUNT_CONTROL_ID,
431
+ Tt as PRODUCT_LAYOUT_CONTROL_ID,
432
+ E as PricePlacementControl,
433
+ k as ProductCountControl,
434
+ D as ProductLayoutControl,
435
+ at as RecommendationBlockControl,
436
+ St as SHUFFLE_CONTROL_ID,
437
+ Lt as STRATEGY_CONTROL_ID,
438
+ F as ShuffleControl,
439
+ w as StrategyControl,
440
+ kt as adjustProductsToSize,
441
+ Dt as formatProductPrice,
442
+ B as getBlockElement,
443
+ Ft as getCardComposition,
444
+ wt as getCurrentLayout,
445
+ At as getMainContainerTbody,
444
446
  v as isPartnerManagedBlock,
445
- At as regenerateMobileProductRows,
446
- B as regenerateProductRowsWithStyles,
447
- w as setCurrencyAttributes,
447
+ Bt as regenerateMobileProductRows,
448
+ U as regenerateProductRowsWithStyles,
449
+ A as setCurrencyAttributes,
448
450
  vt as updatePricesInPlace,
449
451
  x as updateProductContentInPlace,
450
452
  xt as updateSingleProductContent
@@ -1,26 +1,30 @@
1
- var d = Object.defineProperty;
2
- var y = (r, s, t) => s in r ? d(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
3
- var o = (r, s, t) => y(r, typeof s != "symbol" ? s + "" : s, t);
4
- import { ACADEMY_LINKS as m } from "../../../../../enums/academy.js";
5
- import { CommonControl as h } from "../../../common-control.js";
6
- import { useRecommendationExtensionStore as u } from "../../store/recommendation.js";
7
- const p = "recommendation-strategy-control";
8
- class f extends h {
1
+ var v = Object.defineProperty;
2
+ var _ = (o, s, t) => s in o ? v(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
3
+ var c = (o, s, t) => _(o, typeof s != "symbol" ? s + "" : s, t);
4
+ import { useLegacyStrategyConversion as S } from "../../../../../composables/useLegacyStrategyConversion.js";
5
+ import { ACADEMY_LINKS as b } from "../../../../../enums/academy.js";
6
+ import { CommonControl as f } from "../../../common-control.js";
7
+ import { useRecommendationExtensionStore as $ } from "../../store/recommendation.js";
8
+ const C = "recommendation-strategy-control";
9
+ class N extends f {
9
10
  constructor() {
10
11
  super(...arguments);
11
- o(this, "store", u());
12
- o(this, "storeUnsubscription", () => {
12
+ c(this, "store", $());
13
+ c(this, "legacyConversion", S());
14
+ c(this, "storeUnsubscription", () => {
13
15
  });
14
- o(this, "listeners", []);
15
- o(this, "lastPaintedState", null);
16
+ c(this, "listeners", []);
17
+ c(this, "lastPaintedState", null);
16
18
  }
17
19
  getId() {
18
- return p;
20
+ return C;
19
21
  }
20
22
  getTemplate() {
21
23
  const t = this.api.translate(
22
24
  "You can assign a recommendation strategy by selecting an existing one or creating a new one to show specific content."
23
- ), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
25
+ ), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy"), r = this.api.translate("Legacy Strategy"), n = this.api.translate(
26
+ "This block uses an older version of recommendation strategies. Update it to manage it like your other strategies."
27
+ );
24
28
  return `
25
29
  <div class="strategy-control-container">
26
30
  <div class="strategy-control-header">
@@ -31,7 +35,7 @@ class f extends h {
31
35
  ${t}
32
36
  ${e}
33
37
  <a
34
- href="${m.EMAIL_RECOMMENDATION_BLOCK}"
38
+ href="${b.EMAIL_RECOMMENDATION_BLOCK}"
35
39
  target="_blank"
36
40
  rel="noopener noreferrer">${a}</a>.
37
41
  </p>
@@ -53,6 +57,29 @@ class f extends h {
53
57
  })
54
58
  ], "strategy-control-cta-row")}
55
59
  </div>
60
+ <div data-strategy-legacy-state style="display: none;">
61
+ <div class="strategy-control-name-band">
62
+ <span class="strategy-control-name">${r}</span>
63
+ </div>
64
+ <div class="strategy-control-description-row">
65
+ <p class="strategy-control-legacy-notice">${n}</p>
66
+ </div>
67
+ <div class="strategy-control-actions">
68
+ ${this._strategyAction({
69
+ id: "guido__btn-update-legacy-strategy",
70
+ label: this.api.translate("Update"),
71
+ modifier: "update"
72
+ })}
73
+ ${this._strategyAction({
74
+ id: "guido__btn-change-legacy-strategy",
75
+ label: this.api.translate("Change"),
76
+ modifier: "change"
77
+ })}
78
+ </div>
79
+ </div>
80
+ <div data-strategy-skeleton style="display: none;">
81
+ <div class="strategy-control-skeleton"></div>
82
+ </div>
56
83
  <div data-strategy-assigned-state style="display: none;">
57
84
  <div class="strategy-control-name-band">
58
85
  <span class="strategy-control-name" data-strategy-name></span>
@@ -100,25 +127,32 @@ class f extends h {
100
127
  const t = this.getContainer();
101
128
  if (!t)
102
129
  return;
103
- const e = (a, n) => {
104
- const i = t.querySelector(a);
105
- i && (i.addEventListener("click", n), this.listeners.push({ element: i, handler: n }));
130
+ const e = (a, r) => {
131
+ const n = t.querySelector(a);
132
+ n && (n.addEventListener("click", r), this.listeners.push({ element: n, handler: r }));
106
133
  };
107
- e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal());
134
+ 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-update-legacy-strategy", () => {
135
+ this.legacyConversion.convertLegacyStrategy();
136
+ });
108
137
  }
109
138
  _renderState() {
110
- var l;
111
- const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((l = this.store.assignedStrategy) == null ? void 0 : l.name) ?? "" : "", a = `${t}\0${e}`;
112
- if (a === this.lastPaintedState)
139
+ var m;
140
+ const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((m = this.store.assignedStrategy) == null ? void 0 : m.name) ?? "" : "", a = this.store.legacyConversionLoading, r = this.store.isLegacyStrategyBlock, n = `${t}\0${e}\0${a}\0${r}`;
141
+ if (n === this.lastPaintedState)
142
+ return;
143
+ const i = this.getContainer();
144
+ if (!i)
113
145
  return;
114
- const n = this.getContainer();
115
- if (!n)
146
+ const g = i.querySelector("[data-strategy-empty-state]"), l = i.querySelector("[data-strategy-assigned-state]"), d = i.querySelector("[data-strategy-legacy-state]"), y = i.querySelector("[data-strategy-skeleton]"), h = i.querySelector("[data-strategy-name]");
147
+ if (!g || !l || !d || !y)
116
148
  return;
117
- const i = n.querySelector("[data-strategy-empty-state]"), c = n.querySelector("[data-strategy-assigned-state]"), g = n.querySelector("[data-strategy-name]");
118
- !i || !c || (i.style.display = t ? "none" : "", c.style.display = t ? "" : "none", g && t && (g.textContent = e || `#${t}`), this.lastPaintedState = a);
149
+ const u = a ? y : t ? l : r ? d : g;
150
+ [g, l, d, y].forEach((p) => {
151
+ p.style.display = p === u ? "" : "none";
152
+ }), h && t && (h.textContent = e || `#${t}`), this.lastPaintedState = n;
119
153
  }
120
154
  }
121
155
  export {
122
- p as STRATEGY_CONTROL_ID,
123
- f as StrategyControl
156
+ C as STRATEGY_CONTROL_ID,
157
+ N as StrategyControl
124
158
  };