@useinsider/guido 3.18.1-beta.cb31236 → 3.18.1-beta.d0bc5f3

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 (41) hide show
  1. package/dist/@types/config/schemas.js +51 -59
  2. package/dist/components/Guido.vue.js +4 -4
  3. package/dist/components/Guido.vue2.js +70 -72
  4. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +9 -7
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +76 -87
  6. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +22 -24
  7. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +26 -28
  8. package/dist/composables/useCustomInterfaceAppearance.js +42 -46
  9. package/dist/enums/extensions/recommendationBlock.js +29 -25
  10. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +71 -72
  11. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +37 -68
  12. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +44 -45
  13. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +119 -105
  14. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +7 -7
  15. package/dist/guido.css +1 -1
  16. package/dist/services/recommendationApi.js +84 -93
  17. package/dist/src/@types/config/schemas.d.ts +0 -16
  18. package/dist/src/composables/useConfig.d.ts +0 -4
  19. package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -3
  20. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +0 -1
  21. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -4
  22. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +45 -54
  23. package/dist/src/services/recommendationApi.d.ts +1 -2
  24. package/dist/src/stores/config.d.ts +0 -322
  25. package/dist/src/stores/onboarding.d.ts +0 -421
  26. package/dist/static/styles/components/recommendation-strategy.css.js +41 -74
  27. package/dist/stores/config.js +60 -74
  28. package/dist/stores/onboarding.js +1 -6
  29. package/package.json +1 -1
  30. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +0 -18
  31. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +0 -25
  32. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +0 -21
  33. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +0 -46
  34. package/dist/composables/useLegacyStrategyConversion.js +0 -58
  35. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +0 -72
  36. package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +0 -2
  37. package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +0 -2
  38. package/dist/src/composables/useLegacyStrategyConversion.d.ts +0 -3
  39. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +0 -44
  40. package/dist/static/assets/icons/filled-arrow-rising.svg.js +0 -5
  41. package/dist/static/assets/icons/line-info.svg.js +0 -5
