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