@builder.io/sdk-react 3.0.3-0 → 3.0.5
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.
- package/lib/browser/blocks-exports.cjs +32 -169
- package/lib/browser/blocks-exports.mjs +778 -1199
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +16 -17
- package/lib/browser/server-entry-101d66b8.cjs +2 -0
- package/lib/browser/{server-entry-da1754bd.js → server-entry-785c0408.js} +237 -279
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/{accordion-388f5e60.cjs → accordion-190c4426.cjs} +1 -1
- package/lib/edge/{accordion-50de133c.js → accordion-cd6e0363.js} +1 -1
- package/lib/edge/{blocks-a5193d52.cjs → blocks-766e8d45.cjs} +9 -9
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +12 -13
- package/lib/edge/{blocks-5e476ddc.js → blocks-fe2d7c1a.js} +2 -3
- package/lib/edge/{button-c6ec3aea.cjs → button-694fcd4f.cjs} +1 -1
- package/lib/edge/{button-4261ae64.js → button-6a27481c.js} +2 -2
- package/lib/edge/{columns-28e9fb0a.js → columns-90e6407e.js} +18 -18
- package/lib/edge/{columns-8c831c02.cjs → columns-b38bf0f7.cjs} +2 -2
- package/lib/edge/content-variants-4e385c19.cjs +134 -0
- package/lib/edge/{content-variants-36ca4fe5.js → content-variants-cbb89349.js} +124 -165
- package/lib/edge/dynamic-blocks-exports.cjs +1 -3
- package/lib/edge/dynamic-blocks-exports.mjs +2 -5
- package/lib/edge/form-16bbf874.js +166 -0
- package/lib/edge/form-547645eb.cjs +1 -0
- package/lib/edge/{get-class-prop-name-a86a3e60.cjs → get-class-prop-name-58770197.cjs} +1 -1
- package/lib/edge/{get-class-prop-name-65d6824c.js → get-class-prop-name-8b719c6b.js} +1 -1
- package/lib/edge/{image-2a2b26d2.js → image-38917f45.js} +22 -24
- package/lib/edge/image-590e36ae.cjs +17 -0
- package/lib/edge/{img-7de3a3de.cjs → img-8859c851.cjs} +1 -1
- package/lib/edge/{img-61d29fb3.js → img-d3351743.js} +1 -1
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +17 -18
- package/lib/edge/{input-c8539054.js → input-24c601b4.js} +1 -1
- package/lib/edge/{input-bd5387a6.cjs → input-4fe0fc6d.cjs} +1 -1
- package/lib/edge/{select-6b5cda00.js → select-af05377b.js} +1 -1
- package/lib/edge/{select-73accaf4.cjs → select-c73bd418.cjs} +1 -1
- package/lib/edge/server-entry-3c7fa63a.cjs +2 -0
- package/lib/edge/{server-entry-838c1f06.js → server-entry-67bfc740.js} +280 -322
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/{slot-403c77da.js → slot-32a4df0c.js} +3 -3
- package/lib/edge/{slot-099112f1.cjs → slot-759c8dd9.cjs} +1 -1
- package/lib/edge/{symbol-97f456f4.js → symbol-50360a37.js} +2 -2
- package/lib/edge/{symbol-ffa6e6cd.cjs → symbol-8d63aa7d.cjs} +1 -1
- package/lib/edge/{tabs-a7c94ead.js → tabs-6535c934.js} +3 -3
- package/lib/edge/{tabs-ad55c6a7.cjs → tabs-fc6c1700.cjs} +1 -1
- package/lib/edge/video-4ecfd08b.cjs +1 -0
- package/lib/edge/{video-58c2cc8d.js → video-a3f10439.js} +0 -1
- package/lib/node/blocks-exports.cjs +32 -169
- package/lib/node/blocks-exports.mjs +896 -1317
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +16 -17
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +3 -3
- package/lib/node/server-entry-95273908.cjs +2 -0
- package/lib/node/{server-entry-51bc0b1d.js → server-entry-ffc70868.js} +237 -279
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/lib/node/{setIvm-575cf1f1.js → setIvm-2cea7252.js} +1 -1
- package/lib/node/{setIvm-d912cf4d.cjs → setIvm-4ce0db03.cjs} +1 -1
- package/lib/node/setIvm.cjs +1 -1
- package/lib/node/setIvm.mjs +2 -2
- package/lib/node/{should-force-browser-runtime-in-node-66df4856.js → should-force-browser-runtime-in-node-c0d50009.js} +1 -1
- package/lib/node/{should-force-browser-runtime-in-node-23225980.cjs → should-force-browser-runtime-in-node-d3e6df07.cjs} +1 -1
- package/package.json +2 -2
- package/types/blocks/form/form/form.d.ts +1 -0
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/index-helpers/blocks-exports.d.ts +0 -1
- package/types/types/components.d.ts +2 -2
- package/types/types/input.d.ts +0 -1
- package/lib/browser/server-entry-c7bda8b5.cjs +0 -2
- package/lib/edge/content-variants-81713434.cjs +0 -134
- package/lib/edge/form-039fb5ff.js +0 -176
- package/lib/edge/form-e7a1dec9.cjs +0 -1
- package/lib/edge/image-4db81d72.cjs +0 -17
- package/lib/edge/personalization-container-3fda6014.cjs +0 -138
- package/lib/edge/personalization-container-c76e4fef.js +0 -379
- package/lib/edge/server-entry-ea2a8b0e.cjs +0 -2
- package/lib/edge/video-e20dcbbc.cjs +0 -1
- package/lib/node/server-entry-d7316893.cjs +0 -2
- package/types/blocks/index.d.ts +0 -4
- package/types/blocks/personalization-container/component-info.d.ts +0 -2
- package/types/blocks/personalization-container/helpers/index.d.ts +0 -15
- package/types/blocks/personalization-container/helpers/inlined-fns.d.ts +0 -8
- package/types/blocks/personalization-container/helpers.d.ts +0 -27
- package/types/blocks/personalization-container/index.d.ts +0 -1
- package/types/blocks/personalization-container/personalization-container.d.ts +0 -4
- package/types/blocks/personalization-container/personalization-container.types.d.ts +0 -14
- package/types/blocks/textarea/component-info.d.ts +0 -2
- package/types/blocks/textarea/index.d.ts +0 -1
- package/types/blocks/textarea/textarea.d.ts +0 -14
- package/types/functions/filter-with-custom-targeting.d.ts +0 -15
- package/types/helpers/user-attributes.d.ts +0 -17
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),g=require("react"),D=require("./blocks-a5193d52.cjs"),P=require("./content-variants-81713434.cjs"),m=require("./server-entry-ea2a8b0e.cjs");require("./blocks-exports.cjs");require("./get-class-prop-name-a86a3e60.cjs");require("./dynamic-renderer-b29b45ca.cjs");function $(e,n,u,k){function l(v){return typeof v=="string"}function d(v){return typeof v=="number"}function h(v,c){return(()=>{const y=c.property,f=c.operator;let r=c.value;if(c&&c.property==="urlPath"&&c.value&&typeof c.value=="string"&&c.value!=="/"&&c.value.endsWith("/")&&(r=c.value.slice(0,-1)),!(y&&f))return!0;if(Array.isArray(r))return f==="isNot"?r.every(S=>h(v,{property:y,operator:f,value:S})):!!r.find(S=>h(v,{property:y,operator:f,value:S}));const t=v[y];if(Array.isArray(t))return t.includes(r);switch(f){case"is":return t===r;case"isNot":return t!==r;case"contains":return(l(t)||Array.isArray(t))&&t.includes(String(r));case"startsWith":return l(t)&&t.startsWith(String(r));case"endsWith":return l(t)&&t.endsWith(String(r));case"greaterThan":return d(t)&&d(r)&&t>r;case"lessThan":return d(t)&&d(r)&&t<r;case"greaterThanOrEqualTo":return d(t)&&d(r)&&t>=r;case"lessThanOrEqualTo":return d(t)&&d(r)&&t<=r;default:return!1}})()}const o={query:n,startDate:u,endDate:k},w=e.date&&new Date(e.date)||new Date;return o.startDate&&new Date(o.startDate)>w||o.endDate&&new Date(o.endDate)<w?!1:!o.query||!o.query.length?!0:o.query.every(v=>h(e,v))}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,n){return!(!(e&&e.length>0)||!n||m.isBrowser())}function B(e){const{variants:n,previewingIndex:u,isHydrated:k,filteredVariants:l,fallbackBlocks:d}=e;if(k&&m.isEditing()&&typeof u=="number"&&u<((n==null?void 0:n.length)||0)&&!(l!=null&&l.length))return{blocks:n[u].blocks,path:`component.options.variants.${u}.blocks`};const o=l==null?void 0:l[0];return o?{blocks:o.blocks,path:`component.options.variants.${n==null?void 0:n.indexOf(o)}.blocks`}:{blocks:d||[],path:void 0}}const O=(e,n,u)=>`
|
|
133
|
-
(function() {
|
|
134
|
-
${R}
|
|
135
|
-
${j}
|
|
136
|
-
getPersonalizedVariant(${JSON.stringify(e)}, "${n}"${u?`, "${u}"`:""})
|
|
137
|
-
})();
|
|
138
|
-
`;function Q(e){var t,S,C,N,T,x,A;const n=g.useRef(null),[u,k]=g.useState(()=>m.userAttributesService.getUserAttributes()),[l,d]=g.useState(()=>{var a,s,i;return O(e.variants,((a=e.builderBlock)==null?void 0:a.id)||"none",(i=(s=e.builderContext)==null?void 0:s.rootState)==null?void 0:i.locale)}),[h,o]=g.useState(()=>[]),[w,v]=g.useState(()=>{var a;return W(e.variants,m.getDefaultCanTrack((a=e.builderContext)==null?void 0:a.canTrack))}),[c,q]=g.useState(()=>!1);function y(){return(e.variants||[]).filter(a=>{var s,i,V,p;return $({...(i=(s=e.builderContext)==null?void 0:s.rootState)!=null&&i.locale?{locale:(p=(V=e.builderContext)==null?void 0:V.rootState)==null?void 0:p.locale}:{},...u},a.query,a.startDate,a.endDate)})}function f(){var a;return B({variants:e.variants,fallbackBlocks:(a=e.builderBlock)==null?void 0:a.children,isHydrated:c,filteredVariants:y(),previewingIndex:e.previewingIndex})}function r(){return(e.variants||[]).map((a,s)=>{var i;return`[data-variant-id="${(i=e.builderBlock)==null?void 0:i.id}-${s}"] { display: none; } `}).join("")}return g.useEffect(()=>{var s;q(!0);const a=m.userAttributesService.subscribeOnUserAttributesChange(i=>{k(i)});if(!(m.isEditing()||m.isPreviewing())){const i=y()[0];n.current&&(n.current.dispatchEvent(new CustomEvent("builder.variantLoaded",{detail:{variant:i||"default",content:(s=e.builderContext)==null?void 0:s.content},bubbles:!0})),new IntersectionObserver(p=>{p.forEach(E=>{var I;E.isIntersecting&&n.current&&n.current.dispatchEvent(new CustomEvent("builder.variantDisplayed",{detail:{variant:i||"default",content:(I=e.builderContext)==null?void 0:I.content},bubbles:!0}))})}).observe(n.current))}h.push(a)},[]),g.useEffect(()=>()=>{h.forEach(a=>a())},[]),b.jsxs("div",{ref:n,...e.attributes,className:`builder-personalization-container ${((t=e.attributes)==null?void 0:t.class)||""}`,children:[w?b.jsxs(b.Fragment,{children:[(S=e.variants)==null?void 0:S.map((a,s)=>{var i,V;return b.jsx("template",{"data-variant-id":`${(i=e.builderBlock)==null?void 0:i.id}-${s}`,children:b.jsx(D.Blocks,{blocks:a.blocks,parent:(V=e.builderBlock)==null?void 0:V.id,path:`component.options.variants.${s}.blocks`})},s)}),b.jsx(D.InlinedStyles,{nonce:((C=e.builderContext)==null?void 0:C.nonce)||"",styles:r(),id:`variants-styles-${(N=e.builderBlock)==null?void 0:N.id}`}),b.jsx(P.InlinedScript,{nonce:((T=e.builderContext)==null?void 0:T.nonce)||"",scriptStr:l,id:`variants-script-${(x=e.builderBlock)==null?void 0:x.id}`})]}):null,b.jsx(D.Blocks,{blocks:f().blocks,parent:(A=e.builderBlock)==null?void 0:A.id,path:f().path})]})}exports.default=Q;
|
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
import { jsxs as x, Fragment as B, jsx as V } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as O, useState as w, useEffect as q } from "react";
|
|
3
|
-
import { Blocks as E, InlinedStyles as R } from "./blocks-5e476ddc.js";
|
|
4
|
-
import { InlinedScript as j } from "./content-variants-36ca4fe5.js";
|
|
5
|
-
import { isBrowser as Q, isEditing as $, userAttributesService as P, getDefaultCanTrack as z, isPreviewing as _ } from "./server-entry-838c1f06.js";
|
|
6
|
-
import "./blocks-exports.mjs";
|
|
7
|
-
import "./get-class-prop-name-65d6824c.js";
|
|
8
|
-
import "./dynamic-renderer-8b343325.js";
|
|
9
|
-
function M(e, n, u, m) {
|
|
10
|
-
function o(f) {
|
|
11
|
-
return typeof f == "string";
|
|
12
|
-
}
|
|
13
|
-
function d(f) {
|
|
14
|
-
return typeof f == "number";
|
|
15
|
-
}
|
|
16
|
-
function b(f, c) {
|
|
17
|
-
return (() => {
|
|
18
|
-
const g = c.property, v = c.operator;
|
|
19
|
-
let r = c.value;
|
|
20
|
-
if (c && c.property === "urlPath" && c.value && typeof c.value == "string" && c.value !== "/" && c.value.endsWith("/") && (r = c.value.slice(0, -1)), !(g && v))
|
|
21
|
-
return !0;
|
|
22
|
-
if (Array.isArray(r))
|
|
23
|
-
return v === "isNot" ? r.every((h) => b(f, {
|
|
24
|
-
property: g,
|
|
25
|
-
operator: v,
|
|
26
|
-
value: h
|
|
27
|
-
})) : !!r.find((h) => b(f, {
|
|
28
|
-
property: g,
|
|
29
|
-
operator: v,
|
|
30
|
-
value: h
|
|
31
|
-
}));
|
|
32
|
-
const t = f[g];
|
|
33
|
-
if (Array.isArray(t))
|
|
34
|
-
return t.includes(r);
|
|
35
|
-
switch (v) {
|
|
36
|
-
case "is":
|
|
37
|
-
return t === r;
|
|
38
|
-
case "isNot":
|
|
39
|
-
return t !== r;
|
|
40
|
-
case "contains":
|
|
41
|
-
return (o(t) || Array.isArray(t)) && t.includes(String(r));
|
|
42
|
-
case "startsWith":
|
|
43
|
-
return o(t) && t.startsWith(String(r));
|
|
44
|
-
case "endsWith":
|
|
45
|
-
return o(t) && t.endsWith(String(r));
|
|
46
|
-
case "greaterThan":
|
|
47
|
-
return d(t) && d(r) && t > r;
|
|
48
|
-
case "lessThan":
|
|
49
|
-
return d(t) && d(r) && t < r;
|
|
50
|
-
case "greaterThanOrEqualTo":
|
|
51
|
-
return d(t) && d(r) && t >= r;
|
|
52
|
-
case "lessThanOrEqualTo":
|
|
53
|
-
return d(t) && d(r) && t <= r;
|
|
54
|
-
default:
|
|
55
|
-
return !1;
|
|
56
|
-
}
|
|
57
|
-
})();
|
|
58
|
-
}
|
|
59
|
-
const l = {
|
|
60
|
-
query: n,
|
|
61
|
-
startDate: u,
|
|
62
|
-
endDate: m
|
|
63
|
-
}, p = e.date && new Date(e.date) || /* @__PURE__ */ new Date();
|
|
64
|
-
return l.startDate && new Date(l.startDate) > p || l.endDate && new Date(l.endDate) < p ? !1 : !l.query || !l.query.length ? !0 : l.query.every((f) => b(e, f));
|
|
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, n) {
|
|
199
|
-
return !(!(e && e.length > 0) || !n || Q());
|
|
200
|
-
}
|
|
201
|
-
function F(e) {
|
|
202
|
-
const {
|
|
203
|
-
variants: n,
|
|
204
|
-
previewingIndex: u,
|
|
205
|
-
isHydrated: m,
|
|
206
|
-
filteredVariants: o,
|
|
207
|
-
fallbackBlocks: d
|
|
208
|
-
} = e;
|
|
209
|
-
if (m && $() && typeof u == "number" && u < ((n == null ? void 0 : n.length) || 0) && !(o != null && o.length))
|
|
210
|
-
return {
|
|
211
|
-
blocks: n[u].blocks,
|
|
212
|
-
path: `component.options.variants.${u}.blocks`
|
|
213
|
-
};
|
|
214
|
-
const l = o == null ? void 0 : o[0];
|
|
215
|
-
return l ? {
|
|
216
|
-
blocks: l.blocks,
|
|
217
|
-
path: `component.options.variants.${n == null ? void 0 : n.indexOf(l)}.blocks`
|
|
218
|
-
} : {
|
|
219
|
-
blocks: d || [],
|
|
220
|
-
path: void 0
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
const G = (e, n, u) => `
|
|
224
|
-
(function() {
|
|
225
|
-
${H}
|
|
226
|
-
${U}
|
|
227
|
-
getPersonalizedVariant(${JSON.stringify(e)}, "${n}"${u ? `, "${u}"` : ""})
|
|
228
|
-
})();
|
|
229
|
-
`;
|
|
230
|
-
function re(e) {
|
|
231
|
-
var t, h, D, C, N, T, I;
|
|
232
|
-
const n = O(null), [u, m] = w(
|
|
233
|
-
() => P.getUserAttributes()
|
|
234
|
-
), [o, d] = w(
|
|
235
|
-
() => {
|
|
236
|
-
var a, s, i;
|
|
237
|
-
return G(
|
|
238
|
-
e.variants,
|
|
239
|
-
((a = e.builderBlock) == null ? void 0 : a.id) || "none",
|
|
240
|
-
(i = (s = e.builderContext) == null ? void 0 : s.rootState) == null ? void 0 : i.locale
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
), [b, l] = w(() => []), [p, f] = w(
|
|
244
|
-
() => {
|
|
245
|
-
var a;
|
|
246
|
-
return L(
|
|
247
|
-
e.variants,
|
|
248
|
-
z((a = e.builderContext) == null ? void 0 : a.canTrack)
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
), [c, S] = w(() => !1);
|
|
252
|
-
function g() {
|
|
253
|
-
return (e.variants || []).filter((a) => {
|
|
254
|
-
var s, i, y, k;
|
|
255
|
-
return M(
|
|
256
|
-
{
|
|
257
|
-
...(i = (s = e.builderContext) == null ? void 0 : s.rootState) != null && i.locale ? {
|
|
258
|
-
locale: (k = (y = e.builderContext) == null ? void 0 : y.rootState) == null ? void 0 : k.locale
|
|
259
|
-
} : {},
|
|
260
|
-
...u
|
|
261
|
-
},
|
|
262
|
-
a.query,
|
|
263
|
-
a.startDate,
|
|
264
|
-
a.endDate
|
|
265
|
-
);
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
function v() {
|
|
269
|
-
var a;
|
|
270
|
-
return F({
|
|
271
|
-
variants: e.variants,
|
|
272
|
-
fallbackBlocks: (a = e.builderBlock) == null ? void 0 : a.children,
|
|
273
|
-
isHydrated: c,
|
|
274
|
-
filteredVariants: g(),
|
|
275
|
-
previewingIndex: e.previewingIndex
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
function r() {
|
|
279
|
-
return (e.variants || []).map(
|
|
280
|
-
(a, s) => {
|
|
281
|
-
var i;
|
|
282
|
-
return `[data-variant-id="${(i = e.builderBlock) == null ? void 0 : i.id}-${s}"] { display: none; } `;
|
|
283
|
-
}
|
|
284
|
-
).join("");
|
|
285
|
-
}
|
|
286
|
-
return q(() => {
|
|
287
|
-
var s;
|
|
288
|
-
S(!0);
|
|
289
|
-
const a = P.subscribeOnUserAttributesChange(
|
|
290
|
-
(i) => {
|
|
291
|
-
m(i);
|
|
292
|
-
}
|
|
293
|
-
);
|
|
294
|
-
if (!($() || _())) {
|
|
295
|
-
const i = g()[0];
|
|
296
|
-
n.current && (n.current.dispatchEvent(
|
|
297
|
-
new CustomEvent("builder.variantLoaded", {
|
|
298
|
-
detail: {
|
|
299
|
-
variant: i || "default",
|
|
300
|
-
content: (s = e.builderContext) == null ? void 0 : s.content
|
|
301
|
-
},
|
|
302
|
-
bubbles: !0
|
|
303
|
-
})
|
|
304
|
-
), new IntersectionObserver((k) => {
|
|
305
|
-
k.forEach((W) => {
|
|
306
|
-
var A;
|
|
307
|
-
W.isIntersecting && n.current && n.current.dispatchEvent(
|
|
308
|
-
new CustomEvent("builder.variantDisplayed", {
|
|
309
|
-
detail: {
|
|
310
|
-
variant: i || "default",
|
|
311
|
-
content: (A = e.builderContext) == null ? void 0 : A.content
|
|
312
|
-
},
|
|
313
|
-
bubbles: !0
|
|
314
|
-
})
|
|
315
|
-
);
|
|
316
|
-
});
|
|
317
|
-
}).observe(n.current));
|
|
318
|
-
}
|
|
319
|
-
b.push(a);
|
|
320
|
-
}, []), q(() => () => {
|
|
321
|
-
b.forEach((a) => a());
|
|
322
|
-
}, []), /* @__PURE__ */ x(
|
|
323
|
-
"div",
|
|
324
|
-
{
|
|
325
|
-
ref: n,
|
|
326
|
-
...e.attributes,
|
|
327
|
-
className: `builder-personalization-container ${((t = e.attributes) == null ? void 0 : t.class) || ""}`,
|
|
328
|
-
children: [
|
|
329
|
-
p ? /* @__PURE__ */ x(B, { children: [
|
|
330
|
-
(h = e.variants) == null ? void 0 : h.map((a, s) => {
|
|
331
|
-
var i, y;
|
|
332
|
-
return /* @__PURE__ */ V(
|
|
333
|
-
"template",
|
|
334
|
-
{
|
|
335
|
-
"data-variant-id": `${(i = e.builderBlock) == null ? void 0 : i.id}-${s}`,
|
|
336
|
-
children: /* @__PURE__ */ V(
|
|
337
|
-
E,
|
|
338
|
-
{
|
|
339
|
-
blocks: a.blocks,
|
|
340
|
-
parent: (y = e.builderBlock) == null ? void 0 : y.id,
|
|
341
|
-
path: `component.options.variants.${s}.blocks`
|
|
342
|
-
}
|
|
343
|
-
)
|
|
344
|
-
},
|
|
345
|
-
s
|
|
346
|
-
);
|
|
347
|
-
}),
|
|
348
|
-
/* @__PURE__ */ V(
|
|
349
|
-
R,
|
|
350
|
-
{
|
|
351
|
-
nonce: ((D = e.builderContext) == null ? void 0 : D.nonce) || "",
|
|
352
|
-
styles: r(),
|
|
353
|
-
id: `variants-styles-${(C = e.builderBlock) == null ? void 0 : C.id}`
|
|
354
|
-
}
|
|
355
|
-
),
|
|
356
|
-
/* @__PURE__ */ V(
|
|
357
|
-
j,
|
|
358
|
-
{
|
|
359
|
-
nonce: ((N = e.builderContext) == null ? void 0 : N.nonce) || "",
|
|
360
|
-
scriptStr: o,
|
|
361
|
-
id: `variants-script-${(T = e.builderBlock) == null ? void 0 : T.id}`
|
|
362
|
-
}
|
|
363
|
-
)
|
|
364
|
-
] }) : null,
|
|
365
|
-
/* @__PURE__ */ V(
|
|
366
|
-
E,
|
|
367
|
-
{
|
|
368
|
-
blocks: v().blocks,
|
|
369
|
-
parent: (I = e.builderBlock) == null ? void 0 : I.id,
|
|
370
|
-
path: v().path
|
|
371
|
-
}
|
|
372
|
-
)
|
|
373
|
-
]
|
|
374
|
-
}
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
export {
|
|
378
|
-
re as default
|
|
379
|
-
};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";function c(){return typeof window!="undefined"&&typeof document!="undefined"}const E="[Builder.io]: ",d={log:(...t)=>console.log(E,...t),error:(...t)=>console.error(E,...t),warn:(...t)=>console.warn(E,...t),debug:(...t)=>console.debug(E,...t)},p=t=>t!=null,mt=t=>{if(t==="localhost"||t==="127.0.0.1")return t;const e=t.split(".");return e.length>2?e.slice(1).join("."):t},O=({name:t,canTrack:e})=>{var n;try{return e?(n=document.cookie.split("; ").find(r=>r.startsWith(`${t}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){d.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},j=async t=>O(t),bt=t=>t.map(([e,n])=>n?`${e}=${n}`:e).filter(p).join("; "),yt=[["secure",""],["SameSite","None"]],St=({name:t,value:e,expires:n})=>{const s=(c()?location.protocol==="https:":!0)?yt:[[]],o=n?[["expires",n.toUTCString()]]:[[]],i=[[t,e],...o,["path","/"],["domain",mt(window.location.hostname)],...s];return bt(i)},C=async({name:t,value:e,expires:n,canTrack:r})=>{try{if(!r)return;const s=St({name:t,value:e,expires:n});document.cookie=s}catch(s){d.warn("[COOKIE] SET error: ",(s==null?void 0:s.message)||s)}},V="builder.userAttributes";function wt(){let t=!0;const e=new Set;return{setUserAttributes(n){if(!c())return;const r={...this.getUserAttributes(),...n};C({name:V,value:JSON.stringify(r),canTrack:t}),e.forEach(s=>s(r))},getUserAttributes(){return c()?JSON.parse(O({name:V,canTrack:t})||"{}"):{}},subscribeOnUserAttributesChange(n){return e.add(n),()=>{e.delete(n)}},setCanTrack(n){t=n}}}const P=wt(),vt=t=>{P.setUserAttributes(t)},y="react",Et=t=>{const e={};return t.forEach((n,r)=>{e[r]=n}),e},W=t=>t instanceof URLSearchParams?Et(t):t,$=t=>typeof t=="string"?t:t instanceof URLSearchParams?t.toString():new URLSearchParams(t).toString();function It(){return c()&&window.self!==window.top}function G(t){return It()&&$(t||window.location.search).indexOf("builder.frameEditing=")!==-1}function kt(t){const e=t||(c()?window.location.search:void 0);return e?$(e).indexOf("builder.preview=")!==-1:!1}const At=t=>({type:"builder.registerComponent",data:T(t)}),Ot=t=>{const e=t.toString().trim(),n=/^[a-zA-Z0-9_]+\s*=>/i.test(e);return`return (${!e.startsWith("function")&&!e.startsWith("async")&&!e.startsWith("(")&&!n?"function ":""}${e}).apply(this, arguments)`};function T(t){return JSON.parse(JSON.stringify(t,(e,n)=>typeof n=="function"?Ot(n):n))}const N={};function J(t,e){t==="plugin"&&(e=T(e));let n=N[t];if(n||(n=N[t]=[]),n.push(e),c()){const r={type:"builder.register",data:{type:t,info:e}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(s){console.debug("Could not postmessage",s)}}}const D={};function Ct(t){if(c()){Object.assign(D,t);const e={type:"builder.settingsChange",data:D};parent.postMessage(e,"*")}}const M="builder.",Pt="options.",U=t=>{if(!t)return{};const e=W(t),n={};return Object.keys(e).forEach(r=>{if(r.startsWith(M)){const s=r.replace(M,"").replace(Pt,"");n[s]=e[r]}}),n},Tt=()=>{if(!c())return{};const t=new URLSearchParams(window.location.search);return U(t)},z="3.0.3",H=()=>({"X-Builder-SDK":y,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":z});function Ut(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}function X(){return Ut().replace(/-/g,"")}const Q="builderSessionId",Bt=async({canTrack:t})=>{if(!t)return;const e=await j({name:Q,canTrack:t});if(p(e))return e;{const n=xt();return Rt({id:n,canTrack:t}),n}},xt=()=>X(),Rt=({id:t,canTrack:e})=>C({name:Q,value:t,canTrack:e}),Y=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Lt=({key:t,canTrack:e})=>{var n;try{return e?(n=Y())==null?void 0:n.getItem(t):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Ft=({key:t,canTrack:e,value:n})=>{var r;try{e&&((r=Y())==null||r.setItem(t,n))}catch(s){console.debug("[LocalStorage] SET error: ",s)}},Z="builderVisitorId",Vt=({canTrack:t})=>{if(!t)return;const e=Lt({key:Z,canTrack:t});if(p(e))return e;{const n=Nt();return Dt({id:n,canTrack:t}),n}},Nt=()=>X(),Dt=({id:t,canTrack:e})=>Ft({key:Z,value:t,canTrack:e});function q(t){var e;typeof process!="undefined"&&((e=process.env)!=null&&e.DEBUG)&&String(process.env.DEBUG)=="true"&&d.log(t)}const Mt=()=>{if(c()){const t=new URL(location.href);return t.pathname===""&&(t.pathname="/"),t}else return console.warn("Cannot get location for tracking in non-browser environment"),null},Kt=()=>typeof navigator=="object"&&navigator.userAgent||"",tt=()=>{const t=Kt(),e={Android(){return t.match(/Android/i)},BlackBerry(){return t.match(/BlackBerry/i)},iOS(){return t.match(/iPhone|iPod/i)},Opera(){return t.match(/Opera Mini/i)},Windows(){return t.match(/IEMobile/i)||t.match(/WPDesktop/i)},any(){return e.Android()||e.BlackBerry()||e.iOS()||e.Opera()||e.Windows()||y==="reactNative"}},n=t.match(/Tablet|iPad/i),r=Mt();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":e.any()?"mobile":"desktop"}},_t=async({canTrack:t})=>{if(!t)return{visitorId:void 0,sessionId:void 0};const e=await Bt({canTrack:t}),n=Vt({canTrack:t});return{sessionId:e,visitorId:n}},jt=async({type:t,canTrack:e,apiKey:n,metadata:r,...s})=>({type:t,data:{...s,metadata:{url:location.href,...r},...await _t({canTrack:e}),userAttributes:tt(),ownerId:n}});async function et({apiHost:t,...e}){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(!e.canTrack||G()||!(c()||y==="reactNative"))return;const r=`${t||"https://cdn.builder.io"}/api/v1/track`;return q(r),fetch(r,{method:"POST",body:JSON.stringify({events:[await jt(e)]}),headers:{"content-type":"application/json",...H()},mode:"cors"}).catch(s=>{console.error("Failed to track: ",s)})}const Wt=t=>et({...t,canTrack:!0}),$t=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function nt(t,e){if(!e.origin.startsWith("http")&&!e.origin.startsWith("https"))return!1;const n=new URL(e.origin),r=n.hostname;return(t||$t).findIndex(s=>s.startsWith("*.")?r.endsWith(s.slice(1)):s===r)>-1}const Gt=()=>{J("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let K=!1;const rt=(t={})=>{var e,n;K||(K=!0,c()&&((e=window.parent)==null||e.postMessage({type:"builder.sdkInfo",data:{target:y,version:z,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0,blockLevelPersonalization:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:t}},"*"),window.addEventListener("message",r=>{var o,i;if(!nt(t.trustedHosts,r))return;const{data:s}=r;if(s!=null&&s.type)switch(s.type){case"builder.evaluate":{const u=s.data.text,S=s.data.arguments||[],m=s.data.id,I=new Function(u);let l,g=null;try{l=I.apply(null,S)}catch(h){g=h}g?(o=window.parent)==null||o.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):l&&typeof l.then=="function"?l.then(h=>{var w;(w=window.parent)==null||w.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:l,id:m}},"*");break}}})))},st=({model:t,trustedHosts:e,callbacks:n})=>r=>{if(!nt(e,r))return;const{data:s}=r;if(s)switch(s.type){case"builder.configureSdk":{n.configureSdk(s.data);break}case"builder.triggerAnimation":{n.animation(s.data);break}case"builder.contentUpdate":{const o=s.data,i=o.key||o.alias||o.entry||o.modelName,u=o.data;i===t&&n.contentUpdate(u);break}}},Jt=(t,e,n)=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};rt();const r=st({callbacks:{contentUpdate:e,animation:()=>{},configureSdk:()=>{}},model:t,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},zt="builder.tests",B=t=>`${zt}.${t}`,Ht=({contentId:t})=>j({name:B(t),canTrack:!0}),Xt=({contentId:t})=>O({name:B(t),canTrack:!0}),Qt=({contentId:t,value:e})=>C({name:B(t),value:e,canTrack:!0}),ot=t=>p(t.id)&&p(t.variations)&&Object.keys(t.variations).length>0,Yt=({id:t,variations:e})=>{var s;let n=0;const r=Math.random();for(const o in e){const i=(s=e[o])==null?void 0:s.testRatio;if(n+=i,r<n)return o}return t},it=t=>{const e=Yt(t);return Qt({contentId:t.id,value:e}).catch(n=>{d.error("could not store A/B test variation: ",n)}),e},at=({item:t,testGroupId:e})=>{const n=t.variations[e];return e===t.id||!n?{testVariationId:t.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===t.id?"Default":"")}},Zt=({item:t,canTrack:e})=>{if(!e)return t;if(!t)return;if(!ot(t))return t;const n=Xt({contentId:t.id})||it({variations:t.variations,id:t.id}),r=at({item:t,testGroupId:n});return{...t,...r}},qt=async({item:t,canTrack:e})=>{if(!e||!ot(t))return t;const r=await Ht({contentId:t.id})||it({variations:t.variations,id:t.id}),s=at({item:t,testGroupId:r});return{...t,...s}},ct=t=>{const e=p(t)?t:!0;return P.setCanTrack(e),e};function te(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function ee(){const t=te().fetch;if(typeof t=="undefined")throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2
|
-
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`),new Error("Builder SDK could not find a global `fetch` function");return t}const ne=ee();function A(t,e=null,n="."){return Object.keys(t).reduce((r,s)=>{const o=t[s],i=[e,s].filter(Boolean).join(n);return[typeof o=="object",o!==null,!(Array.isArray(o)&&o.length===0)].every(Boolean)?{...r,...A(o,i,n)}:{...r,[i]:o}},{})}function ut(t,e,n={}){for(const r in t){const s=t[r],o=e?e+"."+r:r;s&&typeof s=="object"&&!Array.isArray(s)&&!Object.keys(s).find(i=>i.startsWith("$"))?ut(s,o,n):n[o]=s}return n}function re(t){const e={};for(const n in t){const r=n.split(".");let s=e;for(let o=0;o<r.length;o++){const i=r[o];o===r.length-1?s[i]=t[n]:(s[i]=s[i]||{},s=s[i])}}return e}const se="v3",_=t=>typeof t=="number"&&!isNaN(t)&&t>=0,x=t=>{const{limit:e=30,userAttributes:n,query:r,model:s,apiKey:o,enrich:i,locale:u,apiVersion:S=se,fields:m,omit:I,offset:l,cacheSeconds:g,staleCacheSeconds:h,sort:w,includeUnpublished:R,apiHost:gt}=t;if(!o)throw new Error("Missing API key");if(!["v3"].includes(S))throw new Error(`Invalid apiVersion: expected 'v3', received '${S}'`);const ht=e!==1,pt=gt||"https://cdn.builder.io",a=new URL(`${pt}/api/${S}/content/${s}`);a.searchParams.set("apiKey",o),a.searchParams.set("limit",String(e)),a.searchParams.set("noTraverse",String(ht)),a.searchParams.set("includeRefs",String(!0));const k=u||(n==null?void 0:n.locale);let b=n||{};if(k&&(a.searchParams.set("locale",k),b={locale:k,...b}),i&&a.searchParams.set("enrich",String(i)),a.searchParams.set("omit",I||"meta.componentsUsed"),m&&a.searchParams.set("fields",m),Number.isFinite(l)&&l>-1&&a.searchParams.set("offset",String(Math.floor(l))),typeof R=="boolean"&&a.searchParams.set("includeUnpublished",String(R)),g&&_(g)&&a.searchParams.set("cacheSeconds",String(g)),h&&_(h)&&a.searchParams.set("staleCacheSeconds",String(h)),w){const f=A({sort:w});for(const v in f)a.searchParams.set(v,JSON.stringify(f[v]))}const L={...Tt(),...W(t.options||{})};b={...b,...ie(L)};const F=A(L);for(const f in F)a.searchParams.set(f,String(F[f]));if(Object.keys(b).length>0&&a.searchParams.set("userAttributes",JSON.stringify(b)),r){const f=ut({query:r});for(const v in f)a.searchParams.set(v,JSON.stringify(f[v]))}return a},oe=t=>{const e={};for(const n in t)n.startsWith("userAttributes.")&&(e[n]=t[n],delete t[n]);return e},ie=t=>{if(c()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const e=oe(t),{userAttributes:n}=re(e);return n}return{}},ae=t=>"results"in t;async function lt(t){const e=await ft({...t,limit:1});return e&&e[0]||null}const ce=async t=>{var i,u;const e=x(t),n=(i=t.fetch)!=null?i:ne,r={...t.fetchOptions,headers:{...(u=t.fetchOptions)==null?void 0:u.headers,...H()}};return await(await n(e.href,r)).json()},dt=async(t,e,n=x(t))=>{const r=ct(t.canTrack);if(n.search.includes("preview="),!r||!(c()||y==="reactNative"))return e.results;try{const s=[];for(const o of e.results)s.push(await qt({item:o,canTrack:r}));e.results=s}catch(s){d.error("Could not process A/B tests. ",s)}return e.results};async function ft(t){const e=x(t),n=await ce(t);if(!ae(n))throw d.error("Error fetching data. ",{url:e,content:n,options:t}),n;return dt(t,n)}const ue=async t=>{var r,s,o;const e=t.path||((r=t.url)==null?void 0:r.pathname)||((s=t.userAttributes)==null?void 0:s.urlPath),n={...t,apiKey:t.apiKey,model:t.model||"page",userAttributes:{...t.userAttributes,...e?{urlPath:e}:{}},options:U(t.searchParams||((o=t.url)==null?void 0:o.searchParams)||t.options)};return{apiKey:n.apiKey,model:n.model,content:await lt(n)}};exports.TARGET=y;exports._processContentResult=dt;exports._track=et;exports.checkIsDefined=p;exports.createEditorListener=st;exports.createRegisterComponentMessage=At;exports.fetchBuilderProps=ue;exports.fetchEntries=ft;exports.fetchOneEntry=lt;exports.getBuilderSearchParams=U;exports.getDefaultCanTrack=ct;exports.getUserAttributes=tt;exports.handleABTestingSync=Zt;exports.isBrowser=c;exports.isEditing=G;exports.isPreviewing=kt;exports.logFetch=q;exports.logger=d;exports.register=J;exports.registerInsertMenu=Gt;exports.serializeIncludingFunctions=T;exports.setClientUserAttributes=vt;exports.setEditorSettings=Ct;exports.setupBrowserForEditing=rt;exports.subscribeToEditor=Jt;exports.track=Wt;exports.userAttributesService=P;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime");function s(e){var i,l,n,o,d,u,a;function c(){return{...e.autoPlay===!0?{autoPlay:!0}:{},...e.muted===!0?{muted:!0}:{},...e.controls===!0?{controls:!0}:{},...e.loop===!0?{loop:!0}:{},...e.playsInline===!0?{playsInline:!0}:{}}}function r(){return{...c()}}return t.jsxs("div",{style:{position:"relative"},children:[t.jsx("video",{className:"builder-video",...r(),preload:e.preload||"metadata",style:{width:"100%",height:"100%",...(i=e.attributes)==null?void 0:i.style,objectFit:e.fit,objectPosition:e.position,zIndex:2,borderRadius:"1px",...e.aspectRatio?{position:"absolute"}:null},src:e.video||"no-src",poster:e.posterImage,children:e.lazyLoad?null:t.jsx("source",{type:"video/mp4",src:e.video})}),e.aspectRatio&&!(e.fitContent&&((n=(l=e.builderBlock)==null?void 0:l.children)!=null&&n.length))?t.jsx("div",{style:{width:"100%",paddingTop:e.aspectRatio*100+"%",pointerEvents:"none",fontSize:"0px"}}):null,(d=(o=e.builderBlock)==null?void 0:o.children)!=null&&d.length&&e.fitContent?t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"stretch"},children:e.children}):null,(a=(u=e.builderBlock)==null?void 0:u.children)!=null&&a.length&&!e.fitContent?t.jsx("div",{style:{pointerEvents:"none",display:"flex",flexDirection:"column",alignItems:"stretch",position:"absolute",top:"0",left:"0",width:"100%",height:"100%"},children:e.children}):null]})}exports.default=s;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const y="react",E="[Builder.io]: ",d={log:(...t)=>console.log(E,...t),error:(...t)=>console.error(E,...t),warn:(...t)=>console.warn(E,...t),debug:(...t)=>console.debug(E,...t)};function c(){return typeof window!="undefined"&&typeof document!="undefined"}const mt=t=>{const e={};return t.forEach((n,r)=>{e[r]=n}),e},j=t=>t instanceof URLSearchParams?mt(t):t,W=t=>typeof t=="string"?t:t instanceof URLSearchParams?t.toString():new URLSearchParams(t).toString();function bt(){return c()&&window.self!==window.top}function G(t){return bt()&&W(t||window.location.search).indexOf("builder.frameEditing=")!==-1}const yt=()=>{if(c()){const t=new URL(location.href);return t.pathname===""&&(t.pathname="/"),t}else return console.warn("Cannot get location for tracking in non-browser environment"),null},St=()=>typeof navigator=="object"&&navigator.userAgent||"",$=()=>{const t=St(),e={Android(){return t.match(/Android/i)},BlackBerry(){return t.match(/BlackBerry/i)},iOS(){return t.match(/iPhone|iPod/i)},Opera(){return t.match(/Opera Mini/i)},Windows(){return t.match(/IEMobile/i)||t.match(/WPDesktop/i)},any(){return e.Android()||e.BlackBerry()||e.iOS()||e.Opera()||e.Windows()||y==="reactNative"}},n=t.match(/Tablet|iPad/i),r=yt();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":e.any()?"mobile":"desktop"}},p=t=>t!=null;function wt(t){const e=t||(c()?window.location.search:void 0);return e?W(e).indexOf("builder.preview=")!==-1:!1}const vt=t=>({type:"builder.registerComponent",data:O(t)}),Et=t=>{const e=t.toString().trim(),n=/^[a-zA-Z0-9_]+\s*=>/i.test(e);return`return (${!e.startsWith("function")&&!e.startsWith("async")&&!e.startsWith("(")&&!n?"function ":""}${e}).apply(this, arguments)`};function O(t){return JSON.parse(JSON.stringify(t,(e,n)=>typeof n=="function"?Et(n):n))}const V={};function J(t,e){t==="plugin"&&(e=O(e));let n=V[t];if(n||(n=V[t]=[]),n.push(e),c()){const r={type:"builder.register",data:{type:t,info:e}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(s){console.debug("Could not postmessage",s)}}}const M={};function It(t){if(c()){Object.assign(M,t);const e={type:"builder.settingsChange",data:M};parent.postMessage(e,"*")}}const N="builder.",kt="options.",P=t=>{if(!t)return{};const e=j(t),n={};return Object.keys(e).forEach(r=>{if(r.startsWith(N)){const s=r.replace(N,"").replace(kt,"");n[s]=e[r]}}),n},At=()=>{if(!c())return{};const t=new URLSearchParams(window.location.search);return P(t)},z="3.0.3",X=()=>({"X-Builder-SDK":y,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":z}),Ot=t=>{if(t==="localhost"||t==="127.0.0.1")return t;const e=t.split(".");return e.length>2?e.slice(1).join("."):t},C=({name:t,canTrack:e})=>{var n;try{return e?(n=document.cookie.split("; ").find(r=>r.startsWith(`${t}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){d.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},H=async t=>C(t),Pt=t=>t.map(([e,n])=>n?`${e}=${n}`:e).filter(p).join("; "),Ct=[["secure",""],["SameSite","None"]],Tt=({name:t,value:e,expires:n})=>{const s=(c()?location.protocol==="https:":!0)?Ct:[[]],o=n?[["expires",n.toUTCString()]]:[[]],i=[[t,e],...o,["path","/"],["domain",Ot(window.location.hostname)],...s];return Pt(i)},T=async({name:t,value:e,expires:n,canTrack:r})=>{try{if(!r)return;const s=Tt({name:t,value:e,expires:n});document.cookie=s}catch(s){d.warn("[COOKIE] SET error: ",(s==null?void 0:s.message)||s)}};function Ut(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}function Q(){return Ut().replace(/-/g,"")}const Y="builderSessionId",Bt=async({canTrack:t})=>{if(!t)return;const e=await H({name:Y,canTrack:t});if(p(e))return e;{const n=Rt();return xt({id:n,canTrack:t}),n}},Rt=()=>Q(),xt=({id:t,canTrack:e})=>T({name:Y,value:t,canTrack:e}),Z=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Lt=({key:t,canTrack:e})=>{var n;try{return e?(n=Z())==null?void 0:n.getItem(t):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Ft=({key:t,canTrack:e,value:n})=>{var r;try{e&&((r=Z())==null||r.setItem(t,n))}catch(s){console.debug("[LocalStorage] SET error: ",s)}},q="builderVisitorId",Vt=({canTrack:t})=>{if(!t)return;const e=Lt({key:q,canTrack:t});if(p(e))return e;{const n=Mt();return Nt({id:n,canTrack:t}),n}},Mt=()=>Q(),Nt=({id:t,canTrack:e})=>Ft({key:q,value:t,canTrack:e});function tt(t){var e;typeof process!="undefined"&&((e=process.env)!=null&&e.DEBUG)&&String(process.env.DEBUG)=="true"&&d.log(t)}const Dt=async({canTrack:t})=>{if(!t)return{visitorId:void 0,sessionId:void 0};const e=await Bt({canTrack:t}),n=Vt({canTrack:t});return{sessionId:e,visitorId:n}},Kt=async({type:t,canTrack:e,apiKey:n,metadata:r,...s})=>({type:t,data:{...s,metadata:{url:location.href,...r},...await Dt({canTrack:e}),userAttributes:$(),ownerId:n}});async function et({apiHost:t,...e}){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(!e.canTrack||G()||!(c()||y==="reactNative"))return;const r=`${t||"https://cdn.builder.io"}/api/v1/track`;return tt(r),fetch(r,{method:"POST",body:JSON.stringify({events:[await Kt(e)]}),headers:{"content-type":"application/json",...X()},mode:"cors"}).catch(s=>{console.error("Failed to track: ",s)})}const _t=t=>et({...t,canTrack:!0}),jt=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function nt(t,e){if(!e.origin.startsWith("http")&&!e.origin.startsWith("https"))return!1;const n=new URL(e.origin),r=n.hostname;return(t||jt).findIndex(s=>s.startsWith("*.")?r.endsWith(s.slice(1)):s===r)>-1}const Wt=()=>{J("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let D=!1;const rt=(t={})=>{var e,n;D||(D=!0,c()&&((e=window.parent)==null||e.postMessage({type:"builder.sdkInfo",data:{target:y,version:z,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0,blockLevelPersonalization:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:t}},"*"),window.addEventListener("message",r=>{var o,i;if(!nt(t.trustedHosts,r))return;const{data:s}=r;if(s!=null&&s.type)switch(s.type){case"builder.evaluate":{const u=s.data.text,S=s.data.arguments||[],m=s.data.id,I=new Function(u);let l,g=null;try{l=I.apply(null,S)}catch(h){g=h}g?(o=window.parent)==null||o.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):l&&typeof l.then=="function"?l.then(h=>{var w;(w=window.parent)==null||w.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:l,id:m}},"*");break}}})))},st=({model:t,trustedHosts:e,callbacks:n})=>r=>{if(!nt(e,r))return;const{data:s}=r;if(s)switch(s.type){case"builder.configureSdk":{n.configureSdk(s.data);break}case"builder.triggerAnimation":{n.animation(s.data);break}case"builder.contentUpdate":{const o=s.data,i=o.key||o.alias||o.entry||o.modelName,u=o.data;i===t&&n.contentUpdate(u);break}}},Gt=(t,e,n)=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};rt();const r=st({callbacks:{contentUpdate:e,animation:()=>{},configureSdk:()=>{}},model:t,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},$t="builder.tests",U=t=>`${$t}.${t}`,Jt=({contentId:t})=>H({name:U(t),canTrack:!0}),zt=({contentId:t})=>C({name:U(t),canTrack:!0}),Xt=({contentId:t,value:e})=>T({name:U(t),value:e,canTrack:!0}),ot=t=>p(t.id)&&p(t.variations)&&Object.keys(t.variations).length>0,Ht=({id:t,variations:e})=>{var s;let n=0;const r=Math.random();for(const o in e){const i=(s=e[o])==null?void 0:s.testRatio;if(n+=i,r<n)return o}return t},it=t=>{const e=Ht(t);return Xt({contentId:t.id,value:e}).catch(n=>{d.error("could not store A/B test variation: ",n)}),e},at=({item:t,testGroupId:e})=>{const n=t.variations[e];return e===t.id||!n?{testVariationId:t.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===t.id?"Default":"")}},Qt=({item:t,canTrack:e})=>{if(!e)return t;if(!t)return;if(!ot(t))return t;const n=zt({contentId:t.id})||it({variations:t.variations,id:t.id}),r=at({item:t,testGroupId:n});return{...t,...r}},Yt=async({item:t,canTrack:e})=>{if(!e||!ot(t))return t;const r=await Jt({contentId:t.id})||it({variations:t.variations,id:t.id}),s=at({item:t,testGroupId:r});return{...t,...s}},K="builder.userAttributes";function Zt(){let t=!0;const e=new Set;return{setUserAttributes(n){if(!c())return;const r={...this.getUserAttributes(),...n};T({name:K,value:JSON.stringify(r),canTrack:t}),e.forEach(s=>s(r))},getUserAttributes(){return c()?JSON.parse(C({name:K,canTrack:t})||"{}"):{}},subscribeOnUserAttributesChange(n){return e.add(n),()=>{e.delete(n)}},setCanTrack(n){t=n}}}const B=Zt(),qt=t=>{B.setUserAttributes(t)},ct=t=>{const e=p(t)?t:!0;return B.setCanTrack(e),e};function te(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function ee(){const t=te().fetch;if(typeof t=="undefined")throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2
|
-
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`),new Error("Builder SDK could not find a global `fetch` function");return t}const ne=ee();function A(t,e=null,n="."){return Object.keys(t).reduce((r,s)=>{const o=t[s],i=[e,s].filter(Boolean).join(n);return[typeof o=="object",o!==null,!(Array.isArray(o)&&o.length===0)].every(Boolean)?{...r,...A(o,i,n)}:{...r,[i]:o}},{})}function ut(t,e,n={}){for(const r in t){const s=t[r],o=e?e+"."+r:r;s&&typeof s=="object"&&!Array.isArray(s)&&!Object.keys(s).find(i=>i.startsWith("$"))?ut(s,o,n):n[o]=s}return n}function re(t){const e={};for(const n in t){const r=n.split(".");let s=e;for(let o=0;o<r.length;o++){const i=r[o];o===r.length-1?s[i]=t[n]:(s[i]=s[i]||{},s=s[i])}}return e}const se="v3",_=t=>typeof t=="number"&&!isNaN(t)&&t>=0,R=t=>{const{limit:e=30,userAttributes:n,query:r,model:s,apiKey:o,enrich:i,locale:u,apiVersion:S=se,fields:m,omit:I,offset:l,cacheSeconds:g,staleCacheSeconds:h,sort:w,includeUnpublished:x,apiHost:gt}=t;if(!o)throw new Error("Missing API key");if(!["v3"].includes(S))throw new Error(`Invalid apiVersion: expected 'v3', received '${S}'`);const ht=e!==1,pt=gt||"https://cdn.builder.io",a=new URL(`${pt}/api/${S}/content/${s}`);a.searchParams.set("apiKey",o),a.searchParams.set("limit",String(e)),a.searchParams.set("noTraverse",String(ht)),a.searchParams.set("includeRefs",String(!0));const k=u||(n==null?void 0:n.locale);let b=n||{};if(k&&(a.searchParams.set("locale",k),b={locale:k,...b}),i&&a.searchParams.set("enrich",String(i)),a.searchParams.set("omit",I||"meta.componentsUsed"),m&&a.searchParams.set("fields",m),Number.isFinite(l)&&l>-1&&a.searchParams.set("offset",String(Math.floor(l))),typeof x=="boolean"&&a.searchParams.set("includeUnpublished",String(x)),g&&_(g)&&a.searchParams.set("cacheSeconds",String(g)),h&&_(h)&&a.searchParams.set("staleCacheSeconds",String(h)),w){const f=A({sort:w});for(const v in f)a.searchParams.set(v,JSON.stringify(f[v]))}const L={...At(),...j(t.options||{})};b={...b,...ie(L)};const F=A(L);for(const f in F)a.searchParams.set(f,String(F[f]));if(Object.keys(b).length>0&&a.searchParams.set("userAttributes",JSON.stringify(b)),r){const f=ut({query:r});for(const v in f)a.searchParams.set(v,JSON.stringify(f[v]))}return a},oe=t=>{const e={};for(const n in t)n.startsWith("userAttributes.")&&(e[n]=t[n],delete t[n]);return e},ie=t=>{if(c()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const e=oe(t),{userAttributes:n}=re(e);return n}return{}},ae=t=>"results"in t;async function lt(t){const e=await ft({...t,limit:1});return e&&e[0]||null}const ce=async t=>{var i,u;const e=R(t),n=(i=t.fetch)!=null?i:ne,r={...t.fetchOptions,headers:{...(u=t.fetchOptions)==null?void 0:u.headers,...X()}};return await(await n(e.href,r)).json()},dt=async(t,e,n=R(t))=>{const r=ct(t.canTrack);if(n.search.includes("preview="),!r||!(c()||y==="reactNative"))return e.results;try{const s=[];for(const o of e.results)s.push(await Yt({item:o,canTrack:r}));e.results=s}catch(s){d.error("Could not process A/B tests. ",s)}return e.results};async function ft(t){const e=R(t),n=await ce(t);if(!ae(n))throw d.error("Error fetching data. ",{url:e,content:n,options:t}),n;return dt(t,n)}const ue=async t=>{var r,s,o;const e=t.path||((r=t.url)==null?void 0:r.pathname)||((s=t.userAttributes)==null?void 0:s.urlPath),n={...t,apiKey:t.apiKey,model:t.model||"page",userAttributes:{...t.userAttributes,...e?{urlPath:e}:{}},options:P(t.searchParams||((o=t.url)==null?void 0:o.searchParams)||t.options)};return{apiKey:n.apiKey,model:n.model,content:await lt(n)}};exports.MSG_PREFIX=E;exports.TARGET=y;exports._processContentResult=dt;exports._track=et;exports.checkIsDefined=p;exports.createEditorListener=st;exports.createRegisterComponentMessage=vt;exports.fetchBuilderProps=ue;exports.fetchEntries=ft;exports.fetchOneEntry=lt;exports.getBuilderSearchParams=P;exports.getDefaultCanTrack=ct;exports.getUserAttributes=$;exports.handleABTestingSync=Qt;exports.isBrowser=c;exports.isEditing=G;exports.isPreviewing=wt;exports.logFetch=tt;exports.logger=d;exports.register=J;exports.registerInsertMenu=Wt;exports.serializeIncludingFunctions=O;exports.setClientUserAttributes=qt;exports.setEditorSettings=It;exports.setupBrowserForEditing=rt;exports.subscribeToEditor=Gt;exports.track=_t;exports.userAttributesService=B;
|
package/types/blocks/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { BuilderBlock } from '../../../types/builder-block';
|
|
2
|
-
import type { PersonalizationContainerProps } from '../personalization-container.types';
|
|
3
|
-
export declare function checkShouldRenderVariants(variants: PersonalizationContainerProps['variants'], canTrack: boolean): boolean;
|
|
4
|
-
export declare function getBlocksToRender(options: {
|
|
5
|
-
variants: PersonalizationContainerProps['variants'];
|
|
6
|
-
previewingIndex?: number | null;
|
|
7
|
-
isHydrated: boolean;
|
|
8
|
-
filteredVariants: PersonalizationContainerProps['variants'];
|
|
9
|
-
fallbackBlocks?: BuilderBlock[];
|
|
10
|
-
}): {
|
|
11
|
-
blocks: BuilderBlock[];
|
|
12
|
-
path: string | undefined;
|
|
13
|
-
};
|
|
14
|
-
export declare const getPersonalizationScript: (variants: PersonalizationContainerProps['variants'], blockId: string, locale?: string) => string;
|
|
15
|
-
export declare const filterWithCustomTargeting: any;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WARNING: This file contains functions that get stringified and inlined into the HTML at build-time.
|
|
3
|
-
* They cannot import anything.
|
|
4
|
-
*/
|
|
5
|
-
import type { Query, UserAttributes } from '../helpers';
|
|
6
|
-
export declare function filterWithCustomTargeting(userAttributes: UserAttributes, query: Query[], startDate?: string, endDate?: string): boolean;
|
|
7
|
-
export declare const PERSONALIZATION_SCRIPT = "function getPersonalizedVariant(variants, blockId, locale) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) == ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n function removeVariants() {\n variants?.forEach(function (_, index) {\n document.querySelector('template[data-variant-id=\"' + blockId + '-' + index + '\"]')?.remove();\n });\n document.querySelector('script[data-id=\"variants-script-' + blockId + '\"]')?.remove();\n document.querySelector('style[data-id=\"variants-styles-' + blockId + '\"]')?.remove();\n }\n const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');\n if (locale) {\n attributes.locale = locale;\n }\n const winningVariantIndex = variants?.findIndex(function (variant) {\n return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);\n });\n const isDebug = location.href.includes('builder.debug=true');\n if (isDebug) {\n console.debug('PersonalizationContainer', {\n attributes,\n variants,\n winningVariantIndex\n });\n }\n if (winningVariantIndex !== -1) {\n const winningVariant = document.querySelector('template[data-variant-id=\"' + blockId + '-' + winningVariantIndex + '\"]');\n if (winningVariant) {\n const parentNode = winningVariant.parentNode;\n if (parentNode) {\n const newParent = parentNode.cloneNode(false);\n newParent.appendChild(winningVariant.content.firstChild);\n newParent.appendChild(winningVariant.content.lastChild);\n parentNode.parentNode?.replaceChild(newParent, parentNode);\n }\n if (isDebug) {\n console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);\n }\n }\n } else if (variants && variants.length > 0) {\n removeVariants();\n }\n}";
|
|
8
|
-
export declare const FILTER_WITH_CUSTOM_TARGETING_SCRIPT = "function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {\n function isString(val) {\n return typeof val === 'string';\n }\n function isNumber(val) {\n return typeof val === 'number';\n }\n function objectMatchesQuery(userattr, query) {\n const result = (() => {\n const property = query.property;\n const operator = query.operator;\n let testValue = query.value;\n if (query && query.property === 'urlPath' && query.value && typeof query.value === 'string' && query.value !== '/' && query.value.endsWith('/')) {\n testValue = query.value.slice(0, -1);\n }\n if (!(property && operator)) {\n return true;\n }\n if (Array.isArray(testValue)) {\n if (operator === 'isNot') {\n return testValue.every(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n return !!testValue.find(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n const value = userattr[property];\n if (Array.isArray(value)) {\n return value.includes(testValue);\n }\n switch (operator) {\n case 'is':\n return value === testValue;\n case 'isNot':\n return value !== testValue;\n case 'contains':\n return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));\n case 'startsWith':\n return isString(value) && value.startsWith(String(testValue));\n case 'endsWith':\n return isString(value) && value.endsWith(String(testValue));\n case 'greaterThan':\n return isNumber(value) && isNumber(testValue) && value > testValue;\n case 'lessThan':\n return isNumber(value) && isNumber(testValue) && value < testValue;\n case 'greaterThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value >= testValue;\n case 'lessThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value <= testValue;\n default:\n return false;\n }\n })();\n return result;\n }\n const item = {\n query,\n startDate,\n endDate\n };\n const now = userAttributes.date && new Date(userAttributes.date) || new Date();\n if (item.startDate && new Date(item.startDate) > now) {\n return false;\n } else if (item.endDate && new Date(item.endDate) < now) {\n return false;\n }\n if (!item.query || !item.query.length) {\n return true;\n }\n return item.query.every(filter => {\n return objectMatchesQuery(userAttributes, filter);\n });\n}";
|