@useinsider/guido 3.20.0 → 3.20.1-beta.07e0277

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 (113) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +11 -10
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +114 -103
  5. package/dist/components/organisms/AutoSaveController.vue2.js +19 -9
  6. package/dist/components/organisms/header/AutoSaveStatus.vue.js +17 -0
  7. package/dist/components/organisms/header/AutoSaveStatus.vue2.js +25 -0
  8. package/dist/components/organisms/header/EditorActions.vue.js +13 -13
  9. package/dist/components/organisms/header/EditorActions.vue2.js +57 -72
  10. package/dist/components/organisms/header/EditorActionsMenu.vue.js +20 -0
  11. package/dist/components/organisms/header/EditorActionsMenu.vue2.js +98 -0
  12. package/dist/components/organisms/header/HeaderWrapper.vue.js +6 -6
  13. package/dist/components/organisms/header/HeaderWrapper.vue2.js +9 -17
  14. package/dist/components/organisms/header/LeftSlot.vue.js +1 -1
  15. package/dist/components/organisms/header/LeftSlot.vue2.js +28 -23
  16. package/dist/components/organisms/header/MiddleSlot.vue.js +4 -4
  17. package/dist/components/organisms/header/MiddleSlot.vue2.js +8 -7
  18. package/dist/components/organisms/header/RightSlot.vue.js +11 -10
  19. package/dist/components/organisms/header/RightSlot.vue2.js +13 -18
  20. package/dist/components/organisms/header/accessibility/AccessibilityToolbar.vue.js +18 -0
  21. package/dist/components/organisms/header/accessibility/AccessibilityToolbar.vue2.js +37 -0
  22. package/dist/components/organisms/header/accessibility/ColorVisionSelect.vue.js +22 -0
  23. package/dist/components/organisms/header/accessibility/ColorVisionSelect.vue2.js +48 -0
  24. package/dist/components/organisms/onboarding/EditorTabBarOnboarding.vue.js +19 -0
  25. package/dist/components/organisms/onboarding/EditorTabBarOnboarding.vue2.js +90 -0
  26. package/dist/components/organisms/onboarding/OnboardingWrapper.vue.js +12 -12
  27. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +60 -35
  28. package/dist/composables/useAccessibilityApi.js +51 -0
  29. package/dist/composables/useCustomInterfaceAppearance.js +42 -41
  30. package/dist/composables/useLegacyStrategyConversion.js +16 -16
  31. package/dist/composables/useStripo.js +4 -3
  32. package/dist/config/compiler/itemsCompilerRules.js +21 -5
  33. package/dist/config/compiler/utils/itemsCompilerUtils.js +64 -17
  34. package/dist/config/i18n/en/labels.json.js +36 -4
  35. package/dist/config/i18n/en/tooltips.json.js +2 -1
  36. package/dist/config/migrator/itemsBlockMigrator.js +112 -108
  37. package/dist/extensions/Blocks/Items/block.js +76 -64
  38. package/dist/extensions/Blocks/Items/constants/cardWidth.js +20 -0
  39. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +1 -1
  40. package/dist/extensions/Blocks/Recommendation/block.js +51 -44
  41. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +103 -91
  42. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +308 -218
  43. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +209 -203
  44. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +232 -186
  45. package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +19 -0
  46. package/dist/extensions/Blocks/Recommendation/utils/blockUrlConfig.js +25 -0
  47. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +72 -70
  48. package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +69 -60
  49. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +63 -27
  50. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +39 -20
  51. package/dist/guido.css +1 -1
  52. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +271 -192
  53. package/dist/package.json.js +1 -1
  54. package/dist/sprite.svg +10 -0
  55. package/dist/src/@types/config/schemas.d.ts +2 -0
  56. package/dist/src/components/organisms/AutoSaveController.vue.d.ts +19 -1
  57. package/dist/src/components/organisms/header/EditorActionsMenu.vue.d.ts +2 -0
  58. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -19
  59. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -19
  60. package/dist/src/components/organisms/header/accessibility/AccessibilityToolbar.vue.d.ts +2 -0
  61. package/dist/src/components/organisms/header/accessibility/ColorVisionSelect.vue.d.ts +2 -0
  62. package/dist/src/components/organisms/onboarding/EditorTabBarOnboarding.vue.d.ts +2 -0
  63. package/dist/src/composables/useAccessibilityApi.d.ts +13 -0
  64. package/dist/src/composables/useActionsApi.d.ts +2 -2
  65. package/dist/src/composables/useConfig.d.ts +2 -0
  66. package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +10 -0
  67. package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +1 -0
  68. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +8 -0
  69. package/dist/src/extensions/Blocks/Items/block.d.ts +5 -0
  70. package/dist/src/extensions/Blocks/Items/constants/cardWidth.d.ts +12 -0
  71. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +40 -0
  72. package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +1 -0
  73. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +2 -0
  74. package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +1 -0
  75. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +11 -0
  76. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -0
  77. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +7 -0
  78. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +2 -0
  79. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +20 -3
  80. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +7 -0
  81. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +7 -0
  82. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +7 -0
  83. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +7 -0
  84. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +7 -0
  85. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +7 -0
  86. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +26 -6
  87. package/dist/src/extensions/Blocks/Recommendation/utils/blockRefresh.d.ts +17 -0
  88. package/dist/src/extensions/Blocks/Recommendation/utils/blockUrlConfig.d.ts +4 -0
  89. package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +4 -0
  90. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +10 -1
  91. package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +7 -0
  92. package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +1 -0
  93. package/dist/src/extensions/Blocks/controlFactories.d.ts +22 -0
  94. package/dist/src/stores/autosave.d.ts +73 -1
  95. package/dist/src/stores/config.d.ts +20 -0
  96. package/dist/src/stores/editor.d.ts +109 -0
  97. package/dist/src/stores/onboarding.d.ts +966 -35
  98. package/dist/src/stores/version-history.d.ts +1 -1
  99. package/dist/src/utils/liquidProtection.d.ts +3 -0
  100. package/dist/src/utils/timeUtil.d.ts +5 -8
  101. package/dist/static/styles/components/accessibility.css.js +234 -0
  102. package/dist/static/styles/components/button.css.js +5 -0
  103. package/dist/static/styles/variables.css.js +2 -0
  104. package/dist/stores/autosave.js +12 -7
  105. package/dist/stores/editor.js +8 -3
  106. package/dist/stores/onboarding.js +48 -22
  107. package/dist/utils/liquidProtection.js +5 -0
  108. package/dist/utils/templatePreparation.js +61 -85
  109. package/dist/utils/timeUtil.js +6 -17
  110. package/package.json +3 -3
  111. package/dist/components/organisms/header/AutoSaveToggle.vue.js +0 -22
  112. package/dist/components/organisms/header/AutoSaveToggle.vue2.js +0 -19
  113. /package/dist/src/components/organisms/header/{AutoSaveToggle.vue.d.ts → AutoSaveStatus.vue.d.ts} +0 -0
