@builder.io/sdk-react 3.0.1 → 3.0.3-0
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 +169 -32
- package/lib/browser/blocks-exports.mjs +1331 -922
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +17 -16
- package/lib/browser/server-entry-c7bda8b5.cjs +2 -0
- package/lib/browser/server-entry-da1754bd.js +790 -0
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/accordion-388f5e60.cjs +1 -0
- package/lib/edge/{accordion-1572cb0d.js → accordion-50de133c.js} +17 -16
- package/lib/edge/blocks-5e476ddc.js +3534 -0
- package/lib/edge/blocks-a5193d52.cjs +30 -0
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +13 -12
- package/lib/edge/{button-0709893d.js → button-4261ae64.js} +2 -2
- package/lib/edge/{button-cf66cf8d.cjs → button-c6ec3aea.cjs} +1 -1
- package/lib/edge/{columns-e234acc6.js → columns-28e9fb0a.js} +14 -15
- package/lib/edge/columns-8c831c02.cjs +28 -0
- package/lib/edge/{content-variants-3ab9230f.js → content-variants-36ca4fe5.js} +297 -252
- package/lib/edge/content-variants-81713434.cjs +134 -0
- package/lib/edge/{custom-code-6d9730ff.cjs → custom-code-8119ea3f.cjs} +1 -1
- package/lib/edge/dynamic-blocks-exports.cjs +3 -1
- package/lib/edge/dynamic-blocks-exports.mjs +5 -2
- package/lib/edge/{form-27bcc23a.js → form-039fb5ff.js} +7 -8
- package/lib/edge/form-e7a1dec9.cjs +1 -0
- package/lib/edge/{get-class-prop-name-a3bd113c.js → get-class-prop-name-65d6824c.js} +1 -1
- package/lib/edge/{get-class-prop-name-0b3d48a4.cjs → get-class-prop-name-a86a3e60.cjs} +1 -1
- package/lib/edge/{image-5c9e156f.js → image-2a2b26d2.js} +6 -6
- package/lib/edge/{image-94922c87.cjs → image-4db81d72.cjs} +3 -3
- package/lib/edge/{img-80be6914.js → img-61d29fb3.js} +1 -1
- package/lib/edge/{img-e0c8f7f9.cjs → img-7de3a3de.cjs} +1 -1
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +18 -17
- package/lib/edge/{input-f5ba6b1e.cjs → input-bd5387a6.cjs} +1 -1
- package/lib/edge/{input-920922d5.js → input-c8539054.js} +1 -1
- package/lib/edge/personalization-container-3fda6014.cjs +138 -0
- package/lib/edge/personalization-container-c76e4fef.js +379 -0
- package/lib/edge/{select-673864b7.js → select-6b5cda00.js} +1 -1
- package/lib/edge/{select-2ced1aca.cjs → select-73accaf4.cjs} +1 -1
- package/lib/edge/server-entry-838c1f06.js +788 -0
- package/lib/edge/server-entry-ea2a8b0e.cjs +2 -0
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/slot-099112f1.cjs +1 -0
- package/lib/edge/{slot-68f2b177.js → slot-403c77da.js} +5 -6
- package/lib/edge/{symbol-7e260a70.js → symbol-97f456f4.js} +2 -2
- package/lib/edge/{symbol-ded9dba9.cjs → symbol-ffa6e6cd.cjs} +1 -1
- package/lib/edge/{tabs-5156494d.js → tabs-a7c94ead.js} +15 -16
- package/lib/edge/tabs-ad55c6a7.cjs +1 -0
- package/lib/edge/text-5915f038.js +17 -0
- package/lib/edge/text-e6dbb721.cjs +1 -0
- package/lib/node/blocks-exports.cjs +169 -32
- package/lib/node/blocks-exports.mjs +1359 -950
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +17 -16
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +3 -3
- package/lib/node/server-entry-51bc0b1d.js +791 -0
- package/lib/node/server-entry-d7316893.cjs +2 -0
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/lib/node/{setIvm-8b303d4e.js → setIvm-575cf1f1.js} +1 -1
- package/lib/node/{setIvm-aba1bed8.cjs → setIvm-d912cf4d.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-491a9b55.cjs → should-force-browser-runtime-in-node-23225980.cjs} +1 -1
- package/lib/node/{should-force-browser-runtime-in-node-0a037bde.js → should-force-browser-runtime-in-node-66df4856.js} +1 -1
- package/package.json +1 -1
- package/types/blocks/index.d.ts +4 -0
- package/types/blocks/personalization-container/component-info.d.ts +2 -0
- package/types/blocks/personalization-container/helpers/index.d.ts +15 -0
- package/types/blocks/personalization-container/helpers/inlined-fns.d.ts +8 -0
- package/types/blocks/personalization-container/helpers.d.ts +27 -0
- package/types/blocks/personalization-container/index.d.ts +1 -0
- package/types/blocks/personalization-container/personalization-container.d.ts +4 -0
- package/types/blocks/personalization-container/personalization-container.types.d.ts +14 -0
- package/types/blocks/textarea/component-info.d.ts +2 -0
- package/types/blocks/textarea/index.d.ts +1 -0
- package/types/blocks/textarea/textarea.d.ts +14 -0
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/functions/filter-with-custom-targeting.d.ts +15 -0
- package/types/functions/get-block-component-options.d.ts +2 -1
- package/types/functions/get-processed-block.d.ts +1 -6
- package/types/helpers/flatten.d.ts +6 -0
- package/types/helpers/user-attributes.d.ts +17 -0
- package/types/index-helpers/blocks-exports.d.ts +1 -0
- package/types/server-index.d.ts +1 -1
- package/types/types/builder-content.d.ts +1 -0
- package/types/types/input.d.ts +11 -0
- package/lib/browser/server-entry-017b8439.js +0 -717
- package/lib/browser/server-entry-9f80066e.cjs +0 -2
- package/lib/edge/accordion-decb24cf.cjs +0 -1
- package/lib/edge/blocks-9c35be74.js +0 -916
- package/lib/edge/blocks-d3823063.cjs +0 -12
- package/lib/edge/columns-2fdf0656.cjs +0 -28
- package/lib/edge/content-variants-616a6c0f.cjs +0 -134
- package/lib/edge/evaluate-ccf1ad96.cjs +0 -19
- package/lib/edge/evaluate-f0b82ede.js +0 -2612
- package/lib/edge/form-7c61693d.cjs +0 -1
- package/lib/edge/server-entry-6c0047ea.js +0 -715
- package/lib/edge/server-entry-de142ee8.cjs +0 -2
- package/lib/edge/slot-cc8b4e5b.cjs +0 -1
- package/lib/edge/tabs-d422921f.cjs +0 -1
- package/lib/edge/text-27a917c0.js +0 -37
- package/lib/edge/text-5796f488.cjs +0 -1
- package/lib/node/server-entry-e91e06a3.cjs +0 -2
- package/lib/node/server-entry-fdedc1aa.js +0 -718
|
@@ -0,0 +1,791 @@
|
|
|
1
|
+
const v = "react", I = "[Builder.io]: ", f = {
|
|
2
|
+
log: (...t) => console.log(I, ...t),
|
|
3
|
+
error: (...t) => console.error(I, ...t),
|
|
4
|
+
warn: (...t) => console.warn(I, ...t),
|
|
5
|
+
debug: (...t) => console.debug(I, ...t)
|
|
6
|
+
};
|
|
7
|
+
function c() {
|
|
8
|
+
return typeof window != "undefined" && typeof document != "undefined";
|
|
9
|
+
}
|
|
10
|
+
const ot = (t) => {
|
|
11
|
+
const e = {};
|
|
12
|
+
return t.forEach((n, r) => {
|
|
13
|
+
e[r] = n;
|
|
14
|
+
}), e;
|
|
15
|
+
}, M = (t) => t instanceof URLSearchParams ? ot(t) : t, K = (t) => typeof t == "string" ? t : t instanceof URLSearchParams ? t.toString() : new URLSearchParams(t).toString();
|
|
16
|
+
function it() {
|
|
17
|
+
return c() && window.self !== window.top;
|
|
18
|
+
}
|
|
19
|
+
function at(t) {
|
|
20
|
+
return it() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
|
|
21
|
+
K(t || window.location.search).indexOf("builder.frameEditing=") !== -1;
|
|
22
|
+
}
|
|
23
|
+
const ct = () => {
|
|
24
|
+
if (c()) {
|
|
25
|
+
const t = new URL(location.href);
|
|
26
|
+
return t.pathname === "" && (t.pathname = "/"), t;
|
|
27
|
+
} else
|
|
28
|
+
return console.warn("Cannot get location for tracking in non-browser environment"), null;
|
|
29
|
+
}, ut = () => typeof navigator == "object" && navigator.userAgent || "", lt = () => {
|
|
30
|
+
const t = ut(), e = {
|
|
31
|
+
Android() {
|
|
32
|
+
return t.match(/Android/i);
|
|
33
|
+
},
|
|
34
|
+
BlackBerry() {
|
|
35
|
+
return t.match(/BlackBerry/i);
|
|
36
|
+
},
|
|
37
|
+
iOS() {
|
|
38
|
+
return t.match(/iPhone|iPod/i);
|
|
39
|
+
},
|
|
40
|
+
Opera() {
|
|
41
|
+
return t.match(/Opera Mini/i);
|
|
42
|
+
},
|
|
43
|
+
Windows() {
|
|
44
|
+
return t.match(/IEMobile/i) || t.match(/WPDesktop/i);
|
|
45
|
+
},
|
|
46
|
+
any() {
|
|
47
|
+
return e.Android() || e.BlackBerry() || e.iOS() || e.Opera() || e.Windows() || v === "reactNative";
|
|
48
|
+
}
|
|
49
|
+
}, n = t.match(/Tablet|iPad/i), r = ct();
|
|
50
|
+
return {
|
|
51
|
+
urlPath: r == null ? void 0 : r.pathname,
|
|
52
|
+
host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
|
|
53
|
+
device: n ? "tablet" : e.any() ? "mobile" : "desktop"
|
|
54
|
+
};
|
|
55
|
+
}, y = (t) => t != null;
|
|
56
|
+
function ee(t) {
|
|
57
|
+
const e = t || (c() ? window.location.search : void 0);
|
|
58
|
+
return e ? K(e).indexOf("builder.preview=") !== -1 : !1;
|
|
59
|
+
}
|
|
60
|
+
const ne = (t) => ({
|
|
61
|
+
type: "builder.registerComponent",
|
|
62
|
+
data: j(t)
|
|
63
|
+
}), dt = (t) => {
|
|
64
|
+
const e = t.toString().trim(), n = /^[a-zA-Z0-9_]+\s*=>/i.test(e);
|
|
65
|
+
return `return (${!e.startsWith("function") && !e.startsWith("async") && !e.startsWith("(") && !n ? "function " : ""}${e}).apply(this, arguments)`;
|
|
66
|
+
};
|
|
67
|
+
function j(t) {
|
|
68
|
+
return JSON.parse(JSON.stringify(t, (e, n) => typeof n == "function" ? dt(n) : n));
|
|
69
|
+
}
|
|
70
|
+
const B = {};
|
|
71
|
+
function ft(t, e) {
|
|
72
|
+
t === "plugin" && (e = j(e));
|
|
73
|
+
let n = B[t];
|
|
74
|
+
if (n || (n = B[t] = []), n.push(e), c()) {
|
|
75
|
+
const r = {
|
|
76
|
+
type: "builder.register",
|
|
77
|
+
data: {
|
|
78
|
+
type: t,
|
|
79
|
+
info: e
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
try {
|
|
83
|
+
parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
|
|
84
|
+
} catch (s) {
|
|
85
|
+
console.debug("Could not postmessage", s);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const L = {};
|
|
90
|
+
function re(t) {
|
|
91
|
+
if (c()) {
|
|
92
|
+
Object.assign(L, t);
|
|
93
|
+
const e = {
|
|
94
|
+
type: "builder.settingsChange",
|
|
95
|
+
data: L
|
|
96
|
+
};
|
|
97
|
+
parent.postMessage(e, "*");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const V = "builder.", ht = "options.", W = (t) => {
|
|
101
|
+
if (!t)
|
|
102
|
+
return {};
|
|
103
|
+
const e = M(t), n = {};
|
|
104
|
+
return Object.keys(e).forEach((r) => {
|
|
105
|
+
if (r.startsWith(V)) {
|
|
106
|
+
const s = r.replace(V, "").replace(ht, "");
|
|
107
|
+
n[s] = e[r];
|
|
108
|
+
}
|
|
109
|
+
}), n;
|
|
110
|
+
}, gt = () => {
|
|
111
|
+
if (!c())
|
|
112
|
+
return {};
|
|
113
|
+
const t = new URLSearchParams(window.location.search);
|
|
114
|
+
return W(t);
|
|
115
|
+
}, _ = "3.0.3", $ = () => ({
|
|
116
|
+
"X-Builder-SDK": v,
|
|
117
|
+
"X-Builder-SDK-GEN": "2",
|
|
118
|
+
"X-Builder-SDK-Version": _
|
|
119
|
+
}), pt = (t) => {
|
|
120
|
+
if (t === "localhost" || t === "127.0.0.1")
|
|
121
|
+
return t;
|
|
122
|
+
const e = t.split(".");
|
|
123
|
+
return e.length > 2 ? e.slice(1).join(".") : t;
|
|
124
|
+
}, O = ({
|
|
125
|
+
name: t,
|
|
126
|
+
canTrack: e
|
|
127
|
+
}) => {
|
|
128
|
+
var n;
|
|
129
|
+
try {
|
|
130
|
+
return e ? (n = document.cookie.split("; ").find((r) => r.startsWith(`${t}=`))) == null ? void 0 : n.split("=")[1] : void 0;
|
|
131
|
+
} catch (r) {
|
|
132
|
+
f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
}, G = async (t) => O(t), mt = (t) => t.map(([e, n]) => n ? `${e}=${n}` : e).filter(y).join("; "), yt = [["secure", ""], ["SameSite", "None"]], bt = ({
|
|
136
|
+
name: t,
|
|
137
|
+
value: e,
|
|
138
|
+
expires: n
|
|
139
|
+
}) => {
|
|
140
|
+
const s = (c() ? location.protocol === "https:" : !0) ? yt : [[]], o = n ? [["expires", n.toUTCString()]] : [[]], i = [[t, e], ...o, ["path", "/"], ["domain", pt(window.location.hostname)], ...s];
|
|
141
|
+
return mt(i);
|
|
142
|
+
}, P = async ({
|
|
143
|
+
name: t,
|
|
144
|
+
value: e,
|
|
145
|
+
expires: n,
|
|
146
|
+
canTrack: r
|
|
147
|
+
}) => {
|
|
148
|
+
try {
|
|
149
|
+
if (!r)
|
|
150
|
+
return;
|
|
151
|
+
const s = bt({
|
|
152
|
+
name: t,
|
|
153
|
+
value: e,
|
|
154
|
+
expires: n
|
|
155
|
+
});
|
|
156
|
+
document.cookie = s;
|
|
157
|
+
} catch (s) {
|
|
158
|
+
f.warn("[COOKIE] SET error: ", (s == null ? void 0 : s.message) || s);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
function St() {
|
|
162
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) {
|
|
163
|
+
const e = Math.random() * 16 | 0;
|
|
164
|
+
return (t == "x" ? e : e & 3 | 8).toString(16);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function J() {
|
|
168
|
+
return St().replace(/-/g, "");
|
|
169
|
+
}
|
|
170
|
+
const z = "builderSessionId", wt = async ({
|
|
171
|
+
canTrack: t
|
|
172
|
+
}) => {
|
|
173
|
+
if (!t)
|
|
174
|
+
return;
|
|
175
|
+
const e = await G({
|
|
176
|
+
name: z,
|
|
177
|
+
canTrack: t
|
|
178
|
+
});
|
|
179
|
+
if (y(e))
|
|
180
|
+
return e;
|
|
181
|
+
{
|
|
182
|
+
const n = vt();
|
|
183
|
+
return It({
|
|
184
|
+
id: n,
|
|
185
|
+
canTrack: t
|
|
186
|
+
}), n;
|
|
187
|
+
}
|
|
188
|
+
}, vt = () => J(), It = ({
|
|
189
|
+
id: t,
|
|
190
|
+
canTrack: e
|
|
191
|
+
}) => P({
|
|
192
|
+
name: z,
|
|
193
|
+
value: t,
|
|
194
|
+
canTrack: e
|
|
195
|
+
}), H = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, kt = ({
|
|
196
|
+
key: t,
|
|
197
|
+
canTrack: e
|
|
198
|
+
}) => {
|
|
199
|
+
var n;
|
|
200
|
+
try {
|
|
201
|
+
return e ? (n = H()) == null ? void 0 : n.getItem(t) : void 0;
|
|
202
|
+
} catch (r) {
|
|
203
|
+
console.debug("[LocalStorage] GET error: ", r);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
}, At = ({
|
|
207
|
+
key: t,
|
|
208
|
+
canTrack: e,
|
|
209
|
+
value: n
|
|
210
|
+
}) => {
|
|
211
|
+
var r;
|
|
212
|
+
try {
|
|
213
|
+
e && ((r = H()) == null || r.setItem(t, n));
|
|
214
|
+
} catch (s) {
|
|
215
|
+
console.debug("[LocalStorage] SET error: ", s);
|
|
216
|
+
}
|
|
217
|
+
}, X = "builderVisitorId", Et = ({
|
|
218
|
+
canTrack: t
|
|
219
|
+
}) => {
|
|
220
|
+
if (!t)
|
|
221
|
+
return;
|
|
222
|
+
const e = kt({
|
|
223
|
+
key: X,
|
|
224
|
+
canTrack: t
|
|
225
|
+
});
|
|
226
|
+
if (y(e))
|
|
227
|
+
return e;
|
|
228
|
+
{
|
|
229
|
+
const n = Ot();
|
|
230
|
+
return Pt({
|
|
231
|
+
id: n,
|
|
232
|
+
canTrack: t
|
|
233
|
+
}), n;
|
|
234
|
+
}
|
|
235
|
+
}, Ot = () => J(), Pt = ({
|
|
236
|
+
id: t,
|
|
237
|
+
canTrack: e
|
|
238
|
+
}) => At({
|
|
239
|
+
key: X,
|
|
240
|
+
value: t,
|
|
241
|
+
canTrack: e
|
|
242
|
+
});
|
|
243
|
+
function Ct(t) {
|
|
244
|
+
var e;
|
|
245
|
+
typeof process != "undefined" && ((e = process.env) != null && e.DEBUG) && String(process.env.DEBUG) == "true" && f.log(t);
|
|
246
|
+
}
|
|
247
|
+
const Ut = async ({
|
|
248
|
+
canTrack: t
|
|
249
|
+
}) => {
|
|
250
|
+
if (!t)
|
|
251
|
+
return {
|
|
252
|
+
visitorId: void 0,
|
|
253
|
+
sessionId: void 0
|
|
254
|
+
};
|
|
255
|
+
const e = await wt({
|
|
256
|
+
canTrack: t
|
|
257
|
+
}), n = Et({
|
|
258
|
+
canTrack: t
|
|
259
|
+
});
|
|
260
|
+
return {
|
|
261
|
+
sessionId: e,
|
|
262
|
+
visitorId: n
|
|
263
|
+
};
|
|
264
|
+
}, Tt = async ({
|
|
265
|
+
type: t,
|
|
266
|
+
canTrack: e,
|
|
267
|
+
apiKey: n,
|
|
268
|
+
metadata: r,
|
|
269
|
+
...s
|
|
270
|
+
}) => ({
|
|
271
|
+
type: t,
|
|
272
|
+
data: {
|
|
273
|
+
...s,
|
|
274
|
+
metadata: {
|
|
275
|
+
url: location.href,
|
|
276
|
+
...r
|
|
277
|
+
},
|
|
278
|
+
...await Ut({
|
|
279
|
+
canTrack: e
|
|
280
|
+
}),
|
|
281
|
+
userAttributes: lt(),
|
|
282
|
+
ownerId: n
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
async function xt({
|
|
286
|
+
apiHost: t,
|
|
287
|
+
...e
|
|
288
|
+
}) {
|
|
289
|
+
if (!e.apiKey) {
|
|
290
|
+
f.error("Missing API key for track call. Please provide your API key.");
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (!e.canTrack || at() || !(c() || v === "reactNative"))
|
|
294
|
+
return;
|
|
295
|
+
const r = `${t || "https://cdn.builder.io"}/api/v1/track`;
|
|
296
|
+
return Ct(r), fetch(r, {
|
|
297
|
+
method: "POST",
|
|
298
|
+
body: JSON.stringify({
|
|
299
|
+
events: [await Tt(e)]
|
|
300
|
+
}),
|
|
301
|
+
headers: {
|
|
302
|
+
"content-type": "application/json",
|
|
303
|
+
...$()
|
|
304
|
+
},
|
|
305
|
+
mode: "cors"
|
|
306
|
+
}).catch((s) => {
|
|
307
|
+
console.error("Failed to track: ", s);
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
const se = (t) => xt({
|
|
311
|
+
...t,
|
|
312
|
+
canTrack: !0
|
|
313
|
+
}), Rt = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
314
|
+
function Q(t, e) {
|
|
315
|
+
if (!e.origin.startsWith("http") && !e.origin.startsWith("https"))
|
|
316
|
+
return !1;
|
|
317
|
+
const n = new URL(e.origin), r = n.hostname;
|
|
318
|
+
return (t || Rt).findIndex((s) => s.startsWith("*.") ? r.endsWith(s.slice(1)) : s === r) > -1;
|
|
319
|
+
}
|
|
320
|
+
const oe = () => {
|
|
321
|
+
ft("insertMenu", {
|
|
322
|
+
name: "_default",
|
|
323
|
+
default: !0,
|
|
324
|
+
items: [{
|
|
325
|
+
name: "Box"
|
|
326
|
+
}, {
|
|
327
|
+
name: "Text"
|
|
328
|
+
}, {
|
|
329
|
+
name: "Image"
|
|
330
|
+
}, {
|
|
331
|
+
name: "Columns"
|
|
332
|
+
}, {
|
|
333
|
+
name: "Core:Section"
|
|
334
|
+
}, {
|
|
335
|
+
name: "Core:Button"
|
|
336
|
+
}, {
|
|
337
|
+
name: "Embed"
|
|
338
|
+
}, {
|
|
339
|
+
name: "Custom Code"
|
|
340
|
+
}]
|
|
341
|
+
});
|
|
342
|
+
};
|
|
343
|
+
let N = !1;
|
|
344
|
+
const Bt = (t = {}) => {
|
|
345
|
+
var e, n;
|
|
346
|
+
N || (N = !0, c() && ((e = window.parent) == null || e.postMessage({
|
|
347
|
+
type: "builder.sdkInfo",
|
|
348
|
+
data: {
|
|
349
|
+
target: v,
|
|
350
|
+
version: _,
|
|
351
|
+
supportsPatchUpdates: !1,
|
|
352
|
+
// Supports builder-model="..." attribute which is needed to
|
|
353
|
+
// scope our '+ add block' button styling
|
|
354
|
+
supportsAddBlockScoping: !0,
|
|
355
|
+
supportsCustomBreakpoints: !0,
|
|
356
|
+
blockLevelPersonalization: !0
|
|
357
|
+
}
|
|
358
|
+
}, "*"), (n = window.parent) == null || n.postMessage({
|
|
359
|
+
type: "builder.updateContent",
|
|
360
|
+
data: {
|
|
361
|
+
options: t
|
|
362
|
+
}
|
|
363
|
+
}, "*"), window.addEventListener("message", (r) => {
|
|
364
|
+
var o, i;
|
|
365
|
+
if (!Q(t.trustedHosts, r))
|
|
366
|
+
return;
|
|
367
|
+
const {
|
|
368
|
+
data: s
|
|
369
|
+
} = r;
|
|
370
|
+
if (s != null && s.type)
|
|
371
|
+
switch (s.type) {
|
|
372
|
+
case "builder.evaluate": {
|
|
373
|
+
const u = s.data.text, b = s.data.arguments || [], p = s.data.id, k = new Function(u);
|
|
374
|
+
let l, h = null;
|
|
375
|
+
try {
|
|
376
|
+
l = k.apply(null, b);
|
|
377
|
+
} catch (g) {
|
|
378
|
+
h = g;
|
|
379
|
+
}
|
|
380
|
+
h ? (o = window.parent) == null || o.postMessage({
|
|
381
|
+
type: "builder.evaluateError",
|
|
382
|
+
data: {
|
|
383
|
+
id: p,
|
|
384
|
+
error: h.message
|
|
385
|
+
}
|
|
386
|
+
}, "*") : l && typeof l.then == "function" ? l.then((g) => {
|
|
387
|
+
var S;
|
|
388
|
+
(S = window.parent) == null || S.postMessage({
|
|
389
|
+
type: "builder.evaluateResult",
|
|
390
|
+
data: {
|
|
391
|
+
id: p,
|
|
392
|
+
result: g
|
|
393
|
+
}
|
|
394
|
+
}, "*");
|
|
395
|
+
}).catch(console.error) : (i = window.parent) == null || i.postMessage({
|
|
396
|
+
type: "builder.evaluateResult",
|
|
397
|
+
data: {
|
|
398
|
+
result: l,
|
|
399
|
+
id: p
|
|
400
|
+
}
|
|
401
|
+
}, "*");
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
})));
|
|
406
|
+
}, Lt = ({
|
|
407
|
+
model: t,
|
|
408
|
+
trustedHosts: e,
|
|
409
|
+
callbacks: n
|
|
410
|
+
}) => (r) => {
|
|
411
|
+
if (!Q(e, r))
|
|
412
|
+
return;
|
|
413
|
+
const {
|
|
414
|
+
data: s
|
|
415
|
+
} = r;
|
|
416
|
+
if (s)
|
|
417
|
+
switch (s.type) {
|
|
418
|
+
case "builder.configureSdk": {
|
|
419
|
+
n.configureSdk(s.data);
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
case "builder.triggerAnimation": {
|
|
423
|
+
n.animation(s.data);
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
case "builder.contentUpdate": {
|
|
427
|
+
const o = s.data, i = o.key || o.alias || o.entry || o.modelName, u = o.data;
|
|
428
|
+
i === t && n.contentUpdate(u);
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}, ie = (t, e, n) => {
|
|
433
|
+
if (!c)
|
|
434
|
+
return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
|
|
435
|
+
};
|
|
436
|
+
Bt();
|
|
437
|
+
const r = Lt({
|
|
438
|
+
callbacks: {
|
|
439
|
+
contentUpdate: e,
|
|
440
|
+
animation: () => {
|
|
441
|
+
},
|
|
442
|
+
configureSdk: () => {
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
model: t,
|
|
446
|
+
trustedHosts: n == null ? void 0 : n.trustedHosts
|
|
447
|
+
});
|
|
448
|
+
return window.addEventListener("message", r), () => {
|
|
449
|
+
window.removeEventListener("message", r);
|
|
450
|
+
};
|
|
451
|
+
}, Vt = "builder.tests", C = (t) => `${Vt}.${t}`, Nt = ({
|
|
452
|
+
contentId: t
|
|
453
|
+
}) => G({
|
|
454
|
+
name: C(t),
|
|
455
|
+
canTrack: !0
|
|
456
|
+
}), Ft = ({
|
|
457
|
+
contentId: t
|
|
458
|
+
}) => O({
|
|
459
|
+
name: C(t),
|
|
460
|
+
canTrack: !0
|
|
461
|
+
}), Dt = ({
|
|
462
|
+
contentId: t,
|
|
463
|
+
value: e
|
|
464
|
+
}) => P({
|
|
465
|
+
name: C(t),
|
|
466
|
+
value: e,
|
|
467
|
+
canTrack: !0
|
|
468
|
+
}), Y = (t) => y(t.id) && y(t.variations) && Object.keys(t.variations).length > 0, Mt = ({
|
|
469
|
+
id: t,
|
|
470
|
+
variations: e
|
|
471
|
+
}) => {
|
|
472
|
+
var s;
|
|
473
|
+
let n = 0;
|
|
474
|
+
const r = Math.random();
|
|
475
|
+
for (const o in e) {
|
|
476
|
+
const i = (s = e[o]) == null ? void 0 : s.testRatio;
|
|
477
|
+
if (n += i, r < n)
|
|
478
|
+
return o;
|
|
479
|
+
}
|
|
480
|
+
return t;
|
|
481
|
+
}, Z = (t) => {
|
|
482
|
+
const e = Mt(t);
|
|
483
|
+
return Dt({
|
|
484
|
+
contentId: t.id,
|
|
485
|
+
value: e
|
|
486
|
+
}).catch((n) => {
|
|
487
|
+
f.error("could not store A/B test variation: ", n);
|
|
488
|
+
}), e;
|
|
489
|
+
}, q = ({
|
|
490
|
+
item: t,
|
|
491
|
+
testGroupId: e
|
|
492
|
+
}) => {
|
|
493
|
+
const n = t.variations[e];
|
|
494
|
+
return e === t.id || // handle edge-case where `testGroupId` points to non-existing variation
|
|
495
|
+
!n ? {
|
|
496
|
+
testVariationId: t.id,
|
|
497
|
+
testVariationName: "Default"
|
|
498
|
+
} : {
|
|
499
|
+
data: n.data,
|
|
500
|
+
testVariationId: n.id,
|
|
501
|
+
testVariationName: n.name || (n.id === t.id ? "Default" : "")
|
|
502
|
+
};
|
|
503
|
+
}, ae = ({
|
|
504
|
+
item: t,
|
|
505
|
+
canTrack: e
|
|
506
|
+
}) => {
|
|
507
|
+
if (!e)
|
|
508
|
+
return t;
|
|
509
|
+
if (!t)
|
|
510
|
+
return;
|
|
511
|
+
if (!Y(t))
|
|
512
|
+
return t;
|
|
513
|
+
const n = Ft({
|
|
514
|
+
contentId: t.id
|
|
515
|
+
}) || Z({
|
|
516
|
+
variations: t.variations,
|
|
517
|
+
id: t.id
|
|
518
|
+
}), r = q({
|
|
519
|
+
item: t,
|
|
520
|
+
testGroupId: n
|
|
521
|
+
});
|
|
522
|
+
return {
|
|
523
|
+
...t,
|
|
524
|
+
...r
|
|
525
|
+
};
|
|
526
|
+
}, Kt = async ({
|
|
527
|
+
item: t,
|
|
528
|
+
canTrack: e
|
|
529
|
+
}) => {
|
|
530
|
+
if (!e || !Y(t))
|
|
531
|
+
return t;
|
|
532
|
+
const r = await Nt({
|
|
533
|
+
contentId: t.id
|
|
534
|
+
}) || Z({
|
|
535
|
+
variations: t.variations,
|
|
536
|
+
id: t.id
|
|
537
|
+
}), s = q({
|
|
538
|
+
item: t,
|
|
539
|
+
testGroupId: r
|
|
540
|
+
});
|
|
541
|
+
return {
|
|
542
|
+
...t,
|
|
543
|
+
...s
|
|
544
|
+
};
|
|
545
|
+
}, F = "builder.userAttributes";
|
|
546
|
+
function jt() {
|
|
547
|
+
let t = !0;
|
|
548
|
+
const e = /* @__PURE__ */ new Set();
|
|
549
|
+
return {
|
|
550
|
+
setUserAttributes(n) {
|
|
551
|
+
if (!c())
|
|
552
|
+
return;
|
|
553
|
+
const r = {
|
|
554
|
+
...this.getUserAttributes(),
|
|
555
|
+
...n
|
|
556
|
+
};
|
|
557
|
+
P({
|
|
558
|
+
name: F,
|
|
559
|
+
value: JSON.stringify(r),
|
|
560
|
+
canTrack: t
|
|
561
|
+
}), e.forEach((s) => s(r));
|
|
562
|
+
},
|
|
563
|
+
getUserAttributes() {
|
|
564
|
+
return c() ? JSON.parse(O({
|
|
565
|
+
name: F,
|
|
566
|
+
canTrack: t
|
|
567
|
+
}) || "{}") : {};
|
|
568
|
+
},
|
|
569
|
+
subscribeOnUserAttributesChange(n) {
|
|
570
|
+
return e.add(n), () => {
|
|
571
|
+
e.delete(n);
|
|
572
|
+
};
|
|
573
|
+
},
|
|
574
|
+
setCanTrack(n) {
|
|
575
|
+
t = n;
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
const tt = jt(), ce = (t) => {
|
|
580
|
+
tt.setUserAttributes(t);
|
|
581
|
+
}, Wt = (t) => {
|
|
582
|
+
const e = y(t) ? t : !0;
|
|
583
|
+
return tt.setCanTrack(e), e;
|
|
584
|
+
};
|
|
585
|
+
function _t() {
|
|
586
|
+
return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
|
|
587
|
+
}
|
|
588
|
+
function $t() {
|
|
589
|
+
const t = _t().fetch;
|
|
590
|
+
if (typeof t == "undefined")
|
|
591
|
+
throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
592
|
+
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
|
|
593
|
+
return t;
|
|
594
|
+
}
|
|
595
|
+
const Gt = $t();
|
|
596
|
+
function E(t, e = null, n = ".") {
|
|
597
|
+
return Object.keys(t).reduce((r, s) => {
|
|
598
|
+
const o = t[s], i = [e, s].filter(Boolean).join(n);
|
|
599
|
+
return [typeof o == "object", o !== null, !(Array.isArray(o) && o.length === 0)].every(Boolean) ? {
|
|
600
|
+
...r,
|
|
601
|
+
...E(o, i, n)
|
|
602
|
+
} : {
|
|
603
|
+
...r,
|
|
604
|
+
[i]: o
|
|
605
|
+
};
|
|
606
|
+
}, {});
|
|
607
|
+
}
|
|
608
|
+
function et(t, e, n = {}) {
|
|
609
|
+
for (const r in t) {
|
|
610
|
+
const s = t[r], o = e ? e + "." + r : r;
|
|
611
|
+
s && typeof s == "object" && !Array.isArray(s) && !Object.keys(s).find((i) => i.startsWith("$")) ? et(s, o, n) : n[o] = s;
|
|
612
|
+
}
|
|
613
|
+
return n;
|
|
614
|
+
}
|
|
615
|
+
function Jt(t) {
|
|
616
|
+
const e = {};
|
|
617
|
+
for (const n in t) {
|
|
618
|
+
const r = n.split(".");
|
|
619
|
+
let s = e;
|
|
620
|
+
for (let o = 0; o < r.length; o++) {
|
|
621
|
+
const i = r[o];
|
|
622
|
+
o === r.length - 1 ? s[i] = t[n] : (s[i] = s[i] || {}, s = s[i]);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
return e;
|
|
626
|
+
}
|
|
627
|
+
const zt = "v3", D = (t) => typeof t == "number" && !isNaN(t) && t >= 0, U = (t) => {
|
|
628
|
+
const {
|
|
629
|
+
limit: e = 30,
|
|
630
|
+
userAttributes: n,
|
|
631
|
+
query: r,
|
|
632
|
+
model: s,
|
|
633
|
+
apiKey: o,
|
|
634
|
+
enrich: i,
|
|
635
|
+
locale: u,
|
|
636
|
+
apiVersion: b = zt,
|
|
637
|
+
fields: p,
|
|
638
|
+
omit: k,
|
|
639
|
+
offset: l,
|
|
640
|
+
cacheSeconds: h,
|
|
641
|
+
staleCacheSeconds: g,
|
|
642
|
+
sort: S,
|
|
643
|
+
includeUnpublished: T,
|
|
644
|
+
apiHost: nt
|
|
645
|
+
} = t;
|
|
646
|
+
if (!o)
|
|
647
|
+
throw new Error("Missing API key");
|
|
648
|
+
if (!["v3"].includes(b))
|
|
649
|
+
throw new Error(`Invalid apiVersion: expected 'v3', received '${b}'`);
|
|
650
|
+
const rt = e !== 1, st = nt || "https://cdn.builder.io", a = new URL(`${st}/api/${b}/content/${s}`);
|
|
651
|
+
a.searchParams.set("apiKey", o), a.searchParams.set("limit", String(e)), a.searchParams.set("noTraverse", String(rt)), a.searchParams.set("includeRefs", String(!0));
|
|
652
|
+
const A = u || (n == null ? void 0 : n.locale);
|
|
653
|
+
let m = n || {};
|
|
654
|
+
if (A && (a.searchParams.set("locale", A), m = {
|
|
655
|
+
locale: A,
|
|
656
|
+
...m
|
|
657
|
+
}), i && a.searchParams.set("enrich", String(i)), a.searchParams.set("omit", k || "meta.componentsUsed"), p && a.searchParams.set("fields", p), Number.isFinite(l) && l > -1 && a.searchParams.set("offset", String(Math.floor(l))), typeof T == "boolean" && a.searchParams.set("includeUnpublished", String(T)), h && D(h) && a.searchParams.set("cacheSeconds", String(h)), g && D(g) && a.searchParams.set("staleCacheSeconds", String(g)), S) {
|
|
658
|
+
const d = E({
|
|
659
|
+
sort: S
|
|
660
|
+
});
|
|
661
|
+
for (const w in d)
|
|
662
|
+
a.searchParams.set(w, JSON.stringify(d[w]));
|
|
663
|
+
}
|
|
664
|
+
const x = {
|
|
665
|
+
...gt(),
|
|
666
|
+
...M(t.options || {})
|
|
667
|
+
};
|
|
668
|
+
m = {
|
|
669
|
+
...m,
|
|
670
|
+
...Xt(x)
|
|
671
|
+
};
|
|
672
|
+
const R = E(x);
|
|
673
|
+
for (const d in R)
|
|
674
|
+
a.searchParams.set(d, String(R[d]));
|
|
675
|
+
if (Object.keys(m).length > 0 && a.searchParams.set("userAttributes", JSON.stringify(m)), r) {
|
|
676
|
+
const d = et({
|
|
677
|
+
query: r
|
|
678
|
+
});
|
|
679
|
+
for (const w in d)
|
|
680
|
+
a.searchParams.set(w, JSON.stringify(d[w]));
|
|
681
|
+
}
|
|
682
|
+
return a;
|
|
683
|
+
}, Ht = (t) => {
|
|
684
|
+
const e = {};
|
|
685
|
+
for (const n in t)
|
|
686
|
+
n.startsWith("userAttributes.") && (e[n] = t[n], delete t[n]);
|
|
687
|
+
return e;
|
|
688
|
+
}, Xt = (t) => {
|
|
689
|
+
if (c() && t.preview === "BUILDER_STUDIO") {
|
|
690
|
+
t["userAttributes.urlPath"] = window.location.pathname, t["userAttributes.host"] = window.location.host;
|
|
691
|
+
const e = Ht(t), {
|
|
692
|
+
userAttributes: n
|
|
693
|
+
} = Jt(e);
|
|
694
|
+
return n;
|
|
695
|
+
}
|
|
696
|
+
return {};
|
|
697
|
+
}, Qt = (t) => "results" in t;
|
|
698
|
+
async function Yt(t) {
|
|
699
|
+
const e = await te({
|
|
700
|
+
...t,
|
|
701
|
+
limit: 1
|
|
702
|
+
});
|
|
703
|
+
return e && e[0] || null;
|
|
704
|
+
}
|
|
705
|
+
const Zt = async (t) => {
|
|
706
|
+
var i, u;
|
|
707
|
+
const e = U(t), n = (i = t.fetch) != null ? i : Gt, r = {
|
|
708
|
+
...t.fetchOptions,
|
|
709
|
+
headers: {
|
|
710
|
+
...(u = t.fetchOptions) == null ? void 0 : u.headers,
|
|
711
|
+
...$()
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
return await (await n(e.href, r)).json();
|
|
715
|
+
}, qt = async (t, e, n = U(t)) => {
|
|
716
|
+
const r = Wt(t.canTrack);
|
|
717
|
+
if (n.search.includes("preview="), !r || !(c() || v === "reactNative"))
|
|
718
|
+
return e.results;
|
|
719
|
+
try {
|
|
720
|
+
const s = [];
|
|
721
|
+
for (const o of e.results)
|
|
722
|
+
s.push(await Kt({
|
|
723
|
+
item: o,
|
|
724
|
+
canTrack: r
|
|
725
|
+
}));
|
|
726
|
+
e.results = s;
|
|
727
|
+
} catch (s) {
|
|
728
|
+
f.error("Could not process A/B tests. ", s);
|
|
729
|
+
}
|
|
730
|
+
return e.results;
|
|
731
|
+
};
|
|
732
|
+
async function te(t) {
|
|
733
|
+
const e = U(t), n = await Zt(t);
|
|
734
|
+
if (!Qt(n))
|
|
735
|
+
throw f.error("Error fetching data. ", {
|
|
736
|
+
url: e,
|
|
737
|
+
content: n,
|
|
738
|
+
options: t
|
|
739
|
+
}), n;
|
|
740
|
+
return qt(t, n);
|
|
741
|
+
}
|
|
742
|
+
const ue = async (t) => {
|
|
743
|
+
var r, s, o;
|
|
744
|
+
const e = t.path || ((r = t.url) == null ? void 0 : r.pathname) || ((s = t.userAttributes) == null ? void 0 : s.urlPath), n = {
|
|
745
|
+
...t,
|
|
746
|
+
apiKey: t.apiKey,
|
|
747
|
+
model: t.model || "page",
|
|
748
|
+
userAttributes: {
|
|
749
|
+
...t.userAttributes,
|
|
750
|
+
...e ? {
|
|
751
|
+
urlPath: e
|
|
752
|
+
} : {}
|
|
753
|
+
},
|
|
754
|
+
options: W(t.searchParams || ((o = t.url) == null ? void 0 : o.searchParams) || t.options)
|
|
755
|
+
};
|
|
756
|
+
return {
|
|
757
|
+
apiKey: n.apiKey,
|
|
758
|
+
model: n.model,
|
|
759
|
+
content: await Yt(n)
|
|
760
|
+
};
|
|
761
|
+
};
|
|
762
|
+
export {
|
|
763
|
+
I as MSG_PREFIX,
|
|
764
|
+
v as TARGET,
|
|
765
|
+
qt as _processContentResult,
|
|
766
|
+
xt as _track,
|
|
767
|
+
y as checkIsDefined,
|
|
768
|
+
Lt as createEditorListener,
|
|
769
|
+
ne as createRegisterComponentMessage,
|
|
770
|
+
ue as fetchBuilderProps,
|
|
771
|
+
te as fetchEntries,
|
|
772
|
+
Yt as fetchOneEntry,
|
|
773
|
+
W as getBuilderSearchParams,
|
|
774
|
+
Wt as getDefaultCanTrack,
|
|
775
|
+
lt as getUserAttributes,
|
|
776
|
+
ae as handleABTestingSync,
|
|
777
|
+
c as isBrowser,
|
|
778
|
+
at as isEditing,
|
|
779
|
+
ee as isPreviewing,
|
|
780
|
+
Ct as logFetch,
|
|
781
|
+
f as logger,
|
|
782
|
+
ft as register,
|
|
783
|
+
oe as registerInsertMenu,
|
|
784
|
+
j as serializeIncludingFunctions,
|
|
785
|
+
ce as setClientUserAttributes,
|
|
786
|
+
re as setEditorSettings,
|
|
787
|
+
Bt as setupBrowserForEditing,
|
|
788
|
+
ie as subscribeToEditor,
|
|
789
|
+
se as track,
|
|
790
|
+
tt as userAttributesService
|
|
791
|
+
};
|