@builder.io/sdk-react 4.0.7 → 4.0.9

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 (78) hide show
  1. package/lib/browser/blocks-exports.cjs +93 -65
  2. package/lib/browser/blocks-exports.mjs +1721 -1613
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +1 -1
  5. package/lib/browser/{server-entry-e70c12ff.js → server-entry-231f8ecd.js} +1 -1
  6. package/lib/browser/{server-entry-4c650ff5.cjs → server-entry-bdbd3c0d.cjs} +1 -1
  7. package/lib/browser/server-entry.cjs +1 -1
  8. package/lib/browser/server-entry.mjs +1 -1
  9. package/lib/edge/{accordion-742ca147.js → accordion-b551e135.js} +1 -1
  10. package/lib/edge/{accordion-c97e6506.cjs → accordion-e3f81e74.cjs} +1 -1
  11. package/lib/edge/{blocks-2a015bd6.js → blocks-cd1feef2.js} +1014 -1008
  12. package/lib/edge/{blocks-70894a53.cjs → blocks-eb6fa21f.cjs} +15 -15
  13. package/lib/edge/blocks-exports.cjs +1 -1
  14. package/lib/edge/blocks-exports.mjs +2 -2
  15. package/lib/edge/{button-6a072716.cjs → button-5c6a9392.cjs} +1 -1
  16. package/lib/edge/{button-deecd9b5.js → button-f390f723.js} +2 -2
  17. package/lib/edge/{columns-0e9b2bf4.js → columns-7018a027.js} +9 -9
  18. package/lib/edge/{columns-02352a9f.cjs → columns-ad17139e.cjs} +3 -3
  19. package/lib/edge/content-variants-c72ca81f.cjs +302 -0
  20. package/lib/edge/{content-variants-6948115a.js → content-variants-dc54ce4f.js} +650 -367
  21. package/lib/edge/{custom-code-73f76f76.js → custom-code-0daf1c91.js} +1 -1
  22. package/lib/edge/{custom-code-77f98605.cjs → custom-code-e87af7b1.cjs} +1 -1
  23. package/lib/edge/{embed-26470ea1.js → embed-1dfcba43.js} +1 -1
  24. package/lib/edge/{embed-9aaf87f9.cjs → embed-c695c98e.cjs} +1 -1
  25. package/lib/edge/{form-652ef8a9.js → form-5a0c89d9.js} +5 -5
  26. package/lib/edge/{form-0213200e.cjs → form-ba54942c.cjs} +1 -1
  27. package/lib/edge/{get-class-prop-name-1a003fac.js → get-class-prop-name-5edacc3b.js} +1 -1
  28. package/lib/edge/{get-class-prop-name-8647a440.cjs → get-class-prop-name-c479656a.cjs} +1 -1
  29. package/lib/edge/{image-e38bd9e0.cjs → image-cce92f6c.cjs} +2 -2
  30. package/lib/edge/{image-acc1c00c.js → image-d87761af.js} +18 -18
  31. package/lib/edge/{img-f0b9e982.cjs → img-6982d6eb.cjs} +1 -1
  32. package/lib/edge/{img-2d35513d.js → img-882c7222.js} +1 -1
  33. package/lib/edge/index.cjs +1 -1
  34. package/lib/edge/index.mjs +1 -1
  35. package/lib/edge/{input-cdd96bc7.js → input-3d4f956b.js} +1 -1
  36. package/lib/edge/{input-e61cf32f.cjs → input-8c7008b5.cjs} +1 -1
  37. package/lib/edge/personalization-container-3a8dc18a.js +205 -0
  38. package/lib/edge/personalization-container-4557a50b.cjs +1 -0
  39. package/lib/edge/{select-de96bdc0.js → select-153586f8.js} +1 -1
  40. package/lib/edge/{select-f1165866.cjs → select-2efc7503.cjs} +1 -1
  41. package/lib/edge/{server-entry-637ed5ff.js → server-entry-8dc3478a.js} +1 -1
  42. package/lib/edge/{server-entry-10ca8502.cjs → server-entry-9d269960.cjs} +1 -1
  43. package/lib/edge/server-entry.cjs +1 -1
  44. package/lib/edge/server-entry.mjs +1 -1
  45. package/lib/edge/{slot-72846242.js → slot-d268693c.js} +3 -3
  46. package/lib/edge/{slot-3ecf31d9.cjs → slot-f1f7513c.cjs} +1 -1
  47. package/lib/edge/symbol-0344516c.cjs +1 -0
  48. package/lib/edge/symbol-378e19ee.js +90 -0
  49. package/lib/edge/{tabs-ea0258b8.js → tabs-29ff78a0.js} +3 -3
  50. package/lib/edge/{tabs-788974d9.cjs → tabs-4e931765.cjs} +1 -1
  51. package/lib/node/blocks-exports.cjs +92 -64
  52. package/lib/node/blocks-exports.mjs +1608 -1500
  53. package/lib/node/index.cjs +1 -1
  54. package/lib/node/index.mjs +3 -3
  55. package/lib/node/init.cjs +1 -1
  56. package/lib/node/init.mjs +3 -3
  57. package/lib/node/{server-entry-e76904a8.cjs → server-entry-916c726c.cjs} +1 -1
  58. package/lib/node/{server-entry-7167da7c.js → server-entry-f03c1146.js} +1 -1
  59. package/lib/node/server-entry.cjs +1 -1
  60. package/lib/node/server-entry.mjs +1 -1
  61. package/lib/node/{setIvm-72c91afa.js → setIvm-044ce9e7.js} +1 -1
  62. package/lib/node/{setIvm-e89d1a08.cjs → setIvm-3761bb10.cjs} +1 -1
  63. package/lib/node/setIvm.cjs +1 -1
  64. package/lib/node/setIvm.mjs +2 -2
  65. package/lib/node/{should-force-browser-runtime-in-node-b3e23348.cjs → should-force-browser-runtime-in-node-e760d4f2.cjs} +1 -1
  66. package/lib/node/{should-force-browser-runtime-in-node-09a401d5.js → should-force-browser-runtime-in-node-f620dcdc.js} +1 -1
  67. package/package.json +2 -2
  68. package/types/blocks/personalization-container/helpers/inlined-fns.d.ts +4 -1
  69. package/types/blocks/personalization-container/helpers.d.ts +24 -4
  70. package/types/blocks/personalization-container/personalization-container.types.d.ts +2 -2
  71. package/types/components/blocks/blocks-wrapper.d.ts +13 -1
  72. package/types/components/blocks/blocks.types.d.ts +1 -1
  73. package/types/constants/sdk-version.d.ts +1 -1
  74. package/lib/edge/content-variants-41781d1f.cjs +0 -137
  75. package/lib/edge/personalization-container-4f73fbdf.cjs +0 -138
  76. package/lib/edge/personalization-container-e1f03976.js +0 -384
  77. package/lib/edge/symbol-49ed2192.cjs +0 -1
  78. package/lib/edge/symbol-61a3651b.js +0 -85
