@builder.io/sdk-react-nextjs 0.14.28 → 0.14.30-0

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 (118) hide show
  1. package/lib/browser/blocks-exports.cjs +188 -0
  2. package/lib/browser/blocks-exports.mjs +2812 -0
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +25 -26
  5. package/lib/browser/init.cjs +8 -0
  6. package/lib/browser/init.mjs +60 -0
  7. package/lib/browser/server-entry-5cac64f5.js +720 -0
  8. package/lib/browser/server-entry-c9d4cfc0.cjs +2 -0
  9. package/lib/browser/server-entry.cjs +1 -0
  10. package/lib/browser/server-entry.mjs +16 -0
  11. package/lib/edge/blocks-exports.cjs +208 -0
  12. package/lib/edge/{bundle-c67d25d8.js → blocks-exports.mjs} +2388 -2405
  13. package/lib/edge/index.cjs +1 -1
  14. package/lib/edge/index.mjs +25 -26
  15. package/lib/edge/init.cjs +8 -0
  16. package/lib/edge/init.mjs +60 -0
  17. package/lib/edge/server-entry-5cac64f5.js +720 -0
  18. package/lib/edge/server-entry-c9d4cfc0.cjs +2 -0
  19. package/lib/edge/server-entry.cjs +1 -0
  20. package/lib/edge/server-entry.mjs +16 -0
  21. package/lib/node/blocks-exports.cjs +188 -0
  22. package/lib/node/blocks-exports.mjs +2788 -0
  23. package/lib/node/index.cjs +1 -1
  24. package/lib/node/index.mjs +23 -23
  25. package/lib/node/init.cjs +1 -0
  26. package/lib/node/init.mjs +13 -0
  27. package/lib/node/node-runtime-591c4640.cjs +48 -0
  28. package/lib/node/node-runtime-8d503570.js +167 -0
  29. package/lib/node/server-entry-00baa89f.js +720 -0
  30. package/lib/node/server-entry-1c6e06e6.cjs +2 -0
  31. package/lib/node/server-entry.cjs +1 -0
  32. package/lib/node/server-entry.mjs +16 -0
  33. package/package.json +14 -9
  34. package/types/cjs/blocks/BaseText.d.ts +6 -0
  35. package/types/cjs/blocks/form/component-info.d.ts +2 -0
  36. package/types/cjs/blocks/form/form.d.ts +33 -0
  37. package/types/cjs/blocks/input/component-info.d.ts +2 -0
  38. package/types/cjs/blocks/input/input.d.ts +15 -0
  39. package/types/cjs/blocks/raw-text/component-info.d.ts +2 -0
  40. package/types/cjs/blocks/raw-text/index.d.ts +1 -0
  41. package/types/cjs/blocks/raw-text/raw-text.d.ts +7 -0
  42. package/types/cjs/blocks/submit-button/component-info.d.ts +2 -0
  43. package/types/cjs/blocks/submit-button/submit-button.d.ts +10 -0
  44. package/types/cjs/blocks/textarea/component-info.d.ts +2 -0
  45. package/types/cjs/blocks/textarea/index.d.ts +1 -0
  46. package/types/cjs/blocks/textarea/textarea.d.ts +13 -0
  47. package/types/cjs/components/content/index.d.ts +1 -0
  48. package/types/cjs/components/error-boundary.d.ts +11 -0
  49. package/types/cjs/constants/sdk-name.d.ts +1 -0
  50. package/types/cjs/constants/sdk-version.d.ts +1 -1
  51. package/types/cjs/functions/apply-patch-with-mutation.d.ts +10 -0
  52. package/types/cjs/functions/evaluate/edge-runtime/acorn-interpreter.d.ts +2 -0
  53. package/types/cjs/functions/evaluate/edge-runtime/edge-runtime.d.ts +2 -0
  54. package/types/cjs/functions/evaluate/edge-runtime/index.d.ts +1 -0
  55. package/types/cjs/functions/evaluate/node-runtime/index.d.ts +1 -0
  56. package/types/cjs/functions/evaluate/node-runtime/init.d.ts +13 -0
  57. package/types/cjs/functions/evaluate/node-runtime/node-runtime.d.ts +11 -0
  58. package/types/cjs/functions/evaluate/node-runtime/safeDynamicRequire.d.ts +8 -0
  59. package/types/cjs/functions/evaluate/placeholder-runtime.d.ts +2 -0
  60. package/types/cjs/functions/extract-css-var-default-value.d.ts +1 -0
  61. package/types/cjs/functions/get-react-native-block-styles.d.ts +15 -0
  62. package/types/cjs/functions/is-edge-runtime.d.ts +4 -0
  63. package/types/cjs/functions/on-change.d.ts +7 -0
  64. package/types/cjs/functions/sanitize-react-native-block-styles.d.ts +3 -0
  65. package/types/cjs/functions/sanitize-rn-allowed-css.d.ts +8 -0
  66. package/types/cjs/helpers/omit.d.ts +1 -0
  67. package/types/cjs/helpers/time.d.ts +1 -0
  68. package/types/esm/blocks/BaseText.d.ts +6 -0
  69. package/types/esm/blocks/form/component-info.d.ts +2 -0
  70. package/types/esm/blocks/form/form.d.ts +33 -0
  71. package/types/esm/blocks/input/component-info.d.ts +2 -0
  72. package/types/esm/blocks/input/input.d.ts +15 -0
  73. package/types/esm/blocks/raw-text/component-info.d.ts +2 -0
  74. package/types/esm/blocks/raw-text/index.d.ts +1 -0
  75. package/types/esm/blocks/raw-text/raw-text.d.ts +7 -0
  76. package/types/esm/blocks/submit-button/component-info.d.ts +2 -0
  77. package/types/esm/blocks/submit-button/submit-button.d.ts +10 -0
  78. package/types/esm/blocks/textarea/component-info.d.ts +2 -0
  79. package/types/esm/blocks/textarea/index.d.ts +1 -0
  80. package/types/esm/blocks/textarea/textarea.d.ts +13 -0
  81. package/types/esm/components/content/index.d.ts +1 -0
  82. package/types/esm/components/error-boundary.d.ts +11 -0
  83. package/types/esm/constants/sdk-name.d.ts +1 -0
  84. package/types/esm/constants/sdk-version.d.ts +1 -1
  85. package/types/esm/functions/apply-patch-with-mutation.d.ts +10 -0
  86. package/types/esm/functions/evaluate/edge-runtime/acorn-interpreter.d.ts +2 -0
  87. package/types/esm/functions/evaluate/edge-runtime/edge-runtime.d.ts +2 -0
  88. package/types/esm/functions/evaluate/edge-runtime/index.d.ts +1 -0
  89. package/types/esm/functions/evaluate/node-runtime/index.d.ts +1 -0
  90. package/types/esm/functions/evaluate/node-runtime/init.d.ts +13 -0
  91. package/types/esm/functions/evaluate/node-runtime/node-runtime.d.ts +11 -0
  92. package/types/esm/functions/evaluate/node-runtime/safeDynamicRequire.d.ts +8 -0
  93. package/types/esm/functions/evaluate/placeholder-runtime.d.ts +2 -0
  94. package/types/esm/functions/extract-css-var-default-value.d.ts +1 -0
  95. package/types/esm/functions/get-react-native-block-styles.d.ts +15 -0
  96. package/types/esm/functions/is-edge-runtime.d.ts +4 -0
  97. package/types/esm/functions/on-change.d.ts +7 -0
  98. package/types/esm/functions/sanitize-react-native-block-styles.d.ts +3 -0
  99. package/types/esm/functions/sanitize-rn-allowed-css.d.ts +8 -0
  100. package/types/esm/helpers/omit.d.ts +1 -0
  101. package/types/esm/helpers/time.d.ts +1 -0
  102. package/lib/browser/USE_CLIENT_BUNDLE-1c35fc0a.js +0 -703
  103. package/lib/browser/USE_CLIENT_BUNDLE-65950ed4.cjs +0 -21
  104. package/lib/browser/USE_SERVER_BUNDLE-3ea7f606.cjs +0 -1
  105. package/lib/browser/USE_SERVER_BUNDLE-812dfc95.js +0 -11
  106. package/lib/browser/bundle-763c7cf6.js +0 -2829
  107. package/lib/browser/bundle-aff841a2.cjs +0 -169
  108. package/lib/edge/USE_CLIENT_BUNDLE-cf0350f7.js +0 -703
  109. package/lib/edge/USE_CLIENT_BUNDLE-fc025b97.cjs +0 -21
  110. package/lib/edge/USE_SERVER_BUNDLE-8e198f44.cjs +0 -1
  111. package/lib/edge/USE_SERVER_BUNDLE-ded4dbdc.js +0 -11
  112. package/lib/edge/bundle-05000fd3.cjs +0 -189
  113. package/lib/node/USE_CLIENT_BUNDLE-0fda6fd8.js +0 -703
  114. package/lib/node/USE_CLIENT_BUNDLE-c57c9376.cjs +0 -21
  115. package/lib/node/USE_SERVER_BUNDLE-15a235fc.js +0 -11
  116. package/lib/node/USE_SERVER_BUNDLE-5472e997.cjs +0 -1
  117. package/lib/node/bundle-40b09581.js +0 -2950
  118. package/lib/node/bundle-acffe20a.cjs +0 -216
