@builder.io/sdk-react 1.0.26 → 1.0.27
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 +1 -1
- package/lib/browser/blocks-exports.mjs +1 -1
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/init.cjs +1 -1
- package/lib/browser/init.mjs +1 -1
- package/lib/browser/server-entry-60c3f2b2.cjs +2 -0
- package/lib/browser/{server-entry-c522a38f.js → server-entry-805a2c2a.js} +142 -135
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/{blocks-612eb41b.js → blocks-a1399a78.js} +2 -2
- package/lib/edge/{blocks-77e27834.cjs → blocks-af5c8ecf.cjs} +1 -1
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +2 -2
- package/lib/edge/{button-70b2e3a9.js → button-0820a5bc.js} +2 -2
- package/lib/edge/{button-956ab5bc.cjs → button-16076ac7.cjs} +1 -1
- package/lib/edge/{columns-623de7ba.js → columns-688cc205.js} +3 -3
- package/lib/edge/{columns-9ed7dfeb.cjs → columns-6b8c03be.cjs} +1 -1
- package/lib/edge/{content-variants-eca40007.cjs → content-variants-4679172a.cjs} +1 -1
- package/lib/edge/{content-variants-059e455f.js → content-variants-efa4f81b.js} +9 -9
- package/lib/edge/{form-5c01a94c.cjs → form-91166ed6.cjs} +1 -1
- package/lib/edge/{form-a1e588d6.js → form-cbe7d822.js} +3 -3
- package/lib/edge/{get-class-prop-name-65450a8e.cjs → get-class-prop-name-47012c9c.cjs} +1 -1
- package/lib/edge/{get-class-prop-name-bee742f6.js → get-class-prop-name-4a1bad2b.js} +1 -1
- package/lib/edge/{img-79534c61.js → img-14849a5b.js} +1 -1
- package/lib/edge/{img-d8259a3f.cjs → img-d3420f5d.cjs} +1 -1
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/edge/init.cjs +1 -1
- package/lib/edge/init.mjs +1 -1
- package/lib/edge/{input-d9a6232c.cjs → input-07becc4d.cjs} +1 -1
- package/lib/edge/{input-5b9458cd.js → input-534b9f95.js} +1 -1
- package/lib/edge/{select-1b1b666f.js → select-b05ef24f.js} +1 -1
- package/lib/edge/{select-fd3daca2.cjs → select-e576d7d0.cjs} +1 -1
- package/lib/edge/{server-entry-5a6eeaf9.js → server-entry-6aaf6054.js} +137 -130
- package/lib/edge/server-entry-ee324b22.cjs +2 -0
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/{slot-7cd830aa.js → slot-944437dd.js} +3 -3
- package/lib/edge/{slot-0f591294.cjs → slot-e139f9b4.cjs} +1 -1
- package/lib/edge/{symbol-1bd5d636.js → symbol-75d1c60d.js} +2 -2
- package/lib/edge/{symbol-0eff91f7.cjs → symbol-f7f42446.cjs} +1 -1
- package/lib/edge/{tabs-784ddfd3.cjs → tabs-4860ef6d.cjs} +1 -1
- package/lib/edge/{tabs-fd103011.js → tabs-62e415e1.js} +3 -3
- package/lib/node/blocks-exports.cjs +1 -1
- package/lib/node/blocks-exports.mjs +2 -2
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +2 -2
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +2 -2
- package/lib/node/{node-runtime-72de67f1.cjs → node-runtime-1bee7133.cjs} +1 -1
- package/lib/node/{node-runtime-8a7cc42d.js → node-runtime-e167306c.js} +1 -1
- package/lib/node/{server-entry-262852ac.js → server-entry-38fb2258.js} +142 -135
- package/lib/node/server-entry-db936548.cjs +2 -0
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/package.json +1 -1
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/helpers/flatten.d.ts +10 -0
- package/lib/browser/server-entry-298501b1.cjs +0 -2
- package/lib/edge/server-entry-2f25c4ff.cjs +0 -2
- package/lib/node/server-entry-e9d5a539.cjs +0 -2
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
const
|
|
1
|
+
const v = "react", Q = (e) => {
|
|
2
2
|
const t = {};
|
|
3
3
|
return e.forEach((n, r) => {
|
|
4
4
|
t[r] = n;
|
|
5
5
|
}), t;
|
|
6
|
-
}, L = (e) => e instanceof URLSearchParams ?
|
|
6
|
+
}, L = (e) => e instanceof URLSearchParams ? Q(e) : e, V = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
|
|
7
7
|
function c() {
|
|
8
8
|
return typeof window != "undefined" && typeof document != "undefined";
|
|
9
9
|
}
|
|
10
10
|
function Y() {
|
|
11
11
|
return c() && window.self !== window.top;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function Z(e) {
|
|
14
14
|
return Y() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
|
|
15
15
|
V(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function Ge(e) {
|
|
18
18
|
const t = e || (c() ? window.location.search : void 0);
|
|
19
19
|
return t ? V(t).indexOf("builder.preview=") !== -1 : !1;
|
|
20
20
|
}
|
|
21
|
-
const U = (e) => JSON.parse(JSON.stringify(e)),
|
|
21
|
+
const U = (e) => JSON.parse(JSON.stringify(e)), ze = (e) => ({
|
|
22
22
|
type: "builder.registerComponent",
|
|
23
|
-
data:
|
|
24
|
-
}),
|
|
23
|
+
data: ne(e)
|
|
24
|
+
}), ee = (e) => {
|
|
25
25
|
const t = e.toString().trim();
|
|
26
26
|
return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
|
|
27
|
-
},
|
|
27
|
+
}, te = (e) => typeof e == "function" ? ee(e) : U(e), ne = ({
|
|
28
28
|
inputs: e,
|
|
29
29
|
...t
|
|
30
30
|
}) => ({
|
|
31
31
|
...U(t),
|
|
32
32
|
inputs: e == null ? void 0 : e.map((n) => Object.entries(n).reduce((r, [o, s]) => ({
|
|
33
33
|
...r,
|
|
34
|
-
[o]:
|
|
34
|
+
[o]: te(s)
|
|
35
35
|
}), {}))
|
|
36
36
|
}), x = {};
|
|
37
|
-
function
|
|
37
|
+
function re(e, t) {
|
|
38
38
|
let n = x[e];
|
|
39
39
|
if (n || (n = x[e] = []), n.push(t), c()) {
|
|
40
40
|
const r = {
|
|
@@ -52,7 +52,7 @@ function ne(e, t) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
const A = {};
|
|
55
|
-
function
|
|
55
|
+
function Je(e) {
|
|
56
56
|
if (c()) {
|
|
57
57
|
Object.assign(A, e);
|
|
58
58
|
const t = {
|
|
@@ -62,17 +62,17 @@ function ze(e) {
|
|
|
62
62
|
parent.postMessage(t, "*");
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
const T = "builder.",
|
|
65
|
+
const T = "builder.", oe = "options.", M = (e) => {
|
|
66
66
|
if (!e)
|
|
67
67
|
return {};
|
|
68
68
|
const t = L(e), n = {};
|
|
69
69
|
return Object.keys(t).forEach((r) => {
|
|
70
70
|
if (r.startsWith(T)) {
|
|
71
|
-
const o = r.replace(T, "").replace(
|
|
71
|
+
const o = r.replace(T, "").replace(oe, "");
|
|
72
72
|
n[o] = t[r];
|
|
73
73
|
}
|
|
74
74
|
}), n;
|
|
75
|
-
},
|
|
75
|
+
}, se = () => {
|
|
76
76
|
if (!c())
|
|
77
77
|
return {};
|
|
78
78
|
const e = new URLSearchParams(window.location.search);
|
|
@@ -82,7 +82,7 @@ const T = "builder.", re = "options.", M = (e) => {
|
|
|
82
82
|
error: (...e) => console.error(b, ...e),
|
|
83
83
|
warn: (...e) => console.warn(b, ...e),
|
|
84
84
|
debug: (...e) => console.debug(b, ...e)
|
|
85
|
-
}, m = (e) => e != null,
|
|
85
|
+
}, m = (e) => e != null, ie = (e) => {
|
|
86
86
|
if (e === "localhost" || e === "127.0.0.1")
|
|
87
87
|
return e;
|
|
88
88
|
const t = e.split(".");
|
|
@@ -98,13 +98,13 @@ const T = "builder.", re = "options.", M = (e) => {
|
|
|
98
98
|
f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
}, F = async (e) => N(e),
|
|
101
|
+
}, F = async (e) => N(e), ae = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), ce = [["secure", ""], ["SameSite", "None"]], ue = ({
|
|
102
102
|
name: e,
|
|
103
103
|
value: t,
|
|
104
104
|
expires: n
|
|
105
105
|
}) => {
|
|
106
|
-
const o = (c() ? location.protocol === "https:" : !0) ?
|
|
107
|
-
return
|
|
106
|
+
const o = (c() ? location.protocol === "https:" : !0) ? ce : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], a = [[e, t], ...s, ["path", "/"], ["domain", ie(window.location.hostname)], ...o];
|
|
107
|
+
return ae(a);
|
|
108
108
|
}, j = async ({
|
|
109
109
|
name: e,
|
|
110
110
|
value: t,
|
|
@@ -114,7 +114,7 @@ const T = "builder.", re = "options.", M = (e) => {
|
|
|
114
114
|
try {
|
|
115
115
|
if (!r)
|
|
116
116
|
return;
|
|
117
|
-
const o =
|
|
117
|
+
const o = ue({
|
|
118
118
|
name: e,
|
|
119
119
|
value: t,
|
|
120
120
|
expires: n
|
|
@@ -124,16 +124,16 @@ const T = "builder.", re = "options.", M = (e) => {
|
|
|
124
124
|
f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
|
-
function
|
|
127
|
+
function de() {
|
|
128
128
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
129
129
|
const t = Math.random() * 16 | 0;
|
|
130
130
|
return (e == "x" ? t : t & 3 | 8).toString(16);
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
function D() {
|
|
134
|
-
return
|
|
134
|
+
return de().replace(/-/g, "");
|
|
135
135
|
}
|
|
136
|
-
const K = "builderSessionId",
|
|
136
|
+
const K = "builderSessionId", le = async ({
|
|
137
137
|
canTrack: e
|
|
138
138
|
}) => {
|
|
139
139
|
if (!e)
|
|
@@ -145,64 +145,64 @@ const K = "builderSessionId", de = async ({
|
|
|
145
145
|
if (m(t))
|
|
146
146
|
return t;
|
|
147
147
|
{
|
|
148
|
-
const n =
|
|
149
|
-
return
|
|
148
|
+
const n = fe();
|
|
149
|
+
return he({
|
|
150
150
|
id: n,
|
|
151
151
|
canTrack: e
|
|
152
152
|
}), n;
|
|
153
153
|
}
|
|
154
|
-
},
|
|
154
|
+
}, fe = () => D(), he = ({
|
|
155
155
|
id: e,
|
|
156
156
|
canTrack: t
|
|
157
157
|
}) => j({
|
|
158
158
|
name: K,
|
|
159
159
|
value: e,
|
|
160
160
|
canTrack: t
|
|
161
|
-
}),
|
|
161
|
+
}), W = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, ge = ({
|
|
162
162
|
key: e,
|
|
163
163
|
canTrack: t
|
|
164
164
|
}) => {
|
|
165
165
|
var n;
|
|
166
166
|
try {
|
|
167
|
-
return t ? (n =
|
|
167
|
+
return t ? (n = W()) == null ? void 0 : n.getItem(e) : void 0;
|
|
168
168
|
} catch (r) {
|
|
169
169
|
console.debug("[LocalStorage] GET error: ", r);
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
},
|
|
172
|
+
}, pe = ({
|
|
173
173
|
key: e,
|
|
174
174
|
canTrack: t,
|
|
175
175
|
value: n
|
|
176
176
|
}) => {
|
|
177
177
|
var r;
|
|
178
178
|
try {
|
|
179
|
-
t && ((r =
|
|
179
|
+
t && ((r = W()) == null || r.setItem(e, n));
|
|
180
180
|
} catch (o) {
|
|
181
181
|
console.debug("[LocalStorage] SET error: ", o);
|
|
182
182
|
}
|
|
183
|
-
},
|
|
183
|
+
}, _ = "builderVisitorId", me = ({
|
|
184
184
|
canTrack: e
|
|
185
185
|
}) => {
|
|
186
186
|
if (!e)
|
|
187
187
|
return;
|
|
188
|
-
const t =
|
|
189
|
-
key:
|
|
188
|
+
const t = ge({
|
|
189
|
+
key: _,
|
|
190
190
|
canTrack: e
|
|
191
191
|
});
|
|
192
192
|
if (m(t))
|
|
193
193
|
return t;
|
|
194
194
|
{
|
|
195
|
-
const n =
|
|
196
|
-
return
|
|
195
|
+
const n = ye();
|
|
196
|
+
return we({
|
|
197
197
|
id: n,
|
|
198
198
|
canTrack: e
|
|
199
199
|
}), n;
|
|
200
200
|
}
|
|
201
|
-
},
|
|
201
|
+
}, ye = () => D(), we = ({
|
|
202
202
|
id: e,
|
|
203
203
|
canTrack: t
|
|
204
|
-
}) =>
|
|
205
|
-
key:
|
|
204
|
+
}) => pe({
|
|
205
|
+
key: _,
|
|
206
206
|
value: e,
|
|
207
207
|
canTrack: t
|
|
208
208
|
}), Se = () => {
|
|
@@ -211,8 +211,8 @@ const K = "builderSessionId", de = async ({
|
|
|
211
211
|
return e.pathname === "" && (e.pathname = "/"), e;
|
|
212
212
|
} else
|
|
213
213
|
return console.warn("Cannot get location for tracking in non-browser environment"), null;
|
|
214
|
-
},
|
|
215
|
-
const e =
|
|
214
|
+
}, be = () => typeof navigator == "object" && navigator.userAgent || "", ve = () => {
|
|
215
|
+
const e = be(), t = {
|
|
216
216
|
Android() {
|
|
217
217
|
return e.match(/Android/i);
|
|
218
218
|
},
|
|
@@ -229,7 +229,7 @@ const K = "builderSessionId", de = async ({
|
|
|
229
229
|
return e.match(/IEMobile/i) || e.match(/WPDesktop/i);
|
|
230
230
|
},
|
|
231
231
|
any() {
|
|
232
|
-
return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() ||
|
|
232
|
+
return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || v === "reactNative";
|
|
233
233
|
}
|
|
234
234
|
}, n = e.match(/Tablet|iPad/i), r = Se();
|
|
235
235
|
return {
|
|
@@ -237,7 +237,7 @@ const K = "builderSessionId", de = async ({
|
|
|
237
237
|
host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
|
|
238
238
|
device: n ? "tablet" : t.any() ? "mobile" : "desktop"
|
|
239
239
|
};
|
|
240
|
-
},
|
|
240
|
+
}, Ie = async ({
|
|
241
241
|
canTrack: e
|
|
242
242
|
}) => {
|
|
243
243
|
if (!e)
|
|
@@ -245,16 +245,16 @@ const K = "builderSessionId", de = async ({
|
|
|
245
245
|
visitorId: void 0,
|
|
246
246
|
sessionId: void 0
|
|
247
247
|
};
|
|
248
|
-
const t = await
|
|
248
|
+
const t = await le({
|
|
249
249
|
canTrack: e
|
|
250
|
-
}), n =
|
|
250
|
+
}), n = me({
|
|
251
251
|
canTrack: e
|
|
252
252
|
});
|
|
253
253
|
return {
|
|
254
254
|
sessionId: t,
|
|
255
255
|
visitorId: n
|
|
256
256
|
};
|
|
257
|
-
},
|
|
257
|
+
}, ke = async ({
|
|
258
258
|
type: e,
|
|
259
259
|
canTrack: t,
|
|
260
260
|
apiKey: n,
|
|
@@ -268,23 +268,23 @@ const K = "builderSessionId", de = async ({
|
|
|
268
268
|
url: location.href,
|
|
269
269
|
...r
|
|
270
270
|
},
|
|
271
|
-
...await
|
|
271
|
+
...await Ie({
|
|
272
272
|
canTrack: t
|
|
273
273
|
}),
|
|
274
|
-
userAttributes:
|
|
274
|
+
userAttributes: ve(),
|
|
275
275
|
ownerId: n
|
|
276
276
|
}
|
|
277
277
|
});
|
|
278
|
-
async function
|
|
278
|
+
async function Ee(e) {
|
|
279
279
|
if (!e.apiKey) {
|
|
280
280
|
f.error("Missing API key for track call. Please provide your API key.");
|
|
281
281
|
return;
|
|
282
282
|
}
|
|
283
|
-
if (e.canTrack && !
|
|
283
|
+
if (e.canTrack && !Z() && (c() || v === "reactNative"))
|
|
284
284
|
return fetch("https://cdn.builder.io/api/v1/track", {
|
|
285
285
|
method: "POST",
|
|
286
286
|
body: JSON.stringify({
|
|
287
|
-
events: [await
|
|
287
|
+
events: [await ke(e)]
|
|
288
288
|
}),
|
|
289
289
|
headers: {
|
|
290
290
|
"content-type": "application/json"
|
|
@@ -294,16 +294,16 @@ async function ke(e) {
|
|
|
294
294
|
console.error("Failed to track: ", t);
|
|
295
295
|
});
|
|
296
296
|
}
|
|
297
|
-
const
|
|
297
|
+
const He = (e) => Ee({
|
|
298
298
|
...e,
|
|
299
299
|
canTrack: !0
|
|
300
|
-
}),
|
|
300
|
+
}), Oe = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
|
|
301
301
|
function $(e, t) {
|
|
302
302
|
const n = new URL(t.origin), r = n.hostname;
|
|
303
|
-
return (e ||
|
|
303
|
+
return (e || Oe).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
|
|
304
304
|
}
|
|
305
|
-
const Pe = "1.0.
|
|
306
|
-
|
|
305
|
+
const Pe = "1.0.27", Xe = () => {
|
|
306
|
+
re("insertMenu", {
|
|
307
307
|
name: "_default",
|
|
308
308
|
default: !0,
|
|
309
309
|
items: [{
|
|
@@ -331,7 +331,7 @@ const Ce = (e = {}) => {
|
|
|
331
331
|
R || (R = !0, c() && ((t = window.parent) == null || t.postMessage({
|
|
332
332
|
type: "builder.sdkInfo",
|
|
333
333
|
data: {
|
|
334
|
-
target:
|
|
334
|
+
target: v,
|
|
335
335
|
version: Pe,
|
|
336
336
|
supportsPatchUpdates: !1,
|
|
337
337
|
// Supports builder-model="..." attribute which is needed to
|
|
@@ -354,10 +354,10 @@ const Ce = (e = {}) => {
|
|
|
354
354
|
if (o != null && o.type)
|
|
355
355
|
switch (o.type) {
|
|
356
356
|
case "builder.evaluate": {
|
|
357
|
-
const d = o.data.text, y = o.data.arguments || [], p = o.data.id,
|
|
357
|
+
const d = o.data.text, y = o.data.arguments || [], p = o.data.id, I = new Function(d);
|
|
358
358
|
let u, h = null;
|
|
359
359
|
try {
|
|
360
|
-
u =
|
|
360
|
+
u = I.apply(null, y);
|
|
361
361
|
} catch (g) {
|
|
362
362
|
h = g;
|
|
363
363
|
}
|
|
@@ -368,8 +368,8 @@ const Ce = (e = {}) => {
|
|
|
368
368
|
error: h.message
|
|
369
369
|
}
|
|
370
370
|
}, "*") : u && typeof u.then == "function" ? u.then((g) => {
|
|
371
|
-
var
|
|
372
|
-
(
|
|
371
|
+
var w;
|
|
372
|
+
(w = window.parent) == null || w.postMessage({
|
|
373
373
|
type: "builder.evaluateResult",
|
|
374
374
|
data: {
|
|
375
375
|
id: p,
|
|
@@ -387,7 +387,7 @@ const Ce = (e = {}) => {
|
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
})));
|
|
390
|
-
},
|
|
390
|
+
}, xe = ({
|
|
391
391
|
model: e,
|
|
392
392
|
trustedHosts: t,
|
|
393
393
|
callbacks: n
|
|
@@ -413,12 +413,12 @@ const Ce = (e = {}) => {
|
|
|
413
413
|
break;
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
|
-
},
|
|
416
|
+
}, qe = (e, t, n) => {
|
|
417
417
|
if (!c)
|
|
418
418
|
return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
|
|
419
419
|
};
|
|
420
420
|
Ce();
|
|
421
|
-
const r =
|
|
421
|
+
const r = xe({
|
|
422
422
|
callbacks: {
|
|
423
423
|
contentUpdate: t,
|
|
424
424
|
animation: () => {
|
|
@@ -432,24 +432,24 @@ const Ce = (e = {}) => {
|
|
|
432
432
|
return window.addEventListener("message", r), () => {
|
|
433
433
|
window.removeEventListener("message", r);
|
|
434
434
|
};
|
|
435
|
-
},
|
|
435
|
+
}, Ae = "builder.tests", E = (e) => `${Ae}.${e}`, Te = ({
|
|
436
436
|
contentId: e
|
|
437
437
|
}) => F({
|
|
438
438
|
name: E(e),
|
|
439
439
|
canTrack: !0
|
|
440
|
-
}),
|
|
440
|
+
}), Re = ({
|
|
441
441
|
contentId: e
|
|
442
442
|
}) => N({
|
|
443
443
|
name: E(e),
|
|
444
444
|
canTrack: !0
|
|
445
|
-
}),
|
|
445
|
+
}), Be = ({
|
|
446
446
|
contentId: e,
|
|
447
447
|
value: t
|
|
448
448
|
}) => j({
|
|
449
449
|
name: E(e),
|
|
450
450
|
value: t,
|
|
451
451
|
canTrack: !0
|
|
452
|
-
}), G = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0,
|
|
452
|
+
}), G = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Le = ({
|
|
453
453
|
id: e,
|
|
454
454
|
variations: t
|
|
455
455
|
}) => {
|
|
@@ -463,8 +463,8 @@ const Ce = (e = {}) => {
|
|
|
463
463
|
}
|
|
464
464
|
return e;
|
|
465
465
|
}, z = (e) => {
|
|
466
|
-
const t =
|
|
467
|
-
return
|
|
466
|
+
const t = Le(e);
|
|
467
|
+
return Be({
|
|
468
468
|
contentId: e.id,
|
|
469
469
|
value: t
|
|
470
470
|
}).catch((n) => {
|
|
@@ -484,7 +484,7 @@ const Ce = (e = {}) => {
|
|
|
484
484
|
testVariationId: n.id,
|
|
485
485
|
testVariationName: n.name || (n.id === e.id ? "Default" : "")
|
|
486
486
|
};
|
|
487
|
-
},
|
|
487
|
+
}, Qe = ({
|
|
488
488
|
item: e,
|
|
489
489
|
canTrack: t
|
|
490
490
|
}) => {
|
|
@@ -494,7 +494,7 @@ const Ce = (e = {}) => {
|
|
|
494
494
|
return;
|
|
495
495
|
if (!G(e))
|
|
496
496
|
return e;
|
|
497
|
-
const n =
|
|
497
|
+
const n = Re({
|
|
498
498
|
contentId: e.id
|
|
499
499
|
}) || z({
|
|
500
500
|
variations: e.variations,
|
|
@@ -507,13 +507,13 @@ const Ce = (e = {}) => {
|
|
|
507
507
|
...e,
|
|
508
508
|
...r
|
|
509
509
|
};
|
|
510
|
-
},
|
|
510
|
+
}, Ve = async ({
|
|
511
511
|
item: e,
|
|
512
512
|
canTrack: t
|
|
513
513
|
}) => {
|
|
514
514
|
if (!t || !G(e))
|
|
515
515
|
return e;
|
|
516
|
-
const r = await
|
|
516
|
+
const r = await Te({
|
|
517
517
|
contentId: e.id
|
|
518
518
|
}) || z({
|
|
519
519
|
variations: e.variations,
|
|
@@ -526,31 +526,38 @@ const Ce = (e = {}) => {
|
|
|
526
526
|
...e,
|
|
527
527
|
...o
|
|
528
528
|
};
|
|
529
|
-
},
|
|
530
|
-
function
|
|
529
|
+
}, Ue = (e) => m(e) ? e : !0;
|
|
530
|
+
function Me() {
|
|
531
531
|
return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
|
|
532
532
|
}
|
|
533
|
-
function
|
|
534
|
-
const e =
|
|
533
|
+
function Ne() {
|
|
534
|
+
const e = Me().fetch;
|
|
535
535
|
if (typeof e == "undefined")
|
|
536
536
|
throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
537
537
|
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
|
|
538
538
|
return e;
|
|
539
539
|
}
|
|
540
|
-
const
|
|
541
|
-
function
|
|
540
|
+
const Fe = Ne();
|
|
541
|
+
function k(e, t = null, n = ".") {
|
|
542
542
|
return Object.keys(e).reduce((r, o) => {
|
|
543
543
|
const s = e[o], a = [t, o].filter(Boolean).join(n);
|
|
544
544
|
return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
|
|
545
545
|
...r,
|
|
546
|
-
...
|
|
546
|
+
...k(s, a, n)
|
|
547
547
|
} : {
|
|
548
548
|
...r,
|
|
549
549
|
[a]: s
|
|
550
550
|
};
|
|
551
551
|
}, {});
|
|
552
552
|
}
|
|
553
|
-
|
|
553
|
+
function H(e, t, n = {}) {
|
|
554
|
+
for (const r in e) {
|
|
555
|
+
const o = e[r], s = t ? t + "." + r : r;
|
|
556
|
+
o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((a) => a.startsWith("$")) ? H(o, s, n) : n[s] = o;
|
|
557
|
+
}
|
|
558
|
+
return n;
|
|
559
|
+
}
|
|
560
|
+
const je = "v3", B = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e) => {
|
|
554
561
|
const {
|
|
555
562
|
limit: t = 30,
|
|
556
563
|
userAttributes: n,
|
|
@@ -559,61 +566,61 @@ const Fe = "v3", B = (e) => typeof e == "number" && !isNaN(e) && e >= 0, P = (e)
|
|
|
559
566
|
apiKey: s,
|
|
560
567
|
enrich: a,
|
|
561
568
|
locale: d,
|
|
562
|
-
apiVersion: y =
|
|
569
|
+
apiVersion: y = je,
|
|
563
570
|
fields: p,
|
|
564
|
-
omit:
|
|
571
|
+
omit: I,
|
|
565
572
|
offset: u,
|
|
566
573
|
cacheSeconds: h,
|
|
567
574
|
staleCacheSeconds: g,
|
|
568
|
-
sort:
|
|
569
|
-
includeUnpublished:
|
|
575
|
+
sort: w,
|
|
576
|
+
includeUnpublished: P
|
|
570
577
|
} = e;
|
|
571
578
|
if (!s)
|
|
572
579
|
throw new Error("Missing API key");
|
|
573
580
|
if (!["v3"].includes(y))
|
|
574
581
|
throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
|
|
575
|
-
const
|
|
576
|
-
if (i.searchParams.set("apiKey", s), i.searchParams.set("limit", String(t)), i.searchParams.set("noTraverse", String(
|
|
577
|
-
const l =
|
|
578
|
-
sort:
|
|
582
|
+
const X = t !== 1, i = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
|
|
583
|
+
if (i.searchParams.set("apiKey", s), i.searchParams.set("limit", String(t)), i.searchParams.set("noTraverse", String(X)), i.searchParams.set("includeRefs", String(!0)), d && i.searchParams.set("locale", d), a && i.searchParams.set("enrich", String(a)), i.searchParams.set("omit", I || "meta.componentsUsed"), p && i.searchParams.set("fields", p), Number.isFinite(u) && u > -1 && i.searchParams.set("offset", String(Math.floor(u))), typeof P == "boolean" && i.searchParams.set("includeUnpublished", String(P)), h && B(h) && i.searchParams.set("cacheSeconds", String(h)), g && B(g) && i.searchParams.set("staleCacheSeconds", String(g)), w) {
|
|
584
|
+
const l = k({
|
|
585
|
+
sort: w
|
|
579
586
|
});
|
|
580
|
-
for (const
|
|
581
|
-
i.searchParams.set(
|
|
587
|
+
for (const S in l)
|
|
588
|
+
i.searchParams.set(S, JSON.stringify(l[S]));
|
|
582
589
|
}
|
|
583
|
-
const
|
|
584
|
-
...
|
|
590
|
+
const q = {
|
|
591
|
+
...se(),
|
|
585
592
|
...L(e.options || {})
|
|
586
|
-
},
|
|
587
|
-
for (const l in
|
|
588
|
-
i.searchParams.set(l, String(
|
|
593
|
+
}, C = k(q);
|
|
594
|
+
for (const l in C)
|
|
595
|
+
i.searchParams.set(l, String(C[l]));
|
|
589
596
|
if (n && i.searchParams.set("userAttributes", JSON.stringify(n)), r) {
|
|
590
|
-
const l =
|
|
597
|
+
const l = H({
|
|
591
598
|
query: r
|
|
592
599
|
});
|
|
593
|
-
for (const
|
|
594
|
-
i.searchParams.set(
|
|
600
|
+
for (const S in l)
|
|
601
|
+
i.searchParams.set(S, JSON.stringify(l[S]));
|
|
595
602
|
}
|
|
596
603
|
return i;
|
|
597
|
-
},
|
|
598
|
-
async function
|
|
599
|
-
const t = await
|
|
604
|
+
}, De = (e) => "results" in e;
|
|
605
|
+
async function Ke(e) {
|
|
606
|
+
const t = await $e({
|
|
600
607
|
...e,
|
|
601
608
|
limit: 1
|
|
602
609
|
});
|
|
603
610
|
return t && t[0] || null;
|
|
604
611
|
}
|
|
605
|
-
const
|
|
612
|
+
const We = async (e) => {
|
|
606
613
|
var s;
|
|
607
|
-
const t =
|
|
608
|
-
return await (await ((s = e.fetch) != null ? s :
|
|
609
|
-
}, _e = async (e, t, n =
|
|
610
|
-
const r =
|
|
611
|
-
if (n.search.includes("preview="), !r || !(c() ||
|
|
614
|
+
const t = O(e);
|
|
615
|
+
return await (await ((s = e.fetch) != null ? s : Fe)(t.href, e.fetchOptions)).json();
|
|
616
|
+
}, _e = async (e, t, n = O(e)) => {
|
|
617
|
+
const r = Ue(e.canTrack);
|
|
618
|
+
if (n.search.includes("preview="), !r || !(c() || v === "reactNative"))
|
|
612
619
|
return t.results;
|
|
613
620
|
try {
|
|
614
621
|
const o = [];
|
|
615
622
|
for (const s of t.results)
|
|
616
|
-
o.push(await
|
|
623
|
+
o.push(await Ve({
|
|
617
624
|
item: s,
|
|
618
625
|
canTrack: r
|
|
619
626
|
}));
|
|
@@ -623,10 +630,10 @@ const Ke = async (e) => {
|
|
|
623
630
|
}
|
|
624
631
|
return t.results;
|
|
625
632
|
};
|
|
626
|
-
async function
|
|
633
|
+
async function $e(e) {
|
|
627
634
|
try {
|
|
628
|
-
const t =
|
|
629
|
-
return
|
|
635
|
+
const t = O(e), n = await We(e);
|
|
636
|
+
return De(n) ? _e(e, n) : (f.error("Error fetching data. ", {
|
|
630
637
|
url: t,
|
|
631
638
|
content: n,
|
|
632
639
|
options: e
|
|
@@ -652,35 +659,35 @@ const Ye = async (e) => {
|
|
|
652
659
|
return {
|
|
653
660
|
apiKey: n.apiKey,
|
|
654
661
|
model: n.model,
|
|
655
|
-
content: await
|
|
662
|
+
content: await Ke(n)
|
|
656
663
|
};
|
|
657
664
|
};
|
|
658
665
|
export {
|
|
659
666
|
b as MSG_PREFIX,
|
|
660
|
-
|
|
667
|
+
v as TARGET,
|
|
661
668
|
_e as _processContentResult,
|
|
662
|
-
|
|
669
|
+
Ee as _track,
|
|
663
670
|
m as checkIsDefined,
|
|
664
|
-
|
|
665
|
-
|
|
671
|
+
xe as createEditorListener,
|
|
672
|
+
ze as createRegisterComponentMessage,
|
|
666
673
|
U as fastClone,
|
|
667
|
-
|
|
674
|
+
Fe as fetch,
|
|
668
675
|
Ye as fetchBuilderProps,
|
|
669
|
-
|
|
670
|
-
|
|
676
|
+
$e as fetchEntries,
|
|
677
|
+
Ke as fetchOneEntry,
|
|
671
678
|
M as getBuilderSearchParams,
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
679
|
+
Ue as getDefaultCanTrack,
|
|
680
|
+
ve as getUserAttributes,
|
|
681
|
+
Qe as handleABTestingSync,
|
|
675
682
|
c as isBrowser,
|
|
676
|
-
|
|
677
|
-
|
|
683
|
+
Z as isEditing,
|
|
684
|
+
Ge as isPreviewing,
|
|
678
685
|
f as logger,
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
686
|
+
re as register,
|
|
687
|
+
Xe as registerInsertMenu,
|
|
688
|
+
ne as serializeComponentInfo,
|
|
689
|
+
Je as setEditorSettings,
|
|
683
690
|
Ce as setupBrowserForEditing,
|
|
684
|
-
|
|
685
|
-
|
|
691
|
+
qe as subscribeToEditor,
|
|
692
|
+
He as track
|
|
686
693
|
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const I="react",ue=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},M=e=>e instanceof URLSearchParams?ue(e):e,U=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function c(){return typeof window!="undefined"&&typeof document!="undefined"}function de(){return c()&&window.self!==window.top}function F(e){return de()&&U(e||window.location.search).indexOf("builder.frameEditing=")!==-1}function le(e){const t=e||(c()?window.location.search:void 0);return t?U(t).indexOf("builder.preview=")!==-1:!1}const k=e=>JSON.parse(JSON.stringify(e)),fe=e=>({type:"builder.registerComponent",data:N(e)}),ge=e=>{const t=e.toString().trim();return`return (${!t.startsWith("function")&&!t.startsWith("(")?"function ":""}${t}).apply(this, arguments)`},he=e=>typeof e=="function"?ge(e):k(e),N=({inputs:e,...t})=>({...k(t),inputs:e==null?void 0:e.map(n=>Object.entries(n).reduce((r,[o,s])=>({...r,[o]:he(s)}),{}))}),x={};function D(e,t){let n=x[e];if(n||(n=x[e]=[]),n.push(t),c()){const r={type:"builder.register",data:{type:e,info:t}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(o){console.debug("Could not postmessage",o)}}}const R={};function pe(e){if(c()){Object.assign(R,e);const t={type:"builder.settingsChange",data:R};parent.postMessage(t,"*")}}const B="builder.",me="options.",C=e=>{if(!e)return{};const t=M(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(B)){const o=r.replace(B,"").replace(me,"");n[o]=t[r]}}),n},ye=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return C(e)},b="[Builder.io]: ",d={log:(...e)=>console.log(b,...e),error:(...e)=>console.error(b,...e),warn:(...e)=>console.warn(b,...e),debug:(...e)=>console.debug(b,...e)},p=e=>e!=null,Se=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},j=({name:e,canTrack:t})=>{var n;try{return t?(n=document.cookie.split("; ").find(r=>r.startsWith(`${e}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){d.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},K=async e=>j(e),we=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),be=[["secure",""],["SameSite","None"]],Ie=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?be:[[]],s=n?[["expires",n.toUTCString()]]:[[]],a=[[e,t],...s,["path","/"],["domain",Se(window.location.hostname)],...o];return we(a)},_=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=Ie({name:e,value:t,expires:n});document.cookie=o}catch(o){d.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}};function ve(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}function W(){return ve().replace(/-/g,"")}const $="builderSessionId",Ee=async({canTrack:e})=>{if(!e)return;const t=await K({name:$,canTrack:e});if(p(t))return t;{const n=ke();return Ce({id:n,canTrack:e}),n}},ke=()=>W(),Ce=({id:e,canTrack:t})=>_({name:$,value:e,canTrack:t}),G=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Pe=({key:e,canTrack:t})=>{var n;try{return t?(n=G())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Oe=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=G())==null||r.setItem(e,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},z="builderVisitorId",Ae=({canTrack:e})=>{if(!e)return;const t=Pe({key:z,canTrack:e});if(p(t))return t;{const n=Te();return xe({id:n,canTrack:e}),n}},Te=()=>W(),xe=({id:e,canTrack:t})=>Oe({key:z,value:e,canTrack:t}),Re=()=>{if(c()){const e=new URL(location.href);return e.pathname===""&&(e.pathname="/"),e}else return console.warn("Cannot get location for tracking in non-browser environment"),null},Be=()=>typeof navigator=="object"&&navigator.userAgent||"",J=()=>{const e=Be(),t={Android(){return e.match(/Android/i)},BlackBerry(){return e.match(/BlackBerry/i)},iOS(){return e.match(/iPhone|iPod/i)},Opera(){return e.match(/Opera Mini/i)},Windows(){return e.match(/IEMobile/i)||e.match(/WPDesktop/i)},any(){return t.Android()||t.BlackBerry()||t.iOS()||t.Opera()||t.Windows()||I==="reactNative"}},n=e.match(/Tablet|iPad/i),r=Re();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":t.any()?"mobile":"desktop"}},Le=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Ee({canTrack:e}),n=Ae({canTrack:e});return{sessionId:t,visitorId:n}},Ve=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await Le({canTrack:t}),userAttributes:J(),ownerId:n}});async function H(e){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(e.canTrack&&!F()&&(c()||I==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await Ve(e)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(t=>{console.error("Failed to track: ",t)})}const Me=e=>H({...e,canTrack:!0}),Ue=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function X(e,t){const n=new URL(t.origin),r=n.hostname;return(e||Ue).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const Fe="1.0.27",Ne=()=>{D("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 L=!1;const q=(e={})=>{var t,n;L||(L=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:I,version:Fe,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var s,a;if(!X(e.trustedHosts,r))return;const{data:o}=r;if(o!=null&&o.type)switch(o.type){case"builder.evaluate":{const l=o.data.text,y=o.data.arguments||[],m=o.data.id,v=new Function(l);let u,g=null;try{u=v.apply(null,y)}catch(h){g=h}g?(s=window.parent)==null||s.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):u&&typeof u.then=="function"?u.then(h=>{var S;(S=window.parent)==null||S.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(a=window.parent)==null||a.postMessage({type:"builder.evaluateResult",data:{result:u,id:m}},"*");break}}})))},Q=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!X(t,r))return;const{data:o}=r;if(o)switch(o.type){case"builder.configureSdk":{n.configureSdk(o.data);break}case"builder.triggerAnimation":{n.animation(o.data);break}case"builder.contentUpdate":{const s=o.data,a=s.key||s.alias||s.entry||s.modelName,l=s.data;a===e&&n.contentUpdate(l);break}}},De=(e,t,n)=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};q();const r=Q({callbacks:{contentUpdate:t,animation:()=>{},configureSdk:()=>{}},model:e,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},je="builder.tests",P=e=>`${je}.${e}`,Ke=({contentId:e})=>K({name:P(e),canTrack:!0}),_e=({contentId:e})=>j({name:P(e),canTrack:!0}),We=({contentId:e,value:t})=>_({name:P(e),value:t,canTrack:!0}),Y=e=>p(e.id)&&p(e.variations)&&Object.keys(e.variations).length>0,$e=({id:e,variations:t})=>{var o;let n=0;const r=Math.random();for(const s in t){const a=(o=t[s])==null?void 0:o.testRatio;if(n+=a,r<n)return s}return e},Z=e=>{const t=$e(e);return We({contentId:e.id,value:t}).catch(n=>{d.error("could not store A/B test variation: ",n)}),t},ee=({item:e,testGroupId:t})=>{const n=e.variations[t];return t===e.id||!n?{testVariationId:e.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===e.id?"Default":"")}},Ge=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!Y(e))return e;const n=_e({contentId:e.id})||Z({variations:e.variations,id:e.id}),r=ee({item:e,testGroupId:n});return{...e,...r}},ze=async({item:e,canTrack:t})=>{if(!t||!Y(e))return e;const r=await Ke({contentId:e.id})||Z({variations:e.variations,id:e.id}),o=ee({item:e,testGroupId:r});return{...e,...o}},te=e=>p(e)?e:!0;function Je(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function He(){const e=Je().fetch;if(typeof e=="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 e}const ne=He();function E(e,t=null,n="."){return Object.keys(e).reduce((r,o)=>{const s=e[o],a=[t,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...E(s,a,n)}:{...r,[a]:s}},{})}function re(e,t,n={}){for(const r in e){const o=e[r],s=t?t+"."+r:r;o&&typeof o=="object"&&!Array.isArray(o)&&!Object.keys(o).find(a=>a.startsWith("$"))?re(o,s,n):n[s]=o}return n}const Xe="v3",V=e=>typeof e=="number"&&!isNaN(e)&&e>=0,O=e=>{const{limit:t=30,userAttributes:n,query:r,model:o,apiKey:s,enrich:a,locale:l,apiVersion:y=Xe,fields:m,omit:v,offset:u,cacheSeconds:g,staleCacheSeconds:h,sort:S,includeUnpublished:A}=e;if(!s)throw new Error("Missing API key");if(!["v3"].includes(y))throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);const ae=t!==1,i=new URL(`https://cdn.builder.io/api/${y}/content/${o}`);if(i.searchParams.set("apiKey",s),i.searchParams.set("limit",String(t)),i.searchParams.set("noTraverse",String(ae)),i.searchParams.set("includeRefs",String(!0)),l&&i.searchParams.set("locale",l),a&&i.searchParams.set("enrich",String(a)),i.searchParams.set("omit",v||"meta.componentsUsed"),m&&i.searchParams.set("fields",m),Number.isFinite(u)&&u>-1&&i.searchParams.set("offset",String(Math.floor(u))),typeof A=="boolean"&&i.searchParams.set("includeUnpublished",String(A)),g&&V(g)&&i.searchParams.set("cacheSeconds",String(g)),h&&V(h)&&i.searchParams.set("staleCacheSeconds",String(h)),S){const f=E({sort:S});for(const w in f)i.searchParams.set(w,JSON.stringify(f[w]))}const ce={...ye(),...M(e.options||{})},T=E(ce);for(const f in T)i.searchParams.set(f,String(T[f]));if(n&&i.searchParams.set("userAttributes",JSON.stringify(n)),r){const f=re({query:r});for(const w in f)i.searchParams.set(w,JSON.stringify(f[w]))}return i},qe=e=>"results"in e;async function oe(e){const t=await ie({...e,limit:1});return t&&t[0]||null}const Qe=async e=>{var s;const t=O(e);return await(await((s=e.fetch)!=null?s:ne)(t.href,e.fetchOptions)).json()},se=async(e,t,n=O(e))=>{const r=te(e.canTrack);if(n.search.includes("preview="),!r||!(c()||I==="reactNative"))return t.results;try{const o=[];for(const s of t.results)o.push(await ze({item:s,canTrack:r}));t.results=o}catch(o){d.error("Could not process A/B tests. ",o)}return t.results};async function ie(e){try{const t=O(e),n=await Qe(e);return qe(n)?se(e,n):(d.error("Error fetching data. ",{url:t,content:n,options:e}),null)}catch(t){return d.error("Error fetching data. ",t),null}}const Ye=async e=>{var r,o,s;const t=e.path||((r=e.url)==null?void 0:r.pathname)||((o=e.userAttributes)==null?void 0:o.urlPath),n={...e,apiKey:e.apiKey,model:e.model||"page",userAttributes:{...e.userAttributes,...t?{urlPath:t}:{}},options:C(e.searchParams||((s=e.url)==null?void 0:s.searchParams)||e.options)};return{apiKey:n.apiKey,model:n.model,content:await oe(n)}};exports.MSG_PREFIX=b;exports.TARGET=I;exports._processContentResult=se;exports._track=H;exports.checkIsDefined=p;exports.createEditorListener=Q;exports.createRegisterComponentMessage=fe;exports.fastClone=k;exports.fetch=ne;exports.fetchBuilderProps=Ye;exports.fetchEntries=ie;exports.fetchOneEntry=oe;exports.getBuilderSearchParams=C;exports.getDefaultCanTrack=te;exports.getUserAttributes=J;exports.handleABTestingSync=Ge;exports.isBrowser=c;exports.isEditing=F;exports.isPreviewing=le;exports.logger=d;exports.register=D;exports.registerInsertMenu=Ne;exports.serializeComponentInfo=N;exports.setEditorSettings=pe;exports.setupBrowserForEditing=q;exports.subscribeToEditor=De;exports.track=Me;
|