@builder.io/sdk-react 4.2.0 → 4.2.1

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 (72) hide show
  1. package/lib/browser/blocks-exports.cjs +8 -8
  2. package/lib/browser/blocks-exports.mjs +100 -98
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +6 -5
  5. package/lib/browser/server-entry-4cf669a1.cjs +2 -0
  6. package/lib/browser/{server-entry-065ec411.js → server-entry-5e98a993.js} +24 -13
  7. package/lib/browser/server-entry.cjs +1 -1
  8. package/lib/browser/server-entry.mjs +7 -6
  9. package/lib/edge/{accordion-c239771d.cjs → accordion-4bab42b1.cjs} +1 -1
  10. package/lib/edge/{accordion-79f6d62c.js → accordion-a8a363e4.js} +1 -1
  11. package/lib/edge/{blocks-56f79850.cjs → blocks-d07d0261.cjs} +1 -1
  12. package/lib/edge/{blocks-3cb3a9cd.js → blocks-e1f5b0d0.js} +2 -2
  13. package/lib/edge/blocks-exports.cjs +1 -1
  14. package/lib/edge/blocks-exports.mjs +2 -2
  15. package/lib/edge/{button-759b43fb.cjs → button-6734c0bb.cjs} +1 -1
  16. package/lib/edge/{button-6dee05c9.js → button-bbcadacf.js} +2 -2
  17. package/lib/edge/{columns-a29ec0ac.cjs → columns-821cba14.cjs} +1 -1
  18. package/lib/edge/{columns-2743498a.js → columns-cf3081c6.js} +3 -3
  19. package/lib/edge/{content-variants-4d5a1e3c.js → content-variants-a704e35c.js} +12 -12
  20. package/lib/edge/{content-variants-bdf1748b.cjs → content-variants-ec180883.cjs} +2 -2
  21. package/lib/edge/{custom-code-6129bd8c.cjs → custom-code-8fcaa31e.cjs} +1 -1
  22. package/lib/edge/{custom-code-8034fac0.js → custom-code-f6c30129.js} +1 -1
  23. package/lib/edge/{embed-f5b10eeb.js → embed-3c0b5564.js} +1 -1
  24. package/lib/edge/{embed-b2ea5150.cjs → embed-666d3cc4.cjs} +1 -1
  25. package/lib/edge/form-51f639ab.cjs +1 -0
  26. package/lib/edge/{form-14942d4f.js → form-8b068721.js} +9 -7
  27. package/lib/edge/{get-class-prop-name-7e739c9f.cjs → get-class-prop-name-2869a960.cjs} +1 -1
  28. package/lib/edge/{get-class-prop-name-f6a63f4a.js → get-class-prop-name-d6d821d6.js} +1 -1
  29. package/lib/edge/{img-f33a2e42.cjs → img-b04b9b6d.cjs} +1 -1
  30. package/lib/edge/{img-ba2ef9ee.js → img-dfbd4080.js} +1 -1
  31. package/lib/edge/index.cjs +1 -1
  32. package/lib/edge/index.mjs +4 -3
  33. package/lib/edge/{input-7089e95f.js → input-665ef328.js} +1 -1
  34. package/lib/edge/{input-c2f95825.cjs → input-d31d6451.cjs} +1 -1
  35. package/lib/edge/{personalization-container-794b3939.cjs → personalization-container-d12566e8.cjs} +1 -1
  36. package/lib/edge/{personalization-container-eb1ecef2.js → personalization-container-e784836e.js} +4 -4
  37. package/lib/edge/{select-8f01592a.js → select-5fe49bd4.js} +1 -1
  38. package/lib/edge/{select-af0bb9fe.cjs → select-c3085265.cjs} +1 -1
  39. package/lib/edge/server-entry-acf5ce7d.cjs +2 -0
  40. package/lib/edge/{server-entry-7c65c9a8.js → server-entry-c9d5300f.js} +22 -11
  41. package/lib/edge/server-entry.cjs +1 -1
  42. package/lib/edge/server-entry.mjs +7 -6
  43. package/lib/edge/{slot-2638fd6d.js → slot-a17ee2d7.js} +3 -3
  44. package/lib/edge/{slot-db37860e.cjs → slot-cbbbb02e.cjs} +1 -1
  45. package/lib/edge/{symbol-7faca118.js → symbol-9f960685.js} +2 -2
  46. package/lib/edge/{symbol-630b9a57.cjs → symbol-b56b5675.cjs} +1 -1
  47. package/lib/edge/{tabs-2eee6422.js → tabs-26ac5b2f.js} +3 -3
  48. package/lib/edge/{tabs-502123df.cjs → tabs-bf6643d7.cjs} +1 -1
  49. package/lib/node/blocks-exports.cjs +8 -8
  50. package/lib/node/blocks-exports.mjs +102 -100
  51. package/lib/node/index.cjs +1 -1
  52. package/lib/node/index.mjs +6 -5
  53. package/lib/node/init.cjs +1 -1
  54. package/lib/node/init.mjs +3 -3
  55. package/lib/node/{server-entry-581dd491.js → server-entry-48724189.js} +24 -13
  56. package/lib/node/server-entry-562c0663.cjs +2 -0
  57. package/lib/node/server-entry.cjs +1 -1
  58. package/lib/node/server-entry.mjs +7 -6
  59. package/lib/node/{setIvm-2eb44b9d.cjs → setIvm-3b6199a0.cjs} +1 -1
  60. package/lib/node/{setIvm-8d02dc72.js → setIvm-a7aba6d2.js} +1 -1
  61. package/lib/node/setIvm.cjs +1 -1
  62. package/lib/node/setIvm.mjs +2 -2
  63. package/lib/node/{should-force-browser-runtime-in-node-ed3fa1f9.cjs → should-force-browser-runtime-in-node-cbe0ef14.cjs} +1 -1
  64. package/lib/node/{should-force-browser-runtime-in-node-f461467e.js → should-force-browser-runtime-in-node-fdc70f22.js} +1 -1
  65. package/package.json +1 -1
  66. package/types/constants/sdk-version.d.ts +1 -1
  67. package/types/functions/register.d.ts +18 -0
  68. package/types/server-index.d.ts +1 -1
  69. package/lib/browser/server-entry-09953757.cjs +0 -2
  70. package/lib/edge/form-26c3a03e.cjs +0 -1
  71. package/lib/edge/server-entry-142a50e9.cjs +0 -2
  72. package/lib/node/server-entry-375d06e8.cjs +0 -2
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { TARGET as O, isEditing as L, isBrowser as M, getUserAttributes as ct, checkIsDefined as ae, logger as J, isPreviewing as se, userAttributesService as Ce, getDefaultCanTrack as Z, logFetch as Fe, setupBrowserForEditing as ut, createRegisterComponentMessage as dt, getCookieSync as mt, _track as Te, fetchOneEntry as Le, createEditorListener as ft, serializeIncludingFunctions as Ie, handleABTestingSync as ht } from "./server-entry-065ec411.js";
3
- import { setClientUserAttributes as Hi } from "./server-entry-065ec411.js";
2
+ import { TARGET as O, isEditing as L, isBrowser as M, getUserAttributes as ct, checkIsDefined as ae, logger as J, isPreviewing as se, userAttributesService as Ce, getDefaultCanTrack as Z, logFetch as Fe, setupBrowserForEditing as ut, createRegisterComponentMessage as dt, getCookieSync as mt, _track as Te, fetchOneEntry as Le, createEditorListener as ft, serializeIncludingFunctions as Ie, handleABTestingSync as ht } from "./server-entry-5e98a993.js";
3
+ import { setClientUserAttributes as Hi } from "./server-entry-5e98a993.js";
4
4
  import { jsx as s, Fragment as R, jsxs as $ } from "react/jsx-runtime";