@@ -0,0 +1,720 @@
1
+ import { LRUCache as Q } from "lru-cache";
2
+ const v = "rsc", b = "[Builder.io]: ", l = {
3
+ log: (...e) => console.log(b, ...e),
4
+ error: (...e) => console.error(b, ...e),
5
+ warn: (...e) => console.warn(b, ...e),
6
+ debug: (...e) => console.debug(b, ...e)
7
+ };
8
+ function c() {
9
+ return typeof window != "undefined" && typeof document != "undefined";
10
+ }
11
+ const Y = (e) => {
12
+ const t = {};
13
+ return e.forEach((n, r) => {
14
+ t[r] = n;
15
+ }), t;
16
+ }, B = (e) => e instanceof URLSearchParams ? Y(e) : e, U = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString();
17
+ function Z() {
18
+ return c() && window.self !== window.top;
19
+ }
20
+ function ee(e) {
21
+ return Z() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
22
+ U(e || window.location.search).indexOf("builder.frameEditing=") !== -1;
23
+ }
24
+ const te = () => {
25
+ if (c()) {
26
+ const e = new URL(location.href);
27
+ return e.pathname === "" && (e.pathname = "/"), e;
28
+ } else
29
+ return console.warn("Cannot get location for tracking in non-browser environment"), null;
30
+ }, ne = () => typeof navigator == "object" && navigator.userAgent || "", re = () => {
31
+ const e = ne(), t = {
32
+ Android() {
33
+ return e.match(/Android/i);
34
+ },
35
+ BlackBerry() {
36
+ return e.match(/BlackBerry/i);
37
+ },
38
+ iOS() {
39
+ return e.match(/iPhone|iPod/i);
40
+ },
41
+ Opera() {
42
+ return e.match(/Opera Mini/i);
43
+ },
44
+ Windows() {
45
+ return e.match(/IEMobile/i) || e.match(/WPDesktop/i);
46
+ },
47
+ any() {
48
+ return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || v === "reactNative";
49
+ }
50
+ }, n = e.match(/Tablet|iPad/i), r = te();
51
+ return {
52
+ urlPath: r == null ? void 0 : r.pathname,
53
+ host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
54
+ device: n ? "tablet" : t.any() ? "mobile" : "desktop"
55
+ };
56
+ }, m = (e) => e != null, V = (e) => JSON.parse(JSON.stringify(e)), oe = (e) => {
57
+ if (e === "localhost" || e === "127.0.0.1")
58
+ return e;
59
+ const t = e.split(".");
60
+ return t.length > 2 ? t.slice(1).join(".") : e;
61
+ }, M = ({
62
+ name: e,
63
+ canTrack: t
64
+ }) => {
65
+ var n;
66
+ try {
67
+ return t ? (n = document.cookie.split("; ").find((r) => r.startsWith(`${e}=`))) == null ? void 0 : n.split("=")[1] : void 0;
68
+ } catch (r) {
69
+ l.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
70
+ return;
71
+ }
72
+ }, _ = async (e) => M(e), se = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(m).join("; "), ie = [["secure", ""], ["SameSite", "None"]], ae = ({
73
+ name: e,
74
+ value: t,
75
+ expires: n
76
+ }) => {
77
+ const o = (c() ? location.protocol === "https:" : !0) ? ie : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], i = [[e, t], ...s, ["path", "/"], ["domain", oe(window.location.hostname)], ...o];
78
+ return se(i);
79
+ }, N = async ({
80
+ name: e,
81
+ value: t,
82
+ expires: n,
83
+ canTrack: r
84
+ }) => {
85
+ try {
86
+ if (!r)
87
+ return;
88
+ const o = ae({
89
+ name: e,
90
+ value: t,
91
+ expires: n
92
+ });
93
+ document.cookie = o;
94
+ } catch (o) {
95
+ l.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
96
+ }
97
+ }, ce = "builder.tests", k = (e) => `${ce}.${e}`, ue = ({
98
+ contentId: e
99
+ }) => _({
100
+ name: k(e),
101
+ canTrack: !0
102
+ }), de = ({
103
+ contentId: e
104
+ }) => M({
105
+ name: k(e),
106
+ canTrack: !0
107
+ }), le = ({
108
+ contentId: e,
109
+ value: t
110
+ }) => N({
111
+ name: k(e),
112
+ value: t,
113
+ canTrack: !0
114
+ }), F = (e) => m(e.id) && m(e.variations) && Object.keys(e.variations).length > 0, fe = ({
115
+ id: e,
116
+ variations: t
117
+ }) => {
118
+ var o;
119
+ let n = 0;
120
+ const r = Math.random();
121
+ for (const s in t) {
122
+ const i = (o = t[s]) == null ? void 0 : o.testRatio;
123
+ if (n += i, r < n)
124
+ return s;
125
+ }
126
+ return e;
127
+ }, D = (e) => {
128
+ const t = fe(e);
129
+ return le({
130
+ contentId: e.id,
131
+ value: t
132
+ }).catch((n) => {
133
+ l.error("could not store A/B test variation: ", n);
134
+ }), t;
135
+ }, j = ({
136
+ item: e,
137
+ testGroupId: t
138
+ }) => {
139
+ const n = e.variations[t];
140
+ return t === e.id || // handle edge-case where `testGroupId` points to non-existing variation
141
+ !n ? {
142
+ testVariationId: e.id,
143
+ testVariationName: "Default"
144
+ } : {
145
+ data: n.data,
146
+ testVariationId: n.id,
147
+ testVariationName: n.name || (n.id === e.id ? "Default" : "")
148
+ };
149
+ }, qe = ({
150
+ item: e,
151
+ canTrack: t
152
+ }) => {
153
+ if (!t)
154
+ return e;
155
+ if (!e)
156
+ return;
157
+ if (!F(e))
158
+ return e;
159
+ const n = de({
160
+ contentId: e.id
161
+ }) || D({
162
+ variations: e.variations,
163
+ id: e.id
164
+ }), r = j({
165
+ item: e,
166
+ testGroupId: n
167
+ });
168
+ return {
169
+ ...e,
170
+ ...r
171
+ };
172
+ }, he = async ({
173
+ item: e,
174
+ canTrack: t
175
+ }) => {
176
+ if (!t || !F(e))
177
+ return e;
178
+ const r = await ue({
179
+ contentId: e.id
180
+ }) || D({
181
+ variations: e.variations,
182
+ id: e.id
183
+ }), o = j({
184
+ item: e,
185
+ testGroupId: r
186
+ });
187
+ return {
188
+ ...e,
189
+ ...o
190
+ };
191
+ }, ge = (e) => m(e) ? e : !0, Qe = (e) => ({
192
+ type: "builder.registerComponent",
193
+ data: ye(e)
194
+ }), pe = (e) => {
195
+ const t = e.toString().trim();
196
+ return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
197
+ }, me = (e) => typeof e == "function" ? pe(e) : V(e), ye = ({
198
+ inputs: e,
199
+ ...t
200
+ }) => ({
201
+ ...V(t),
202
+ inputs: e == null ? void 0 : e.map((n) => Object.entries(n).reduce((r, [o, s]) => ({
203
+ ...r,
204
+ [o]: me(s)
205
+ }), {}))
206
+ }), we = (e) => {
207
+ const t = e.get("preview"), n = e.get("overrides." + t);
208
+ return n || l.warn("No previewed ID found in search params."), n;
209
+ };
210
+ function Se() {
211
+ globalThis._BUILDER_PREVIEW_LRU_CACHE || (globalThis._BUILDER_PREVIEW_LRU_CACHE = new Q({
212
+ max: 500,
213
+ // how long to live in ms
214
+ ttl: 1e3 * 60 * 5
215
+ }));
216
+ }
217
+ function be(e) {
218
+ Se();
219
+ const t = we(e);
220
+ return typeof t == "string" ? globalThis._BUILDER_PREVIEW_LRU_CACHE.get(t) : void 0;
221
+ }
222
+ function ve() {
223
+ return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
224
+ }
225
+ function Ie() {
226
+ const e = ve().fetch;
227
+ if (typeof e == "undefined")
228
+ throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
229
+ For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
230
+ return e;
231
+ }
232
+ const Ee = Ie();
233
+ function E(e, t = null, n = ".") {
234
+ return Object.keys(e).reduce((r, o) => {
235
+ const s = e[o], i = [t, o].filter(Boolean).join(n);
236
+ return [typeof s == "object", s !== null, !(Array.isArray(s) && s.length === 0)].every(Boolean) ? {
237
+ ...r,
238
+ ...E(s, i, n)
239
+ } : {
240
+ ...r,
241
+ [i]: s
242
+ };
243
+ }, {});
244
+ }
245
+ function K(e, t, n = {}) {
246
+ for (const r in e) {
247
+ const o = e[r], s = t ? t + "." + r : r;
248
+ o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((i) => i.startsWith("$")) ? K(o, s, n) : n[s] = o;
249
+ }
250
+ return n;
251
+ }
252
+ const ke = "v3", R = "builder.", Ce = "options.", W = (e) => {
253
+ if (!e)
254
+ return {};
255
+ const t = B(e), n = {};
256
+ return Object.keys(t).forEach((r) => {
257
+ if (r.startsWith(R)) {
258
+ const o = r.replace(R, "").replace(Ce, "");
259
+ n[o] = t[r];
260
+ }
261
+ }), n;
262
+ }, Pe = () => {
263
+ if (!c())
264
+ return {};
265
+ const e = new URLSearchParams(window.location.search);
266
+ return W(e);
267
+ }, x = (e) => typeof e == "number" && !isNaN(e) && e >= 0, C = (e) => {
268
+ const {
269
+ limit: t = 30,
270
+ userAttributes: n,
271
+ query: r,
272
+ model: o,
273
+ apiKey: s,
274
+ enrich: i,
275
+ locale: u,
276
+ apiVersion: y = ke,
277
+ fields: p,
278
+ omit: I,
279
+ offset: d,
280
+ cacheSeconds: h,
281
+ staleCacheSeconds: g,
282
+ sort: w,
283
+ includeUnpublished: P
284
+ } = e;
285
+ if (!s)
286
+ throw new Error("Missing API key");
287
+ if (!["v3"].includes(y))
288
+ throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
289
+ const X = t !== 1, a = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
290
+ if (a.searchParams.set("apiKey", s), a.searchParams.set("limit", String(t)), a.searchParams.set("noTraverse", String(X)), a.searchParams.set("includeRefs", String(!0)), u && a.searchParams.set("locale", u), i && a.searchParams.set("enrich", String(i)), a.searchParams.set("omit", I || "meta.componentsUsed"), p && a.searchParams.set("fields", p), Number.isFinite(d) && d > -1 && a.searchParams.set("offset", String(Math.floor(d))), typeof P == "boolean" && a.searchParams.set("includeUnpublished", String(P)), h && x(h) && a.searchParams.set("cacheSeconds", String(h)), g && x(g) && a.searchParams.set("staleCacheSeconds", String(g)), w) {
291
+ const f = E({
292
+ sort: w
293
+ });
294
+ for (const S in f)
295
+ a.searchParams.set(S, JSON.stringify(f[S]));
296
+ }
297
+ const q = {
298
+ ...Pe(),
299
+ ...B(e.options || {})
300
+ }, O = E(q);
301
+ for (const f in O)
302
+ a.searchParams.set(f, String(O[f]));
303
+ if (n && a.searchParams.set("userAttributes", JSON.stringify(n)), r) {
304
+ const f = K({
305
+ query: r
306
+ });
307
+ for (const S in f)
308
+ a.searchParams.set(S, JSON.stringify(f[S]));
309
+ }
310
+ return a;
311
+ }, Oe = (e) => "results" in e;
312
+ async function Re(e) {
313
+ const t = await Te({
314
+ ...e,
315
+ limit: 1
316
+ });
317
+ return t && t[0] || null;
318
+ }
319
+ const xe = async (e) => {
320
+ var s;
321
+ const t = C(e);
322
+ return await (await ((s = e.fetch) != null ? s : Ee)(t.href, e.fetchOptions)).json();
323
+ }, Ae = async (e, t, n = C(e)) => {
324
+ const r = ge(e.canTrack);
325
+ if (n.search.includes("preview=")) {
326
+ const s = [];
327
+ for (const i of t.results) {
328
+ const u = be(n.searchParams);
329
+ s.push(u || i);
330
+ }
331
+ t.results = s;
332
+ }
333
+ if (!r || !(c() || v === "reactNative"))
334
+ return t.results;
335
+ try {
336
+ const s = [];
337
+ for (const i of t.results)
338
+ s.push(await he({
339
+ item: i,
340
+ canTrack: r
341
+ }));
342
+ t.results = s;
343
+ } catch (s) {
344
+ l.error("Could not process A/B tests. ", s);
345
+ }
346
+ return t.results;
347
+ };
348
+ async function Te(e) {
349
+ try {
350
+ const t = C(e), n = await xe(e);
351
+ return Oe(n) ? Ae(e, n) : (l.error("Error fetching data. ", {
352
+ url: t,
353
+ content: n,
354
+ options: e
355
+ }), null);
356
+ } catch (t) {
357
+ return l.error("Error fetching data. ", t), null;
358
+ }
359
+ }
360
+ function Ye(e) {
361
+ const t = e || (c() ? window.location.search : void 0);
362
+ return t ? U(t).indexOf("builder.preview=") !== -1 : !1;
363
+ }
364
+ function Le() {
365
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
366
+ const t = Math.random() * 16 | 0;
367
+ return (e == "x" ? t : t & 3 | 8).toString(16);
368
+ });
369
+ }
370
+ function $() {
371
+ return Le().replace(/-/g, "");
372
+ }
373
+ const G = "builderSessionId", Be = async ({
374
+ canTrack: e
375
+ }) => {
376
+ if (!e)
377
+ return;
378
+ const t = await _({
379
+ name: G,
380
+ canTrack: e
381
+ });
382
+ if (m(t))
383
+ return t;
384
+ {
385
+ const n = Ue();
386
+ return Ve({
387
+ id: n,
388
+ canTrack: e
389
+ }), n;
390
+ }
391
+ }, Ue = () => $(), Ve = ({
392
+ id: e,
393
+ canTrack: t
394
+ }) => N({
395
+ name: G,
396
+ value: e,
397
+ canTrack: t
398
+ }), H = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, Me = ({
399
+ key: e,
400
+ canTrack: t
401
+ }) => {
402
+ var n;
403
+ try {
404
+ return t ? (n = H()) == null ? void 0 : n.getItem(e) : void 0;
405
+ } catch (r) {
406
+ console.debug("[LocalStorage] GET error: ", r);
407
+ return;
408
+ }
409
+ }, _e = ({
410
+ key: e,
411
+ canTrack: t,
412
+ value: n
413
+ }) => {
414
+ var r;
415
+ try {
416
+ t && ((r = H()) == null || r.setItem(e, n));
417
+ } catch (o) {
418
+ console.debug("[LocalStorage] SET error: ", o);
419
+ }
420
+ }, z = "builderVisitorId", Ne = ({
421
+ canTrack: e
422
+ }) => {
423
+ if (!e)
424
+ return;
425
+ const t = Me({
426
+ key: z,
427
+ canTrack: e
428
+ });
429
+ if (m(t))
430
+ return t;
431
+ {
432
+ const n = Fe();
433
+ return De({
434
+ id: n,
435
+ canTrack: e
436
+ }), n;
437
+ }
438
+ }, Fe = () => $(), De = ({
439
+ id: e,
440
+ canTrack: t
441
+ }) => _e({
442
+ key: z,
443
+ value: e,
444
+ canTrack: t
445
+ }), je = async ({
446
+ canTrack: e
447
+ }) => {
448
+ if (!e)
449
+ return {
450
+ visitorId: void 0,
451
+ sessionId: void 0
452
+ };
453
+ const t = await Be({
454
+ canTrack: e
455
+ }), n = Ne({
456
+ canTrack: e
457
+ });
458
+ return {
459
+ sessionId: t,
460
+ visitorId: n
461
+ };
462
+ }, Ke = async ({
463
+ type: e,
464
+ canTrack: t,
465
+ apiKey: n,
466
+ metadata: r,
467
+ ...o
468
+ }) => ({
469
+ type: e,
470
+ data: {
471
+ ...o,
472
+ metadata: {
473
+ url: location.href,
474
+ ...r
475
+ },
476
+ ...await je({
477
+ canTrack: t
478
+ }),
479
+ userAttributes: re(),
480
+ ownerId: n
481
+ }
482
+ });
483
+ async function We(e) {
484
+ if (!e.apiKey) {
485
+ l.error("Missing API key for track call. Please provide your API key.");
486
+ return;
487
+ }
488
+ if (e.canTrack && !ee() && (c() || v === "reactNative"))
489
+ return fetch("https://cdn.builder.io/api/v1/track", {
490
+ method: "POST",
491
+ body: JSON.stringify({
492
+ events: [await Ke(e)]
493
+ }),
494
+ headers: {
495
+ "content-type": "application/json"
496
+ },
497
+ mode: "cors"
498
+ }).catch((t) => {
499
+ console.error("Failed to track: ", t);
500
+ });
501
+ }
502
+ const Ze = (e) => We({
503
+ ...e,
504
+ canTrack: !0
505
+ }), $e = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
506
+ function J(e, t) {
507
+ if (!t.origin.startsWith("http") && !t.origin.startsWith("https"))
508
+ return !1;
509
+ const n = new URL(t.origin), r = n.hostname;
510
+ return (e || $e).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
511
+ }
512
+ const Ge = "0.14.30-0", A = {};
513
+ function He(e, t) {
514
+ let n = A[e];
515
+ if (n || (n = A[e] = []), n.push(t), c()) {
516
+ const r = {
517
+ type: "builder.register",
518
+ data: {
519
+ type: e,
520
+ info: t
521
+ }
522
+ };
523
+ try {
524
+ parent.postMessage(r, "*"), parent !== window && window.postMessage(r, "*");
525
+ } catch (o) {
526
+ console.debug("Could not postmessage", o);
527
+ }
528
+ }
529
+ }
530
+ const et = () => {
531
+ He("insertMenu", {
532
+ name: "_default",
533
+ default: !0,
534
+ items: [{
535
+ name: "Box"
536
+ }, {
537
+ name: "Text"
538
+ }, {
539
+ name: "Image"
540
+ }, {
541
+ name: "Columns"
542
+ }, {
543
+ name: "Core:Section"
544
+ }, {
545
+ name: "Core:Button"
546
+ }, {
547
+ name: "Embed"
548
+ }, {
549
+ name: "Custom Code"
550
+ }]
551
+ });
552
+ };
553
+ let T = !1;
554
+ const ze = (e = {}) => {
555
+ var t, n;
556
+ T || (T = !0, c() && ((t = window.parent) == null || t.postMessage({
557
+ type: "builder.sdkInfo",
558
+ data: {
559
+ target: v,
560
+ version: Ge,
561
+ supportsPatchUpdates: !1,
562
+ // Supports builder-model="..." attribute which is needed to
563
+ // scope our '+ add block' button styling
564
+ supportsAddBlockScoping: !0,
565
+ supportsCustomBreakpoints: !0
566
+ }
567
+ }, "*"), (n = window.parent) == null || n.postMessage({
568
+ type: "builder.updateContent",
569
+ data: {
570
+ options: e
571
+ }
572
+ }, "*"), window.addEventListener("message", (r) => {
573
+ var s, i;
574
+ if (!J(e.trustedHosts, r))
575
+ return;
576
+ const {
577
+ data: o
578
+ } = r;
579
+ if (o != null && o.type)
580
+ switch (o.type) {
581
+ case "builder.evaluate": {
582
+ const u = o.data.text, y = o.data.arguments || [], p = o.data.id, I = new Function(u);
583
+ let d, h = null;
584
+ try {
585
+ d = I.apply(null, y);
586
+ } catch (g) {
587
+ h = g;
588
+ }
589
+ h ? (s = window.parent) == null || s.postMessage({
590
+ type: "builder.evaluateError",
591
+ data: {
592
+ id: p,
593
+ error: h.message
594
+ }
595
+ }, "*") : d && typeof d.then == "function" ? d.then((g) => {
596
+ var w;
597
+ (w = window.parent) == null || w.postMessage({
598
+ type: "builder.evaluateResult",
599
+ data: {
600
+ id: p,
601
+ result: g
602
+ }
603
+ }, "*");
604
+ }).catch(console.error) : (i = window.parent) == null || i.postMessage({
605
+ type: "builder.evaluateResult",
606
+ data: {
607
+ result: d,
608
+ id: p
609
+ }
610
+ }, "*");
611
+ break;
612
+ }
613
+ }
614
+ })));
615
+ }, Je = ({
616
+ model: e,
617
+ trustedHosts: t,
618
+ callbacks: n
619
+ }) => (r) => {
620
+ if (!J(t, r))
621
+ return;
622
+ const {
623
+ data: o
624
+ } = r;
625
+ if (o)
626
+ switch (o.type) {
627
+ case "builder.configureSdk": {
628
+ n.configureSdk(o.data);
629
+ break;
630
+ }
631
+ case "builder.triggerAnimation": {
632
+ n.animation(o.data);
633
+ break;
634
+ }
635
+ case "builder.contentUpdate": {
636
+ const s = o.data, i = s.key || s.alias || s.entry || s.modelName, u = s.data;
637
+ i === e && n.contentUpdate(u);
638
+ break;
639
+ }
640
+ }
641
+ }, tt = (e, t, n) => {
642
+ if (!c)
643
+ return l.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => {
644
+ };
645
+ ze();
646
+ const r = Je({
647
+ callbacks: {
648
+ contentUpdate: t,
649
+ animation: () => {
650
+ },
651
+ configureSdk: () => {
652
+ }
653
+ },
654
+ model: e,
655
+ trustedHosts: n == null ? void 0 : n.trustedHosts
656
+ });
657
+ return window.addEventListener("message", r), () => {
658
+ window.removeEventListener("message", r);
659
+ };
660
+ }, L = {};
661
+ function nt(e) {
662
+ if (c()) {
663
+ Object.assign(L, e);
664
+ const t = {
665
+ type: "builder.settingsChange",
666
+ data: L
667
+ };
668
+ parent.postMessage(t, "*");
669
+ }
670
+ }
671
+ const rt = async (e) => {
672
+ var r, o, s;
673
+ const t = e.path || ((r = e.url) == null ? void 0 : r.pathname) || ((o = e.userAttributes) == null ? void 0 : o.urlPath), n = {
674
+ ...e,
675
+ apiKey: e.apiKey,
676
+ model: e.model || "page",
677
+ userAttributes: {
678
+ ...e.userAttributes,
679
+ ...t ? {
680
+ urlPath: t
681
+ } : {}
682
+ },
683
+ options: W(e.searchParams || ((s = e.url) == null ? void 0 : s.searchParams) || e.options)
684
+ };
685
+ return {
686
+ apiKey: n.apiKey,
687
+ model: n.model,
688
+ content: await Re(n)
689
+ };
690
+ };
691
+ export {
692
+ b as MSG_PREFIX,
693
+ v as TARGET,
694
+ Ae as _processContentResult,
695
+ We as _track,
696
+ m as checkIsDefined,
697
+ Je as createEditorListener,
698
+ Qe as createRegisterComponentMessage,
699
+ V as fastClone,
700
+ Ee as fetch,
701
+ rt as fetchBuilderProps,
702
+ Te as fetchEntries,
703
+ Re as fetchOneEntry,
704
+ W as getBuilderSearchParams,
705
+ ge as getDefaultCanTrack,
706
+ re as getUserAttributes,
707
+ qe as handleABTestingSync,
708
+ Se as init,
709
+ c as isBrowser,
710
+ ee as isEditing,
711
+ Ye as isPreviewing,
712
+ l as logger,
713
+ He as register,
714
+ et as registerInsertMenu,
715
+ ye as serializeComponentInfo,
716
+ nt as setEditorSettings,
717
+ ze as setupBrowserForEditing,
718
+ tt as subscribeToEditor,
719
+ Ze as track
720
+ };