@builder.io/sdk-react-nextjs 0.7.1-0 → 0.7.1-2

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 (35) hide show
  1. package/lib/browser/{USE_CLIENT_BUNDLE-9195e6a5.js → USE_CLIENT_BUNDLE-11d41596.js} +1 -1
  2. package/lib/browser/{USE_CLIENT_BUNDLE-7a3bf41a.mjs → USE_CLIENT_BUNDLE-48d9356f.mjs} +2 -2
  3. package/lib/{edge/USE_SERVER_BUNDLE-f184d7eb.mjs → browser/USE_SERVER_BUNDLE-3875256b.mjs} +1 -1
  4. package/lib/{edge/USE_SERVER_BUNDLE-3f12faf4.js → browser/USE_SERVER_BUNDLE-568694d9.js} +1 -1
  5. package/lib/browser/bundle-05622db1.js +76 -0
  6. package/lib/browser/{bundle-7285a09d.mjs → bundle-242ae8b5.mjs} +522 -502
  7. package/lib/browser/index.cjs +1 -1
  8. package/lib/browser/index.mjs +3 -3
  9. package/lib/edge/{USE_CLIENT_BUNDLE-4a0cfa69.mjs → USE_CLIENT_BUNDLE-6eb1ee54.mjs} +2 -2
  10. package/lib/edge/{USE_CLIENT_BUNDLE-3cca560e.js → USE_CLIENT_BUNDLE-bba76732.js} +1 -1
  11. package/lib/{node/USE_SERVER_BUNDLE-cd844269.js → edge/USE_SERVER_BUNDLE-305bf94a.js} +1 -1
  12. package/lib/{node/USE_SERVER_BUNDLE-22e86776.mjs → edge/USE_SERVER_BUNDLE-66d4b8c4.mjs} +1 -1
  13. package/lib/edge/bundle-1b9b93c7.js +96 -0
  14. package/lib/edge/{bundle-a5949d33.mjs → bundle-3d31ba5d.mjs} +1936 -1888
  15. package/lib/edge/index.cjs +1 -1
  16. package/lib/edge/index.mjs +3 -3
  17. package/lib/node/USE_CLIENT_BUNDLE-8147b412.js +23 -0
  18. package/lib/node/USE_CLIENT_BUNDLE-e041d92c.mjs +657 -0
  19. package/lib/{browser/USE_SERVER_BUNDLE-e5c2279a.mjs → node/USE_SERVER_BUNDLE-1634816a.mjs} +1 -1
  20. package/lib/{browser/USE_SERVER_BUNDLE-d7b13097.js → node/USE_SERVER_BUNDLE-8c1ae1f0.js} +1 -1
  21. package/lib/node/bundle-4203318d.js +116 -0
  22. package/lib/node/{bundle-0358b224.mjs → bundle-7ebcd79e.mjs} +783 -640
  23. package/lib/node/index.cjs +1 -1
  24. package/lib/node/index.mjs +22 -23
  25. package/package.json +1 -2
  26. package/types/constants/sdk-version.d.ts +1 -1
  27. package/types/functions/evaluate/choose-eval.d.ts +6 -0
  28. package/types/functions/evaluate/evaluate.d.ts +1 -5
  29. package/types/functions/evaluate/helpers.d.ts +7 -1
  30. package/types/functions/get-content/types.d.ts +94 -3
  31. package/lib/browser/bundle-620ae296.js +0 -76
  32. package/lib/edge/bundle-a0f5cad2.js +0 -96
  33. package/lib/node/USE_CLIENT_BUNDLE-63c7fe77.js +0 -61
  34. package/lib/node/USE_CLIENT_BUNDLE-d9e90ed7.mjs +0 -747
  35. package/lib/node/bundle-630ffe6d.js +0 -76
@@ -1,10 +1,9 @@
1
- import "isolated-vm";
2
- import { LRUCache as Re } from "lru-cache";
3
- import { jsx as l, Fragment as x, jsxs as w } from "react/jsx-runtime";
4
- import { createElement as Ee } from "react";
5
- import { e as Ae, I as Ve, B as q, a as $e, b as Be, C as Pe, E as Fe, F as Oe, c as We, d as Ne, S as Le, V as Me, f as Ue } from "./USE_CLIENT_BUNDLE-d9e90ed7.mjs";
1
+ import { LRUCache } from "lru-cache";
2
+ import { jsx, Fragment, jsxs } from "react/jsx-runtime";
3
+ import { createElement } from "react";
4
+ import { I as InteractiveElement, B as BlockWrapper, a as BlocksWrapper, b as Button, C as CustomCode, E as Embed, F as FragmentComponent, c as Image, d as ImgComponent, S as SectionComponent, V as Video, e as EnableEditor } from "./USE_CLIENT_BUNDLE-e041d92c.mjs";
6
5
  import "next/navigation";
