@useinsider/guido 3.2.0-beta.c2a858e → 3.2.0-beta.caa22bf

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 (90) hide show
  1. package/README.md +92 -0
  2. package/dist/@types/config/schemas.js +150 -94
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +88 -87
  5. package/dist/components/organisms/onboarding/AMPOnboarding.vue2.js +51 -31
  6. package/dist/components/organisms/onboarding/GenericOnboarding.vue.js +1 -1
  7. package/dist/components/organisms/onboarding/GenericOnboarding.vue2.js +23 -22
  8. package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +1 -1
  9. package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +37 -39
  10. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue.js +3 -3
  11. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue2.js +30 -41
  12. package/dist/components/organisms/onboarding/VersionHistoryOnboarding.vue2.js +15 -14
  13. package/dist/composables/useRecommendation.js +46 -26
  14. package/dist/composables/useRibbonOffset.js +21 -0
  15. package/dist/composables/useSave.js +21 -18
  16. package/dist/composables/useStripo.js +14 -16
  17. package/dist/composables/validators/useCouponBlockValidator.js +24 -0
  18. package/dist/config/compiler/recommendationCompilerRules.js +27 -27
  19. package/dist/config/migrator/index.js +9 -9
  20. package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
  21. package/dist/config/migrator/recommendation/extractors.js +27 -0
  22. package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
  23. package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
  24. package/dist/config/migrator/recommendation/settingsMapper.js +70 -0
  25. package/dist/config/migrator/recommendation/themeMapper.js +93 -0
  26. package/dist/config/migrator/recommendationMigrator.js +74 -290
  27. package/dist/enums/extensions/recommendationBlock.js +2 -1
  28. package/dist/enums/onboarding.js +7 -2
  29. package/dist/extensions/Blocks/Recommendation/block.js +35 -32
  30. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
  31. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +25 -24
  32. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +228 -181
  33. package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
  34. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +130 -90
  35. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
  36. package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
  37. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +21 -0
  38. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
  39. package/dist/guido.css +1 -1
  40. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +258 -235
  41. package/dist/node_modules/valibot/dist/index.js +450 -235
  42. package/dist/package.json.js +1 -1
  43. package/dist/services/templateLibraryApi.js +5 -4
  44. package/dist/src/@types/config/defaults.d.ts +5 -1
  45. package/dist/src/@types/config/index.d.ts +3 -3
  46. package/dist/src/@types/config/schemas.d.ts +213 -0
  47. package/dist/src/@types/config/types.d.ts +9 -1
  48. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  49. package/dist/src/composables/useConfig.d.ts +56 -0
  50. package/dist/src/composables/useRecommendation.d.ts +10 -1
  51. package/dist/src/composables/useRecommendation.test.d.ts +1 -0
  52. package/dist/src/composables/useRibbonOffset.d.ts +4 -0
  53. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
  54. package/dist/src/config/migrator/index.d.ts +2 -1
  55. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
  56. package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
  57. package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
  58. package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
  59. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
  60. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
  61. package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
  62. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
  63. package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
  64. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
  65. package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
  66. package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
  67. package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
  68. package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
  69. package/dist/src/enums/onboarding.d.ts +6 -0
  70. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
  71. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
  72. package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
  73. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +34 -0
  74. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
  75. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +21 -0
  76. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +1 -0
  77. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
  78. package/dist/src/library.d.ts +1 -1
  79. package/dist/src/stores/config.d.ts +504 -0
  80. package/dist/src/stores/onboarding.d.ts +4 -0
  81. package/dist/src/utils/htmlEscape.d.ts +5 -0
  82. package/dist/src/utils/htmlEscape.test.d.ts +1 -0
  83. package/dist/stores/onboarding.js +4 -0
  84. package/dist/utils/htmlEscape.js +13 -0
  85. package/dist/utils/pairProductVariables.js +89 -88
  86. package/dist/utils/templatePreparation.js +72 -32
  87. package/package.json +7 -3
  88. package/dist/enums/displayConditions.js +0 -80
  89. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
  90. package/dist/src/enums/displayConditions.d.ts +0 -2