5
5
  import * as gt from "react";
6
6
  import { createContext as _e, useEffect as V, useState as C, useRef as H, useContext as we, createElement as Ue } from "react";
@@ -624,7 +624,7 @@ function Yt(e) {
624
624
  return ae(i.hide) ? !i.hide : ae(i.show) ? i.show : !0;
625
625
  }
626
626
  function n() {
627
- var k, A, T, w, g;
627
+ var k, A, T, w, h;
628
628
  const i = e.block, r = i.responsiveStyles, o = e.context.content, a = et(
629
629
  ((k = o == null ? void 0 : o.meta) == null ? void 0 : k.breakpoints) || {}
630
630
  ), l = !!((T = (A = o == null ? void 0 : o.meta) == null ? void 0 : A.breakpoints) != null && T.xsmall), c = r == null ? void 0 : r.large, u = r == null ? void 0 : r.medium, f = r == null ? void 0 : r.small, b = r == null ? void 0 : r.xsmall, m = i.id;
@@ -640,7 +640,7 @@ function Yt(e) {
640
640
  "medium",
641
641
  a
642
642
  )
643
- }) : "", h = f ? Y({
643
+ }) : "", g = f ? Y({
644
644
  className: m,
645
645
  styles: f,
646
646
  mediaQuery: de(
@@ -657,7 +657,7 @@ function Yt(e) {
657
657
  }) : "", y = i.animations && i.animations.find((x) => x.trigger === "hover");
658
658
  let S = "";
659
659
  if (y) {
660
- const x = ((g = (w = y.steps) == null ? void 0 : w[1]) == null ? void 0 : g.styles) || {};
660
+ const x = ((h = (w = y.steps) == null ? void 0 : w[1]) == null ? void 0 : h.styles) || {};
661
661
  S = Y({
662
662
  className: `${m}:hover`,
663
663
  styles: {
@@ -672,7 +672,7 @@ function Yt(e) {
672
672
  return [
673
673
  v,
674
674
  d,
675
- h,
675
+ g,
676
676
  p,
677
677
  S
678
678
  ].join(" ");
@@ -896,10 +896,10 @@ function ue(e) {
896
896
  update: !1
897
897
  }));
898
898
  function r() {
899
- var h;
899
+ var g;
900
900
  if (n.value && !n.update && !se())
901
901
  return n.value;
902
- const d = (h = e.block.repeat) != null && h.collection ? e.block : Ot({
902
+ const d = (g = e.block.repeat) != null && g.collection ? e.block : Ot({
903
903
  block: e.block,
904
904
  localState: e.context.localState,
905
905
  rootState: e.context.rootState,
@@ -916,8 +916,8 @@ function ue(e) {
916
916
  });
917
917
  }
918
918
  function a() {
919
- var h;
920
- return e.block.tagName === "a" || ((h = r().properties) == null ? void 0 : h.href) || r().href ? e.linkComponent || "a" : e.block.tagName || "div";
919
+ var g;
920
+ return e.block.tagName === "a" || ((g = r().properties) == null ? void 0 : g.href) || r().href ? e.linkComponent || "a" : e.block.tagName || "div";
921
921
  }
922
922
  function l() {
923
923
  var p, y;
@@ -927,14 +927,14 @@ function ue(e) {
927
927
  return ("show" in r() ? r().show : !0) && !d;
928
928
  }
929
929
  function c() {
930
- var h, p;
931
- return !((h = o == null ? void 0 : o()) != null && h.component) && !t() ? (p = r().children) != null ? p : [] : [];
930
+ var g, p;
931
+ return !((g = o == null ? void 0 : o()) != null && g.component) && !t() ? (p = r().children) != null ? p : [] : [];
932
932
  }
933
933
  function u() {
934
- var d, h, p, y;
934
+ var d, g, p, y;
935
935
  return {
936
936
  blockChildren: (d = r().children) != null ? d : [],
937
- componentRef: (h = o == null ? void 0 : o()) == null ? void 0 : h.component,
937
+ componentRef: (g = o == null ? void 0 : o()) == null ? void 0 : g.component,
938
938
  componentOptions: {
939
939
  ...Rt(r(), e.context),
940
940
  ...Gt(o(), r()),
@@ -955,9 +955,9 @@ function ue(e) {
955
955
  };
956
956
  }
957
957
  return V(() => {
958
- const d = r().id, h = r().animations;
959
- h && d && Lt(
960
- h.map((p) => ({
958
+ const d = r().id, g = r().animations;
959
+ g && d && Lt(
960
+ g.map((p) => ({
961
961
  ...p,
962
962
  elementId: d
963
963
  }))
@@ -966,7 +966,7 @@ function ue(e) {
966
966
  n.update = !0;
967
967
  }), /* @__PURE__ */ s(R, { children: l() ? /* @__PURE__ */ $(R, { children: [
968
968
  /* @__PURE__ */ s(Yt, { block: r(), context: e.context }),
969
- (f = o == null ? void 0 : o()) != null && f.noWrap ? t() ? /* @__PURE__ */ s(R, { children: (v = t()) == null ? void 0 : v.map((d, h) => /* @__PURE__ */ s(
969
+ (f = o == null ? void 0 : o()) != null && f.noWrap ? t() ? /* @__PURE__ */ s(R, { children: (v = t()) == null ? void 0 : v.map((d, g) => /* @__PURE__ */ s(
970
970
  Ve,
971
971
  {
972
972
  repeatContext: d.context,
@@ -974,7 +974,7 @@ function ue(e) {
974
974
  registeredComponents: e.registeredComponents,
975
975
  linkComponent: e.linkComponent
976
976
  },
977
- Re(h)
977
+ Re(g)
978
978
  )) }) : /* @__PURE__ */ s(
979
979
  Pe,
980
980
  {
@@ -988,7 +988,7 @@ function ue(e) {
988
988
  includeBlockProps: u().includeBlockProps,
989
989
  isInteractive: u().isInteractive
990
990
  }
991
- ) : /* @__PURE__ */ s(R, { children: t() ? /* @__PURE__ */ s(R, { children: (m = t()) == null ? void 0 : m.map((d, h) => /* @__PURE__ */ s(
991
+ ) : /* @__PURE__ */ s(R, { children: t() ? /* @__PURE__ */ s(R, { children: (m = t()) == null ? void 0 : m.map((d, g) => /* @__PURE__ */ s(
992
992
  Ve,
993
993
  {
994
994
  repeatContext: d.context,
@@ -996,7 +996,7 @@ function ue(e) {
996
996
  registeredComponents: e.registeredComponents,
997
997
  linkComponent: e.linkComponent
998
998
  },
999
- Re(h)
999
+ Re(g)
1000
1000
  )) }) : /* @__PURE__ */ $(
1001
1001
  rn,
1002
1002
  {
@@ -1132,7 +1132,7 @@ function U(e) {
1132
1132
  }
1133
1133
  const cn = (e) => `builder-columns ${e}-breakpoints`;
1134
1134
  function un(e) {
1135
- var h, p;
1135
+ var g, p;
1136
1136
  function t() {
1137
1137
  return typeof e.space == "number" ? e.space || 0 : 20;
1138
1138
  }
@@ -1257,7 +1257,7 @@ function un(e) {
1257
1257
  /* @__PURE__ */ $(
1258
1258
  "div",
1259
1259
  {
1260
- className: cn((h = e.builderBlock) == null ? void 0 : h.id) + " div-0369db37",
1260
+ className: cn((g = e.builderBlock) == null ? void 0 : g.id) + " div-0369db37",
1261
1261
  style: f(),
1262
1262
  children: [
1263
1263
  /* @__PURE__ */ s(
@@ -1461,28 +1461,28 @@ function bn(e, t, n, i) {
1461
1461
  operator: v,
1462
1462
  value: p
1463
1463
  }));
1464
- const h = u[m];
1465
- if (Array.isArray(h))
1466
- return h.includes(d);
1464
+ const g = u[m];
1465
+ if (Array.isArray(g))
1466
+ return g.includes(d);
1467
1467
  switch (v) {
1468
1468
  case "is":
1469
- return h === d;
1469
+ return g === d;
1470
1470
  case "isNot":
1471
- return h !== d;
1471
+ return g !== d;
1472
1472
  case "contains":
1473
- return (r(h) || Array.isArray(h)) && h.includes(String(d));
1473
+ return (r(g) || Array.isArray(g)) && g.includes(String(d));
1474
1474
  case "startsWith":
1475
- return r(h) && h.startsWith(String(d));
1475
+ return r(g) && g.startsWith(String(d));
1476
1476
  case "endsWith":
1477
- return r(h) && h.endsWith(String(d));
1477
+ return r(g) && g.endsWith(String(d));
1478
1478
  case "greaterThan":
1479
- return o(h) && o(d) && h > d;
1479
+ return o(g) && o(d) && g > d;
1480
1480
  case "lessThan":
1481
- return o(h) && o(d) && h < d;
1481
+ return o(g) && o(d) && g < d;
1482
1482
  case "greaterThanOrEqualTo":
1483
- return o(h) && o(d) && h >= d;
1483
+ return o(g) && o(d) && g >= d;
1484
1484
  case "lessThanOrEqualTo":
1485
- return o(h) && o(d) && h <= d;
1485
+ return o(g) && o(d) && g <= d;
1486
1486
  default:
1487
1487
  return !1;
1488
1488
  }
@@ -1856,7 +1856,7 @@ function En(e) {
1856
1856
  cursor: "pointer"
1857
1857
  };
1858
1858
  return Object.fromEntries(
1859
- Object.entries(v).filter(([d, h]) => h !== void 0)
1859
+ Object.entries(v).filter(([d, g]) => g !== void 0)
1860
1860
  );
1861
1861
  }
1862
1862
  function a(m) {
@@ -2362,7 +2362,7 @@ function j(e) {
2362
2362
  );
2363
2363
  }
2364
2364
  function Wn(e) {
2365
- var S, k, A, T, w, g, x, E, N, F, _, P, D;
2365
+ var S, k, A, T, w, h, x, E, N, F, _, P, D;
2366
2366
  const t = H(null), [n, i] = C(
2367
2367
  () => Ce.getUserAttributes()
2368
2368
  ), [r, o] = C(
@@ -2398,7 +2398,7 @@ function Wn(e) {
2398
2398
  [z()]: `builder-personalization-container ${e.attributes[z()] || ""}`
2399
2399
  };
2400
2400
  }
2401
- function h() {
2401
+ function g() {
2402
2402
  return (e.variants || []).filter((I) => {
2403
2403
  var B, W, K, q;
2404
2404
  return bn(
@@ -2420,7 +2420,7 @@ function Wn(e) {
2420
2420
  variants: e.variants,
2421
2421
  fallbackBlocks: (I = e.builderBlock) == null ? void 0 : I.children,
2422
2422
  isHydrated: m,
2423
- filteredVariants: h(),
2423
+ filteredVariants: g(),
2424
2424
  previewingIndex: e.previewingIndex
2425
2425
  });
2426
2426
  }
@@ -2444,7 +2444,7 @@ function Wn(e) {
2444
2444
  }
2445
2445
  );
2446
2446
  if (!(L() || se())) {
2447
- const W = h()[0];
2447
+ const W = g()[0];
2448
2448
  t.current && (t.current.dispatchEvent(
2449
2449
  new CustomEvent("builder.variantLoaded", {
2450
2450
  detail: {
@@ -2499,7 +2499,7 @@ function Wn(e) {
2499
2499
  /* @__PURE__ */ s(
2500
2500
  j,
2501
2501
  {
2502
- nonce: ((g = e.builderContext) == null ? void 0 : g.nonce) || "",
2502
+ nonce: ((h = e.builderContext) == null ? void 0 : h.nonce) || "",
2503
2503
  scriptStr: a,
2504
2504
  id: `variants-visibility-script-${(x = e.builderBlock) == null ? void 0 : x.id}`
2505
2505
  }
@@ -3293,63 +3293,65 @@ function Xn(e) {
3293
3293
  return;
3294
3294
  }
3295
3295
  b.preventDefault();
3296
- const d = b.currentTarget || b.target, h = e.customHeaders || {};
3296
+ const d = b.currentTarget || b.target, g = e.customHeaders || {};
3297
3297
  let p;
3298
- const y = new FormData(d), S = Array.from(d.querySelectorAll("input,select,textarea")).filter((g) => !!g.name).map((g) => {
3298
+ const y = new FormData(d), S = Array.from(d.querySelectorAll("input,select,textarea")).filter((h) => !!h.name).filter(
3299
+ (h) => !!h.name && (h.type !== "radio" || h.checked)
3300
+ ).map((h) => {
3299
3301
  let x;
3300
- const E = g.name;
3301
- if (g instanceof HTMLInputElement)
3302
- if (g.type === "radio") {
3303
- if (g.checked)
3304
- return x = g.name, {
3302
+ const E = h.name;
3303
+ if (h instanceof HTMLInputElement)
3304
+ if (h.type === "radio") {
3305
+ if (h.checked)
3306
+ return x = h.value, {
3305
3307
  key: E,
3306
3308
  value: x
3307
3309
  };
3308
- } else if (g.type === "checkbox")
3309
- x = g.checked;
3310
- else if (g.type === "number" || g.type === "range") {
3311
- const N = g.valueAsNumber;
3310
+ } else if (h.type === "checkbox")
3311
+ x = h.checked;
3312
+ else if (h.type === "number" || h.type === "range") {
3313
+ const N = h.valueAsNumber;
3312
3314
  isNaN(N) || (x = N);
3313
3315
  } else
3314
- g.type === "file" ? x = g.files : x = g.value;
3316
+ h.type === "file" ? x = h.files : x = h.value;
3315
3317
  else
3316
- x = g.value;
3318
+ x = h.value;
3317
3319
  return {
3318
3320
  key: E,
3319
3321
  value: x
3320
3322
  };
3321
3323
  });
3322
3324
  let k = e.contentType;
3323
- if (e.sendSubmissionsTo === "email" && (k = "multipart/form-data"), Array.from(S).forEach(({ value: g }) => {
3324
- (g instanceof File || Array.isArray(g) && g[0] instanceof File || g instanceof FileList) && (k = "multipart/form-data");
3325
+ if (e.sendSubmissionsTo === "email" && (k = "multipart/form-data"), Array.from(S).forEach(({ value: h }) => {
3326
+ (h instanceof File || Array.isArray(h) && h[0] instanceof File || h instanceof FileList) && (k = "multipart/form-data");
3325
3327
  }), k !== "application/json")
3326
3328
  p = y;
3327
3329
  else {
3328
- const g = {};
3330
+ const h = {};
3329
3331
  Array.from(S).forEach(({ value: x, key: E }) => {
3330
- ze(g, E, x);
3331
- }), p = JSON.stringify(g);
3332
+ ze(h, E, x);
3333
+ }), p = JSON.stringify(h);
3332
3334
  }
3333
- k && k !== "multipart/form-data" && (m && ((v = e.action) != null && v.includes("zapier.com")) || (h["content-type"] = k));
3335
+ k && k !== "multipart/form-data" && (m && ((v = e.action) != null && v.includes("zapier.com")) || (g["content-type"] = k));
3334
3336
  const A = new CustomEvent("presubmit", { detail: { body: p } });
3335
3337
  if (t.current && (t.current.dispatchEvent(A), A.defaultPrevented))
3336
3338
  return;
3337
3339
  if (i("sending"), e.sendSubmissionsTo === "email" && (e.sendSubmissionsToEmail === "your@email.com" || !e.sendSubmissionsToEmail)) {
3338
- const g = "SubmissionsToEmail is required when sendSubmissionsTo is set to email";
3339
- console.error(g), i("error"), c({ formErrorMessage: g });
3340
+ const h = "SubmissionsToEmail is required when sendSubmissionsTo is set to email";
3341
+ console.error(h), i("error"), c({ formErrorMessage: h });
3340
3342
  return;
3341
3343
  }
3342
3344
  const T = `${Yn() === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${e.builderContext.apiKey}&to=${btoa(
3343
3345
  e.sendSubmissionsToEmail || ""
3344
3346
  )}&name=${encodeURIComponent(e.name || "")}`, w = e.sendSubmissionsTo === "email" ? T : e.action;
3345
- Fe(w), fetch(w, { body: p, headers: h, method: e.method || "post" }).then(
3346
- async (g) => {
3347
+ Fe(w), fetch(w, { body: p, headers: g, method: e.method || "post" }).then(
3348
+ async (h) => {
3347
3349
  var N, F;
3348
3350
  let x;
3349
- const E = g.headers.get("content-type");
3350
- if (E && E.indexOf("application/json") !== -1 ? x = await g.json() : x = await g.text(), !g.ok) {
3351
+ const E = h.headers.get("content-type");
3352
+ if (E && E.indexOf("application/json") !== -1 ? x = await h.json() : x = await h.text(), !h.ok) {
3351
3353
  const _ = new CustomEvent("submit:error", {
3352
- detail: { error: x, status: g.status }
3354
+ detail: { error: x, status: h.status }
3353
3355
  });
3354
3356
  if ((N = t.current) != null && N.nativeElement && ((F = t.current) == null || F.nativeElement.dispatchEvent(_), _.defaultPrevented))
3355
3357
  return;
@@ -3358,9 +3360,9 @@ function Xn(e) {
3358
3360
  typeof P != "string" && (P = JSON.stringify(P)), l(P), c({ formErrorMessage: P });
3359
3361
  return;
3360
3362
  }
3361
- if (o(x), i(g.ok ? "success" : "error"), g.ok) {
3363
+ if (o(x), i(h.ok ? "success" : "error"), h.ok) {
3362
3364
  const _ = new CustomEvent("submit:success", {
3363
- detail: { res: g, body: x }
3365
+ detail: { res: h, body: x }
3364
3366
  });
3365
3367
  if (t.current) {
3366
3368
  if (t.current.dispatchEvent(_), _.defaultPrevented)
@@ -3377,18 +3379,18 @@ function Xn(e) {
3377
3379
  location.href = e.successUrl;
3378
3380
  }
3379
3381
  },
3380
- (g) => {
3382
+ (h) => {
3381
3383
  const x = new CustomEvent("submit:error", {
3382
- detail: { error: g }
3384
+ detail: { error: h }
3383
3385
  });
3384
- t.current && (t.current.dispatchEvent(x), x.defaultPrevented) || (o(g), i("error"));
3386
+ t.current && (t.current.dispatchEvent(x), x.defaultPrevented) || (o(h), i("error"));
3385
3387
  }
3386
3388
  );
3387
3389
  }
3388
3390
  }
3389
3391
  return /* @__PURE__ */ $(R, { children: [
3390
3392
  " ",
3391
- /* @__PURE__ */ s("style", { children: ".pre-7c90c93e { padding: 10px; color: red; text-align: center; }" }),
3393
+ /* @__PURE__ */ s("style", { children: ".pre-26f6d56a { padding: 10px; color: red; text-align: center; }" }),
3392
3394
  " ",
3393
3395
  /* @__PURE__ */ $(
3394
3396
  "form",
@@ -3418,7 +3420,7 @@ function Xn(e) {
3418
3420
  context: e.builderContext
3419
3421
  }
3420
3422
  ) : null,
3421
- u() === "error" && r ? /* @__PURE__ */ s("pre", { className: "builder-form-error-text pre-7c90c93e", children: JSON.stringify(r, null, 2) }) : null,
3423
+ u() === "error" && r ? /* @__PURE__ */ s("pre", { className: "builder-form-error-text pre-26f6d56a", children: JSON.stringify(r, null, 2) }) : null,
3422
3424
  u() === "success" ? /* @__PURE__ */ s(
3423
3425
  U,
3424
3426
  {
@@ -3791,10 +3793,10 @@ function ui(e) {
3791
3793
  return V(() => {
3792
3794
  if (e.lazyLoad) {
3793
3795
  const v = new IntersectionObserver(function(d) {
3794
- d.forEach(function(h) {
3795
- if (!h.isIntersecting)
3796
+ d.forEach(function(g) {
3797
+ if (!g.isIntersecting)
3796
3798
  return;
3797
- const p = h.target;
3799
+ const p = g.target;
3798
3800
  try {
3799
3801
  Array.from(p.children).filter(
3800
3802
  (y) => y instanceof HTMLElement && y.tagName === "SOURCE"
@@ -4166,23 +4168,23 @@ function Vi(e) {
4166
4168
  const t = H(null);
4167
4169
  C(() => !1);
4168
4170
  function n(T) {
4169
- var g, x;
4171
+ var h, x;
4170
4172
  const w = {
4171
4173
  ...e.builderContextSignal.rootState,
4172
4174
  ...T
4173
4175
  };
4174
- e.builderContextSignal.rootSetState ? (x = (g = e.builderContextSignal).rootSetState) == null || x.call(g, w) : e.setBuilderContextSignal((E) => ({
4176
+ e.builderContextSignal.rootSetState ? (x = (h = e.builderContextSignal).rootSetState) == null || x.call(h, w) : e.setBuilderContextSignal((E) => ({
4175
4177
  ...E,
4176
4178
  rootState: w
4177
4179
  }));
4178
4180
  }
4179
4181
  function i(T) {
4180
- var g, x, E, N, F;
4182
+ var h, x, E, N, F;
4181
4183
  const w = {
4182
4184
  ...e.builderContextSignal.content,
4183
4185
  ...T,
4184
4186
  data: {
4185
- ...(g = e.builderContextSignal.content) == null ? void 0 : g.data,
4187
+ ...(h = e.builderContextSignal.content) == null ? void 0 : h.data,
4186
4188
  ...T == null ? void 0 : T.data
4187
4189
  },
4188
4190
  meta: {
@@ -4212,10 +4214,10 @@ function Vi(e) {
4212
4214
  callbacks: {
4213
4215
  configureSdk: (w) => {
4214
4216
  var E;
4215
- const { breakpoints: g, contentId: x } = w;
4216
- !x || x !== ((E = e.builderContextSignal.content) == null ? void 0 : E.id) || g && i({
4217
+ const { breakpoints: h, contentId: x } = w;
4218
+ !x || x !== ((E = e.builderContextSignal.content) == null ? void 0 : E.id) || h && i({
4217
4219
  meta: {
4218
- breakpoints: g
4220
+ breakpoints: h
4219
4221
  }
4220
4222
  });
4221
4223
  },
@@ -4233,9 +4235,9 @@ function Vi(e) {
4233
4235
  }
4234
4236
  const [c, u] = C(() => ({})), [f, b] = C(() => ({})), [m, v] = C(() => !1);
4235
4237
  function d(T) {
4236
- var w, g;
4238
+ var w, h;
4237
4239
  if (e.builderContextSignal.content) {
4238
- const x = (w = e.builderContextSignal.content) == null ? void 0 : w.testVariationId, E = (g = e.builderContextSignal.content) == null ? void 0 : g.id;
4240
+ const x = (w = e.builderContextSignal.content) == null ? void 0 : w.testVariationId, E = (h = e.builderContextSignal.content) == null ? void 0 : h.id;
4239
4241
  Te({
4240
4242
  apiHost: e.apiHost,
4241
4243
  type: "click",
@@ -4249,9 +4251,9 @@ function Vi(e) {
4249
4251
  }
4250
4252
  m || v(!0);
4251
4253
  }
4252
- function h() {
4253
- var w, g, x;
4254
- const T = (x = (g = (w = e.builderContextSignal.content) == null ? void 0 : w.data) == null ? void 0 : g.httpRequests) != null ? x : {};
4254
+ function g() {
4255
+ var w, h, x;
4256
+ const T = (x = (h = (w = e.builderContextSignal.content) == null ? void 0 : w.data) == null ? void 0 : h.httpRequests) != null ? x : {};
4255
4257
  Object.entries(T).forEach(
4256
4258
  ([E, N]) => {
4257
4259
  if (!N)
@@ -4317,8 +4319,8 @@ function Vi(e) {
4317
4319
  );
4318
4320
  }
4319
4321
  const y = H(!1);
4320
- return y.current || (h(), p(), y.current = !0), V(() => {
4321
- var T, w, g, x, E;
4322
+ return y.current || (g(), p(), y.current = !0), V(() => {
4323
+ var T, w, h, x, E;
4322
4324
  if (M()) {
4323
4325
  L() && !e.isNestedRender && (window.addEventListener("message", l), ut({
4324
4326
  ...e.locale ? {
@@ -4347,7 +4349,7 @@ function Vi(e) {
4347
4349
  const N = e.builderContextSignal.content && Z(e.canTrack), F = mt({
4348
4350
  name: `builder.tests.${(w = e.builderContextSignal.content) == null ? void 0 : w.id}`,
4349
4351
  canTrack: !0
4350
- }), _ = (g = e.builderContextSignal.content) == null ? void 0 : g.testVariationId;
4352
+ }), _ = (h = e.builderContextSignal.content) == null ? void 0 : h.testVariationId;
4351
4353
  if (N && _ === F) {
4352
4354
  const P = (x = e.builderContextSignal.content) == null ? void 0 : x.id, D = e.apiKey;
4353
4355
  Te({
@@ -4462,7 +4464,7 @@ const Bi = ({
4462
4464
  meta: e == null ? void 0 : e.meta
4463
4465
  } : void 0;
4464
4466
  function Oe(e) {
4465
- var u, f, b, m, v, d, h, p, y;
4467
+ var u, f, b, m, v, d, g, p, y;
4466
4468
  const [t, n] = C(
4467
4469
  () => {
4468
4470
  var S, k;
@@ -4584,7 +4586,7 @@ function Oe(e) {
4584
4586
  isNestedRender: e.isNestedRender,
4585
4587
  contentId: (b = a.content) == null ? void 0 : b.id,
4586
4588
  cssCode: (v = (m = a.content) == null ? void 0 : m.data) == null ? void 0 : v.cssCode,
4587
- customFonts: (h = (d = a.content) == null ? void 0 : d.data) == null ? void 0 : h.customFonts
4589
+ customFonts: (g = (d = a.content) == null ? void 0 : d.data) == null ? void 0 : g.customFonts
4588
4590
  }
4589
4591
  ),
4590
4592
  /* @__PURE__ */ s(
@@ -4754,12 +4756,12 @@ function Di(e) {
4754
4756
  return "div";
4755
4757
  }
4756
4758
  function i() {
4757
- var d, h;
4759
+ var d, g;
4758
4760
  return [
4759
4761
  e.attributes[z()],
4760
4762
  "builder-symbol",
4761
4763
  (d = e.symbol) != null && d.inline ? "builder-inline-symbol" : void 0,
4762
- (h = e.symbol) != null && h.dynamic || e.dynamic ? "builder-dynamic-symbol" : void 0
4764
+ (g = e.symbol) != null && g.dynamic || e.dynamic ? "builder-dynamic-symbol" : void 0
4763
4765
  ].filter(Boolean).join(" ");
4764
4766
  }
4765
4767
  const [r, o] = C(() => {
@@ -4774,9 +4776,9 @@ function Di(e) {
4774
4776
  r && a === ((d = e.symbol) == null ? void 0 : d.entry) || $i({
4775
4777
  symbol: e.symbol,
4776
4778
  builderContextValue: e.builderContext
4777
- }).then((h) => {
4779
+ }).then((g) => {
4778
4780
  var p;
4779
- h && (o(h), l((p = e.symbol) == null ? void 0 : p.entry));
4781
+ g && (o(g), l((p = e.symbol) == null ? void 0 : p.entry));
4780
4782
  });
4781
4783
  }
4782
4784
  return V(() => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./blocks-exports.cjs"),e=require("./server-entry-09953757.cjs");require("react/jsx-runtime");require("react");exports.Blocks=t.Blocks;exports.BuilderContext=t.BuilderContext;exports.Button=t.Button;exports.Columns=t.Columns;exports.Content=t.Content;exports.Fragment=t.Fragment;exports.Image=t.Image;exports.Section=t.Section;exports.Symbol=t.Symbol;exports.Text=t.Text;exports.Video=t.Video;exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setClientUserAttributes=e.setClientUserAttributes;exports.setEditorSettings=e.setEditorSettings;exports.subscribeToEditor=e.subscribeToEditor;exports.track=e.track;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./blocks-exports.cjs"),e=require("./server-entry-4cf669a1.cjs");require("react/jsx-runtime");require("react");exports.Blocks=t.Blocks;exports.BuilderContext=t.BuilderContext;exports.Button=t.Button;exports.Columns=t.Columns;exports.Content=t.Content;exports.Fragment=t.Fragment;exports.Image=t.Image;exports.Section=t.Section;exports.Symbol=t.Symbol;exports.Text=t.Text;exports.Video=t.Video;exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.registerAction=e.registerAction;exports.setClientUserAttributes=e.setClientUserAttributes;exports.setEditorSettings=e.setEditorSettings;exports.subscribeToEditor=e.subscribeToEditor;exports.track=e.track;
@@ -1,5 +1,5 @@
1
- import { Blocks as o, BuilderContext as s, Button as n, Columns as c, Content as m, Fragment as g, Image as a, Section as l, Symbol as u, Text as d, Video as p } from "./blocks-exports.mjs";
2
- import { _processContentResult as f, createRegisterComponentMessage as B, fetchBuilderProps as E, fetchEntries as b, fetchOneEntry as h, getBuilderSearchParams as x, isEditing as S, isPreviewing as P, register as k, setClientUserAttributes as y, setEditorSettings as R, subscribeToEditor as T, track as v } from "./server-entry-065ec411.js";
1
+ import { Blocks as o, BuilderContext as s, Button as n, Columns as c, Content as g, Fragment as m, Image as a, Section as l, Symbol as u, Text as d, Video as p } from "./blocks-exports.mjs";
2
+ import { _processContentResult as f, createRegisterComponentMessage as B, fetchBuilderProps as E, fetchEntries as b, fetchOneEntry as h, getBuilderSearchParams as x, isEditing as S, isPreviewing as P, register as k, registerAction as y, setClientUserAttributes as A, setEditorSettings as R, subscribeToEditor as T, track as v } from "./server-entry-5e98a993.js";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  export {
@@ -7,8 +7,8 @@ export {
7
7
  s as BuilderContext,
8
8
  n as Button,
9
9
  c as Columns,
10
- m as Content,
11
- g as Fragment,
10
+ g as Content,
11
+ m as Fragment,
12
12
  a as Image,
13
13
  l as Section,
14
14
  u as Symbol,
@@ -23,7 +23,8 @@ export {
23
23
  S as isEditing,
24
24
  P as isPreviewing,
25
25
  k as register,
26
- y as setClientUserAttributes,
26
+ y as registerAction,
27
+ A as setClientUserAttributes,
27
28
  R as setEditorSettings,
28
29
  T as subscribeToEditor,
29
30
  v as track
@@ -0,0 +1,2 @@
1
+ "use strict";const S="react",A="[Builder.io]: ",d={log:(...t)=>console.log(A,...t),error:(...t)=>console.error(A,...t),warn:(...t)=>console.warn(A,...t),debug:(...t)=>console.debug(A,...t)};function a(){return typeof window!="undefined"&&typeof document!="undefined"}const yt=t=>{const e={};return t.forEach((n,r)=>{e[r]=n}),e},$=t=>t instanceof URLSearchParams?yt(t):t,G=t=>typeof t=="string"?t:t instanceof URLSearchParams?t.toString():new URLSearchParams(t).toString();function bt(){return a()&&window.self!==window.top}function J(t){return bt()&&G(t||window.location.search).indexOf("builder.frameEditing=")!==-1}const mt=()=>{if(a()){const t=new URL(location.href);return t.pathname===""&&(t.pathname="/"),t}else return console.warn("Cannot get location for tracking in non-browser environment"),null},wt=()=>typeof navigator=="object"&&navigator.userAgent||"",z=()=>{const t=wt(),e={Android(){return t.match(/Android/i)},BlackBerry(){return t.match(/BlackBerry/i)},iOS(){return t.match(/iPhone|iPod/i)},Opera(){return t.match(/Opera Mini/i)},Windows(){return t.match(/IEMobile/i)||t.match(/WPDesktop/i)},any(){return e.Android()||e.BlackBerry()||e.iOS()||e.Opera()||e.Windows()||S==="reactNative"}},n=t.match(/Tablet|iPad/i),r=mt();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":e.any()?"mobile":"desktop"}},p=t=>t!=null;function Et(t){const e=t||(a()?window.location.search:void 0);return e?G(e).indexOf("builder.preview=")!==-1:!1}const It=t=>({type:"builder.registerComponent",data:O(t)}),At=t=>{const e=t.toString().trim(),n=/^[a-zA-Z0-9_]+\s*=>/i.test(e);return`return (${!e.startsWith("function")&&!e.startsWith("async")&&!e.startsWith("(")&&!n?"function ":""}${e}).apply(this, arguments)`};function O(t){return JSON.parse(JSON.stringify(t,(e,n)=>typeof n=="function"?At(n):n))}const V={};function vt(t,e){t==="plugin"&&(e=O(e));let n=V[t];if(n||(n=V[t]=[]),n.push(e),a()){const r={type:"builder.register",data:{type:t,info:e}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(s){console.debug("Could not postmessage",s)}}}function kt(t){var e;if(a()){const n=JSON.parse(JSON.stringify(t));t.action&&(n.action=t.action.toString()),(e=window.parent)==null||e.postMessage({type:"builder.registerAction",data:n},"*")}}const D={};function Ut(t){if(a()){Object.assign(D,t);const e={type:"builder.settingsChange",data:D};parent.postMessage(e,"*")}}const F="builder.",Tt="options.",P=t=>{if(!t)return{};const e=$(t),n={};return Object.keys(e).forEach(r=>{if(r.startsWith(F)){const s=r.replace(F,"").replace(Tt,"");n[s]=e[r]}}),n},Ot=()=>{if(!a())return{};const t=new URLSearchParams(window.location.search);return P(t)},X="4.2.1",H=()=>({"X-Builder-SDK":S,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":X}),Pt=t=>{if(t==="localhost"||t==="127.0.0.1")return t;const e=t.split(".");return e.length>2?e.slice(1).join("."):t},v=({name:t,canTrack:e})=>{var n;try{return e?(n=document.cookie.split("; ").find(r=>r.startsWith(`${t}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){d.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},Q=async t=>v(t),Rt=t=>t.map(([e,n])=>n?`${e}=${n}`:e).filter(p).join("; "),Ct=[["secure",""],["SameSite","None"]],Bt=({name:t,value:e,expires:n})=>{const s=(a()?location.protocol==="https:":!0)?Ct:[[]],o=n?[["expires",n.toUTCString()]]:[[]],i=[[t,e],...o,["path","/"],["domain",Pt(window.location.hostname)],...s];return Rt(i)},R=async({name:t,value:e,expires:n,canTrack:r})=>{try{if(!r)return;const s=Bt({name:t,value:e,expires:n});document.cookie=s}catch(s){d.warn("[COOKIE] SET error: ",(s==null?void 0:s.message)||s)}};function xt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}function Y(){return xt().replace(/-/g,"")}const Z="builderSessionId",_t=async({canTrack:t})=>{if(!t)return;const e=await Q({name:Z,canTrack:t});if(p(e))return e;{const n=Lt();return Nt({id:n,canTrack:t}),n}},Lt=()=>Y(),Nt=({id:t,canTrack:e})=>R({name:Z,value:t,canTrack:e}),q=()=>a()&&typeof localStorage!="undefined"?localStorage:void 0,Vt=({key:t,canTrack:e})=>{var n;try{return e?(n=q())==null?void 0:n.getItem(t):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Dt=({key:t,canTrack:e,value:n})=>{var r;try{e&&((r=q())==null||r.setItem(t,n))}catch(s){console.debug("[LocalStorage] SET error: ",s)}},tt="builderVisitorId",Ft=({canTrack:t})=>{if(!t)return;const e=Vt({key:tt,canTrack:t});if(p(e))return e;{const n=Mt();return Kt({id:n,canTrack:t}),n}},Mt=()=>Y(),Kt=({id:t,canTrack:e})=>Dt({key:tt,value:t,canTrack:e});function et(t){var e;typeof process!="undefined"&&((e=process.env)!=null&&e.DEBUG)&&String(process.env.DEBUG)=="true"&&d.log(t)}const Wt=async({canTrack:t})=>{if(!t)return{visitorId:void 0,sessionId:void 0};const e=await _t({canTrack:t}),n=Ft({canTrack:t});return{sessionId:e,visitorId:n}},jt=async({type:t,canTrack:e,apiKey:n,metadata:r,...s})=>({type:t,data:{...s,metadata:{url:location.href,...r},...await Wt({canTrack:e}),userAttributes:z(),ownerId:n}});async function nt({apiHost:t,...e}){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(!e.canTrack||J()||!(a()||S==="reactNative"))return;const r=`${t||"https://cdn.builder.io"}/api/v1/track`;return et(r),fetch(r,{method:"POST",body:JSON.stringify({events:[await jt(e)]}),headers:{"content-type":"application/json",...H()},mode:"cors"}).catch(s=>{console.error("Failed to track: ",s)})}const $t=t=>nt({...t,canTrack:!0}),Gt=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function rt(t,e){if(!e.origin.startsWith("http")&&!e.origin.startsWith("https"))return!1;const n=new URL(e.origin),r=n.hostname;return(t||Gt).findIndex(s=>s.startsWith("*.")?r.endsWith(s.slice(1)):s===r)>-1}let M=!1;const st=t=>{var e,n;M||(M=!0,a()&&((e=window.parent)==null||e.postMessage({type:"builder.sdkInfo",data:{target:S,version:X,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0,modelName:t.modelName,apiKey:t.apiKey,supportsXSmallBreakpoint:!0,blockLevelPersonalization:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:t}},"*"),window.addEventListener("message",r=>{var o,i;if(!rt(t.trustedHosts,r))return;const{data:s}=r;if(s!=null&&s.type)switch(s.type){case"builder.evaluate":{const u=s.data.text,m=s.data.arguments||[],y=s.data.id,w=new Function(u);let l,g=null;try{l=w.apply(null,m)}catch(h){g=h}g?(o=window.parent)==null||o.postMessage({type:"builder.evaluateError",data:{id:y,error:g.message}},"*"):l&&typeof l.then=="function"?l.then(h=>{var E;(E=window.parent)==null||E.postMessage({type:"builder.evaluateResult",data:{id:y,result:h}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:l,id:y}},"*");break}}})))},ot=({model:t,trustedHosts:e,callbacks:n})=>r=>{if(!rt(e,r))return;const{data:s}=r;if(s)switch(s.type){case"builder.configureSdk":{n.configureSdk(s.data);break}case"builder.triggerAnimation":{n.animation(s.data);break}case"builder.resetState":{const o=s.data,i=o.model,u=o==null?void 0:o.state;i===t&&u&&n.stateUpdate(u);break}case"builder.contentUpdate":{const o=s.data,i=o.key||o.alias||o.entry||o.modelName,u=o.data;i===t&&n.contentUpdate(u);break}}},Jt=({model:t,apiKey:e,callback:n,trustedHosts:r})=>{if(!a)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};st({modelName:t,apiKey:e});const s=ot({callbacks:{contentUpdate:n,animation:()=>{},configureSdk:()=>{},stateUpdate:()=>{}},model:t,trustedHosts:r});return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},zt="builder.tests",C=t=>`${zt}.${t}`,Xt=({contentId:t})=>Q({name:C(t),canTrack:!0}),Ht=({contentId:t})=>v({name:C(t),canTrack:!0}),Qt=({contentId:t,value:e})=>R({name:C(t),value:e,canTrack:!0}),it=t=>p(t.id)&&p(t.variations)&&Object.keys(t.variations).length>0,Yt=({id:t,variations:e})=>{var s;let n=0;const r=Math.random();for(const o in e){const i=(s=e[o])==null?void 0:s.testRatio;if(n+=i,r<n)return o}return t},at=t=>{const e=Yt(t);return Qt({contentId:t.id,value:e}).catch(n=>{d.error("could not store A/B test variation: ",n)}),e},ct=({item:t,testGroupId:e})=>{const n=t.variations[e];return e===t.id||!n?{testVariationId:t.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===t.id?"Default":"")}},Zt=({item:t,canTrack:e})=>{if(!e)return t;if(!t)return;if(!it(t))return t;const n=Ht({contentId:t.id})||at({variations:t.variations,id:t.id}),r=ct({item:t,testGroupId:n});return{...t,...r}},qt=async({item:t,canTrack:e})=>{if(!e||!it(t))return t;const r=await Xt({contentId:t.id})||at({variations:t.variations,id:t.id}),s=ct({item:t,testGroupId:r});return{...t,...s}};const K="builder.userAttributes";function W(){let t=!0;const e=new Set;return{setUserAttributes(n){if(!a())return;const r={...this.getUserAttributes(),...n};R({name:K,value:JSON.stringify(r),canTrack:t}),e.forEach(s=>s(r))},getUserAttributes(){return a()?JSON.parse(v({name:K,canTrack:t})||"{}"):{}},subscribeOnUserAttributesChange(n,{fireImmediately:r}={}){return e.add(n),r&&n(this.getUserAttributes()),function(){e.delete(n)}},setCanTrack(n){t=n}}}let U;a()&&S==="qwik"?(window.__BUILDER_USER_ATTRIBUTES_SERVICE__||(window.__BUILDER_USER_ATTRIBUTES_SERVICE__=W()),U=window.__BUILDER_USER_ATTRIBUTES_SERVICE__):U=W();const B=U,te=t=>{B.setUserAttributes(t)},ut=t=>{const e=p(t)?t:!0;return B.setCanTrack(e),e};function ee(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function ne(){const t=ee().fetch;if(typeof t=="undefined")throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
2
+ For more information, read https://github.com/BuilderIO/this-package-uses-fetch`),new Error("Builder SDK could not find a global `fetch` function");return t}const re=ne();function T(t,e=null,n="."){return Object.keys(t).reduce((r,s)=>{const o=t[s],i=[e,s].filter(Boolean).join(n);return[typeof o=="object",o!==null,!(Array.isArray(o)&&o.length===0)].every(Boolean)?{...r,...T(o,i,n)}:{...r,[i]:o}},{})}function lt(t,e,n={}){for(const r in t){const s=t[r],o=e?e+"."+r:r;s&&typeof s=="object"&&!Array.isArray(s)&&!Object.keys(s).find(i=>i.startsWith("$"))?lt(s,o,n):n[o]=s}return n}function se(t){const e={};for(const n in t){const r=n.split(".");let s=e;for(let o=0;o<r.length;o++){const i=r[o];o===r.length-1?s[i]=t[n]:(s[i]=s[i]||{},s=s[i])}}return e}const oe="v3",j=t=>typeof t=="number"&&!isNaN(t)&&t>=0,x=t=>{const{limit:e=30,userAttributes:n,query:r,model:s,apiKey:o,enrich:i,locale:u,apiVersion:m=oe,fields:y,omit:w,offset:l,cacheSeconds:g,staleCacheSeconds:h,sort:E,includeUnpublished:_,apiHost:ht}=t;if(!o)throw new Error("Missing API key");if(!["v3"].includes(m))throw new Error(`Invalid apiVersion: expected 'v3', received '${m}'`);const pt=e!==1,St=ht||"https://cdn.builder.io",c=new URL(`${St}/api/${m}/content/${s}`);c.searchParams.set("apiKey",o),c.searchParams.set("limit",String(e)),c.searchParams.set("noTraverse",String(pt)),c.searchParams.set("includeRefs",String(!0));const k=u||(n==null?void 0:n.locale);let b=n||{};if(k&&(c.searchParams.set("locale",k),b={locale:k,...b}),i&&c.searchParams.set("enrich",String(i)),c.searchParams.set("omit",w!=null?w:"meta.componentsUsed"),y&&c.searchParams.set("fields",y),Number.isFinite(l)&&l>-1&&c.searchParams.set("offset",String(Math.floor(l))),typeof _=="boolean"&&c.searchParams.set("includeUnpublished",String(_)),g&&j(g)&&c.searchParams.set("cacheSeconds",String(g)),h&&j(h)&&c.searchParams.set("staleCacheSeconds",String(h)),E){const f=T({sort:E});for(const I in f)c.searchParams.set(I,JSON.stringify(f[I]))}const L={...Ot(),...$(t.options||{})};b={...b,...ae(L)};const N=T(L);for(const f in N)c.searchParams.set(f,String(N[f]));if(Object.keys(b).length>0&&c.searchParams.set("userAttributes",JSON.stringify(b)),r){const f=lt({query:r});for(const I in f)c.searchParams.set(I,JSON.stringify(f[I]))}return c},ie=t=>{const e={};for(const n in t)n.startsWith("userAttributes.")&&(e[n]=t[n],delete t[n]);return e},ae=t=>{if(a()&&t.preview==="BUILDER_STUDIO"){t["userAttributes.urlPath"]=window.location.pathname,t["userAttributes.host"]=window.location.host;const e=ie(t),{userAttributes:n}=se(e);return n}return{}},ce=t=>"results"in t;async function dt(t){const e=await gt({...t,limit:1});return e&&e[0]||null}const ue=async t=>{var i,u;const e=x(t),n=(i=t.fetch)!=null?i:re,r={...t.fetchOptions,headers:{...(u=t.fetchOptions)==null?void 0:u.headers,...H()}};return await(await n(e.href,r)).json()},ft=async(t,e,n=x(t))=>{const r=ut(t.canTrack);if(n.search.includes("preview="),!r||!(a()||S==="reactNative"))return e.results;try{const s=[];for(const o of e.results)s.push(await qt({item:o,canTrack:r}));e.results=s}catch(s){d.error("Could not process A/B tests. ",s)}return e.results};async function gt(t){const e=x(t),n=await ue(t);if(!ce(n))throw d.error("Error fetching data. ",{url:e,content:n,options:t}),n;return ft(t,n)}const le=async t=>{var r,s,o;const e=t.path||((r=t.url)==null?void 0:r.pathname)||((s=t.userAttributes)==null?void 0:s.urlPath),n={...t,apiKey:t.apiKey,model:t.model||"page",userAttributes:{...t.userAttributes,...e?{urlPath:e}:{}},options:P(t.searchParams||((o=t.url)==null?void 0:o.searchParams)||t.options)};return{apiKey:n.apiKey,model:n.model,content:await dt(n)}};exports.TARGET=S;exports._processContentResult=ft;exports._track=nt;exports.checkIsDefined=p;exports.createEditorListener=ot;exports.createRegisterComponentMessage=It;exports.fetchBuilderProps=le;exports.fetchEntries=gt;exports.fetchOneEntry=dt;exports.getBuilderSearchParams=P;exports.getCookieSync=v;exports.getDefaultCanTrack=ut;exports.getUserAttributes=z;exports.handleABTestingSync=Zt;exports.isBrowser=a;exports.isEditing=J;exports.isPreviewing=Et;exports.logFetch=et;exports.logger=d;exports.register=vt;exports.registerAction=kt;exports.serializeIncludingFunctions=O;exports.setClientUserAttributes=te;exports.setEditorSettings=Ut;exports.setupBrowserForEditing=st;exports.subscribeToEditor=Jt;exports.track=$t;exports.userAttributesService=B;