@builder.io/sdk-react-nextjs 0.16.2 → 0.16.3
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.
- package/lib/browser/blocks-exports.cjs +24 -24
- package/lib/browser/blocks-exports.mjs +93 -92
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/init.cjs +1 -1
- package/lib/browser/init.mjs +1 -1
- package/lib/browser/server-entry-8a47b9f9.cjs +2 -0
- package/lib/browser/{server-entry-242f596f.js → server-entry-b8ecec52.js} +152 -158
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/blocks-exports.cjs +33 -33
- package/lib/edge/blocks-exports.mjs +60 -58
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/edge/init.cjs +1 -1
- package/lib/edge/init.mjs +1 -1
- package/lib/edge/server-entry-8a47b9f9.cjs +2 -0
- package/lib/{node/server-entry-fbf4e3a9.js → edge/server-entry-b8ecec52.js} +152 -158
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/node/blocks-exports.cjs +8 -8
- package/lib/node/blocks-exports.mjs +60 -59
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +2 -2
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +2 -2
- package/lib/node/{node-runtime-e1243cd6.cjs → node-runtime-e2a21ba1.cjs} +2 -2
- package/lib/node/{node-runtime-42e494ca.js → node-runtime-ffe74dec.js} +3 -2
- package/lib/node/server-entry-8a47b9f9.cjs +2 -0
- package/lib/{edge/server-entry-242f596f.js → node/server-entry-b8ecec52.js} +152 -158
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/package.json +1 -1
- package/types/cjs/constants/sdk-version.d.ts +1 -1
- package/types/cjs/functions/register-component.d.ts +2 -2
- package/types/esm/constants/sdk-version.d.ts +1 -1
- package/types/esm/functions/register-component.d.ts +2 -2
- package/lib/browser/server-entry-494604dc.cjs +0 -2
- package/lib/edge/server-entry-494604dc.cjs +0 -2
- package/lib/node/server-entry-db7b41aa.cjs +0 -2
|
@@ -3,12 +3,12 @@ var Ae = Object.defineProperty;
|
|
|
3
3
|
var Ve = (e, t, n) => t in e ? Ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
4
4
|
var ee = (e, t, n) => (Ve(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
5
5
|
import { jsx as l, Fragment as C, jsxs as E } from "react/jsx-runtime";
|
|
6
|
-
import { TARGET as M, isEditing as V, isBrowser as L, getUserAttributes as $e, checkIsDefined as z, logger as J,
|
|
7
|
-
import { useRef as
|
|
6
|
+
import { TARGET as M, isEditing as V, isBrowser as L, getUserAttributes as $e, checkIsDefined as z, logger as J, init as Fe, getDefaultCanTrack as q, _track as ue, isPreviewing as Le, createEditorListener as Oe, fetch as De, registerInsertMenu as je, setupBrowserForEditing as He, createRegisterComponentMessage as Me, fetchOneEntry as ke, serializeComponentInfo as me, handleABTestingSync as Ue } from "./server-entry-b8ecec52.js";
|
|
7
|
+
import { useRef as ie, useState as A, useEffect as R, createContext as _e } from "react";
|
|
8
8
|
import { useRouter as Ke } from "next/navigation";
|
|
9
9
|
import "lru-cache";
|
|
10
10
|
const ze = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]), qe = (e) => typeof e == "string" && ze.has(e.toLowerCase());
|
|
11
|
-
function
|
|
11
|
+
function oe(e) {
|
|
12
12
|
return /* @__PURE__ */ l(C, { children: qe(e.TagName) ? /* @__PURE__ */ l(C, { children: /* @__PURE__ */ l(e.TagName, { ...e.attributes, ...e.actionAttributes }) }) : /* @__PURE__ */ l(C, { children: typeof e.TagName == "string" ? /* @__PURE__ */ l(e.TagName, { ...e.attributes, ...e.actionAttributes, children: e.children }) : /* @__PURE__ */ l(e.TagName, { ...e.attributes, ...e.actionAttributes, children: e.children }) }) });
|
|
13
13
|
}
|
|
14
14
|
const j = () => {
|
|
@@ -40,7 +40,7 @@ function Ye(e) {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
return /* @__PURE__ */ l(
|
|
43
|
-
|
|
43
|
+
oe,
|
|
44
44
|
{
|
|
45
45
|
attributes: t(),
|
|
46
46
|
TagName: e.link ? e.builderLinkComponent || "a" : "button",
|
|
@@ -193,7 +193,7 @@ function H({
|
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
const nt = (e, t, n) => {
|
|
196
|
+
const ae = (e) => JSON.parse(JSON.stringify(e)), nt = (e, t, n) => {
|
|
197
197
|
if (Object(e) !== e)
|
|
198
198
|
return e;
|
|
199
199
|
const i = Array.isArray(t) ? t : t.toString().match(/[^.[\]]+/g);
|
|
@@ -208,7 +208,7 @@ const it = ({
|
|
|
208
208
|
}) => {
|
|
209
209
|
if (!e.bindings)
|
|
210
210
|
return e;
|
|
211
|
-
const a =
|
|
211
|
+
const a = ae(e), r = {
|
|
212
212
|
...a,
|
|
213
213
|
properties: {
|
|
214
214
|
...a.properties
|
|
@@ -386,7 +386,7 @@ const ct = ({
|
|
|
386
386
|
small: e,
|
|
387
387
|
medium: t
|
|
388
388
|
}) => {
|
|
389
|
-
const n =
|
|
389
|
+
const n = ae(Te);
|
|
390
390
|
if (!e || !t)
|
|
391
391
|
return n;
|
|
392
392
|
const i = Math.floor(e / 2);
|
|
@@ -431,7 +431,7 @@ function ht(e) {
|
|
|
431
431
|
});
|
|
432
432
|
return z(o.hide) ? !o.hide : z(o.show) ? o.show : !0;
|
|
433
433
|
}, n = function() {
|
|
434
|
-
var
|
|
434
|
+
var v, y, p;
|
|
435
435
|
const o = Y({
|
|
436
436
|
block: e.block,
|
|
437
437
|
localState: e.context.localState,
|
|
@@ -440,7 +440,7 @@ function ht(e) {
|
|
|
440
440
|
context: e.context.context,
|
|
441
441
|
shouldEvaluateBindings: !0
|
|
442
442
|
}), a = o.responsiveStyles, r = e.context.content, c = Re(
|
|
443
|
-
((
|
|
443
|
+
((v = r == null ? void 0 : r.meta) == null ? void 0 : v.breakpoints) || {}
|
|
444
444
|
), s = a == null ? void 0 : a.large, d = a == null ? void 0 : a.medium, m = a == null ? void 0 : a.small, u = o.id;
|
|
445
445
|
if (!u)
|
|
446
446
|
return "";
|
|
@@ -464,7 +464,7 @@ function ht(e) {
|
|
|
464
464
|
}) : "", b = o.animations && o.animations.find((T) => T.trigger === "hover");
|
|
465
465
|
let P = "";
|
|
466
466
|
if (b) {
|
|
467
|
-
const T = ((p = (
|
|
467
|
+
const T = ((p = (y = b.steps) == null ? void 0 : y[1]) == null ? void 0 : p.styles) || {};
|
|
468
468
|
P = _({
|
|
469
469
|
className: `${u}:hover`,
|
|
470
470
|
styles: {
|
|
@@ -555,9 +555,9 @@ function ce({
|
|
|
555
555
|
block: e
|
|
556
556
|
});
|
|
557
557
|
}
|
|
558
|
-
function
|
|
558
|
+
function St(e) {
|
|
559
559
|
return /* @__PURE__ */ l(
|
|
560
|
-
|
|
560
|
+
oe,
|
|
561
561
|
{
|
|
562
562
|
TagName: e.Wrapper,
|
|
563
563
|
attributes: ce({
|
|
@@ -576,7 +576,7 @@ function xt(e) {
|
|
|
576
576
|
}
|
|
577
577
|
);
|
|
578
578
|
}
|
|
579
|
-
function
|
|
579
|
+
function xt(e) {
|
|
580
580
|
function t() {
|
|
581
581
|
return e.includeBlockProps ? {
|
|
582
582
|
...ce({
|
|
@@ -626,7 +626,7 @@ const pt = ({
|
|
|
626
626
|
};
|
|
627
627
|
function ge(e) {
|
|
628
628
|
var n;
|
|
629
|
-
const t = e.isInteractive ?
|
|
629
|
+
const t = e.isInteractive ? xt : e.componentRef;
|
|
630
630
|
return /* @__PURE__ */ l(C, { children: e.componentRef ? /* @__PURE__ */ l(C, { children: /* @__PURE__ */ l(
|
|
631
631
|
t,
|
|
632
632
|
{
|
|
@@ -748,7 +748,7 @@ function G(e) {
|
|
|
748
748
|
},
|
|
749
749
|
f
|
|
750
750
|
)) }) : /* @__PURE__ */ E(
|
|
751
|
-
|
|
751
|
+
St,
|
|
752
752
|
{
|
|
753
753
|
Wrapper: o(),
|
|
754
754
|
block: i(),
|
|
@@ -863,24 +863,24 @@ function le(e) {
|
|
|
863
863
|
const wt = (e) => `builder-columns ${e}-breakpoints`;
|
|
864
864
|
function It(e) {
|
|
865
865
|
var b, P;
|
|
866
|
-
const t = typeof e.space == "number" ? e.space || 0 : 20, n = e.columns || [], i = e.stackColumnsAt || "tablet", o = function(
|
|
867
|
-
return
|
|
868
|
-
}, a = function(
|
|
866
|
+
const t = typeof e.space == "number" ? e.space || 0 : 20, n = e.columns || [], i = e.stackColumnsAt || "tablet", o = function(y) {
|
|
867
|
+
return y.link ? e.builderLinkComponent || "a" : "div";
|
|
868
|
+
}, a = function(y) {
|
|
869
869
|
var p;
|
|
870
|
-
return ((p = n[
|
|
871
|
-
}, r = function(
|
|
872
|
-
const p = a(
|
|
870
|
+
return ((p = n[y]) == null ? void 0 : p.width) || 100 / n.length;
|
|
871
|
+
}, r = function(y) {
|
|
872
|
+
const p = a(y), T = t * (n.length - 1) * (p / 100);
|
|
873
873
|
return `calc(${p}% - ${T}px)`;
|
|
874
874
|
}, c = function({
|
|
875
|
-
stackedStyle:
|
|
875
|
+
stackedStyle: y,
|
|
876
876
|
desktopStyle: p
|
|
877
877
|
}) {
|
|
878
|
-
return i === "tablet" ?
|
|
878
|
+
return i === "tablet" ? y : p;
|
|
879
879
|
}, s = function({
|
|
880
|
-
stackedStyle:
|
|
880
|
+
stackedStyle: y,
|
|
881
881
|
desktopStyle: p
|
|
882
882
|
}) {
|
|
883
|
-
return i === "never" ? p :
|
|
883
|
+
return i === "never" ? p : y;
|
|
884
884
|
}, d = e.stackColumnsAt === "never" ? "row" : e.reverseColumnsWhenStacked ? "column-reverse" : "column", m = function() {
|
|
885
885
|
return {
|
|
886
886
|
"--flex-dir": d,
|
|
@@ -889,8 +889,8 @@ function It(e) {
|
|
|
889
889
|
desktopStyle: "row"
|
|
890
890
|
})
|
|
891
891
|
};
|
|
892
|
-
}, u = function(
|
|
893
|
-
const p =
|
|
892
|
+
}, u = function(y) {
|
|
893
|
+
const p = y === 0 ? 0 : t, T = r(y), W = `${p}px`, O = "100%", D = 0;
|
|
894
894
|
return {
|
|
895
895
|
...{
|
|
896
896
|
display: "flex",
|
|
@@ -916,12 +916,13 @@ function It(e) {
|
|
|
916
916
|
desktopStyle: W
|
|
917
917
|
})
|
|
918
918
|
};
|
|
919
|
-
}, f = function(
|
|
919
|
+
}, f = function(y) {
|
|
920
920
|
var T, W;
|
|
921
921
|
return Re(
|
|
922
922
|
((W = (T = e.builderContext.content) == null ? void 0 : T.meta) == null ? void 0 : W.breakpoints) || {}
|
|
923
|
-
)[
|
|
923
|
+
)[y].max;
|
|
924
924
|
}, w = function() {
|
|
925
|
+
const y = `.${e.builderBlock.id}-breakpoints > .builder-column`;
|
|
925
926
|
return `
|
|
926
927
|
@media (max-width: ${f("medium")}px) {
|
|
927
928
|
.${e.builderBlock.id}-breakpoints {
|
|
@@ -929,7 +930,7 @@ function It(e) {
|
|
|
929
930
|
align-items: stretch;
|
|
930
931
|
}
|
|
931
932
|
|
|
932
|
-
|
|
933
|
+
${y} {
|
|
933
934
|
width: var(--column-width-tablet) !important;
|
|
934
935
|
margin-left: var(--column-margin-left-tablet) !important;
|
|
935
936
|
}
|
|
@@ -941,16 +942,16 @@ function It(e) {
|
|
|
941
942
|
align-items: stretch;
|
|
942
943
|
}
|
|
943
944
|
|
|
944
|
-
|
|
945
|
+
${y} {
|
|
945
946
|
width: var(--column-width-mobile) !important;
|
|
946
947
|
margin-left: var(--column-margin-left-mobile) !important;
|
|
947
948
|
}
|
|
948
949
|
},
|
|
949
950
|
`;
|
|
950
|
-
}, I = function(
|
|
951
|
+
}, I = function(y, p) {
|
|
951
952
|
return {
|
|
952
|
-
...
|
|
953
|
-
href:
|
|
953
|
+
...y.link ? {
|
|
954
|
+
href: y.link
|
|
954
955
|
} : {},
|
|
955
956
|
[j()]: "builder-column",
|
|
956
957
|
style: Ie(u(p))
|
|
@@ -960,7 +961,7 @@ function It(e) {
|
|
|
960
961
|
/* @__PURE__ */ E(
|
|
961
962
|
"div",
|
|
962
963
|
{
|
|
963
|
-
className: wt((b = e.builderBlock) == null ? void 0 : b.id) + " div-
|
|
964
|
+
className: wt((b = e.builderBlock) == null ? void 0 : b.id) + " div-2cd13691",
|
|
964
965
|
style: m(),
|
|
965
966
|
children: [
|
|
966
967
|
/* @__PURE__ */ l(
|
|
@@ -971,16 +972,16 @@ function It(e) {
|
|
|
971
972
|
nonce: e.builderContext.nonce
|
|
972
973
|
}
|
|
973
974
|
),
|
|
974
|
-
(P = e.columns) == null ? void 0 : P.map((
|
|
975
|
-
|
|
975
|
+
(P = e.columns) == null ? void 0 : P.map((v, y) => /* @__PURE__ */ l(
|
|
976
|
+
oe,
|
|
976
977
|
{
|
|
977
|
-
TagName: o(
|
|
978
|
+
TagName: o(v),
|
|
978
979
|
actionAttributes: {},
|
|
979
|
-
attributes: I(
|
|
980
|
+
attributes: I(v, y),
|
|
980
981
|
children: /* @__PURE__ */ l(
|
|
981
982
|
le,
|
|
982
983
|
{
|
|
983
|
-
path: `component.options.columns.${
|
|
984
|
+
path: `component.options.columns.${y}.blocks`,
|
|
984
985
|
parent: e.builderBlock.id,
|
|
985
986
|
styleProp: {
|
|
986
987
|
flexGrow: "1"
|
|
@@ -988,16 +989,16 @@ function It(e) {
|
|
|
988
989
|
context: e.builderContext,
|
|
989
990
|
registeredComponents: e.builderComponents,
|
|
990
991
|
linkComponent: e.builderLinkComponent,
|
|
991
|
-
blocks:
|
|
992
|
+
blocks: v.blocks
|
|
992
993
|
}
|
|
993
994
|
)
|
|
994
995
|
},
|
|
995
|
-
|
|
996
|
+
y
|
|
996
997
|
))
|
|
997
998
|
]
|
|
998
999
|
}
|
|
999
1000
|
),
|
|
1000
|
-
/* @__PURE__ */ l("style", { children: `.div-
|
|
1001
|
+
/* @__PURE__ */ l("style", { children: `.div-2cd13691 {
|
|
1001
1002
|
display: flex;
|
|
1002
1003
|
line-height: normal;
|
|
1003
1004
|
}` })
|
|
@@ -1677,7 +1678,7 @@ const Ht = {
|
|
|
1677
1678
|
}]
|
|
1678
1679
|
};
|
|
1679
1680
|
function Mt(e) {
|
|
1680
|
-
const t =
|
|
1681
|
+
const t = ie(null), [n, i] = A(() => []), [o, a] = A(() => []);
|
|
1681
1682
|
return R(() => {
|
|
1682
1683
|
var c;
|
|
1683
1684
|
if (!((c = t.current) != null && c.getElementsByTagName) || typeof window == "undefined")
|
|
@@ -1731,7 +1732,7 @@ const Ut = {
|
|
|
1731
1732
|
}]
|
|
1732
1733
|
}, _t = ["text/javascript", "application/javascript", "application/ecmascript"], Kt = (e) => _t.includes(e.type);
|
|
1733
1734
|
function zt(e) {
|
|
1734
|
-
const t =
|
|
1735
|
+
const t = ie(null), [n, i] = A(() => []), [o, a] = A(() => []), [r, c] = A(() => !1);
|
|
1735
1736
|
function s() {
|
|
1736
1737
|
if (!t.current || !t.current.getElementsByTagName)
|
|
1737
1738
|
return;
|
|
@@ -2164,7 +2165,7 @@ const cn = (e, t, n = !0) => {
|
|
|
2164
2165
|
}, ln = (e) => cn(e, (t) => {
|
|
2165
2166
|
const n = t.getAttribute("builder-id") || t.id;
|
|
2166
2167
|
return (n == null ? void 0 : n.indexOf("builder-")) === 0;
|
|
2167
|
-
}),
|
|
2168
|
+
}), Se = ({
|
|
2168
2169
|
event: e,
|
|
2169
2170
|
target: t
|
|
2170
2171
|
}) => {
|
|
@@ -2178,11 +2179,11 @@ const cn = (e, t, n = !0) => {
|
|
|
2178
2179
|
return {
|
|
2179
2180
|
targetBuilderElement: i || void 0,
|
|
2180
2181
|
metadata: {
|
|
2181
|
-
targetOffset: t ?
|
|
2182
|
+
targetOffset: t ? Se({
|
|
2182
2183
|
event: e,
|
|
2183
2184
|
target: t
|
|
2184
2185
|
}) : void 0,
|
|
2185
|
-
builderTargetOffset: n ?
|
|
2186
|
+
builderTargetOffset: n ? Se({
|
|
2186
2187
|
event: e,
|
|
2187
2188
|
target: n
|
|
2188
2189
|
}) : void 0,
|
|
@@ -2196,7 +2197,7 @@ async function dn({
|
|
|
2196
2197
|
}) {
|
|
2197
2198
|
return Fe(), globalThis._BUILDER_PREVIEW_LRU_CACHE.set(e, t), { [e]: t };
|
|
2198
2199
|
}
|
|
2199
|
-
function
|
|
2200
|
+
function xe(e, ...t) {
|
|
2200
2201
|
const n = Object(e);
|
|
2201
2202
|
for (let i = 1; i < arguments.length; i++) {
|
|
2202
2203
|
const o = arguments[i];
|
|
@@ -2229,8 +2230,8 @@ function fn(e) {
|
|
|
2229
2230
|
return;
|
|
2230
2231
|
}
|
|
2231
2232
|
Array.from(t).forEach((n) => {
|
|
2232
|
-
mn(e, n), n.style.transition = "none", n.style.transitionDelay = "0",
|
|
2233
|
-
n.style.transition = `all ${e.duration}s ${re(e.easing)}`, e.delay && (n.style.transitionDelay = e.delay + "s"),
|
|
2233
|
+
mn(e, n), n.style.transition = "none", n.style.transitionDelay = "0", xe(n.style, e.steps[0].styles), setTimeout(() => {
|
|
2234
|
+
n.style.transition = `all ${e.duration}s ${re(e.easing)}`, e.delay && (n.style.transitionDelay = e.delay + "s"), xe(n.style, e.steps[1].styles), setTimeout(() => {
|
|
2234
2235
|
n.style.transition = "", n.style.transitionDelay = "";
|
|
2235
2236
|
}, (e.delay || 0) * 1e3 + e.duration * 1e3 + 100);
|
|
2236
2237
|
});
|
|
@@ -2287,29 +2288,29 @@ font-weight: ${c};
|
|
|
2287
2288
|
text-align: inherit;
|
|
2288
2289
|
font-family: inherit;
|
|
2289
2290
|
}
|
|
2290
|
-
`,
|
|
2291
|
+
`, Sn = (e) => e ? "" : vn, xn = (e) => `variant-${e}`;
|
|
2291
2292
|
function pn(e) {
|
|
2292
2293
|
var W, O, D, X, Z, se, de;
|
|
2293
|
-
const t =
|
|
2294
|
+
const t = ie(null);
|
|
2294
2295
|
function n(g) {
|
|
2295
|
-
var
|
|
2296
|
+
var S, x;
|
|
2296
2297
|
const h = {
|
|
2297
2298
|
...e.builderContextSignal.rootState,
|
|
2298
2299
|
...g
|
|
2299
2300
|
};
|
|
2300
|
-
e.builderContextSignal.rootSetState ? (
|
|
2301
|
+
e.builderContextSignal.rootSetState ? (x = (S = e.builderContextSignal).rootSetState) == null || x.call(S, h) : e.builderContextSignal.rootState = h;
|
|
2301
2302
|
}
|
|
2302
2303
|
function i(g) {
|
|
2303
|
-
var
|
|
2304
|
+
var S, x, k, B, U;
|
|
2304
2305
|
const h = {
|
|
2305
2306
|
...e.builderContextSignal.content,
|
|
2306
2307
|
...g,
|
|
2307
2308
|
data: {
|
|
2308
|
-
...(
|
|
2309
|
+
...(S = e.builderContextSignal.content) == null ? void 0 : S.data,
|
|
2309
2310
|
...g == null ? void 0 : g.data
|
|
2310
2311
|
},
|
|
2311
2312
|
meta: {
|
|
2312
|
-
...(
|
|
2313
|
+
...(x = e.builderContextSignal.content) == null ? void 0 : x.meta,
|
|
2313
2314
|
...g == null ? void 0 : g.meta,
|
|
2314
2315
|
breakpoints: ((k = g == null ? void 0 : g.meta) == null ? void 0 : k.breakpoints) || ((U = (B = e.builderContextSignal.content) == null ? void 0 : B.meta) == null ? void 0 : U.breakpoints)
|
|
2315
2316
|
}
|
|
@@ -2337,10 +2338,10 @@ function pn(e) {
|
|
|
2337
2338
|
callbacks: {
|
|
2338
2339
|
configureSdk: (h) => {
|
|
2339
2340
|
var k;
|
|
2340
|
-
const { breakpoints:
|
|
2341
|
-
!
|
|
2341
|
+
const { breakpoints: S, contentId: x } = h;
|
|
2342
|
+
!x || x !== ((k = e.builderContextSignal.content) == null ? void 0 : k.id) || S && i({
|
|
2342
2343
|
meta: {
|
|
2343
|
-
breakpoints:
|
|
2344
|
+
breakpoints: S
|
|
2344
2345
|
}
|
|
2345
2346
|
});
|
|
2346
2347
|
},
|
|
@@ -2354,8 +2355,8 @@ function pn(e) {
|
|
|
2354
2355
|
})(g);
|
|
2355
2356
|
}
|
|
2356
2357
|
function s() {
|
|
2357
|
-
var h,
|
|
2358
|
-
const g = (
|
|
2358
|
+
var h, S;
|
|
2359
|
+
const g = (S = (h = e.builderContextSignal.content) == null ? void 0 : h.data) == null ? void 0 : S.jsCode;
|
|
2359
2360
|
g && H({
|
|
2360
2361
|
code: g,
|
|
2361
2362
|
context: e.context || {},
|
|
@@ -2370,15 +2371,15 @@ function pn(e) {
|
|
|
2370
2371
|
}
|
|
2371
2372
|
const [d, m] = A(() => ({})), [u, f] = A(() => ({})), [w, I] = A(() => !1);
|
|
2372
2373
|
function b(g) {
|
|
2373
|
-
var h,
|
|
2374
|
+
var h, S;
|
|
2374
2375
|
if (e.builderContextSignal.content) {
|
|
2375
|
-
const
|
|
2376
|
+
const x = (h = e.builderContextSignal.content) == null ? void 0 : h.testVariationId, k = (S = e.builderContextSignal.content) == null ? void 0 : S.id;
|
|
2376
2377
|
ue({
|
|
2377
2378
|
type: "click",
|
|
2378
2379
|
canTrack: q(e.canTrack),
|
|
2379
2380
|
contentId: k,
|
|
2380
2381
|
apiKey: e.apiKey,
|
|
2381
|
-
variationId:
|
|
2382
|
+
variationId: x !== k ? x : void 0,
|
|
2382
2383
|
...sn(g),
|
|
2383
2384
|
unique: !w
|
|
2384
2385
|
});
|
|
@@ -2386,8 +2387,8 @@ function pn(e) {
|
|
|
2386
2387
|
w || I(!0);
|
|
2387
2388
|
}
|
|
2388
2389
|
function P() {
|
|
2389
|
-
var h,
|
|
2390
|
-
const g = (
|
|
2390
|
+
var h, S, x;
|
|
2391
|
+
const g = (x = (S = (h = e.builderContextSignal.content) == null ? void 0 : h.data) == null ? void 0 : S.httpRequests) != null ? x : {};
|
|
2391
2392
|
Object.entries(g).forEach(([k, B]) => {
|
|
2392
2393
|
if (!B || u[k] || d[k] && !V())
|
|
2393
2394
|
return;
|
|
@@ -2416,13 +2417,13 @@ function pn(e) {
|
|
|
2416
2417
|
});
|
|
2417
2418
|
});
|
|
2418
2419
|
}
|
|
2419
|
-
function
|
|
2420
|
+
function v() {
|
|
2420
2421
|
V() && window.dispatchEvent(
|
|
2421
2422
|
new CustomEvent(
|
|
2422
2423
|
"builder:component:stateChange",
|
|
2423
2424
|
{
|
|
2424
2425
|
detail: {
|
|
2425
|
-
state:
|
|
2426
|
+
state: ae(e.builderContextSignal.rootState),
|
|
2426
2427
|
ref: {
|
|
2427
2428
|
name: e.model
|
|
2428
2429
|
}
|
|
@@ -2431,7 +2432,7 @@ function pn(e) {
|
|
|
2431
2432
|
)
|
|
2432
2433
|
);
|
|
2433
2434
|
}
|
|
2434
|
-
function
|
|
2435
|
+
function y(g) {
|
|
2435
2436
|
window.addEventListener("message", c), je(), He({
|
|
2436
2437
|
...e.locale ? {
|
|
2437
2438
|
locale: e.locale
|
|
@@ -2445,19 +2446,19 @@ function pn(e) {
|
|
|
2445
2446
|
}), Object.values(
|
|
2446
2447
|
e.builderContextSignal.componentInfos
|
|
2447
2448
|
).forEach((h) => {
|
|
2448
|
-
var
|
|
2449
|
-
const
|
|
2450
|
-
(
|
|
2449
|
+
var x;
|
|
2450
|
+
const S = Me(h);
|
|
2451
|
+
(x = window.parent) == null || x.postMessage(S, "*");
|
|
2451
2452
|
}), window.addEventListener(
|
|
2452
2453
|
"builder:component:stateChangeListenerActivated",
|
|
2453
|
-
|
|
2454
|
+
v
|
|
2454
2455
|
);
|
|
2455
2456
|
}
|
|
2456
2457
|
function p(g) {
|
|
2457
|
-
const h = new URL(location.href).searchParams,
|
|
2458
|
-
`builder.overrides.${
|
|
2458
|
+
const h = new URL(location.href).searchParams, S = h.get("builder.preview"), x = h.get(
|
|
2459
|
+
`builder.overrides.${S}`
|
|
2459
2460
|
), k = h.get("apiKey") || h.get("builder.space");
|
|
2460
|
-
|
|
2461
|
+
S === e.model && k === e.apiKey && (!e.content || x === e.content.id) && ke({
|
|
2461
2462
|
model: e.model,
|
|
2462
2463
|
apiKey: e.apiKey,
|
|
2463
2464
|
apiVersion: e.builderContextSignal.apiVersion
|
|
@@ -2470,12 +2471,12 @@ function pn(e) {
|
|
|
2470
2471
|
var g;
|
|
2471
2472
|
return (g = t.current) == null || g.addEventListener(
|
|
2472
2473
|
"initeditingbldr",
|
|
2473
|
-
|
|
2474
|
+
y
|
|
2474
2475
|
), () => {
|
|
2475
2476
|
var h;
|
|
2476
2477
|
return (h = t.current) == null ? void 0 : h.removeEventListener(
|
|
2477
2478
|
"initeditingbldr",
|
|
2478
|
-
|
|
2479
|
+
y
|
|
2479
2480
|
);
|
|
2480
2481
|
};
|
|
2481
2482
|
}, []), R(() => {
|
|
@@ -2494,13 +2495,13 @@ function pn(e) {
|
|
|
2494
2495
|
var g, h;
|
|
2495
2496
|
if (L()) {
|
|
2496
2497
|
if (V() && t.current && t.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && q(e.canTrack)) {
|
|
2497
|
-
const
|
|
2498
|
+
const x = (g = e.builderContextSignal.content) == null ? void 0 : g.testVariationId, k = (h = e.builderContextSignal.content) == null ? void 0 : h.id, B = e.apiKey;
|
|
2498
2499
|
ue({
|
|
2499
2500
|
type: "impression",
|
|
2500
2501
|
canTrack: !0,
|
|
2501
2502
|
contentId: k,
|
|
2502
2503
|
apiKey: B,
|
|
2503
|
-
variationId:
|
|
2504
|
+
variationId: x !== k ? x : void 0
|
|
2504
2505
|
});
|
|
2505
2506
|
}
|
|
2506
2507
|
Le() && V();
|
|
@@ -2508,14 +2509,14 @@ function pn(e) {
|
|
|
2508
2509
|
}, []), R(() => {
|
|
2509
2510
|
e.apiKey || J.error(
|
|
2510
2511
|
"No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop."
|
|
2511
|
-
), s(), P(),
|
|
2512
|
+
), s(), P(), v();
|
|
2512
2513
|
}, []), R(() => {
|
|
2513
2514
|
}, [e.content]), R(() => {
|
|
2514
2515
|
s();
|
|
2515
2516
|
}, [(O = (W = e.builderContextSignal.content) == null ? void 0 : W.data) == null ? void 0 : O.jsCode]), R(() => {
|
|
2516
2517
|
P();
|
|
2517
2518
|
}, [(X = (D = e.builderContextSignal.content) == null ? void 0 : D.data) == null ? void 0 : X.httpRequests]), R(() => {
|
|
2518
|
-
|
|
2519
|
+
v();
|
|
2519
2520
|
}, [e.builderContextSignal.rootState]), R(() => {
|
|
2520
2521
|
e.data && n(e.data);
|
|
2521
2522
|
}, [e.data]), R(() => {
|
|
@@ -2525,7 +2526,7 @@ function pn(e) {
|
|
|
2525
2526
|
}, [e.locale]), R(() => () => {
|
|
2526
2527
|
L() && (window.removeEventListener("message", c), window.removeEventListener(
|
|
2527
2528
|
"builder:component:stateChangeListenerActivated",
|
|
2528
|
-
|
|
2529
|
+
v
|
|
2529
2530
|
));
|
|
2530
2531
|
}, []), /* @__PURE__ */ l(rn.Provider, { value: e.builderContextSignal, children: e.builderContextSignal.content ? /* @__PURE__ */ l(
|
|
2531
2532
|
a,
|
|
@@ -2536,7 +2537,7 @@ function pn(e) {
|
|
|
2536
2537
|
"builder-model": e.model,
|
|
2537
2538
|
...o(),
|
|
2538
2539
|
...e.contentWrapperProps,
|
|
2539
|
-
className:
|
|
2540
|
+
className: xn(
|
|
2540
2541
|
((se = e.content) == null ? void 0 : se.testVariationId) || ((de = e.content) == null ? void 0 : de.id)
|
|
2541
2542
|
),
|
|
2542
2543
|
children: e.children
|
|
@@ -2552,7 +2553,7 @@ ${yn({
|
|
|
2552
2553
|
${bn({
|
|
2553
2554
|
customFonts: e.customFonts
|
|
2554
2555
|
})}
|
|
2555
|
-
${
|
|
2556
|
+
${Sn(e.isNestedRender)}
|
|
2556
2557
|
`.trim();
|
|
2557
2558
|
return /* @__PURE__ */ l(
|
|
2558
2559
|
Q,
|
|
@@ -2602,11 +2603,11 @@ function pe(e) {
|
|
|
2602
2603
|
...ye(),
|
|
2603
2604
|
...((r = e.customComponents) == null ? void 0 : r.filter(({ models: b }) => !(b != null && b.length) || !e.model ? !0 : b.includes(e.model))) || []
|
|
2604
2605
|
].reduce(
|
|
2605
|
-
(b, { component: P, ...
|
|
2606
|
+
(b, { component: P, ...v }) => ({
|
|
2606
2607
|
...b,
|
|
2607
|
-
[
|
|
2608
|
+
[v.name]: {
|
|
2608
2609
|
component: P,
|
|
2609
|
-
...me(
|
|
2610
|
+
...me(v)
|
|
2610
2611
|
}
|
|
2611
2612
|
}),
|
|
2612
2613
|
{}
|
|
@@ -2630,9 +2631,9 @@ function pe(e) {
|
|
|
2630
2631
|
...ye(),
|
|
2631
2632
|
...((c = e.customComponents) == null ? void 0 : c.filter(({ models: b }) => !(b != null && b.length) || !e.model ? !0 : b.includes(e.model))) || []
|
|
2632
2633
|
].reduce(
|
|
2633
|
-
(b, { component: P, ...
|
|
2634
|
+
(b, { component: P, ...v }) => ({
|
|
2634
2635
|
...b,
|
|
2635
|
-
[
|
|
2636
|
+
[v.name]: me(v)
|
|
2636
2637
|
}),
|
|
2637
2638
|
{}
|
|
2638
2639
|
),
|
package/lib/browser/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./blocks-exports.cjs"),e=require("./server-entry-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./blocks-exports.cjs"),e=require("./server-entry-8a47b9f9.cjs");require("react/jsx-runtime");require("react");require("next/navigation");require("lru-cache");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.setEditorSettings=e.setEditorSettings;exports.subscribeToEditor=e.subscribeToEditor;exports.track=e.track;
|
package/lib/browser/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Blocks as n, BuilderContext as m, Button as c, Columns as g, Content as p, Fragment as a, Image as d, Section as l, Symbol as u, Text as f, Video as B } from "./blocks-exports.mjs";
|
|
2
|
-
import { _processContentResult as E, createRegisterComponentMessage as h, fetchBuilderProps as x, fetchEntries as S, fetchOneEntry as b, getBuilderSearchParams as P, isEditing as k, isPreviewing as y, register as R, setEditorSettings as T, subscribeToEditor as v, track as w } from "./server-entry-
|
|
2
|
+
import { _processContentResult as E, createRegisterComponentMessage as h, fetchBuilderProps as x, fetchEntries as S, fetchOneEntry as b, getBuilderSearchParams as P, isEditing as k, isPreviewing as y, register as R, setEditorSettings as T, subscribeToEditor as v, track as w } from "./server-entry-b8ecec52.js";
|
|
3
3
|
import "react/jsx-runtime";
|
|
4
4
|
import "react";
|
|
5
5
|
import "next/navigation";
|
package/lib/browser/init.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ivm=require("isolated-vm"),serverEntry=require("./server-entry-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ivm=require("isolated-vm"),serverEntry=require("./server-entry-8a47b9f9.cjs");require("lru-cache");const SDK_NAME_FOR_TARGET=(()=>{switch(serverEntry.TARGET){case"rsc":return"react-nextjs";case"reactNative":return"react-native";default:return serverEntry.TARGET}})(),SDK_NAME=`@builder.io/sdk-${SDK_NAME_FOR_TARGET}`,noop=()=>{};let safeDynamicRequire=noop;try{safeDynamicRequire=eval("require")}catch(t){}const INJECTED_IVM_GLOBAL="BUILDER_IVM";let IVM_INSTANCE=null;const setIvm=(t,e={})=>{IVM_INSTANCE=t,setIsolateContext(e)},SHOULD_MENTION_INITIALIZE_SCRIPT=SDK_NAME==="@builder.io/sdk-react-nextjs"||SDK_NAME==="@builder.io/sdk-react",getIvm=()=>{try{if(IVM_INSTANCE)return IVM_INSTANCE;const e=safeDynamicRequire("isolated-vm");if(e)return e}catch(e){serverEntry.logger.error("isolated-vm import error.",e)}const t=`${serverEntry.MSG_PREFIX}could not import \`isolated-vm\` module for safe script execution on a Node server.
|
|
2
2
|
|
|
3
3
|
SOLUTION: In a server-only execution path within your application, do one of the following:
|
|
4
4
|
|
package/lib/browser/init.mjs
CHANGED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const ue=require("lru-cache"),I="rsc",b="[Builder.io]: ",d={log:(...e)=>console.log(b,...e),error:(...e)=>console.error(b,...e),warn:(...e)=>console.warn(b,...e),debug:(...e)=>console.debug(b,...e)};function c(){return typeof window!="undefined"&&typeof document!="undefined"}const de=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},U=e=>e instanceof URLSearchParams?de(e):e,V=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function le(){return c()&&window.self!==window.top}function M(e){return le()&&V(e||window.location.search).indexOf("builder.frameEditing=")!==-1}const fe=()=>{if(c()){const e=new URL(location.href);return e.pathname===""&&(e.pathname="/"),e}else return console.warn("Cannot get location for tracking in non-browser environment"),null},ge=()=>typeof navigator=="object"&&navigator.userAgent||"",_=()=>{const e=ge(),t={Android(){return e.match(/Android/i)},BlackBerry(){return e.match(/BlackBerry/i)},iOS(){return e.match(/iPhone|iPod/i)},Opera(){return e.match(/Opera Mini/i)},Windows(){return e.match(/IEMobile/i)||e.match(/WPDesktop/i)},any(){return t.Android()||t.BlackBerry()||t.iOS()||t.Opera()||t.Windows()||I==="reactNative"}},n=e.match(/Tablet|iPad/i),r=fe();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":t.any()?"mobile":"desktop"}},p=e=>e!=null,he=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},F=({name:e,canTrack:t})=>{var n;try{return t?(n=document.cookie.split("; ").find(r=>r.startsWith(`${e}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){d.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},D=async e=>F(e),pe=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),me=[["secure",""],["SameSite","None"]],ye=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?me:[[]],s=n?[["expires",n.toUTCString()]]:[[]],i=[[e,t],...s,["path","/"],["domain",he(window.location.hostname)],...o];return pe(i)},N=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=ye({name:e,value:t,expires:n});document.cookie=o}catch(o){d.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}},we="builder.tests",k=e=>`${we}.${e}`,Se=({contentId:e})=>D({name:k(e),canTrack:!0}),be=({contentId:e})=>F({name:k(e),canTrack:!0}),Ie=({contentId:e,value:t})=>N({name:k(e),value:t,canTrack:!0}),j=e=>p(e.id)&&p(e.variations)&&Object.keys(e.variations).length>0,ve=({id:e,variations:t})=>{var o;let n=0;const r=Math.random();for(const s in t){const i=(o=t[s])==null?void 0:o.testRatio;if(n+=i,r<n)return s}return e},K=e=>{const t=ve(e);return Ie({contentId:e.id,value:t}).catch(n=>{d.error("could not store A/B test variation: ",n)}),t},W=({item:e,testGroupId:t})=>{const n=e.variations[t];return t===e.id||!n?{testVariationId:e.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===e.id?"Default":"")}},Ee=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!j(e))return e;const n=be({contentId:e.id})||K({variations:e.variations,id:e.id}),r=W({item:e,testGroupId:n});return{...e,...r}},ke=async({item:e,canTrack:t})=>{if(!t||!j(e))return e;const r=await Se({contentId:e.id})||K({variations:e.variations,id:e.id}),o=W({item:e,testGroupId:r});return{...e,...o}},$=e=>p(e)?e:!0,Ce=e=>({type:"builder.registerComponent",data:G(e)}),Pe=e=>{const t=e.toString().trim();return`return (${!t.startsWith("function")&&!t.startsWith("(")?"function ":""}${t}).apply(this, arguments)`};function G(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?Pe(n):n))}const Re=e=>{const t=e.get("preview"),n=e.get("overrides."+t);return n||d.warn("No previewed ID found in search params."),n};function H(){globalThis._BUILDER_PREVIEW_LRU_CACHE||(globalThis._BUILDER_PREVIEW_LRU_CACHE=new ue.LRUCache({max:500,ttl:1e3*60*5}))}function Oe(e){H();const t=Re(e);return typeof t=="string"?globalThis._BUILDER_PREVIEW_LRU_CACHE.get(t):void 0}function Ae(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function Te(){const e=Ae().fetch;if(typeof e=="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 e}const z=Te();function E(e,t=null,n="."){return Object.keys(e).reduce((r,o)=>{const s=e[o],i=[t,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...E(s,i,n)}:{...r,[i]:s}},{})}function J(e,t,n={}){for(const r in e){const o=e[r],s=t?t+"."+r:r;o&&typeof o=="object"&&!Array.isArray(o)&&!Object.keys(o).find(i=>i.startsWith("$"))?J(o,s,n):n[s]=o}return n}const xe="v3",A="builder.",Be="options.",C=e=>{if(!e)return{};const t=U(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(A)){const o=r.replace(A,"").replace(Be,"");n[o]=t[r]}}),n},Le=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return C(e)},T=e=>typeof e=="number"&&!isNaN(e)&&e>=0,P=e=>{const{limit:t=30,userAttributes:n,query:r,model:o,apiKey:s,enrich:i,locale:u,apiVersion:y=xe,fields:m,omit:v,offset:l,cacheSeconds:g,staleCacheSeconds:h,sort:w,includeUnpublished:R}=e;if(!s)throw new Error("Missing API key");if(!["v3"].includes(y))throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);const ae=t!==1,a=new URL(`https://cdn.builder.io/api/${y}/content/${o}`);if(a.searchParams.set("apiKey",s),a.searchParams.set("limit",String(t)),a.searchParams.set("noTraverse",String(ae)),a.searchParams.set("includeRefs",String(!0)),u&&a.searchParams.set("locale",u),i&&a.searchParams.set("enrich",String(i)),a.searchParams.set("omit",v||"meta.componentsUsed"),m&&a.searchParams.set("fields",m),Number.isFinite(l)&&l>-1&&a.searchParams.set("offset",String(Math.floor(l))),typeof R=="boolean"&&a.searchParams.set("includeUnpublished",String(R)),g&&T(g)&&a.searchParams.set("cacheSeconds",String(g)),h&&T(h)&&a.searchParams.set("staleCacheSeconds",String(h)),w){const f=E({sort:w});for(const S in f)a.searchParams.set(S,JSON.stringify(f[S]))}const ce={...Le(),...U(e.options||{})},O=E(ce);for(const f in O)a.searchParams.set(f,String(O[f]));if(n&&a.searchParams.set("userAttributes",JSON.stringify(n)),r){const f=J({query:r});for(const S in f)a.searchParams.set(S,JSON.stringify(f[S]))}return a},Ue=e=>"results"in e;async function X(e){const t=await Q({...e,limit:1});return t&&t[0]||null}const Ve=async e=>{var s;const t=P(e);return await(await((s=e.fetch)!=null?s:z)(t.href,e.fetchOptions)).json()},q=async(e,t,n=P(e))=>{const r=$(e.canTrack);if(n.search.includes("preview=")){const s=[];for(const i of t.results){const u=Oe(n.searchParams);s.push(u||i)}t.results=s}if(!r||!(c()||I==="reactNative"))return t.results;try{const s=[];for(const i of t.results)s.push(await ke({item:i,canTrack:r}));t.results=s}catch(s){d.error("Could not process A/B tests. ",s)}return t.results};async function Q(e){try{const t=P(e),n=await Ve(e);return Ue(n)?q(e,n):(d.error("Error fetching data. ",{url:t,content:n,options:e}),null)}catch(t){return d.error("Error fetching data. ",t),null}}function Me(e){const t=e||(c()?window.location.search:void 0);return t?V(t).indexOf("builder.preview=")!==-1:!1}function _e(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}function Y(){return _e().replace(/-/g,"")}const Z="builderSessionId",Fe=async({canTrack:e})=>{if(!e)return;const t=await D({name:Z,canTrack:e});if(p(t))return t;{const n=De();return Ne({id:n,canTrack:e}),n}},De=()=>Y(),Ne=({id:e,canTrack:t})=>N({name:Z,value:e,canTrack:t}),ee=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,je=({key:e,canTrack:t})=>{var n;try{return t?(n=ee())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Ke=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=ee())==null||r.setItem(e,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},te="builderVisitorId",We=({canTrack:e})=>{if(!e)return;const t=je({key:te,canTrack:e});if(p(t))return t;{const n=$e();return Ge({id:n,canTrack:e}),n}},$e=()=>Y(),Ge=({id:e,canTrack:t})=>Ke({key:te,value:e,canTrack:t}),He=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Fe({canTrack:e}),n=We({canTrack:e});return{sessionId:t,visitorId:n}},ze=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await He({canTrack:t}),userAttributes:_(),ownerId:n}});async function ne(e){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(e.canTrack&&!M()&&(c()||I==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await ze(e)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(t=>{console.error("Failed to track: ",t)})}const Je=e=>ne({...e,canTrack:!0}),Xe=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function re(e,t){if(!t.origin.startsWith("http")&&!t.origin.startsWith("https"))return!1;const n=new URL(t.origin),r=n.hostname;return(e||Xe).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const qe="0.16.3",x={};function oe(e,t){let n=x[e];if(n||(n=x[e]=[]),n.push(t),c()){const r={type:"builder.register",data:{type:e,info:t}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(o){console.debug("Could not postmessage",o)}}}const Qe=()=>{oe("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let B=!1;const se=(e={})=>{var t,n;B||(B=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:I,version:qe,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var s,i;if(!re(e.trustedHosts,r))return;const{data:o}=r;if(o!=null&&o.type)switch(o.type){case"builder.evaluate":{const u=o.data.text,y=o.data.arguments||[],m=o.data.id,v=new Function(u);let l,g=null;try{l=v.apply(null,y)}catch(h){g=h}g?(s=window.parent)==null||s.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):l&&typeof l.then=="function"?l.then(h=>{var w;(w=window.parent)==null||w.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:l,id:m}},"*");break}}})))},ie=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!re(t,r))return;const{data:o}=r;if(o)switch(o.type){case"builder.configureSdk":{n.configureSdk(o.data);break}case"builder.triggerAnimation":{n.animation(o.data);break}case"builder.contentUpdate":{const s=o.data,i=s.key||s.alias||s.entry||s.modelName,u=s.data;i===e&&n.contentUpdate(u);break}}},Ye=(e,t,n)=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};se();const r=ie({callbacks:{contentUpdate:t,animation:()=>{},configureSdk:()=>{}},model:e,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},L={};function Ze(e){if(c()){Object.assign(L,e);const t={type:"builder.settingsChange",data:L};parent.postMessage(t,"*")}}const et=async e=>{var r,o,s;const t=e.path||((r=e.url)==null?void 0:r.pathname)||((o=e.userAttributes)==null?void 0:o.urlPath),n={...e,apiKey:e.apiKey,model:e.model||"page",userAttributes:{...e.userAttributes,...t?{urlPath:t}:{}},options:C(e.searchParams||((s=e.url)==null?void 0:s.searchParams)||e.options)};return{apiKey:n.apiKey,model:n.model,content:await X(n)}};exports.MSG_PREFIX=b;exports.TARGET=I;exports._processContentResult=q;exports._track=ne;exports.checkIsDefined=p;exports.createEditorListener=ie;exports.createRegisterComponentMessage=Ce;exports.fetch=z;exports.fetchBuilderProps=et;exports.fetchEntries=Q;exports.fetchOneEntry=X;exports.getBuilderSearchParams=C;exports.getDefaultCanTrack=$;exports.getUserAttributes=_;exports.handleABTestingSync=Ee;exports.init=H;exports.isBrowser=c;exports.isEditing=M;exports.isPreviewing=Me;exports.logger=d;exports.register=oe;exports.registerInsertMenu=Qe;exports.serializeComponentInfo=G;exports.setEditorSettings=Ze;exports.setupBrowserForEditing=se;exports.subscribeToEditor=Ye;exports.track=Je;
|