@@ -1,8 +1,14 @@
1
- import { ModificationDescription as f } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CURRENT_CONFIG_VERSION as u, DEFAULT_NODE_CONFIG as e } from "../constants/defaultConfig.js";
3
- import { setCurrencyAttributes as g } from "../controls/main/utils.js";
4
- import { hasMinimalConfig as a } from "../types/nodeConfig.js";
5
- class C {
1
+ import { ModificationDescription as h } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CURRENT_CONFIG_VERSION as l, DEFAULT_NODE_CONFIG as r } from "../constants/defaultConfig.js";
3
+ import { setCurrencyAttributes as D } from "../controls/main/utils.js";
4
+ import { hasMinimalConfig as A } from "../types/nodeConfig.js";
5
+ function S(e) {
6
+ return e === "." || e === "," || e === " ";
7
+ }
8
+ function N(e) {
9
+ return e === "." || e === "," || e === " " || e === "";
10
+ }
11
+ class V {
6
12
  // ========================================================================
7
13
  // Read Operations
8
14
  // ========================================================================
@@ -42,7 +48,7 @@ class C {
42
48
  return !1;
43
49
  try {
44
50
  const t = i.getNodeConfig();
45
- return a(t);
51
+ return A(t);
46
52
  } catch {
47
53
  return !1;
48
54
  }
@@ -77,8 +83,8 @@ class C {
77
83
  * @returns The new complete configuration
78
84
  */
79
85
  static updateConfig(i, t, o, n) {
80
- const s = this.getConfig(t), r = this.deepMerge(s, o);
81
- return this.saveConfig(i, t, r, n), r;
86
+ const c = this.getConfig(t), u = this.deepMerge(c, o);
87
+ return this.saveConfig(i, t, u, n), u;
82
88
  }
83
89
  /**
84
90
  * Initialize configuration for a new block
@@ -95,7 +101,7 @@ class C {
95
101
  */
96
102
  static initializeConfig(i, t, o) {
97
103
  const n = o ? this.mergeWithDefaults(o) : this.cloneDefaults();
98
- return this.saveConfig(i, t, n, "Initialize recommendation block"), g({
104
+ return this.saveConfig(i, t, n, "Initialize recommendation block"), D({
99
105
  currentNode: t,
100
106
  documentModifier: i.getDocumentModifier(),
101
107
  currency: n.currency
@@ -112,9 +118,9 @@ class C {
112
118
  */
113
119
  static saveConfig(i, t, o, n) {
114
120
  try {
115
- i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new f(n));
116
- } catch (s) {
117
- console.warn("[RecommendationConfigService] Failed to save config:", s);
121
+ i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new h(n));
122
+ } catch (c) {
123
+ console.warn("[RecommendationConfigService] Failed to save config:", c);
118
124
  }
119
125
  }
120
126
  // ========================================================================
@@ -125,23 +131,53 @@ class C {
125
131
  *
126
132
  * Reads existing data-attributes and creates a proper node config.
127
133
  * Used when loading templates created before node config was implemented.
134
+ *
135
+ * Sources, in priority order (later overrides earlier):
136
+ * 1. `esd-ext-config` JSON blob — emitted by the recommendation migrator and
137
+ * by hand-authored new templates. Carries the full RecommendationNodeConfig
138
+ * (strategy, language, currency, filters, productIds, etc.) which the
139
+ * discrete data-* attrs below cannot capture.
140
+ * 2. Discrete `data-*` attributes — runtime source of truth for
141
+ * layout/composition/spacing; controls keep these in sync as the user
142
+ * edits, so we let them override the JSON blob if they disagree.
143
+ * 3. `currency-*` attributes — durable currency source on the block element.
128
144
  * @param api - Stripo extension API with document modifier
129
145
  * @param node - The block node to migrate
130
146
  * @returns The migrated configuration
131
147
  */
132
148
  static migrateFromDataAttributes(i, t) {
133
149
  const o = {
134
- configVersion: u
150
+ configVersion: l
135
151
  };
136
152
  if ("getAttribute" in t && typeof t.getAttribute == "function") {
137
- const n = t.getAttribute("data-layout");
138
- n === "list" || n === "horizontal" ? o.layout = "list" : (n === "grid" || n === "vertical") && (o.layout = "grid");
139
- const s = t.getAttribute("data-card-composition");
140
- s && (o.composition = s.split(",").filter(Boolean));
141
- const r = t.getAttribute("data-column-spacing");
142
- r && (o.columnSpacing = parseInt(r) || e.columnSpacing);
143
- const c = t.getAttribute("data-row-spacing");
144
- c && (o.rowSpacing = parseInt(c) || e.rowSpacing);
153
+ const n = t.getAttribute("esd-ext-config");
154
+ if (n)
155
+ try {
156
+ const s = JSON.parse(n);
157
+ s && typeof s == "object" && (Object.assign(o, s), o.configVersion = l);
158
+ } catch {
159
+ }
160
+ const c = t.getAttribute("data-layout");
161
+ c === "list" || c === "horizontal" ? o.layout = "list" : (c === "grid" || c === "vertical") && (o.layout = "grid");
162
+ const u = t.getAttribute("data-card-composition");
163
+ u && (o.composition = u.split(",").filter(Boolean));
164
+ const p = t.getAttribute("data-column-spacing");
165
+ p && (o.columnSpacing = parseInt(p) || r.columnSpacing);
166
+ const b = t.getAttribute("data-row-spacing");
167
+ if (b && (o.rowSpacing = parseInt(b) || r.rowSpacing), !o.currency) {
168
+ const s = t.getAttribute("currency"), y = t.getAttribute("currency-symbol"), d = t.getAttribute("currency-alignment"), f = t.getAttribute("currency-thousand-separator"), g = t.getAttribute("currency-decimal-separator"), m = t.getAttribute("currency-decimal-count");
169
+ if (s || y || d || f || g || m) {
170
+ const a = r.currency, C = m ? parseInt(m) : NaN;
171
+ o.currency = {
172
+ code: s ?? a.code,
173
+ symbol: y ?? a.symbol,
174
+ alignment: d === "0" ? "before" : "after",
175
+ decimalCount: Number.isFinite(C) ? C : a.decimalCount,
176
+ decimalSeparator: S(g) ? g : a.decimalSeparator,
177
+ thousandSeparator: N(f) ? f : a.thousandSeparator
178
+ };
179
+ }
180
+ }
145
181
  }
146
182
  return this.initializeConfig(i, t, o);
147
183
  }
@@ -151,7 +187,7 @@ class C {
151
187
  * @returns True if migration is needed
152
188
  */
153
189
  static needsMigration(i) {
154
- return i ? this.hasConfig(i) ? this.getConfigVersion(i) < u : !0 : !1;
190
+ return i ? this.hasConfig(i) ? this.getConfigVersion(i) < l : !0 : !1;
155
191
  }
156
192
  // ========================================================================
157
193
  // Internal Helpers
@@ -161,12 +197,12 @@ class C {
161
197
  */
162
198
  static cloneDefaults() {
163
199
  return {
164
- ...e,
165
- currency: { ...e.currency },
166
- omnibusPrice: { ...e.omnibusPrice },
167
- omnibusDiscount: { ...e.omnibusDiscount },
168
- composition: [...e.composition],
169
- visibility: { ...e.visibility },
200
+ ...r,
201
+ currency: { ...r.currency },
202
+ omnibusPrice: { ...r.omnibusPrice },
203
+ omnibusDiscount: { ...r.omnibusDiscount },
204
+ composition: [...r.composition],
205
+ visibility: { ...r.visibility },
170
206
  filters: [],
171
207
  productIds: [],
172
208
  recommendationId: 0
@@ -236,5 +272,5 @@ class C {
236
272
  }
237
273
  }
238
274
  export {
239
- C as RecommendationConfigService
275
+ V as RecommendationConfigService
240
276
  };
@@ -1,15 +1,15 @@
1
- import { RecommendationFeedSourceMaps as g, getOperatorOptions as R, PriceAttributes as k } from "../../../../enums/extensions/recommendationBlock.js";
1
+ import { RecommendationFeedSourceMaps as S, getOperatorOptions as R, PriceAttributes as y } from "../../../../enums/extensions/recommendationBlock.js";
2
2
  import { useRecommendationApi as C } from "../../../../services/recommendationApi.js";
3
- import { useConfigStore as y } from "../../../../stores/config.js";
4
- import { defineStore as G } from "pinia";
3
+ import { useConfigStore as G } from "../../../../stores/config.js";
4
+ import { defineStore as P } from "pinia";
5
5
  import { DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
6
- import { EXCLUDED_ALGORITHM_IDS as w } from "../constants/defaultConfig.js";
7
- import { getDefaultProducts as S } from "../templates/utils.js";
6
+ import { EXCLUDED_ALGORITHM_IDS as D } from "../constants/defaultConfig.js";
7
+ import { getDefaultProducts as g } from "../templates/utils.js";
8
8
  import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
9
- import { isFilterValid as D } from "../validation/filterSchema.js";
9
+ import { isFilterValid as w } from "../validation/filterSchema.js";
10
10
  const h = C();
11
- let m = null, u = null, d = null;
12
- function I() {
11
+ let u = null, m = null, d = null;
12
+ function k() {
13
13
  return {
14
14
  cardsInRow: F,
15
15
  currencySettings: {
@@ -37,9 +37,9 @@ function I() {
37
37
  customAttributes: []
38
38
  };
39
39
  }
40
- function P() {
40
+ function I() {
41
41
  return {
42
- recommendationConfigs: I(),
42
+ recommendationConfigs: k(),
43
43
  recommendationProducts: [],
44
44
  filterStatus: !1,
45
45
  filterSelectionDrawerStatus: !1,
@@ -57,7 +57,7 @@ const v = () => ({
57
57
  blockStates: {},
58
58
  currentRecommendationId: null,
59
59
  configVersion: 0
60
- }), z = G("guidoRecommendationExtension", {
60
+ }), _ = P("guidoRecommendationExtension", {
61
61
  state: () => v(),
62
62
  getters: {
63
63
  // ====================================================================
@@ -68,7 +68,7 @@ const v = () => ({
68
68
  * This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
69
69
  */
70
70
  recommendationConfigs(t) {
71
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : I();
71
+ return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : k();
72
72
  },
73
73
  /**
74
74
  * Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
@@ -102,45 +102,45 @@ const v = () => ({
102
102
  },
103
103
  hasValidFilters() {
104
104
  const { filters: t } = this.recommendationConfigs;
105
- return t.length ? t.every((r) => r.isValid) : !1;
105
+ return t.length ? t.every((e) => e.isValid) : !1;
106
106
  },
107
107
  getFilterGroupCount() {
108
108
  const { filters: t } = this.recommendationConfigs;
109
- return t.length ? new Set(t.map((r) => r.filterGroup)).size : 0;
109
+ return t.length ? new Set(t.map((e) => e.filterGroup)).size : 0;
110
110
  },
111
111
  getUniqueFilterGroups() {
112
112
  const { filters: t } = this.recommendationConfigs;
113
- return [...new Set(t.map((r) => r.filterGroup))].sort((r, e) => r - e);
113
+ return [...new Set(t.map((e) => e.filterGroup))].sort((e, r) => e - r);
114
114
  },
115
115
  getActivePredictiveAlgorithms: (t) => {
116
- const r = [];
117
- return t.activePredictiveAlgorithms.filter((e) => !w.includes(e)).forEach((e) => {
118
- r.push(...g.filter((n) => n.id === e));
119
- }), r.map((e) => ({
120
- text: e.name,
121
- value: e.key
116
+ const e = [];
117
+ return t.activePredictiveAlgorithms.filter((r) => !D.includes(r)).forEach((r) => {
118
+ e.push(...S.filter((n) => n.id === r));
119
+ }), e.map((r) => ({
120
+ text: r.name,
121
+ value: r.key
122
122
  }));
123
123
  },
124
- getLanguages: (t) => Object.entries(t.languages).map(([r, e]) => ({
125
- text: e,
126
- value: r
124
+ getLanguages: (t) => Object.entries(t.languages).map(([e, r]) => ({
125
+ text: r,
126
+ value: e
127
127
  })),
128
- getCurrencySymbolList: (t) => t.currencyList.map((r) => ({
129
- text: r.text,
130
- value: r.text
128
+ getCurrencySymbolList: (t) => t.currencyList.map((e) => ({
129
+ text: e.text,
130
+ value: e.text
131
131
  })),
132
132
  getFilterList() {
133
133
  return Object.values(this.filterList).map((t) => {
134
- let r;
135
- return t.type === "productAttribute" ? r = `product_attributes.${t.attributeName}` : k.includes(t.attributeName) ? r = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : r = t.attributeName, {
134
+ let e;
135
+ return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : y.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
136
136
  text: t.displayName,
137
- value: r,
137
+ value: e,
138
138
  type: t.attributeType
139
139
  };
140
140
  });
141
141
  },
142
142
  getSelectedFilterGroup() {
143
- return (t) => [...this.recommendationConfigs.filters].filter((r) => r.filterGroup === t);
143
+ return (t) => [...this.recommendationConfigs.filters].filter((e) => e.filterGroup === t);
144
144
  }
145
145
  },
146
146
  actions: {
@@ -154,7 +154,7 @@ const v = () => ({
154
154
  setCurrentBlock(t) {
155
155
  this.blockStates[t] || (this.blockStates = {
156
156
  ...this.blockStates,
157
- [t]: P()
157
+ [t]: I()
158
158
  }), this.currentRecommendationId = t;
159
159
  },
160
160
  /**
@@ -162,13 +162,13 @@ const v = () => ({
162
162
  * Resets currentRecommendationId if it was the deleted block.
163
163
  */
164
164
  removeBlockState(t) {
165
- const r = t.toString();
166
- if (this.recommendationCampaignUrls[r]) {
165
+ const e = t.toString();
166
+ if (this.recommendationCampaignUrls[e]) {
167
167
  const n = { ...this.recommendationCampaignUrls };
168
- delete n[r], this.recommendationCampaignUrls = n;
168
+ delete n[e], this.recommendationCampaignUrls = n;
169
169
  }
170
- const e = { ...this.blockStates };
171
- if (delete e[t], this.blockStates = e, this.currentRecommendationId === t) {
170
+ const r = { ...this.blockStates };
171
+ if (delete r[t], this.blockStates = r, this.currentRecommendationId === t) {
172
172
  const n = Object.keys(this.blockStates).map(Number);
173
173
  this.currentRecommendationId = n.length > 0 ? n[0] : null;
174
174
  }
@@ -180,37 +180,75 @@ const v = () => ({
180
180
  markBlockInitialized(t) {
181
181
  this.blockStates[t] && (this.blockStates[t].isInitialized = !0);
182
182
  },
183
+ /**
184
+ * Seeds the URL-relevant fields of a block from a persisted node config.
185
+ *
186
+ * Used at save-time to ensure the campaign URL is built from the
187
+ * persisted truth (the `esd-ext-config` blob in the raw HTML) even when
188
+ * the user never selected the block in this editor session — without
189
+ * this seed, `_syncNodeConfigToStore` would never have run for that
190
+ * block and the store would hold default values (USD/en_US/mostPopular)
191
+ * instead of the real config.
192
+ *
193
+ * Creates the block entry if missing; otherwise patches only the URL-
194
+ * relevant subset and leaves runtime fields (e.g., `recommendedProducts`,
195
+ * `isInitialized`) alone.
196
+ */
197
+ seedBlockUrlConfig(t, e) {
198
+ const r = (o, s) => o === "." || o === "," || o === " " ? o : s, n = {
199
+ name: e.currencyCode,
200
+ value: e.currencyCode,
201
+ symbol: e.currencyCode,
202
+ alignment: e.currencyAlignment === "before" ? "0" : "1",
203
+ decimalCount: String(e.currencyDecimalCount),
204
+ decimalSeparator: r(e.currencyDecimalSeparator, ","),
205
+ thousandSeparator: r(e.currencyThousandSeparator, ".")
206
+ }, c = !this.blockStates[t], i = c ? I() : this.blockStates[t];
207
+ i.recommendationConfigs = {
208
+ ...i.recommendationConfigs,
209
+ strategy: e.strategy,
210
+ language: e.language,
211
+ size: e.size,
212
+ productIds: e.productIds,
213
+ filters: e.filters,
214
+ shuffleProducts: e.shuffleProducts,
215
+ currencySettings: n
216
+ }, c && (this.blockStates = {
217
+ ...this.blockStates,
218
+ [t]: i
219
+ });
220
+ },
183
221
  /**
184
222
  * Patches the current block's recommendationConfigs.
185
223
  * Replaces `store.$patch({ recommendationConfigs: { ... } })` pattern.
186
224
  */
187
- patchCurrentBlockConfig(t, r = {}) {
225
+ patchCurrentBlockConfig(t, e = {}) {
188
226
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
189
227
  return;
190
- const e = this.blockStates[this.currentRecommendationId];
191
- e.recommendationConfigs = {
192
- ...e.recommendationConfigs,
228
+ const r = this.blockStates[this.currentRecommendationId];
229
+ r.recommendationConfigs = {
230
+ ...r.recommendationConfigs,
193
231
  ...t,
194
232
  currencySettings: {
195
- ...e.recommendationConfigs.currencySettings,
233
+ ...r.recommendationConfigs.currencySettings,
196
234
  ...t.currencySettings || {}
197
235
  }
198
236
  };
199
- const { triggerRefetch: n = !0 } = r;
237
+ const { triggerRefetch: n = !0 } = e;
200
238
  n && this.configVersion++;
201
239
  },
202
240
  /**
203
241
  * Creates a filter with the first available attribute and operator pre-selected.
204
242
  */
205
- createDefaultFilter(t, r) {
206
- const [e] = this.getFilterList, [n] = R(e == null ? void 0 : e.type);
243
+ createDefaultFilter(t, e) {
244
+ const [r] = this.getFilterList, [n] = R(r == null ? void 0 : r.type);
207
245
  return {
208
246
  type: "standardFilter",
209
- attribute: (e == null ? void 0 : e.value) ?? "",
247
+ attribute: (r == null ? void 0 : r.value) ?? "",
210
248
  operator: (n == null ? void 0 : n.value) ?? "",
211
249
  innerGroupOperator: "*",
212
250
  outerGroupOperator: "*",
213
- filterNumber: r,
251
+ filterNumber: e,
214
252
  filterGroup: t,
215
253
  isValid: !1,
216
254
  value: ""
@@ -255,43 +293,43 @@ const v = () => ({
255
293
  // ====================================================================
256
294
  async fetchRecommendationCreateData() {
257
295
  if (!this.activePredictiveAlgorithms.length) {
258
- if (m) {
259
- await m;
296
+ if (u) {
297
+ await u;
260
298
  return;
261
299
  }
262
- m = (async () => {
300
+ u = (async () => {
263
301
  const {
264
302
  activePredictiveAlgorithms: t,
265
- languages: r,
266
- currencies: e
303
+ languages: e,
304
+ currencies: r
267
305
  } = await h.fetchRecommendationCreateData();
268
- if (this.activePredictiveAlgorithms = t, this.languages = r, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
306
+ if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
269
307
  const n = this.blockStates[this.currentRecommendationId];
270
308
  n.filterStatus = !!n.recommendationConfigs.filters.length;
271
309
  }
272
- this.currencyList = e;
310
+ this.currencyList = r;
273
311
  })();
274
312
  try {
275
- await m;
313
+ await u;
276
314
  } finally {
277
- m = null;
315
+ u = null;
278
316
  }
279
317
  }
280
318
  },
281
319
  async fetchRecommendationFilters() {
282
320
  if (!Object.keys(this.filterList).length) {
283
- if (u) {
284
- await u;
321
+ if (m) {
322
+ await m;
285
323
  return;
286
324
  }
287
- u = (async () => {
325
+ m = (async () => {
288
326
  const t = await h.fetchRecommendationFilters();
289
327
  this.filterList = t;
290
328
  })();
291
329
  try {
292
- await u;
330
+ await m;
293
331
  } finally {
294
- u = null;
332
+ m = null;
295
333
  }
296
334
  }
297
335
  },
@@ -306,8 +344,8 @@ const v = () => ({
306
344
  deleteFilterGroup(t) {
307
345
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
308
346
  return;
309
- const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), n = [...new Set(e.map((i) => i.filterGroup))].sort((i, o) => i - o), c = new Map(n.map((i, o) => [i, o + 1]));
310
- r.recommendationConfigs.filters = e.map((i) => ({
347
+ 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]));
348
+ e.recommendationConfigs.filters = r.map((i) => ({
311
349
  ...i,
312
350
  filterGroup: c.get(i.filterGroup) ?? i.filterGroup
313
351
  }));
@@ -315,47 +353,47 @@ const v = () => ({
315
353
  updateFilter(t) {
316
354
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
317
355
  return;
318
- const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
319
- if (e !== -1) {
320
- const n = [...r.recommendationConfigs.filters];
321
- n[e] = {
356
+ const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
357
+ if (r !== -1) {
358
+ const n = [...e.recommendationConfigs.filters];
359
+ n[r] = {
322
360
  ...t,
323
- isValid: D(t)
324
- }, r.recommendationConfigs.filters = n;
361
+ isValid: w(t)
362
+ }, e.recommendationConfigs.filters = n;
325
363
  }
326
364
  },
327
365
  deleteFilter(t) {
328
366
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
329
367
  return;
330
- const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
331
- if (e !== -1) {
332
- let n = [...r.recommendationConfigs.filters];
333
- if (n.splice(e, 1), n.some((i) => i.filterGroup === t.filterGroup)) {
368
+ const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
369
+ if (r !== -1) {
370
+ let n = [...e.recommendationConfigs.filters];
371
+ if (n.splice(r, 1), n.some((i) => i.filterGroup === t.filterGroup)) {
334
372
  let i = 1;
335
373
  n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
336
374
  } else {
337
- const i = [...new Set(n.map((s) => s.filterGroup))].sort((s, l) => s - l), o = new Map(i.map((s, l) => [s, l + 1]));
375
+ const i = [...new Set(n.map((s) => s.filterGroup))].sort((s, a) => s - a), o = new Map(i.map((s, a) => [s, a + 1]));
338
376
  n = n.map((s) => ({
339
377
  ...s,
340
378
  filterGroup: o.get(s.filterGroup) ?? s.filterGroup
341
379
  }));
342
380
  }
343
- r.recommendationConfigs.filters = n;
381
+ e.recommendationConfigs.filters = n;
344
382
  }
345
383
  },
346
384
  addFilter(t) {
347
385
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
348
386
  return;
349
- const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters], c = e.filter(
387
+ const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters], c = r.filter(
350
388
  (o) => o.filterGroup === t.filterGroup
351
- ).length + 1, i = e.findLastIndex((o) => o.filterGroup === t.filterGroup);
352
- i !== -1 ? e.splice(i + 1, 0, {
389
+ ).length + 1, i = r.findLastIndex((o) => o.filterGroup === t.filterGroup);
390
+ i !== -1 ? r.splice(i + 1, 0, {
353
391
  ...t,
354
392
  filterNumber: c
355
- }) : e.push({
393
+ }) : r.push({
356
394
  ...t,
357
395
  filterNumber: c
358
- }), r.recommendationConfigs.filters = e;
396
+ }), e.recommendationConfigs.filters = r;
359
397
  },
360
398
  generateFilterQuery() {
361
399
  return b(this.recommendationConfigs.filters);
@@ -379,29 +417,31 @@ const v = () => ({
379
417
  },
380
418
  async _doFetchProducts() {
381
419
  var p;
382
- const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((a) => a.isValid), c = b(n), i = ((p = g.find((a) => a.key === e.strategy)) == null ? void 0 : p.path) || "", o = y(), s = {
383
- locale: e.language,
384
- currency: e.currencySettings.value,
420
+ const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = r.filters.filter((l) => l.isValid), c = b(n), i = ((p = S.find((l) => l.key === r.strategy)) == null ? void 0 : p.path) || "", o = G(), s = parseInt(r.size) || 6, a = {
421
+ locale: r.language,
422
+ currency: r.currencySettings.value,
385
423
  partnerName: o.partnerName,
386
- size: e.size,
424
+ size: r.size,
387
425
  details: !0,
388
426
  campaignId: o.variationId
389
427
  };
390
- e.strategy === "manualMerchandising" ? s.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (s.productId = "{itemId}"), e.strategy === "userBased" && (s.userId = "{user_id}"), c && (s.filter = c), e.shuffleProducts && (s.shuffle = !0);
391
- const l = parseInt(e.size) || 6;
428
+ r.strategy === "manualMerchandising" ? a.productId = r.productIds.slice(0, s).join(",") : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0);
392
429
  let f;
393
430
  try {
394
- f = await h.fetchRecommendationProducts(i, s);
431
+ f = await h.fetchRecommendationProducts(i, a);
395
432
  } catch {
396
433
  f = [];
397
434
  }
398
435
  if (this.blockStates[t]) {
399
- const a = f.length > 0 ? f : S(l);
400
- this.blockStates[t].recommendationProducts = a.length < l ? [...a, ...S(l - a.length)] : a;
436
+ const l = f.length > 0 ? f : g(s);
437
+ l.length < s ? this.blockStates[t].recommendationProducts = [
438
+ ...l,
439
+ ...g(s - l.length)
440
+ ] : l.length > s ? this.blockStates[t].recommendationProducts = l.slice(0, s) : this.blockStates[t].recommendationProducts = l;
401
441
  }
402
442
  }
403
443
  }
404
444
  });
405
445
  export {
406
- z as useRecommendationExtensionStore
446
+ _ as useRecommendationExtensionStore
407
447
  };
@@ -1,6 +1,6 @@
1
1
  import { DEFAULT_PRODUCTS_PER_ROW as L } from "../../constants/layout.js";
2
- import { DEFAULT_CARD_COMPOSITION as E, spacer as I, getDefaultProducts as _, createBlockTemplate as S, DEFAULTS as b, buildElementRenderer as A, DEFAULT_CARD_VISIBILITY as f } from "../utils.js";
3
- import { gridElementRenderer as w, ATTRIBUTE_CELL_CLASS as D, DEFAULT_CELL_PADDING as C } from "./elementRenderer.js";
2
+ import { getDefaultProducts as E, createBlockTemplate as I, DEFAULTS as _, DEFAULT_CARD_COMPOSITION as S, spacer as b, buildElementRenderer as A, DEFAULT_CARD_VISIBILITY as f } from "../utils.js";
3
+ import { ATTRIBUTE_CELL_CLASS as w, DEFAULT_CELL_PADDING as D, gridElementRenderer as C } from "./elementRenderer.js";
4
4
  const O = `
5
5
  <tr class="recommendation-product-row">
6
6
  <td>
@@ -27,8 +27,8 @@ const O = `
27
27
  {-{-CELLS-}-}
28
28
  </tr>
29
29
  `;
30
- function P(t, e, o, r = E, n = {}) {
31
- const c = (100 / e).toFixed(2), i = e - t.length, l = `<td class="${D}" style="padding: ${C};" width="${c}%"></td>`, d = i > 0 ? l.repeat(i) : "", a = A(o, r, n);
30
+ function P(t, e, o, r = S, n = {}) {
31
+ const c = (100 / e).toFixed(2), i = e - t.length, l = `<td class="${w}" style="padding: ${D};" width="${c}%"></td>`, d = i > 0 ? l.repeat(i) : "", a = A(o, r, n);
32
32
  return r.filter((s) => a[s]).map((s) => {
33
33
  const T = f[s] ?? !0, u = T ? "" : 'style="display: none;"', R = t.map((m) => a[s](m).replace("<td", `<td width="${c}%"`)).join("");
34
34
  return g.replace("{-{-ATTR_TYPE-}-}", s).replace("{-{-VISIBILITY-}-}", T ? "1" : "0").replace("{-{-DISPLAY_STYLE-}-}", u).replace("{-{-CELLS-}-}", R + d);
@@ -46,15 +46,15 @@ function U(t, e, o, r, n = {}) {
46
46
  r,
47
47
  n
48
48
  ), p = O.replace("{-{-ATTRIBUTE_ROWS-}-}", a);
49
- return d > 0 ? I + p : p;
49
+ return d > 0 ? b + p : p;
50
50
  }).join("");
51
51
  }
52
52
  function h(t, e, o, r = {}) {
53
- return U(t, e, w, o, r);
53
+ return U(t, e, C, o, r);
54
54
  }
55
55
  function F(t) {
56
- const e = t ? `ins-recommendation-v3-block-${t}` : void 0, o = S("grid", e), r = _(), n = h(r, L);
57
- return o.replace("{-{-TITLE-}-}", b.TITLE).replace("{-{-PRODUCT_ROWS-}-}", n).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", "");
56
+ const e = t ? `ins-recommendation-v3-block-${t}` : void 0, o = I("grid", e), r = E(), n = h(r, L);
57
+ return o.replace("{-{-TITLE-}-}", _.TITLE).replace("{-{-PRODUCT_ROWS-}-}", n).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", "");
58
58
  }
59
59
  export {
60
60
  F as getDefaultTemplate,
@@ -1,4 +1,4 @@
1
- import { ATTR_PRODUCT_IMAGE as m, ATTR_PRODUCT_NAME as b, ATTR_PRODUCT_OLD_PRICE as T, ATTR_PRODUCT_PRICE as _, ATTR_PRODUCT_OMNIBUS_PRICE as g, ATTR_PRODUCT_OMNIBUS_DISCOUNT as C, ATTR_PRODUCT_BUTTON as f, ATTR_CUSTOM_PREFIX as u } from "../constants/selectors.js";
1
+ import { ATTR_CUSTOM_PREFIX as u, ATTR_PRODUCT_IMAGE as m, ATTR_PRODUCT_NAME as b, ATTR_PRODUCT_OLD_PRICE as T, ATTR_PRODUCT_PRICE as _, ATTR_PRODUCT_OMNIBUS_PRICE as g, ATTR_PRODUCT_OMNIBUS_DISCOUNT as C, ATTR_PRODUCT_BUTTON as f } from "../constants/selectors.js";
2
2
  function U(t) {
3
3
  return t.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
4
4
  }
@@ -0,0 +1,21 @@
1
+ function r(e) {
2
+ if (!e)
3
+ return e;
4
+ switch (e) {
5
+ case "viewedTogether":
6
+ return "similarViewed";
7
+ case "purchasedTogether":
8
+ return "similarBought";
9
+ case "trending":
10
+ return "trendingProducts";
11
+ case "mostValuable":
12
+ return "mostValuableOfPartner";
13
+ case "topSellers":
14
+ return "mostPurchased";
15
+ default:
16
+ return e;
17
+ }
18
+ }
19
+ export {
20
+ r as mapLegacyStrategy
21
+ };