@useinsider/guido 3.17.0-beta.3ff6ea0 → 3.17.0-beta.562c5b1

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 (78) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +12 -6
  3. package/dist/components/Guido.vue.js +2 -2
  4. package/dist/components/Guido.vue2.js +64 -62
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +21 -0
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +69 -0
  7. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +19 -0
  8. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +13 -0
  9. package/dist/composables/useCustomInterfaceAppearance.js +52 -38
  10. package/dist/composables/useRecommendation.js +52 -44
  11. package/dist/composables/useStripo.js +14 -14
  12. package/dist/config/migrator/index.js +8 -9
  13. package/dist/config/migrator/recommendation/compositionMapper.js +20 -20
  14. package/dist/config/migrator/recommendation/extractors.js +24 -29
  15. package/dist/config/migrator/recommendation/htmlBuilder.js +130 -116
  16. package/dist/config/migrator/recommendation/settingsMapper.js +19 -17
  17. package/dist/config/migrator/recommendationMigrator.js +15 -16
  18. package/dist/enums/academy.js +2 -1
  19. package/dist/enums/date.js +4 -3
  20. package/dist/enums/extensions/recommendationBlock.js +4 -1
  21. package/dist/extensions/Blocks/Recommendation/block.js +26 -21
  22. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +1 -1
  23. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  24. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +26 -25
  25. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +28 -34
  26. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +256 -323
  27. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +186 -165
  28. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +142 -0
  29. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +0 -1
  30. package/dist/extensions/Blocks/Recommendation/extension.js +29 -31
  31. package/dist/extensions/Blocks/Recommendation/services/configService.js +35 -35
  32. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +4 -23
  33. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +224 -80
  34. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -3
  35. package/dist/extensions/Blocks/Recommendation/templates/utils.js +107 -85
  36. package/dist/extensions/Blocks/common-control.js +22 -19
  37. package/dist/guido.css +1 -1
  38. package/dist/services/recommendationApi.js +75 -30
  39. package/dist/src/@types/config/schemas.d.ts +12 -0
  40. package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
  41. package/dist/src/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.d.ts +17 -0
  42. package/dist/src/composables/useConfig.d.ts +2 -0
  43. package/dist/src/composables/useRecommendation.d.ts +1 -0
  44. package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -8
  45. package/dist/src/enums/academy.d.ts +1 -0
  46. package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
  47. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +1 -2
  48. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +0 -7
  49. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +7 -7
  50. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +2 -2
  51. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -10
  52. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +0 -10
  53. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +0 -1
  54. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +16 -3
  55. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +30 -0
  56. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -1
  57. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +206 -10
  58. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
  59. package/dist/src/extensions/Blocks/common-control.d.ts +4 -1
  60. package/dist/src/mock/api/recommendation-strategies.d.ts +2 -0
  61. package/dist/src/services/recommendationApi.d.ts +4 -1
  62. package/dist/src/stores/config.d.ts +18 -0
  63. package/dist/src/utils/strategyInfoBox.d.ts +35 -0
  64. package/dist/static/assets/icons/line-change.svg.js +5 -0
  65. package/dist/static/assets/icons/line-delete.svg.js +5 -0
  66. package/dist/static/assets/icons/line-plus.svg.js +5 -0
  67. package/dist/static/styles/components/recommendation-strategy.css.js +188 -0
  68. package/dist/static/styles/customEditorStyle.css.js +1 -3
  69. package/dist/utils/dateUtil.js +29 -10
  70. package/dist/utils/strategyInfoBox.js +68 -0
  71. package/dist/utils/templatePreparation.js +37 -34
  72. package/package.json +2 -1
  73. package/dist/config/migrator/recommendationTitleMigrator.js +0 -119
  74. package/dist/extensions/Blocks/Recommendation/controls/title/index.js +0 -44
  75. package/dist/extensions/Blocks/Recommendation/templates/titleRows.js +0 -33
  76. package/dist/src/config/migrator/recommendationTitleMigrator.d.ts +0 -5
  77. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +0 -86
  78. package/dist/src/extensions/Blocks/Recommendation/templates/titleRows.d.ts +0 -13