@@ -1,23 +1,29 @@
1
- import { useToaster as _ } from "../../../../composables/useToaster.js";
2
- import { useTranslations as L } from "../../../../composables/useTranslations.js";
3
- import { getRecommendationFeedSourceMaps as F, strategyEditPath as U, strategyCreatePath as N, getOperatorOptions as M, PriceAttributes as E } from "../../../../enums/extensions/recommendationBlock.js";
4
- import { ToasterTypeOptions as B } from "../../../../enums/toaster.js";
5
- import { useRecommendationApi as z } from "../../../../services/recommendationApi.js";
1
+ import { useToaster as L } from "../../../../composables/useToaster.js";
2
+ import { useTranslations as U } from "../../../../composables/useTranslations.js";
3
+ import { getRecommendationFeedSourceMaps as F, strategyEditPath as z, strategyCreatePath as B, getOperatorOptions as M, PriceAttributes as N } from "../../../../enums/extensions/recommendationBlock.js";
4
+ import { ToasterTypeOptions as E } from "../../../../enums/toaster.js";
5
+ import { useRecommendationApi as O } from "../../../../services/recommendationApi.js";
6
6
  import { useConfigStore as R } from "../../../../stores/config.js";
7
- import { defineStore as A } from "pinia";
7
+ import { defineStore as V } from "pinia";
8
8
  import "../constants/selectors.js";
9
- import { DEFAULT_MOBILE_CARDS_IN_ROW as O, DEFAULT_CARDS_IN_ROW as x } from "../constants/layout.js";
10
- import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as T, EXCLUDED_ALGORITHM_IDS as V } from "../constants/defaultConfig.js";
9
+ import { DEFAULT_MOBILE_CARDS_IN_ROW as A, DEFAULT_CARDS_IN_ROW as x } from "../constants/layout.js";
10
+ import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as T, EXCLUDED_ALGORITHM_IDS as j } from "../constants/defaultConfig.js";
11
11
  import { getDefaultProducts as w } from "../templates/utils.js";
12
12
  import { generateCompleteFilterQuery as P } from "../utils/filterUtil.js";
13
- import { isLegacyStrategyConfig as j } from "../utils/legacyStrategyMigration.js";
14
- import { getPartnerRecommendationParams as $ } from "../utils/partnerCustomizations.js";
15
- import { sanitizeProductIds as q } from "../utils/productIds.js";
16
- import { isFilterValid as K } from "../validation/filterSchema.js";
17
- import { getInvalidFields as H, isConfigValid as J } from "../validation/requiredFields.js";
18
- const m = z();
19
- let S = null, p = null, y = null, I = "", k = null, b = 0;
20
- const g = /* @__PURE__ */ new Map();
13
+ import { isLegacyStrategyConfig as $ } from "../utils/legacyStrategyMigration.js";
14
+ import { getPartnerRecommendationParams as q } from "../utils/partnerCustomizations.js";
15
+ import { sanitizeProductIds as K } from "../utils/productIds.js";
16
+ import { isFilterValid as H } from "../validation/filterSchema.js";
17
+ import { getInvalidFields as J, isConfigValid as Q } from "../validation/requiredFields.js";
18
+ const m = O();
19
+ let p = null, y = null;
20
+ const I = /* @__PURE__ */ new Map();
21
+ let k = null, b = 0;
22
+ const u = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map();
23
+ function W(t) {
24
+ const e = _.get(t);
25
+ return e && e.token === u.get(t) ? e.outcome : !1;
26
+ }
21
27
  let l = null;
