@builder.io/sdk-react 0.12.7 → 0.12.8

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.
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
3
3
  import { createContext, useState, useEffect, useContext, useRef, createElement } from "react";
4
- import { T as TARGET, i as isEditing, j as isBrowser, k as getUserAttributes, l as fastClone, m as checkIsDefined, n as logger, r as register, o as getDefaultCanTrack, p as _track, a as isPreviewing, c as createRegisterComponentMessage, b as fetchOneEntry, q as fetch$1, u as components, v as serializeComponentInfo, w as handleABTestingSync } from "./server-entry-0457c4c8.js";
5
- import { _ as H, h as K, f as z, g as q, e as Y, d as G, s as J, t as Q } from "./server-entry-0457c4c8.js";
4
+ import { T as TARGET, i as isEditing, k as isBrowser, l as getUserAttributes, m as fastClone, n as checkIsDefined, o as logger, p as getDefaultCanTrack, q as _track, a as isPreviewing, u as createEditorListener, v as registerInsertMenu, w as setupBrowserForEditing, c as createRegisterComponentMessage, e as fetchOneEntry, x as fetch$1, y as components, z as serializeComponentInfo, A as handleABTestingSync } from "./server-entry-d816840a.js";
5
+ import { _ as H, f as K, d as z, h as q, g as Y, j as G, r as J, s as Q, b as X, t as Z } from "./server-entry-d816840a.js";
6
6
  import { createRequire } from "node:module";
7
7
  const EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]), isEmptyElement = (e) => typeof e == "string" && EMPTY_HTML_ELEMENTS.has(e.toLowerCase());
8
8
  function DynamicRenderer(e) {
@@ -214,28 +214,28 @@ output;
214
214
  event: i,
215
215
  state: s
216
216
  }), c = getIsolateContext(), d = c.global;
217
- d.setSync("global", d.derefInto()), d.setSync("log", function(...u) {
218
- console.log(...u);
219
- }), d.setSync(BUILDER_SET_STATE_NAME, function(u, g) {
220
- set(r, u, g), a == null || a(r);
221
- }), l.forEach(([u, g]) => {
222
- const x = typeof g == "object" ? new ivm.Reference(
217
+ d.setSync("global", d.derefInto()), d.setSync("log", function(...f) {
218
+ console.log(...f);
219
+ }), d.setSync(BUILDER_SET_STATE_NAME, function(f, g) {
220
+ set(r, f, g), a == null || a(r);
221
+ }), l.forEach(([f, g]) => {
222
+ const y = typeof g == "object" ? new ivm.Reference(
223
223
  // workaround: methods with default values for arguments is not being cloned over
224
- u === "builder" ? {
224
+ f === "builder" ? {
225
225
  ...g,
226
226
  getUserAttributes: () => g.getUserAttributes()
227
227
  } : g
228
228
  ) : null;
229
- d.setSync(getSyncValName(u), x);
229
+ d.setSync(getSyncValName(f), y);
230
230
  }), d.setSync(INJECTED_IVM_GLOBAL, ivm);
231
- const h = processCode({
231
+ const b = processCode({
232
232
  code: e,
233
233
  args: l
234
- }), y = c.evalSync(h);
234
+ }), S = c.evalSync(b);
235
235
  try {
236
- return JSON.parse(y);
236
+ return JSON.parse(S);
237
237
  } catch {
238
- return y;
238
+ return S;
239
239
  }
240
240
  };
241
241
  function isNodeRuntime() {
@@ -439,8 +439,8 @@ function bindScrollInViewAnimation(e) {
439
439
  leading: !1
440
440
  });
441
441
  function s(d) {
442
- const h = d.getBoundingClientRect(), y = window.innerHeight, g = (e.thresholdPercent || 0) / 100 * y;
443
- return h.bottom > g && h.top < y - g;
442
+ const b = d.getBoundingClientRect(), S = window.innerHeight, g = (e.thresholdPercent || 0) / 100 * S;
443
+ return b.bottom > g && b.top < S - g;
444
444
  }
445
445
  const l = e.steps[0].styles;
446
446
  function c() {
@@ -596,17 +596,17 @@ function BlockStyles(e) {
596
596
  ), s = o == null ? void 0 : o.large, l = o == null ? void 0 : o.medium, c = o == null ? void 0 : o.small, d = i.id;
597
597
  if (!d)
598
598
  return "";
599
- const h = s ? createCssClass({
599
+ const b = s ? createCssClass({
600
600
  className: d,
601
601
  styles: s
602
- }) : "", y = l ? createCssClass({
602
+ }) : "", S = l ? createCssClass({
603
603
  className: d,
604
604
  styles: l,
605
605
  mediaQuery: getMaxWidthQueryForSize(
606
606
  "medium",
607
607
  r
608
608
  )
609
- }) : "", u = c ? createCssClass({
609
+ }) : "", f = c ? createCssClass({
610
610
  className: d,
611
611
  styles: c,
612
612
  mediaQuery: getMaxWidthQueryForSize(
@@ -614,7 +614,7 @@ function BlockStyles(e) {
614
614
  r
615
615
  )
616
616
  }) : "";
617
- return [h, y, u].join(" ");
617
+ return [b, S, f].join(" ");
618
618
  }
619
619
  return /* @__PURE__ */ jsx(Fragment, { children: n() && t() ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { styles: n() }) }) : null });
620
620
  }
@@ -823,7 +823,7 @@ function RepeatedBlock(e) {
823
823
  ) });
824
824
  }
