UNPKG

@builder.io/sdk-vue

Version:
1,803 lines (1,799 loc) 145 kB
import "./style.css"; import { defineComponent as g, openBlock as c, createElementBlock as p, Fragment as T, createBlock as y, resolveDynamicComponent as j, mergeProps as C, toHandlers as x, withCtx as N, renderSlot as A, resolveComponent as k, createTextVNode as St, toDisplayString as ne, defineAsyncComponent as H, createVNode as P, renderList as V, createCommentVNode as v, h as We, createElementVNode as q, normalizeStyle as F, normalizeClass as z, markRaw as Ct } from "vue"; const wt = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]), Tt = (e) => typeof e == "string" && wt.has(e.toLowerCase()); function W(e = {}, t, n) { const o = {}; for (const r in e) { if (!e[r] || n && !r.startsWith(t)) continue; const i = n ? r.replace(t, "") : r; o[i] = e[r]; } return o; } const It = g({ name: "dynamic-renderer", props: ["TagName", "attributes", "actionAttributes"], data() { return { isEmptyElement: Tt }; } }), b = (e, t) => { const n = e.__vccOpts || e; for (const [o, r] of t) n[o] = r; return n; }; function $t(e, t, n, o, r, i) { return e.isEmptyElement(e.TagName) ? (c(), y(j(e.TagName), C({ key: 1 }, e.attributes, x(e.actionAttributes)), null, 16)) : (c(), p(T, { key: 0 }, [ typeof e.TagName == "string" ? (c(), y(j(e.TagName), C({ key: 0 }, e.attributes, x(e.actionAttributes)), { default: N(() => [ A(e.$slots, "default") ]), _: 3 }, 16)) : (c(), y(j(e.TagName), C({ key: 1 }, e.attributes, x(e.actionAttributes)), { default: N(() => [ A(e.$slots, "default") ]), _: 3 }, 16)) ], 64)); } const me = /* @__PURE__ */ b(It, [["render", $t]]), qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: me }, Symbol.toStringTag, { value: "Module" })), R = "vue", _ = () => { switch (R) { case "react": case "reactNative": case "rsc": return "className"; case "svelte": case "vue": case "solid": case "qwik": case "angular": return "class"; } }, Rt = g({ name: "builder-button", components: { DynamicRenderer: me }, props: [ "attributes", "link", "openLinkInNewTab", "builderLinkComponent", "text" ], data() { return { filterAttrs: W }; }, methods: { attrs() { return { ...W(this.attributes, "v-on:", !1), [_()]: `${this.link ? "" : "builder-button"} ${this.attributes[_()] || ""}`, ...this.link ? { href: this.link, target: this.openLinkInNewTab ? "_blank" : void 0, role: "link" } : { role: "button" } }; } } }); function Et(e, t, n, o, r, i) { const s = k("DynamicRenderer"); return c(), y(s, { attributes: e.attrs(), TagName: e.link ? e.builderLinkComponent || "a" : "button", actionAttributes: e.filterAttrs(e.attributes, "v-on:", !0) }, { default: N(() => [ St(ne(e.text), 1) ]), _: 1 }, 8, ["attributes", "TagName", "actionAttributes"]); } const Pt = /* @__PURE__ */ b(Rt, [["render", Et]]), Bt = Symbol(), ce = { Builder: { content: null, context: {}, localState: void 0, rootSetState() { }, rootState: {}, apiKey: null, apiVersion: void 0, componentInfos: {}, inheritedStyles: {}, BlocksWrapper: "div", BlocksWrapperProps: {}, nonce: "", model: "" }, key: Bt }, xt = Symbol(), Ne = { Components: { registeredComponents: {} }, key: xt }; function At(e) { var t; return { ...(t = e.component) == null ? void 0 : t.options, ...e.options }; } function Vt(e, ...t) { const n = Object.assign({}, e); for (const o of t) delete n[o]; return n; } const Q = "[Builder.io]: ", B = { log: (...e) => console.log(Q, ...e), error: (...e) => console.error(Q, ...e), warn: (...e) => console.warn(Q, ...e), debug: (...e) => console.debug(Q, ...e) }, Oe = (e, t, n) => { const o = String.prototype.split.call(t, /[,[\].]+?/).filter(Boolean).reduce((r, i) => r != null ? r[i] : r, e); return o === void 0 || o === e ? n : o; }; function $() { return typeof window < "u" && typeof document < "u"; } const Wt = (e) => { const t = {}; return e.forEach((n, o) => { t[o] = n; }), t; }, Fe = (e) => e instanceof URLSearchParams ? Wt(e) : e, De = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString(); function Nt() { return $() && window.self !== window.top; } function E(e) { return Nt() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser. De(e || window.location.search).indexOf("builder.frameEditing=") !== -1; } const Ot = () => { if ($()) { 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; }, Ft = () => typeof navigator == "object" && navigator.userAgent || "", Le = () => { const e = Ft(), 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() || R === "reactNative"; } }, n = e.match(/Tablet|iPad/i), o = Ot(); return { urlPath: o == null ? void 0 : o.pathname, host: (o == null ? void 0 : o.host) || (o == null ? void 0 : o.hostname), device: n ? "tablet" : t.any() ? "mobile" : "desktop" }; }, Dt = ({ builder: e, context: t, event: n, state: o }) => Object.entries({ state: o, Builder: e, // legacy builder: e, context: t, event: n }), Lt = () => ({ isEditing: E(), isBrowser: $(), isServer: !$(), getUserAttributes: () => Le() }), Ut = (e, { isExpression: t = !0 }) => /* we disable this for cases where we definitely don't want a return */ t && !(e.includes(";") || e.includes(" return ") || e.trim().startsWith("return ")) ? `return (${e});` : e; function Ue({ rootState: e, localState: t, rootSetState: n }) { return new Proxy(e, { get: (o, r) => { if (t && r in t) return t[r]; const i = o[r]; return typeof i == "object" && i !== null ? Ue({ rootState: i, localState: void 0, rootSetState: n ? (s) => { o[r] = s, n(o); } : void 0 }) : i; }, set: (o, r, i) => { if (t && r in t) throw new Error("Writing to local state is not allowed as it is read-only."); return o[r] = i, n == null || n(o), !0; } }); } const Te = ({ code: e, builder: t, context: n, event: o, localState: r, rootSetState: i, rootState: s }) => { const l = Dt({ builder: t, context: n, event: o, state: Ue({ rootState: s, localState: r, rootSetState: i }) }); return new Function(...l.map(([a]) => a), e)(...l.map(([, a]) => a)); }, D = (e) => e != null; function Mt() { var e; return typeof process < "u" && D((e = process == null ? void 0 : process.versions) == null ? void 0 : e.node); } const Ht = ({ shouldLogWarning: e }) => { var r; if (!Mt()) return !1; const t = process.arch === "arm64", n = process.version.startsWith("v20"), o = (r = process.env.NODE_OPTIONS) == null ? void 0 : r.includes("--no-node-snapshot"); return t && n && !o ? (e && B.log("Skipping usage of `isolated-vm` to avoid crashes in Node v20 on an arm64 machine.\n If you would like to use the `isolated-vm` package on this machine, please provide the `NODE_OPTIONS=--no-node-snapshot` config to your Node process.\n See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.\n "), !0) : !1; }, jt = (e) => ($() || Ht({ shouldLogWarning: !0 }), Te(e)), Kt = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/, qt = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/, zt = (e) => { var t, n, o, r, i, s; return ((o = (n = (t = Kt.exec(e.trim())) == null ? void 0 : t.groups) == null ? void 0 : n.getPath) == null ? void 0 : o.slice(1)) || ((s = (i = (r = qt.exec(e.trim())) == null ? void 0 : r.groups) == null ? void 0 : i.getPath) == null ? void 0 : s.slice(1)); }; function J({ code: e, context: t, localState: n, rootState: o, rootSetState: r, event: i, isExpression: s = !0 }) { if (e.trim() === "") return; const l = zt(e.trim()); if (l) return Oe({ ...o, ...n }, l); const a = { code: Ut(e, { isExpression: s }), builder: Lt(), context: t, event: i, rootSetState: r, rootState: o, localState: n }; try { return jt(a); } catch (u) { B.error("Failed code evaluation: " + u.message, { code: e }); return; } } function ee(e, t, n = null, o = null, r = /* @__PURE__ */ new WeakSet()) { if (e == null || typeof e != "object") { t(e, (i) => { n !== null && o !== null && (n[o] = i); }); return; } r.has(e) || (r.add(e), Array.isArray(e) ? e.forEach((i, s) => { t(i, (a) => { e[s] = a; }), ee(i, t, e, s, r); }) : Object.entries(e).forEach(([i, s]) => { t(s, (a) => { e[i] = a; }), ee(s, t, e, i, r); })); } function Me(e) { return e && typeof e == "object" && e["@type"] === "@builder.io/core:LocalizedValue"; } function Gt(e) { if (!e || !Object.getOwnPropertyNames(e).length) return !1; let t = !1; return ee(e, (n) => { if (Me(n)) { t = !0; return; } }), t; } function Jt(e, t) { return !e || !Object.getOwnPropertyNames(e).length ? {} : (ee(e, (n, o) => { Me(n) && o(n[t] ?? void 0); }), e); } function Yt(e, t) { var n, o; return (n = e.component) != null && n.options && Gt((o = e.component) == null ? void 0 : o.options) && (t || console.warn("[Builder.io] In order to use localized fields in Builder, you must pass a locale prop to the BuilderComponent or to options object while fetching the content to resolve localized fields. Learn more: https://www.builder.io/c/docs/localization-inline#targeting-and-inline-localization"), e.component.options = Jt(e.component.options, t ?? "Default")), e; } const he = (e) => JSON.parse(JSON.stringify(e)), He = (e, t, n) => { if (Object(e) !== e) return e; const o = Array.isArray(t) ? t : t.toString().match(/[^.[\]]+/g); return o.slice(0, -1).reduce((r, i, s) => Object(r[i]) === r[i] ? r[i] : r[i] = Math.abs(Number(o[s + 1])) >> 0 === +o[s + 1] ? [] : {}, e)[o[o.length - 1]] = n, e; }; function de(e) { if (e === null || typeof e != "object") return e; if (Array.isArray(e)) return e.map((n) => de(n)); if (e["@type"] === "@builder.io/sdk:Element") return e; const t = {}; for (const n in e) n !== "meta" && Object.prototype.hasOwnProperty.call(e, n) && (t[n] = de(e[n])); return t; } const Xt = ["svelte", "vue", "angular", "qwik", "solid"].includes(R), Qt = (e) => { if (Xt) { const t = he(e); return { ...t, properties: { ...t.properties }, actions: { ...t.actions } }; } else { const t = de(Vt(e, "children", "meta")); return { ...t, properties: { ...t.properties }, actions: { ...t.actions }, children: e.children, meta: e.meta }; } }, Zt = ({ block: e, context: t, localState: n, rootState: o, rootSetState: r }) => { if (!e.bindings) return e; const i = Qt(e); for (const s in e.bindings) { const l = e.bindings[s], a = J({ code: l, localState: n, rootState: o, rootSetState: r, context: t }); He(i, s, a); } return i; }; function _t({ block: e, context: t, shouldEvaluateBindings: n, localState: o, rootState: r, rootSetState: i }) { let s = Yt(e, r.locale); return s = s, n ? Zt({ block: s, localState: o, rootState: r, rootSetState: i, context: t }) : s; } function je(e) { const t = e || ($() ? window.location.search : void 0); return t ? De(t).indexOf("builder.preview=") !== -1 : !1; } const en = (e) => ({ type: "builder.registerComponent", data: te(e) }), tn = (e) => { const t = e.toString().trim(), n = /^[a-zA-Z0-9_]+\s*=>/i.test(t); return `return (${!t.startsWith("function") && !t.startsWith("async") && !t.startsWith("(") && !n ? "function " : ""}${t}).apply(this, arguments)`; }; function te(e) { return JSON.parse(JSON.stringify(e, (t, n) => typeof n == "function" ? tn(n) : n)); } const Ie = {}; function nn(e, t) { e === "plugin" && (t = te(t)); let n = Ie[e]; if (n || (n = Ie[e] = []), n.push(t), $()) { const o = { type: "builder.register", data: { type: e, info: t } }; try { parent.postMessage(o, "*"), parent !== window && window.postMessage(o, "*"); } catch (r) { console.debug("Could not postmessage", r); } } } const $e = {}; function zi(e) { if ($()) { Object.assign($e, e); const t = { type: "builder.settingsChange", data: $e }; parent.postMessage(t, "*"); } } const Re = "builder.", on = "options.", Ke = (e) => { if (!e) return {}; const t = Fe(e), n = {}; return Object.keys(t).forEach((o) => { if (o.startsWith(Re)) { const r = o.replace(Re, "").replace(on, ""); n[r] = t[o]; } }), n; }, rn = () => { if (!$()) return {}; const e = new URLSearchParams(window.location.search); return Ke(e); }, qe = "3.0.1", ze = () => ({ "X-Builder-SDK": R, "X-Builder-SDK-GEN": "2", "X-Builder-SDK-Version": qe }), sn = (e) => { if (e === "localhost" || e === "127.0.0.1") return e; const t = e.split("."); return t.length > 2 ? t.slice(1).join(".") : e; }, Ge = ({ name: e, canTrack: t }) => { var n; try { return t ? (n = document.cookie.split("; ").find((o) => o.startsWith(`${e}=`))) == null ? void 0 : n.split("=")[1] : void 0; } catch (o) { B.warn("[COOKIE] GET error: ", (o == null ? void 0 : o.message) || o); return; } }, Je = async (e) => Ge(e), an = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(D).join("; "), ln = [["secure", ""], ["SameSite", "None"]], cn = ({ name: e, value: t, expires: n }) => { const r = ($() ? location.protocol === "https:" : !0) ? ln : [[]], i = n ? [["expires", n.toUTCString()]] : [[]], s = [[e, t], ...i, ["path", "/"], ["domain", sn(window.location.hostname)], ...r]; return an(s); }, Ye = async ({ name: e, value: t, expires: n, canTrack: o }) => { try { if (!o) return; const r = cn({ name: e, value: t, expires: n }); document.cookie = r; } catch (r) { B.warn("[COOKIE] SET error: ", (r == null ? void 0 : r.message) || r); } }; function dn() { 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 Xe() { return dn().replace(/-/g, ""); } const Qe = "builderSessionId", un = async ({ canTrack: e }) => { if (!e) return; const t = await Je({ name: Qe, canTrack: e }); if (D(t)) return t; { const n = pn(); return mn({ id: n, canTrack: e }), n; } }, pn = () => Xe(), mn = ({ id: e, canTrack: t }) => Ye({ name: Qe, value: e, canTrack: t }), Ze = () => $() && typeof localStorage < "u" ? localStorage : void 0, hn = ({ key: e, canTrack: t }) => { var n; try { return t ? (n = Ze()) == null ? void 0 : n.getItem(e) : void 0; } catch (o) { console.debug("[LocalStorage] GET error: ", o); return; } }, fn = ({ key: e, canTrack: t, value: n }) => { var o; try { t && ((o = Ze()) == null || o.setItem(e, n)); } catch (r) { console.debug("[LocalStorage] SET error: ", r); } }, _e = "builderVisitorId", gn = ({ canTrack: e }) => { if (!e) return; const t = hn({ key: _e, canTrack: e }); if (D(t)) return t; { const n = bn(); return yn({ id: n, canTrack: e }), n; } }, bn = () => Xe(), yn = ({ id: e, canTrack: t }) => fn({ key: _e, value: e, canTrack: t }); function fe(e) { var t; typeof process < "u" && ((t = process.env) != null && t.DEBUG) && String(process.env.DEBUG) == "true" && B.log(e); } const kn = async ({ canTrack: e }) => { if (!e) return { visitorId: void 0, sessionId: void 0 }; const t = await un({ canTrack: e }), n = gn({ canTrack: e }); return { sessionId: t, visitorId: n }; }, vn = async ({ type: e, canTrack: t, apiKey: n, metadata: o, ...r }) => ({ type: e, data: { ...r, metadata: { url: location.href, ...o }, ...await kn({ canTrack: t }), userAttributes: Le(), ownerId: n } }); async function ue({ apiHost: e, ...t }) { if (!t.apiKey) { B.error("Missing API key for track call. Please provide your API key."); return; } if (!t.canTrack || E() || !($() || R === "reactNative")) return; const o = `${e || "https://cdn.builder.io"}/api/v1/track`; return fe(o), fetch(o, { method: "POST", body: JSON.stringify({ events: [await vn(t)] }), headers: { "content-type": "application/json", ...ze() }, mode: "cors" }).catch((r) => { console.error("Failed to track: ", r); }); } const Gi = (e) => ue({ ...e, canTrack: !0 }), Sn = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"]; function et(e, t) { if (!t.origin.startsWith("http") && !t.origin.startsWith("https")) return !1; const n = new URL(t.origin), o = n.hostname; return (e || Sn).findIndex((r) => r.startsWith("*.") ? o.endsWith(r.slice(1)) : r === o) > -1; } const Cn = () => { nn("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 Ee = !1; const tt = (e = {}) => { var t, n; Ee || (Ee = !0, $() && ((t = window.parent) == null || t.postMessage({ type: "builder.sdkInfo", data: { target: R, version: qe, supportsPatchUpdates: !1, // Supports builder-model="..." attribute which is needed to // scope our '+ add block' button styling supportsAddBlockScoping: !0, supportsCustomBreakpoints: !0 } }, "*"), (n = window.parent) == null || n.postMessage({ type: "builder.updateContent", data: { options: e } }, "*"), window.addEventListener("message", (o) => { var i, s; if (!et(e.trustedHosts, o)) return; const { data: r } = o; if (r != null && r.type) switch (r.type) { case "builder.evaluate": { const l = r.data.text, a = r.data.arguments || [], u = r.data.id, m = new Function(l); let h, d = null; try { h = m.apply(null, a); } catch (f) { d = f; } d ? (i = window.parent) == null || i.postMessage({ type: "builder.evaluateError", data: { id: u, error: d.message } }, "*") : h && typeof h.then == "function" ? h.then((f) => { var S; (S = window.parent) == null || S.postMessage({ type: "builder.evaluateResult", data: { id: u, result: f } }, "*"); }).catch(console.error) : (s = window.parent) == null || s.postMessage({ type: "builder.evaluateResult", data: { result: h, id: u } }, "*"); break; } } }))); }, nt = ({ model: e, trustedHosts: t, callbacks: n }) => (o) => { if (!et(t, o)) return; const { data: r } = o; if (r) switch (r.type) { case "builder.configureSdk": { n.configureSdk(r.data); break; } case "builder.triggerAnimation": { n.animation(r.data); break; } case "builder.contentUpdate": { const i = r.data, s = i.key || i.alias || i.entry || i.modelName, l = i.data; s === e && n.contentUpdate(l); break; } } }, Ji = (e, t, n) => { if (!$) return B.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => { }; tt(); const o = nt({ callbacks: { contentUpdate: t, animation: () => { }, configureSdk: () => { } }, model: e, trustedHosts: n == null ? void 0 : n.trustedHosts }); return window.addEventListener("message", o), () => { window.removeEventListener("message", o); }; }, wn = "builder.tests", ge = (e) => `${wn}.${e}`, Tn = ({ contentId: e }) => Je({ name: ge(e), canTrack: !0 }), In = ({ contentId: e }) => Ge({ name: ge(e), canTrack: !0 }), $n = ({ contentId: e, value: t }) => Ye({ name: ge(e), value: t, canTrack: !0 }), ot = (e) => D(e.id) && D(e.variations) && Object.keys(e.variations).length > 0, Rn = ({ id: e, variations: t }) => { var r; let n = 0; const o = Math.random(); for (const i in t) { const s = (r = t[i]) == null ? void 0 : r.testRatio; if (n += s, o < n) return i; } return e; }, rt = (e) => { const t = Rn(e); return $n({ contentId: e.id, value: t }).catch((n) => { B.error("could not store A/B test variation: ", n); }), t; }, it = ({ item: e, testGroupId: t }) => { const n = e.variations[t]; return t === e.id || // handle edge-case where `testGroupId` points to non-existing variation !n ? { testVariationId: e.id, testVariationName: "Default" } : { data: n.data, testVariationId: n.id, testVariationName: n.name || (n.id === e.id ? "Default" : "") }; }, En = ({ item: e, canTrack: t }) => { if (!t) return e; if (!e) return; if (!ot(e)) return e; const n = In({ contentId: e.id }) || rt({ variations: e.variations, id: e.id }), o = it({ item: e, testGroupId: n }); return { ...e, ...o }; }, Pn = async ({ item: e, canTrack: t }) => { if (!t || !ot(e)) return e; const o = await Tn({ contentId: e.id }) || rt({ variations: e.variations, id: e.id }), r = it({ item: e, testGroupId: o }); return { ...e, ...r }; }, G = (e) => D(e) ? e : !0; function Bn() { return typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : globalThis; } function xn() { const e = Bn().fetch; if (typeof e > "u") throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project. 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 An = xn(); function pe(e, t = null, n = ".") { return Object.keys(e).reduce((o, r) => { const i = e[r], s = [t, r].filter(Boolean).join(n); return [typeof i == "object", i !== null, !(Array.isArray(i) && i.length === 0)].every(Boolean) ? { ...o, ...pe(i, s, n) } : { ...o, [s]: i }; }, {}); } function st(e, t, n = {}) { for (const o in e) { const r = e[o], i = t ? t + "." + o : o; r && typeof r == "object" && !Array.isArray(r) && !Object.keys(r).find((s) => s.startsWith("$")) ? st(r, i, n) : n[i] = r; } return n; } const Vn = "v3", Pe = (e) => typeof e == "number" && !isNaN(e) && e >= 0, be = (e) => { const { limit: t = 30, userAttributes: n, query: o, model: r, apiKey: i, enrich: s, locale: l, apiVersion: a = Vn, fields: u, omit: m, offset: h, cacheSeconds: d, staleCacheSeconds: f, sort: S, includeUnpublished: w, apiHost: L } = e; if (!i) throw new Error("Missing API key"); if (!["v3"].includes(a)) throw new Error(`Invalid apiVersion: expected 'v3', received '${a}'`); const yt = t !== 1, kt = L || "https://cdn.builder.io", I = new URL(`${kt}/api/${a}/content/${r}`); I.searchParams.set("apiKey", i), I.searchParams.set("limit", String(t)), I.searchParams.set("noTraverse", String(yt)), I.searchParams.set("includeRefs", String(!0)); const oe = l || (n == null ? void 0 : n.locale); let X = n; if (oe && (I.searchParams.set("locale", oe), X = { locale: oe, ...X }), s && I.searchParams.set("enrich", String(s)), I.searchParams.set("omit", m || "meta.componentsUsed"), u && I.searchParams.set("fields", u), Number.isFinite(h) && h > -1 && I.searchParams.set("offset", String(Math.floor(h))), typeof w == "boolean" && I.searchParams.set("includeUnpublished", String(w)), d && Pe(d) && I.searchParams.set("cacheSeconds", String(d)), f && Pe(f) && I.searchParams.set("staleCacheSeconds", String(f)), S) { const O = pe({ sort: S }); for (const M in O) I.searchParams.set(M, JSON.stringify(O[M])); } const vt = { ...rn(), ...Fe(e.options || {}) }, we = pe(vt); for (const O in we) I.searchParams.set(O, String(we[O])); if (X && I.searchParams.set("userAttributes", JSON.stringify(X)), o) { const O = st({ query: o }); for (const M in O) I.searchParams.set(M, JSON.stringify(O[M])); } return I; }, Wn = (e) => "results" in e; async function ye(e) { const t = await Fn({ ...e, limit: 1 }); return t && t[0] || null; } const Nn = async (e) => { var s; const t = be(e), n = e.fetch ?? An, o = { ...e.fetchOptions, headers: { ...(s = e.fetchOptions) == null ? void 0 : s.headers, ...ze() } }; return await (await n(t.href, o)).json(); }, On = async (e, t, n = be(e)) => { const o = G(e.canTrack); if (n.search.includes("preview="), !o || !($() || R === "reactNative")) return t.results; try { const r = []; for (const i of t.results) r.push(await Pn({ item: i, canTrack: o })); t.results = r; } catch (r) { B.error("Could not process A/B tests. ", r); } return t.results; }; async function Fn(e) { const t = be(e), n = await Nn(e); if (!Wn(n)) throw B.error("Error fetching data. ", { url: t, content: n, options: e }), n; return On(e, n); } const Yi = async (e) => { var o, r, i; const t = e.path || ((o = e.url) == null ? void 0 : o.pathname) || ((r = e.userAttributes) == null ? void 0 : r.urlPath), n = { ...e, apiKey: e.apiKey, model: e.model || "page", userAttributes: { ...e.userAttributes, ...t ? { urlPath: t } : {} }, options: Ke(e.searchParams || ((i = e.url) == null ? void 0 : i.searchParams) || e.options) }; return { apiKey: n.apiKey, model: n.model, content: await ye(n) }; }, ke = (e) => e ? e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase() : ""; function Dn(e, t, n = {}) { let o, r, i, s = null, l = 0; const a = function() { l = n.leading === !1 ? 0 : Date.now(), s = null, i = e.apply(o, r), s || (o = r = null); }; return function() { const u = Date.now(); !l && n.leading === !1 && (l = u); const m = t - (u - l); return o = this, r = arguments, m <= 0 || m > t ? (s && (clearTimeout(s), s = null), l = u, i = e.apply(o, r), s || (o = r = null)) : !s && n.trailing !== !1 && (s = setTimeout(a, m)), i; }; } function K(e, ...t) { const n = Object(e); for (let o = 1; o < arguments.length; o++) { const r = arguments[o]; if (r != null) for (const i in r) Object.prototype.hasOwnProperty.call(r, i) && (n[i] = r[i]); } return n; } function Ln(e) { for (const t of e) switch (t.trigger) { case "pageLoad": ct(t); break; case "scrollInView": Mn(t); break; } } function at(e) { console.warn(`Cannot animate element: element with ID ${e} not found!`); } function lt(e, t) { const n = Un(e), o = getComputedStyle(t), r = e.steps[0].styles, i = e.steps[e.steps.length - 1].styles, s = [r, i]; for (const l of s) for (const a of n) a in l || (l[a] = o[a]); } function Un(e) { const t = []; for (const n of e.steps) for (const o in n.styles) t.indexOf(o) === -1 && t.push(o); return t; } function ct(e) { const t = Array.prototype.slice.call(document.getElementsByClassName(e.elementId || e.id || "")); if (!t.length) { at(e.elementId || e.id || ""); return; } Array.from(t).forEach((n) => { lt(e, n), n.style.transition = "none", n.style.transitionDelay = "0", K(n.style, e.steps[0].styles), setTimeout(() => { n.style.transition = `all ${e.duration}s ${ke(e.easing)}`, e.delay && (n.style.transitionDelay = e.delay + "s"), K(n.style, e.steps[1].styles), setTimeout(() => { n.style.transition = "", n.style.transitionDelay = ""; }, (e.delay || 0) * 1e3 + e.duration * 1e3 + 100); }); }); } function Mn(e) { const t = Array.prototype.slice.call(document.getElementsByClassName(e.elementId || e.id || "")); if (!t.length) { at(e.elementId || e.id || ""); return; } Array.from(t).forEach((n) => { lt(e, n); let o = !1, r = !1; function i() { !o && l(n) ? (o = !0, r = !0, setTimeout(() => { K(n.style, e.steps[1].styles), e.repeat || document.removeEventListener("scroll", s), setTimeout(() => { r = !1, e.repeat || (n.style.transition = "", n.style.transitionDelay = ""); }, (e.duration + (e.delay || 0)) * 1e3 + 100); })) : e.repeat && o && !r && !l(n) && (o = !1, K(n.style, e.steps[0].styles)); } const s = Dn(i, 200, { leading: !1 }); function l(m) { const h = m.getBoundingClientRect(), d = window.innerHeight, S = (e.thresholdPercent || 0) / 100 * d; return h.bottom > S && h.top < d - S; } const a = e.steps[0].styles; function u() { K(n.style, a); } u(), setTimeout(() => { n.style.transition = `all ${e.duration}s ${ke(e.easing)}`, e.delay && (n.style.transitionDelay = e.delay + "s"); }), document.addEventListener("scroll", s, { capture: !0, passive: !0 }), i(); }); } const dt = (e) => Object.entries(e).map(([n, o]) => { if (typeof o == "string") return `${ke(n)}: ${o};`; }).filter(D), Hn = (e) => dt(e).join(` `), Xi = ({ mediaQuery: e, className: t, styles: n }) => { const o = `.${t} { ${Hn(n)} }`; return e ? `${e} { ${o} }` : o; }; function jn({ style: e }) { return e; } const Qi = ({ block: e, context: t }) => ut(jn({ style: e.style || {}, context: t, block: e })); function ut(e) { switch (R) { case "svelte": case "vue": case "solid": case "angular": return dt(e).join(" "); case "qwik": case "reactNative": case "react": case "rsc": return e; } } const pt = (e, t) => e ? t ? e.models && e.models.length > 0 && !e.models.includes(t) : !1 : !0, Kn = ({ block: e, registeredComponents: t, model: n }) => { var i; const o = (i = e.component) == null ? void 0 : i.name; if (!o) return null; const r = t[o]; if (!r || pt(r, n)) { console.warn(` Could not find a registered component named "${o}". If you registered it, is the file that registered it imported by the file that needs to render it?`); return; } else return r; }, qn = ({ block: e, context: t }) => { const { repeat: n, ...o } = e; if (!(n != null && n.collection)) return; const r = J({ code: n.collection, localState: t.localState, rootState: t.rootState, rootSetState: t.rootSetState, context: t.context }); if (!Array.isArray(r)) return; const i = n.collection.split(".").pop(), s = n.itemName || (i ? i + "Item" : "item"); return r.map((a, u) => ({ context: { ...t, localState: { ...t.localState, $index: u, $item: a, [s]: a, [`$${s}Index`]: u } }, block: o })); }, zn = (e, t) => { var n; return (n = e == null ? void 0 : e.shouldReceiveBuilderProps) != null && n.builderLinkComponent ? { builderLinkComponent: t } : {}; }, Gn = (e, t, n) => { var o; return (o = e == null ? void 0 : e.shouldReceiveBuilderProps) != null && o.builderComponents ? { builderComponents: Object.fromEntries(Object.entries(t).filter(([i, s]) => !pt(s, n))) } : {}; }, Jn = (e, t) => { var n; return (n = e == null ? void 0 : e.shouldReceiveBuilderProps) != null && n.builderBlock ? { builderBlock: t } : {}; }, Yn = (e, t) => { var n; return (n = e == null ? void 0 : e.shouldReceiveBuilderProps) != null && n.builderContext ? { builderContext: t } : {}; }, Xn = () => Promise.resolve().then(() => uo).then((e) => e.default).catch((e) => { throw console.error( "Error while attempting to dynamically import component DynamicDiv at ../dynamic-div.vue", e ), e; }), Qn = () => import("./block-styles-YR66YUMW.js").then((e) => e.default).catch((e) => { throw console.error( "Error while attempting to dynamically import component BlockStyles at ./components/block-styles.vue", e ), e; }), Zn = () => import("./block-wrapper-zPfAxV1K.js").then((e) => e.default).catch((e) => { throw console.error( "Error while attempting to dynamically import component BlockWrapper at ./components/block-wrapper.vue", e ), e; }), _n = () => import("./component-ref-1sJWCSnM.js").then((e) => e.default).catch((e) => { throw console.error( "Error while attempting to dynamically import component ComponentRef at ./components/component-ref/component-ref.vue", e ), e; }), eo = () => import("./repeated-block-zdJEPXeM.js").then((e) => e.default).catch((e) => { throw console.error( "Error while attempting to dynamically import component RepeatedBlock at ./components/repeated-block.vue", e ), e; }), to = g({ name: "block", components: { BlockStyles: H(Qn), RepeatedBlock: H(eo), ComponentRef: H(_n), BlockWrapper: H(Zn), DynamicDiv: H(Xn) }, props: ["block", "context", "registeredComponents", "linkComponent"], data() { return { _processedBlock: { value: null, update: !1 } }; }, mounted() { const e = this.processedBlock.id, t = this.processedBlock.animations; t && e && Ln( t.map((n) => ({ ...n, elementId: e })) ); }, updated() { }, computed: { repeatItem() { return qn({ block: this.block, context: this.context }); }, processedBlock() { var t; return (t = this.block.repeat) != null && t.collection ? this.block : _t({ block: this.block, localState: this.context.localState, rootState: this.context.rootState, rootSetState: this.context.rootSetState, context: this.context.context, shouldEvaluateBindings: !0 }); }, blockComponent() { return Kn({ block: this.processedBlock, registeredComponents: this.registeredComponents, model: this.context.model }); }, Tag() { var t; return this.block.tagName === "a" || ((t = this.processedBlock.properties) == null ? void 0 : t.href) || this.processedBlock.href ? this.linkComponent || "a" : this.block.tagName || "div"; }, canShowBlock() { var n, o; if ((n = this.block.repeat) != null && n.collection) return !!((o = this.repeatItem) != null && o.length); const e = "hide" in this.processedBlock ? this.processedBlock.hide : !1; return ("show" in this.processedBlock ? this.processedBlock.show : !0) && !e; }, childrenWithoutParentComponent() { var t; return !((t = this.blockComponent) != null && t.component) && !this.repeatItem ? this.processedBlock.children ?? [] : []; }, componentRefProps() { var e, t, n; return { blockChildren: this.processedBlock.children ?? [], componentRef: (e = this.blockComponent) == null ? void 0 : e.component, componentOptions: { ...At(this.processedBlock), ...Jn(this.blockComponent, this.processedBlock), ...Yn(this.blockComponent, this.context), ...zn(this.blockComponent, this.linkComponent), ...Gn( this.blockComponent, this.registeredComponents, this.context.model ) }, context: this.context, linkComponent: this.linkComponent, registeredComponents: this.registeredComponents, builderBlock: this.processedBlock, includeBlockProps: ((t = this.blockComponent) == null ? void 0 : t.noWrap) === !0, isInteractive: !((n = this.blockComponent) != null && n.isRSC && R === "rsc") }; } } }); function no(e, t, n, o, r, i) { var h; const s = k("BlockStyles"), l = k("ComponentRef"), a = k("Block", !0), u = k("BlockWrapper"), m = k("RepeatedBlock"); return e.canShowBlock ? (c(), p(T, { key: 0 }, [ P(s, { block: e.processedBlock, context: e.context }, null, 8, ["block", "context"]), (h = e.blockComponent) != null && h.noWrap ? (c(), p(T, { key: 1 }, [ e.repeatItem ? (c(!0), p(T, { key: 1 }, V(e.repeatItem, (d, f) => (c(), y(m, { key: f, repeatContext: d.context, block: d.block, registeredComponents: e.registeredComponents, linkComponent: e.linkComponent }, null, 8, ["repeatContext", "block", "registeredComponents", "linkComponent"]))), 128)) : (c(), y(l, { key: 0, componentRef: e.componentRefProps.componentRef, componentOptions: e.componentRefProps.componentOptions, blockChildren: e.componentRefProps.blockChildren, context: e.componentRefProps.context, registeredComponents: e.componentRefProps.registeredComponents, linkComponent: e.componentRefProps.linkComponent, builderBlock: e.componentRefProps.builderBlock, includeBlockProps: e.componentRefProps.includeBlockProps, isInteractive: e.componentRefProps.isInteractive }, null, 8, ["componentRef", "componentOptions", "blockChildren", "context", "registeredComponents", "linkComponent", "builderBlock", "includeBlockProps", "isInteractive"])) ], 64)) : (c(), p(T, { key: 0 }, [ e.repeatItem ? (c(!0), p(T, { key: 1 }, V(e.repeatItem, (d, f) => (c(), y(m, { key: f, repeatContext: d.context, block: d.block, registeredComponents: e.registeredComponents, linkComponent: e.linkComponent }, null, 8, ["repeatContext", "block", "registeredComponents", "linkComponent"]))), 128)) : (c(), y(u, { key: 0, Wrapper: e.Tag, block: e.processedBlock, context: e.context }, { default: N(() => [ P(l, { componentRef: e.componentRefProps.componentRef, componentOptions: e.componentRefProps.componentOptions, blockChildren: e.componentRefProps.blockChildren, context: e.componentRefProps.context, registeredComponents: e.componentRefProps.registeredComponents, linkComponent: e.componentRefProps.linkComponent, builderBlock: e.componentRefProps.builderBlock, includeBlockProps: e.componentRefProps.includeBlockProps, isInteractive: e.componentRefProps.isInteractive }, null, 8, ["componentRef", "componentOptions", "blockChildren", "context", "registeredComponents", "linkComponent", "builderBlock", "includeBlockProps", "isInteractive"]), (c(!0), p(T, null, V(e.childrenWithoutParentComponent, (d, f) => (c(), y(a, { key: d.id, block: d, registeredComponents: e.registeredComponents, linkComponent: e.linkComponent, context: e.context }, null, 8, ["block", "registeredComponents", "linkComponent", "context"]))), 128)) ]), _: 1 }, 8, ["Wrapper", "block", "context"])) ], 64)) ], 64)) : v("", !0); } const ve = /* @__PURE__ */ b(to, [["render", no]]), Zi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: ve }, Symbol.toStringTag, { value: "Module" })), oo = g({ name: "builder-blocks-wrapper", props: [ "blocks", "classNameProp", "path", "parent", "styleProp", "BlocksWrapperProps", "BlocksWrapper" ], mounted() { }, computed: { className() { var e; return [ "builder-blocks", (e = this.blocks) != null && e.length ? "" : "no-blocks", this.classNameProp ].filter(Boolean).join(" "); }, dataPath() { if (!this.path) return; const e = "component.options."; return this.path.startsWith(e) ? this.path : `${e}${this.path || ""}`; } }, methods: { onClick() { var e, t; E() && !((e = this.blocks) != null && e.length) && ((t = window.parent) == null || t.postMessage( { type: "builder.clickEmptyBlocks", data: { parentElementId: this.parent, dataPath: this.dataPath } }, "*" )); }, onMouseEnter() { var e, t; E() && !((e = this.blocks) != null && e.length) && ((t = window.parent) == null || t.postMessage( { type: "builder.hoverEmptyBlocks", data: { parentElementId: this.parent, dataPath: this.dataPath } }, "*" )); } } }); function ro(e, t, n, o, r, i) { return c(), y(j(e.BlocksWrapper), C({ ref: "blocksWrapperRef", class: e.className + " component-1k2igrjdg3x", "builder-path": e.dataPath, "builder-parent-id": e.parent, style: e.styleProp, onClick: (s) => e.onClick(), onMouseEnter: (s) => e.onMouseEnter(), onKeyPress: (s) => e.onClick() }, { ...e.BlocksWrapperProps }), { default: N(() => [ A(e.$slots, "default", {}, void 0, !0) ]), _: 3 }, 16, ["class", "builder-path", "builder-parent-id", "style", "onClick", "onMouseEnter", "onKeyPress"]); } const io = /* @__PURE__ */ b(oo, [["render", ro], ["__scopeId", "data-v-ba2bc5c0"]]), so = g({ name: "builder-blocks", components: { BlocksWrapper: io, Block: ve }, props: [ "blocks", "parent", "path", "styleProp", "className", "context", "linkComponent", "registeredComponents" ], inject: { builderContext: ce.key, componentsContext: Ne.key } }); function ao(e, t, n, o, r, i) { var a, u, m, h; const s = k("Block"), l = k("BlocksWrapper"); return c(), y(l, { blocks: e.blocks, parent: e.parent, path: e.path, styleProp: e.styleProp, classNameProp: e.className, BlocksWrapper: ((a = e.context) == null ? void 0 : a.BlocksWrapper) || ((u = e.builderContext) == null ? void 0 : u.BlocksWrapper), BlocksWrapperProps: ((m = e.context) == null ? void 0 : m.BlocksWrapperProps) || ((h = e.builderContext) == null ? void 0 : h.BlocksWrapperProps) }, { default: N(() => [ e.blocks ? (c(!0), p(T, { key: 0 }, V(e.blocks, (d, f) => { var S; return c(), y(s, { key: d.id, block: d, linkComponent: e.linkComponent, context: e.context || e.builderContext, registeredComponents: e.registeredComponents || ((S = e.componentsContext) == null ? void 0 : S.registeredComponents) }, null, 8, ["block", "linkComponent", "context", "registeredComponents"]); }), 128)) : v("", !0) ]), _: 1 }, 8, ["blocks", "parent", "path", "styleProp", "classNameProp", "BlocksWrapper", "BlocksWrapperProps"]); } const U = /* @__PURE__ */ b(so, [["render", ao]]), lo = g({ name: "dynamic-div", props: [] }); function co(e, t, n, o, r, i) { return c(), p("div", null, [ A(e.$slots, "default") ]); } const Y = /* @__PURE__ */ b(lo, [["render", co]]), uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: Y }, Symbol.toStringTag, { value: "Module" })), Se = g({ render() { return We("style", { innerHTML: this.styles, "data-id": this.id, nonce: this.nonce }); }, name: "inlined-styles", props: ["styles", "id", "nonce"] }), mt = { small: { min: 320, default: 321, max: 640 }, medium: { min: 641, default: 642, max: 991 }, large: { min: 990, default: 991, max: 1200 } }, _i = (e, t = mt) => `@media (max-width: ${t[e].max}px)`, po = ({ small: e, medium: t }) => { const n = he(mt); if (!e || !t) return n; const o = Math.floor(e / 2); n.small = { max: e, min: o, default: o + 1 }; const r = n.small.max + 1; n.medium = { max: t, min: r, default: r + 1 }; const i = n.medium.max + 1; return n.large = { max: 2e3, // TODO: decide upper limit min: i, default: i + 1 }, n; }, mo = (e) => `builder-columns ${e}-breakpoints`, ho = g({ name: "builder-columns", components: { InlinedStyles: Se, DynamicRenderer: me, Blocks: U, DynamicDiv: Y }, props: [ "space", "columns", "stackColumnsAt", "builderLinkComponent", "reverseColumnsWhenStacked", "builderContext", "builderBlock", "builderComponents" ], data() { return { TARGET: R, getColumnsClass: mo }; }, computed: { gutterSize() { return typeof this.space == "number" ? this.space || 0 : 20; }, cols() { return this.columns || []; }, stackAt() { return this.stackColumnsAt || "tablet"; }, flexDir() { return this.stackColumnsAt === "never" ? "row" : this.reverseColumnsWhenStacked ? "column-reverse" : "column"; } }, methods: { getTagName(e) { return e.link ? this.builderLinkComponent || "a" : "div"; }, getWidth(e) { var t; return ((t = this.cols[e]) == null ? void 0 : t.width) || 100 / this.cols.length; }, getColumnCssWidth(e) { const t = this.getWidth(e), n = this.gutterSize * (this.cols.length - 1) * (t / 100); return `calc(${t}% - ${n}px)`; }, getTabletStyle({ stackedStyle: e, desktopStyle: t }) { return this.stackAt === "tablet" ? e : t; }, getMobileStyle({ stackedStyle: e, desktopStyle: t }) { return this.stackAt === "never" ? t : e; }, columnsCssVars() { return { "--flex-dir": this.flexDir, "--flex-dir-tablet": this.getTabletStyle({ stackedStyle: this.flexDir, desktopStyle: "row" }) }; }, columnCssVars(e) { const t = e === 0 ? 0 : this.gutterSize, n = this.getColumnCssWidth(e), o = `${t}px`, r = "100%", i = 0; return { ...{ display: "flex", flexDirection: "column", alignItems: "stretch" }, width: n, ["margin-left"]: o, "--column-width-mobile": this.getMobileStyle({ stackedStyle: r, desktopStyle: n }), "--column-margin-left-mobile": this.getMobileStyle({ stackedStyle: i, desktopStyle: o }), "--column-width-tablet": this.getTabletStyle({ stackedStyle: r, desktopStyle: n }), "--column-margin-left-tablet": this.getTabletStyle({ stackedStyle: i, desktopStyle: o }) }; }, getWidthForBreakpointSize(e) { var n, o; return po( ((o = (n = this.builderContext.content) == null ? void 0 : n.meta) == null ? void 0 : o.breakpoints) || {} )[e].max; }, columnsStyles() { const e = `.${this.builderBlock.id}-breakpoints > .builder-column`; return ` @media (max-width: ${this.getWidthForBreakpointSize("medium")}px) { .${this.builderBlock.id}-breakpoints { flex-direction: var(--flex-dir-tablet); align-items: stretch; } ${e} { width: var(--column-width-tablet) !important; margin-left: var(--column-margin-left-tablet) !important; } } @media (max-width: ${this.getWidthForBreakpointSize("small")}px) { .${this.builderBlock.id}-breakpoints { flex-direction: var(--flex-dir); align-items: stretch; } ${e} { width: var(--column-width-mobile) !important; margin-left: var(--column-margin-left-mobile) !important; } }, `; }, getAttributes(e, t) { return { ...e.link ? { href: e.link } : {}, [_()]: "builder-column", style: ut(this.columnCssVars(t)) }; } } }); function fo(e, t, n, o, r, i) { var u; const s = k("InlinedStyles"), l = k("Blocks"), a = k("DynamicRenderer"); return c(), p("div", C({ class: e.getColumnsClass((u = e.builderBlock) == null ? void 0 : u.id) + " div-4wbls88y960", style: e.columnsCssVars() }, {}), [ e.TARGET !== "reactNative" ? (c(), y(s, { key: 0,