@useinsider/guido 3.7.0-beta.24bdfa3 → 3.7.0-beta.30ff65e

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 (40) hide show
  1. package/dist/@types/config/schemas.js +66 -70
  2. package/dist/composables/usePreviewMode.js +14 -15
  3. package/dist/config/compiler/utils/recommendationCompilerUtils.js +82 -90
  4. package/dist/config/migrator/recommendation/htmlBuilder.js +58 -59
  5. package/dist/config/migrator/recommendation/settingsMapper.js +33 -38
  6. package/dist/extensions/Blocks/Recommendation/block.js +43 -59
  7. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +32 -41
  8. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +313 -377
  9. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +72 -84
  10. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +66 -68
  11. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +7 -21
  12. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +4 -64
  13. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +5 -7
  14. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +72 -101
  15. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -31
  16. package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -9
  17. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +59 -74
  18. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -21
  19. package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -88
  20. package/dist/src/@types/config/schemas.d.ts +0 -16
  21. package/dist/src/composables/useConfig.d.ts +0 -4
  22. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
  23. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -10
  24. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -29
  25. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
  26. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +1 -3
  27. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -2
  28. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +0 -16
  29. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  30. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +0 -13
  31. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +2 -3
  32. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -33
  33. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -15
  34. package/dist/src/stores/config.d.ts +0 -36
  35. package/package.json +1 -1
  36. package/dist/composables/useRecommendationPreview.js +0 -100
  37. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +0 -133
  38. package/dist/src/composables/useRecommendationPreview.d.ts +0 -10
  39. package/dist/src/composables/useRecommendationPreview.test.d.ts +0 -1
  40. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +0 -59
@@ -1,5 +1,5 @@
1
1
  import { ModuleFolderDefaults as S } from "../../enums/defaults.js";
