@builder.io/sdk-react 3.0.5 → 3.0.7

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