7
- const A = (e) => JSON.parse(JSON.stringify(e)), ae = {
6
+ const fastClone = (e) => JSON.parse(JSON.stringify(e)), SIZES = {
8
7
  small: {
9
8
  min: 320,
10
9
  default: 321,
@@ -20,11 +19,11 @@ const A = (e) => JSON.parse(JSON.stringify(e)), ae = {
20
19
  default: 991,
21
20
  max: 1200
22
21
  }
23
- }, G = (e, t = ae) => `@media (max-width: ${t[e].max}px)`, se = ({
22
+ }, getMaxWidthQueryForSize = (e, t = SIZES) => `@media (max-width: ${t[e].max}px)`, getSizesForBreakpoints = ({
24
23
  small: e,
25
24
  medium: t
26
25
  }) => {
27
- const n = A(ae);
26
+ const n = fastClone(SIZES);
28
27
  if (!e || !t)
29
28
  return n;
30
29
  const o = Math.floor(e / 2);
@@ -33,42 +32,42 @@ const A = (e) => JSON.parse(JSON.stringify(e)), ae = {
33
32
  min: o,
34
33
  default: o + 1
35
34
  };
36
- const i = n.small.max + 1;
35
+ const r = n.small.max + 1;
37
36
  n.medium = {
38
37
  max: t,
39
- min: i,
40
- default: i + 1
38
+ min: r,
39
+ default: r + 1
41
40
  };
42
- const r = n.medium.max + 1;
41
+ const i = n.medium.max + 1;
43
42
  return n.large = {
44
43
  max: 2e3,
45
44
  // TODO: decide upper limit
46
- min: r,
47
- default: r + 1
45
+ min: i,
46
+ default: i + 1
48
47
  }, n;
49
- }, I = "rsc", T = "[Builder.io]: ", k = {
50
- log: (...e) => console.log(T, ...e),
51
- error: (...e) => console.error(T, ...e),
52
- warn: (...e) => console.warn(T, ...e),
53
- debug: (...e) => console.debug(T, ...e)
48
+ }, TARGET = "rsc", MSG_PREFIX = "[Builder.io]: ", logger = {
49
+ log: (...e) => console.log(MSG_PREFIX, ...e),
50
+ error: (...e) => console.error(MSG_PREFIX, ...e),
51
+ warn: (...e) => console.warn(MSG_PREFIX, ...e),
52
+ debug: (...e) => console.debug(MSG_PREFIX, ...e)
54
53
  };
55
- function v() {
54
+ function isBrowser() {
56
55
  return typeof window < "u" && typeof document < "u";
57
56
  }
58
- function _e() {
59
- return v() && window.self !== window.top;
57
+ function isIframe() {
58
+ return isBrowser() && window.self !== window.top;
60
59
  }
61
- function L() {
62
- return _e() && window.location.search.indexOf("builder.frameEditing=") !== -1;
60
+ function isEditing() {
61
+ return isIframe() && window.location.search.indexOf("builder.frameEditing=") !== -1;
63
62
  }
64
- const je = () => {
65
- if (v()) {
63
+ const getLocation = () => {
64
+ if (isBrowser()) {
66
65
  const e = new URL(location.href);
67
66
  return e.pathname === "" && (e.pathname = "/"), e;
68
67
  } else
69
68
  return console.warn("Cannot get location for tracking in non-browser environment"), null;
70
- }, Ke = () => typeof navigator == "object" && navigator.userAgent || "", ce = () => {
71
- const e = Ke(), t = {
69
+ }, getUserAgent = () => typeof navigator == "object" && navigator.userAgent || "", getUserAttributes = () => {
70
+ const e = getUserAgent(), t = {
72
71
  Android() {
73
72
  return e.match(/Android/i);
74
73
  },
@@ -85,15 +84,15 @@ const je = () => {
85
84
  return e.match(/IEMobile/i) || e.match(/WPDesktop/i);
86
85
  },
87
86
  any() {
88
- return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || I === "reactNative";
87
+ return t.Android() || t.BlackBerry() || t.iOS() || t.Opera() || t.Windows() || TARGET === "reactNative";
89
88
  }
90
- }, n = e.match(/Tablet|iPad/i), o = je();
89
+ }, n = e.match(/Tablet|iPad/i), o = getLocation();
91
90
  return {
92
91
  urlPath: o == null ? void 0 : o.pathname,
93
92
  host: (o == null ? void 0 : o.host) || (o == null ? void 0 : o.hostname),
94
93
  device: n ? "tablet" : t.any() ? "mobile" : "desktop"
95
94
  };
96
- }, Fn = ({
95
+ }, getFunctionArguments = ({
97
96
  builder: e,
98
97
  context: t,
99
98
  event: n,
@@ -105,118 +104,248 @@ const je = () => {
105
104
  builder: e,
106
105
  context: t,
107
106
  event: n
108
- });
109
- function M({
107
+ }), getBuilderGlobals = () => ({
108
+ isEditing: isEditing(),
109
+ isBrowser: isBrowser(),
110
+ isServer: !isBrowser(),
111
+ getUserAttributes: () => getUserAttributes()
112
+ }), parseCode = (e, {
113
+ isExpression: t = !0
114
+ }) => /* we disable this for cases where we definitely don't want a return */ t && !(e.includes(";") || e.includes(" return ") || e.trim().startsWith("return ")) ? `return (${e});` : e, runInBrowser = ({
115
+ code: e,
116
+ builder: t,
117
+ context: n,
118
+ event: o,
119
+ localState: r,
120
+ rootSetState: i,
121
+ rootState: a
122
+ }) => {
123
+ const c = getFunctionArguments({
124
+ builder: t,
125
+ context: n,
126
+ event: o,
127
+ state: flattenState(a, r, i)
128
+ });
129
+ return new Function(...c.map(([s]) => s), e)(...c.map(([, s]) => s));
130
+ };
131
+ function flattenState(e, t, n) {
132
+ if (e === t)
133
+ throw new Error("rootState === localState");
134
+ return new Proxy(e, {
135
+ get: (o, r) => t && r in t ? t[r] : e[r],
136
+ set: (o, r, i) => {
137
+ if (t && r in t)
138
+ throw new Error("Writing to local state is not allowed as it is read-only.");
139
+ return e[r] = i, n == null || n(e), !0;
140
+ }
141
+ });
142
+ }
143
+ const noop = () => null;
144
+ let safeDynamicRequire = noop;
145
+ try {
146
+ safeDynamicRequire = eval("require");
147
+ } catch (e) {
148
+ }
149
+ const set = (e, t, n) => {
150
+ if (Object(e) !== e)
151
+ return e;
152
+ const o = Array.isArray(t) ? t : t.toString().match(/[^.[\]]+/g);
153
+ return o.slice(0, -1).reduce((r, i, a) => Object(r[i]) === r[i] ? r[i] : r[i] = Math.abs(Number(o[a + 1])) >> 0 === +o[a + 1] ? [] : {}, e)[o[o.length - 1]] = n, e;
154
+ }, ivm = safeDynamicRequire("isolated-vm"), getSyncValName = (e) => `bldr_${e}_sync`, BUILDER_SET_STATE_NAME = "BUILDER_SET_STATE", INJECTED_IVM_GLOBAL = "BUILDER_IVM", REF_TO_PROXY_FN = `
155
+ var refToProxy = (obj) => {
156
+ if (typeof obj !== 'object' || obj === null) {
157
+ return obj;
158
+ }
159
+ return new Proxy({}, {
160
+ get(target, key) {
161
+ if (key === 'copySync') {
162
+ return () => obj.copySync();
163
+ }
164
+ const val = obj.getSync(key);
165
+ if (typeof val?.getSync === 'function') {
166
+ return refToProxy(val);
167
+ }
168
+ return val;
169
+ },
170
+ set(target, key, value) {
171
+ const v = typeof value === 'object' ? new ${INJECTED_IVM_GLOBAL}.Reference(value) : value;
172
+ obj.setSync(key, v);
173
+ ${BUILDER_SET_STATE_NAME}(key, value)
174
+ },
175
+ deleteProperty(target, key) {
176
+ obj.deleteSync(key);
177
+ }
178
+ })
179
+ }
180
+ `, processCode = ({
181
+ code: e,
182
+ args: t
183
+ }) => {
184
+ const n = t.map(([o]) => `var ${o} = refToProxy(${getSyncValName(o)}); `).join("");
185
+ return `
186
+ ${REF_TO_PROXY_FN}
187
+ ${n}
188
+ function theFunction() {
189
+ ${e}
190
+ }
191
+
192
+ let output = theFunction()
193
+
194
+ if (typeof output === 'object' && output !== null) {
195
+ output = JSON.stringify(output.copySync ? output.copySync() : output);
196
+ }
197
+
198
+ output;
199
+ `;
200
+ }, getIsolateContext = () => new ivm.Isolate({
201
+ memoryLimit: 128
202
+ }).createContextSync(), runInNode = ({
203
+ code: e,
204
+ builder: t,
205
+ context: n,
206
+ event: o,
207
+ localState: r,
208
+ rootSetState: i,
209
+ rootState: a
210
+ }) => {
211
+ const c = fastClone({
212
+ ...a,
213
+ ...r
214
+ }), s = getFunctionArguments({
215
+ builder: t,
216
+ context: n,
217
+ event: o,
218
+ state: c
219
+ }), u = getIsolateContext(), m = u.global;
220
+ m.setSync("global", m.derefInto()), m.setSync("log", function(...l) {
221
+ console.log(...l);
222
+ }), m.setSync(BUILDER_SET_STATE_NAME, function(l, f) {
223
+ set(a, l, f), i == null || i(a);
224
+ }), s.forEach(([l, f]) => {
225
+ const d = typeof f == "object" ? new ivm.Reference(
226
+ // workaround: methods with default values for arguments is not being cloned over
227
+ l === "builder" ? {
228
+ ...f,
229
+ getUserAttributes: () => f.getUserAttributes()
230
+ } : f
231
+ ) : null;
232
+ m.setSync(getSyncValName(l), d);
233
+ }), m.setSync(INJECTED_IVM_GLOBAL, ivm);
234
+ const h = processCode({
235
+ code: e,
236
+ args: s
237
+ }), p = u.evalSync(h);
238
+ try {
239
+ return JSON.parse(p);
240
+ } catch {
241
+ return p;
242
+ }
243
+ }, chooseBrowserOrServerEval = (e) => isBrowser() ? runInBrowser(e) : runInNode(e);
244
+ function evaluate({
110
245
  code: e,
111
246
  context: t,
112
247
  localState: n,
113
248
  rootState: o,
114
- rootSetState: i,
115
- event: r,
249
+ rootSetState: r,
250
+ event: i,
116
251
  isExpression: a = !0
117
252
  }) {
118
253
  if (e === "") {
119
- k.warn("Skipping evaluation of empty code block.");
254
+ logger.warn("Skipping evaluation of empty code block.");
120
255
  return;
121
256
  }
122
257
  const c = {
123
- isEditing: L(),
124
- isBrowser: v(),
125
- isServer: !v(),
126
- getUserAttributes: () => ce()
127
- }, f = {
128
- code: /* we disable this for cases where we definitely don't want a return */ a && !(e.includes(";") || e.includes(" return ") || e.trim().startsWith("return ")) ? `return (${e});` : e,
129
- builder: c,
258
+ code: parseCode(e, {
259
+ isExpression: a
260
+ }),
261
+ builder: getBuilderGlobals(),
130
262
  context: t,
131
- event: r,
132
- rootSetState: i,
263
+ event: i,
264
+ rootSetState: r,
133
265
  rootState: o,
134
266
  localState: n
135
267
  };
136
268
  try {
137
- return Ae(f);
138
- } catch (g) {
139
- k.error("Failed code evaluation: " + g.message, {
269
+ return chooseBrowserOrServerEval(c);
270
+ } catch (s) {
271
+ logger.error("Failed code evaluation: " + s.message, {
140
272
  code: e
141
273
  });
142
274
  return;
143
275
  }
144
276
  }
145
- const He = (e, t, n) => {
146
- if (Object(e) !== e)
147
- return e;
148
- const o = Array.isArray(t) ? t : t.toString().match(/[^.[\]]+/g);
149
- return o.slice(0, -1).reduce((i, r, a) => Object(i[r]) === i[r] ? i[r] : i[r] = Math.abs(Number(o[a + 1])) >> 0 === +o[a + 1] ? [] : {}, e)[o[o.length - 1]] = n, e;
150
- };
151
- const De = ({
277
+ function transformBlock(e) {
278
+ return e;
279
+ }
280
+ const evaluateBindings = ({
152
281
  block: e,
153
282
  context: t,
154
283
  localState: n,
155
284
  rootState: o,
156
- rootSetState: i
285
+ rootSetState: r
157
286
  }) => {
158
287
  if (!e.bindings)
159
288
  return e;
160
- const r = A(e), a = {
161
- ...r,
289
+ const i = fastClone(e), a = {
290
+ ...i,
162
291
  properties: {
163
- ...r.properties
292
+ ...i.properties
164
293
  },
165
294
  actions: {
166
- ...r.actions
295
+ ...i.actions
167
296
  }
168
297
  };
169
298
  for (const c in e.bindings) {
170
- const s = e.bindings[c], u = M({
299
+ const s = e.bindings[c], u = evaluate({
171
300
  code: s,
172
301
  localState: n,
173
302
  rootState: o,
174
- rootSetState: i,
303
+ rootSetState: r,
175
304
  context: t
176
305
  });
177
- He(a, c, u);
306
+ set(a, c, u);
178
307
  }
179
308
  return a;
180
309
  };
181
- function E({
310
+ function getProcessedBlock({
182
311
  block: e,
183
312
  context: t,
184
313
  shouldEvaluateBindings: n,
185
314
  localState: o,
186
- rootState: i,
187
- rootSetState: r
315
+ rootState: r,
316
+ rootSetState: i
188
317
  }) {
189
318
  const a = e;
190
- return n ? De({
319
+ return n ? evaluateBindings({
191
320
  block: a,
192
321
  localState: o,
193
- rootState: i,
194
- rootSetState: r,
322
+ rootState: r,
323
+ rootSetState: i,
195
324
  context: t
196
325
  }) : a;
197
326
  }
198
- const ze = (e) => e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase(), C = (e) => e != null, le = (e) => Object.entries(e).map(([n, o]) => {
327
+ const camelToKebabCase = (e) => e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase(), checkIsDefined = (e) => e != null, convertStyleMapToCSSArray = (e) => Object.entries(e).map(([n, o]) => {
199
328
  if (typeof o == "string")
200
- return `${ze(n)}: ${o};`;
201
- }).filter(C), qe = (e) => le(e).join(`
202
- `), B = ({
329
+ return `${camelToKebabCase(n)}: ${o};`;
330
+ }).filter(checkIsDefined), convertStyleMapToCSS = (e) => convertStyleMapToCSSArray(e).join(`
331
+ `), createCssClass = ({
203
332
  mediaQuery: e,
204
333
  className: t,
205
334
  styles: n
206
335
  }) => {
207
336
  const o = `.${t} {
208
- ${qe(n)}
337
+ ${convertStyleMapToCSS(n)}
209
338
  }`;
210
339
  return e ? `${e} {
211
340
  ${o}
212
341
  }` : o;
213
342
  };
214
- function V(e) {
215
- return /* @__PURE__ */ l("style", { dangerouslySetInnerHTML: { __html: e.styles }, id: e.id });
343
+ function InlinedStyles(e) {
344
+ return /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: e.styles }, id: e.id });
216
345
  }
217
- function U(e) {
346
+ function BlockStyles(e) {
218
347
  const t = function() {
219
- const i = E({
348
+ const r = getProcessedBlock({
220
349
  block: e.block,
221
350
  localState: e.context.localState,
222
351
  rootState: e.context.rootState,
@@ -224,44 +353,44 @@ function U(e) {
224
353
  context: e.context.context,
225
354
  shouldEvaluateBindings: !0
226
355
  });
227
- return C(i.hide) ? !i.hide : C(i.show) ? i.show : !0;
356
+ return checkIsDefined(r.hide) ? !r.hide : checkIsDefined(r.show) ? r.show : !0;
228
357
  }, n = function() {
229
358
  var d;
230
- const i = E({
359
+ const r = getProcessedBlock({
231
360
  block: e.block,
232
361
  localState: e.context.localState,
233
362
  rootState: e.context.rootState,
234
363
  rootSetState: e.context.rootSetState,
235
364
  context: e.context.context,
236
365
  shouldEvaluateBindings: !0
237
- }), r = i.responsiveStyles, a = e.context.content, c = se(
366
+ }), i = r.responsiveStyles, a = e.context.content, c = getSizesForBreakpoints(
238
367
  ((d = a == null ? void 0 : a.meta) == null ? void 0 : d.breakpoints) || {}
239
- ), s = r == null ? void 0 : r.large, u = r == null ? void 0 : r.medium, f = r == null ? void 0 : r.small, g = i.id;
240
- if (!g)
368
+ ), s = i == null ? void 0 : i.large, u = i == null ? void 0 : i.medium, m = i == null ? void 0 : i.small, h = r.id;
369
+ if (!h)
241
370
  return "";
242
- const p = s ? B({
243
- className: g,
371
+ const p = s ? createCssClass({
372
+ className: h,
244
373
  styles: s
245
- }) : "", m = u ? B({
246
- className: g,
374
+ }) : "", l = u ? createCssClass({
375
+ className: h,
247
376
  styles: u,
248
- mediaQuery: G(
377
+ mediaQuery: getMaxWidthQueryForSize(
249
378
  "medium",
250
379
  c
251
380
  )
252
- }) : "", h = f ? B({
253
- className: g,
254
- styles: f,
255
- mediaQuery: G(
381
+ }) : "", f = m ? createCssClass({
382
+ className: h,
383
+ styles: m,
384
+ mediaQuery: getMaxWidthQueryForSize(
256
385
  "small",
257
386
  c
258
387
  )
259
388
  }) : "";
260
- return [p, m, h].join(" ");
389
+ return [p, l, f].join(" ");
261
390
  };
262
- return /* @__PURE__ */ l(x, { children: n() && t() ? /* @__PURE__ */ l(x, { children: /* @__PURE__ */ l(V, { styles: n() }) }) : null });
391
+ return /* @__PURE__ */ jsx(Fragment, { children: n() && t() ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { styles: n() }) }) : null });
263
392
  }
264
- function Ge(e) {
393
+ function getBlockComponentOptions(e) {
265
394
  var t;
266
395
  return {
267
396
  ...(t = e.component) == null ? void 0 : t.options,
@@ -272,29 +401,29 @@ function Ge(e) {
272
401
  builderBlock: e
273
402
  };
274
403
  }
275
- const Je = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"], P = (e) => typeof e == "string" && Je.includes(e.toLowerCase()), Ye = ({
404
+ const EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"], isEmptyHtmlElement = (e) => typeof e == "string" && EMPTY_HTML_ELEMENTS.includes(e.toLowerCase()), getComponent = ({
276
405
  block: e,
277
406
  context: t,
278
407
  registeredComponents: n
279
408
  }) => {
280
- var r;
281
- const o = (r = E({
409
+ var i;
410
+ const o = (i = getProcessedBlock({
282
411
  block: e,
283
412
  localState: t.localState,
284
413
  rootState: t.rootState,
285
414
  rootSetState: t.rootSetState,
286
415
  context: t.context,
287
416
  shouldEvaluateBindings: !1
288
- }).component) == null ? void 0 : r.name;
417
+ }).component) == null ? void 0 : i.name;
289
418
  if (!o)
290
419
  return null;
291
- const i = n[o];
292
- if (i)
293
- return i;
420
+ const r = n[o];
421
+ if (r)
422
+ return r;
294
423
  console.warn(`
295
424
  Could not find a registered component named "${o}".
296
425
  If you registered it, is the file that registered it imported by the file that needs to render it?`);
297
- }, Xe = ({
426
+ }, getRepeatItemData = ({
298
427
  block: e,
299
428
  context: t
300
429
  }) => {
@@ -304,17 +433,17 @@ const Je = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen"
304
433
  } = e;
305
434
  if (!(n != null && n.collection))
306
435
  return;
307
- const i = M({
436
+ const r = evaluate({
308
437
  code: n.collection,
309
438
  localState: t.localState,
310
439
  rootState: t.rootState,
311
440
  rootSetState: t.rootSetState,
312
441
  context: t.context
313
442
  });
314
- if (!Array.isArray(i))
443
+ if (!Array.isArray(r))
315
444
  return;
316
- const r = n.collection.split(".").pop(), a = n.itemName || (r ? r + "Item" : "item");
317
- return i.map((s, u) => ({
445
+ const i = n.collection.split(".").pop(), a = n.itemName || (i ? i + "Item" : "item");
446
+ return r.map((s, u) => ({
318
447
  context: {
319
448
  ...t,
320
449
  localState: {
@@ -328,10 +457,10 @@ const Je = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen"
328
457
  block: o
329
458
  }));
330
459
  };
331
- function Qe(e) {
460
+ function RepeatedBlock(e) {
332
461
  const t = e.repeatContext;
333
- return /* @__PURE__ */ l(
334
- $,
462
+ return /* @__PURE__ */ jsx(
463
+ Block,
335
464
  {
336
465
  block: e.block,
337
466
  context: t,
@@ -339,10 +468,10 @@ function Qe(e) {
339
468
  }
340
469
  );
341
470
  }
342
- function Ze(e) {
471
+ function capitalizeFirstLetter(e) {
343
472
  return e.charAt(0).toUpperCase() + e.slice(1);
344
473
  }
345
- const et = (e) => `on${Ze(e)}`, tt = (e, t) => (n) => M({
474
+ const getEventHandlerName = (e) => `on${capitalizeFirstLetter(e)}`, createEventHandler = (e, t) => (n) => evaluate({
346
475
  code: e,
347
476
  context: t.context,
348
477
  localState: t.localState,
@@ -351,54 +480,54 @@ const et = (e) => `on${Ze(e)}`, tt = (e, t) => (n) => M({
351
480
  event: n,
352
481
  isExpression: !1
353
482
  });
354
- function On(e) {
483
+ function getBlockActions(e) {
355
484
  const t = {}, n = e.block.actions ?? {};
356
485
  for (const o in n) {
357
486
  if (!n.hasOwnProperty(o))
358
487
  continue;
359
- const i = n[o];
360
- let r = et(o);
488
+ const r = n[o];
489
+ let i = getEventHandlerName(o);
361
490
  if (e.stripPrefix)
362
- switch (I) {
491
+ switch (TARGET) {
363
492
  case "vue2":
364
493
  case "vue3":
365
- r = r.replace("v-on:", "");
494
+ i = i.replace("v-on:", "");
366
495
  break;
367
496
  case "svelte":
368
- r = r.replace("on:", "");
497
+ i = i.replace("on:", "");
369
498
  break;
370
499
  }
371
- t[r] = tt(i, e);
500
+ t[i] = createEventHandler(r, e);
372
501
  }
373
502
  return t;
374
503
  }
375
- function nt(e) {
504
+ function transformBlockProperties(e) {
376
505
  return e.className = e.class, delete e.class, e;
377
506
  }
378
- const ot = (e) => ({
507
+ const extractRelevantRootBlockProperties = (e) => ({
379
508
  href: e.href
380
509
  });
381
- function it({
510
+ function getBlockProperties({
382
511
  block: e,
383
512
  context: t
384
513
  }) {
385
514
  var o;
386
515
  const n = {
387
- ...ot(e),
516
+ ...extractRelevantRootBlockProperties(e),
388
517
  ...e.properties,
389
518
  "builder-id": e.id,
390
- style: e.style ? rt(e.style) : void 0,
519
+ style: e.style ? getStyleAttribute(e.style) : void 0,
391
520
  class: [e.id, "builder-block", e.class, (o = e.properties) == null ? void 0 : o.class].filter(Boolean).join(" ")
392
521
  };
393
- return nt(n);
522
+ return transformBlockProperties(n);
394
523
  }
395
- function rt(e) {
396
- switch (I) {
524
+ function getStyleAttribute(e) {
525
+ switch (TARGET) {
397
526
  case "svelte":
398
527
  case "vue2":
399
528
  case "vue3":
400
529
  case "solid":
401
- return le(e).join(" ");
530
+ return convertStyleMapToCSSArray(e).join(" ");
402
531
  case "qwik":
403
532
  case "reactNative":
404
533
  case "react":
@@ -406,15 +535,15 @@ function rt(e) {
406
535
  return e;
407
536
  }
408
537
  }
409
- const at = ({
538
+ const getWrapperProps = ({
410
539
  componentOptions: e,
411
540
  builderBlock: t,
412
541
  context: n,
413
542
  componentRef: o,
414
- includeBlockProps: i,
415
- isInteractive: r,
543
+ includeBlockProps: r,
544
+ isInteractive: i,
416
545
  contextValue: a
417
- }) => r ? {
546
+ }) => i ? {
418
547
  Wrapper: o,
419
548
  block: t,
420
549
  context: n,
@@ -425,20 +554,20 @@ const at = ({
425
554
  * If `noWrap` is set to `true`, then the block's props/attributes are provided to the
426
555
  * component itself directly. Otherwise, they are provided to the wrapper element.
427
556
  */
428
- ...i ? {
429
- attributes: it({
557
+ ...r ? {
558
+ attributes: getBlockProperties({
430
559
  block: t,
431
560
  context: a
432
561
  })
433
562
  } : {}
434
563
  };
435
- function J(e) {
564
+ function ComponentRef(e) {
436
565
  var n, o;
437
- const t = e.isInteractive ? Ve : e.componentRef;
438
- return /* @__PURE__ */ l(x, { children: e.componentRef ? /* @__PURE__ */ l(x, { children: /* @__PURE__ */ w(
566
+ const t = e.isInteractive ? InteractiveElement : e.componentRef;
567
+ return /* @__PURE__ */ jsx(Fragment, { children: e.componentRef ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
439
568
  t,
440
569
  {
441
- ...at({
570
+ ...getWrapperProps({
442
571
  componentOptions: e.componentOptions,
443
572
  builderBlock: e.builderBlock,
444
573
  context: e.context,
@@ -448,42 +577,42 @@ function J(e) {
448
577
  contextValue: e.context
449
578
  }),
450
579
  children: [
451
- (n = e.blockChildren) == null ? void 0 : n.map((i) => /* @__PURE__ */ l(
452
- $,
580
+ (n = e.blockChildren) == null ? void 0 : n.map((r) => /* @__PURE__ */ jsx(
581
+ Block,
453
582
  {
454
- block: i,
583
+ block: r,
455
584
  context: e.context,
456
585
  registeredComponents: e.registeredComponents
457
586
  },
458
- "block-" + i.id
587
+ "block-" + r.id
459
588
  )),
460
- (o = e.blockChildren) == null ? void 0 : o.map((i) => /* @__PURE__ */ l(
461
- U,
589
+ (o = e.blockChildren) == null ? void 0 : o.map((r) => /* @__PURE__ */ jsx(
590
+ BlockStyles,
462
591
  {
463
- block: i,
592
+ block: r,
464
593
  context: e.context
465
594
  },
466
- "block-style-" + i.id
595
+ "block-style-" + r.id
467
596
  ))
468
597
  ]
469
598
  }
470
599
  ) }) : null });
471
600
  }
472
- function $(e) {
473
- var u, f, g, p;
601
+ function Block(e) {
602
+ var u, m, h, p;
474
603
  const t = function() {
475
- return Ye({
604
+ return getComponent({
476
605
  block: e.block,
477
606
  context: e.context,
478
607
  registeredComponents: e.registeredComponents
479
608
  });
480
609
  }, n = function() {
481
- return Xe({
610
+ return getRepeatItemData({
482
611
  block: e.block,
483
612
  context: e.context
484
613
  });
485
614
  }, o = function() {
486
- return n() ? e.block : E({
615
+ return n() ? e.block : getProcessedBlock({
487
616
  block: e.block,
488
617
  localState: e.context.localState,
489
618
  rootState: e.context.rootState,
@@ -491,20 +620,20 @@ function $(e) {
491
620
  context: e.context.context,
492
621
  shouldEvaluateBindings: !0
493
622
  });
494
- }, i = function() {
495
- return e.block.tagName || "div";
496
623
  }, r = function() {
624
+ return e.block.tagName || "div";
625
+ }, i = function() {
497
626
  return "hide" in o() ? !o().hide : "show" in o() ? o().show : !0;
498
627
  }, a = function() {
499
628
  var d;
500
629
  return !((d = t()) != null && d.component) && !n() ? o().children ?? [] : [];
501
630
  }, c = function() {
502
- var h, d, b, S, y;
631
+ var f, d, b, y, g;
503
632
  return {
504
633
  blockChildren: o().children ?? [],
505
- componentRef: (h = t()) == null ? void 0 : h.component,
634
+ componentRef: (f = t()) == null ? void 0 : f.component,
506
635
  componentOptions: {
507
- ...Ge(o()),
636
+ ...getBlockComponentOptions(o()),
508
637
  builderContext: e.context,
509
638
  ...((d = t()) == null ? void 0 : d.name) === "Symbol" || ((b = t()) == null ? void 0 : b.name) === "Columns" ? {
510
639
  builderComponents: e.registeredComponents
@@ -513,72 +642,72 @@ function $(e) {
513
642
  context: s,
514
643
  registeredComponents: e.registeredComponents,
515
644
  builderBlock: o(),
516
- includeBlockProps: ((S = t()) == null ? void 0 : S.noWrap) === !0,
517
- isInteractive: !((y = t()) != null && y.isRSC)
645
+ includeBlockProps: ((y = t()) == null ? void 0 : y.noWrap) === !0,
646
+ isInteractive: !((g = t()) != null && g.isRSC)
518
647
  };
519
648
  }, s = e.context;
520
- return /* @__PURE__ */ l(x, { children: r() ? /* @__PURE__ */ l(x, { children: (u = t()) != null && u.noWrap ? /* @__PURE__ */ l(x, { children: /* @__PURE__ */ l(J, { ...c() }) }) : /* @__PURE__ */ w(x, { children: [
521
- P(i()) ? /* @__PURE__ */ l(x, { children: /* @__PURE__ */ l(
522
- q,
649
+ return /* @__PURE__ */ jsx(Fragment, { children: i() ? /* @__PURE__ */ jsx(Fragment, { children: (u = t()) != null && u.noWrap ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ComponentRef, { ...c() }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
650
+ isEmptyHtmlElement(r()) ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
651
+ BlockWrapper,
523
652
  {
524
- Wrapper: i(),
653
+ Wrapper: r(),
525
654
  block: o(),
526
655
  context: e.context,
527
656
  hasChildren: !1
528
657
  }
529
658
  ) }) : null,
530
- !P(i()) && n() ? /* @__PURE__ */ l(x, { children: (f = n()) == null ? void 0 : f.map((m, h) => /* @__PURE__ */ l(
531
- Qe,
659
+ !isEmptyHtmlElement(r()) && n() ? /* @__PURE__ */ jsx(Fragment, { children: (m = n()) == null ? void 0 : m.map((l, f) => /* @__PURE__ */ jsx(
660
+ RepeatedBlock,
532
661
  {
533
- repeatContext: m.context,
534
- block: m.block,
662
+ repeatContext: l.context,
663
+ block: l.block,
535
664
  registeredComponents: e.registeredComponents
536
665
  },
537
- h
666
+ f
538
667
  )) }) : null,
539
- !P(i()) && !n() ? /* @__PURE__ */ l(x, { children: /* @__PURE__ */ w(
540
- q,
668
+ !isEmptyHtmlElement(r()) && !n() ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
669
+ BlockWrapper,
541
670
  {
542
- Wrapper: i(),
671
+ Wrapper: r(),
543
672
  block: o(),
544
673
  context: e.context,
545
674
  hasChildren: !0,
546
675
  children: [
547
- /* @__PURE__ */ l(J, { ...c() }),
548
- (g = a()) == null ? void 0 : g.map((m) => /* @__PURE__ */ l(
549
- $,
676
+ /* @__PURE__ */ jsx(ComponentRef, { ...c() }),
677
+ (h = a()) == null ? void 0 : h.map((l) => /* @__PURE__ */ jsx(
678
+ Block,
550
679
  {
551
- block: m,
680
+ block: l,
552
681
  context: s,
553
682
  registeredComponents: e.registeredComponents
554
683
  },
555
- "block-" + m.id
684
+ "block-" + l.id
556
685
  )),
557
- (p = a()) == null ? void 0 : p.map((m) => /* @__PURE__ */ l(
558
- U,
686
+ (p = a()) == null ? void 0 : p.map((l) => /* @__PURE__ */ jsx(
687
+ BlockStyles,
559
688
  {
560
- block: m,
689
+ block: l,
561
690
  context: s
562
691
  },
563
- "block-style-" + m.id
692
+ "block-style-" + l.id
564
693
  ))
565
694
  ]
566
695
  }
567
696
  ) }) : null
568
697
  ] }) }) : null });
569
698
  }
570
- function _(e) {
699
+ function Blocks(e) {
571
700
  var t, n;
572
- return /* @__PURE__ */ w(
573
- $e,
701
+ return /* @__PURE__ */ jsxs(
702
+ BlocksWrapper,
574
703
  {
575
704
  blocks: e.blocks,
576
705
  parent: e.parent,
577
706
  path: e.path,
578
707
  styleProp: e.styleProp,
579
708
  children: [
580
- e.blocks ? /* @__PURE__ */ l(x, { children: (t = e.blocks) == null ? void 0 : t.map((o) => /* @__PURE__ */ l(
581
- $,
709
+ e.blocks ? /* @__PURE__ */ jsx(Fragment, { children: (t = e.blocks) == null ? void 0 : t.map((o) => /* @__PURE__ */ jsx(
710
+ Block,
582
711
  {
583
712
  block: o,
584
713
  context: e.context,
@@ -586,8 +715,8 @@ function _(e) {
586
715
  },
587
716
  "render-block-" + o.id
588
717
  )) }) : null,
589
- e.blocks ? /* @__PURE__ */ l(x, { children: (n = e.blocks) == null ? void 0 : n.map((o) => /* @__PURE__ */ l(
590
- U,
718
+ e.blocks ? /* @__PURE__ */ jsx(Fragment, { children: (n = e.blocks) == null ? void 0 : n.map((o) => /* @__PURE__ */ jsx(
719
+ BlockStyles,
591
720
  {
592
721
  block: o,
593
722
  context: e.context
@@ -598,14 +727,14 @@ function _(e) {
598
727
  }
599
728
  );
600
729
  }
601
- function st(e) {
602
- var m;
603
- const t = typeof e.space == "number" ? e.space || 0 : 20, n = e.columns || [], o = e.stackColumnsAt || "tablet", i = function(d) {
730
+ function Columns(e) {
731
+ var l;
732
+ const t = typeof e.space == "number" ? e.space || 0 : 20, n = e.columns || [], o = e.stackColumnsAt || "tablet", r = function(d) {
604
733
  var b;
605
734
  return ((b = n[d]) == null ? void 0 : b.width) || 100 / n.length;
606
- }, r = function(d) {
735
+ }, i = function(d) {
607
736
  const b = t * (n.length - 1) / n.length;
608
- return `calc(${i(d)}% - ${b}px)`;
737
+ return `calc(${r(d)}% - ${b}px)`;
609
738
  }, a = function({
610
739
  stackedStyle: d,
611
740
  desktopStyle: b
@@ -624,36 +753,36 @@ function st(e) {
624
753
  desktopStyle: "row"
625
754
  })
626
755
  };
627
- }, f = function(d) {
628
- const b = d === 0 ? 0 : t, S = r(d), y = `${b}px`, D = "100%", z = 0;
756
+ }, m = function(d) {
757
+ const b = d === 0 ? 0 : t, y = i(d), g = `${b}px`, v = "100%", x = 0;
629
758
  return {
630
- width: S,
631
- ["marginLeft"]: y,
759
+ width: y,
760
+ ["marginLeft"]: g,
632
761
  "--column-width-mobile": c({
633
- stackedStyle: D,
634
- desktopStyle: S
762
+ stackedStyle: v,
763
+ desktopStyle: y
635
764
  }),
636
765
  "--column-margin-left-mobile": c({
637
- stackedStyle: z,
638
- desktopStyle: y
766
+ stackedStyle: x,
767
+ desktopStyle: g
639
768
  }),
640
769
  "--column-width-tablet": a({
641
- stackedStyle: D,
642
- desktopStyle: S
770
+ stackedStyle: v,
771
+ desktopStyle: y
643
772
  }),
644
773
  "--column-margin-left-tablet": a({
645
- stackedStyle: z,
646
- desktopStyle: y
774
+ stackedStyle: x,
775
+ desktopStyle: g
647
776
  })
648
777
  };
649
- }, g = function(d) {
650
- var S, y;
651
- return se(
652
- ((y = (S = e.builderContext.content) == null ? void 0 : S.meta) == null ? void 0 : y.breakpoints) || {}
778
+ }, h = function(d) {
779
+ var y, g;
780
+ return getSizesForBreakpoints(
781
+ ((g = (y = e.builderContext.content) == null ? void 0 : y.meta) == null ? void 0 : g.breakpoints) || {}
653
782
  )[d].max;
654
783
  }, p = function() {
655
784
  return `
656
- @media (max-width: ${g("medium")}px) {
785
+ @media (max-width: ${h("medium")}px) {
657
786
  .${e.builderBlock.id}-breakpoints {
658
787
  flex-direction: var(--flex-dir-tablet);
659
788
  align-items: stretch;
@@ -665,7 +794,7 @@ function st(e) {
665
794
  }
666
795
  }
667
796
 
668
- @media (max-width: ${g("small")}px) {
797
+ @media (max-width: ${h("small")}px) {
669
798
  .${e.builderBlock.id}-breakpoints {
670
799
  flex-direction: var(--flex-dir);
671
800
  align-items: stretch;
@@ -678,23 +807,23 @@ function st(e) {
678
807
  },
679
808
  `;
680
809
  };
681
- return /* @__PURE__ */ w(x, { children: [
682
- /* @__PURE__ */ w(
810
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
811
+ /* @__PURE__ */ jsxs(
683
812
  "div",
684
813
  {
685
814
  className: `builder-columns ${e.builderBlock.id}-breakpoints div-666689ca`,
686
815
  style: u(),
687
816
  children: [
688
- /* @__PURE__ */ l(x, { children: /* @__PURE__ */ l(V, { styles: p() }) }),
689
- (m = e.columns) == null ? void 0 : m.map((h, d) => /* @__PURE__ */ Ee(
817
+ /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { styles: p() }) }),
818
+ (l = e.columns) == null ? void 0 : l.map((f, d) => /* @__PURE__ */ createElement(
690
819
  "div",
691
820
  {
692
821
  className: "builder-column div-666689ca-2",
693
- style: f(d),
822
+ style: m(d),
694
823
  key: d
695
824
  },
696
- /* @__PURE__ */ l(
697
- _,
825
+ /* @__PURE__ */ jsx(
826
+ Blocks,
698
827
  {
699
828
  path: `component.options.columns.${d}.blocks`,
700
829
  parent: e.builderBlock.id,
@@ -703,14 +832,14 @@ function st(e) {
703
832
  },
704
833
  context: e.builderContext,
705
834
  registeredComponents: e.builderComponents,
706
- blocks: h.blocks
835
+ blocks: f.blocks
707
836
  }
708
837
  )
709
838
  ))
710
839
  ]
711
840
  }
712
841
  ),
713
- /* @__PURE__ */ l("style", { children: `.div-666689ca {
842
+ /* @__PURE__ */ jsx("style", { children: `.div-666689ca {
714
843
  display: flex;
715
844
  line-height: normal;
716
845
  }.div-666689ca-2 {
@@ -720,108 +849,108 @@ function st(e) {
720
849
  }` })
721
850
  ] });
722
851
  }
723
- function Y(e) {
852
+ function removeProtocol(e) {
724
853
  return e.replace(/http(s)?:/, "");
725
854
  }
726
- function ct(e = "", t, n) {
727
- const o = new RegExp("([?&])" + t + "=.*?(&|$)", "i"), i = e.indexOf("?") !== -1 ? "&" : "?";
728
- return e.match(o) ? e.replace(o, "$1" + t + "=" + encodeURIComponent(n) + "$2") : e + i + t + "=" + encodeURIComponent(n);
855
+ function updateQueryParam(e = "", t, n) {
856
+ const o = new RegExp("([?&])" + t + "=.*?(&|$)", "i"), r = e.indexOf("?") !== -1 ? "&" : "?";
857
+ return e.match(o) ? e.replace(o, "$1" + t + "=" + encodeURIComponent(n) + "$2") : e + r + t + "=" + encodeURIComponent(n);
729
858
  }
730
- function lt(e, t) {
859
+ function getShopifyImageUrl(e, t) {
731
860
  if (!e || !(e != null && e.match(/cdn\.shopify\.com/)) || !t)
732
861
  return e;
733
862
  if (t === "master")
734
- return Y(e);
863
+ return removeProtocol(e);
735
864
  const n = e.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);
736
865
  if (n) {
737
- const o = e.split(n[0]), i = n[3], r = t.match("x") ? t : `${t}x`;
738
- return Y(`${o[0]}_${r}${i}`);
866
+ const o = e.split(n[0]), r = n[3], i = t.match("x") ? t : `${t}x`;
867
+ return removeProtocol(`${o[0]}_${i}${r}`);
739
868
  }
740
869
  return null;
741
870
  }
742
- function Wn(e) {
871
+ function getSrcSet(e) {
743
872
  if (!e)
744
873
  return e;
745
874
  const t = [100, 200, 400, 800, 1200, 1600, 2e3];
746
875
  if (e.match(/builder\.io/)) {
747
876
  let n = e;
748
877
  const o = Number(e.split("?width=")[1]);
749
- return isNaN(o) || (n = `${n} ${o}w`), t.filter((i) => i !== o).map((i) => `${ct(e, "width", i)} ${i}w`).concat([n]).join(", ");
878
+ return isNaN(o) || (n = `${n} ${o}w`), t.filter((r) => r !== o).map((r) => `${updateQueryParam(e, "width", r)} ${r}w`).concat([n]).join(", ");
750
879
  }
751
- return e.match(/cdn\.shopify\.com/) ? t.map((n) => [lt(e, `${n}x${n}`), n]).filter(([n]) => !!n).map(([n, o]) => `${n} ${o}w`).concat([e]).join(", ") : e;
880
+ return e.match(/cdn\.shopify\.com/) ? t.map((n) => [getShopifyImageUrl(e, `${n}x${n}`), n]).filter(([n]) => !!n).map(([n, o]) => `${n} ${o}w`).concat([e]).join(", ") : e;
752
881
  }
753
- const R = (e) => Object.values((e == null ? void 0 : e.variations) || {}).map((t) => ({
882
+ const getVariants = (e) => Object.values((e == null ? void 0 : e.variations) || {}).map((t) => ({
754
883
  ...t,
755
884
  testVariationId: t.id,
756
885
  id: e == null ? void 0 : e.id
757
- })), ut = ({
886
+ })), checkShouldRunVariants = ({
758
887
  canTrack: e,
759
888
  content: t
760
- }) => !(!(R(t).length > 0) || !e || v());
761
- function dt(e, t, n) {
889
+ }) => !(!(getVariants(t).length > 0) || !e || isBrowser());
890
+ function bldrAbTest(e, t, n) {
762
891
  var a;
763
892
  function o() {
764
- function c(h, d, b) {
765
- let S = "";
893
+ function c(f, d, b) {
894
+ let y = "";
766
895
  if (b) {
767
- const y = /* @__PURE__ */ new Date();
768
- y.setTime(y.getTime() + b * 24 * 60 * 60 * 1e3), S = "; expires=" + y.toUTCString();
896
+ const g = /* @__PURE__ */ new Date();
897
+ g.setTime(g.getTime() + b * 24 * 60 * 60 * 1e3), y = "; expires=" + g.toUTCString();
769
898
  }
770
- document.cookie = h + "=" + (d || "") + S + "; path=/; Secure; SameSite=None";
899
+ document.cookie = f + "=" + (d || "") + y + "; path=/; Secure; SameSite=None";
771
900
  }
772
- function s(h) {
773
- const d = h + "=", b = document.cookie.split(";");
774
- for (let S = 0; S < b.length; S++) {
775
- let y = b[S];
776
- for (; y.charAt(0) === " "; )
777
- y = y.substring(1, y.length);
778
- if (y.indexOf(d) === 0)
779
- return y.substring(d.length, y.length);
901
+ function s(f) {
902
+ const d = f + "=", b = document.cookie.split(";");
903
+ for (let y = 0; y < b.length; y++) {
904
+ let g = b[y];
905
+ for (; g.charAt(0) === " "; )
906
+ g = g.substring(1, g.length);
907
+ if (g.indexOf(d) === 0)
908
+ return g.substring(d.length, g.length);
780
909
  }
781
910
  return null;
782
911
  }
783
- const u = `builder.tests.${e}`, f = s(u), g = t.map((h) => h.id).concat(e);
784
- if (f && g.includes(f))
785
- return f;
912
+ const u = `builder.tests.${e}`, m = s(u), h = t.map((f) => f.id).concat(e);
913
+ if (m && h.includes(m))
914
+ return m;
786
915
  let p = 0;
787
- const m = Math.random();
788
- for (let h = 0; h < t.length; h++) {
789
- const d = t[h], b = d.testRatio;
790
- if (p += b, m < p)
916
+ const l = Math.random();
917
+ for (let f = 0; f < t.length; f++) {
918
+ const d = t[f], b = d.testRatio;
919
+ if (p += b, l < p)
791
920
  return c(u, d.id), d.id;
792
921
  }
793
922
  return c(u, e), e;
794
923
  }
795
- const i = o(), r = (a = document.currentScript) == null ? void 0 : a.previousElementSibling;
924
+ const r = o(), i = (a = document.currentScript) == null ? void 0 : a.previousElementSibling;
796
925
  if (n) {
797
- r.remove();
926
+ i.remove();
798
927
  const c = document.currentScript;
799
928
  c == null || c.remove();
800
929
  } else {
801
930
  const c = t.concat({
802
931
  id: e
803
- }).filter((s) => s.id !== i).map((s) => `.variant-${s.id} { display: none; }
932
+ }).filter((s) => s.id !== r).map((s) => `.variant-${s.id} { display: none; }
804
933
  `).join("");
805
- r.innerHTML = c;
934
+ i.innerHTML = c;
806
935
  }
807
936
  }
808
- function mt(e, t, n) {
937
+ function bldrCntntScrpt(e, t, n) {
809
938
  var s;
810
939
  if (!navigator.cookieEnabled)
811
940
  return;
812
941
  function o(u) {
813
- const f = u + "=", g = document.cookie.split(";");
814
- for (let p = 0; p < g.length; p++) {
815
- let m = g[p];
816
- for (; m.charAt(0) === " "; )
817
- m = m.substring(1, m.length);
818
- if (m.indexOf(f) === 0)
819
- return m.substring(f.length, m.length);
942
+ const m = u + "=", h = document.cookie.split(";");
943
+ for (let p = 0; p < h.length; p++) {
944
+ let l = h[p];
945
+ for (; l.charAt(0) === " "; )
946
+ l = l.substring(1, l.length);
947
+ if (l.indexOf(m) === 0)
948
+ return l.substring(m.length, l.length);
820
949
  }
821
950
  return null;
822
951
  }
823
- const i = `builder.tests.${t}`, r = o(i), a = (s = document.currentScript) == null ? void 0 : s.parentElement, c = e === t;
824
- if (r === e) {
952
+ const r = `builder.tests.${t}`, i = o(r), a = (s = document.currentScript) == null ? void 0 : s.parentElement, c = e === t;
953
+ if (i === e) {
825
954
  if (c)
826
955
  return;
827
956
  a == null || a.removeAttribute("hidden"), a == null || a.removeAttribute("aria-hidden");
@@ -830,18 +959,18 @@ function mt(e, t, n) {
830
959
  return;
831
960
  }
832
961
  }
833
- const ft = (e) => e === "react" || e === "reactNative", ue = ft(I), de = "builderIoAbTest", me = "builderIoRenderContent", ht = () => {
834
- const e = dt.toString().replace(/\s+/g, " "), t = mt.toString().replace(/\s+/g, " ");
962
+ const getIsHydrationTarget = (e) => e === "react" || e === "reactNative", isHydrationTarget = getIsHydrationTarget(TARGET), AB_TEST_FN_NAME = "builderIoAbTest", CONTENT_FN_NAME = "builderIoRenderContent", getScriptString = () => {
963
+ const e = bldrAbTest.toString().replace(/\s+/g, " "), t = bldrCntntScrpt.toString().replace(/\s+/g, " ");
835
964
  return `
836
- window.${de} = ${e}
837
- window.${me} = ${t}
965
+ window.${AB_TEST_FN_NAME} = ${e}
966
+ window.${CONTENT_FN_NAME} = ${t}
838
967
  `;
839
- }, gt = (e, t) => `
840
- window.${de}("${t}",${JSON.stringify(e)}, ${ue})`, pt = ({
968
+ }, getVariantsScriptString = (e, t) => `
969
+ window.${AB_TEST_FN_NAME}("${t}",${JSON.stringify(e)}, ${isHydrationTarget})`, getRenderContentScriptString = ({
841
970
  contentId: e,
842
971
  variationId: t
843
972
  }) => `
844
- window.${me}("${t}", "${e}", ${ue})`, bt = {
973
+ window.${CONTENT_FN_NAME}("${t}", "${e}", ${isHydrationTarget})`, componentInfo$a = {
845
974
  name: "Core:Button",
846
975
  image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
847
976
  defaultStyles: {
@@ -874,7 +1003,7 @@ const ft = (e) => e === "react" || e === "reactNative", ue = ft(I), de = "builde
874
1003
  }],
875
1004
  static: !0,
876
1005
  noWrap: !0
877
- }, yt = {
1006
+ }, componentInfo$9 = {
878
1007
  // TODO: ways to statically preprocess JSON for references, functions, etc
879
1008
  name: "Columns",
880
1009
  isRSC: !0,
@@ -1053,7 +1182,7 @@ const ft = (e) => e === "react" || e === "reactNative", ue = ft(I), de = "builde
1053
1182
  });
1054
1183
  }
1055
1184
  const n = e.get("columns");
1056
- Array.isArray(n) && n.find((i) => i.get("width")) && (n.find((r) => !r.get("width")) || n.reduce((c, s) => c + s.get("width"), 0) !== 100) && t();
1185
+ Array.isArray(n) && n.find((r) => r.get("width")) && (n.find((i) => !i.get("width")) || n.reduce((c, s) => c + s.get("width"), 0) !== 100) && t();
1057
1186
  }
1058
1187
  }, {
1059
1188
  name: "space",
@@ -1075,13 +1204,13 @@ const ft = (e) => e === "react" || e === "reactNative", ue = ft(I), de = "builde
1075
1204
  helperText: "When stacking columns for mobile devices, reverse the ordering",
1076
1205
  advanced: !0
1077
1206
  }]
1078
- }, xt = {
1207
+ }, componentInfo$8 = {
1079
1208
  name: "Fragment",
1080
1209
  static: !0,
1081
1210
  hidden: !0,
1082
1211
  canHaveChildren: !0,
1083
1212
  noWrap: !0
1084
- }, St = {
1213
+ }, componentInfo$7 = {
1085
1214
  name: "Image",
1086
1215
  static: !0,
1087
1216
  image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
@@ -1103,27 +1232,27 @@ const ft = (e) => e === "react" || e === "reactNative", ue = ft(I), de = "builde
1103
1232
  e.delete("srcset"), e.delete("noWebp");
1104
1233
  function n(a, c = 6e4) {
1105
1234
  return new Promise((s, u) => {
1106
- const f = document.createElement("img");
1107
- let g = !1;
1108
- f.onload = () => {
1109
- g = !0, s(f);
1110
- }, f.addEventListener("error", (p) => {
1235
+ const m = document.createElement("img");
1236
+ let h = !1;
1237
+ m.onload = () => {
1238
+ h = !0, s(m);
1239
+ }, m.addEventListener("error", (p) => {
1111
1240
  console.warn("Image load failed", p.error), u(p.error);
1112
- }), f.src = a, setTimeout(() => {
1113
- g || u(new Error("Image load timed out"));
1241
+ }), m.src = a, setTimeout(() => {
1242
+ h || u(new Error("Image load timed out"));
1114
1243
  }, c);
1115
1244
  });
1116
1245
  }
1117
1246
  function o(a) {
1118
1247
  return Math.round(a * 1e3) / 1e3;
1119
1248
  }
1120
- const i = e.get("image"), r = e.get("aspectRatio");
1121
- if (fetch(i).then((a) => a.blob()).then((a) => {
1249
+ const r = e.get("image"), i = e.get("aspectRatio");
1250
+ if (fetch(r).then((a) => a.blob()).then((a) => {
1122
1251
  a.type.includes("svg") && e.set("noWebp", !0);
1123
- }), i && (!r || r === 0.7041))
1124
- return n(i).then((a) => {
1252
+ }), r && (!i || i === 0.7041))
1253
+ return n(r).then((a) => {
1125
1254
  const c = e.get("aspectRatio");
1126
- e.get("image") === i && (!c || c === 0.7041) && a.width && a.height && (e.set("aspectRatio", o(a.height / a.width)), e.set("height", a.height), e.set("width", a.width));
1255
+ e.get("image") === r && (!c || c === 0.7041) && a.width && a.height && (e.set("aspectRatio", o(a.height / a.width)), e.set("height", a.height), e.set("width", a.width));
1127
1256
  });
1128
1257
  }
1129
1258
  }, {
@@ -1181,7 +1310,7 @@ const ft = (e) => e === "react" || e === "reactNative", ue = ft(I), de = "builde
1181
1310
  advanced: !0,
1182
1311
  defaultValue: 0.7041
1183
1312
  }]
1184
- }, vt = {
1313
+ }, componentInfo$6 = {
1185
1314
  name: "Core:Section",
1186
1315
  static: !0,
1187
1316
  image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
@@ -1220,7 +1349,7 @@ const ft = (e) => e === "react" || e === "reactNative", ue = ft(I), de = "builde
1220
1349
  }
1221
1350
  }
1222
1351
  }]
1223
- }, kt = {
1352
+ }, componentInfo$5 = {
1224
1353
  name: "Symbol",
1225
1354
  noWrap: !0,
1226
1355
  static: !0,
@@ -1253,7 +1382,7 @@ const ft = (e) => e === "react" || e === "reactNative", ue = ft(I), de = "builde
1253
1382
  hideFromUI: !0,
1254
1383
  type: "boolean"
1255
1384
  }]
1256
- }, wt = {
1385
+ }, componentInfo$4 = {
1257
1386
  name: "Text",
1258
1387
  static: !0,
1259
1388
  isRSC: !0,
@@ -1272,9 +1401,9 @@ const ft = (e) => e === "react" || e === "reactNative", ue = ft(I), de = "builde
1272
1401
  textAlign: "center"
1273
1402
  }
1274
1403
  };
1275
- function Ct(e) {
1404
+ function Text(e) {
1276
1405
  var t;
1277
- return /* @__PURE__ */ l(
1406
+ return /* @__PURE__ */ jsx(
1278
1407
  "div",
1279
1408
  {
1280
1409
  className: "builder-text",
@@ -1285,7 +1414,7 @@ function Ct(e) {
1285
1414
  }
1286
1415
  );
1287
1416
  }
1288
- const It = {
1417
+ const componentInfo$3 = {
1289
1418
  name: "Video",
1290
1419
  canHaveChildren: !0,
1291
1420
  defaultStyles: {
@@ -1366,7 +1495,7 @@ const It = {
1366
1495
  defaultValue: !0,
1367
1496
  advanced: !0
1368
1497
  }]
1369
- }, Tt = {
1498
+ }, componentInfo$2 = {
1370
1499
  name: "Embed",
1371
1500
  static: !0,
1372
1501
  inputs: [{
@@ -1391,7 +1520,7 @@ const It = {
1391
1520
  defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
1392
1521
  hideFromUI: !0
1393
1522
  }]
1394
- }, Rt = ["text/javascript", "application/javascript", "application/ecmascript"], Nn = (e) => Rt.includes(e.type), Et = {
1523
+ }, SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"], isJsScript = (e) => SCRIPT_MIME_TYPES.includes(e.type), componentInfo$1 = {
1395
1524
  // friendlyName?
1396
1525
  name: "Raw:Img",
1397
1526
  hideFromInsertMenu: !0,
@@ -1405,7 +1534,7 @@ const It = {
1405
1534
  }],
1406
1535
  noWrap: !0,
1407
1536
  static: !0
1408
- }, At = {
1537
+ }, componentInfo = {
1409
1538
  name: "Custom Code",
1410
1539
  static: !0,
1411
1540
  requiredPermissions: ["editCode"],
@@ -1427,59 +1556,59 @@ const It = {
1427
1556
  helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
1428
1557
  advanced: !0
1429
1558
  }]
1430
- }, X = () => [{
1431
- component: Be,
1432
- ...bt
1559
+ }, getDefaultRegisteredComponents = () => [{
1560
+ component: Button,
1561
+ ...componentInfo$a
1433
1562
  }, {
1434
- component: st,
1435
- ...yt
1563
+ component: Columns,
1564
+ ...componentInfo$9
1436
1565
  }, {
1437
- component: Pe,
1438
- ...At
1566
+ component: CustomCode,
1567
+ ...componentInfo
1439
1568
  }, {
1440
- component: Fe,
1441
- ...Tt
1569
+ component: Embed,
1570
+ ...componentInfo$2
1442
1571
  }, {
1443
- component: Oe,
1444
- ...xt
1572
+ component: FragmentComponent,
1573
+ ...componentInfo$8
1445
1574
  }, {
1446
- component: We,
1447
- ...St
1575
+ component: Image,
1576
+ ...componentInfo$7
1448
1577
  }, {
1449
- component: Ne,
1450
- ...Et
1578
+ component: ImgComponent,
1579
+ ...componentInfo$1
1451
1580
  }, {
1452
- component: Le,
1453
- ...vt
1581
+ component: SectionComponent,
1582
+ ...componentInfo$6
1454
1583
  }, {
1455
- component: Tn,
1456
- ...kt
1584
+ component: Symbol$1,
1585
+ ...componentInfo$5
1457
1586
  }, {
1458
- component: Ct,
1459
- ...wt
1587
+ component: Text,
1588
+ ...componentInfo$4
1460
1589
  }, {
1461
- component: Me,
1462
- ...It
1463
- }], Q = [], Ln = (e) => ({
1590
+ component: Video,
1591
+ ...componentInfo$3
1592
+ }], components = [], createRegisterComponentMessage = (e) => ({
1464
1593
  type: "builder.registerComponent",
1465
- data: F(e)
1466
- }), Vt = (e) => {
1594
+ data: serializeComponentInfo(e)
1595
+ }), serializeFn = (e) => {
1467
1596
  const t = e.toString().trim();
1468
1597
  return `return (${!t.startsWith("function") && !t.startsWith("(") ? "function " : ""}${t}).apply(this, arguments)`;
1469
- }, $t = (e) => typeof e == "function" ? Vt(e) : A(e), F = ({
1598
+ }, serializeValue = (e) => typeof e == "function" ? serializeFn(e) : fastClone(e), serializeComponentInfo = ({
1470
1599
  inputs: e,
1471
1600
  ...t
1472
1601
  }) => ({
1473
- ...A(t),
1474
- inputs: e == null ? void 0 : e.map((n) => Object.entries(n).reduce((o, [i, r]) => ({
1602
+ ...fastClone(t),
1603
+ inputs: e == null ? void 0 : e.map((n) => Object.entries(n).reduce((o, [r, i]) => ({
1475
1604
  ...o,
1476
- [i]: $t(r)
1605
+ [r]: serializeValue(i)
1477
1606
  }), {}))
1478
- }), Bt = (e) => {
1479
- var r;
1480
- const t = e.family + (e.kind && !e.kind.includes("#") ? ", " + e.kind : ""), n = t.split(",")[0], o = e.fileUrl ?? ((r = e == null ? void 0 : e.files) == null ? void 0 : r.regular);
1481
- let i = "";
1482
- if (o && t && n && (i += `
1607
+ }), getCssFromFont = (e) => {
1608
+ var i;
1609
+ const t = e.family + (e.kind && !e.kind.includes("#") ? ", " + e.kind : ""), n = t.split(",")[0], o = e.fileUrl ?? ((i = e == null ? void 0 : e.files) == null ? void 0 : i.regular);
1610
+ let r = "";
1611
+ if (o && t && n && (r += `
1483
1612
  @font-face {
1484
1613
  font-family: "${t}";
1485
1614
  src: local("${n}"), url('${o}') format('woff2');
@@ -1491,7 +1620,7 @@ font-weight: 400;
1491
1620
  if (!(String(Number(a)) === a))
1492
1621
  continue;
1493
1622
  const s = e.files[a];
1494
- s && s !== o && (i += `
1623
+ s && s !== o && (r += `
1495
1624
  @font-face {
1496
1625
  font-family: "${t}";
1497
1626
  src: url('${s}') format('woff2');
@@ -1500,23 +1629,23 @@ font-weight: ${a};
1500
1629
  }
1501
1630
  `.trim());
1502
1631
  }
1503
- return i;
1504
- }, Pt = ({
1632
+ return r;
1633
+ }, getFontCss = ({
1505
1634
  customFonts: e
1506
1635
  }) => {
1507
1636
  var t;
1508
- return ((t = e == null ? void 0 : e.map((n) => Bt(n))) == null ? void 0 : t.join(" ")) || "";
1509
- }, Ft = ({
1637
+ return ((t = e == null ? void 0 : e.map((n) => getCssFromFont(n))) == null ? void 0 : t.join(" ")) || "";
1638
+ }, getCss = ({
1510
1639
  cssCode: e,
1511
1640
  contentId: t
1512
1641
  }) => e ? t ? (e == null ? void 0 : e.replace(/&/g, `div[builder-content-id="${t}"]`)) || "" : e : "";
1513
- function Ot(e) {
1642
+ function ContentStyles(e) {
1514
1643
  const t = `
1515
- ${Ft({
1644
+ ${getCss({
1516
1645
  cssCode: e.cssCode,
1517
1646
  contentId: e.contentId
1518
1647
  })}
1519
- ${Pt({
1648
+ ${getFontCss({
1520
1649
  customFonts: e.customFonts
1521
1650
  })}
1522
1651
 
@@ -1533,20 +1662,20 @@ ${Pt({
1533
1662
  font-family: inherit;
1534
1663
  }
1535
1664
  `.trim();
1536
- return /* @__PURE__ */ l(V, { styles: t });
1665
+ return /* @__PURE__ */ jsx(InlinedStyles, { styles: t });
1537
1666
  }
1538
- const Wt = ({
1667
+ const getContextStateInitialValue = ({
1539
1668
  content: e,
1540
1669
  data: t,
1541
1670
  locale: n
1542
1671
  }) => {
1543
- var r, a, c;
1672
+ var i, a, c;
1544
1673
  const o = {};
1545
- (a = (r = e == null ? void 0 : e.data) == null ? void 0 : r.inputs) == null || a.forEach((s) => {
1674
+ (a = (i = e == null ? void 0 : e.data) == null ? void 0 : i.inputs) == null || a.forEach((s) => {
1546
1675
  var u;
1547
1676
  s.name && s.defaultValue !== void 0 && ((u = e == null ? void 0 : e.data) != null && u.state) && e.data.state[s.name] === void 0 && (o[s.name] = s.defaultValue);
1548
1677
  });
1549
- const i = {
1678
+ const r = {
1550
1679
  ...(c = e == null ? void 0 : e.data) == null ? void 0 : c.state,
1551
1680
  ...t,
1552
1681
  ...n ? {
@@ -1555,9 +1684,9 @@ const Wt = ({
1555
1684
  };
1556
1685
  return {
1557
1686
  ...o,
1558
- ...i
1687
+ ...r
1559
1688
  };
1560
- }, Nt = ({
1689
+ }, getContentInitialValue = ({
1561
1690
  content: e,
1562
1691
  data: t
1563
1692
  }) => e ? {
@@ -1568,22 +1697,22 @@ const Wt = ({
1568
1697
  },
1569
1698
  meta: e == null ? void 0 : e.meta
1570
1699
  } : void 0;
1571
- function Lt() {
1700
+ function getGlobalThis() {
1572
1701
  return typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : globalThis;
1573
1702
  }
1574
- function Mt() {
1575
- const e = Lt().fetch;
1703
+ function getFetch() {
1704
+ const e = getGlobalThis().fetch;
1576
1705
  if (typeof e > "u")
1577
1706
  throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
1578
1707
  For more information, read https://github.com/BuilderIO/this-package-uses-fetch`), new Error("Builder SDK could not find a global `fetch` function");
1579
1708
  return e;
1580
1709
  }
1581
- const Ut = Mt(), _t = (e) => {
1710
+ const fetch$1 = getFetch(), getTopLevelDomain = (e) => {
1582
1711
  if (e === "localhost" || e === "127.0.0.1")
1583
1712
  return e;
1584
1713
  const t = e.split(".");
1585
1714
  return t.length > 2 ? t.slice(1).join(".") : e;
1586
- }, fe = ({
1715
+ }, getCookieSync = ({
1587
1716
  name: e,
1588
1717
  canTrack: t
1589
1718
  }) => {
@@ -1591,17 +1720,17 @@ const Ut = Mt(), _t = (e) => {
1591
1720
  try {
1592
1721
  return t ? (n = document.cookie.split("; ").find((o) => o.startsWith(`${e}=`))) == null ? void 0 : n.split("=")[1] : void 0;
1593
1722
  } catch (o) {
1594
- k.warn("[COOKIE] GET error: ", (o == null ? void 0 : o.message) || o);
1723
+ logger.warn("[COOKIE] GET error: ", (o == null ? void 0 : o.message) || o);
1595
1724
  return;
1596
1725
  }
1597
- }, he = async (e) => fe(e), jt = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(C).join("; "), Kt = [["secure", ""], ["SameSite", "None"]], Ht = ({
1726
+ }, getCookie = async (e) => getCookieSync(e), stringifyCookie = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(checkIsDefined).join("; "), SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]], createCookieString = ({
1598
1727
  name: e,
1599
1728
  value: t,
1600
1729
  expires: n
1601
1730
  }) => {
1602
- const i = (v() ? location.protocol === "https:" : !0) ? Kt : [[]], r = n ? [["expires", n.toUTCString()]] : [[]], a = [[e, t], ...r, ["path", "/"], ["domain", _t(window.location.hostname)], ...i];
1603
- return jt(a);
1604
- }, ge = async ({
1731
+ const r = (isBrowser() ? location.protocol === "https:" : !0) ? SECURE_CONFIG : [[]], i = n ? [["expires", n.toUTCString()]] : [[]], a = [[e, t], ...i, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...r];
1732
+ return stringifyCookie(a);
1733
+ }, setCookie = async ({
1605
1734
  name: e,
1606
1735
  value: t,
1607
1736
  expires: n,
@@ -1610,98 +1739,98 @@ const Ut = Mt(), _t = (e) => {
1610
1739
  try {
1611
1740
  if (!o)
1612
1741
  return;
1613
- const i = Ht({
1742
+ const r = createCookieString({
1614
1743
  name: e,
1615
1744
  value: t,
1616
1745
  expires: n
1617
1746
  });
1618
- document.cookie = i;
1619
- } catch (i) {
1620
- k.warn("[COOKIE] SET error: ", (i == null ? void 0 : i.message) || i);
1747
+ document.cookie = r;
1748
+ } catch (r) {
1749
+ logger.warn("[COOKIE] SET error: ", (r == null ? void 0 : r.message) || r);
1621
1750
  }
1622
1751
  };
1623
- function Dt() {
1752
+ function uuidv4() {
1624
1753
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
1625
1754
  const t = Math.random() * 16 | 0;
1626
1755
  return (e == "x" ? t : t & 3 | 8).toString(16);
1627
1756
  });
1628
1757
  }
1629
- function pe() {
1630
- return Dt().replace(/-/g, "");
1758
+ function uuid() {
1759
+ return uuidv4().replace(/-/g, "");
1631
1760
  }
1632
- const be = "builderSessionId", zt = async ({
1761
+ const SESSION_LOCAL_STORAGE_KEY = "builderSessionId", getSessionId = async ({
1633
1762
  canTrack: e
1634
1763
  }) => {
1635
1764
  if (!e)
1636
1765
  return;
1637
- const t = await he({
1638
- name: be,
1766
+ const t = await getCookie({
1767
+ name: SESSION_LOCAL_STORAGE_KEY,
1639
1768
  canTrack: e
1640
1769
  });
1641
- if (C(t))
1770
+ if (checkIsDefined(t))
1642
1771
  return t;
1643
1772
  {
1644
- const n = qt();
1645
- return Gt({
1773
+ const n = createSessionId();
1774
+ return setSessionId({
1646
1775
  id: n,
1647
1776
  canTrack: e
1648
1777
  }), n;
1649
1778
  }
1650
- }, qt = () => pe(), Gt = ({
1779
+ }, createSessionId = () => uuid(), setSessionId = ({
1651
1780
  id: e,
1652
1781
  canTrack: t
1653
- }) => ge({
1654
- name: be,
1782
+ }) => setCookie({
1783
+ name: SESSION_LOCAL_STORAGE_KEY,
1655
1784
  value: e,
1656
1785
  canTrack: t
1657
- }), ye = () => v() && typeof localStorage < "u" ? localStorage : void 0, Jt = ({
1786
+ }), getLocalStorage = () => isBrowser() && typeof localStorage < "u" ? localStorage : void 0, getLocalStorageItem = ({
1658
1787
  key: e,
1659
1788
  canTrack: t
1660
1789
  }) => {
1661
1790
  var n;
1662
1791
  try {
1663
- return t ? (n = ye()) == null ? void 0 : n.getItem(e) : void 0;
1792
+ return t ? (n = getLocalStorage()) == null ? void 0 : n.getItem(e) : void 0;
1664
1793
  } catch (o) {
1665
1794
  console.debug("[LocalStorage] GET error: ", o);
1666
1795
  return;
1667
1796
  }
1668
- }, Yt = ({
1797
+ }, setLocalStorageItem = ({
1669
1798
  key: e,
1670
1799
  canTrack: t,
1671
1800
  value: n
1672
1801
  }) => {
1673
1802
  var o;
1674
1803
  try {
1675
- t && ((o = ye()) == null || o.setItem(e, n));
1676
- } catch (i) {
1677
- console.debug("[LocalStorage] SET error: ", i);
1804
+ t && ((o = getLocalStorage()) == null || o.setItem(e, n));
1805
+ } catch (r) {
1806
+ console.debug("[LocalStorage] SET error: ", r);
1678
1807
  }
1679
- }, xe = "builderVisitorId", Xt = ({
1808
+ }, VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId", getVisitorId = ({
1680
1809
  canTrack: e
1681
1810
  }) => {
1682
1811
  if (!e)
1683
1812
  return;
1684
- const t = Jt({
1685
- key: xe,
1813
+ const t = getLocalStorageItem({
1814
+ key: VISITOR_LOCAL_STORAGE_KEY,
1686
1815
  canTrack: e
1687
1816
  });
1688
- if (C(t))
1817
+ if (checkIsDefined(t))
1689
1818
  return t;
1690
1819
  {
1691
- const n = Qt();
1692
- return Zt({
1820
+ const n = createVisitorId();
1821
+ return setVisitorId({
1693
1822
  id: n,
1694
1823
  canTrack: e
1695
1824
  }), n;
1696
1825
  }
1697
- }, Qt = () => pe(), Zt = ({
1826
+ }, createVisitorId = () => uuid(), setVisitorId = ({
1698
1827
  id: e,
1699
1828
  canTrack: t
1700
- }) => Yt({
1701
- key: xe,
1829
+ }) => setLocalStorageItem({
1830
+ key: VISITOR_LOCAL_STORAGE_KEY,
1702
1831
  value: e,
1703
1832
  canTrack: t
1704
- }), en = async ({
1833
+ }), getTrackingEventData = async ({
1705
1834
  canTrack: e
1706
1835
  }) => {
1707
1836
  if (!e)
@@ -1709,46 +1838,46 @@ const be = "builderSessionId", zt = async ({
1709
1838
  visitorId: void 0,
1710
1839
  sessionId: void 0
1711
1840
  };
1712
- const t = await zt({
1841
+ const t = await getSessionId({
1713
1842
  canTrack: e
1714
- }), n = Xt({
1843
+ }), n = getVisitorId({
1715
1844
  canTrack: e
1716
1845
  });
1717
1846
  return {
1718
1847
  sessionId: t,
1719
1848
  visitorId: n
1720
1849
  };
1721
- }, tn = async ({
1850
+ }, createEvent = async ({
1722
1851
  type: e,
1723
1852
  canTrack: t,
1724
1853
  apiKey: n,
1725
1854
  metadata: o,
1726
- ...i
1855
+ ...r
1727
1856
  }) => ({
1728
1857
  type: e,
1729
1858
  data: {
1730
- ...i,
1859
+ ...r,
1731
1860
  metadata: {
1732
1861
  url: location.href,
1733
1862
  ...o
1734
1863
  },
1735
- ...await en({
1864
+ ...await getTrackingEventData({
1736
1865
  canTrack: t
1737
1866
  }),
1738
- userAttributes: ce(),
1867
+ userAttributes: getUserAttributes(),
1739
1868
  ownerId: n
1740
1869
  }
1741
1870
  });
1742
- async function nn(e) {
1871
+ async function _track(e) {
1743
1872
  if (!e.apiKey) {
1744
- k.error("Missing API key for track call. Please provide your API key.");
1873
+ logger.error("Missing API key for track call. Please provide your API key.");
1745
1874
  return;
1746
1875
  }
1747
- if (e.canTrack && !L() && (v() || I === "reactNative"))
1876
+ if (e.canTrack && !isEditing() && (isBrowser() || TARGET === "reactNative"))
1748
1877
  return fetch("https://cdn.builder.io/api/v1/track", {
1749
1878
  method: "POST",
1750
1879
  body: JSON.stringify({
1751
- events: [await tn(e)]
1880
+ events: [await createEvent(e)]
1752
1881
  }),
1753
1882
  headers: {
1754
1883
  "content-type": "application/json"
@@ -1758,13 +1887,13 @@ async function nn(e) {
1758
1887
  console.error("Failed to track: ", t);
1759
1888
  });
1760
1889
  }
1761
- const Mn = (e) => nn({
1890
+ const track = (e) => _track({
1762
1891
  ...e,
1763
1892
  canTrack: !0
1764
- }), on = "0.7.1-0", Z = {};
1765
- function rn(e, t) {
1766
- let n = Z[e];
1767
- if (n || (n = Z[e] = []), n.push(t), v()) {
1893
+ }), SDK_VERSION = "0.7.1-2", registry = {};
1894
+ function register(e, t) {
1895
+ let n = registry[e];
1896
+ if (n || (n = registry[e] = []), n.push(t), isBrowser()) {
1768
1897
  const o = {
1769
1898
  type: "builder.register",
1770
1899
  data: {
@@ -1774,13 +1903,13 @@ function rn(e, t) {
1774
1903
  };
1775
1904
  try {
1776
1905
  parent.postMessage(o, "*"), parent !== window && window.postMessage(o, "*");
1777
- } catch (i) {
1778
- console.debug("Could not postmessage", i);
1906
+ } catch (r) {
1907
+ console.debug("Could not postmessage", r);
1779
1908
  }
1780
1909
  }
1781
1910
  }
1782
- const Un = () => {
1783
- rn("insertMenu", {
1911
+ const registerInsertMenu = () => {
1912
+ register("insertMenu", {
1784
1913
  name: "_default",
1785
1914
  default: !0,
1786
1915
  items: [{
@@ -1802,14 +1931,14 @@ const Un = () => {
1802
1931
  }]
1803
1932
  });
1804
1933
  };
1805
- let ee = !1;
1806
- const _n = (e = {}) => {
1934
+ let isSetupForEditing = !1;
1935
+ const setupBrowserForEditing = (e = {}) => {
1807
1936
  var t, n;
1808
- ee || (ee = !0, v() && ((t = window.parent) == null || t.postMessage({
1937
+ isSetupForEditing || (isSetupForEditing = !0, isBrowser() && ((t = window.parent) == null || t.postMessage({
1809
1938
  type: "builder.sdkInfo",
1810
1939
  data: {
1811
- target: I,
1812
- version: on,
1940
+ target: TARGET,
1941
+ version: SDK_VERSION,
1813
1942
  supportsPatchUpdates: !1,
1814
1943
  // Supports builder-model="..." attribute which is needed to
1815
1944
  // scope our '+ add block' button styling
@@ -1824,36 +1953,36 @@ const _n = (e = {}) => {
1824
1953
  }, "*"), window.addEventListener("message", ({
1825
1954
  data: o
1826
1955
  }) => {
1827
- var i, r;
1956
+ var r, i;
1828
1957
  if (o != null && o.type)
1829
1958
  switch (o.type) {
1830
1959
  case "builder.evaluate": {
1831
1960
  const a = o.data.text, c = o.data.arguments || [], s = o.data.id, u = new Function(a);
1832
- let f, g = null;
1961
+ let m, h = null;
1833
1962
  try {
1834
- f = u.apply(null, c);
1963
+ m = u.apply(null, c);
1835
1964
  } catch (p) {
1836
- g = p;
1965
+ h = p;
1837
1966
  }
1838
- g ? (i = window.parent) == null || i.postMessage({
1967
+ h ? (r = window.parent) == null || r.postMessage({
1839
1968
  type: "builder.evaluateError",
1840
1969
  data: {
1841
1970
  id: s,
1842
- error: g.message
1971
+ error: h.message
1843
1972
  }
1844
- }, "*") : f && typeof f.then == "function" ? f.then((p) => {
1845
- var m;
1846
- (m = window.parent) == null || m.postMessage({
1973
+ }, "*") : m && typeof m.then == "function" ? m.then((p) => {
1974
+ var l;
1975
+ (l = window.parent) == null || l.postMessage({
1847
1976
  type: "builder.evaluateResult",
1848
1977
  data: {
1849
1978
  id: s,
1850
1979
  result: p
1851
1980
  }
1852
1981
  }, "*");
1853
- }).catch(console.error) : (r = window.parent) == null || r.postMessage({
1982
+ }).catch(console.error) : (i = window.parent) == null || i.postMessage({
1854
1983
  type: "builder.evaluateResult",
1855
1984
  data: {
1856
- result: f,
1985
+ result: m,
1857
1986
  id: s
1858
1987
  }
1859
1988
  }, "*");
@@ -1862,10 +1991,10 @@ const _n = (e = {}) => {
1862
1991
  }
1863
1992
  })));
1864
1993
  };
1865
- function te(e) {
1994
+ function round(e) {
1866
1995
  return Math.round(e * 1e3) / 1e3;
1867
1996
  }
1868
- const an = (e, t, n = !0) => {
1997
+ const findParentElement = (e, t, n = !0) => {
1869
1998
  if (!(e instanceof HTMLElement))
1870
1999
  return null;
1871
2000
  let o = n ? e : e.parentElement;
@@ -1876,73 +2005,73 @@ const an = (e, t, n = !0) => {
1876
2005
  return o;
1877
2006
  } while (o = o.parentElement);
1878
2007
  return null;
1879
- }, sn = (e) => an(e, (t) => {
2008
+ }, findBuilderParent = (e) => findParentElement(e, (t) => {
1880
2009
  const n = t.getAttribute("builder-id") || t.id;
1881
2010
  return (n == null ? void 0 : n.indexOf("builder-")) === 0;
1882
- }), ne = ({
2011
+ }), computeOffset = ({
1883
2012
  event: e,
1884
2013
  target: t
1885
2014
  }) => {
1886
- const n = t.getBoundingClientRect(), o = e.clientX - n.left, i = e.clientY - n.top, r = te(o / n.width), a = te(i / n.height);
2015
+ const n = t.getBoundingClientRect(), o = e.clientX - n.left, r = e.clientY - n.top, i = round(o / n.width), a = round(r / n.height);
1887
2016
  return {
1888
- x: r,
2017
+ x: i,
1889
2018
  y: a
1890
2019
  };
1891
- }, jn = (e) => {
1892
- const t = e.target, n = t && sn(t), o = (n == null ? void 0 : n.getAttribute("builder-id")) || (n == null ? void 0 : n.id);
2020
+ }, getInteractionPropertiesForEvent = (e) => {
2021
+ const t = e.target, n = t && findBuilderParent(t), o = (n == null ? void 0 : n.getAttribute("builder-id")) || (n == null ? void 0 : n.id);
1893
2022
  return {
1894
2023
  targetBuilderElement: o || void 0,
1895
2024
  metadata: {
1896
- targetOffset: t ? ne({
2025
+ targetOffset: t ? computeOffset({
1897
2026
  event: e,
1898
2027
  target: t
1899
2028
  }) : void 0,
1900
- builderTargetOffset: n ? ne({
2029
+ builderTargetOffset: n ? computeOffset({
1901
2030
  event: e,
1902
2031
  target: n
1903
2032
  }) : void 0,
1904
2033
  builderElementIndex: n && o ? [].slice.call(document.getElementsByClassName(o)).indexOf(n) : void 0
1905
2034
  }
1906
2035
  };
1907
- }, cn = "builder.tests", j = (e) => `${cn}.${e}`, ln = ({
2036
+ }, BUILDER_STORE_PREFIX = "builder.tests", getContentTestKey = (e) => `${BUILDER_STORE_PREFIX}.${e}`, getContentVariationCookie = ({
1908
2037
  contentId: e
1909
- }) => he({
1910
- name: j(e),
2038
+ }) => getCookie({
2039
+ name: getContentTestKey(e),
1911
2040
  canTrack: !0
1912
- }), un = ({
2041
+ }), getContentVariationCookieSync = ({
1913
2042
  contentId: e
1914
- }) => fe({
1915
- name: j(e),
2043
+ }) => getCookieSync({
2044
+ name: getContentTestKey(e),
1916
2045
  canTrack: !0
1917
- }), dn = ({
2046
+ }), setContentVariationCookie = ({
1918
2047
  contentId: e,
1919
2048
  value: t
1920
- }) => ge({
1921
- name: j(e),
2049
+ }) => setCookie({
2050
+ name: getContentTestKey(e),
1922
2051
  value: t,
1923
2052
  canTrack: !0
1924
- }), Se = (e) => C(e.id) && C(e.variations) && Object.keys(e.variations).length > 0, mn = ({
2053
+ }), checkIsBuilderContentWithVariations = (e) => checkIsDefined(e.id) && checkIsDefined(e.variations) && Object.keys(e.variations).length > 0, getRandomVariationId = ({
1925
2054
  id: e,
1926
2055
  variations: t
1927
2056
  }) => {
1928
- var i;
2057
+ var r;
1929
2058
  let n = 0;
1930
2059
  const o = Math.random();
1931
- for (const r in t) {
1932
- const a = (i = t[r]) == null ? void 0 : i.testRatio;
2060
+ for (const i in t) {
2061
+ const a = (r = t[i]) == null ? void 0 : r.testRatio;
1933
2062
  if (n += a, o < n)
1934
- return r;
2063
+ return i;
1935
2064
  }
1936
2065
  return e;
1937
- }, ve = (e) => {
1938
- const t = mn(e);
1939
- return dn({
2066
+ }, getAndSetVariantId = (e) => {
2067
+ const t = getRandomVariationId(e);
2068
+ return setContentVariationCookie({
1940
2069
  contentId: e.id,
1941
2070
  value: t
1942
2071
  }).catch((n) => {
1943
- k.error("could not store A/B test variation: ", n);
2072
+ logger.error("could not store A/B test variation: ", n);
1944
2073
  }), t;
1945
- }, ke = ({
2074
+ }, getTestFields = ({
1946
2075
  item: e,
1947
2076
  testGroupId: t
1948
2077
  }) => {
@@ -1956,7 +2085,7 @@ const an = (e, t, n = !0) => {
1956
2085
  testVariationId: n.id,
1957
2086
  testVariationName: n.name || (n.id === e.id ? "Default" : "")
1958
2087
  };
1959
- }, fn = ({
2088
+ }, handleABTestingSync = ({
1960
2089
  item: e,
1961
2090
  canTrack: t
1962
2091
  }) => {
@@ -1964,14 +2093,14 @@ const an = (e, t, n = !0) => {
1964
2093
  return e;
1965
2094
  if (!e)
1966
2095
  return;
1967
- if (!Se(e))
2096
+ if (!checkIsBuilderContentWithVariations(e))
1968
2097
  return e;
1969
- const n = un({
2098
+ const n = getContentVariationCookieSync({
1970
2099
  contentId: e.id
1971
- }) || ve({
2100
+ }) || getAndSetVariantId({
1972
2101
  variations: e.variations,
1973
2102
  id: e.id
1974
- }), o = ke({
2103
+ }), o = getTestFields({
1975
2104
  item: e,
1976
2105
  testGroupId: n
1977
2106
  });
@@ -1979,161 +2108,176 @@ const an = (e, t, n = !0) => {
1979
2108
  ...e,
1980
2109
  ...o
1981
2110
  };
1982
- }, hn = async ({
2111
+ }, handleABTesting = async ({
1983
2112
  item: e,
1984
2113
  canTrack: t
1985
2114
  }) => {
1986
- if (!t || !Se(e))
2115
+ if (!t || !checkIsBuilderContentWithVariations(e))
1987
2116
  return e;
1988
- const o = await ln({
2117
+ const o = await getContentVariationCookie({
1989
2118
  contentId: e.id
1990
- }) || ve({
2119
+ }) || getAndSetVariantId({
1991
2120
  variations: e.variations,
1992
2121
  id: e.id
1993
- }), i = ke({
2122
+ }), r = getTestFields({
1994
2123
  item: e,
1995
2124
  testGroupId: o
1996
2125
  });
1997
2126
  return {
1998
2127
  ...e,
1999
- ...i
2128
+ ...r
2000
2129
  };
2001
- }, O = (e) => C(e) ? e : !0, gn = (e) => {
2130
+ }, getDefaultCanTrack = (e) => checkIsDefined(e) ? e : !0, getIdFromSearchParams = (e) => {
2002
2131
  const t = e.get("preview"), n = e.get("overrides." + t);
2003
- return n || k.warn("No previewed ID found in search params."), n;
2132
+ return n || logger.warn("No previewed ID found in search params."), n;
2004
2133
  };
2005
- function pn() {
2006
- globalThis._BUILDER_PREVIEW_LRU_CACHE || (globalThis._BUILDER_PREVIEW_LRU_CACHE = new Re({
2134
+ function init() {
2135
+ globalThis._BUILDER_PREVIEW_LRU_CACHE || (globalThis._BUILDER_PREVIEW_LRU_CACHE = new LRUCache({
2007
2136
  max: 500,
2008
2137
  // how long to live in ms
2009
2138
  ttl: 1e3 * 60 * 5
2010
2139
  }));
2011
2140
  }
2012
- function bn(e) {
2013
- pn();
2014
- const t = gn(e);
2141
+ function getPreviewContent(e) {
2142
+ init();
2143
+ const t = getIdFromSearchParams(e);
2015
2144
  return typeof t == "string" ? globalThis._BUILDER_PREVIEW_LRU_CACHE.get(t) : void 0;
2016
2145
  }
2017
- function W(e, t = null, n = ".") {
2018
- return Object.keys(e).reduce((o, i) => {
2019
- const r = e[i], a = [t, i].filter(Boolean).join(n);
2020
- return [typeof r == "object", r !== null, !(Array.isArray(r) && r.length === 0)].every(Boolean) ? {
2146
+ function flatten(e, t = null, n = ".") {
2147
+ return Object.keys(e).reduce((o, r) => {
2148
+ const i = e[r], a = [t, r].filter(Boolean).join(n);
2149
+ return [typeof i == "object", i !== null, !(Array.isArray(i) && i.length === 0)].every(Boolean) ? {
2021
2150
  ...o,
2022
- ...W(r, a, n)
2151
+ ...flatten(i, a, n)
2023
2152
  } : {
2024
2153
  ...o,
2025
- [a]: r
2154
+ [a]: i
2026
2155
  };
2027
2156
  }, {});
2028
2157
  }
2029
- const oe = "builder.", yn = "options.", xn = (e) => {
2158
+ const BUILDER_SEARCHPARAMS_PREFIX = "builder.", BUILDER_OPTIONS_PREFIX = "options.", convertSearchParamsToQueryObject = (e) => {
2030
2159
  const t = {};
2031
2160
  return e.forEach((n, o) => {
2032
2161
  t[o] = n;
2033
2162
  }), t;
2034
- }, we = (e) => {
2163
+ }, getBuilderSearchParams = (e) => {
2035
2164
  if (!e)
2036
2165
  return {};
2037
- const t = Ce(e), n = {};
2166
+ const t = normalizeSearchParams(e), n = {};
2038
2167
  return Object.keys(t).forEach((o) => {
2039
- if (o.startsWith(oe)) {
2040
- const i = o.replace(oe, "").replace(yn, "");
2041
- n[i] = t[o];
2168
+ if (o.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
2169
+ const r = o.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
2170
+ n[r] = t[o];
2042
2171
  }
2043
2172
  }), n;
2044
- }, Sn = () => {
2045
- if (!v())
2173
+ }, getBuilderSearchParamsFromWindow = () => {
2174
+ if (!isBrowser())
2046
2175
  return {};
2047
2176
  const e = new URLSearchParams(window.location.search);
2048
- return we(e);
2049
- }, Ce = (e) => e instanceof URLSearchParams ? xn(e) : e, vn = "v3", K = (e) => {
2177
+ return getBuilderSearchParams(e);
2178
+ }, normalizeSearchParams = (e) => e instanceof URLSearchParams ? convertSearchParamsToQueryObject(e) : e, DEFAULT_API_VERSION = "v3", isPositiveNumber = (e) => typeof e == "number" && !isNaN(e) && e >= 0, generateContentUrl = (e) => {
2050
2179
  let {
2051
2180
  noTraverse: t = !1
2052
2181
  } = e;
2053
2182
  const {
2054
2183
  limit: n = 30,
2055
2184
  userAttributes: o,
2056
- query: i,
2057
- model: r,
2185
+ query: r,
2186
+ model: i,
2058
2187
  apiKey: a,
2059
2188
  includeRefs: c = !0,
2060
2189
  enrich: s,
2061
2190
  locale: u,
2062
- apiVersion: f = vn
2191
+ apiVersion: m = DEFAULT_API_VERSION,
2192
+ fields: h,
2193
+ omit: p,
2194
+ offset: l,
2195
+ cacheSeconds: f,
2196
+ staleCacheSeconds: d,
2197
+ sort: b,
2198
+ includeUnpublished: y
2063
2199
  } = e;
2064
2200
  if (!a)
2065
2201
  throw new Error("Missing API key");
2066
- if (!["v2", "v3"].includes(f))
2067
- throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${f}'`);
2202
+ if (!["v2", "v3"].includes(m))
2203
+ throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${m}'`);
2068
2204
  (e.limit === void 0 || e.limit > 1) && !("noTraverse" in e) && (t = !0);
2069
- const g = new URL(`https://cdn.builder.io/api/${f}/content/${r}?apiKey=${a}&limit=${n}&noTraverse=${t}&includeRefs=${c}${u ? `&locale=${u}` : ""}${s ? `&enrich=${s}` : ""}`), p = {
2070
- ...Sn(),
2071
- ...Ce(e.options || {})
2072
- }, m = W(p);
2073
- for (const h in m)
2074
- g.searchParams.set(h, String(m[h]));
2075
- if (o && g.searchParams.set("userAttributes", JSON.stringify(o)), i) {
2076
- const h = W({
2077
- query: i
2205
+ const g = new URL(`https://cdn.builder.io/api/${m}/content/${i}?apiKey=${a}&limit=${n}&noTraverse=${t}&includeRefs=${c}${u ? `&locale=${u}` : ""}${s ? `&enrich=${s}` : ""}`);
2206
+ if (g.searchParams.set("omit", p || "meta.componentsUsed"), h && g.searchParams.set("fields", h), Number.isFinite(l) && l > -1 && g.searchParams.set("offset", String(Math.floor(l))), typeof y == "boolean" && g.searchParams.set("includeUnpublished", String(y)), f && isPositiveNumber(f) && g.searchParams.set("cacheSeconds", String(f)), d && isPositiveNumber(d) && g.searchParams.set("staleCacheSeconds", String(d)), b) {
2207
+ const S = flatten({
2208
+ sort: b
2209
+ });
2210
+ for (const C in S)
2211
+ g.searchParams.set(C, JSON.stringify(S[C]));
2212
+ }
2213
+ const v = {
2214
+ ...getBuilderSearchParamsFromWindow(),
2215
+ ...normalizeSearchParams(e.options || {})
2216
+ }, x = flatten(v);
2217
+ for (const S in x)
2218
+ g.searchParams.set(S, String(x[S]));
2219
+ if (o && g.searchParams.set("userAttributes", JSON.stringify(o)), r) {
2220
+ const S = flatten({
2221
+ query: r
2078
2222
  });
2079
- for (const d in h)
2080
- g.searchParams.set(d, JSON.stringify(h[d]));
2223
+ for (const C in S)
2224
+ g.searchParams.set(C, JSON.stringify(S[C]));
2081
2225
  }
2082
2226
  return g;
2083
- }, kn = (e) => "results" in e;
2084
- async function H(e) {
2085
- const t = await Ie({
2227
+ }, checkContentHasResults = (e) => "results" in e;
2228
+ async function fetchOneEntry(e) {
2229
+ const t = await fetchEntries({
2086
2230
  ...e,
2087
2231
  limit: 1
2088
2232
  });
2089
2233
  return t && t.results[0] || null;
2090
2234
  }
2091
- const Kn = H, wn = async (e) => {
2092
- const t = K(e);
2093
- return await (await Ut(t.href)).json();
2094
- }, Cn = async (e, t, n = K(e)) => {
2095
- const o = O(e.canTrack);
2235
+ const getContent = fetchOneEntry, _fetchContent = async (e) => {
2236
+ const t = generateContentUrl(e);
2237
+ return await (await fetch$1(t.href)).json();
2238
+ }, _processContentResult = async (e, t, n = generateContentUrl(e)) => {
2239
+ const o = getDefaultCanTrack(e.canTrack);
2096
2240
  if (n.search.includes("preview=")) {
2097
- const r = [];
2241
+ const i = [];
2098
2242
  for (const a of t.results) {
2099
- const c = bn(n.searchParams);
2100
- r.push(c || a);
2243
+ const c = getPreviewContent(n.searchParams);
2244
+ i.push(c || a);
2101
2245
  }
2102
- t.results = r;
2246
+ t.results = i;
2103
2247
  }
2104
- if (!o || !(v() || I === "reactNative"))
2248
+ if (!o || !(isBrowser() || TARGET === "reactNative"))
2105
2249
  return t;
2106
2250
  try {
2107
- const r = [];
2251
+ const i = [];
2108
2252
  for (const a of t.results)
2109
- r.push(await hn({
2253
+ i.push(await handleABTesting({
2110
2254
  item: a,
2111
2255
  canTrack: o
2112
2256
  }));
2113
- t.results = r;
2114
- } catch (r) {
2115
- k.error("Could not process A/B tests. ", r);
2257
+ t.results = i;
2258
+ } catch (i) {
2259
+ logger.error("Could not process A/B tests. ", i);
2116
2260
  }
2117
2261
  return t;
2118
2262
  };
2119
- async function Ie(e) {
2263
+ async function fetchEntries(e) {
2120
2264
  try {
2121
- const t = K(e), n = await wn(e);
2122
- return kn(n) ? Cn(e, n) : (k.error("Error fetching data. ", {
2265
+ const t = generateContentUrl(e), n = await _fetchContent(e);
2266
+ return checkContentHasResults(n) ? _processContentResult(e, n) : (logger.error("Error fetching data. ", {
2123
2267
  url: t,
2124
2268
  content: n,
2125
2269
  options: e
2126
2270
  }), null);
2127
2271
  } catch (t) {
2128
- return k.error("Error fetching data. ", t), null;
2272
+ return logger.error("Error fetching data. ", t), null;
2129
2273
  }
2130
2274
  }
2131
- const Hn = Ie;
2132
- function Dn() {
2133
- return !v() || L() ? !1 : location.search.indexOf("builder.preview=") !== -1;
2275
+ const getAllContent = fetchEntries;
2276
+ function isPreviewing() {
2277
+ return !isBrowser() || isEditing() ? !1 : location.search.indexOf("builder.preview=") !== -1;
2134
2278
  }
2135
- function N(e) {
2136
- return /* @__PURE__ */ l(
2279
+ function InlinedScript(e) {
2280
+ return /* @__PURE__ */ jsx(
2137
2281
  "script",
2138
2282
  {
2139
2283
  dangerouslySetInnerHTML: { __html: e.scriptStr },
@@ -2141,38 +2285,38 @@ function N(e) {
2141
2285
  }
2142
2286
  );
2143
2287
  }
2144
- function ie(e) {
2145
- var i, r, a, c, s, u, f, g, p;
2146
- const t = pt({
2288
+ function ContentComponent(e) {
2289
+ var r, i, a, c, s, u, m, h, p;
2290
+ const t = getRenderContentScriptString({
2147
2291
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
2148
- variationId: (i = e.content) == null ? void 0 : i.testVariationId,
2292
+ variationId: (r = e.content) == null ? void 0 : r.testVariationId,
2149
2293
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
2150
- contentId: (r = e.content) == null ? void 0 : r.id
2294
+ contentId: (i = e.content) == null ? void 0 : i.id
2151
2295
  }), n = [
2152
- ...X(),
2296
+ ...getDefaultRegisteredComponents(),
2153
2297
  // While this `components` object is deprecated, we must maintain support for it.
2154
2298
  // Since users are able to override our default components, we need to make sure that we do not break such
2155
2299
  // existing usage.
2156
2300
  // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
2157
2301
  // which is the new standard way of providing custom components, and must therefore take precedence.
2158
- ...Q,
2302
+ ...components,
2159
2303
  ...e.customComponents || []
2160
2304
  ].reduce(
2161
- (m, { component: h, ...d }) => ({
2162
- ...m,
2305
+ (l, { component: f, ...d }) => ({
2306
+ ...l,
2163
2307
  [d.name]: {
2164
- component: h,
2165
- ...F(d)
2308
+ component: f,
2309
+ ...serializeComponentInfo(d)
2166
2310
  }
2167
2311
  }),
2168
2312
  {}
2169
2313
  ), o = {
2170
- content: Nt({
2314
+ content: getContentInitialValue({
2171
2315
  content: e.content,
2172
2316
  data: e.data
2173
2317
  }),
2174
2318
  localState: void 0,
2175
- rootState: Wt({
2319
+ rootState: getContextStateInitialValue({
2176
2320
  content: e.content,
2177
2321
  data: e.data,
2178
2322
  locale: e.locale
@@ -2182,25 +2326,25 @@ function ie(e) {
2182
2326
  apiKey: e.apiKey,
2183
2327
  apiVersion: e.apiVersion,
2184
2328
  componentInfos: [
2185
- ...X(),
2329
+ ...getDefaultRegisteredComponents(),
2186
2330
  // While this `components` object is deprecated, we must maintain support for it.
2187
2331
  // Since users are able to override our default components, we need to make sure that we do not break such
2188
2332
  // existing usage.
2189
2333
  // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
2190
2334
  // which is the new standard way of providing custom components, and must therefore take precedence.
2191
- ...Q,
2335
+ ...components,
2192
2336
  ...e.customComponents || []
2193
2337
  ].reduce(
2194
- (m, { component: h, ...d }) => ({
2195
- ...m,
2196
- [d.name]: F(d)
2338
+ (l, { component: f, ...d }) => ({
2339
+ ...l,
2340
+ [d.name]: serializeComponentInfo(d)
2197
2341
  }),
2198
2342
  {}
2199
2343
  ),
2200
2344
  inheritedStyles: {}
2201
2345
  };
2202
- return /* @__PURE__ */ w(
2203
- Ue,
2346
+ return /* @__PURE__ */ jsxs(
2347
+ EnableEditor,
2204
2348
  {
2205
2349
  content: e.content,
2206
2350
  model: e.model,
@@ -2214,19 +2358,19 @@ function ie(e) {
2214
2358
  showContent: e.showContent,
2215
2359
  builderContextSignal: o,
2216
2360
  children: [
2217
- e.isSsrAbTest ? /* @__PURE__ */ l(x, { children: /* @__PURE__ */ l(N, { scriptStr: t }) }) : null,
2218
- /* @__PURE__ */ l(x, { children: /* @__PURE__ */ l(
2219
- Ot,
2361
+ e.isSsrAbTest ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedScript, { scriptStr: t }) }) : null,
2362
+ /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
2363
+ ContentStyles,
2220
2364
  {
2221
2365
  contentId: (a = o.content) == null ? void 0 : a.id,
2222
2366
  cssCode: (s = (c = o.content) == null ? void 0 : c.data) == null ? void 0 : s.cssCode,
2223
- customFonts: (f = (u = o.content) == null ? void 0 : u.data) == null ? void 0 : f.customFonts
2367
+ customFonts: (m = (u = o.content) == null ? void 0 : u.data) == null ? void 0 : m.customFonts
2224
2368
  }
2225
2369
  ) }),
2226
- /* @__PURE__ */ l(
2227
- _,
2370
+ /* @__PURE__ */ jsx(
2371
+ Blocks,
2228
2372
  {
2229
- blocks: (p = (g = o.content) == null ? void 0 : g.data) == null ? void 0 : p.blocks,
2373
+ blocks: (p = (h = o.content) == null ? void 0 : h.data) == null ? void 0 : p.blocks,
2230
2374
  context: o,
2231
2375
  registeredComponents: n
2232
2376
  }
@@ -2235,45 +2379,45 @@ function ie(e) {
2235
2379
  }
2236
2380
  );
2237
2381
  }
2238
- function Te(e) {
2239
- var r, a, c;
2240
- const t = ut({
2241
- canTrack: O(e.canTrack),
2382
+ function ContentVariants(e) {
2383
+ var i, a, c;
2384
+ const t = checkShouldRunVariants({
2385
+ canTrack: getDefaultCanTrack(e.canTrack),
2242
2386
  content: e.content
2243
2387
  }), n = function() {
2244
2388
  var u;
2245
- return gt(
2246
- R(e.content).map((f) => ({
2247
- id: f.testVariationId,
2248
- testRatio: f.testRatio
2389
+ return getVariantsScriptString(
2390
+ getVariants(e.content).map((m) => ({
2391
+ id: m.testVariationId,
2392
+ testRatio: m.testRatio
2249
2393
  })),
2250
2394
  ((u = e.content) == null ? void 0 : u.id) || ""
2251
2395
  );
2252
2396
  }, o = function() {
2253
- return R(e.content).map((u) => `.variant-${u.testVariationId} { display: none; } `).join("");
2254
- }, i = function() {
2397
+ return getVariants(e.content).map((u) => `.variant-${u.testVariationId} { display: none; } `).join("");
2398
+ }, r = function() {
2255
2399
  var u;
2256
2400
  return t ? {
2257
2401
  ...e.content,
2258
2402
  testVariationId: (u = e.content) == null ? void 0 : u.id
2259
- } : fn({
2403
+ } : handleABTestingSync({
2260
2404
  item: e.content,
2261
- canTrack: O(e.canTrack)
2405
+ canTrack: getDefaultCanTrack(e.canTrack)
2262
2406
  });
2263
2407
  };
2264
- return /* @__PURE__ */ w(x, { children: [
2265
- !e.__isNestedRender && I !== "reactNative" ? /* @__PURE__ */ l(x, { children: /* @__PURE__ */ l(N, { scriptStr: ht() }) }) : null,
2266
- t ? /* @__PURE__ */ w(x, { children: [
2267
- /* @__PURE__ */ l(
2268
- V,
2408
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2409
+ !e.__isNestedRender && TARGET !== "reactNative" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedScript, { scriptStr: getScriptString() }) }) : null,
2410
+ t ? /* @__PURE__ */ jsxs(Fragment, { children: [
2411
+ /* @__PURE__ */ jsx(
2412
+ InlinedStyles,
2269
2413
  {
2270
- id: `variants-styles-${(r = e.content) == null ? void 0 : r.id}`,
2414
+ id: `variants-styles-${(i = e.content) == null ? void 0 : i.id}`,
2271
2415
  styles: o()
2272
2416
  }
2273
2417
  ),
2274
- /* @__PURE__ */ l(N, { scriptStr: n() }),
2275
- (a = R(e.content)) == null ? void 0 : a.map((s) => /* @__PURE__ */ l(
2276
- ie,
2418
+ /* @__PURE__ */ jsx(InlinedScript, { scriptStr: n() }),
2419
+ (a = getVariants(e.content)) == null ? void 0 : a.map((s) => /* @__PURE__ */ jsx(
2420
+ ContentComponent,
2277
2421
  {
2278
2422
  content: s,
2279
2423
  showContent: !1,
@@ -2293,10 +2437,10 @@ function Te(e) {
2293
2437
  s.testVariationId
2294
2438
  ))
2295
2439
  ] }) : null,
2296
- /* @__PURE__ */ l(
2297
- ie,
2440
+ /* @__PURE__ */ jsx(
2441
+ ContentComponent,
2298
2442
  {
2299
- content: i(),
2443
+ content: r(),
2300
2444
  classNameProp: `variant-${(c = e.content) == null ? void 0 : c.id}`,
2301
2445
  showContent: !0,
2302
2446
  model: e.model,
@@ -2314,13 +2458,13 @@ function Te(e) {
2314
2458
  )
2315
2459
  ] });
2316
2460
  }
2317
- const In = async ({
2461
+ const fetchSymbolContent = async ({
2318
2462
  builderContextValue: e,
2319
2463
  symbol: t
2320
2464
  }) => {
2321
2465
  if (t != null && t.model && // This is a hack, we should not need to check for this, but it is needed for Svelte.
2322
2466
  (e != null && e.apiKey))
2323
- return H({
2467
+ return fetchOneEntry({
2324
2468
  model: t.model,
2325
2469
  apiKey: e.apiKey,
2326
2470
  apiVersion: e.apiVersion,
@@ -2330,11 +2474,11 @@ const In = async ({
2330
2474
  }
2331
2475
  }
2332
2476
  }).catch((n) => {
2333
- k.error("Could not fetch symbol content: ", n);
2477
+ logger.error("Could not fetch symbol content: ", n);
2334
2478
  });
2335
2479
  };
2336
- async function Tn(e) {
2337
- var o, i, r, a;
2480
+ async function Symbol$1(e) {
2481
+ var o, r, i, a;
2338
2482
  const t = function() {
2339
2483
  var s, u;
2340
2484
  return [
@@ -2343,12 +2487,12 @@ async function Tn(e) {
2343
2487
  (s = e.symbol) != null && s.inline ? "builder-inline-symbol" : void 0,
2344
2488
  (u = e.symbol) != null && u.dynamic || e.dynamic ? "builder-dynamic-symbol" : void 0
2345
2489
  ].filter(Boolean).join(" ");
2346
- }, n = ((o = e.symbol) == null ? void 0 : o.content) || await In({
2490
+ }, n = ((o = e.symbol) == null ? void 0 : o.content) || await fetchSymbolContent({
2347
2491
  symbol: e.symbol,
2348
2492
  builderContextValue: e.builderContext
2349
2493
  });
2350
- return /* @__PURE__ */ l("div", { ...e.attributes, className: t(), children: /* @__PURE__ */ l(
2351
- Te,
2494
+ return /* @__PURE__ */ jsx("div", { ...e.attributes, className: t(), children: /* @__PURE__ */ jsx(
2495
+ ContentVariants,
2352
2496
  {
2353
2497
  __isNestedRender: !0,
2354
2498
  apiVersion: e.builderContext.apiVersion,
@@ -2356,29 +2500,29 @@ async function Tn(e) {
2356
2500
  context: e.builderContext.context,
2357
2501
  customComponents: Object.values(e.builderComponents),
2358
2502
  data: {
2359
- ...(i = e.symbol) == null ? void 0 : i.data,
2503
+ ...(r = e.symbol) == null ? void 0 : r.data,
2360
2504
  ...e.builderContext.localState,
2361
- ...(r = n == null ? void 0 : n.data) == null ? void 0 : r.state
2505
+ ...(i = n == null ? void 0 : n.data) == null ? void 0 : i.state
2362
2506
  },
2363
2507
  model: (a = e.symbol) == null ? void 0 : a.model,
2364
2508
  content: n
2365
2509
  }
2366
2510
  ) });
2367
2511
  }
2368
- const zn = _, qn = Te, re = {};
2369
- function Gn(e) {
2370
- if (v()) {
2371
- Object.assign(re, e);
2512
+ const RenderBlocks = Blocks, RenderContent = ContentVariants, settings = {};
2513
+ function setEditorSettings(e) {
2514
+ if (isBrowser()) {
2515
+ Object.assign(settings, e);
2372
2516
  const t = {
2373
2517
  type: "builder.settingsChange",
2374
- data: re
2518
+ data: settings
2375
2519
  };
2376
2520
  parent.postMessage(t, "*");
2377
2521
  }
2378
2522
  }
2379
- const Jn = async (e) => {
2380
- var o, i, r;
2381
- const t = e.path || ((o = e.url) == null ? void 0 : o.pathname) || ((i = e.userAttributes) == null ? void 0 : i.urlPath), n = {
2523
+ const fetchBuilderProps = async (e) => {
2524
+ var o, r, i;
2525
+ const t = e.path || ((o = e.url) == null ? void 0 : o.pathname) || ((r = e.userAttributes) == null ? void 0 : r.urlPath), n = {
2382
2526
  ...e,
2383
2527
  apiKey: e.apiKey,
2384
2528
  model: e.model || "page",
@@ -2388,49 +2532,48 @@ const Jn = async (e) => {
2388
2532
  urlPath: t
2389
2533
  } : {}
2390
2534
  },
2391
- options: we(e.searchParams || ((r = e.url) == null ? void 0 : r.searchParams) || e.options)
2535
+ options: getBuilderSearchParams(e.searchParams || ((i = e.url) == null ? void 0 : i.searchParams) || e.options)
2392
2536
  };
2393
2537
  return {
2394
2538
  apiKey: n.apiKey,
2395
2539
  model: n.model,
2396
- content: await H(n)
2540
+ content: await fetchOneEntry(n)
2397
2541
  };
2398
2542
  };
2399
2543
  export {
2400
- Cn as A,
2401
- _ as B,
2402
- Te as C,
2403
- we as D,
2404
- Mn as E,
2405
- Jn as F,
2406
- zn as R,
2407
- Tn as S,
2408
- Ct as T,
2409
- nn as _,
2410
- it as a,
2411
- On as b,
2412
- Wn as c,
2413
- Nn as d,
2414
- v as e,
2415
- O as f,
2416
- Fn as g,
2417
- Dn as h,
2418
- L as i,
2419
- M as j,
2420
- jn as k,
2421
- k as l,
2422
- A as m,
2423
- Ln as n,
2424
- H as o,
2425
- Ut as p,
2426
- pn as q,
2427
- Un as r,
2428
- _n as s,
2429
- qn as t,
2430
- st as u,
2431
- rn as v,
2432
- Gn as w,
2433
- Ie as x,
2434
- Hn as y,
2435
- Kn as z
2544
+ getBuilderSearchParams as A,
2545
+ Blocks as B,
2546
+ ContentVariants as C,
2547
+ track as D,
2548
+ fetchBuilderProps as E,
2549
+ RenderBlocks as R,
2550
+ Symbol$1 as S,
2551
+ Text as T,
2552
+ _track as _,
2553
+ getBlockActions as a,
2554
+ getSrcSet as b,
2555
+ isJsScript as c,
2556
+ isBrowser as d,
2557
+ getDefaultCanTrack as e,
2558
+ isPreviewing as f,
2559
+ getBlockProperties as g,
2560
+ evaluate as h,
2561
+ isEditing as i,
2562
+ getInteractionPropertiesForEvent as j,
2563
+ fastClone as k,
2564
+ logger as l,
2565
+ createRegisterComponentMessage as m,
2566
+ fetchOneEntry as n,
2567
+ fetch$1 as o,
2568
+ init as p,
2569
+ RenderContent as q,
2570
+ registerInsertMenu as r,
2571
+ setupBrowserForEditing as s,
2572
+ Columns as t,
2573
+ register as u,
2574
+ setEditorSettings as v,
2575
+ fetchEntries as w,
2576
+ getAllContent as x,
2577
+ getContent as y,
2578
+ _processContentResult as z
2436
2579
  };