@builder.io/sdk-react 2.0.29 → 2.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/lib/browser/blocks-exports.cjs +18 -18
  2. package/lib/browser/blocks-exports.mjs +584 -587
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +1 -1
  5. package/lib/{edge/server-entry-05dd3f4b.js → browser/server-entry-77f4513c.js} +245 -228
  6. package/lib/browser/server-entry-d7a13b14.cjs +2 -0
  7. package/lib/browser/server-entry.cjs +1 -1
  8. package/lib/browser/server-entry.mjs +1 -1
  9. package/lib/edge/{accordion-200ac141.cjs → accordion-696fad97.cjs} +1 -1
  10. package/lib/edge/{accordion-1fae9bd5.js → accordion-d1213549.js} +1 -1
  11. package/lib/edge/{blocks-b47cd3fc.js → blocks-9ef79098.js} +3 -3
  12. package/lib/edge/{blocks-fd9e445c.cjs → blocks-aa67fee8.cjs} +1 -1
  13. package/lib/edge/blocks-exports.cjs +1 -1
  14. package/lib/edge/blocks-exports.mjs +2 -2
  15. package/lib/edge/{button-ffe70d17.cjs → button-2ed05d22.cjs} +1 -1
  16. package/lib/edge/{button-5cc9a94f.js → button-b41f1129.js} +2 -2
  17. package/lib/edge/{columns-9ad996bb.js → columns-5f8497fb.js} +4 -4
  18. package/lib/edge/{columns-7651ba21.cjs → columns-ca9ac444.cjs} +1 -1
  19. package/lib/edge/{content-variants-a9017964.cjs → content-variants-2f5a6ccd.cjs} +4 -4
  20. package/lib/edge/{content-variants-0ece6057.js → content-variants-9c4db669.js} +118 -118
  21. package/lib/edge/{evaluate-73e0df40.cjs → evaluate-8453ffc0.cjs} +1 -1
  22. package/lib/edge/{evaluate-5cfe10b0.js → evaluate-f626f584.js} +1 -1
  23. package/lib/edge/{form-186bf59f.js → form-a5407307.js} +30 -33
  24. package/lib/edge/form-b0c5418b.cjs +1 -0
  25. package/lib/edge/{get-class-prop-name-7d6a77a4.js → get-class-prop-name-40d6defb.js} +1 -1
  26. package/lib/edge/{get-class-prop-name-11734dbc.cjs → get-class-prop-name-86f0330a.cjs} +1 -1
  27. package/lib/edge/{img-ef160d2b.cjs → img-83ed868e.cjs} +1 -1
  28. package/lib/edge/{img-6c1f4ea4.js → img-fa36f926.js} +1 -1
  29. package/lib/edge/index.cjs +1 -1
  30. package/lib/edge/index.mjs +1 -1
  31. package/lib/edge/{input-97dc199a.cjs → input-3106b577.cjs} +1 -1
  32. package/lib/edge/{input-b4ee4339.js → input-93e42e28.js} +1 -1
  33. package/lib/edge/{select-2cdf2c8f.cjs → select-29495824.cjs} +1 -1
  34. package/lib/edge/{select-e79d6e1b.js → select-4cf4356a.js} +1 -1
  35. package/lib/edge/server-entry-4cd5389e.cjs +2 -0
  36. package/lib/{node/server-entry-00c52924.js → edge/server-entry-ea35faa6.js} +243 -231
  37. package/lib/edge/server-entry.cjs +1 -1
  38. package/lib/edge/server-entry.mjs +1 -1
  39. package/lib/edge/{slot-680234a8.js → slot-6ad4152e.js} +4 -4
  40. package/lib/edge/{slot-66ba436b.cjs → slot-c8ab71b6.cjs} +1 -1
  41. package/lib/edge/{symbol-4d0b1228.cjs → symbol-74313a4b.cjs} +1 -1
  42. package/lib/edge/{symbol-e920f028.js → symbol-d2b48e54.js} +2 -2
  43. package/lib/edge/{tabs-1bea88d1.js → tabs-6d924c90.js} +4 -4
  44. package/lib/edge/{tabs-1f3f45cf.cjs → tabs-f699b318.cjs} +1 -1
  45. package/lib/edge/{text-9533b278.cjs → text-7120ee0c.cjs} +1 -1
  46. package/lib/edge/{text-fd78274f.js → text-7137a306.js} +2 -2
  47. package/lib/node/blocks-exports.cjs +20 -20
  48. package/lib/node/blocks-exports.mjs +576 -579
  49. package/lib/node/index.cjs +1 -1
  50. package/lib/node/index.mjs +3 -3
  51. package/lib/node/init.cjs +1 -1
  52. package/lib/node/init.mjs +3 -3
  53. package/lib/{browser/server-entry-712b1faa.js → node/server-entry-32ef60c0.js} +213 -197
  54. package/lib/node/server-entry-9c026e49.cjs +2 -0
  55. package/lib/node/server-entry.cjs +1 -1
  56. package/lib/node/server-entry.mjs +1 -1
  57. package/lib/node/{setIvm-156def75.js → setIvm-26e65816.js} +1 -1
  58. package/lib/node/{setIvm-ca4d1590.cjs → setIvm-bf1ad328.cjs} +1 -1
  59. package/lib/node/setIvm.cjs +1 -1
  60. package/lib/node/setIvm.mjs +2 -2
  61. package/lib/node/{should-force-browser-runtime-in-node-bc24fcdd.cjs → should-force-browser-runtime-in-node-000957e3.cjs} +1 -1
  62. package/lib/node/{should-force-browser-runtime-in-node-eb3eac6a.js → should-force-browser-runtime-in-node-343fd6c7.js} +1 -1
  63. package/package.json +1 -1
  64. package/types/constants/sdk-version.d.ts +1 -1
  65. package/types/functions/log-fetch.d.ts +1 -0
  66. package/lib/browser/server-entry-3e3279b7.cjs +0 -2
  67. package/lib/edge/form-c98c7fc1.cjs +0 -1
  68. package/lib/edge/server-entry-0224e0bb.cjs +0 -2
  69. package/lib/node/server-entry-0b1fe826.cjs +0 -2
