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