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