2
- import { object as a, number as s, optional as e, string as t, picklist as l, pipe as p, minLength as b, custom as h, boolean as o, array as c, record as k, literal as i, looseObject as y, variant as g, union as f, unknown as n } from "../../node_modules/valibot/dist/index.js";
2
+ import { object as o, number as n, optional as e, string as t, picklist as l, pipe as p, minLength as b, custom as h, boolean as a, array as c, record as k, literal as i, looseObject as y, variant as g, union as f, unknown as s } from "../../node_modules/valibot/dist/index.js";
3
3
  const d = {
4
4
  /** Promotional/marketing emails */
5
5
  PROMOTIONAL: 1,
@@ -12,7 +12,7 @@ const d = {
12
12
  ARCHITECT: 49,
13
13
  /** Unsubscribe page builder */
14
14
  UNSUBSCRIBE_PAGES: 97
15
- }, R = a({
15
+ }, R = o({
16
16
  /** Unique identifier for the template being edited */
17
17
  templateId: p(
18
18
  t(),
@@ -25,12 +25,12 @@ const d = {
25
25
  ),
26
26
  /** Optional variation ID for A/B testing */
27
27
  variationId: e(t())
28
- }), T = a({
28
+ }), C = o({
29
29
  /** Fallback font name (e.g., "Georgia") */
30
30
  name: t(),
31
31
  /** Fallback font family (e.g., "serif" or "sans-serif") */
32
32
  family: t()
33
- }), C = a({
33
+ }), T = o({
34
34
  /** Partner/organization name (required) */
35
35
  name: p(
36
36
  t(),
@@ -53,8 +53,8 @@ const d = {
53
53
  /** Display name for the current user */
54
54
  username: e(t(), "Guido User"),
55
55
  /** Fallback font settings from partner settings — used to match backend size calculation */
56
- fallbackFont: e(T)
57
- }), A = a({
56
+ fallbackFont: e(C)
57
+ }), A = o({
58
58
  /** Display text for the dynamic content */
59
59
  text: t(),
60
60
  /** Template variable value (e.g., {{username}}) */
@@ -63,57 +63,53 @@ const d = {
63
63
  fallback: e(t()),
64
64
  /** Optional formatting options */
65
65
  format: e(
66
- a({
66
+ o({
67
67
  key: t(),
68
68
  value: t()
69
69
  })
70
70
  )
71
71
  }), I = y({
72
72
  /** Block ID (matches the dictionary key and the legacy HTML element id) */
73
- id: e(s()),
73
+ id: e(n()),
74
74
  /** Decimal places for price display (legacy data may use string or number) */
75
- decimalCount: e(f([t(), s()])),
75
+ decimalCount: e(f([t(), n()])),
76
76
  /** Pinned product IDs (empty array when filter-driven) */
77
- productIds: e(c(n())),
77
+ productIds: e(c(s())),
78
78
  /** Whether the block requested live products at send time */
79
- sendProductRequestFlag: e(o()),
79
+ sendProductRequestFlag: e(a()),
80
80
  /** Whether to randomize product order */
81
- shuffleProducts: e(o()),
81
+ shuffleProducts: e(a()),
82
82
  /** Filter rules driving product selection */
83
- filters: e(c(n())),
83
+ filters: e(c(s())),
84
84
  /** Currency code (e.g. 'EUR') — sometimes absent in legacy data */
85
85
  currency: e(t()),
86
86
  /** Currency display settings (separators, alignment, decimals) */
87
- currencySettings: e(n()),
87
+ currencySettings: e(s()),
88
88
  /** Locale (e.g. 'nl_NL') */
89
89
  language: e(t()),
90
90
  /** Recommendation strategy key (e.g. 'newArrivals') */
91
91
  strategy: e(t()),
92
92
  /** Snapshot of products as rendered by the legacy block */
93
- recommendedProducts: e(c(n())),
93
+ recommendedProducts: e(c(s())),
94
94
  /** Number of product cards per row */
95
- cardsInRow: e(s()),
95
+ cardsInRow: e(n()),
96
96
  /** Mobile-only padding (right) */
97
- mobileRightPadding: e(s()),
97
+ mobileRightPadding: e(n()),
98
98
  /** Mobile-only padding (left) */
99
- mobileLeftPadding: e(s()),
99
+ mobileLeftPadding: e(n()),
100
100
  /** Disable responsive scaling */
101
- unresponsive: e(o()),
101
+ unresponsive: e(a()),
102
102
  /** Layout orientation ('vertical' | 'horizontal') */
103
103
  orientation: e(t()),
104
104
  /** Whether long text is trimmed */
105
- textTrimming: e(o()),
105
+ textTrimming: e(a()),
106
106
  /** Block type marker used by some legacy variants */
107
107
  blockType: e(t()),
108
108
  /** Size variant marker (legacy data may use string or number) */
109
- size: e(f([t(), s()])),
109
+ size: e(f([t(), n()])),
110
110
  /** Vertical responsiveness flag (legacy size=1 variants) */
111
- verticalResponsiveness: e(o()),
112
- /** Legacy "Move to next line" price placement toggle (cardPricePlacement.js) */
113
- isPriceMovedToNextLine: e(o()),
114
- /** Legacy "Hide if same as discounted" / delete-price-for-zero-sale toggle */
115
- isPriceDeletedForZeroSale: e(o())
116
- }), L = a({
111
+ verticalResponsiveness: e(a())
112
+ }), E = o({
117
113
  /**
118
114
  * Legacy recommendation block configs keyed by block ID.
119
115
  * Pass this when loading a template authored with the v1
@@ -124,7 +120,7 @@ const d = {
124
120
  k(t(), I),
125
121
  {}
126
122
  )
127
- }), P = a({
123
+ }), L = o({
128
124
  /** Initial HTML content */
129
125
  html: e(t(), ""),
130
126
  /** Initial CSS content */
@@ -137,53 +133,53 @@ const d = {
137
133
  /** Valid custom field attribute names from the partner's categorized fields */
138
134
  customFieldAttributes: e(c(t()), []),
139
135
  /** Selected unsubscribe page IDs */
140
- selectedUnsubscribePages: e(c(s()), []),
136
+ selectedUnsubscribePages: e(c(n()), []),
141
137
  /** Force recreate template in Stripo storage (use true when updating externally modified templates) */
142
- forceRecreate: e(o(), !1),
138
+ forceRecreate: e(a(), !1),
143
139
  /** Migration-only inputs (legacy block configs) */
144
- migration: e(L, {})
145
- }), v = a({
140
+ migration: e(E, {})
141
+ }), O = o({
146
142
  /** Sender display name */
147
143
  senderName: e(t(), ""),
148
144
  /** Email subject line */
149
145
  subject: e(t(), "")
150
- }), E = a({
146
+ }), v = o({
151
147
  /** Locale for the editor UI */
152
148
  locale: e(t(), "en"),
153
149
  /** Path to translations object */
154
150
  translationsPath: e(t(), "window.trans[Object.keys(window.trans)[0]]"),
155
151
  /** Migration date for template compatibility */
156
- migrationDate: e(s(), 1759696858),
152
+ migrationDate: e(n(), 1759696858),
157
153
  /** Email header settings */
158
- emailHeader: e(v, { senderName: "", subject: "" }),
154
+ emailHeader: e(O, { senderName: "", subject: "" }),
159
155
  /** Folder name for user-saved modules (used by Stripo plugin panel for path construction) */
160
156
  savedModulesFolderName: e(t(), S.SAVED_MODULES),
161
157
  /** Folder name for default/prebuilt modules (used by Stripo plugin panel for path construction) */
162
158
  defaultModulesFolderName: e(t(), S.DEFAULT_MODULES)
163
- }), M = a({
159
+ }), M = o({
164
160
  /** Whether to show the header bar */
165
- showHeader: e(o(), !0),
161
+ showHeader: e(a(), !0),
166
162
  /** Custom label for back button (if shown) */
167
163
  backButtonLabel: e(t())
168
- }), O = a({
164
+ }), P = o({
169
165
  /** Enable dynamic content insertion */
170
- dynamicContent: e(o(), !0),
166
+ dynamicContent: e(a(), !0),
171
167
  /** Enable save as template functionality */
172
- saveAsTemplate: e(o(), !0),
168
+ saveAsTemplate: e(a(), !0),
173
169
  /** Enable version history */
174
- versionHistory: e(o(), !0),
170
+ versionHistory: e(a(), !0),
175
171
  /** Enable test message sending */
176
- testMessage: e(o(), !0),
172
+ testMessage: e(a(), !0),
177
173
  /** Enable display conditions */
178
- displayConditions: e(o(), !0),
174
+ displayConditions: e(a(), !0),
179
175
  /** Enable unsubscribe block */
180
- unsubscribe: e(o(), !0),
176
+ unsubscribe: e(a(), !0),
181
177
  /** Disable modules panel in the editor */
182
- modulesDisabled: e(o(), !1),
178
+ modulesDisabled: e(a(), !1),
183
179
  /** Enable Liquid template syntax */
184
- liquidSyntax: e(o(), !1),
180
+ liquidSyntax: e(a(), !1),
185
181
  /** Enable autosave (3-min interval + tab-hide). User toggles on/off from the header. */
186
- autosave: e(o(), !1)
182
+ autosave: e(a(), !1)
187
183
  }), N = l([
188
184
  "amp-accordion",
189
185
  "amp-carousel",
@@ -206,7 +202,7 @@ const d = {
206
202
  "unsubscribe-block",
207
203
  "coupon-block",
208
204
  "items-block"
209
- ]), x = a({
205
+ ]), x = o({
210
206
  /** Default blocks to exclude from the editor */
211
207
  excludeDefaults: e(
212
208
  c(N),
@@ -217,14 +213,14 @@ const d = {
217
213
  c(D),
218
214
  []
219
215
  )
220
- }), m = a({
216
+ }), m = o({
221
217
  /** Unique identifier for the rule */
222
218
  id: t(),
223
219
  /** Human-readable description */
224
220
  description: e(t()),
225
221
  /** Priority for rule ordering (lower = earlier) */
226
- priority: s()
227
- }), F = a({
222
+ priority: n()
223
+ }), F = o({
228
224
  ...m.entries,
229
225
  type: i("replace"),
230
226
  /** String to search for */
@@ -232,8 +228,8 @@ const d = {
232
228
  /** Replacement string */
233
229
  replacement: t(),
234
230
  /** Replace all occurrences (default: false) */
235
- replaceAll: e(o())
236
- }), U = a({
231
+ replaceAll: e(a())
232
+ }), U = o({
237
233
  ...m.entries,
238
234
  type: i("regex"),
239
235
  /** Regex pattern string */
@@ -242,12 +238,12 @@ const d = {
242
238
  replacement: t(),
243
239
  /** Regex flags (e.g., 'gi') */
244
240
  flags: e(t())
245
- }), B = a({
241
+ }), B = o({
246
242
  ...m.entries,
247
243
  type: i("remove"),
248
244
  /** Strings or patterns to remove */
249
245
  targets: c(t())
250
- }), w = a({
246
+ }), w = o({
251
247
  ...m.entries,
252
248
  type: i("custom"),
253
249
  /** Custom processor function */
@@ -260,12 +256,12 @@ const d = {
260
256
  U,
261
257
  B,
262
258
  w
263
- ]), j = a({
259
+ ]), j = o({
264
260
  /** Custom compiler rules to apply */
265
261
  customRules: e(c(H), []),
266
262
  /** Skip default compiler rules */
267
- ignoreDefaultRules: e(o(), !1)
268
- }), q = a({
263
+ ignoreDefaultRules: e(a(), !1)
264
+ }), q = o({
269
265
  /**
270
266
  * External validation handler called before save completes.
271
267
  * Return false to cancel the save operation.
@@ -276,21 +272,21 @@ const d = {
276
272
  "externalValidation must be a function"
277
273
  )
278
274
  )
279
- }), V = a({
275
+ }), V = o({
280
276
  // Required sections
281
277
  /** Identity configuration (required) */
282
278
  identity: R,
283
279
  /** Partner configuration (required) */
284
- partner: C,
280
+ partner: T,
285
281
  // Optional sections (with defaults)
286
282
  /** Template content and presets */
287
- template: e(P, {}),
283
+ template: e(L, {}),
288
284
  /** Editor settings */
289
- editor: e(E, {}),
285
+ editor: e(v, {}),
290
286
  /** UI configuration */
291
287
  ui: e(M, {}),
292
288
  /** Feature toggles */
293
- features: e(O, {}),
289
+ features: e(P, {}),
294
290
  /** Block configuration */
295
291
  blocks: e(x, {}),
296
292
  /** Compiler configuration */
@@ -307,20 +303,20 @@ export {
307
303
  w as CustomRuleSchema,
308
304
  N as DefaultBlockTypeSchema,
309
305
  A as DynamicContentSchema,
310
- E as EditorSchema,
311
- v as EmailHeaderSchema,
312
- T as FallbackFontSchema,
313
- O as FeaturesSchema,
306
+ v as EditorSchema,
307
+ O as EmailHeaderSchema,
308
+ C as FallbackFontSchema,
309
+ P as FeaturesSchema,
314
310
  V as GuidoConfigSchema,
315
311
  R as IdentitySchema,
316
312
  I as LegacyRecommendationConfigSchema,
317
313
  d as MessageType,
318
- C as PartnerSchema,
314
+ T as PartnerSchema,
319
315
  r as ProductType,
320
316
  U as RegexRuleSchema,
321
317
  B as RemoveRuleSchema,
322
318
  F as ReplaceRuleSchema,
323
- L as TemplateMigrationSchema,
324
- P as TemplateSchema,
319
+ E as TemplateMigrationSchema,
320
+ L as TemplateSchema,
325
321
  M as UISchema
326
322
  };
@@ -1,29 +1,28 @@
1
- import { useEditorStore as n } from "../stores/editor.js";
2
- import { usePreviewStore as p } from "../stores/preview.js";
3
- import { useActionsApi as c } from "./useActionsApi.js";
4
- import { useCodeEditorApi as u } from "./useCodeEditorApi.js";
5
- import { useHtmlCompiler as v } from "./useHtmlCompiler.js";
6
- import { useRecommendationPreview as w } from "./useRecommendationPreview.js";
7
- const C = () => {
8
- const t = n(), e = p(), { closeCodeEditor: a } = u(), { getPreviewData: m, getCompiledEmail: s } = c(), { compileHtml: l } = v(), { substituteRecommendationPreview: r } = w(), i = () => {
1
+ import { useEditorStore as d } from "../stores/editor.js";
2
+ import { usePreviewStore as n } from "../stores/preview.js";
3
+ import { useActionsApi as p } from "./useActionsApi.js";
4
+ import { useCodeEditorApi as c } from "./useCodeEditorApi.js";
5
+ import { useHtmlCompiler as u } from "./useHtmlCompiler.js";
6
+ const g = () => {
7
+ const t = d(), e = n(), { closeCodeEditor: i } = c(), { getPreviewData: a, getCompiledEmail: s } = p(), { compileHtml: m } = u(), r = () => {
9
8
  t.isPreviewModeOpen = !1, e.$reset();
10
9
  };
11
10
  return {
12
- closePreviewMode: i,
11
+ closePreviewMode: r,
13
12
  openPreviewMode: () => {
14
- t.isCodeEditorOpen && a(), t.isPreviewModeOpen = !0;
13
+ t.isCodeEditorOpen && i(), t.isPreviewModeOpen = !0;
15
14
  },
16
15
  loadPreviewData: async () => {
17
16
  if (!(t.loadingStatus || e.isLoaded)) {
18
17
  t.loadingStatus = !0;
19
18
  try {
20
- const [o, d] = await Promise.all([
21
- m(),
19
+ const [o, l] = await Promise.all([
20
+ a(),
22
21
  s({ minimize: !0, resetDataSavedFlag: !1 })
23
22
  ]);
24
- e.templateHtml = r(o.html || ""), e.ampHtml = r(o.ampHtml || ""), e.ampErrors = o.ampErrors || [], e.setEmailFormat(o.ampHtml ? "AMP" : "html"), e.emailSizeKB = l(d.html).estimatedSizeKB, e.isLoaded = !0;
23
+ e.templateHtml = o.html || "", e.ampHtml = o.ampHtml || "", e.ampErrors = o.ampErrors || [], e.setEmailFormat(o.ampHtml ? "AMP" : "html"), e.emailSizeKB = m(l.html).estimatedSizeKB, e.isLoaded = !0;
25
24
  } catch (o) {
26
- console.error("Failed to load preview data:", o), i();
25
+ console.error("Failed to load preview data:", o), r();
27
26
  } finally {
28
27
  t.loadingStatus = !1;
29
28
  }
@@ -32,5 +31,5 @@ const C = () => {
32
31
  };
33
32
  };
34
33
  export {
35
- C as usePreviewMode
34
+ g as usePreviewMode
36
35
  };
@@ -1,159 +1,151 @@
1
- import { useConfig as _ } from "../../../composables/useConfig.js";
2
- import { useRecommendation as g } from "../../../composables/useRecommendation.js";
1
+ import { useConfig as g } from "../../../composables/useConfig.js";
2
+ import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
3
3
  import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
4
  import { useRecommendationExtensionStore as C } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
- function b(r, n, t, o, s = "") {
6
- const c = `{{${s}${r}_${n}_${t}}}`, e = `{{${s}${r}_${n}_currency}}`;
7
- return o === "before" ? `${e} ${c}` : `${c} ${e}`;
5
+ function y(r, n, e, o, i = "") {
6
+ const c = `{{${i}${r}_${n}_${e}}}`, t = `{{${i}${r}_${n}_currency}}`;
7
+ return o === "before" ? `${t} ${c}` : `${c} ${t}`;
8
8
  }
9
- function f(r) {
9
+ function A(r) {
10
10
  let n = r;
11
11
  for (; n.children.length === 1; )
12
12
  [n] = n.children;
13
13
  return n;
14
14
  }
15
- function h(r, n, t, o, s, c) {
15
+ function f(r, n, e, o, i, c) {
16
16
  switch (n) {
17
17
  case "productImage": {
18
- const e = r.querySelector("img");
19
- e && (e.setAttribute("src", `{{${c}${t}_${o}_image_url}}`), e.setAttribute("alt", `{{${c}${t}_${o}_name}}`));
20
- const i = r.querySelector("a");
21
- i && (i.setAttribute("href", `{{${c}${t}_${o}_url}}`), i.classList.add(q));
18
+ const t = r.querySelector("img");
19
+ t && (t.setAttribute("src", `{{${c}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${c}${e}_${o}_name}}`));
20
+ const s = r.querySelector("a");
21
+ s && (s.setAttribute("href", `{{${c}${e}_${o}_url}}`), s.classList.add(q));
22
22
  break;
23
23
  }
24
24
  case "productName": {
25
- const e = r.querySelector("p");
26
- if (e) {
27
- const i = e.querySelector("strong") || e;
28
- i.textContent = `{{${c}${t}_${o}_name}}`;
25
+ const t = r.querySelector("p");
26
+ if (t) {
27
+ const s = t.querySelector("strong") || t;
28
+ s.textContent = `{{${c}${e}_${o}_name}}`;
29
29
  }
30
30
  break;
31
31
  }
32
32
  case "productPrice": {
33
- const e = r.querySelector(".product-price p") ?? r.querySelector("p");
34
- e && (f(e).textContent = b(
35
- t,
33
+ const t = r.querySelector("p");
34
+ t && (A(t).textContent = y(
35
+ e,
36
36
  o,
37
37
  "price",
38
- s,
39
- c
40
- ));
41
- const i = r.querySelector(".product-old-price p");
42
- i && (f(i).textContent = b(
43
- t,
44
- o,
45
- "original_price",
46
- s,
38
+ i,
47
39
  c
48
40
  ));
49
41
  break;
50
42
  }
51
43
  case "productOldPrice": {
52
- const e = r.querySelector("p");
53
- e && (f(e).textContent = b(
54
- t,
44
+ const t = r.querySelector("p");
45
+ t && (A(t).textContent = y(
46
+ e,
55
47
  o,
56
48
  "original_price",
57
- s,
49
+ i,
58
50
  c
59
- ));
51
+ ), t.setAttribute("product-attr", "discount"));
60
52
  break;
61
53
  }
62
54
  case "productButton": {
63
- const e = r.querySelector("a");
64
- e && e.setAttribute("href", `{{${c}${t}_${o}_url}}`);
55
+ const t = r.querySelector("a");
56
+ t && t.setAttribute("href", `{{${c}${e}_${o}_url}}`);
65
57
  break;
66
58
  }
67
59
  case "productOmnibusPrice": {
68
- const e = r.querySelector(".omnibus-price-value");
69
- if (e) {
70
- e.textContent = `{{${c}${t}_${o}_omnibus_price}}`;
71
- const i = e.closest("p");
72
- i && (i.setAttribute("product-attr", "omnibus_price"), i.setAttribute("composition", "true"));
60
+ const t = r.querySelector(".omnibus-price-value");
61
+ if (t) {
62
+ t.textContent = `{{${c}${e}_${o}_omnibus_price}}`;
63
+ const s = t.closest("p");
64
+ s && (s.setAttribute("product-attr", "omnibus_price"), s.setAttribute("composition", "true"));
73
65
  }
74
66
  break;
75
67
  }
76
68
  case "productOmnibusDiscount": {
77
- const e = r.querySelector(".omnibus-discount-value");
78
- if (e) {
79
- e.textContent = `{{${c}${t}_${o}_omnibus_discount}}`;
80
- const i = e.closest("p");
81
- i && (i.setAttribute("product-attr", "omnibus_discount"), i.setAttribute("composition", "true"));
69
+ const t = r.querySelector(".omnibus-discount-value");
70
+ if (t) {
71
+ t.textContent = `{{${c}${e}_${o}_omnibus_discount}}`;
72
+ const s = t.closest("p");
73
+ s && (s.setAttribute("product-attr", "omnibus_discount"), s.setAttribute("composition", "true"));
82
74
  }
83
75
  break;
84
76
  }
85
77
  default: {
86
- const e = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
87
- if (e) {
88
- const i = e.getAttribute("product-attr"), a = e.querySelector("p");
78
+ const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
79
+ if (t) {
80
+ const s = t.getAttribute("product-attr"), a = t.querySelector("p");
89
81
  if (a) {
90
82
  const u = a.querySelector("strong") || a;
91
- u.textContent = `{{${c}${t}_${o}_${i}}}`;
83
+ u.textContent = `{{${c}${e}_${o}_${s}}}`;
92
84
  }
93
85
  }
94
86
  break;
95
87
  }
96
88
  }
97
89
  }
98
- function w(r, n, t, o) {
99
- r.querySelectorAll(".recommendation-product-row").forEach((c, e) => {
90
+ function w(r, n, e, o) {
91
+ r.querySelectorAll(".recommendation-product-row").forEach((c, t) => {
100
92
  c.querySelectorAll("[data-attribute-type]").forEach((a) => {
101
93
  const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
102
94
  p.length > 0 ? p.forEach((l) => {
103
- h(l, u, n, e, t, o);
104
- }) : h(a, u, n, e, t, o);
95
+ f(l, u, n, t, e, o);
96
+ }) : f(a, u, n, t, e, o);
105
97
  });
106
98
  });
107
99
  }
108
- function E(r, n, t, o) {
109
- const s = r.querySelectorAll(".recommendation-product-row");
110
- if (!s.length)
100
+ function E(r, n, e, o) {
101
+ const i = r.querySelectorAll(".recommendation-product-row");
102
+ if (!i.length)
111
103
  return;
112
- const [c] = s, e = c.querySelector("[data-attribute-type]"), i = e ? e.querySelectorAll(".attribute-cell").length : 1;
113
- s.forEach((a, u) => {
104
+ const [c] = i, t = c.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
105
+ i.forEach((a, u) => {
114
106
  a.querySelectorAll("[data-attribute-type]").forEach((l) => {
115
107
  const d = l.getAttribute("data-attribute-type") || "";
116
- l.querySelectorAll(".attribute-cell").forEach((A, $) => {
117
- const S = u * i + $;
118
- h(A, d, n, S, t, o);
108
+ l.querySelectorAll(".attribute-cell").forEach((h, $) => {
109
+ const S = u * s + $;
110
+ f(h, d, n, S, e, o);
119
111
  });
120
112
  });
121
113
  });
122
114
  }
123
- function P(r, n, t, o) {
115
+ function R(r, n, e, o) {
124
116
  r.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
125
- E(c, n, t, o);
117
+ E(c, n, e, o);
126
118
  });
127
119
  }
128
- function R(r, n, t) {
129
- const o = r.getAttribute("data-layout") || "grid", s = r.getAttribute("currency-alignment") || "after";
130
- o === "list" ? w(r, n, s, t) : P(r, n, s, t);
120
+ function P(r, n, e) {
121
+ const o = r.getAttribute("data-layout") || "grid", i = r.getAttribute("currency-alignment") || "after";
122
+ o === "list" ? w(r, n, i, e) : R(r, n, i, e);
131
123
  }
132
- function y(r, n, t) {
133
- const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), s = r.match(o);
134
- return s ? parseInt(s[1]) : t;
124
+ function b(r, n, e) {
125
+ const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), i = r.match(o);
126
+ return i ? parseInt(i[1]) : e;
135
127
  }
136
- function O(r, n) {
137
- let t = r.parentElement;
138
- for (; t && t !== n; ) {
139
- if (t.tagName === "TD") {
140
- const o = t.getAttribute("width");
128
+ function T(r, n) {
129
+ let e = r.parentElement;
130
+ for (; e && e !== n; ) {
131
+ if (e.tagName === "TD") {
132
+ const o = e.getAttribute("width");
141
133
  if (o && o.endsWith("%") && parseFloat(o) < 100)
142
- return t;
134
+ return e;
143
135
  }
144
- t = t.parentElement;
136
+ e = e.parentElement;
145
137
  }
146
138
  return null;
147
139
  }
148
- function T(r) {
149
- const n = r.getAttribute("style") || "", t = y(n, "width", 600), o = y(n, "padding", 0) * 2, s = Math.max(0, t - o);
150
- s !== 0 && r.querySelectorAll("img.adapt-img").forEach((c) => {
140
+ function v(r) {
141
+ const n = r.getAttribute("style") || "", e = b(n, "width", 600), o = b(n, "padding", 0) * 2, i = Math.max(0, e - o);
142
+ i !== 0 && r.querySelectorAll("img.adapt-img").forEach((c) => {
151
143
  if (c.hasAttribute("width"))
152
144
  return;
153
- const e = O(c, r);
154
- if (!e)
145
+ const t = T(c, r);
146
+ if (!t)
155
147
  return;
156
- const i = e.getAttribute("width"), a = parseFloat(i), u = y(e.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(s * a / 100), l = Math.max(1, p - u);
148
+ const s = t.getAttribute("width"), a = parseFloat(s), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(i * a / 100), l = Math.max(1, p - u);
157
149
  c.setAttribute("width", String(l));
158
150
  const d = c.getAttribute("style") || "";
159
151
  if (!/\bwidth\s*:\s*\d/i.test(d)) {
@@ -162,25 +154,25 @@ function T(r) {
162
154
  }
163
155
  });
164
156
  }
165
- function v(r, n) {
166
- const t = r.match(/<!DOCTYPE[^>]*>/i);
167
- return (t ? `${t[0]}
157
+ function O(r, n) {
158
+ const e = r.match(/<!DOCTYPE[^>]*>/i);
159
+ return (e ? `${e[0]}
168
160
  ` : "") + n.documentElement.outerHTML;
169
161
  }
170
162
  function N(r) {
171
- const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), t = new DOMParser().parseFromString(n, "text/html"), o = t.querySelectorAll(".recommendation-block-v2");
163
+ const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
172
164
  if (!o.length)
173
165
  return r;
174
- const { buildCampaignUrl: s } = g(), c = C();
166
+ const { buildCampaignUrl: i } = _(), c = C();
175
167
  c.recommendationCampaignUrls = {};
176
- const { isFeatureEnabled: e } = _(), i = e("liquidSyntax") ? "reco_" : "";
168
+ const { isFeatureEnabled: t } = g(), s = t("liquidSyntax") ? "reco_" : "";
177
169
  return o.forEach((u) => {
178
170
  var l, d;
179
171
  const p = u.getAttribute("recommendation-id");
180
- p && ((l = u.parentNode) == null || l.insertBefore(t.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(t.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), s(p), R(u, p, i), T(u));
181
- }), v(n, t).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
172
+ p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), i(p), P(u, p, s), v(u));
173
+ }), O(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
182
174
  }
183
175
  export {
184
- b as formatPriceVariable,
176
+ y as formatPriceVariable,
185
177
  N as prepareRecommendationBlocks
186
178
  };