@@ -1,138 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),g=require("react"),D=require("./blocks-70894a53.cjs"),P=require("./content-variants-41781d1f.cjs"),y=require("./server-entry-10ca8502.cjs");require("./blocks-exports.cjs");require("./get-class-prop-name-8647a440.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,384 +0,0 @@
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-2a015bd6.js";
4
- import { InlinedScript as Q } from "./content-variants-6948115a.js";
5
- import { isBrowser as $, isEditing as W, userAttributesService as P, getDefaultCanTrack as z, isPreviewing as _ } from "./server-entry-637ed5ff.js";
6
- import "./blocks-exports.mjs";
7
- import "./get-class-prop-name-1a003fac.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
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),o=require("react"),v=require("./blocks-exports.cjs"),k=require("./get-class-prop-name-8647a440.cjs"),b=require("./server-entry-10ca8502.cjs"),x=async({builderContextValue:e,symbol:t})=>{if(t!=null&&t.model&&(e!=null&&e.apiKey))return b.fetchOneEntry({model:t.model,apiKey:e.apiKey,apiVersion:e.apiVersion,...(t==null?void 0:t.entry)&&{query:{id:t.entry}}}).catch(r=>{b.logger.error("Could not fetch symbol content: ",r)})};function g(e){var c,a,d,u,l;function t(){return"div"}function r(){return"div"}function y(){var n,s;return[e.attributes[k.getClassPropName()],"builder-symbol",(n=e.symbol)!=null&&n.inline?"builder-inline-symbol":void 0,(s=e.symbol)!=null&&s.dynamic||e.dynamic?"builder-dynamic-symbol":void 0].filter(Boolean).join(" ")}const[i,f]=o.useState(()=>{var n;return(n=e.symbol)==null?void 0:n.content});function C(){i||x({symbol:e.symbol,builderContextValue:e.builderContext}).then(n=>{n&&f(n)})}return o.useEffect(()=>{},[]),o.useEffect(()=>{C()},[e.symbol]),m.jsx("div",{...e.attributes,className:y(),children:m.jsx(v.Content,{nonce:e.builderContext.nonce,isNestedRender:!0,apiVersion:e.builderContext.apiVersion,apiKey:e.builderContext.apiKey,context:{...e.builderContext.context,symbolId:(c=e.builderBlock)==null?void 0:c.id},customComponents:Object.values(e.builderComponents),data:{...(a=e.symbol)==null?void 0:a.data,...e.builderContext.localState,...(d=i==null?void 0:i.data)==null?void 0:d.state},canTrack:e.builderContext.canTrack,model:(l=(u=e.symbol)==null?void 0:u.model)!=null?l:"",content:i,linkComponent:e.builderLinkComponent,blocksWrapper:t(),contentWrapper:r()})})}exports.default=g;
@@ -1,85 +0,0 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import { useState as C, useEffect as f } from "react";
3
- import { Content as v } from "./blocks-exports.mjs";
4
- import { getClassPropName as k } from "./get-class-prop-name-1a003fac.js";
5
- import { fetchOneEntry as h, logger as x } from "./server-entry-637ed5ff.js";
6
- const K = async ({
7
- builderContextValue: e,
8
- symbol: t
9
- }) => {
10
- if (t != null && t.model && // This is a hack, we should not need to check for this, but it is needed for Svelte.
11
- (e != null && e.apiKey))
12
- return h({
13
- model: t.model,
14
- apiKey: e.apiKey,
15
- apiVersion: e.apiVersion,
16
- ...(t == null ? void 0 : t.entry) && {
17
- query: {
18
- id: t.entry
19
- }
20
- }
21
- }).catch((o) => {
22
- x.error("Could not fetch symbol content: ", o);
23
- });
24
- };
25
- function B(e) {
26
- var r, a, c, d, l;
27
- function t() {
28
- return "div";
29
- }
30
- function o() {
31
- return "div";
32
- }
33
- function b() {
34
- var n, m;
35
- return [
36
- e.attributes[k()],
37
- "builder-symbol",
38
- (n = e.symbol) != null && n.inline ? "builder-inline-symbol" : void 0,
39
- (m = e.symbol) != null && m.dynamic || e.dynamic ? "builder-dynamic-symbol" : void 0
40
- ].filter(Boolean).join(" ");
41
- }
42
- const [i, y] = C(() => {
43
- var n;
44
- return (n = e.symbol) == null ? void 0 : n.content;
45
- });
46
- function s() {
47
- i || K({
48
- symbol: e.symbol,
49
- builderContextValue: e.builderContext
50
- }).then((n) => {
51
- n && y(n);
52
- });
53
- }
54
- return f(() => {
55
- }, []), f(() => {
56
- s();
57
- }, [e.symbol]), /* @__PURE__ */ u("div", { ...e.attributes, className: b(), children: /* @__PURE__ */ u(
58
- v,
59
- {
60
- nonce: e.builderContext.nonce,
61
- isNestedRender: !0,
62
- apiVersion: e.builderContext.apiVersion,
63
- apiKey: e.builderContext.apiKey,
64
- context: {
65
- ...e.builderContext.context,
66
- symbolId: (r = e.builderBlock) == null ? void 0 : r.id
67
- },
68
- customComponents: Object.values(e.builderComponents),
69
- data: {
70
- ...(a = e.symbol) == null ? void 0 : a.data,
71
- ...e.builderContext.localState,
72
- ...(c = i == null ? void 0 : i.data) == null ? void 0 : c.state
73
- },
74
- canTrack: e.builderContext.canTrack,
75
- model: (l = (d = e.symbol) == null ? void 0 : d.model) != null ? l : "",
76
- content: i,
77
- linkComponent: e.builderLinkComponent,
78
- blocksWrapper: t(),
79
- contentWrapper: o()
80
- }
81
- ) });
82
- }
83
- export {
84
- B as default
85
- };