@builder.io/sdk-react 3.0.5 → 3.0.7

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 (81) hide show
  1. package/lib/browser/blocks-exports.cjs +167 -30
  2. package/lib/browser/blocks-exports.mjs +1370 -931
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +17 -16
  5. package/lib/{edge/server-entry-67bfc740.js → browser/server-entry-20c79b90.js} +319 -274
  6. package/lib/browser/server-entry-762e29e0.cjs +2 -0
  7. package/lib/browser/server-entry.cjs +1 -1
  8. package/lib/browser/server-entry.mjs +1 -1
  9. package/lib/edge/{accordion-190c4426.cjs → accordion-071aa4f9.cjs} +1 -1
  10. package/lib/edge/{accordion-cd6e0363.js → accordion-22c2c037.js} +1 -1
  11. package/lib/edge/{blocks-fe2d7c1a.js → blocks-2989e629.js} +1343 -1318
  12. package/lib/edge/blocks-d3f37507.cjs +30 -0
  13. package/lib/edge/blocks-exports.cjs +1 -1
  14. package/lib/edge/blocks-exports.mjs +13 -12
  15. package/lib/edge/{button-6a27481c.js → button-2b5270c4.js} +2 -2
  16. package/lib/edge/{button-694fcd4f.cjs → button-a2cc6565.cjs} +1 -1
  17. package/lib/edge/{columns-90e6407e.js → columns-21b9be25.js} +3 -3
  18. package/lib/edge/{columns-b38bf0f7.cjs → columns-b7240242.cjs} +1 -1
  19. package/lib/edge/{content-variants-cbb89349.js → content-variants-88f4dc64.js} +165 -124
  20. package/lib/edge/content-variants-fdd5ee50.cjs +134 -0
  21. package/lib/edge/dynamic-blocks-exports.cjs +3 -1
  22. package/lib/edge/dynamic-blocks-exports.mjs +5 -2
  23. package/lib/edge/{form-547645eb.cjs → form-77687883.cjs} +1 -1
  24. package/lib/edge/{form-16bbf874.js → form-d29f3cc0.js} +3 -3
  25. package/lib/edge/{get-class-prop-name-8b719c6b.js → get-class-prop-name-dbc5d99c.js} +1 -1
  26. package/lib/edge/{get-class-prop-name-58770197.cjs → get-class-prop-name-f597545d.cjs} +1 -1
  27. package/lib/edge/{img-8859c851.cjs → img-03f9002b.cjs} +1 -1
  28. package/lib/edge/{img-d3351743.js → img-fed70928.js} +1 -1
  29. package/lib/edge/index.cjs +1 -1
  30. package/lib/edge/index.mjs +18 -17
  31. package/lib/edge/{input-24c601b4.js → input-083c3c35.js} +1 -1
  32. package/lib/edge/{input-4fe0fc6d.cjs → input-1e548fd0.cjs} +1 -1
  33. package/lib/edge/personalization-container-bcff3433.js +384 -0
  34. package/lib/edge/personalization-container-dde10a09.cjs +138 -0
  35. package/lib/edge/{select-c73bd418.cjs → select-21e33225.cjs} +1 -1
  36. package/lib/edge/{select-af05377b.js → select-9f22c2ba.js} +1 -1
  37. package/lib/{browser/server-entry-785c0408.js → edge/server-entry-43a6f5be.js} +339 -298
  38. package/lib/edge/server-entry-ac35a5c8.cjs +2 -0
  39. package/lib/edge/server-entry.cjs +1 -1
  40. package/lib/edge/server-entry.mjs +1 -1
  41. package/lib/edge/{slot-759c8dd9.cjs → slot-a9f5d6c0.cjs} +1 -1
  42. package/lib/edge/{slot-32a4df0c.js → slot-ca171e8c.js} +3 -3
  43. package/lib/edge/{symbol-50360a37.js → symbol-8f6ff028.js} +2 -2
  44. package/lib/edge/{symbol-8d63aa7d.cjs → symbol-a2015c7e.cjs} +1 -1
  45. package/lib/edge/{tabs-6535c934.js → tabs-6b67fca2.js} +3 -3
  46. package/lib/edge/{tabs-fc6c1700.cjs → tabs-880c9088.cjs} +1 -1
  47. package/lib/node/blocks-exports.cjs +168 -31
  48. package/lib/node/blocks-exports.mjs +1343 -904
  49. package/lib/node/index.cjs +1 -1
  50. package/lib/node/index.mjs +17 -16
  51. package/lib/node/init.cjs +1 -1
  52. package/lib/node/init.mjs +3 -3
  53. package/lib/node/server-entry-0b433783.cjs +2 -0
  54. package/lib/node/{server-entry-ffc70868.js → server-entry-6626257d.js} +280 -237
  55. package/lib/node/server-entry.cjs +1 -1
  56. package/lib/node/server-entry.mjs +1 -1
  57. package/lib/node/{setIvm-4ce0db03.cjs → setIvm-49abbae6.cjs} +1 -1
  58. package/lib/node/{setIvm-2cea7252.js → setIvm-5cb298bf.js} +1 -1
  59. package/lib/node/setIvm.cjs +1 -1
  60. package/lib/node/setIvm.mjs +2 -2
  61. package/lib/node/{should-force-browser-runtime-in-node-d3e6df07.cjs → should-force-browser-runtime-in-node-11e8399e.cjs} +1 -1
  62. package/lib/node/{should-force-browser-runtime-in-node-c0d50009.js → should-force-browser-runtime-in-node-94f1a5b3.js} +1 -1
  63. package/package.json +1 -1
  64. package/types/blocks/personalization-container/component-info.d.ts +2 -0
  65. package/types/blocks/personalization-container/helpers/inlined-fns.d.ts +8 -0
  66. package/types/blocks/personalization-container/helpers.d.ts +27 -0
  67. package/types/blocks/personalization-container/index.d.ts +1 -0
  68. package/types/blocks/personalization-container/personalization-container.d.ts +4 -0
  69. package/types/blocks/personalization-container/personalization-container.types.d.ts +14 -0
  70. package/types/constants/device-sizes.d.ts +3 -2
  71. package/types/constants/sdk-version.d.ts +1 -1
  72. package/types/helpers/user-attributes.d.ts +17 -0
  73. package/types/index-helpers/blocks-exports.d.ts +1 -0
  74. package/types/types/builder-block.d.ts +0 -1
  75. package/types/types/builder-content.d.ts +1 -0
  76. package/types/types/input.d.ts +1 -0
  77. package/lib/browser/server-entry-101d66b8.cjs +0 -2
  78. package/lib/edge/blocks-766e8d45.cjs +0 -30
  79. package/lib/edge/content-variants-4e385c19.cjs +0 -134
  80. package/lib/edge/server-entry-3c7fa63a.cjs +0 -2
  81. package/lib/node/server-entry-95273908.cjs +0 -2