@@ -1,21 +1,23 @@
1
- import { getRecommendationFeedSourceMaps as g, getOperatorOptions as R, PriceAttributes as C } from "../../../../enums/extensions/recommendationBlock.js";
2
- import { useRecommendationApi as y } from "../../../../services/recommendationApi.js";
3
- import { useConfigStore as G } from "../../../../stores/config.js";
4
- import { defineStore as P } from "pinia";
1
+ import { useConfig as G } from "../../../../composables/useConfig.js";
2
+ import { getRecommendationFeedSourceMaps as I, getOperatorOptions as D, PriceAttributes as P } from "../../../../enums/extensions/recommendationBlock.js";
3
+ import { useRecommendationApi as F } from "../../../../services/recommendationApi.js";
4
+ import { useConfigStore as v } from "../../../../stores/config.js";
5
+ import { defineStore as _ } from "pinia";
5
6
  import "../constants/selectors.js";
6
- import { DEFAULT_MOBILE_CARDS_IN_ROW as F, DEFAULT_CARDS_IN_ROW as D } from "../constants/layout.js";
7
- import { EXCLUDED_ALGORITHM_IDS as w } from "../constants/defaultConfig.js";
8
- import { getDefaultProducts as S } from "../templates/utils.js";
9
- import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
10
- import { getPartnerRecommendationParams as v } from "../utils/partnerCustomizations.js";
11
- import { sanitizeProductIds as N } from "../utils/productIds.js";
12
- import { isFilterValid as x } from "../validation/filterSchema.js";
13
- import { isConfigValid as L } from "../validation/requiredFields.js";
14
- const h = y();
15
- let m = null, u = null, d = null;
16
- function k() {
7
+ import { DEFAULT_MOBILE_CARDS_IN_ROW as U, DEFAULT_CARDS_IN_ROW as N } from "../constants/layout.js";
8
+ import { DEFAULT_NODE_CONFIG as L, EXCLUDED_ALGORITHM_IDS as x } from "../constants/defaultConfig.js";
9
+ import { getDefaultProducts as k } from "../templates/utils.js";
10
+ import { generateCompleteFilterQuery as R } from "../utils/filterUtil.js";
11
+ import { getPartnerRecommendationParams as A } from "../utils/partnerCustomizations.js";
12
+ import { sanitizeProductIds as B } from "../utils/productIds.js";
13
+ import { isFilterValid as z } from "../validation/filterSchema.js";
14
+ import { isConfigValid as O } from "../validation/requiredFields.js";
15
+ const m = F();
16
+ let g = null, h = null, S = null, p = null;
17
+ const y = /* @__PURE__ */ new Map();
18
+ function w() {
17
19
  return {
18
- cardsInRow: D,
20
+ cardsInRow: N,
19
21
  currencySettings: {
20
22
  name: "USD",
21
23
  value: "USD",
@@ -29,13 +31,14 @@ function k() {
29
31
  productIds: [],
30
32
  id: 1,
31
33
  language: "en_US",
32
- mobileCardsInRow: F,
34
+ mobileCardsInRow: U,
33
35
  mobileLayoutEnabled: !1,
34
36
  orientation: "grid",
35
37
  recommendedProducts: [],
36
38
  sendProductRequestFlag: !1,
37
39
  shuffleProducts: !1,
38
40
  strategy: "mostPopular",
41
+ strategyId: "",
39
42
  textTrimming: !0,
40
43
  unresponsive: !1,
41
44
  size: "6",
@@ -44,28 +47,32 @@ function k() {
44
47
  priceHideIfSameAsDiscounted: !1
45
48
  };
46
49
  }
47
- function I() {
50
+ function C() {
48
51
  return {
49
- recommendationConfigs: k(),
52
+ recommendationConfigs: w(),
50
53
  recommendationProducts: [],
51
54
  filterStatus: !1,
52
55
  filterSelectionDrawerStatus: !1,
56
+ assignStrategyDrawerStatus: !1,
53
57
  filterGroup: 1,
54
58
  isInitialized: !1,
55
59
  filterSnapshot: null
56
60
  };
57
61
  }
58
- const U = () => ({
62
+ const E = () => ({
59
63
  recommendationCampaignUrls: {},
60
64
  activePredictiveAlgorithms: [],
61
65
  languages: {},
62
66
  currencyList: [],
63
67
  filterList: {},
68
+ strategies: [],
69
+ strategiesLoading: !1,
70
+ strategyUrlTemplates: {},
64
71
  blockStates: {},
65
72
  currentRecommendationId: null,
66
73
  configVersion: 0
67
- }), H = P("guidoRecommendationExtension", {
68
- state: () => U(),
74
+ }), tt = _("guidoRecommendationExtension", {
75
+ state: () => E(),
69
76
  getters: {
70
77
  // ====================================================================
71
78
  // Proxy Getters — Backward Compatible Access to Current Block State
@@ -75,7 +82,7 @@ const U = () => ({
75
82
  * This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
76
83
  */
77
84
  recommendationConfigs(t) {
78
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : k();
85
+ return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : w();
79
86
  },
80
87
  /**
81
88
  * Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
@@ -89,6 +96,20 @@ const U = () => ({
89
96
  filterSelectionDrawerStatus(t) {
90
97
  return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].filterSelectionDrawerStatus : !1;
91
98
  },
99
+ /**
100
+ * Proxy getter: delegates to blockStates[currentRecommendationId].assignStrategyDrawerStatus
101
+ */
102
+ assignStrategyDrawerStatus(t) {
103
+ return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].assignStrategyDrawerStatus : !1;
104
+ },
105
+ /**
106
+ * The current block's assigned strategy record from the listing,
107
+ * or null when nothing is assigned / the strategy is no longer listed.
108
+ */
109
+ assignedStrategy(t) {
110
+ const { strategyId: e } = this.recommendationConfigs;
111
+ return e ? t.strategies.find((r) => String(r.strategy_id) === e) ?? null : null;
112
+ },
92
113
  /**
93
114
  * Proxy getter: delegates to blockStates[currentRecommendationId].filterStatus
94
115
  */
@@ -120,9 +141,9 @@ const U = () => ({
120
141
  return [...new Set(t.map((e) => e.filterGroup))].sort((e, r) => e - r);
121
142
  },
122
143
  getActivePredictiveAlgorithms: (t) => {
123
- const e = g(), r = [];
124
- return t.activePredictiveAlgorithms.filter((n) => !w.includes(n)).forEach((n) => {
125
- r.push(...e.filter((c) => c.id === n));
144
+ const e = I(), r = [];
145
+ return t.activePredictiveAlgorithms.filter((n) => !x.includes(n)).forEach((n) => {
146
+ r.push(...e.filter((s) => s.id === n));
126
147
  }), r.map((n) => ({
127
148
  text: n.name,
128
149
  value: n.key
@@ -139,7 +160,7 @@ const U = () => ({
139
160
  getFilterList() {
140
161
  return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
141
162
  let e;
142
- return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : C.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
163
+ return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : P.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
143
164
  text: t.displayName,
144
165
  value: e,
145
166
  type: t.attributeType
@@ -161,7 +182,7 @@ const U = () => ({
161
182
  setCurrentBlock(t) {
162
183
  this.blockStates[t] || (this.blockStates = {
163
184
  ...this.blockStates,
164
- [t]: I()
185
+ [t]: C()
165
186
  }), this.currentRecommendationId = t;
166
187
  },
167
188
  /**
@@ -193,10 +214,10 @@ const U = () => ({
193
214
  [e]: o
194
215
  };
195
216
  }
196
- const n = t.toString(), c = e.toString(), i = this.recommendationCampaignUrls[n];
217
+ const n = t.toString(), s = e.toString(), i = this.recommendationCampaignUrls[n];
197
218
  i && (this.recommendationCampaignUrls = {
198
219
  ...this.recommendationCampaignUrls,
199
- [c]: i
220
+ [s]: i
200
221
  });
201
222
  },
202
223
  /**
@@ -221,7 +242,7 @@ const U = () => ({
221
242
  * `isInitialized`) alone.
222
243
  */
223
244
  seedBlockUrlConfig(t, e) {
224
- const r = (o, s) => o === "." || o === "," || o === " " ? o : s, n = {
245
+ const r = (o, a) => o === "." || o === "," || o === " " ? o : a, n = {
225
246
  name: e.currencyCode,
226
247
  value: e.currencyCode,
227
248
  symbol: e.currencyCode,
@@ -229,17 +250,18 @@ const U = () => ({
229
250
  decimalCount: String(e.currencyDecimalCount),
230
251
  decimalSeparator: r(e.currencyDecimalSeparator, ","),
231
252
  thousandSeparator: r(e.currencyThousandSeparator, ".")
232
- }, c = !this.blockStates[t], i = c ? I() : this.blockStates[t];
253
+ }, s = !this.blockStates[t], i = s ? C() : this.blockStates[t];
233
254
  i.recommendationConfigs = {
234
255
  ...i.recommendationConfigs,
235
256
  strategy: e.strategy,
257
+ strategyId: e.strategyId,
236
258
  language: e.language,
237
259
  size: e.size,
238
260
  productIds: e.productIds,
239
261
  filters: e.filters,
240
262
  shuffleProducts: e.shuffleProducts,
241
263
  currencySettings: n
242
- }, c && (this.blockStates = {
264
+ }, s && (this.blockStates = {
243
265
  ...this.blockStates,
244
266
  [t]: i
245
267
  });
@@ -267,7 +289,7 @@ const U = () => ({
267
289
  * Creates a filter with the first available attribute and operator pre-selected.
268
290
  */
269
291
  createDefaultFilter(t, e) {
270
- const [r] = this.getFilterList, [n] = R(r == null ? void 0 : r.type);
292
+ const [r] = this.getFilterList, [n] = D(r == null ? void 0 : r.type);
271
293
  return {
272
294
  type: "standardFilter",
273
295
  attribute: (r == null ? void 0 : r.value) ?? "",
@@ -315,20 +337,102 @@ const U = () => ({
315
337
  t.filterSnapshot !== null && (t.recommendationConfigs.filters = t.filterSnapshot, t.filterSnapshot = null), t.filterSelectionDrawerStatus = !1;
316
338
  },
317
339
  // ====================================================================
340
+ // Reusable Recommendation Strategy (SD-149105)
341
+ // ====================================================================
342
+ /**
343
+ * Opens the Assign Strategy drawer for the current block.
344
+ * Selection state lives in the drawer component until Assign is
345
+ * pressed, so closing without assigning needs no snapshot/revert.
346
+ */
347
+ openAssignStrategyDrawer() {
348
+ this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].assignStrategyDrawerStatus = !0);
349
+ },
350
+ closeAssignStrategyDrawer() {
351
+ this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].assignStrategyDrawerStatus = !1);
352
+ },
353
+ /**
354
+ * Fetches the active + EMAIL strategy listing. Always fetches fresh
355
+ * (dead-strategy detection and post-create refresh need freshness);
356
+ * only concurrent in-flight calls share one request.
357
+ */
358
+ async fetchStrategies() {
359
+ if (p) {
360
+ await p;
361
+ return;
362
+ }
363
+ p = (async () => {
364
+ this.strategiesLoading = !0;
365
+ try {
366
+ this.strategies = await m.fetchRecommendationStrategies();
367
+ } finally {
368
+ this.strategiesLoading = !1;
369
+ }
370
+ })();
371
+ try {
372
+ await p;
373
+ } finally {
374
+ p = null;
375
+ }
376
+ },
377
+ /**
378
+ * Resolves a strategy's recommendation endpoint template via
379
+ * endpoint-generate, cached per strategy id + revision + currency.
380
+ * Failures throw and are NOT cached, so the next attempt retries.
381
+ *
382
+ * `full_path` bakes in the algorithm path and `size=` as they were when
383
+ * generated, so the revision keys the cache — and a record with no
384
+ * revision is not cached at all, since its key could never change.
385
+ * Currency joins the key because it is sent in the request body, so two
386
+ * currencies can resolve to different paths for the same revision.
387
+ */
388
+ async resolveStrategyUrlTemplate(t, e) {
389
+ const r = typeof t.updated_at == "string" ? t.updated_at : "", n = r ? `${t.strategy_id}:${r}:${e}` : "", s = n ? this.strategyUrlTemplates[n] : void 0;
390
+ if (s)
391
+ return s;
392
+ const { full_path: i } = await m.generateStrategyEndpoint(t, e);
393
+ return n && (this.strategyUrlTemplates = {
394
+ ...this.strategyUrlTemplates,
395
+ [n]: i
396
+ }), i;
397
+ },
398
+ /**
399
+ * Assigns a strategy to the current block. The config write is
400
+ * synchronous (before any await) so a block switch cannot misdirect
401
+ * it; the configVersion bump persists it to node config and triggers
402
+ * the product refetch via the coordinator control's subscription.
403
+ */
404
+ assignStrategy(t) {
405
+ this.patchCurrentBlockConfig({
406
+ strategyId: String(t.strategy_id),
407
+ ...t.size !== void 0 ? { size: String(t.size) } : {}
408
+ });
409
+ },
410
+ /**
411
+ * Clears the current block's strategy; it falls back to the per-block
412
+ * algorithm settings.
413
+ *
414
+ * `size` goes back to the default rather than staying on the removed
415
+ * strategy's count: with Number of Products hidden in RRS mode, a block
416
+ * left on that count would have no UI to correct it.
417
+ */
418
+ removeStrategy() {
419
+ this.patchCurrentBlockConfig({ strategyId: "", size: L.size });
420
+ },
421
+ // ====================================================================
318
422
  // Shared Data Fetching (fetched once, used by all blocks)
319
423
  // ====================================================================
320
424
  async fetchRecommendationCreateData() {
321
425
  if (!this.activePredictiveAlgorithms.length) {
322
- if (m) {
323
- await m;
426
+ if (g) {
427
+ await g;
324
428
  return;
325
429
  }
326
- m = (async () => {
430
+ g = (async () => {
327
431
  const {
328
432
  activePredictiveAlgorithms: t,
329
433
  languages: e,
330
434
  currencies: r
331
- } = await h.fetchRecommendationCreateData();
435
+ } = await m.fetchRecommendationCreateData();
332
436
  if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
333
437
  const n = this.blockStates[this.currentRecommendationId];
334
438
  n.filterStatus = !!n.recommendationConfigs.filters.length;
@@ -336,26 +440,26 @@ const U = () => ({
336
440
  this.currencyList = r;
337
441
  })();
338
442
  try {
339
- await m;
443
+ await g;
340
444
  } finally {
341
- m = null;
445
+ g = null;
342
446
  }
343
447
  }
344
448
  },
345
449
  async fetchRecommendationFilters() {
346
450
  if (!Object.keys(this.filterList).length) {
347
- if (u) {
348
- await u;
451
+ if (h) {
452
+ await h;
349
453
  return;
350
454
  }
351
- u = (async () => {
352
- const t = await h.fetchRecommendationFilters();
455
+ h = (async () => {
456
+ const t = await m.fetchRecommendationFilters();
353
457
  this.filterList = t;
354
458
  })();
355
459
  try {
356
- await u;
460
+ await h;
357
461
  } finally {
358
- u = null;
462
+ h = null;
359
463
  }
360
464
  }
361
465
  },
@@ -370,10 +474,10 @@ const U = () => ({
370
474
  deleteFilterGroup(t) {
371
475
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
372
476
  return;
373
- const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), n = [...new Set(r.map((i) => i.filterGroup))].sort((i, o) => i - o), c = new Map(n.map((i, o) => [i, o + 1]));
477
+ const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), n = [...new Set(r.map((i) => i.filterGroup))].sort((i, o) => i - o), s = new Map(n.map((i, o) => [i, o + 1]));
374
478
  e.recommendationConfigs.filters = r.map((i) => ({
375
479
  ...i,
376
- filterGroup: c.get(i.filterGroup) ?? i.filterGroup
480
+ filterGroup: s.get(i.filterGroup) ?? i.filterGroup
377
481
  }));
378
482
  },
379
483
  updateFilter(t) {
@@ -384,7 +488,7 @@ const U = () => ({
384
488
  const n = [...e.recommendationConfigs.filters];
385
489
  n[r] = {
386
490
  ...t,
387
- isValid: x(t)
491
+ isValid: z(t)
388
492
  }, e.recommendationConfigs.filters = n;
389
493
  }
390
494
  },
@@ -398,10 +502,10 @@ const U = () => ({
398
502
  let i = 1;
399
503
  n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
400
504
  } else {
401
- const i = [...new Set(n.map((s) => s.filterGroup))].sort((s, a) => s - a), o = new Map(i.map((s, a) => [s, a + 1]));
402
- n = n.map((s) => ({
403
- ...s,
404
- filterGroup: o.get(s.filterGroup) ?? s.filterGroup
505
+ const i = [...new Set(n.map((a) => a.filterGroup))].sort((a, l) => a - l), o = new Map(i.map((a, l) => [a, l + 1]));
506
+ n = n.map((a) => ({
507
+ ...a,
508
+ filterGroup: o.get(a.filterGroup) ?? a.filterGroup
405
509
  }));
406
510
  }
407
511
  e.recommendationConfigs.filters = n;
@@ -410,19 +514,19 @@ const U = () => ({
410
514
  addFilter(t) {
411
515
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
412
516
  return;
413
- const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters], c = r.filter(
517
+ const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters], s = r.filter(
414
518
  (o) => o.filterGroup === t.filterGroup
415
519
  ).length + 1, i = r.findLastIndex((o) => o.filterGroup === t.filterGroup);
416
520
  i !== -1 ? r.splice(i + 1, 0, {
417
521
  ...t,
418
- filterNumber: c
522
+ filterNumber: s
419
523
  }) : r.push({
420
524
  ...t,
421
- filterNumber: c
525
+ filterNumber: s
422
526
  }), e.recommendationConfigs.filters = r;
423
527
  },
424
528
  generateFilterQuery() {
425
- return b(this.recommendationConfigs.filters);
529
+ return R(this.recommendationConfigs.filters);
426
530
  },
427
531
  /**
428
532
  * Validation-only check invoked at save-CTA time. Defined as an action
@@ -430,55 +534,95 @@ const U = () => ({
430
534
  * every block's recommendationConfigs across user edits.
431
535
  */
432
536
  hasInvalidBlock() {
433
- return Object.values(this.blockStates).some((t) => !L(t.recommendationConfigs, this));
537
+ return Object.values(this.blockStates).some((t) => !O(t.recommendationConfigs, this));
434
538
  },
435
539
  // ====================================================================
436
540
  // Per-Block Product Fetching
437
541
  // ====================================================================
438
542
  async fetchRecommendationProducts() {
439
543
  if (!(this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])) {
440
- if (d) {
441
- await d;
544
+ if (S) {
545
+ await S;
442
546
  return;
443
547
  }
444
- d = this._doFetchProducts();
548
+ S = this._doFetchProducts();
445
549
  try {
446
- await d;
550
+ await S;
447
551
  } finally {
448
- d = null;
552
+ S = null;
449
553
  }
450
554
  }
451
555
  },
452
556
  async _doFetchProducts() {
453
- var p;
454
- const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = r.filters.filter((l) => l.isValid), c = b(n), i = ((p = g().find((l) => l.key === r.strategy)) == null ? void 0 : p.path) || "", o = G(), s = parseInt(r.size) || 6, a = {
557
+ var d;
558
+ const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = v(), { isFeatureEnabled: s } = G();
559
+ if (s("reusableRecommendationStrategy") && r.strategyId) {
560
+ await this._doFetchStrategyProducts(t);
561
+ return;
562
+ }
563
+ const i = r.filters.filter((f) => f.isValid), o = R(i), a = ((d = I().find((f) => f.key === r.strategy)) == null ? void 0 : d.path) || "", l = parseInt(r.size) || 6, c = {
455
564
  locale: r.language,
456
565
  currency: r.currencySettings.value,
457
- partnerName: o.partnerName,
566
+ partnerName: n.partnerName,
458
567
  size: r.size,
459
568
  details: !0,
460
- campaignId: o.variationId
569
+ campaignId: n.variationId
461
570
  };
462
- r.strategy === "manualMerchandising" ? a.productId = N(r.productIds) : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0), Object.assign(
463
- a,
464
- v(o.partnerName, r.strategy)
571
+ r.strategy === "manualMerchandising" ? c.productId = B(r.productIds) : r.strategy === "similarViewed" && (c.productId = "{itemId}"), r.strategy === "userBased" && (c.userId = "{user_id}"), o && (c.filter = o), r.shuffleProducts && (c.shuffle = !0), Object.assign(
572
+ c,
573
+ A(n.partnerName, r.strategy)
465
574
  );
466
- let f;
575
+ let u;
467
576
  try {
468
- f = await h.fetchRecommendationProducts(i, a);
577
+ u = await m.fetchRecommendationProducts(a, c);
469
578
  } catch {
470
- f = [];
579
+ u = [];
471
580
  }
472
- if (this.blockStates[t]) {
473
- const l = f.length > 0 ? f : S(s);
474
- l.length < s ? this.blockStates[t].recommendationProducts = [
475
- ...l,
476
- ...S(s - l.length)
477
- ] : l.length > s ? this.blockStates[t].recommendationProducts = l.slice(0, s) : this.blockStates[t].recommendationProducts = l;
581
+ this._setBlockProducts(t, u, l);
582
+ },
583
+ /**
584
+ * Fetches products for a strategy-backed block: listing lookup →
585
+ * endpoint-generate template → fill {locale}/{currency}, drop
586
+ * {user_id} (resolved at send time) → fetch. Any failure (dead
587
+ * strategy, resolution error) falls back to placeholder products.
588
+ */
589
+ async _doFetchStrategyProducts(t) {
590
+ const e = (y.get(t) ?? 0) + 1;
591
+ y.set(t, e);
592
+ const { recommendationConfigs: r } = this.blockStates[t];
593
+ let n = [], s = parseInt(r.size) || 6;
594
+ try {
595
+ await this.fetchStrategies();
596
+ const i = this.strategies.find(
597
+ (o) => String(o.strategy_id) === r.strategyId
598
+ );
599
+ if (i) {
600
+ s = parseInt(String(i.size ?? "")) || s;
601
+ const o = r.currencySettings.value, l = (await this.resolveStrategyUrlTemplate(i, o)).replaceAll("{locale}", r.language).replaceAll("{currency}", o), c = l.indexOf("?"), u = c === -1 ? l : l.slice(0, c), d = (c === -1 ? "" : l.slice(c + 1)).split("&").filter((b) => b && !b.startsWith("user_id=")), f = d.length ? `${u}?${d.join("&")}` : u;
602
+ n = await m.fetchRecommendationProductsByUrl(f);
603
+ }
604
+ } catch {
605
+ n = [];
478
606
  }
607
+ y.get(t) === e && this._setBlockProducts(t, n, s);
608
+ },
609
+ /**
610
+ * Writes products to a block's state, padded/clipped to exactly `size`:
611
+ * in-place content updates compare the DOM element count against
612
+ * products.length, and a longer list makes the renderer extend its slot
613
+ * grid, which resets migrator-applied styles.
614
+ */
615
+ _setBlockProducts(t, e, r) {
616
+ if (!this.blockStates[t])
617
+ return;
618
+ const n = e.length > 0 ? e : k(r);
619
+ this.blockStates[t].recommendationProducts = [
620
+ ...n.slice(0, r),
621
+ ...k(Math.max(0, r - n.length))
622
+ ];
479
623
  }
480
624
  }
481
625
  });
482
626
  export {
483
- H as useRecommendationExtensionStore
627
+ tt as useRecommendationExtensionStore
484
628
  };
@@ -1,6 +1,6 @@
1
1
  import { ATTR_PRODUCT_PRICE as f, ATTR_PRODUCT_OLD_PRICE as O } from "../../constants/selectors.js";
2
2
  import { DEFAULT_PRODUCTS_PER_ROW as w } from "../../constants/layout.js";
3
- import { createBlockTemplate as A, getDefaultProducts as g, DEFAULTS as U, buildSpacer as h, DEFAULT_CARD_COMPOSITION as Y, buildElementRenderer as B, resolveInlinePriceOrder as F, buildCellOptions as I, DEFAULT_CARD_VISIBILITY as W } from "../utils.js";
3
+ import { getDefaultProducts as A, DEFAULTS as g, createBlockTemplate as U, buildSpacer as h, DEFAULT_CARD_COMPOSITION as Y, buildElementRenderer as B, resolveInlinePriceOrder as F, buildCellOptions as I, DEFAULT_CARD_VISIBILITY as W } from "../utils.js";
4
4
  import { DEFAULT_CELL_PADDING as k, renderInlineGridPriceCell as H, buildFillerCell as x, gridElementRenderer as y } from "./elementRenderer.js";
5
5
  const G = `
6
6
  <tr class="recommendation-product-row">
@@ -69,8 +69,8 @@ function M(t, r, o, e = {}, c = {}) {
69
69
  );
70
70
  }
71
71
  function Q(t) {
72
- const r = t ? `ins-recommendation-v3-block-${t}` : void 0, o = A("grid", r), e = g(), c = M(e, w);
73
- return o.replace("{-{-TITLE-}-}", U.TITLE).replace("{-{-PRODUCT_ROWS-}-}", c).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", "");
72
+ const r = t ? `ins-recommendation-v3-block-${t}` : void 0, o = U("grid", r), e = A(), c = M(e, w);
73
+ return o.replace("{-{-TITLE-}-}", g.TITLE).replace("{-{-PRODUCT_ROWS-}-}", c).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", "");
74
74
  }
75
75
  export {
76
76
  Q as getDefaultTemplate,