825
825
  function Block(e) {
826
- var d, h, y;
826
+ var d, b, S;
827
827
  function t() {
828
828
  return getComponent({
829
829
  block: e.block,
@@ -838,8 +838,8 @@ function Block(e) {
838
838
  });
839
839
  }
840
840
  function i() {
841
- var u;
842
- return (u = e.block.repeat) != null && u.collection ? e.block : getProcessedBlock({
841
+ var f;
842
+ return (f = e.block.repeat) != null && f.collection ? e.block : getProcessedBlock({
843
843
  block: e.block,
844
844
  localState: e.context.localState,
845
845
  rootState: e.context.rootState,
@@ -853,28 +853,28 @@ function Block(e) {
853
853
  return e.block.tagName === "a" || ((g = i().properties) == null ? void 0 : g.href) || i().href ? e.linkComponent || "a" : e.block.tagName || "div";
854
854
  }
855
855
  function a() {
856
- var x, I;
857
- if ((x = e.block.repeat) != null && x.collection)
858
- return !!((I = n == null ? void 0 : n()) != null && I.length);
859
- const u = "hide" in i() ? i().hide : !1;
860
- return ("show" in i() ? i().show : !0) && !u;
856
+ var y, k;
857
+ if ((y = e.block.repeat) != null && y.collection)
858
+ return !!((k = n == null ? void 0 : n()) != null && k.length);
859
+ const f = "hide" in i() ? i().hide : !1;
860
+ return ("show" in i() ? i().show : !0) && !f;
861
861
  }
862
862
  function r() {
863
- var g, x;
864
- return !((g = t == null ? void 0 : t()) != null && g.component) && !n() ? (x = i().children) != null ? x : [] : [];
863
+ var g, y;
864
+ return !((g = t == null ? void 0 : t()) != null && g.component) && !n() ? (y = i().children) != null ? y : [] : [];
865
865
  }
866
866
  function s() {
867
- var u, g, x, I, E, v, C, T, w;
867
+ var f, g, y, k, E, p, v, I, w;
868
868
  return {
869
- blockChildren: (u = i().children) != null ? u : [],
869
+ blockChildren: (f = i().children) != null ? f : [],
870
870
  componentRef: (g = t == null ? void 0 : t()) == null ? void 0 : g.component,
871
871
  componentOptions: {
872
872
  ...getBlockComponentOptions(i()),
873
873
  builderContext: e.context,
874
- ...((x = t == null ? void 0 : t()) == null ? void 0 : x.name) === "Core:Button" || ((I = t == null ? void 0 : t()) == null ? void 0 : I.name) === "Symbol" || ((E = t == null ? void 0 : t()) == null ? void 0 : E.name) === "Columns" ? {
874
+ ...((y = t == null ? void 0 : t()) == null ? void 0 : y.name) === "Core:Button" || ((k = t == null ? void 0 : t()) == null ? void 0 : k.name) === "Symbol" || ((E = t == null ? void 0 : t()) == null ? void 0 : E.name) === "Columns" ? {
875
875
  builderLinkComponent: e.linkComponent
876
876
  } : {},
877
- ...((v = t == null ? void 0 : t()) == null ? void 0 : v.name) === "Symbol" || ((C = t == null ? void 0 : t()) == null ? void 0 : C.name) === "Columns" ? {
877
+ ...((p = t == null ? void 0 : t()) == null ? void 0 : p.name) === "Symbol" || ((v = t == null ? void 0 : t()) == null ? void 0 : v.name) === "Columns" ? {
878
878
  builderComponents: e.registeredComponents
879
879
  } : {}
880
880
  },
@@ -882,17 +882,17 @@ function Block(e) {
882
882
  linkComponent: e.linkComponent,
883
883
  registeredComponents: e.registeredComponents,
884
884
  builderBlock: i(),
885
- includeBlockProps: ((T = t == null ? void 0 : t()) == null ? void 0 : T.noWrap) === !0,
885
+ includeBlockProps: ((I = t == null ? void 0 : t()) == null ? void 0 : I.noWrap) === !0,
886
886
  isInteractive: !((w = t == null ? void 0 : t()) != null && w.isRSC)
887
887
  };
888
888
  }
889
889
  const [l, c] = useState(() => e.context);
890
890
  return useEffect(() => {
891
- const u = i().id, g = i().animations;
892
- g && u && bindAnimations(
893
- g.filter((x) => x.trigger !== "hover").map((x) => ({
894
- ...x,
895
- elementId: u
891
+ const f = i().id, g = i().animations;
892
+ g && f && bindAnimations(
893
+ g.filter((y) => y.trigger !== "hover").map((y) => ({
894
+ ...y,
895
+ elementId: f
896
896
  }))
897
897
  );
898
898
  }, []), /* @__PURE__ */ jsx(Fragment, { children: a() ? /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -910,11 +910,11 @@ function Block(e) {
910
910
  includeBlockProps: s().includeBlockProps,
911
911
  isInteractive: s().isInteractive
912
912
  }
913
- ) }) : /* @__PURE__ */ jsx(Fragment, { children: n() ? /* @__PURE__ */ jsx(Fragment, { children: (y = n()) == null ? void 0 : y.map((u, g) => /* @__PURE__ */ jsx(
913
+ ) }) : /* @__PURE__ */ jsx(Fragment, { children: n() ? /* @__PURE__ */ jsx(Fragment, { children: (S = n()) == null ? void 0 : S.map((f, g) => /* @__PURE__ */ jsx(
914
914
  RepeatedBlock,
915
915
  {
916
- repeatContext: u.context,
917
- block: u.block,
916
+ repeatContext: f.context,
917
+ block: f.block,
918
918
  registeredComponents: e.registeredComponents,
919
919
  linkComponent: e.linkComponent
920
920
  },
@@ -941,15 +941,15 @@ function Block(e) {
941
941
  isInteractive: s().isInteractive
942
942
  }
943
943
  ),
944
- (h = r()) == null ? void 0 : h.map((u) => /* @__PURE__ */ jsx(
944
+ (b = r()) == null ? void 0 : b.map((f) => /* @__PURE__ */ jsx(
945
945
  Block,
946
946
  {
947
- block: u,
947
+ block: f,
948
948
  context: l,
949
949
  registeredComponents: e.registeredComponents,
950
950
  linkComponent: e.linkComponent
951
951
  },
952
- u.id
952
+ f.id
953
953
  ))
954
954
  ]
955
955
  }
@@ -1041,75 +1041,75 @@ function Columns(e) {
1041
1041
  ), [i, o] = useState(() => e.columns || []), [a, r] = useState(
1042
1042
  () => e.stackColumnsAt || "tablet"
1043
1043
  );
1044
- function s(v) {
1045
- var C;
1046
- return ((C = i[v]) == null ? void 0 : C.width) || 100 / i.length;
1044
+ function s(p) {
1045
+ var v;
1046
+ return ((v = i[p]) == null ? void 0 : v.width) || 100 / i.length;
1047
1047
  }
1048
- function l(v) {
1049
- const C = t * (i.length - 1) / i.length;
1050
- return `calc(${s(v)}% - ${C}px)`;
1048
+ function l(p) {
1049
+ const v = t * (i.length - 1) / i.length;
1050
+ return `calc(${s(p)}% - ${v}px)`;
1051
1051
  }
1052
1052
  function c({
1053
- stackedStyle: v,
1054
- desktopStyle: C
1053
+ stackedStyle: p,
1054
+ desktopStyle: v
1055
1055
  }) {
1056
- return a === "tablet" ? v : C;
1056
+ return a === "tablet" ? p : v;
1057
1057
  }
1058
1058
  function d({
1059
- stackedStyle: v,
1060
- desktopStyle: C
1059
+ stackedStyle: p,
1060
+ desktopStyle: v
1061
1061
  }) {
1062
- return a === "never" ? C : v;
1062
+ return a === "never" ? v : p;
1063
1063
  }
1064
- const [h, y] = useState(
1064
+ const [b, S] = useState(
1065
1065
  () => e.stackColumnsAt === "never" ? "row" : e.reverseColumnsWhenStacked ? "column-reverse" : "column"
1066
1066
  );
1067
- function u() {
1067
+ function f() {
1068
1068
  return {
1069
- "--flex-dir": h,
1069
+ "--flex-dir": b,
1070
1070
  "--flex-dir-tablet": c({
1071
- stackedStyle: h,
1071
+ stackedStyle: b,
1072
1072
  desktopStyle: "row"
1073
1073
  })
1074
1074
  };
1075
1075
  }
1076
- function g(v) {
1077
- const C = v === 0 ? 0 : t, T = l(v), w = `${C}px`, R = "100%", A = 0;
1076
+ function g(p) {
1077
+ const v = p === 0 ? 0 : t, I = l(p), w = `${v}px`, R = "100%", j = 0;
1078
1078
  return {
1079
1079
  ...{
1080
1080
  display: "flex",
1081
1081
  flexDirection: "column",
1082
1082
  alignItems: "stretch"
1083
1083
  },
1084
- width: T,
1084
+ width: I,
1085
1085
  ["marginLeft"]: w,
1086
1086
  "--column-width-mobile": d({
1087
1087
  stackedStyle: R,
1088
- desktopStyle: T
1088
+ desktopStyle: I
1089
1089
  }),
1090
1090
  "--column-margin-left-mobile": d({
1091
- stackedStyle: A,
1091
+ stackedStyle: j,
1092
1092
  desktopStyle: w
1093
1093
  }),
1094
1094
  "--column-width-tablet": c({
1095
1095
  stackedStyle: R,
1096
- desktopStyle: T
1096
+ desktopStyle: I
1097
1097
  }),
1098
1098
  "--column-margin-left-tablet": c({
1099
- stackedStyle: A,
1099
+ stackedStyle: j,
1100
1100
  desktopStyle: w
1101
1101
  })
1102
1102
  };
1103
1103
  }
1104
- function x(v) {
1105
- var T, w;
1104
+ function y(p) {
1105
+ var I, w;
1106
1106
  return getSizesForBreakpoints(
1107
- ((w = (T = e.builderContext.content) == null ? void 0 : T.meta) == null ? void 0 : w.breakpoints) || {}
1108
- )[v].max;
1107
+ ((w = (I = e.builderContext.content) == null ? void 0 : I.meta) == null ? void 0 : w.breakpoints) || {}
1108
+ )[p].max;
1109
1109
  }
1110
- function I() {
1110
+ function k() {
1111
1111
  return `
1112
- @media (max-width: ${x("medium")}px) {
1112
+ @media (max-width: ${y("medium")}px) {
1113
1113
  .${e.builderBlock.id}-breakpoints {
1114
1114
  flex-direction: var(--flex-dir-tablet);
1115
1115
  align-items: stretch;
@@ -1121,7 +1121,7 @@ function Columns(e) {
1121
1121
  }
1122
1122
  }
1123
1123
 
1124
- @media (max-width: ${x("small")}px) {
1124
+ @media (max-width: ${y("small")}px) {
1125
1125
  .${e.builderBlock.id}-breakpoints {
1126
1126
  flex-direction: var(--flex-dir);
1127
1127
  align-items: stretch;
@@ -1139,25 +1139,25 @@ function Columns(e) {
1139
1139
  "div",
1140
1140
  {
1141
1141
  className: `builder-columns ${e.builderBlock.id}-breakpoints div-6f826264`,
1142
- style: u(),
1142
+ style: f(),
1143
1143
  children: [
1144
- /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { styles: I() }) }),
1145
- (E = e.columns) == null ? void 0 : E.map((v, C) => /* @__PURE__ */ jsx(
1144
+ /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(InlinedStyles, { styles: k() }) }),
1145
+ (E = e.columns) == null ? void 0 : E.map((p, v) => /* @__PURE__ */ jsx(
1146
1146
  DynamicRenderer,
1147
1147
  {
1148
- TagName: v.link ? e.builderLinkComponent || "a" : "div",
1148
+ TagName: p.link ? e.builderLinkComponent || "a" : "div",
1149
1149
  actionAttributes: {},
1150
1150
  attributes: {
1151
- ...v.link ? {
1152
- href: v.link
1151
+ ...p.link ? {
1152
+ href: p.link
1153
1153
  } : {},
1154
1154
  [getClassPropName()]: "builder-column",
1155
- style: mapStyleObjToStrIfNeeded(g(C))
1155
+ style: mapStyleObjToStrIfNeeded(g(v))
1156
1156
  },
1157
1157
  children: /* @__PURE__ */ jsx(
1158
1158
  Blocks,
1159
1159
  {
1160
- path: `component.options.columns.${C}.blocks`,
1160
+ path: `component.options.columns.${v}.blocks`,
1161
1161
  parent: e.builderBlock.id,
1162
1162
  styleProp: {
1163
1163
  flexGrow: "1"
@@ -1165,11 +1165,11 @@ function Columns(e) {
1165
1165
  context: e.builderContext,
1166
1166
  registeredComponents: e.builderComponents,
1167
1167
  linkComponent: e.builderLinkComponent,
1168
- blocks: v.blocks
1168
+ blocks: p.blocks
1169
1169
  }
1170
1170
  )
1171
1171
  },
1172
- C
1172
+ v
1173
1173
  ))
1174
1174
  ]
1175
1175
  }
@@ -1645,16 +1645,16 @@ function Embed(e) {
1645
1645
  return;
1646
1646
  const c = t.current.getElementsByTagName("script");
1647
1647
  for (let d = 0; d < c.length; d++) {
1648
- const h = c[d];
1649
- if (h.src && !n.includes(h.src)) {
1650
- n.push(h.src);
1651
- const y = document.createElement("script");
1652
- y.async = !0, y.src = h.src, document.head.appendChild(y);
1653
- } else if (isJsScript(h) && !o.includes(h.innerText))
1648
+ const b = c[d];
1649
+ if (b.src && !n.includes(b.src)) {
1650
+ n.push(b.src);
1651
+ const S = document.createElement("script");
1652
+ S.async = !0, S.src = b.src, document.head.appendChild(S);
1653
+ } else if (isJsScript(b) && !o.includes(b.innerText))
1654
1654
  try {
1655
- o.push(h.innerText), new Function(h.innerText)();
1656
- } catch (y) {
1657
- console.warn("`Embed`: Error running script:", y);
1655
+ o.push(b.innerText), new Function(b.innerText)();
1656
+ } catch (S) {
1657
+ console.warn("`Embed`: Error running script:", S);
1658
1658
  }
1659
1659
  }
1660
1660
  }
@@ -1698,13 +1698,13 @@ const componentInfo$7 = {
1698
1698
  function n(r, s = 6e4) {
1699
1699
  return new Promise((l, c) => {
1700
1700
  const d = document.createElement("img");
1701
- let h = !1;
1701
+ let b = !1;
1702
1702
  d.onload = () => {
1703
- h = !0, l(d);
1704
- }, d.addEventListener("error", (y) => {
1705
- console.warn("Image load failed", y.error), c(y.error);
1703
+ b = !0, l(d);
1704
+ }, d.addEventListener("error", (S) => {
1705
+ console.warn("Image load failed", S.error), c(S.error);
1706
1706
  }), d.src = r, setTimeout(() => {
1707
- h || c(new Error("Image load timed out"));
1707
+ b || c(new Error("Image load timed out"));
1708
1708
  }, s);
1709
1709
  });
1710
1710
  }
@@ -2283,11 +2283,6 @@ function InlinedScript(e) {
2283
2283
  }
2284
2284
  );
2285
2285
  }
2286
- const DEFAULT_TRUSTED_HOSTS = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
2287
- function isFromTrustedHost(e, t) {
2288
- const n = new URL(t.origin), i = n.hostname;
2289
- return (e || DEFAULT_TRUSTED_HOSTS).findIndex((o) => o.startsWith("*.") ? i.endsWith(o.slice(1)) : o === i) > -1;
2290
- }
2291
2286
  function round(e) {
2292
2287
  return Math.round(e * 1e3) / 1e3;
2293
2288
  }
@@ -2330,125 +2325,40 @@ const findParentElement = (e, t, n = !0) => {
2330
2325
  builderElementIndex: n && i ? [].slice.call(document.getElementsByClassName(i)).indexOf(n) : void 0
2331
2326
  }
2332
2327
  };
2333
- }, SDK_VERSION = "0.12.7", registerInsertMenu = () => {
2334
- register("insertMenu", {
2335
- name: "_default",
2336
- default: !0,
2337
- items: [{
2338
- name: "Box"
2339
- }, {
2340
- name: "Text"
2341
- }, {
2342
- name: "Image"
2343
- }, {
2344
- name: "Columns"
2345
- }, {
2346
- name: "Core:Section"
2347
- }, {
2348
- name: "Core:Button"
2349
- }, {
2350
- name: "Embed"
2351
- }, {
2352
- name: "Custom Code"
2353
- }]
2354
- });
2355
- };
2356
- let isSetupForEditing = !1;
2357
- const setupBrowserForEditing = (e = {}) => {
2358
- var t, n;
2359
- isSetupForEditing || (isSetupForEditing = !0, isBrowser() && ((t = window.parent) == null || t.postMessage({
2360
- type: "builder.sdkInfo",
2361
- data: {
2362
- target: TARGET,
2363
- version: SDK_VERSION,
2364
- supportsPatchUpdates: !1,
2365
- // Supports builder-model="..." attribute which is needed to
2366
- // scope our '+ add block' button styling
2367
- supportsAddBlockScoping: !0,
2368
- supportsCustomBreakpoints: !0
2369
- }
2370
- }, "*"), (n = window.parent) == null || n.postMessage({
2371
- type: "builder.updateContent",
2372
- data: {
2373
- options: e
2374
- }
2375
- }, "*"), window.addEventListener("message", (i) => {
2376
- var a, r;
2377
- if (!isFromTrustedHost(e.trustedHosts, i))
2378
- return;
2379
- const {
2380
- data: o
2381
- } = i;
2382
- if (o != null && o.type)
2383
- switch (o.type) {
2384
- case "builder.evaluate": {
2385
- const s = o.data.text, l = o.data.arguments || [], c = o.data.id, d = new Function(s);
2386
- let h, y = null;
2387
- try {
2388
- h = d.apply(null, l);
2389
- } catch (u) {
2390
- y = u;
2391
- }
2392
- y ? (a = window.parent) == null || a.postMessage({
2393
- type: "builder.evaluateError",
2394
- data: {
2395
- id: c,
2396
- error: y.message
2397
- }
2398
- }, "*") : h && typeof h.then == "function" ? h.then((u) => {
2399
- var g;
2400
- (g = window.parent) == null || g.postMessage({
2401
- type: "builder.evaluateResult",
2402
- data: {
2403
- id: c,
2404
- result: u
2405
- }
2406
- }, "*");
2407
- }).catch(console.error) : (r = window.parent) == null || r.postMessage({
2408
- type: "builder.evaluateResult",
2409
- data: {
2410
- result: h,
2411
- id: c
2412
- }
2413
- }, "*");
2414
- break;
2415
- }
2416
- }
2417
- })));
2418
2328
  };
2419
2329
  function EnableEditor(e) {
2420
- var A, B, P, N, F, _, V;
2330
+ var j, P, B, N, F, V, $;
2421
2331
  const t = useRef(null), [n, i] = useState(() => 0);
2422
2332
  useState(() => !0);
2423
- function o(m) {
2424
- var b, S;
2425
- const f = {
2333
+ function o(u) {
2334
+ var h, x;
2335
+ const m = {
2426
2336
  ...e.builderContextSignal.rootState,
2427
- ...m
2337
+ ...u
2428
2338
  };
2429
- e.builderContextSignal.rootSetState ? (S = (b = e.builderContextSignal).rootSetState) == null || S.call(b, f) : e.setBuilderContextSignal((p) => ({
2430
- ...p,
2431
- rootState: f
2339
+ e.builderContextSignal.rootSetState ? (x = (h = e.builderContextSignal).rootSetState) == null || x.call(h, m) : e.setBuilderContextSignal((C) => ({
2340
+ ...C,
2341
+ rootState: m
2432
2342
  }));
2433
2343
  }
2434
- function a(m) {
2435
- var b, S, p, k, j;
2436
- const f = {
2344
+ function a(u) {
2345
+ var h, x, C, T, A;
2346
+ const m = {
2437
2347
  ...e.builderContextSignal.content,
2438
- ...m,
2348
+ ...u,
2439
2349
  data: {
2440
- ...(b = e.builderContextSignal.content) == null ? void 0 : b.data,
2441
- ...m == null ? void 0 : m.data
2350
+ ...(h = e.builderContextSignal.content) == null ? void 0 : h.data,
2351
+ ...u == null ? void 0 : u.data
2442
2352
  },
2443
2353
  meta: {
2444
- ...(S = e.builderContextSignal.content) == null ? void 0 : S.meta,
2445
- ...m == null ? void 0 : m.meta,
2446
- breakpoints: ((p = m == null ? void 0 : m.meta) == null ? void 0 : p.breakpoints) || ((j = (k = e.builderContextSignal.content) == null ? void 0 : k.meta) == null ? void 0 : j.breakpoints)
2354
+ ...(x = e.builderContextSignal.content) == null ? void 0 : x.meta,
2355
+ ...u == null ? void 0 : u.meta,
2356
+ breakpoints: ((C = u == null ? void 0 : u.meta) == null ? void 0 : C.breakpoints) || ((A = (T = e.builderContextSignal.content) == null ? void 0 : T.meta) == null ? void 0 : A.breakpoints)
2447
2357
  }
2448
2358
  };
2449
- e.setBuilderContextSignal(($) => ({
2450
- ...$,
2451
- content: f
2359
+ e.setBuilderContextSignal((_) => ({
2360
+ ..._,
2361
+ content: m
2452
2362
  }));
2453
2363
  }
2454
2364
  useState(() => 0);
@@ -2457,68 +2367,62 @@ function EnableEditor(e) {
2457
2367
  ), [l, c] = useState(
2458
2368
  () => e.contentWrapper || "div"
2459
2369
  );
2460
- function d(m) {
2461
- var b;
2462
- if (!isFromTrustedHost(e.trustedHosts, m))
2463
- return;
2464
- const { data: f } = m;
2465
- if (f)
2466
- switch (f.type) {
2467
- case "builder.configureSdk": {
2468
- const S = f.data, { breakpoints: p, contentId: k } = S;
2469
- if (!k || k !== ((b = e.builderContextSignal.content) == null ? void 0 : b.id))
2470
- return;
2471
- p && a({
2370
+ function d(u) {
2371
+ return createEditorListener({
2372
+ model: e.model,
2373
+ trustedHosts: e.trustedHosts,
2374
+ callbacks: {
2375
+ configureSdk: (m) => {
2376
+ var C;
2377
+ const { breakpoints: h, contentId: x } = m;
2378
+ !x || x !== ((C = e.builderContextSignal.content) == null ? void 0 : C.id) || h && (a({
2472
2379
  meta: {
2473
- breakpoints: p
2380
+ breakpoints: h
2474
2381
  }
2475
- }), i(n + 1);
2476
- break;
2477
- }
2478
- case "builder.triggerAnimation": {
2479
- triggerAnimation(f.data);
2480
- break;
2481
- }
2482
- case "builder.contentUpdate": {
2483
- const S = f.data, p = S.key || S.alias || S.entry || S.modelName, k = S.data;
2484
- p === e.model && (a(k), i(n + 1));
2485
- break;
2382
+ }), i(n + 1));
2383
+ },
2384
+ animation: (m) => {
2385
+ triggerAnimation(m);
2386
+ },
2387
+ contentUpdate: (m) => {
2388
+ a(m), i(n + 1);
2486
2389
  }
2487
2390
  }
2391
+ })(u);
2488
2392
  }
2489
- function h() {
2490
- var f, b;
2491
- const m = (b = (f = e.builderContextSignal.content) == null ? void 0 : f.data) == null ? void 0 : b.jsCode;
2492
- m && evaluate({
2493
- code: m,
2393
+ function b() {
2394
+ var m, h;
2395
+ const u = (h = (m = e.builderContextSignal.content) == null ? void 0 : m.data) == null ? void 0 : h.jsCode;
2396
+ u && evaluate({
2397
+ code: u,
2494
2398
  context: e.context || {},
2495
2399
  localState: void 0,
2496
2400
  rootState: e.builderContextSignal.rootState,
2497
2401
  rootSetState: e.builderContextSignal.rootSetState
2498
2402
  });
2499
2403
  }
2500
- const [y, u] = useState(() => ({})), [g, x] = useState(() => !1);
2501
- function I(m) {
2502
- var f, b;
2404
+ const [S, f] = useState(() => ({})), [g, y] = useState(() => !1);
2405
+ function k(u) {
2406
+ var m, h;
2503
2407
  if (e.builderContextSignal.content) {
2504
- const S = (f = e.builderContextSignal.content) == null ? void 0 : f.testVariationId, p = (b = e.builderContextSignal.content) == null ? void 0 : b.id;
2408
+ const x = (m = e.builderContextSignal.content) == null ? void 0 : m.testVariationId, C = (h = e.builderContextSignal.content) == null ? void 0 : h.id;
2505
2409
  _track({
2506
2410
  type: "click",
2507
2411
  canTrack: getDefaultCanTrack(e.canTrack),
2508
- contentId: p,
2412
+ contentId: C,
2509
2413
  apiKey: e.apiKey,
2510
- variationId: S !== p ? S : void 0,
2511
- ...getInteractionPropertiesForEvent(m),
2414
+ variationId: x !== C ? x : void 0,
2415
+ ...getInteractionPropertiesForEvent(u),
2512
2416
  unique: !g
2513
2417
  });
2514
2418
  }
2515
- g || x(!0);
2419
+ g || y(!0);
2516
2420
  }
2517
- function E(m) {
2518
- return m.replace(
2421
+ function E(u) {
2422
+ return u.replace(
2519
2423
  /{{([^}]+)}}/g,
2520
- (f, b) => evaluate({
2521
- code: b,
2424
+ (m, h) => evaluate({
2425
+ code: h,
2522
2426
  context: e.context || {},
2523
2427
  localState: void 0,
2524
2428
  rootState: e.builderContextSignal.rootState,
@@ -2526,32 +2430,32 @@ function EnableEditor(e) {
2526
2430
  })
2527
2431
  );
2528
2432
  }
2529
- function v({ url: m, key: f }) {
2530
- fetch$1(m).then((b) => b.json()).then((b) => {
2531
- var p, k;
2532
- const S = {
2433
+ function p({ url: u, key: m }) {
2434
+ fetch$1(u).then((h) => h.json()).then((h) => {
2435
+ var C, T;
2436
+ const x = {
2533
2437
  ...e.builderContextSignal.rootState,
2534
- [f]: b
2438
+ [m]: h
2535
2439
  };
2536
- (k = (p = e.builderContextSignal).rootSetState) == null || k.call(p, S), y[f] = !0;
2537
- }).catch((b) => {
2538
- console.error("error fetching dynamic data", m, b);
2440
+ (T = (C = e.builderContextSignal).rootSetState) == null || T.call(C, x), S[m] = !0;
2441
+ }).catch((h) => {
2442
+ console.error("error fetching dynamic data", u, h);
2539
2443
  });
2540
2444
  }
2541
- function C() {
2542
- var f, b, S;
2543
- const m = (S = (b = (f = e.builderContextSignal.content) == null ? void 0 : f.data) == null ? void 0 : b.httpRequests) != null ? S : {};
2544
- Object.entries(m).forEach(([p, k]) => {
2545
- if (k && (!y[p] || isEditing())) {
2546
- const j = E(k);
2547
- v({
2548
- url: j,
2549
- key: p
2445
+ function v() {
2446
+ var m, h, x;
2447
+ const u = (x = (h = (m = e.builderContextSignal.content) == null ? void 0 : m.data) == null ? void 0 : h.httpRequests) != null ? x : {};
2448
+ Object.entries(u).forEach(([C, T]) => {
2449
+ if (T && (!S[C] || isEditing())) {
2450
+ const A = E(T);
2451
+ p({
2452
+ url: A,
2453
+ key: C
2550
2454
  });
2551
2455
  }
2552
2456
  });
2553
2457
  }
2554
- function T() {
2458
+ function I() {
2555
2459
  isEditing() && window.dispatchEvent(
2556
2460
  new CustomEvent(
2557
2461
  "builder:component:stateChange",
@@ -2566,7 +2470,7 @@ function EnableEditor(e) {
2566
2470
  )
2567
2471
  );
2568
2472
  }
2569
- function w(m) {
2473
+ function w(u) {
2570
2474
  i(n + 1), window.addEventListener("message", d), registerInsertMenu(), setupBrowserForEditing({
2571
2475
  ...e.locale ? {
2572
2476
  locale: e.locale
@@ -2582,62 +2486,62 @@ function EnableEditor(e) {
2582
2486
  } : {}
2583
2487
  }), Object.values(
2584
2488
  e.builderContextSignal.componentInfos
2585
- ).forEach((f) => {
2586
- var S;
2587
- const b = createRegisterComponentMessage(f);
2588
- (S = window.parent) == null || S.postMessage(b, "*");
2489
+ ).forEach((m) => {
2490
+ var x;
2491
+ const h = createRegisterComponentMessage(m);
2492
+ (x = window.parent) == null || x.postMessage(h, "*");
2589
2493
  }), window.addEventListener(
2590
2494
  "builder:component:stateChangeListenerActivated",
2591
- T
2495
+ I
2592
2496
  );
2593
2497
  }
2594
- function R(m) {
2595
- const f = new URL(location.href).searchParams, b = f.get("builder.preview"), S = f.get(
2596
- `builder.preview.${b}`
2597
- ), p = f.get("apiKey") || f.get("builder.space");
2598
- b === e.model && p === e.apiKey && (!e.content || S === e.content.id) && fetchOneEntry({
2498
+ function R(u) {
2499
+ const m = new URL(location.href).searchParams, h = m.get("builder.preview"), x = m.get(
2500
+ `builder.preview.${h}`
2501
+ ), C = m.get("apiKey") || m.get("builder.space");
2502
+ h === e.model && C === e.apiKey && (!e.content || x === e.content.id) && fetchOneEntry({
2599
2503
  model: e.model,
2600
2504
  apiKey: e.apiKey,
2601
2505
  apiVersion: e.builderContextSignal.apiVersion
2602
- }).then((k) => {
2603
- k && a(k);
2506
+ }).then((T) => {
2507
+ T && a(T);
2604
2508
  });
2605
2509
  }
2606
2510
  return useEffect(() => {
2607
- var m;
2608
- return (m = t.current) == null || m.addEventListener(
2511
+ var u;
2512
+ return (u = t.current) == null || u.addEventListener(
2609
2513
  "initeditingbldr",
2610
2514
  w
2611
2515
  ), () => {
2612
- var f;
2613
- return (f = t.current) == null ? void 0 : f.removeEventListener(
2516
+ var m;
2517
+ return (m = t.current) == null ? void 0 : m.removeEventListener(
2614
2518
  "initeditingbldr",
2615
2519
  w
2616
2520
  );
2617
2521
  };
2618
2522
  }, []), useEffect(() => {
2619
- var m;
2620
- return (m = t.current) == null || m.addEventListener(
2523
+ var u;
2524
+ return (u = t.current) == null || u.addEventListener(
2621
2525
  "initpreviewingbldr",
2622
2526
  R
2623
2527
  ), () => {
2624
- var f;
2625
- return (f = t.current) == null ? void 0 : f.removeEventListener(
2528
+ var m;
2529
+ return (m = t.current) == null ? void 0 : m.removeEventListener(
2626
2530
  "initpreviewingbldr",
2627
2531
  R
2628
2532
  );
2629
2533
  };
2630
2534
  }, []), useEffect(() => {
2631
- var m, f;
2535
+ var u, m;
2632
2536
  if (isBrowser()) {
2633
2537
  if (isEditing() && t.current && t.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && getDefaultCanTrack(e.canTrack)) {
2634
- const S = (m = e.builderContextSignal.content) == null ? void 0 : m.testVariationId, p = (f = e.builderContextSignal.content) == null ? void 0 : f.id, k = e.apiKey;
2538
+ const x = (u = e.builderContextSignal.content) == null ? void 0 : u.testVariationId, C = (m = e.builderContextSignal.content) == null ? void 0 : m.id, T = e.apiKey;
2635
2539
  _track({
2636
2540
  type: "impression",
2637
2541
  canTrack: !0,
2638
- contentId: p,
2639
- apiKey: k,
2640
- variationId: S !== p ? S : void 0
2542
+ contentId: C,
2543
+ apiKey: T,
2544
+ variationId: x !== C ? x : void 0
2641
2545
  });
2642
2546
  }
2643
2547
  isPreviewing() && t.current && t.current.dispatchEvent(new CustomEvent("initpreviewingbldr"));
@@ -2645,16 +2549,16 @@ function EnableEditor(e) {
2645
2549
  }, []), useEffect(() => {
2646
2550
  e.apiKey || logger.error(
2647
2551
  "No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
2648
- ), h(), C(), T();
2552
+ ), b(), v(), I();
2649
2553
  }, []), useEffect(() => {
2650
2554
  e.content && a(e.content);
2651
2555
  }, [e.content]), useEffect(() => {
2652
2556
  }, [r]), useEffect(() => {
2653
- h();
2654
- }, [(B = (A = e.builderContextSignal.content) == null ? void 0 : A.data) == null ? void 0 : B.jsCode]), useEffect(() => {
2655
- C();
2656
- }, [(N = (P = e.builderContextSignal.content) == null ? void 0 : P.data) == null ? void 0 : N.httpRequests]), useEffect(() => {
2657
- T();
2557
+ b();
2558
+ }, [(P = (j = e.builderContextSignal.content) == null ? void 0 : j.data) == null ? void 0 : P.jsCode]), useEffect(() => {
2559
+ v();
2560
+ }, [(N = (B = e.builderContextSignal.content) == null ? void 0 : B.data) == null ? void 0 : N.httpRequests]), useEffect(() => {
2561
+ I();
2658
2562
  }, [e.builderContextSignal.rootState]), useEffect(() => {
2659
2563
  e.data && o(e.data);
2660
2564
  }, [e.data]), useEffect(() => {
@@ -2664,14 +2568,14 @@ function EnableEditor(e) {
2664
2568
  }, [e.locale]), useEffect(() => () => {
2665
2569
  isBrowser() && (window.removeEventListener("message", d), window.removeEventListener(
2666
2570
  "builder:component:stateChangeListenerActivated",
2667
- T
2571
+ I
2668
2572
  ));
2669
2573
  }, []), /* @__PURE__ */ jsx(builderContext.Provider, { value: e.builderContextSignal, children: e.builderContextSignal.content ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ createElement(
2670
2574
  l,
2671
2575
  {
2672
2576
  key: n,
2673
2577
  ref: t,
2674
- onClick: (m) => I(m),
2578
+ onClick: (u) => k(u),
2675
2579
  "builder-content-id": (F = e.builderContextSignal.content) == null ? void 0 : F.id,
2676
2580
  "builder-model": e.model,
2677
2581
  ...e.showContent ? {} : {
@@ -2679,7 +2583,7 @@ function EnableEditor(e) {
2679
2583
  "aria-hidden": !0
2680
2584
  },
2681
2585
  ...e.contentWrapperProps,
2682
- className: `variant-${((_ = e.content) == null ? void 0 : _.testVariationId) || ((V = e.content) == null ? void 0 : V.id)}`
2586
+ className: `variant-${((V = e.content) == null ? void 0 : V.testVariationId) || (($ = e.content) == null ? void 0 : $.id)}`
2683
2587
  },
2684
2588
  e.children
2685
2589
  ) }) : null });
@@ -2779,22 +2683,22 @@ const getRootStateInitialValue = ({
2779
2683
  meta: e == null ? void 0 : e.meta
2780
2684
  } : void 0;
2781
2685
  function ContentComponent(e) {
2782
- var l, c, d, h, y, u, g;
2686
+ var l, c, d, b, S, f, g;
2783
2687
  const [t, n] = useState(
2784
2688
  () => {
2785
- var x, I;
2689
+ var y, k;
2786
2690
  return getUpdateVariantVisibilityScript({
2787
2691
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
2788
- variationId: (x = e.content) == null ? void 0 : x.testVariationId,
2692
+ variationId: (y = e.content) == null ? void 0 : y.testVariationId,
2789
2693
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
2790
- contentId: (I = e.content) == null ? void 0 : I.id
2694
+ contentId: (k = e.content) == null ? void 0 : k.id
2791
2695
  });
2792
2696
  }
2793
2697
  );
2794
- function i(x) {
2795
- s((I) => ({
2796
- ...I,
2797
- rootState: x
2698
+ function i(y) {
2699
+ s((k) => ({
2700
+ ...k,
2701
+ rootState: y
2798
2702
  }));
2799
2703
  }
2800
2704
  const [o, a] = useState(
@@ -2808,10 +2712,10 @@ function ContentComponent(e) {
2808
2712
  ...components,
2809
2713
  ...e.customComponents || []
2810
2714
  ].reduce(
2811
- (x, { component: I, ...E }) => ({
2812
- ...x,
2715
+ (y, { component: k, ...E }) => ({
2716
+ ...y,
2813
2717
  [E.name]: {
2814
- component: I,
2718
+ component: k,
2815
2719
  ...serializeComponentInfo(E)
2816
2720
  }
2817
2721
  }),
@@ -2842,8 +2746,8 @@ function ContentComponent(e) {
2842
2746
  ...components,
2843
2747
  ...e.customComponents || []
2844
2748
  ].reduce(
2845
- (x, { component: I, ...E }) => ({
2846
- ...x,
2749
+ (y, { component: k, ...E }) => ({
2750
+ ...y,
2847
2751
  [E.name]: serializeComponentInfo(E)
2848
2752
  }),
2849
2753
  {}
@@ -2884,13 +2788,13 @@ function ContentComponent(e) {
2884
2788
  {
2885
2789
  contentId: (l = r.content) == null ? void 0 : l.id,
2886
2790
  cssCode: (d = (c = r.content) == null ? void 0 : c.data) == null ? void 0 : d.cssCode,
2887
- customFonts: (y = (h = r.content) == null ? void 0 : h.data) == null ? void 0 : y.customFonts
2791
+ customFonts: (S = (b = r.content) == null ? void 0 : b.data) == null ? void 0 : S.customFonts
2888
2792
  }
2889
2793
  ) }),
2890
2794
  /* @__PURE__ */ jsx(
2891
2795
  Blocks,
2892
2796
  {
2893
- blocks: (g = (u = r.content) == null ? void 0 : u.data) == null ? void 0 : g.blocks,
2797
+ blocks: (g = (f = r.content) == null ? void 0 : f.data) == null ? void 0 : g.blocks,
2894
2798
  context: r,
2895
2799
  registeredComponents: o,
2896
2800
  linkComponent: e.linkComponent
@@ -3088,7 +2992,8 @@ export {
3088
2992
  G as getContent,
3089
2993
  isEditing,
3090
2994
  isPreviewing,
3091
- register,
3092
- J as setEditorSettings,
3093
- Q as track
2995
+ J as register,
2996
+ Q as setEditorSettings,
2997
+ X as subscribeToEditor,
2998
+ Z as track
3094
2999
  };