@@ -0,0 +1,384 @@
1
+ import { jsxs as q, Fragment as R, jsx as p } from "react/jsx-runtime";
2
+ import { useRef as j, useState as V, useEffect as E } from "react";
3
+ import { Blocks as x, InlinedStyles as B } from "./blocks-2989e629.js";
4
+ import { InlinedScript as Q } from "./content-variants-88f4dc64.js";
5
+ import { isBrowser as $, isEditing as W, userAttributesService as P, getDefaultCanTrack as z, isPreviewing as _ } from "./server-entry-43a6f5be.js";
6
+ import "./blocks-exports.mjs";
7
+ import "./get-class-prop-name-dbc5d99c.js";
8
+ import "./dynamic-renderer-8b343325.js";
9
+ function M(e, a, d, h) {
10
+ function f(c) {
11
+ return typeof c == "string";
12
+ }
13
+ function o(c) {
14
+ return typeof c == "number";
15
+ }
16
+ function b(c, l) {
17
+ return (() => {
18
+ const g = l.property, v = l.operator;
19
+ let n = l.value;
20
+ if (l && l.property === "urlPath" && l.value && typeof l.value == "string" && l.value !== "/" && l.value.endsWith("/") && (n = l.value.slice(0, -1)), !(g && v))
21
+ return !0;
22
+ if (Array.isArray(n))
23
+ return v === "isNot" ? n.every((m) => b(c, {
24
+ property: g,
25
+ operator: v,
26
+ value: m
27
+ })) : !!n.find((m) => b(c, {
28
+ property: g,
29
+ operator: v,
30
+ value: m
31
+ }));
32
+ const t = c[g];
33
+ if (Array.isArray(t))
34
+ return t.includes(n);
35
+ switch (v) {
36
+ case "is":
37
+ return t === n;
38
+ case "isNot":
39
+ return t !== n;
40
+ case "contains":
41
+ return (f(t) || Array.isArray(t)) && t.includes(String(n));
42
+ case "startsWith":
43
+ return f(t) && t.startsWith(String(n));
44
+ case "endsWith":
45
+ return f(t) && t.endsWith(String(n));
46
+ case "greaterThan":
47
+ return o(t) && o(n) && t > n;
48
+ case "lessThan":
49
+ return o(t) && o(n) && t < n;
50
+ case "greaterThanOrEqualTo":
51
+ return o(t) && o(n) && t >= n;
52
+ case "lessThanOrEqualTo":
53
+ return o(t) && o(n) && t <= n;
54
+ default:
55
+ return !1;
56
+ }
57
+ })();
58
+ }
59
+ const s = {
60
+ query: a,
61
+ startDate: d,
62
+ endDate: h
63
+ }, S = e.date && new Date(e.date) || /* @__PURE__ */ new Date();
64
+ return s.startDate && new Date(s.startDate) > S || s.endDate && new Date(s.endDate) < S ? !1 : !s.query || !s.query.length ? !0 : s.query.every((c) => b(e, c));
65
+ }
66
+ const U = `function getPersonalizedVariant(variants, blockId, locale) {
67
+ if (!navigator.cookieEnabled) {
68
+ return;
69
+ }
70
+ function getCookie(name) {
71
+ const nameEQ = name + '=';
72
+ const ca = document.cookie.split(';');
73
+ for (let i = 0; i < ca.length; i++) {
74
+ let c = ca[i];
75
+ while (c.charAt(0) == ' ') c = c.substring(1, c.length);
76
+ if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
77
+ }
78
+ return null;
79
+ }
80
+ function removeVariants() {
81
+ variants?.forEach(function (_, index) {
82
+ document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
83
+ });
84
+ document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
85
+ document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
86
+ }
87
+ const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
88
+ if (locale) {
89
+ attributes.locale = locale;
90
+ }
91
+ const winningVariantIndex = variants?.findIndex(function (variant) {
92
+ return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
93
+ });
94
+ const isDebug = location.href.includes('builder.debug=true');
95
+ if (isDebug) {
96
+ console.debug('PersonalizationContainer', {
97
+ attributes,
98
+ variants,
99
+ winningVariantIndex
100
+ });
101
+ }
102
+ if (winningVariantIndex !== -1) {
103
+ const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
104
+ if (winningVariant) {
105
+ const parentNode = winningVariant.parentNode;
106
+ if (parentNode) {
107
+ const newParent = parentNode.cloneNode(false);
108
+ newParent.appendChild(winningVariant.content.firstChild);
109
+ newParent.appendChild(winningVariant.content.lastChild);
110
+ parentNode.parentNode?.replaceChild(newParent, parentNode);
111
+ }
112
+ if (isDebug) {
113
+ console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
114
+ }
115
+ }
116
+ } else if (variants && variants.length > 0) {
117
+ removeVariants();
118
+ }
119
+ }`, H = `function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
120
+ function isString(val) {
121
+ return typeof val === 'string';
122
+ }
123
+ function isNumber(val) {
124
+ return typeof val === 'number';
125
+ }
126
+ function objectMatchesQuery(userattr, query) {
127
+ const result = (() => {
128
+ const property = query.property;
129
+ const operator = query.operator;
130
+ let testValue = query.value;
131
+ if (query && query.property === 'urlPath' && query.value && typeof query.value === 'string' && query.value !== '/' && query.value.endsWith('/')) {
132
+ testValue = query.value.slice(0, -1);
133
+ }
134
+ if (!(property && operator)) {
135
+ return true;
136
+ }
137
+ if (Array.isArray(testValue)) {
138
+ if (operator === 'isNot') {
139
+ return testValue.every(val => objectMatchesQuery(userattr, {
140
+ property,
141
+ operator,
142
+ value: val
143
+ }));
144
+ }
145
+ return !!testValue.find(val => objectMatchesQuery(userattr, {
146
+ property,
147
+ operator,
148
+ value: val
149
+ }));
150
+ }
151
+ const value = userattr[property];
152
+ if (Array.isArray(value)) {
153
+ return value.includes(testValue);
154
+ }
155
+ switch (operator) {
156
+ case 'is':
157
+ return value === testValue;
158
+ case 'isNot':
159
+ return value !== testValue;
160
+ case 'contains':
161
+ return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
162
+ case 'startsWith':
163
+ return isString(value) && value.startsWith(String(testValue));
164
+ case 'endsWith':
165
+ return isString(value) && value.endsWith(String(testValue));
166
+ case 'greaterThan':
167
+ return isNumber(value) && isNumber(testValue) && value > testValue;
168
+ case 'lessThan':
169
+ return isNumber(value) && isNumber(testValue) && value < testValue;
170
+ case 'greaterThanOrEqualTo':
171
+ return isNumber(value) && isNumber(testValue) && value >= testValue;
172
+ case 'lessThanOrEqualTo':
173
+ return isNumber(value) && isNumber(testValue) && value <= testValue;
174
+ default:
175
+ return false;
176
+ }
177
+ })();
178
+ return result;
179
+ }
180
+ const item = {
181
+ query,
182
+ startDate,
183
+ endDate
184
+ };
185
+ const now = userAttributes.date && new Date(userAttributes.date) || new Date();
186
+ if (item.startDate && new Date(item.startDate) > now) {
187
+ return false;
188
+ } else if (item.endDate && new Date(item.endDate) < now) {
189
+ return false;
190
+ }
191
+ if (!item.query || !item.query.length) {
192
+ return true;
193
+ }
194
+ return item.query.every(filter => {
195
+ return objectMatchesQuery(userAttributes, filter);
196
+ });
197
+ }`;
198
+ function L(e, a) {
199
+ return !(!(e && e.length > 0) || !a || $());
200
+ }
201
+ function F({
202
+ variants: e,
203
+ previewingIndex: a,
204
+ isHydrated: d,
205
+ filteredVariants: h,
206
+ fallbackBlocks: f
207
+ }) {
208
+ var b;
209
+ const o = {
210
+ blocks: f != null ? f : [],
211
+ path: "this.children"
212
+ };
213
+ if (d && W())
214
+ return typeof a == "number" && a < ((b = e == null ? void 0 : e.length) != null ? b : 0) ? {
215
+ blocks: e[a].blocks,
216
+ path: `component.options.variants.${a}.blocks`
217
+ } : o;
218
+ if ($()) {
219
+ const s = h == null ? void 0 : h[0];
220
+ if (s)
221
+ return {
222
+ blocks: s.blocks,
223
+ path: `component.options.variants.${e == null ? void 0 : e.indexOf(s)}.blocks`
224
+ };
225
+ }
226
+ return o;
227
+ }
228
+ const G = (e, a, d) => `
229
+ (function() {
230
+ ${H}
231
+ ${U}
232
+ getPersonalizedVariant(${JSON.stringify(e)}, "${a}"${d ? `, "${d}"` : ""})
233
+ })();
234
+ `;
235
+ function re(e) {
236
+ var t, m, D, N, C, T, A;
237
+ const a = j(null), [d, h] = V(
238
+ () => P.getUserAttributes()
239
+ ), [f, o] = V(
240
+ () => {
241
+ var r, u, i;
242
+ return G(
243
+ e.variants,
244
+ ((r = e.builderBlock) == null ? void 0 : r.id) || "none",
245
+ (i = (u = e.builderContext) == null ? void 0 : u.rootState) == null ? void 0 : i.locale
246
+ );
247
+ }
248
+ ), [b, s] = V(() => []), [S, c] = V(
249
+ () => {
250
+ var r;
251
+ return L(
252
+ e.variants,
253
+ z((r = e.builderContext) == null ? void 0 : r.canTrack)
254
+ );
255
+ }
256
+ ), [l, k] = V(() => !1);
257
+ function g() {
258
+ return (e.variants || []).filter((r) => {
259
+ var u, i, y, w;
260
+ return M(
261
+ {
262
+ ...(i = (u = e.builderContext) == null ? void 0 : u.rootState) != null && i.locale ? {
263
+ locale: (w = (y = e.builderContext) == null ? void 0 : y.rootState) == null ? void 0 : w.locale
264
+ } : {},
265
+ ...d
266
+ },
267
+ r.query,
268
+ r.startDate,
269
+ r.endDate
270
+ );
271
+ });
272
+ }
273
+ function v() {
274
+ var r;
275
+ return F({
276
+ variants: e.variants,
277
+ fallbackBlocks: (r = e.builderBlock) == null ? void 0 : r.children,
278
+ isHydrated: l,
279
+ filteredVariants: g(),
280
+ previewingIndex: e.previewingIndex
281
+ });
282
+ }
283
+ function n() {
284
+ return (e.variants || []).map(
285
+ (r, u) => {
286
+ var i;
287
+ return `[data-variant-id="${(i = e.builderBlock) == null ? void 0 : i.id}-${u}"] { display: none; } `;
288
+ }
289
+ ).join("");
290
+ }
291
+ return E(() => {
292
+ var u;
293
+ k(!0);
294
+ const r = P.subscribeOnUserAttributesChange(
295
+ (i) => {
296
+ h(i);
297
+ }
298
+ );
299
+ if (!(W() || _())) {
300
+ const i = g()[0];
301
+ a.current && (a.current.dispatchEvent(
302
+ new CustomEvent("builder.variantLoaded", {
303
+ detail: {
304
+ variant: i || "default",
305
+ content: (u = e.builderContext) == null ? void 0 : u.content
306
+ },
307
+ bubbles: !0
308
+ })
309
+ ), new IntersectionObserver((w) => {
310
+ w.forEach((O) => {
311
+ var I;
312
+ O.isIntersecting && a.current && a.current.dispatchEvent(
313
+ new CustomEvent("builder.variantDisplayed", {
314
+ detail: {
315
+ variant: i || "default",
316
+ content: (I = e.builderContext) == null ? void 0 : I.content
317
+ },
318
+ bubbles: !0
319
+ })
320
+ );
321
+ });
322
+ }).observe(a.current));
323
+ }
324
+ b.push(r);
325
+ }, []), E(() => () => {
326
+ b.forEach((r) => r());
327
+ }, []), /* @__PURE__ */ q(
328
+ "div",
329
+ {
330
+ ref: a,
331
+ ...e.attributes,
332
+ className: `builder-personalization-container ${((t = e.attributes) == null ? void 0 : t.className) || ""}`,
333
+ children: [
334
+ S ? /* @__PURE__ */ q(R, { children: [
335
+ (m = e.variants) == null ? void 0 : m.map((r, u) => {
336
+ var i, y;
337
+ return /* @__PURE__ */ p(
338
+ "template",
339
+ {
340
+ "data-variant-id": `${(i = e.builderBlock) == null ? void 0 : i.id}-${u}`,
341
+ children: /* @__PURE__ */ p(
342
+ x,
343
+ {
344
+ blocks: r.blocks,
345
+ parent: (y = e.builderBlock) == null ? void 0 : y.id,
346
+ path: `component.options.variants.${u}.blocks`
347
+ }
348
+ )
349
+ },
350
+ u
351
+ );
352
+ }),
353
+ /* @__PURE__ */ p(
354
+ B,
355
+ {
356
+ nonce: ((D = e.builderContext) == null ? void 0 : D.nonce) || "",
357
+ styles: n(),
358
+ id: `variants-styles-${(N = e.builderBlock) == null ? void 0 : N.id}`
359
+ }
360
+ ),
361
+ /* @__PURE__ */ p(
362
+ Q,
363
+ {
364
+ nonce: ((C = e.builderContext) == null ? void 0 : C.nonce) || "",
365
+ scriptStr: f,
366
+ id: `variants-script-${(T = e.builderBlock) == null ? void 0 : T.id}`
367
+ }
368
+ )
369
+ ] }) : null,
370
+ /* @__PURE__ */ p(
371
+ x,
372
+ {
373
+ blocks: v().blocks,
374
+ parent: (A = e.builderBlock) == null ? void 0 : A.id,
375
+ path: v().path
376
+ }
377
+ )
378
+ ]
379
+ }
380
+ );
381
+ }
382
+ export {
383
+ re as default
384
+ };
@@ -0,0 +1,138 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),g=require("react"),D=require("./blocks-d3f37507.cjs"),P=require("./content-variants-fdd5ee50.cjs"),y=require("./server-entry-ac35a5c8.cjs");require("./blocks-exports.cjs");require("./get-class-prop-name-f597545d.cjs");require("./dynamic-renderer-b29b45ca.cjs");function $(e,a,d,m){function f(c){return typeof c=="string"}function o(c){return typeof c=="number"}function b(c,l){return(()=>{const S=l.property,v=l.operator;let n=l.value;if(l&&l.property==="urlPath"&&l.value&&typeof l.value=="string"&&l.value!=="/"&&l.value.endsWith("/")&&(n=l.value.slice(0,-1)),!(S&&v))return!0;if(Array.isArray(n))return v==="isNot"?n.every(V=>b(c,{property:S,operator:v,value:V})):!!n.find(V=>b(c,{property:S,operator:v,value:V}));const t=c[S];if(Array.isArray(t))return t.includes(n);switch(v){case"is":return t===n;case"isNot":return t!==n;case"contains":return(f(t)||Array.isArray(t))&&t.includes(String(n));case"startsWith":return f(t)&&t.startsWith(String(n));case"endsWith":return f(t)&&t.endsWith(String(n));case"greaterThan":return o(t)&&o(n)&&t>n;case"lessThan":return o(t)&&o(n)&&t<n;case"greaterThanOrEqualTo":return o(t)&&o(n)&&t>=n;case"lessThanOrEqualTo":return o(t)&&o(n)&&t<=n;default:return!1}})()}const u={query:a,startDate:d,endDate:m},w=e.date&&new Date(e.date)||new Date;return u.startDate&&new Date(u.startDate)>w||u.endDate&&new Date(u.endDate)<w?!1:!u.query||!u.query.length?!0:u.query.every(c=>b(e,c))}const j=`function getPersonalizedVariant(variants, blockId, locale) {
2
+ if (!navigator.cookieEnabled) {
3
+ return;
4
+ }
5
+ function getCookie(name) {
6
+ const nameEQ = name + '=';
7
+ const ca = document.cookie.split(';');
8
+ for (let i = 0; i < ca.length; i++) {
9
+ let c = ca[i];
10
+ while (c.charAt(0) == ' ') c = c.substring(1, c.length);
11
+ if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
12
+ }
13
+ return null;
14
+ }
15
+ function removeVariants() {
16
+ variants?.forEach(function (_, index) {
17
+ document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
18
+ });
19
+ document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
20
+ document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
21
+ }
22
+ const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
23
+ if (locale) {
24
+ attributes.locale = locale;
25
+ }
26
+ const winningVariantIndex = variants?.findIndex(function (variant) {
27
+ return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
28
+ });
29
+ const isDebug = location.href.includes('builder.debug=true');
30
+ if (isDebug) {
31
+ console.debug('PersonalizationContainer', {
32
+ attributes,
33
+ variants,
34
+ winningVariantIndex
35
+ });
36
+ }
37
+ if (winningVariantIndex !== -1) {
38
+ const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
39
+ if (winningVariant) {
40
+ const parentNode = winningVariant.parentNode;
41
+ if (parentNode) {
42
+ const newParent = parentNode.cloneNode(false);
43
+ newParent.appendChild(winningVariant.content.firstChild);
44
+ newParent.appendChild(winningVariant.content.lastChild);
45
+ parentNode.parentNode?.replaceChild(newParent, parentNode);
46
+ }
47
+ if (isDebug) {
48
+ console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
49
+ }
50
+ }
51
+ } else if (variants && variants.length > 0) {
52
+ removeVariants();
53
+ }
54
+ }`,R=`function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
55
+ function isString(val) {
56
+ return typeof val === 'string';
57
+ }
58
+ function isNumber(val) {
59
+ return typeof val === 'number';
60
+ }
61
+ function objectMatchesQuery(userattr, query) {
62
+ const result = (() => {
63
+ const property = query.property;
64
+ const operator = query.operator;
65
+ let testValue = query.value;
66
+ if (query && query.property === 'urlPath' && query.value && typeof query.value === 'string' && query.value !== '/' && query.value.endsWith('/')) {
67
+ testValue = query.value.slice(0, -1);
68
+ }
69
+ if (!(property && operator)) {
70
+ return true;
71
+ }
72
+ if (Array.isArray(testValue)) {
73
+ if (operator === 'isNot') {
74
+ return testValue.every(val => objectMatchesQuery(userattr, {
75
+ property,
76
+ operator,
77
+ value: val
78
+ }));
79
+ }
80
+ return !!testValue.find(val => objectMatchesQuery(userattr, {
81
+ property,
82
+ operator,
83
+ value: val
84
+ }));
85
+ }
86
+ const value = userattr[property];
87
+ if (Array.isArray(value)) {
88
+ return value.includes(testValue);
89
+ }
90
+ switch (operator) {
91
+ case 'is':
92
+ return value === testValue;
93
+ case 'isNot':
94
+ return value !== testValue;
95
+ case 'contains':
96
+ return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
97
+ case 'startsWith':
98
+ return isString(value) && value.startsWith(String(testValue));
99
+ case 'endsWith':
100
+ return isString(value) && value.endsWith(String(testValue));
101
+ case 'greaterThan':
102
+ return isNumber(value) && isNumber(testValue) && value > testValue;
103
+ case 'lessThan':
104
+ return isNumber(value) && isNumber(testValue) && value < testValue;
105
+ case 'greaterThanOrEqualTo':
106
+ return isNumber(value) && isNumber(testValue) && value >= testValue;
107
+ case 'lessThanOrEqualTo':
108
+ return isNumber(value) && isNumber(testValue) && value <= testValue;
109
+ default:
110
+ return false;
111
+ }
112
+ })();
113
+ return result;
114
+ }
115
+ const item = {
116
+ query,
117
+ startDate,
118
+ endDate
119
+ };
120
+ const now = userAttributes.date && new Date(userAttributes.date) || new Date();
121
+ if (item.startDate && new Date(item.startDate) > now) {
122
+ return false;
123
+ } else if (item.endDate && new Date(item.endDate) < now) {
124
+ return false;
125
+ }
126
+ if (!item.query || !item.query.length) {
127
+ return true;
128
+ }
129
+ return item.query.every(filter => {
130
+ return objectMatchesQuery(userAttributes, filter);
131
+ });
132
+ }`;function W(e,a){return!(!(e&&e.length>0)||!a||y.isBrowser())}function O({variants:e,previewingIndex:a,isHydrated:d,filteredVariants:m,fallbackBlocks:f}){var b;const o={blocks:f!=null?f:[],path:"this.children"};if(d&&y.isEditing())return typeof a=="number"&&a<((b=e==null?void 0:e.length)!=null?b:0)?{blocks:e[a].blocks,path:`component.options.variants.${a}.blocks`}:o;if(y.isBrowser()){const u=m==null?void 0:m[0];if(u)return{blocks:u.blocks,path:`component.options.variants.${e==null?void 0:e.indexOf(u)}.blocks`}}return o}const B=(e,a,d)=>`
133
+ (function() {
134
+ ${R}
135
+ ${j}
136
+ getPersonalizedVariant(${JSON.stringify(e)}, "${a}"${d?`, "${d}"`:""})
137
+ })();
138
+ `;function Q(e){var t,V,q,C,T,A,E;const a=g.useRef(null),[d,m]=g.useState(()=>y.userAttributesService.getUserAttributes()),[f,o]=g.useState(()=>{var r,s,i;return B(e.variants,((r=e.builderBlock)==null?void 0:r.id)||"none",(i=(s=e.builderContext)==null?void 0:s.rootState)==null?void 0:i.locale)}),[b,u]=g.useState(()=>[]),[w,c]=g.useState(()=>{var r;return W(e.variants,y.getDefaultCanTrack((r=e.builderContext)==null?void 0:r.canTrack))}),[l,N]=g.useState(()=>!1);function S(){return(e.variants||[]).filter(r=>{var s,i,p,k;return $({...(i=(s=e.builderContext)==null?void 0:s.rootState)!=null&&i.locale?{locale:(k=(p=e.builderContext)==null?void 0:p.rootState)==null?void 0:k.locale}:{},...d},r.query,r.startDate,r.endDate)})}function v(){var r;return O({variants:e.variants,fallbackBlocks:(r=e.builderBlock)==null?void 0:r.children,isHydrated:l,filteredVariants:S(),previewingIndex:e.previewingIndex})}function n(){return(e.variants||[]).map((r,s)=>{var i;return`[data-variant-id="${(i=e.builderBlock)==null?void 0:i.id}-${s}"] { display: none; } `}).join("")}return g.useEffect(()=>{var s;N(!0);const r=y.userAttributesService.subscribeOnUserAttributesChange(i=>{m(i)});if(!(y.isEditing()||y.isPreviewing())){const i=S()[0];a.current&&(a.current.dispatchEvent(new CustomEvent("builder.variantLoaded",{detail:{variant:i||"default",content:(s=e.builderContext)==null?void 0:s.content},bubbles:!0})),new IntersectionObserver(k=>{k.forEach(I=>{var x;I.isIntersecting&&a.current&&a.current.dispatchEvent(new CustomEvent("builder.variantDisplayed",{detail:{variant:i||"default",content:(x=e.builderContext)==null?void 0:x.content},bubbles:!0}))})}).observe(a.current))}b.push(r)},[]),g.useEffect(()=>()=>{b.forEach(r=>r())},[]),h.jsxs("div",{ref:a,...e.attributes,className:`builder-personalization-container ${((t=e.attributes)==null?void 0:t.className)||""}`,children:[w?h.jsxs(h.Fragment,{children:[(V=e.variants)==null?void 0:V.map((r,s)=>{var i,p;return h.jsx("template",{"data-variant-id":`${(i=e.builderBlock)==null?void 0:i.id}-${s}`,children:h.jsx(D.Blocks,{blocks:r.blocks,parent:(p=e.builderBlock)==null?void 0:p.id,path:`component.options.variants.${s}.blocks`})},s)}),h.jsx(D.InlinedStyles,{nonce:((q=e.builderContext)==null?void 0:q.nonce)||"",styles:n(),id:`variants-styles-${(C=e.builderBlock)==null?void 0:C.id}`}),h.jsx(P.InlinedScript,{nonce:((T=e.builderContext)==null?void 0:T.nonce)||"",scriptStr:f,id:`variants-script-${(A=e.builderBlock)==null?void 0:A.id}`})]}):null,h.jsx(D.Blocks,{blocks:v().blocks,parent:(E=e.builderBlock)==null?void 0:E.id,path:v().path})]})}exports.default=Q;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),n=require("react"),r=require("./server-entry-3c7fa63a.cjs");function i(e){var u;return n.createElement("select",{...e.attributes,value:e.value,key:r.isEditing()&&e.defaultValue?e.defaultValue:"default-key",defaultValue:e.defaultValue,name:e.name,required:e.required},(u=e.options)==null?void 0:u.map((t,a)=>l.jsx("option",{value:t.value,children:t.name||t.value},`${t.name}-${a}`)))}exports.default=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),n=require("react"),r=require("./server-entry-ac35a5c8.cjs");function i(e){var u;return n.createElement("select",{...e.attributes,value:e.value,key:r.isEditing()&&e.defaultValue?e.defaultValue:"default-key",defaultValue:e.defaultValue,name:e.name,required:e.required},(u=e.options)==null?void 0:u.map((t,a)=>l.jsx("option",{value:t.value,children:t.name||t.value},`${t.name}-${a}`)))}exports.default=i;
@@ -1,6 +1,6 @@
1
1
  import { jsx as l } from "react/jsx-runtime";
2
2
  import { createElement as m } from "react";
3
- import { isEditing as n } from "./server-entry-67bfc740.js";
3
+ import { isEditing as n } from "./server-entry-43a6f5be.js";
4
4
  function r(e) {
5
5
  var t;
6
6
  return /* @__PURE__ */ m(