22
28
  function D() {
23
29
  return {
@@ -35,7 +41,7 @@ function D() {
35
41
  productIds: [],
36
42
  id: 1,
37
43
  language: "en_US",
38
- mobileCardsInRow: O,
44
+ mobileCardsInRow: A,
39
45
  mobileLayoutEnabled: !1,
40
46
  orientation: "grid",
41
47
  recommendedProducts: [],
@@ -69,10 +75,12 @@ function G() {
69
75
  isInitialized: !1,
70
76
  filterSnapshot: null,
71
77
  syncedConfigFingerprint: null,
72
- legacyConversionLoading: !1
78
+ legacyConversionLoading: !1,
79
+ configVersion: 0,
80
+ adoptedSizeVersion: 0
73
81
  };
74
82
  }
75
- const Q = () => ({
83
+ const X = () => ({
76
84
  recommendationCampaignUrls: {},
77
85
  activePredictiveAlgorithms: [],
78
86
  languages: {},
@@ -87,8 +95,8 @@ const Q = () => ({
87
95
  currentRecommendationId: null,
88
96
  strategyPanelOpen: !1,
89
97
  configVersion: 0
90
- }), ft = A("guidoRecommendationExtension", {
91
- state: () => Q(),
98
+ }), ht = V("guidoRecommendationExtension", {
99
+ state: () => X(),
92
100
  getters: {
93
101
  // ====================================================================
94
102
  // Proxy Getters — Backward Compatible Access to Current Block State
@@ -119,7 +127,7 @@ const Q = () => ({
119
127
  return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].removeStrategyModalStatus : !1;
120
128
  },
121
129
  isLegacyStrategyBlock() {
122
- return R().isFeatureEnabled("reusableRecommendationStrategy") && j(this.recommendationConfigs);
130
+ return R().isFeatureEnabled("reusableRecommendationStrategy") && $(this.recommendationConfigs);
123
131
  },
124
132
  legacyConversionLoading(t) {
125
133
  return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].legacyConversionLoading ?? !1 : !1;
@@ -129,7 +137,7 @@ const Q = () => ({
129
137
  },
130
138
  assignedStrategy(t) {
131
139
  const { strategyId: e } = this.recommendationConfigs;
132
- return e ? t.strategies.find((r) => String(r.strategy_id) === e) ?? null : null;
140
+ return e ? t.strategies.find((n) => String(n.strategy_id) === e) ?? null : null;
133
141
  },
134
142
  /**
135
143
  * Proxy getter: delegates to blockStates[currentRecommendationId].filterStatus
@@ -159,19 +167,19 @@ const Q = () => ({
159
167
  },
160
168
  getUniqueFilterGroups() {
161
169
  const { filters: t } = this.recommendationConfigs;
162
- return [...new Set(t.map((e) => e.filterGroup))].sort((e, r) => e - r);
170
+ return [...new Set(t.map((e) => e.filterGroup))].sort((e, n) => e - n);
163
171
  },
164
172
  getActivePredictiveAlgorithms: (t) => {
165
- const e = F(), r = [];
166
- return t.activePredictiveAlgorithms.filter((n) => !V.includes(n)).forEach((n) => {
167
- r.push(...e.filter((s) => s.id === n));
168
- }), r.map((n) => ({
169
- text: n.name,
170
- value: n.key
173
+ const e = F(), n = [];
174
+ return t.activePredictiveAlgorithms.filter((r) => !j.includes(r)).forEach((r) => {
175
+ n.push(...e.filter((o) => o.id === r));
176
+ }), n.map((r) => ({
177
+ text: r.name,
178
+ value: r.key
171
179
  }));
172
180
  },
173
- getLanguages: (t) => Object.entries(t.languages).map(([e, r]) => ({
174
- text: r,
181
+ getLanguages: (t) => Object.entries(t.languages).map(([e, n]) => ({
182
+ text: n,
175
183
  value: e
176
184
  })),
177
185
  getCurrencySymbolList: (t) => t.currencyList.map((e) => ({
@@ -181,7 +189,7 @@ const Q = () => ({
181
189
  getFilterList() {
182
190
  return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
183
191
  let e;
184
- return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : E.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
192
+ return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : N.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
185
193
  text: t.displayName,
186
194
  value: e,
187
195
  type: t.attributeType
@@ -213,13 +221,13 @@ const Q = () => ({
213
221
  removeBlockState(t) {
214
222
  const e = t.toString();
215
223
  if (this.recommendationCampaignUrls[e]) {
216
- const n = { ...this.recommendationCampaignUrls };
217
- delete n[e], this.recommendationCampaignUrls = n;
224
+ const r = { ...this.recommendationCampaignUrls };
225
+ delete r[e], this.recommendationCampaignUrls = r;
218
226
  }
219
- const r = { ...this.blockStates };
220
- if (delete r[t], this.blockStates = r, this.currentRecommendationId === t) {
221
- const n = Object.keys(this.blockStates).map(Number);
222
- this.currentRecommendationId = n.length > 0 ? n[0] : null;
227
+ const n = { ...this.blockStates };
228
+ if (delete n[t], this.blockStates = n, this.currentRecommendationId === t) {
229
+ const r = Object.keys(this.blockStates).map(Number);
230
+ this.currentRecommendationId = r.length > 0 ? r[0] : null;
223
231
  }
224
232
  },
225
233
  /**
@@ -231,18 +239,18 @@ const Q = () => ({
231
239
  * (SD-149916).
232
240
  */
233
241
  cloneBlockState(t, e) {
234
- const r = this.blockStates[t];
235
- if (r) {
236
- const o = structuredClone(r);
237
- o.recommendationConfigs.id = e, o.recommendationConfigs.strategyId && R().isFeatureEnabled("reusableRecommendationStrategy") && (o.isInitialized = !1, o.syncedConfigFingerprint = null), this.blockStates = {
242
+ const n = this.blockStates[t];
243
+ if (n) {
244
+ const s = structuredClone(n);
245
+ s.recommendationConfigs.id = e, s.recommendationConfigs.strategyId && R().isFeatureEnabled("reusableRecommendationStrategy") && (s.isInitialized = !1, s.syncedConfigFingerprint = null), this.blockStates = {
238
246
  ...this.blockStates,
239
- [e]: o
247
+ [e]: s
240
248
  };
241
249
  }
242
- const n = t.toString(), s = e.toString(), i = this.recommendationCampaignUrls[n];
250
+ const r = t.toString(), o = e.toString(), i = this.recommendationCampaignUrls[r];
243
251
  i && (this.recommendationCampaignUrls = {
244
252
  ...this.recommendationCampaignUrls,
245
- [s]: i
253
+ [o]: i
246
254
  });
247
255
  },
248
256
  /**
@@ -267,15 +275,15 @@ const Q = () => ({
267
275
  * `isInitialized`) alone.
268
276
  */
269
277
  seedBlockUrlConfig(t, e) {
270
- const r = (o, a) => o === "." || o === "," || o === " " ? o : a, n = {
278
+ const n = (s, a) => s === "." || s === "," || s === " " ? s : a, r = {
271
279
  name: e.currencyCode,
272
280
  value: e.currencyCode,
273
281
  symbol: e.currencySymbol,
274
282
  alignment: e.currencyAlignment === "before" ? "0" : "1",
275
283
  decimalCount: String(e.currencyDecimalCount),
276
- decimalSeparator: r(e.currencyDecimalSeparator, ","),
277
- thousandSeparator: r(e.currencyThousandSeparator, ".")
278
- }, s = !this.blockStates[t], i = s ? G() : this.blockStates[t];
284
+ decimalSeparator: n(e.currencyDecimalSeparator, ","),
285
+ thousandSeparator: n(e.currencyThousandSeparator, ".")
286
+ }, o = !this.blockStates[t], i = o ? G() : this.blockStates[t];
279
287
  i.recommendationConfigs = {
280
288
  ...i.recommendationConfigs,
281
289
  strategy: e.strategy,
@@ -285,8 +293,8 @@ const Q = () => ({
285
293
  productIds: e.productIds,
286
294
  filters: e.filters,
287
295
  shuffleProducts: e.shuffleProducts,
288
- currencySettings: n
289
- }, s && (this.blockStates = {
296
+ currencySettings: r
297
+ }, o && (this.blockStates = {
290
298
  ...this.blockStates,
291
299
  [t]: i
292
300
  });
@@ -298,27 +306,27 @@ const Q = () => ({
298
306
  patchCurrentBlockConfig(t, e = {}) {
299
307
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
300
308
  return;
301
- const r = this.blockStates[this.currentRecommendationId];
302
- r.recommendationConfigs = {
303
- ...r.recommendationConfigs,
309
+ const n = this.blockStates[this.currentRecommendationId];
310
+ n.recommendationConfigs = {
311
+ ...n.recommendationConfigs,
304
312
  ...t,
305
313
  currencySettings: {
306
- ...r.recommendationConfigs.currencySettings,
314
+ ...n.recommendationConfigs.currencySettings,
307
315
  ...t.currencySettings || {}
308
316
  }
309
317
  };
310
- const { triggerRefetch: n = !0 } = e;
311
- n && this.configVersion++;
318
+ const { triggerRefetch: r = !0 } = e;
319
+ r && (n.configVersion++, this.configVersion++);
312
320
  },
313
321
  /**
314
322
  * Creates a filter with the first available attribute and operator pre-selected.
315
323
  */
316
324
  createDefaultFilter(t, e) {
317
- const [r] = this.getFilterList, [n] = M(r == null ? void 0 : r.type);
325
+ const [n] = this.getFilterList, [r] = M(n == null ? void 0 : n.type);
318
326
  return {
319
327
  type: "standardFilter",
320
- attribute: (r == null ? void 0 : r.value) ?? "",
321
- operator: (n == null ? void 0 : n.value) ?? "",
328
+ attribute: (n == null ? void 0 : n.value) ?? "",
329
+ operator: (r == null ? void 0 : r.value) ?? "",
322
330
  innerGroupOperator: "*",
323
331
  outerGroupOperator: "*",
324
332
  filterNumber: e,
@@ -390,10 +398,10 @@ const Q = () => ({
390
398
  const t = b, e = (async () => {
391
399
  this.strategiesLoading = !0;
392
400
  try {
393
- const r = await m.fetchRecommendationStrategies();
401
+ const n = await m.fetchRecommendationStrategies();
394
402
  if (t !== b)
395
403
  return;
396
- this.strategies = r, this.strategiesFetched = !0;
404
+ this.strategies = n, this.strategiesFetched = !0;
397
405
  } finally {
398
406
  this.strategiesLoading = !1, t === b && (this.strategiesSettled = !0);
399
407
  }
@@ -434,20 +442,20 @@ const Q = () => ({
434
442
  _armStrategyPageReturn(t) {
435
443
  const e = window.open(t, "_blank");
436
444
  if (!e)
437
- return _().showToaster({
438
- type: B.Error,
439
- message: L()("discovery-strategy.error-description")
445
+ return L().showToaster({
446
+ type: E.Error,
447
+ message: U()("discovery-strategy.error-description")
440
448
  }), !1;
441
449
  e.opener = null, l == null || l();
442
- let r = !1;
443
- const n = () => {
444
- document.hidden || r || (e != null && e.closed && (l == null || l()), r = !0, this.invalidateStrategies(), this.fetchStrategies().then(() => this._refreshAssignedStrategyProducts()).catch(() => {
450
+ let n = !1;
451
+ const r = () => {
452
+ document.hidden || n || (e != null && e.closed && (l == null || l()), n = !0, this.invalidateStrategies(), this.fetchStrategies().then(() => this._refreshAssignedStrategyProducts()).catch(() => {
445
453
  }).finally(() => {
446
- r = !1;
454
+ n = !1;
447
455
  }));
448
456
  };
449
- return document.addEventListener("visibilitychange", n), l = () => {
450
- document.removeEventListener("visibilitychange", n), l = null;
457
+ return document.addEventListener("visibilitychange", r), l = () => {
458
+ document.removeEventListener("visibilitychange", r), l = null;
451
459
  }, !0;
452
460
  },
453
461
  /**
@@ -471,23 +479,23 @@ const Q = () => ({
471
479
  * new strategy is offered; the user picks it themselves.
472
480
  */
473
481
  openStrategyCreation() {
474
- return this._armStrategyPageReturn(N());
482
+ return this._armStrategyPageReturn(B());
475
483
  },
476
484
  /**
477
485
  * Opens the strategy's edit page. Every return refreshes the list so the block reflects the
478
486
  * edited configuration.
479
487
  */
480
488
  openStrategyEdit(t) {
481
- return this._armStrategyPageReturn(U(t));
489
+ return this._armStrategyPageReturn(z(t));
482
490
  },
483
491
  async resolveStrategyUrlTemplate(t, e) {
484
- const r = typeof t.updated_at == "string" ? t.updated_at : "", n = r ? `${t.strategy_id}:${r}:${e}` : "", s = n ? this.strategyUrlTemplates[n] : void 0;
485
- if (s)
486
- return s;
492
+ const n = typeof t.updated_at == "string" ? t.updated_at : "", r = n ? `${t.strategy_id}:${n}:${e}` : "", o = r ? this.strategyUrlTemplates[r] : void 0;
493
+ if (o)
494
+ return o;
487
495
  const { full_path: i = "" } = await m.generateStrategyEndpoint(t, e) ?? {};
488
- return n && i && (this.strategyUrlTemplates = {
496
+ return r && i && (this.strategyUrlTemplates = {
489
497
  ...this.strategyUrlTemplates,
490
- [n]: i
498
+ [r]: i
491
499
  }), i;
492
500
  },
493
501
  assignStrategy(t) {
@@ -497,27 +505,27 @@ const Q = () => ({
497
505
  });
498
506
  },
499
507
  async convertLegacyStrategy(t, e = { scope: "campaign" }) {
500
- const r = this.currentRecommendationId;
501
- if (r === null || !this.blockStates[r])
508
+ const n = this.currentRecommendationId;
509
+ if (n === null || !this.blockStates[n])
502
510
  throw new Error("[Guido] convertLegacyStrategy called without an active block");
503
- this.blockStates[r].legacyConversionLoading = !0;
511
+ this.blockStates[n].legacyConversionLoading = !0;
504
512
  try {
505
- const n = await m.migrateLegacyStrategy(t, e);
513
+ const r = await m.migrateLegacyStrategy(t, e);
506
514
  this.invalidateStrategies();
507
515
  try {
508
516
  await this.fetchStrategies();
509
- } catch (o) {
510
- console.error("[Guido] strategy listing refresh after conversion failed", o);
517
+ } catch (s) {
518
+ console.error("[Guido] strategy listing refresh after conversion failed", s);
511
519
  }
512
- const s = this.strategies.find((o) => String(o.strategy_id) === n), i = this.blockStates[r];
520
+ const o = this.strategies.find((s) => String(s.strategy_id) === r), i = this.blockStates[n];
513
521
  return i && (i.recommendationConfigs = {
514
522
  ...i.recommendationConfigs,
515
- strategyId: n,
523
+ strategyId: r,
516
524
  nodeConfigVersion: C,
517
- ...(s == null ? void 0 : s.size) !== void 0 ? { size: String(s.size) } : {}
518
- }), this.currentRecommendationId === r && this.configVersion++, n;
525
+ ...(o == null ? void 0 : o.size) !== void 0 ? { size: String(o.size) } : {}
526
+ }, i.configVersion++), this.currentRecommendationId === n && this.configVersion++, r;
519
527
  } finally {
520
- this.blockStates[r] && (this.blockStates[r].legacyConversionLoading = !1);
528
+ this.blockStates[n] && (this.blockStates[n].legacyConversionLoading = !1);
521
529
  }
522
530
  },
523
531
  /**
@@ -526,8 +534,8 @@ const Q = () => ({
526
534
  * the document never received.
527
535
  */
528
536
  revertLegacyConversion(t, e) {
529
- const r = this.blockStates[t];
530
- r && (r.recommendationConfigs = { ...r.recommendationConfigs, ...e }, this.currentRecommendationId === t && this.configVersion++);
537
+ const n = this.blockStates[t];
538
+ n && (n.recommendationConfigs = { ...n.recommendationConfigs, ...e }, n.configVersion++, this.currentRecommendationId === t && this.configVersion++);
531
539
  },
532
540
  removeStrategy() {
533
541
  this.patchCurrentBlockConfig({
@@ -542,43 +550,43 @@ const Q = () => ({
542
550
  // ====================================================================
543
551
  async fetchRecommendationCreateData() {
544
552
  if (!this.activePredictiveAlgorithms.length) {
545
- if (S) {
546
- await S;
553
+ if (p) {
554
+ await p;
547
555
  return;
548
556
  }
549
- S = (async () => {
557
+ p = (async () => {
550
558
  const {
551
559
  activePredictiveAlgorithms: t,
552
560
  languages: e,
553
- currencies: r
561
+ currencies: n
554
562
  } = await m.fetchRecommendationCreateData();
555
563
  if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
556
- const n = this.blockStates[this.currentRecommendationId];
557
- n.filterStatus = !!n.recommendationConfigs.filters.length;
564
+ const r = this.blockStates[this.currentRecommendationId];
565
+ r.filterStatus = !!r.recommendationConfigs.filters.length;
558
566
  }
559
- this.currencyList = r;
567
+ this.currencyList = n;
560
568
  })();
561
569
  try {
562
- await S;
570
+ await p;
563
571
  } finally {
564
- S = null;
572
+ p = null;
565
573
  }
566
574
  }
567
575
  },
568
576
  async fetchRecommendationFilters() {
569
577
  if (!Object.keys(this.filterList).length) {
570
- if (p) {
571
- await p;
578
+ if (y) {
579
+ await y;
572
580
  return;
573
581
  }
574
- p = (async () => {
582
+ y = (async () => {
575
583
  const t = await m.fetchRecommendationFilters();
576
584
  this.filterList = t;
577
585
  })();
578
586
  try {
579
- await p;
587
+ await y;
580
588
  } finally {
581
- p = null;
589
+ y = null;
582
590
  }
583
591
  }
584
592
  },
@@ -593,56 +601,56 @@ const Q = () => ({
593
601
  deleteFilterGroup(t) {
594
602
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
595
603
  return;
596
- 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]));
597
- e.recommendationConfigs.filters = r.map((i) => ({
604
+ const e = this.blockStates[this.currentRecommendationId], n = e.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), r = [...new Set(n.map((i) => i.filterGroup))].sort((i, s) => i - s), o = new Map(r.map((i, s) => [i, s + 1]));
605
+ e.recommendationConfigs.filters = n.map((i) => ({
598
606
  ...i,
599
- filterGroup: s.get(i.filterGroup) ?? i.filterGroup
607
+ filterGroup: o.get(i.filterGroup) ?? i.filterGroup
600
608
  }));
601
609
  },
602
610
  updateFilter(t) {
603
611
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
604
612
  return;
605
- const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
606
- if (r !== -1) {
607
- const n = [...e.recommendationConfigs.filters];
608
- n[r] = {
613
+ const e = this.blockStates[this.currentRecommendationId], n = e.recommendationConfigs.filters.findIndex((r) => r.filterNumber === t.filterNumber && r.filterGroup === t.filterGroup);
614
+ if (n !== -1) {
615
+ const r = [...e.recommendationConfigs.filters];
616
+ r[n] = {
609
617
  ...t,
610
- isValid: K(t)
611
- }, e.recommendationConfigs.filters = n;
618
+ isValid: H(t)
619
+ }, e.recommendationConfigs.filters = r;
612
620
  }
613
621
  },
614
622
  deleteFilter(t) {
615
623
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
616
624
  return;
617
- const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
618
- if (r !== -1) {
619
- let n = [...e.recommendationConfigs.filters];
620
- if (n.splice(r, 1), n.some((i) => i.filterGroup === t.filterGroup)) {
625
+ const e = this.blockStates[this.currentRecommendationId], n = [...e.recommendationConfigs.filters].findIndex((r) => r.filterNumber === t.filterNumber && r.filterGroup === t.filterGroup);
626
+ if (n !== -1) {
627
+ let r = [...e.recommendationConfigs.filters];
628
+ if (r.splice(n, 1), r.some((i) => i.filterGroup === t.filterGroup)) {
621
629
  let i = 1;
622
- n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
630
+ r = r.map((s) => s.filterGroup === t.filterGroup ? { ...s, filterNumber: i++ } : s);
623
631
  } else {
624
- const i = [...new Set(n.map((a) => a.filterGroup))].sort((a, d) => a - d), o = new Map(i.map((a, d) => [a, d + 1]));
625
- n = n.map((a) => ({
632
+ const i = [...new Set(r.map((a) => a.filterGroup))].sort((a, d) => a - d), s = new Map(i.map((a, d) => [a, d + 1]));
633
+ r = r.map((a) => ({
626
634
  ...a,
627
- filterGroup: o.get(a.filterGroup) ?? a.filterGroup
635
+ filterGroup: s.get(a.filterGroup) ?? a.filterGroup
628
636
  }));
629
637
  }
630
- e.recommendationConfigs.filters = n;
638
+ e.recommendationConfigs.filters = r;
631
639
  }
632
640
  },
633
641
  addFilter(t) {
634
642
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
635
643
  return;
636
- const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters], s = r.filter(
637
- (o) => o.filterGroup === t.filterGroup
638
- ).length + 1, i = r.findLastIndex((o) => o.filterGroup === t.filterGroup);
639
- i !== -1 ? r.splice(i + 1, 0, {
644
+ const e = this.blockStates[this.currentRecommendationId], n = [...e.recommendationConfigs.filters], o = n.filter(
645
+ (s) => s.filterGroup === t.filterGroup
646
+ ).length + 1, i = n.findLastIndex((s) => s.filterGroup === t.filterGroup);
647
+ i !== -1 ? n.splice(i + 1, 0, {
640
648
  ...t,
641
- filterNumber: s
642
- }) : r.push({
649
+ filterNumber: o
650
+ }) : n.push({
643
651
  ...t,
644
- filterNumber: s
645
- }), e.recommendationConfigs.filters = r;
652
+ filterNumber: o
653
+ }), e.recommendationConfigs.filters = n;
646
654
  },
647
655
  generateFilterQuery() {
648
656
  return P(this.recommendationConfigs.filters);
@@ -653,111 +661,149 @@ const Q = () => ({
653
661
  * every block's recommendationConfigs across user edits.
654
662
  */
655
663
  hasInvalidBlock() {
656
- return Object.values(this.blockStates).some((t) => !J(t.recommendationConfigs, this));
664
+ return Object.values(this.blockStates).some((t) => !Q(t.recommendationConfigs, this));
657
665
  },
658
666
  /**
659
667
  * Which required fields are missing across the design's blocks, so the save
660
668
  * toaster can name the cause instead of always showing the generic message.
661
669
  */
662
670
  invalidBlockFields() {
663
- return Object.values(this.blockStates).flatMap((t) => H(t.recommendationConfigs, this));
671
+ return Object.values(this.blockStates).flatMap((t) => J(t.recommendationConfigs, this));
664
672
  },
665
673
  // ====================================================================
666
674
  // Per-Block Product Fetching
667
675
  // ====================================================================
668
676
  async fetchRecommendationProducts() {
669
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
677
+ this.currentRecommendationId !== null && await this.fetchRecommendationProductsForBlock(this.currentRecommendationId);
678
+ },
679
+ /**
680
+ * Fetches one block's products whether or not it is selected: the panel teardown and the
681
+ * strategy drawer refresh the block they were handed after the user may have moved on.
682
+ */
683
+ async fetchRecommendationProductsForBlock(t) {
684
+ var i;
685
+ const e = this.blockStates[t];
686
+ if (!e)
670
687
  return;
671
- const t = [
672
- this.currentRecommendationId,
673
- this.configVersion,
674
- b
675
- ].join(":");
676
- if (y && I === t) {
677
- await y;
688
+ const n = [e.configVersion, e.adoptedSizeVersion, b].join(":"), r = I.get(t);
689
+ if ((r == null ? void 0 : r.key) === n) {
690
+ await r.promise;
678
691
  return;
679
692
  }
680
- I = t, y = this._doFetchProducts();
693
+ const o = this._doFetchProducts(t);
694
+ I.set(t, { key: n, promise: o });
681
695
  try {
682
- await y;
696
+ await o;
683
697
  } finally {
684
- I === t && (y = null, I = "");
698
+ ((i = I.get(t)) == null ? void 0 : i.promise) === o && I.delete(t);
685
699
  }
686
700
  },
687
- async _doFetchProducts() {
688
- var h;
689
- const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = R();
690
- if (r.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy")) {
691
- await this._doFetchStrategyProducts(t);
701
+ // Captures the block ID up front so the write lands on it even if the user switches.
702
+ async _doFetchProducts(t) {
703
+ var S;
704
+ const e = t ?? this.currentRecommendationId, n = this.blockStates[e], { recommendationConfigs: r } = n, o = R();
705
+ if (r.strategyId && o.isFeatureEnabled("reusableRecommendationStrategy")) {
706
+ await this._doFetchStrategyProducts(e);
692
707
  return;
693
708
  }
694
- const s = (g.get(t) ?? 0) + 1;
695
- g.set(t, s);
696
- const i = parseInt(r.size) || 6;
709
+ const i = (u.get(e) ?? 0) + 1;
710
+ u.set(e, i);
711
+ const s = parseInt(r.size) || 6;
697
712
  if (!r.strategy) {
698
- this._setBlockProducts(t, [], i);
713
+ this._setBlockProducts(e, [], s);
699
714
  return;
700
715
  }
701
- const o = r.filters.filter((f) => f.isValid), a = P(o), d = ((h = F().find((f) => f.key === r.strategy)) == null ? void 0 : h.path) || "", c = {
716
+ const a = r.filters.filter((h) => h.isValid), d = P(a), f = ((S = F().find((h) => h.key === r.strategy)) == null ? void 0 : S.path) || "", c = {
702
717
  locale: r.language,
703
718
  currency: r.currencySettings.value,
704
- partnerName: n.partnerName,
719
+ partnerName: o.partnerName,
705
720
  size: r.size,
706
721
  details: !0,
707
- campaignId: n.variationId
722
+ campaignId: o.variationId
708
723
  };
709
- r.strategy === "manualMerchandising" ? c.productId = q(r.productIds) : r.strategy === "similarViewed" && (c.productId = "{itemId}"), r.strategy === "userBased" && (c.userId = "{user_id}"), a && (c.filter = a), r.shuffleProducts && (c.shuffle = !0), Object.assign(
724
+ r.strategy === "manualMerchandising" ? c.productId = K(r.productIds) : r.strategy === "similarViewed" && (c.productId = "{itemId}"), r.strategy === "userBased" && (c.userId = "{user_id}"), d && (c.filter = d), r.shuffleProducts && (c.shuffle = !0), Object.assign(
710
725
  c,
711
- $(n.partnerName, r.strategy)
726
+ q(o.partnerName, r.strategy)
712
727
  );
713
- let u;
728
+ let g;
714
729
  try {
715
- u = await m.fetchRecommendationProducts(d, c);
730
+ g = await m.fetchRecommendationProducts(f, c);
716
731
  } catch {
717
- u = [];
732
+ g = [];
718
733
  }
719
- g.get(t) === s && this._setBlockProducts(t, u, i);
734
+ u.get(e) === i && this._setBlockProducts(e, g, s);
720
735
  },
721
736
  /**
722
- * Block-scoped counterpart of `fetchRecommendationProducts`, which only ever serves the
723
- * selected block. The legacy conversion must refresh the products of the block that
724
- * started it even after the user selected another one.
737
+ * Block-scoped counterpart of `fetchRecommendationProducts`, which only serves the selected block:
738
+ * the legacy conversion and the duplicate refresh must reach a block that may no longer be selected.
739
+ * @returns whether real products arrived
725
740
  */
726
- async fetchStrategyProductsForBlock(t) {
727
- var e;
728
- (e = this.blockStates[t]) != null && e.recommendationConfigs.strategyId && await this._doFetchStrategyProducts(t);
741
+ async fetchStrategyProductsForBlock(t, e = {}) {
742
+ var n;
743
+ return (n = this.blockStates[t]) != null && n.recommendationConfigs.strategyId ? this._doFetchStrategyProducts(t, e) : !1;
744
+ },
745
+ /**
746
+ * Reloads a block's products and adopts its strategy's current size, which may have
747
+ * moved since the block was assigned.
748
+ * @returns whether a fresh listing holds the strategy and its products arrived
749
+ */
750
+ async refreshStrategyBlock(t) {
751
+ var o;
752
+ const e = (o = this.blockStates[t]) == null ? void 0 : o.recommendationConfigs.strategyId;
753
+ if (!e)
754
+ return !1;
755
+ try {
756
+ await this.fetchStrategies();
757
+ } catch {
758
+ return !1;
759
+ }
760
+ const n = this.strategiesFetched ? this.strategies.find((i) => String(i.strategy_id) === e) : void 0;
761
+ if (!n || !await this.fetchStrategyProductsForBlock(t, { keepOnFailure: !0 }))
762
+ return !1;
763
+ const r = this.blockStates[t];
764
+ if ((r == null ? void 0 : r.recommendationConfigs.strategyId) !== e)
765
+ return !1;
766
+ if (n.size !== void 0) {
767
+ const i = String(n.size);
768
+ r.recommendationConfigs.size !== i && r.adoptedSizeVersion++, r.recommendationConfigs = { ...r.recommendationConfigs, size: i };
769
+ }
770
+ return !0;
771
+ },
772
+ _doFetchStrategyProducts(t, e = {}) {
773
+ const n = (u.get(t) ?? 0) + 1;
774
+ u.set(t, n);
775
+ const r = this._loadStrategyProducts(t, n, e);
776
+ return _.set(t, { token: n, outcome: r }), r;
729
777
  },
730
- async _doFetchStrategyProducts(t) {
731
- const e = (g.get(t) ?? 0) + 1;
732
- g.set(t, e);
778
+ async _loadStrategyProducts(t, e, { keepOnFailure: n = !1 }) {
733
779
  const { recommendationConfigs: r } = this.blockStates[t];
734
- let n = [], s = parseInt(r.size) || 6;
780
+ let o = [], i = parseInt(r.size) || 6;
735
781
  try {
736
782
  await this.fetchStrategies();
737
- const i = this.strategies.find(
738
- (o) => String(o.strategy_id) === r.strategyId
783
+ const s = this.strategies.find(
784
+ (a) => String(a.strategy_id) === r.strategyId
739
785
  );
740
- if (i) {
741
- s = parseInt(String(i.size ?? "")) || s;
742
- const o = r.currencySettings.value, d = (await this.resolveStrategyUrlTemplate(i, o)).replaceAll("{locale}", r.language).replaceAll("{currency}", o), c = d.indexOf("?"), u = c === -1 ? d : d.slice(0, c), h = (c === -1 ? "" : d.slice(c + 1)).split("&").filter((v) => v && !v.startsWith("user_id=")), f = h.length ? `${u}?${h.join("&")}` : u;
743
- f && (n = await m.fetchRecommendationProductsByUrl(f));
786
+ if (s) {
787
+ i = parseInt(String(s.size ?? "")) || i;
788
+ const a = r.currencySettings.value, f = (await this.resolveStrategyUrlTemplate(s, a)).replaceAll("{locale}", r.language).replaceAll("{currency}", a), c = f.indexOf("?"), g = c === -1 ? f : f.slice(0, c), S = (c === -1 ? "" : f.slice(c + 1)).split("&").filter((v) => v && !v.startsWith("user_id=")), h = S.length ? `${g}?${S.join("&")}` : g;
789
+ h && (o = await m.fetchRecommendationProductsByUrl(h));
744
790
  }
745
791
  } catch {
746
- n = [];
792
+ o = [];
747
793
  }
748
- g.get(t) === e && this._setBlockProducts(t, n, s);
794
+ return u.get(t) !== e ? W(t) : !o.length && n ? !1 : (this._setBlockProducts(t, o, i), o.length > 0);
749
795
  },
750
- _setBlockProducts(t, e, r) {
796
+ _setBlockProducts(t, e, n) {
751
797
  if (!this.blockStates[t])
752
798
  return;
753
- const n = e.length > 0 ? e : w(r);
799
+ const r = e.length > 0 ? e : w(n);
754
800
  this.blockStates[t].recommendationProducts = [
755
- ...n.slice(0, r),
756
- ...w(Math.max(0, r - n.length))
801
+ ...r.slice(0, n),
802
+ ...w(Math.max(0, n - r.length))
757
803
  ];
758
804
  }
759
805
  }
760
806
  });
761
807
  export {
762
- ft as useRecommendationExtensionStore
808
+ ht as useRecommendationExtensionStore
763
809
  };