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