@@ -1,77 +1,38 @@
1
- const b = "react", v = "[Builder.io]: ", f = {
2
- log: (...e) => console.log(v, ...e),
3
- error: (...e) => console.error(v, ...e),
4
- warn: (...e) => console.warn(v, ...e),
5
- debug: (...e) => console.debug(v, ...e)
6
- };
7
- function c() {
8
- return typeof window != "undefined" && typeof document != "undefined";
9
- }
10
- const te = (e) => {
1
+ const b = "react", re = (e) => {
11
2
  const t = {};
12
3
  return e.forEach((n, r) => {
13
4
  t[r] = n;
14
5
  }), t;
15
- }, L = (e) => e instanceof URLSearchParams ? te(e) : e, U = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
16
- function ne() {
6
+ }, V = (e) => e instanceof URLSearchParams ? re(e) : e, F = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
7
+ function c() {
8
+ return typeof window != "undefined" && typeof document != "undefined";
9
+ }
10
+ function oe() {
17
11
  return c() && window.self !== window.top;
18
12
  }
19
- function re(e) {
20
- return ne() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
21
- U(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
13
+ function se(e) {
14
+ return oe() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
15
+ F(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
22
16
  }
23
- const oe = () => {
24
- if (c()) {
25
- const e = new URL(location.href);
26
- return e.pathname === "" && (e.pathname = "/"), e;
27
- } else
28
- return console.warn("Cannot get location for tracking in non-browser environment"), null;
29
- }, se = () => typeof navigator == "object" && navigator.userAgent || "", ie = () => {
30
- const e = se(), t = {
31
- Android() {
32
- return e.match(/Android/i);
33
- },
34
- BlackBerry() {
35
- return e.match(/BlackBerry/i);
36
- },
37
- iOS() {
38
- return e.match(/iPhone|iPod/i);
39
- },
40
- Opera() {
41
- return e.match(/Opera Mini/i);
42
- },
43
- Windows() {
44
- return e.match(/IEMobile/i) || e.match(/WPDesktop/i);
45
- },
46
- any() {
47
- return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || b === "reactNative";
48
- }
49
- }, n = e.match(/Tablet|iPad/i), r = oe();
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" : t.any() ? "mobile" : "desktop"
54
- };
55
- }, m = (e) => e != null;
56
- function He(e) {
17
+ function Je(e) {
57
18
  const t = e || (c() ? window.location.search : void 0);
58
- return t ? U(t).indexOf("builder.preview=") !== -1 : !1;
19
+ return t ? F(t).indexOf("builder.preview=") !== -1 : !1;
59
20
  }
60
- const Xe = (e) => ({
21
+ const qe = (e) => ({
61
22
  type: "builder.registerComponent",
62
- data: V(e)
63
- }), ae = (e) => {
64
- const t = e.toString().trim();
65
- return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
23
+ data: M(e)
24
+ }), ie = (e) => {
25
+ const t = e.toString().trim(), n = /^[a-zA-Z0-9_]+\s*=>/i.test(t);
26
+ return `return (${!t.startsWith("function") && !t.startsWith("(") && !n ? "function " : ""}${t}).apply(this, arguments)`;
66
27
  };
67
- function V(e) {
68
- return JSON.parse(JSON.stringify(e, (t, n) => typeof n == "function" ? ae(n) : n));
28
+ function M(e) {
29
+ return JSON.parse(JSON.stringify(e, (t, n) => typeof n == "function" ? ie(n) : n));
69
30
  }
70
- const x = {};
71
- function ce(e, t) {
72
- e === "plugin" && (t = V(t));
73
- let n = x[e];
74
- if (n || (n = x[e] = []), n.push(t), c()) {
31
+ const T = {};
32
+ function ae(e, t) {
33
+ e === "plugin" && (t = M(t));
34
+ let n = T[e];
35
+ if (n || (n = T[e] = []), n.push(t), c()) {
75
36
  const r = {
76
37
  type: "builder.register",
77
38
  data: {
@@ -86,42 +47,47 @@ function ce(e, t) {
86
47
  }
87
48
  }
88
49
  }
89
- const A = {};
90
- function Je(e) {
50
+ const B = {};
51
+ function Qe(e) {
91
52
  if (c()) {
92
- Object.assign(A, e);
53
+ Object.assign(B, e);
93
54
  const t = {
94
55
  type: "builder.settingsChange",
95
- data: A
56
+ data: B
96
57
  };
97
58
  parent.postMessage(t, "*");
98
59
  }
99
60
  }
100
- const T = "builder.", ue = "options.", M = (e) => {
61
+ const R = "builder.", ce = "options.", N = (e) => {
101
62
  if (!e)
102
63
  return {};
103
- const t = L(e), n = {};
64
+ const t = V(e), n = {};
104
65
  return Object.keys(t).forEach((r) => {
105
- if (r.startsWith(T)) {
106
- const o = r.replace(T, "").replace(ue, "");
66
+ if (r.startsWith(R)) {
67
+ const o = r.replace(R, "").replace(ce, "");
107
68
  n[o] = t[r];
108
69
  }
109
70
  }), n;
110
- }, de = () => {
71
+ }, ue = () => {
111
72
  if (!c())
112
73
  return {};
113
74
  const e = new URLSearchParams(window.location.search);
114
- return M(e);
115
- }, N = "2.0.29", F = () => ({
75
+ return N(e);
76
+ }, I = "[Builder.io]: ", l = {
77
+ log: (...e) => console.log(I, ...e),
78
+ error: (...e) => console.error(I, ...e),
79
+ warn: (...e) => console.warn(I, ...e),
80
+ debug: (...e) => console.debug(I, ...e)
81
+ }, D = "2.0.31", K = () => ({
116
82
  "X-Builder-SDK": b,
117
83
  "X-Builder-SDK-GEN": "2",
118
- "X-Builder-SDK-Version": N
119
- }), le = (e) => {
84
+ "X-Builder-SDK-Version": D
85
+ }), m = (e) => e != null, de = (e) => {
120
86
  if (e === "localhost" || e === "127.0.0.1")
121
87
  return e;
122
88
  const t = e.split(".");
123
89
  return t.length > 2 ? t.slice(1).join(".") : e;
124
- }, D = ({
90
+ }, j = ({
125
91
  name: e,
126
92
  canTrack: t
127
93
  }) => {
@@ -129,17 +95,17 @@ const T = "builder.", ue = "options.", M = (e) => {
129
95
  try {
130
96
  return t ? (n = document.cookie.split("; ").find((r) => r.startsWith(`${e}=`))) == null ? void 0 : n.split("=")[1] : void 0;
131
97
  } catch (r) {
132
- f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
98
+ l.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
133
99
  return;
134
100
  }
135
- }, K = async (e) => D(e), fe = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), he = [["secure", ""], ["SameSite", "None"]], ge = ({
101
+ }, W = async (e) => j(e), le = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), fe = [["secure", ""], ["SameSite", "None"]], he = ({
136
102
  name: e,
137
103
  value: t,
138
104
  expires: n
139
105
  }) => {
140
- const o = (c() ? location.protocol === "https:" : !0) ? he : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], i = [[e, t], ...s, ["path", "/"], ["domain", le(window.location.hostname)], ...o];
141
- return fe(i);
142
- }, j = async ({
106
+ const o = (c() ? location.protocol === "https:" : !0) ? fe : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], i = [[e, t], ...s, ["path", "/"], ["domain", de(window.location.hostname)], ...o];
107
+ return le(i);
108
+ }, $ = async ({
143
109
  name: e,
144
110
  value: t,
145
111
  expires: n,
@@ -148,98 +114,135 @@ const T = "builder.", ue = "options.", M = (e) => {
148
114
  try {
149
115
  if (!r)
150
116
  return;
151
- const o = ge({
117
+ const o = he({
152
118
  name: e,
153
119
  value: t,
154
120
  expires: n
155
121
  });
156
122
  document.cookie = o;
157
123
  } catch (o) {
158
- f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
124
+ l.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
159
125
  }
160
126
  };
161
- function pe() {
127
+ function ge() {
162
128
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
163
129
  const t = Math.random() * 16 | 0;
164
130
  return (e == "x" ? t : t & 3 | 8).toString(16);
165
131
  });
166
132
  }
167
- function W() {
168
- return pe().replace(/-/g, "");
133
+ function G() {
134
+ return ge().replace(/-/g, "");
169
135
  }
170
- const $ = "builderSessionId", me = async ({
136
+ const _ = "builderSessionId", pe = async ({
171
137
  canTrack: e
172
138
  }) => {
173
139
  if (!e)
174
140
  return;
175
- const t = await K({
176
- name: $,
141
+ const t = await W({
142
+ name: _,
177
143
  canTrack: e
178
144
  });
179
145
  if (m(t))
180
146
  return t;
181
147
  {
182
- const n = ye();
183
- return Se({
148
+ const n = me();
149
+ return ye({
184
150
  id: n,
185
151
  canTrack: e
186
152
  }), n;
187
153
  }
188
- }, ye = () => W(), Se = ({
154
+ }, me = () => G(), ye = ({
189
155
  id: e,
190
156
  canTrack: t
191
- }) => j({
192
- name: $,
157
+ }) => $({
158
+ name: _,
193
159
  value: e,
194
160
  canTrack: t
195
- }), _ = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, we = ({
161
+ }), H = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, Se = ({
196
162
  key: e,
197
163
  canTrack: t
198
164
  }) => {
199
165
  var n;
200
166
  try {
201
- return t ? (n = _()) == null ? void 0 : n.getItem(e) : void 0;
167
+ return t ? (n = H()) == null ? void 0 : n.getItem(e) : void 0;
202
168
  } catch (r) {
203
169
  console.debug("[LocalStorage] GET error: ", r);
204
170
  return;
205
171
  }
206
- }, be = ({
172
+ }, we = ({
207
173
  key: e,
208
174
  canTrack: t,
209
175
  value: n
210
176
  }) => {
211
177
  var r;
212
178
  try {
213
- t && ((r = _()) == null || r.setItem(e, n));
179
+ t && ((r = H()) == null || r.setItem(e, n));
214
180
  } catch (o) {
215
181
  console.debug("[LocalStorage] SET error: ", o);
216
182
  }
217
- }, G = "builderVisitorId", ve = ({
183
+ }, X = "builderVisitorId", be = ({
218
184
  canTrack: e
219
185
  }) => {
220
186
  if (!e)
221
187
  return;
222
- const t = we({
223
- key: G,
188
+ const t = Se({
189
+ key: X,
224
190
  canTrack: e
225
191
  });
226
192
  if (m(t))
227
193
  return t;
228
194
  {
229
- const n = Ie();
230
- return ke({
195
+ const n = ve();
196
+ return Ie({
231
197
  id: n,
232
198
  canTrack: e
233
199
  }), n;
234
200
  }
235
- }, Ie = () => W(), ke = ({
201
+ }, ve = () => G(), Ie = ({
236
202
  id: e,
237
203
  canTrack: t
238
- }) => be({
239
- key: G,
204
+ }) => we({
205
+ key: X,
240
206
  value: e,
241
207
  canTrack: t
242
- }), Ee = async ({
208
+ });
209
+ function ke(e) {
210
+ var t;
211
+ typeof process != "undefined" && ((t = process.env) != null && t.DEBUG) && String(process.env.DEBUG) == "true" && l.log(e);
212
+ }
213
+ const Ee = () => {
214
+ if (c()) {
215
+ const e = new URL(location.href);
216
+ return e.pathname === "" && (e.pathname = "/"), e;
217
+ } else
218
+ return console.warn("Cannot get location for tracking in non-browser environment"), null;
219
+ }, Oe = () => typeof navigator == "object" && navigator.userAgent || "", Pe = () => {
220
+ const e = Oe(), t = {
221
+ Android() {
222
+ return e.match(/Android/i);
223
+ },
224
+ BlackBerry() {
225
+ return e.match(/BlackBerry/i);
226
+ },
227
+ iOS() {
228
+ return e.match(/iPhone|iPod/i);
229
+ },
230
+ Opera() {
231
+ return e.match(/Opera Mini/i);
232
+ },
233
+ Windows() {
234
+ return e.match(/IEMobile/i) || e.match(/WPDesktop/i);
235
+ },
236
+ any() {
237
+ return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || b === "reactNative";
238
+ }
239
+ }, n = e.match(/Tablet|iPad/i), r = Ee();
240
+ return {
241
+ urlPath: r == null ? void 0 : r.pathname,
242
+ host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
243
+ device: n ? "tablet" : t.any() ? "mobile" : "desktop"
244
+ };
245
+ }, Ce = async ({
243
246
  canTrack: e
244
247
  }) => {
245
248
  if (!e)
@@ -247,16 +250,16 @@ const $ = "builderSessionId", me = async ({
247
250
  visitorId: void 0,
248
251
  sessionId: void 0
249
252
  };
250
- const t = await me({
253
+ const t = await pe({
251
254
  canTrack: e
252
- }), n = ve({
255
+ }), n = be({
253
256
  canTrack: e
254
257
  });
255
258
  return {
256
259
  sessionId: t,
257
260
  visitorId: n
258
261
  };
259
- }, Oe = async ({
262
+ }, xe = async ({
260
263
  type: e,
261
264
  canTrack: t,
262
265
  apiKey: n,
@@ -270,47 +273,50 @@ const $ = "builderSessionId", me = async ({
270
273
  url: location.href,
271
274
  ...r
272
275
  },
273
- ...await Ee({
276
+ ...await Ce({
274
277
  canTrack: t
275
278
  }),
276
- userAttributes: ie(),
279
+ userAttributes: Pe(),
277
280
  ownerId: n
278
281
  }
279
282
  });
280
- async function Pe({
283
+ async function Ae({
281
284
  apiHost: e,
282
285
  ...t
283
286
  }) {
284
287
  if (!t.apiKey) {
285
- f.error("Missing API key for track call. Please provide your API key.");
288
+ l.error("Missing API key for track call. Please provide your API key.");
286
289
  return;
287
290
  }
288
- return !t.canTrack || re() || !(c() || b === "reactNative") ? void 0 : fetch(`${e || "https://cdn.builder.io"}/api/v1/track`, {
291
+ if (!t.canTrack || se() || !(c() || b === "reactNative"))
292
+ return;
293
+ const r = `${e || "https://cdn.builder.io"}/api/v1/track`;
294
+ return ke(r), fetch(r, {
289
295
  method: "POST",
290
296
  body: JSON.stringify({
291
- events: [await Oe(t)]
297
+ events: [await xe(t)]
292
298
  }),
293
299
  headers: {
294
300
  "content-type": "application/json",
295
- ...F()
301
+ ...K()
296
302
  },
297
303
  mode: "cors"
298
- }).catch((r) => {
299
- console.error("Failed to track: ", r);
304
+ }).catch((o) => {
305
+ console.error("Failed to track: ", o);
300
306
  });
301
307
  }
302
- const ze = (e) => Pe({
308
+ const Ye = (e) => Ae({
303
309
  ...e,
304
310
  canTrack: !0
305
- }), Ce = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
306
- function H(e, t) {
311
+ }), Te = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
312
+ function z(e, t) {
307
313
  if (!t.origin.startsWith("http") && !t.origin.startsWith("https"))
308
314
  return !1;
309
315
  const n = new URL(t.origin), r = n.hostname;
310
- return (e || Ce).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
316
+ return (e || Te).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
311
317
  }
312
- const qe = () => {
313
- ce("insertMenu", {
318
+ const Ze = () => {
319
+ ae("insertMenu", {
314
320
  name: "_default",
315
321
  default: !0,
316
322
  items: [{
@@ -332,14 +338,14 @@ const qe = () => {
332
338
  }]
333
339
  });
334
340
  };
335
- let R = !1;
336
- const xe = (e = {}) => {
341
+ let U = !1;
342
+ const Be = (e = {}) => {
337
343
  var t, n;
338
- R || (R = !0, c() && ((t = window.parent) == null || t.postMessage({
344
+ U || (U = !0, c() && ((t = window.parent) == null || t.postMessage({
339
345
  type: "builder.sdkInfo",
340
346
  data: {
341
347
  target: b,
342
- version: N,
348
+ version: D,
343
349
  supportsPatchUpdates: !1,
344
350
  // Supports builder-model="..." attribute which is needed to
345
351
  // scope our '+ add block' button styling
@@ -353,7 +359,7 @@ const xe = (e = {}) => {
353
359
  }
354
360
  }, "*"), window.addEventListener("message", (r) => {
355
361
  var s, i;
356
- if (!H(e.trustedHosts, r))
362
+ if (!z(e.trustedHosts, r))
357
363
  return;
358
364
  const {
359
365
  data: o
@@ -361,10 +367,10 @@ const xe = (e = {}) => {
361
367
  if (o != null && o.type)
362
368
  switch (o.type) {
363
369
  case "builder.evaluate": {
364
- const u = o.data.text, y = o.data.arguments || [], p = o.data.id, I = new Function(u);
370
+ const u = o.data.text, y = o.data.arguments || [], p = o.data.id, k = new Function(u);
365
371
  let d, h = null;
366
372
  try {
367
- d = I.apply(null, y);
373
+ d = k.apply(null, y);
368
374
  } catch (g) {
369
375
  h = g;
370
376
  }
@@ -394,12 +400,12 @@ const xe = (e = {}) => {
394
400
  }
395
401
  }
396
402
  })));
397
- }, Ae = ({
403
+ }, Re = ({
398
404
  model: e,
399
405
  trustedHosts: t,
400
406
  callbacks: n
401
407
  }) => (r) => {
402
- if (!H(t, r))
408
+ if (!z(t, r))
403
409
  return;
404
410
  const {
405
411
  data: o
@@ -420,12 +426,12 @@ const xe = (e = {}) => {
420
426
  break;
421
427
  }
422
428
  }
423
- }, Qe = (e, t, n) => {
429
+ }, et = (e, t, n) => {
424
430
  if (!c)
425
- return f.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
431
+ return l.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
426
432
  };
427
- xe();
428
- const r = Ae({
433
+ Be();
434
+ const r = Re({
429
435
  callbacks: {
430
436
  contentUpdate: t,
431
437
  animation: () => {
@@ -439,24 +445,24 @@ const xe = (e = {}) => {
439
445
  return window.addEventListener("message", r), () => {
440
446
  window.removeEventListener("message", r);
441
447
  };
442
- }, Te = "builder.tests", E = (e) => `${Te}.${e}`, Re = ({
448
+ }, Ue = "builder.tests", P = (e) => `${Ue}.${e}`, Le = ({
443
449
  contentId: e
444
- }) => K({
445
- name: E(e),
450
+ }) => W({
451
+ name: P(e),
446
452
  canTrack: !0
447
- }), Be = ({
453
+ }), Ve = ({
448
454
  contentId: e
449
- }) => D({
450
- name: E(e),
455
+ }) => j({
456
+ name: P(e),
451
457
  canTrack: !0
452
- }), Le = ({
458
+ }), Fe = ({
453
459
  contentId: e,
454
460
  value: t
455
- }) => j({
456
- name: E(e),
461
+ }) => $({
462
+ name: P(e),
457
463
  value: t,
458
464
  canTrack: !0
459
- }), X = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Ue = ({
465
+ }), J = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, Me = ({
460
466
  id: e,
461
467
  variations: t
462
468
  }) => {
@@ -469,15 +475,15 @@ const xe = (e = {}) => {
469
475
  return s;
470
476
  }
471
477
  return e;
472
- }, J = (e) => {
473
- const t = Ue(e);
474
- return Le({
478
+ }, q = (e) => {
479
+ const t = Me(e);
480
+ return Fe({
475
481
  contentId: e.id,
476
482
  value: t
477
483
  }).catch((n) => {
478
- f.error("could not store A/B test variation: ", n);
484
+ l.error("could not store A/B test variation: ", n);
479
485
  }), t;
480
- }, z = ({
486
+ }, Q = ({
481
487
  item: e,
482
488
  testGroupId: t
483
489
  }) => {
@@ -491,7 +497,7 @@ const xe = (e = {}) => {
491
497
  testVariationId: n.id,
492
498
  testVariationName: n.name || (n.id === e.id ? "Default" : "")
493
499
  };
494
- }, Ye = ({
500
+ }, tt = ({
495
501
  item: e,
496
502
  canTrack: t
497
503
  }) => {
@@ -499,14 +505,14 @@ const xe = (e = {}) => {
499
505
  return e;
500
506
  if (!e)
501
507
  return;
502
- if (!X(e))
508
+ if (!J(e))
503
509
  return e;
504
- const n = Be({
510
+ const n = Ve({
505
511
  contentId: e.id
506
- }) || J({
512
+ }) || q({
507
513
  variations: e.variations,
508
514
  id: e.id
509
- }), r = z({
515
+ }), r = Q({
510
516
  item: e,
511
517
  testGroupId: n
512
518
  });
@@ -514,18 +520,18 @@ const xe = (e = {}) => {
514
520
  ...e,
515
521
  ...r
516
522
  };
517
- }, Ve = async ({
523
+ }, Ne = async ({
518
524
  item: e,
519
525
  canTrack: t
520
526
  }) => {
521
- if (!t || !X(e))
527
+ if (!t || !J(e))
522
528
  return e;
523
- const r = await Re({
529
+ const r = await Le({
524
530
  contentId: e.id
525
- }) || J({
531
+ }) || q({
526
532
  variations: e.variations,
527
533
  id: e.id
528
- }), o = z({
534
+ }), o = Q({
529
535
  item: e,
530
536
  testGroupId: r
531
537
  });
@@ -533,38 +539,38 @@ const xe = (e = {}) => {
533
539
  ...e,
534
540
  ...o
535
541
  };
536
- }, Me = (e) => m(e) ? e : !0;
537
- function Ne() {
542
+ }, De = (e) => m(e) ? e : !0;
543
+ function Ke() {
538
544
  return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
539
545
  }
540
- function Fe() {
541
- const e = Ne().fetch;
546
+ function je() {
547
+ const e = Ke().fetch;
542
548
  if (typeof e == "undefined")
543
549
  throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
544
550
  For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
545
551
  return e;
546
552
  }
547
- const De = Fe();
548
- function k(e, t = null, n = ".") {
553
+ const We = je();
554
+ function O(e, t = null, n = ".") {
549
555
  return Object.keys(e).reduce((r, o) => {
550
556
  const s = e[o], i = [t, o].filter(Boolean).join(n);
551
557
  return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
552
558
  ...r,
553
- ...k(s, i, n)
559
+ ...O(s, i, n)
554
560
  } : {
555
561
  ...r,
556
562
  [i]: s
557
563
  };
558
564
  }, {});
559
565
  }
560
- function q(e, t, n = {}) {
566
+ function Y(e, t, n = {}) {
561
567
  for (const r in e) {
562
568
  const o = e[r], s = t ? t + "." + r : r;
563
- o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((i) => i.startsWith("$")) ? q(o, s, n) : n[s] = o;
569
+ o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((i) => i.startsWith("$")) ? Y(o, s, n) : n[s] = o;
564
570
  }
565
571
  return n;
566
572
  }
567
- const Ke = "v3", B = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e) => {
573
+ const $e = "v3", L = (e) => typeof e == "number" && !isNaN(e) && e >= 0, C = (e) => {
568
574
  const {
569
575
  limit: t = 30,
570
576
  userAttributes: n,
@@ -573,90 +579,96 @@ const Ke = "v3", B = (e) => typeof e == "number" && !isNaN(e) && e >= 0, O = (e)
573
579
  apiKey: s,
574
580
  enrich: i,
575
581
  locale: u,
576
- apiVersion: y = Ke,
582
+ apiVersion: y = $e,
577
583
  fields: p,
578
- omit: I,
584
+ omit: k,
579
585
  offset: d,
580
586
  cacheSeconds: h,
581
587
  staleCacheSeconds: g,
582
588
  sort: S,
583
- includeUnpublished: P,
584
- apiHost: Q
589
+ includeUnpublished: x,
590
+ apiHost: Z
585
591
  } = e;
586
592
  if (!s)
587
593
  throw new Error("Missing API key");
588
594
  if (!["v3"].includes(y))
589
595
  throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
590
- const Y = t !== 1, Z = Q || "https://cdn.builder.io", a = new URL(`${Z}/api/${y}/content/${o}`);
591
- if (a.searchParams.set("apiKey", s), a.searchParams.set("limit", String(t)), a.searchParams.set("noTraverse", String(Y)), a.searchParams.set("includeRefs", String(!0)), u && a.searchParams.set("locale", u), i && a.searchParams.set("enrich", String(i)), a.searchParams.set("omit", I || "meta.componentsUsed"), p && a.searchParams.set("fields", p), Number.isFinite(d) && d > -1 && a.searchParams.set("offset", String(Math.floor(d))), typeof P == "boolean" && a.searchParams.set("includeUnpublished", String(P)), h && B(h) && a.searchParams.set("cacheSeconds", String(h)), g && B(g) && a.searchParams.set("staleCacheSeconds", String(g)), S) {
592
- const l = k({
596
+ const ee = t !== 1, te = Z || "https://cdn.builder.io", a = new URL(`${te}/api/${y}/content/${o}`);
597
+ a.searchParams.set("apiKey", s), a.searchParams.set("limit", String(t)), a.searchParams.set("noTraverse", String(ee)), a.searchParams.set("includeRefs", String(!0));
598
+ const E = u || (n == null ? void 0 : n.locale);
599
+ let v = n;
600
+ if (E && (a.searchParams.set("locale", E), v = {
601
+ locale: E,
602
+ ...v
603
+ }), i && a.searchParams.set("enrich", String(i)), a.searchParams.set("omit", k || "meta.componentsUsed"), p && a.searchParams.set("fields", p), Number.isFinite(d) && d > -1 && a.searchParams.set("offset", String(Math.floor(d))), typeof x == "boolean" && a.searchParams.set("includeUnpublished", String(x)), h && L(h) && a.searchParams.set("cacheSeconds", String(h)), g && L(g) && a.searchParams.set("staleCacheSeconds", String(g)), S) {
604
+ const f = O({
593
605
  sort: S
594
606
  });
595
- for (const w in l)
596
- a.searchParams.set(w, JSON.stringify(l[w]));
607
+ for (const w in f)
608
+ a.searchParams.set(w, JSON.stringify(f[w]));
597
609
  }
598
- const ee = {
599
- ...de(),
600
- ...L(e.options || {})
601
- }, C = k(ee);
602
- for (const l in C)
603
- a.searchParams.set(l, String(C[l]));
604
- if (n && a.searchParams.set("userAttributes", JSON.stringify(n)), r) {
605
- const l = q({
610
+ const ne = {
611
+ ...ue(),
612
+ ...V(e.options || {})
613
+ }, A = O(ne);
614
+ for (const f in A)
615
+ a.searchParams.set(f, String(A[f]));
616
+ if (v && a.searchParams.set("userAttributes", JSON.stringify(v)), r) {
617
+ const f = Y({
606
618
  query: r
607
619
  });
608
- for (const w in l)
609
- a.searchParams.set(w, JSON.stringify(l[w]));
620
+ for (const w in f)
621
+ a.searchParams.set(w, JSON.stringify(f[w]));
610
622
  }
611
623
  return a;
612
- }, je = (e) => "results" in e;
613
- async function We(e) {
614
- const t = await Ge({
624
+ }, Ge = (e) => "results" in e;
625
+ async function _e(e) {
626
+ const t = await ze({
615
627
  ...e,
616
628
  limit: 1
617
629
  });
618
630
  return t && t[0] || null;
619
631
  }
620
- const $e = async (e) => {
632
+ const He = async (e) => {
621
633
  var i, u;
622
- const t = O(e), n = (i = e.fetch) != null ? i : De, r = {
634
+ const t = C(e), n = (i = e.fetch) != null ? i : We, r = {
623
635
  ...e.fetchOptions,
624
636
  headers: {
625
637
  ...(u = e.fetchOptions) == null ? void 0 : u.headers,
626
- ...F()
638
+ ...K()
627
639
  }
628
640
  };
629
641
  return await (await n(t.href, r)).json();
630
- }, _e = async (e, t, n = O(e)) => {
631
- const r = Me(e.canTrack);
642
+ }, Xe = async (e, t, n = C(e)) => {
643
+ const r = De(e.canTrack);
632
644
  if (n.search.includes("preview="), !r || !(c() || b === "reactNative"))
633
645
  return t.results;
634
646
  try {
635
647
  const o = [];
636
648
  for (const s of t.results)
637
- o.push(await Ve({
649
+ o.push(await Ne({
638
650
  item: s,
639
651
  canTrack: r
640
652
  }));
641
653
  t.results = o;
642
654
  } catch (o) {
643
- f.error("Could not process A/B tests. ", o);
655
+ l.error("Could not process A/B tests. ", o);
644
656
  }
645
657
  return t.results;
646
658
  };
647
- async function Ge(e) {
659
+ async function ze(e) {
648
660
  try {
649
- const t = O(e), n = await $e(e);
650
- return je(n) ? _e(e, n) : (f.error("Error fetching data. ", {
661
+ const t = C(e), n = await He(e);
662
+ return Ge(n) ? Xe(e, n) : (l.error("Error fetching data. ", {
651
663
  url: t,
652
664
  content: n,
653
665
  options: e
654
666
  }), null);
655
667
  } catch (t) {
656
- return f.error("Error fetching data. ", t), null;
668
+ return l.error("Error fetching data. ", t), null;
657
669
  }
658
670
  }
659
- const Ze = async (e) => {
671
+ const nt = async (e) => {
660
672
  var r, o, s;
661
673
  const t = e.path || ((r = e.url) == null ? void 0 : r.pathname) || ((o = e.userAttributes) == null ? void 0 : o.urlPath), n = {
662
674
  ...e,
@@ -668,38 +680,38 @@ const Ze = async (e) => {
668
680
  urlPath: t
669
681
  } : {}
670
682
  },
671
- options: M(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
683
+ options: N(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
672
684
  };
673
685
  return {
674
686
  apiKey: n.apiKey,
675
687
  model: n.model,
676
- content: await We(n)
688
+ content: await _e(n)
677
689
  };
678
690
  };
679
691
  export {
680
- v as MSG_PREFIX,
681
692
  b as TARGET,
682
- _e as _processContentResult,
683
- Pe as _track,
693
+ Xe as _processContentResult,
694
+ Ae as _track,
684
695
  m as checkIsDefined,
685
- Ae as createEditorListener,
686
- Xe as createRegisterComponentMessage,
687
- Ze as fetchBuilderProps,
688
- Ge as fetchEntries,
689
- We as fetchOneEntry,
690
- M as getBuilderSearchParams,
691
- Me as getDefaultCanTrack,
692
- ie as getUserAttributes,
693
- Ye as handleABTestingSync,
696
+ Re as createEditorListener,
697
+ qe as createRegisterComponentMessage,
698
+ nt as fetchBuilderProps,
699
+ ze as fetchEntries,
700
+ _e as fetchOneEntry,
701
+ N as getBuilderSearchParams,
702
+ De as getDefaultCanTrack,
703
+ Pe as getUserAttributes,
704
+ tt as handleABTestingSync,
694
705
  c as isBrowser,
695
- re as isEditing,
696
- He as isPreviewing,
697
- f as logger,
698
- ce as register,
699
- qe as registerInsertMenu,
700
- V as serializeIncludingFunctions,
701
- Je as setEditorSettings,
702
- xe as setupBrowserForEditing,
703
- Qe as subscribeToEditor,
704
- ze as track
706
+ se as isEditing,
707
+ Je as isPreviewing,
708
+ ke as logFetch,
709
+ l as logger,
710
+ ae as register,
711
+ Ze as registerInsertMenu,
712
+ M as serializeIncludingFunctions,
713
+ Qe as setEditorSettings,
714
+ Be as setupBrowserForEditing,
715
+ et as subscribeToEditor,
716
+ Ye as track
705
717
  };