@@ -94,9 +94,9 @@ function j(e, t = {}) {
94
94
  const u = s ?? P(n), l = y.getConfig(n);
95
95
  if (u === "list" || !l.mobileLayoutEnabled)
96
96
  return te({ currentNode: n, documentModifier: o });
97
- const c = A(), f = $(r, c.recommendationProducts), a = i ?? U(n, c.filterList), p = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${k(f, u, {
97
+ const c = A(), a = $(r, c.recommendationProducts), f = i ?? U(n, c.filterList), p = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${k(a, u, {
98
98
  productsPerRow: l.mobileCardsInRow,
99
- composition: a,
99
+ composition: f,
100
100
  filterList: c.filterList,
101
101
  priceInline: !l.priceMovedToNextLine,
102
102
  // Match the initial render's gutter so a regeneration never changes block height (SD-143023, #386).
@@ -122,9 +122,9 @@ function ie(e, t = {}) {
122
122
  const u = n.querySelector(L) ?? n.querySelector(W);
123
123
  if (!u)
124
124
  return !1;
125
- const l = A(), c = $(r, l.recommendationProducts), { cardsInRow: f } = y.getConfig(n), a = i ?? U(n, l.filterList), d = s ?? P(n), p = y.getConfig(n), E = k(c, d, {
126
- productsPerRow: f,
127
- composition: a,
125
+ const l = A(), c = $(r, l.recommendationProducts), { cardsInRow: a } = y.getConfig(n), f = i ?? U(n, l.filterList), d = s ?? P(n), p = y.getConfig(n), E = k(c, d, {
126
+ productsPerRow: a,
127
+ composition: f,
128
128
  filterList: l.filterList,
129
129
  priceInline: !p.priceMovedToNextLine,
130
130
  // Match the initial render's gutter so a regeneration never changes block height (SD-143023, #386).
@@ -153,10 +153,10 @@ function ce(e, t, n) {
153
153
  return !1;
154
154
  const s = A(), i = r.split(",").filter(Boolean), u = D(i, o, s.filterList), l = [], c = u.join(",") !== i.join(",");
155
155
  c && l.push([R, u.join(",")]);
156
- const f = le(
156
+ const a = le(
157
157
  o.getAttribute(q)
158
- ), a = f && z(f, o, s.filterList);
159
- if (f && a && a.join(",") !== f.join(",") && l.push([q, JSON.stringify(a)]), l.length === 0)
158
+ ), f = a && z(a, o, s.filterList);
159
+ if (a && f && f.join(",") !== a.join(",") && l.push([q, JSON.stringify(f)]), l.length === 0)
160
160
  return !1;
161
161
  if (l.forEach(([d, p]) => {
162
162
  t.modifyHtml(o).setAttribute(d, p);
@@ -177,20 +177,19 @@ function Te(e) {
177
177
  products: r,
178
178
  layout: s,
179
179
  composition: i,
180
- skipStylePreservation: u,
181
- forceApply: l = !1
180
+ skipStylePreservation: u
182
181
  } = e;
183
182
  if (!t)
184
183
  return;
185
- const c = u ? {} : x(t), f = {
184
+ const l = u ? {} : x(t), c = {
186
185
  currentNode: t,
187
186
  documentModifier: n,
188
187
  products: r,
189
188
  layout: s,
190
189
  composition: i
191
190
  };
192
- let a = ie(f, c);
193
- a = j(f, c) || a, a && ce(t, n, i), (a || l) && n.apply(new S("Regenerate products with styles")), o == null || o();
191
+ let a = ie(c, l);
192
+ a = j(c, l) || a, a && (ce(t, n, i), n.apply(new S("Regenerate products with styles"))), o == null || o();
194
193
  }
195
194
  function Re(e, t) {
196
195
  return e.length === t ? e : e.length > t ? e.slice(0, t) : [...e, ...H(t - e.length)];
@@ -251,16 +250,16 @@ function se(e) {
251
250
  omnibusDiscountEl: l,
252
251
  buttonEl: c
253
252
  } = e;
254
- let f = !1;
253
+ let a = !1;
255
254
  if (o && "querySelector" in o) {
256
- const a = o.querySelector("img");
257
- a && (t.modifyHtml(a).setAttribute("src", X(n.image_url)).setAttribute("alt", n.name), f = !0);
255
+ const f = o.querySelector("img");
256
+ f && (t.modifyHtml(f).setAttribute("src", X(n.image_url)).setAttribute("alt", n.name), a = !0);
258
257
  const d = o.querySelector("a");
259
- d && (t.modifyHtml(d).setAttribute("href", n.url), f = !0);
258
+ d && (t.modifyHtml(d).setAttribute("href", n.url), a = !0);
260
259
  }
261
260
  if (r && "querySelector" in r) {
262
- const a = r.querySelector("strong") ?? r.querySelector("p");
263
- b(t, a ?? null, n.name) && (f = !0);
261
+ const f = r.querySelector("strong") ?? r.querySelector("p");
262
+ b(t, f ?? null, n.name) && (a = !0);
264
263
  }
265
264
  if (K({
266
265
  documentModifier: t,
@@ -269,11 +268,11 @@ function se(e) {
269
268
  oldPriceEl: i,
270
269
  omnibusPriceEl: u,
271
270
  omnibusDiscountEl: l
272
- }) && (f = !0), c && "querySelector" in c) {
273
- const a = c.querySelector("a.es-button") || c.querySelector("a");
274
- a && (t.modifyHtml(a).setAttribute("href", n.url), f = !0);
271
+ }) && (a = !0), c && "querySelector" in c) {
272
+ const f = c.querySelector("a.es-button") || c.querySelector("a");
273
+ f && (t.modifyHtml(f).setAttribute("href", n.url), a = !0);
275
274
  }
276
- return f;
275
+ return a;
277
276
  }
278
277
  function V(e) {
279
278
  return "querySelector" in e ? e.querySelector(L) ?? e : e;
@@ -309,14 +308,14 @@ function fe(e, t, n) {
309
308
  let s = !1;
310
309
  return r.forEach((i, u) => {
311
310
  const l = Math.min(i.length, n.length);
312
- i.slice(0, l).forEach((c, f) => {
311
+ i.slice(0, l).forEach((c, a) => {
313
312
  if (!("querySelector" in c))
314
313
  return;
315
- const a = ae(u, n[f]);
316
- if (a === null)
314
+ const f = ae(u, n[a]);
315
+ if (f === null)
317
316
  return;
318
317
  const d = c.querySelector("p") ?? null;
319
- b(t, d, a) && (s = !0);
318
+ b(t, d, f) && (s = !0);
320
319
  });
321
320
  }), s;
322
321
  }
@@ -337,9 +336,9 @@ function O(e, t, n) {
337
336
  `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
338
337
  ), c = e.querySelectorAll(
339
338
  `[esd-extension-block-id="${m.BUTTON}"]`
340
- ), f = Math.min(o.length, n.length);
341
- let a = !1;
342
- for (let d = 0; d < f; d++) {
339
+ ), a = Math.min(o.length, n.length);
340
+ let f = !1;
341
+ for (let d = 0; d < a; d++) {
343
342
  const p = se({
344
343
  documentModifier: t,
345
344
  product: n[d],
@@ -351,33 +350,33 @@ function O(e, t, n) {
351
350
  omnibusDiscountEl: l[d] ?? null,
352
351
  buttonEl: c[d] ?? null
353
352
  });
354
- a = a || p;
353
+ f = f || p;
355
354
  }
356
- return fe(e, t, n) && (a = !0), a;
355
+ return fe(e, t, n) && (f = !0), f;
357
356
  }
358
357
  function qe(e) {
359
- const { currentNode: t, documentModifier: n, products: o, forceApply: r = !1 } = e;
358
+ const { currentNode: t, documentModifier: n, products: o } = e;
360
359
  if (!t || !("querySelectorAll" in t))
361
360
  return !1;
362
- const s = V(t);
363
- if (!("querySelectorAll" in s) || s.querySelectorAll(
361
+ const r = V(t);
362
+ if (!("querySelectorAll" in r) || r.querySelectorAll(
364
363
  `[esd-extension-block-id="${m.IMAGE}"]`
365
364
  ).length !== o.length)
366
365
  return !1;
367
- let u = O(s, n, o);
368
- const l = P(t), c = y.getConfig(t);
369
- if (l !== "list" && c.mobileLayoutEnabled && "querySelector" in t) {
370
- const f = t.querySelector(N);
371
- if (f) {
366
+ let i = O(r, n, o);
367
+ const u = P(t), l = y.getConfig(t);
368
+ if (u !== "list" && l.mobileLayoutEnabled && "querySelector" in t) {
369
+ const c = t.querySelector(N);
370
+ if (c) {
372
371
  const a = O(
373
- f,
372
+ c,
374
373
  n,
375
374
  o
376
375
  );
377
- u = u || a;
376
+ i = i || a;
378
377
  }
379
378
  }
380
- return (u || r) && n.apply(new S("Updated product content in-place")), !0;
379
+ return i && n.apply(new S("Updated product content in-place")), !0;
381
380
  }
382
381
  function _(e, t, n) {
383
382
  if (!("querySelectorAll" in e))
@@ -418,8 +417,8 @@ function Me(e) {
418
417
  if (u !== "list" && l.mobileLayoutEnabled && "querySelector" in t) {
419
418
  const c = t.querySelector(N);
420
419
  if (c) {
421
- const f = _(c, n, r);
422
- i = i || f;
420
+ const a = _(c, n, r);
421
+ i = i || a;
423
422
  }
424
423
  }
425
424
  return i && n.apply(new S("Updated price formatting in-place")), i;
@@ -1,23 +1,23 @@
1
- import { getRecommendationFeedSourceMaps as R, getOperatorOptions as D, PriceAttributes as F } from "../../../../enums/extensions/recommendationBlock.js";
2
- import { useRecommendationApi as P } from "../../../../services/recommendationApi.js";
3
- import { useConfigStore as k } from "../../../../stores/config.js";
4
- import { defineStore as L } from "pinia";
1
+ import { getRecommendationFeedSourceMaps as k, strategyEditPath as G, URLS as F, getOperatorOptions as D, PriceAttributes as _ } from "../../../../enums/extensions/recommendationBlock.js";
2
+ import { useRecommendationApi as L } from "../../../../services/recommendationApi.js";
3
+ import { useConfigStore as N } from "../../../../stores/config.js";
4
+ import { defineStore as U } from "pinia";
5
5
  import "../constants/selectors.js";
6
- import { DEFAULT_MOBILE_CARDS_IN_ROW as U, DEFAULT_CARDS_IN_ROW as _ } from "../constants/layout.js";
7
- import { CURRENT_CONFIG_VERSION as y, DEFAULT_NODE_CONFIG as N, EXCLUDED_ALGORITHM_IDS as M } from "../constants/defaultConfig.js";
6
+ import { DEFAULT_MOBILE_CARDS_IN_ROW as A, DEFAULT_CARDS_IN_ROW as E } from "../constants/layout.js";
7
+ import { DEFAULT_NODE_CONFIG as x, EXCLUDED_ALGORITHM_IDS as M } from "../constants/defaultConfig.js";
8
8
  import { getDefaultProducts as C } from "../templates/utils.js";
9
9
  import { generateCompleteFilterQuery as v } from "../utils/filterUtil.js";
10
- import { isLegacyStrategyConfig as x } from "../utils/legacyStrategyMigration.js";
11
- import { getPartnerRecommendationParams as z } from "../utils/partnerCustomizations.js";
12
- import { sanitizeProductIds as B } from "../utils/productIds.js";
13
- import { isFilterValid as A } from "../validation/filterSchema.js";
14
- import { isConfigValid as O } from "../validation/requiredFields.js";
15
- const m = P();
16
- let f = null, g = null, h = null, S = null;
17
- const p = /* @__PURE__ */ new Map();
18
- function G() {
10
+ import { getPartnerRecommendationParams as B } from "../utils/partnerCustomizations.js";
11
+ import { sanitizeProductIds as O } from "../utils/productIds.js";
12
+ import { isFilterValid as T } from "../validation/filterSchema.js";
13
+ import { isConfigValid as z } from "../validation/requiredFields.js";
14
+ const d = L();
15
+ let h = null, g = null, S = null, p = null, y = 0;
16
+ const I = /* @__PURE__ */ new Map();
17
+ let m = null;
18
+ function P() {
19
19
  return {
20
- cardsInRow: _,
20
+ cardsInRow: E,
21
21
  currencySettings: {
22
22
  name: "USD",
23
23
  value: "USD",
@@ -31,7 +31,7 @@ function G() {
31
31
  productIds: [],
32
32
  id: 1,
33
33
  language: "en_US",
34
- mobileCardsInRow: U,
34
+ mobileCardsInRow: A,
35
35
  mobileLayoutEnabled: !1,
36
36
  orientation: "grid",
37
37
  recommendedProducts: [],
@@ -39,7 +39,6 @@ function G() {
39
39
  shuffleProducts: !1,
40
40
  strategy: "mostPopular",
41
41
  strategyId: "",
42
- nodeConfigVersion: y,
43
42
  textTrimming: !0,
44
43
  unresponsive: !1,
45
44
  size: "6",
@@ -50,20 +49,18 @@ function G() {
50
49
  }
51
50
  function w() {
52
51
  return {
53
- recommendationConfigs: G(),
52
+ recommendationConfigs: P(),
54
53
  recommendationProducts: [],
55
54
  filterStatus: !1,
56
55
  filterSelectionDrawerStatus: !1,
57
56
  assignStrategyDrawerStatus: !1,
58
57
  removeStrategyModalStatus: !1,
59
- legacyStrategyUpdatedModalStatus: !1,
60
58
  filterGroup: 1,
61
59
  isInitialized: !1,
62
- filterSnapshot: null,
63
- legacyConversionLoading: !1
60
+ filterSnapshot: null
64
61
  };
65
62
  }
66
- const E = () => ({
63
+ const V = () => ({
67
64
  recommendationCampaignUrls: {},
68
65
  activePredictiveAlgorithms: [],
69
66
  languages: {},
@@ -72,11 +69,12 @@ const E = () => ({
72
69
  strategies: [],
73
70
  strategiesLoading: !1,
74
71
  strategyUrlTemplates: {},
72
+ strategiesFetched: !1,
75
73
  blockStates: {},
76
74
  currentRecommendationId: null,
77
75
  configVersion: 0
78
- }), et = L("guidoRecommendationExtension", {
79
- state: () => E(),
76
+ }), rt = U("guidoRecommendationExtension", {
77
+ state: () => V(),
80
78
  getters: {
81
79
  // ====================================================================
82
80
  // Proxy Getters — Backward Compatible Access to Current Block State
@@ -86,7 +84,7 @@ const E = () => ({
86
84
  * This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
87
85
  */
88
86
  recommendationConfigs(t) {
89
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : G();
87
+ return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : P();
90
88
  },
91
89
  /**
92
90
  * Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
@@ -106,15 +104,6 @@ const E = () => ({
106
104
  removeStrategyModalStatus(t) {
107
105
  return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].removeStrategyModalStatus : !1;
108
106
  },
109
- isLegacyStrategyBlock() {
110
- return k().isFeatureEnabled("reusableRecommendationStrategy") && x(this.recommendationConfigs);
111
- },
112
- legacyConversionLoading(t) {
113
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].legacyConversionLoading : !1;
114
- },
115
- legacyStrategyUpdatedModalStatus(t) {
116
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].legacyStrategyUpdatedModalStatus : !1;
117
- },
118
107
  assignedStrategy(t) {
119
108
  const { strategyId: e } = this.recommendationConfigs;
120
109
  return e ? t.strategies.find((r) => String(r.strategy_id) === e) ?? null : null;
@@ -150,7 +139,7 @@ const E = () => ({
150
139
  return [...new Set(t.map((e) => e.filterGroup))].sort((e, r) => e - r);
151
140
  },
152
141
  getActivePredictiveAlgorithms: (t) => {
153
- const e = R(), r = [];
142
+ const e = k(), r = [];
154
143
  return t.activePredictiveAlgorithms.filter((n) => !M.includes(n)).forEach((n) => {
155
144
  r.push(...e.filter((s) => s.id === n));
156
145
  }), r.map((n) => ({
@@ -169,7 +158,7 @@ const E = () => ({
169
158
  getFilterList() {
170
159
  return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
171
160
  let e;
172
- return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : F.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
161
+ return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : _.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
173
162
  text: t.displayName,
174
163
  value: e,
175
164
  type: t.attributeType
@@ -351,12 +340,6 @@ const E = () => ({
351
340
  closeAssignStrategyDrawer() {
352
341
  this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].assignStrategyDrawerStatus = !1);
353
342
  },
354
- openLegacyStrategyUpdatedModal() {
355
- this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].legacyStrategyUpdatedModalStatus = !0);
356
- },
357
- closeLegacyStrategyUpdatedModal() {
358
- this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].legacyStrategyUpdatedModalStatus = !1);
359
- },
360
343
  openRemoveStrategyModal() {
361
344
  this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].removeStrategyModalStatus = !0);
362
345
  },
@@ -364,29 +347,87 @@ const E = () => ({
364
347
  this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].removeStrategyModalStatus = !1);
365
348
  },
366
349
  async fetchStrategies() {
367
- if (S) {
368
- await S;
350
+ if (p && await p, this.strategiesFetched)
369
351
  return;
370
- }
371
- S = (async () => {
352
+ const t = y;
353
+ p = (async () => {
372
354
  this.strategiesLoading = !0;
373
355
  try {
374
- this.strategies = await m.fetchRecommendationStrategies();
356
+ const e = await d.fetchRecommendationStrategies();
357
+ if (t !== y)
358
+ return;
359
+ this.strategies = e, this.strategiesFetched = !0;
375
360
  } finally {
376
361
  this.strategiesLoading = !1;
377
362
  }
378
363
  })();
379
364
  try {
380
- await S;
365
+ await p;
381
366
  } finally {
382
- S = null;
367
+ p = null;
383
368
  }
384
369
  },
370
+ invalidateStrategies() {
371
+ this.strategiesFetched = !1, y += 1;
372
+ },
373
+ /**
374
+ * Opens a Smart Recommender strategy page in a new tab and refreshes the list every time
375
+ * the user comes back. `visibilitychange` covers the tab case; `focus` covers the page
376
+ * landing in a separate window, where this document never goes hidden.
377
+ *
378
+ * Deliberately NOT one-shot: the strategy tab stays open, so a user can create a second
379
+ * strategy in it and come back again — a listener that disarmed on the first return would
380
+ * leave that one missing from the list. Armed only once the user actually opens a strategy
381
+ * page, so anyone who never does pays nothing.
382
+ */
383
+ _armStrategyPageReturn(t) {
384
+ window.open(t, "_blank", "noopener"), m == null || m();
385
+ let e = !1;
386
+ const r = () => {
387
+ document.hidden || e || (e = !0, this.invalidateStrategies(), this.fetchStrategies().then(() => this._refreshAssignedStrategyProducts()).catch(() => {
388
+ }).finally(() => {
389
+ e = !1;
390
+ }));
391
+ };
392
+ document.addEventListener("visibilitychange", r), window.addEventListener("focus", r), m = () => {
393
+ document.removeEventListener("visibilitychange", r), window.removeEventListener("focus", r), m = null;
394
+ };
395
+ },
396
+ /**
397
+ * Reloads the products of the block the user is on, so an edit made in the strategy tab
398
+ * lands on the canvas instead of waiting for the assign drawer to be reopened.
399
+ *
400
+ * Only the selected block: the canvas regeneration is driven off the active block's
401
+ * product array, so refreshing an unselected block would fetch without redrawing it.
402
+ */
403
+ async _refreshAssignedStrategyProducts() {
404
+ var e;
405
+ const t = this.currentRecommendationId;
406
+ t === null || !((e = this.blockStates[t]) != null && e.recommendationConfigs.strategyId) || await this.fetchRecommendationProducts();
407
+ },
408
+ /** Lets the editor tear the return listeners down when it unmounts. */
409
+ disposeStrategyPageReturn() {
410
+ m == null || m();
411
+ },
412
+ /**
413
+ * Opens Smart Recommender's strategy creation page. Every return refreshes the list so the
414
+ * new strategy is offered; the user picks it themselves.
415
+ */
416
+ openStrategyCreation() {
417
+ this._armStrategyPageReturn(F.RECOMMENDATION_STRATEGY_CREATE_PATH);
418
+ },
419
+ /**
420
+ * Opens the strategy's edit page. Every return refreshes the list so the block reflects the
421
+ * edited configuration.
422
+ */
423
+ openStrategyEdit(t) {
424
+ this._armStrategyPageReturn(G(t));
425
+ },
385
426
  async resolveStrategyUrlTemplate(t, e) {
386
427
  const r = typeof t.updated_at == "string" ? t.updated_at : "", n = r ? `${t.strategy_id}:${r}:${e}` : "", s = n ? this.strategyUrlTemplates[n] : void 0;
387
428
  if (s)
388
429
  return s;
389
- const { full_path: i = "" } = await m.generateStrategyEndpoint(t, e) ?? {};
430
+ const { full_path: i = "" } = await d.generateStrategyEndpoint(t, e) ?? {};
390
431
  return n && i && (this.strategyUrlTemplates = {
391
432
  ...this.strategyUrlTemplates,
392
433
  [n]: i
@@ -398,51 +439,24 @@ const E = () => ({
398
439
  ...t.size !== void 0 ? { size: String(t.size) } : {}
399
440
  });
400
441
  },
401
- async convertLegacyStrategy(t, e = { scope: "campaign" }) {
402
- const r = this.currentRecommendationId;
403
- if (r === null || !this.blockStates[r])
404
- throw new Error("[Guido] convertLegacyStrategy called without an active block");
405
- this.blockStates[r].legacyConversionLoading = !0;
406
- try {
407
- const n = await m.migrateLegacyStrategy(t, e);
408
- try {
409
- await this.fetchStrategies();
410
- } catch (o) {
411
- console.error("[Guido] strategy listing refresh after conversion failed", o);
412
- }
413
- const s = this.strategies.find((o) => String(o.strategy_id) === n), i = this.blockStates[r];
414
- return i.recommendationConfigs = {
415
- ...i.recommendationConfigs,
416
- strategyId: n,
417
- nodeConfigVersion: y,
418
- ...(s == null ? void 0 : s.size) !== void 0 ? { size: String(s.size) } : {}
419
- }, this.currentRecommendationId === r && this.configVersion++, n;
420
- } finally {
421
- this.blockStates[r].legacyConversionLoading = !1;
422
- }
423
- },
424
442
  removeStrategy() {
425
- this.patchCurrentBlockConfig({
426
- strategyId: "",
427
- size: N.size,
428
- nodeConfigVersion: y
429
- });
443
+ this.patchCurrentBlockConfig({ strategyId: "", size: x.size });
430
444
  },
431
445
  // ====================================================================
432
446
  // Shared Data Fetching (fetched once, used by all blocks)
433
447
  // ====================================================================
434
448
  async fetchRecommendationCreateData() {
435
449
  if (!this.activePredictiveAlgorithms.length) {
436
- if (f) {
437
- await f;
450
+ if (h) {
451
+ await h;
438
452
  return;
439
453
  }
440
- f = (async () => {
454
+ h = (async () => {
441
455
  const {
442
456
  activePredictiveAlgorithms: t,
443
457
  languages: e,
444
458
  currencies: r
445
- } = await m.fetchRecommendationCreateData();
459
+ } = await d.fetchRecommendationCreateData();
446
460
  if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
447
461
  const n = this.blockStates[this.currentRecommendationId];
448
462
  n.filterStatus = !!n.recommendationConfigs.filters.length;
@@ -450,9 +464,9 @@ const E = () => ({
450
464
  this.currencyList = r;
451
465
  })();
452
466
  try {
453
- await f;
467
+ await h;
454
468
  } finally {
455
- f = null;
469
+ h = null;
456
470
  }
457
471
  }
458
472
  },
@@ -463,7 +477,7 @@ const E = () => ({
463
477
  return;
464
478
  }
465
479
  g = (async () => {
466
- const t = await m.fetchRecommendationFilters();
480
+ const t = await d.fetchRecommendationFilters();
467
481
  this.filterList = t;
468
482
  })();
469
483
  try {
@@ -498,7 +512,7 @@ const E = () => ({
498
512
  const n = [...e.recommendationConfigs.filters];
499
513
  n[r] = {
500
514
  ...t,
501
- isValid: A(t)
515
+ isValid: T(t)
502
516
  }, e.recommendationConfigs.filters = n;
503
517
  }
504
518
  },
@@ -544,33 +558,33 @@ const E = () => ({
544
558
  * every block's recommendationConfigs across user edits.
545
559
  */
546
560
  hasInvalidBlock() {
547
- return Object.values(this.blockStates).some((t) => !O(t.recommendationConfigs, this));
561
+ return Object.values(this.blockStates).some((t) => !z(t.recommendationConfigs, this));
548
562
  },
549
563
  // ====================================================================
550
564
  // Per-Block Product Fetching
551
565
  // ====================================================================
552
566
  async fetchRecommendationProducts() {
553
567
  if (!(this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])) {
554
- if (h) {
555
- await h;
568
+ if (S) {
569
+ await S;
556
570
  return;
557
571
  }
558
- h = this._doFetchProducts();
572
+ S = this._doFetchProducts();
559
573
  try {
560
- await h;
574
+ await S;
561
575
  } finally {
562
- h = null;
576
+ S = null;
563
577
  }
564
578
  }
565
579
  },
566
580
  async _doFetchProducts() {
567
- var d;
568
- const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = k();
581
+ var f;
582
+ const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = N();
569
583
  if (r.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy")) {
570
584
  await this._doFetchStrategyProducts(t);
571
585
  return;
572
586
  }
573
- const s = r.filters.filter((u) => u.isValid), i = v(s), o = ((d = R().find((u) => u.key === r.strategy)) == null ? void 0 : d.path) || "", c = parseInt(r.size) || 6, a = {
587
+ const s = r.filters.filter((u) => u.isValid), i = v(s), o = ((f = k().find((u) => u.key === r.strategy)) == null ? void 0 : f.path) || "", c = parseInt(r.size) || 6, a = {
574
588
  locale: r.language,
575
589
  currency: r.currencySettings.value,
576
590
  partnerName: n.partnerName,
@@ -578,21 +592,21 @@ const E = () => ({
578
592
  details: !0,
579
593
  campaignId: n.variationId
580
594
  };
581
- r.strategy === "manualMerchandising" ? a.productId = B(r.productIds) : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), i && (a.filter = i), r.shuffleProducts && (a.shuffle = !0), Object.assign(
595
+ r.strategy === "manualMerchandising" ? a.productId = O(r.productIds) : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), i && (a.filter = i), r.shuffleProducts && (a.shuffle = !0), Object.assign(
582
596
  a,
583
- z(n.partnerName, r.strategy)
597
+ B(n.partnerName, r.strategy)
584
598
  );
585
599
  let l;
586
600
  try {
587
- l = await m.fetchRecommendationProducts(o, a);
601
+ l = await d.fetchRecommendationProducts(o, a);
588
602
  } catch {
589
603
  l = [];
590
604
  }
591
605
  this._setBlockProducts(t, l, c);
592
606
  },
593
607
  async _doFetchStrategyProducts(t) {
594
- const e = (p.get(t) ?? 0) + 1;
595
- p.set(t, e);
608
+ const e = (I.get(t) ?? 0) + 1;
609
+ I.set(t, e);
596
610
  const { recommendationConfigs: r } = this.blockStates[t];
597
611
  let n = [], s = parseInt(r.size) || 6;
598
612
  try {
@@ -602,13 +616,13 @@ const E = () => ({
602
616
  );
603
617
  if (i) {
604
618
  s = parseInt(String(i.size ?? "")) || s;
605
- const o = r.currencySettings.value, a = (await this.resolveStrategyUrlTemplate(i, o)).replaceAll("{locale}", r.language).replaceAll("{currency}", o), l = a.indexOf("?"), d = l === -1 ? a : a.slice(0, l), u = (l === -1 ? "" : a.slice(l + 1)).split("&").filter((b) => b && !b.startsWith("user_id=")), I = u.length ? `${d}?${u.join("&")}` : d;
606
- I && (n = await m.fetchRecommendationProductsByUrl(I));
619
+ const o = r.currencySettings.value, a = (await this.resolveStrategyUrlTemplate(i, o)).replaceAll("{locale}", r.language).replaceAll("{currency}", o), l = a.indexOf("?"), f = l === -1 ? a : a.slice(0, l), u = (l === -1 ? "" : a.slice(l + 1)).split("&").filter((R) => R && !R.startsWith("user_id=")), b = u.length ? `${f}?${u.join("&")}` : f;
620
+ b && (n = await d.fetchRecommendationProductsByUrl(b));
607
621
  }
608
622
  } catch {
609
623
  n = [];
610
624
  }
611
- p.get(t) === e && this._setBlockProducts(t, n, s);
625
+ I.get(t) === e && this._setBlockProducts(t, n, s);
612
626
  },
613
627
  _setBlockProducts(t, e, r) {
614
628
  if (!this.blockStates[t])
@@ -622,5 +636,5 @@ const E = () => ({
622
636
  }
623
637
  });
624
638
  export {
625
- et as useRecommendationExtensionStore
639
+ rt as useRecommendationExtensionStore
626
640
  };
@@ -1,12 +1,12 @@
1
1
  import { ModificationDescription as f } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
2
  import { RECOMMENDATION_ID_ATTR as m } from "../constants/selectors.js";
3
- import { isPartnerManagedBlock as l, updateProductContentInPlace as a, regenerateProductRowsWithStyles as d } from "../controls/main/utils.js";
4
- import { RecommendationConfigService as p } from "../services/configService.js";
3
+ import { isPartnerManagedBlock as a, updateProductContentInPlace as d, regenerateProductRowsWithStyles as l } from "../controls/main/utils.js";
4
+ import { RecommendationConfigService as s } from "../services/configService.js";
5
5
  let e = null;
6
- function M(r) {
6
+ function N(r) {
7
7
  e = r;
8
8
  }
9
- function N(r, c, i, u) {
9
+ function D(r, c, i, u) {
10
10
  const n = e == null ? void 0 : e.getDocumentRootHtmlNode();
11
11
  if (!e || !n || !("querySelector" in n))
12
12
  return !1;
@@ -14,9 +14,9 @@ function N(r, c, i, u) {
14
14
  if (!t)
15
15
  return !1;
16
16
  const o = e.getDocumentModifier();
17
- return p.stageConfig(o, t, c), l(t) ? (o.apply(new f(u)), !0) : (a({ currentNode: t, documentModifier: o, products: i, forceApply: !0 }) || d({ currentNode: t, documentModifier: o, products: i, forceApply: !0 }), !0);
17
+ return s.stageConfig(o, t, c), a(t) ? (o.apply(new f(u)), !0) : (d({ currentNode: t, documentModifier: o, products: i }) || l({ currentNode: t, documentModifier: o, products: i }), !0);
18
18
  }
19
19
  export {
20
- N as commitBlockChangeOutsidePanel,
21
- M as registerNodeConfigWriter
20
+ D as commitBlockChangeOutsidePanel,
21
+ N as registerNodeConfigWriter
22
22
  };