@myissue/vue-website-page-builder
Version:
Vue 3 page builder component with drag & drop functionality.
26,176 lines • 947 kB
JavaScript
var Ah = Object.defineProperty;
var _h = (n, e, t) => e in n ? Ah(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
var be = (n, e, t) => _h(n, typeof e != "symbol" ? e + "" : e, t);
import * as gc from "vue";
import { defineComponent as Qe, computed as I, createBlock as pe, openBlock as w, Teleport as Lh, createElementVNode as d, createElementBlock as E, createCommentVNode as A, normalizeClass as X, toDisplayString as k, renderSlot as ar, ref as M, watchEffect as ro, Fragment as Z, withCtx as V, nextTick as ce, readonly as Nh, createVNode as j, unref as y, shallowRef as Dh, onMounted as pn, onBeforeUnmount as _s, h as jn, getCurrentInstance as Bu, markRaw as Pn, customRef as Ih, effectScope as Pu, toRaw as Ve, hasInjectionContext as $h, inject as zn, watch as ee, reactive as Rh, isRef as No, isReactive as Sa, toRef as Qs, getCurrentScope as Fh, onScopeDispose as Hh, toRefs as yc, onBeforeMount as jh, withDirectives as xe, vModelText as gr, createTextVNode as we, provide as En, resolveDynamicComponent as Au, cloneVNode as zh, onUnmounted as Vh, Transition as oo, renderList as fe, withKeys as Nl, withModifiers as bt, vShow as Dl, vModelSelect as Ue } from "vue";
const Wh = { class: "pbx-font-sans" }, Uh = {
key: 0,
class: "pbx-fixed pbx-inset-0 pbx-z-40 pbx-flex pbx-items-center pbx-justify-center pbx-mx-4",
role: "dialog",
"aria-modal": "true",
"aria-labelledby": "dialog-title"
}, qh = { class: "pbx-px-4 pbx-min-h-32" }, Vt = /* @__PURE__ */ Qe({
__name: "ModalBuilder",
props: {
title: {
type: String,
required: !0
},
showModalBuilder: {
type: Boolean,
default: !1
},
type: {
type: String,
default: "success"
},
maxWidth: {
type: String,
default: "2xl"
},
minHeight: {
type: String
},
maxHeight: {
type: String
},
noBackgroundOpacity: {
type: Boolean
}
},
emits: ["closeMainModalBuilder"],
setup(n, { emit: e }) {
const t = n, r = e, o = () => {
r("closeMainModalBuilder");
}, i = I(() => ({
sm: "lg:pbx-max-w-sm",
md: "lg:pbx-max-w-md",
lg: "lg:pbx-max-w-lg",
xl: "lg:pbx-max-w-xl",
"2xl": "lg:pbx-max-w-2xl",
"3xl": "lg:pbx-max-w-3xl",
"4xl": "lg:pbx-max-w-4xl",
"5xl": "lg:pbx-max-w-5xl",
"6xl": "lg:pbx-max-w-6xl",
"7xl": "lg:pbx-max-w-7xl",
full: "lg:pbx-max-w-full",
// 100% width
screen: "lg:w-screen sm:pbx-max-w-none"
// truly full screen
})[t.maxWidth]);
return (s, l) => (w(), pe(Lh, { to: "body" }, [
d("div", Wh, [
n.showModalBuilder ? (w(), E("div", Uh, [
d("div", {
class: X(["pbx-fixed pbx-inset-0 pbx-bg-black/50 pbx-transition-opacity", [n.noBackgroundOpacity ? "pbx-bg-black/100" : ""]]),
onClick: o
}, null, 2),
d("div", {
class: X(["pbx-relative pbx-inline-block pbx-bg-white pbx-rounded-xl pbx-text-left pbx-shadow-xl pbx-transform pbx-transition-all pbx-max-w-[96vh] lg:pbx-max-h-[98vh] pbx-max-h-[85vh] pbx-overflow-y-auto pbx-w-full", [
i.value ? i.value : "",
n.minHeight ? n.minHeight : "",
n.maxHeight ? n.maxHeight : ""
]])
}, [
d("div", {
class: X(["pbx-h-16 pbx-px-4 pbx-border-0 pbx-border-solid pbx-border-b pbx-border-gray-200 pbx-mb-2 pbx-flex pbx-items-center pbx-justify-between", [
n.type === "success" ? "pbx-bg-white" : "",
n.type === "warning" ? "pbx-bg-white" : "",
n.type === "danger" ? "pbx-bg-white" : "",
n.type === "delete" ? "pbx-bg-white" : ""
]])
}, [
d("h3", {
as: "h3",
class: X(["pbx-myQuaternaryHeader pbx-my-0 pbx-py-0", [
n.type === "success" ? "pbx-text-black" : "",
n.type === "warning" ? "pbx-text-black" : "",
n.type === "danger" ? "pbx-text-black" : "",
n.type === "delete" ? "pbx-text-black" : ""
]])
}, k(n.title), 3),
d("div", {
class: "pbx-h-10 pbx-w-10 pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-50 pbx-aspect-square hover:pbx-bg-myPrimaryLinkColor hover:pbx-text-white focus-visible:pbx-ring-0 pbx-text-black",
onClick: o
}, l[0] || (l[0] = [
d("span", { class: "material-symbols-outlined" }, " close ", -1)
]))
], 2),
d("div", qh, [
ar(s.$slots, "default")
])
], 2)
])) : A("", !0)
])
]));
}
}), Kh = { key: 0 }, Gh = { class: "pbx-text-black pbx-w-full pbx-inset-x-0 pbx-h-[90vh] pbx-bg-white pbx-overflow-x-scroll lg:pbx-pt-2 pbx-pt-2" }, Jh = { id: "pagebuilder" }, Yh = ["innerHTML"], Xh = { key: 1 }, vc = {
__name: "Preview",
props: {
mobile: {
type: Boolean
}
},
setup(n) {
const e = n, t = M(""), r = M(null), o = localStorage.getItem("preview");
if (o)
try {
const i = JSON.parse(o);
t.value = Array.isArray(i) ? i.join("") : "";
} catch (i) {
console.error("Invalid preview data:", i), t.value = "";
}
return ro(() => {
if (e.mobile && r.value && t.value) {
const s = r.value.contentWindow.document;
s.open(), s.write(
`<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width, initial-scale=1.0"></head><body><div id="pagebuilder" class="pbx-font-sans pbx-text-black">${t.value}</div></body></html>`
), s.close(), document.querySelectorAll('link[rel="stylesheet"], style').forEach((l) => {
s.head.appendChild(l.cloneNode(!0));
});
}
}), (i, s) => (w(), E(Z, null, [
n.mobile ? A("", !0) : (w(), E("div", Kh, [
d("div", Gh, [
d("div", Jh, [
d("div", {
class: "",
innerHTML: t.value
}, null, 8, Yh)
])
])
])),
n.mobile ? (w(), E("div", Xh, [
d("iframe", {
ref_key: "iframeRef",
ref: r,
class: "pbx-mx-auto pbx-w-full pbx-bg-white pbx-shadow-lg pbx-h-[80vh] pbx-border-0",
src: "about:blank"
}, null, 512)
])) : A("", !0)
], 64));
}
}, Qh = { class: "pbx-min-h-32 pbx-h-max pbx-font-sans pbx-w-full pbx-relative pbx-inline-block pbx-align-bottom pbx-text-left pbx-overflow-hidden pbx-transform pbx-transition-all sm:pbx-align-middle" }, Zh = ["innerHTML"], eb = { class: "pbx-border-0 pbx-border-solid pbx-border-t pbx-border-gray-200 pbx-mt-4 pbx-flex pbx-items-center pbx-justify-end" }, tb = {
key: 0,
class: "pbx-py-4 pbx-flex sm:pbx-justify-end pbx-justify-center"
}, nb = {
key: 1,
class: "pbx-flex pbx-items-center pbx-my-2 pbx-py-4 pbx-px-2 pbx-justify-end"
}, yr = {
__name: "DynamicModalBuilder",
props: {
showDynamicModalBuilder: {
type: Boolean,
default: !1,
required: !0
},
simpleModal: {
type: Boolean,
default: !1,
required: !1
},
disabled: {
type: Boolean,
default: !1,
required: !1
},
isLoading: {
type: Boolean,
default: !1,
required: !1
},
disabledWhichButton: {
type: String,
default: "",
required: !1
},
maxWidth: {
type: String,
required: !1,
default: "2xl"
},
gridColumnAmount: {
type: Number,
required: !0
},
type: {
type: String,
required: !0
},
title: {
type: String,
required: !0
},
description: {
required: !0
},
firstButtonText: {
type: String
},
secondButtonText: {
type: String
},
thirdButtonText: {
type: String
}
},
emits: [
"firstModalButtonFunctionDynamicModalBuilder",
"secondModalButtonFunctionDynamicModalBuilder",
"thirdModalButtonFunctionDynamicModalBuilder"
],
setup(n, { emit: e }) {
const t = e, r = function() {
t("firstModalButtonFunctionDynamicModalBuilder");
}, o = function() {
t("secondModalButtonFunctionDynamicModalBuilder");
}, i = function() {
t("thirdModalButtonFunctionDynamicModalBuilder");
};
return (s, l) => (w(), pe(Vt, {
title: n.title,
showModalBuilder: n.showDynamicModalBuilder,
type: n.type,
onCloseMainModalBuilder: r,
maxWidth: n.maxWidth
}, {
default: V(() => [
ar(s.$slots, "content"),
d("div", Qh, [
d("div", {
class: X({ "pbx-pr-4 pbx-pb-4": !n.simpleModal })
}, [
n.simpleModal !== !0 ? (w(), E("div", {
key: 0,
innerHTML: n.description,
class: "pbx-myPrimaryParagraph pbx-mb-6"
}, null, 8, Zh)) : A("", !0),
ar(s.$slots, "header"),
ar(s.$slots, "default")
], 2)
]),
d("div", eb, [
n.simpleModal !== !0 && !n.isLoading ? (w(), E("div", tb, [
ar(s.$slots, "footer"),
d("div", {
class: X([{
"sm:pbx-grid-cols-1": n.gridColumnAmount === 1,
"sm:pbx-grid-cols-2": n.gridColumnAmount === 2,
"sm:pbx-grid-cols-3": n.gridColumnAmount === 3
}, "sm:pbx-items-end sm:pbx-justify-end pbx-flex sm:pbx-flex-row pbx-flex-col pbx-myPrimaryGap sm:pbx-w-5/6 pbx-w-full"])
}, [
n.firstButtonText ? (w(), E("button", {
key: 0,
ref: "firstButtonRef",
class: "pbx-mySecondaryButton",
type: "button",
onClick: r
}, k(n.firstButtonText), 513)) : A("", !0),
n.secondButtonText ? (w(), E("button", {
key: 1,
class: "pbx-myPrimaryButton pbx-bg-yellow-300 hover:pbx-bg-yellow-400 pbx-text-myPrimaryDarkGrayColor hover:pbx-text-myPrimaryDarkGrayColor focus:pbx-ring-yellow-400 pbx-w-full",
type: "button",
onClick: o
}, k(n.secondButtonText), 1)) : A("", !0),
n.thirdButtonText ? (w(), E("button", {
key: 2,
class: X(["pbx-myPrimaryButton pbx-bg-myPrimaryLinkColor focus-visible:pbx-ring-myPrimaryLinkColor focus:pbx-ring-myPrimaryLinkColor hover:pbx-bg-myPrimaryLinkColor pbx-w-full", [
n.type === "danger" || n.type === "delete" ? "pbx-bg-red-600 focus-visible:pbx-ring-red-600 focus:pbx-ring-red-600 hover:pbx-bg-red-600" : "pbx-bg-myPrimaryLinkColor focus-visible:pbx-ring-myPrimaryLinkColor focus:pbx-ring-myPrimaryLinkColor hover:pbx-bg-myPrimaryLinkColor"
]]),
type: "button",
onClick: i
}, k(n.thirdButtonText), 3)) : A("", !0)
], 2)
])) : A("", !0),
n.isLoading ? (w(), E("div", nb, l[0] || (l[0] = [
d("div", { class: "pbx-inline-block pbx-h-8 pbx-w-8 pbx-animate-spin pbx-rounded-full pbx-border-4 pbx-border-solid pbx-border-current pbx-border-r-transparent pbx-align-[-0.125em] motion-reduce:pbx-animate-[spin_1.5s_linear_infinite]" }, [
d("span", { class: "!pbx-absolute !pbx-m-px !pbx-h-px !pbx-w-px !pbx-overflow-hidden !pbx-whitespace-nowrap !pbx-border-0 !pbx-p-0 !pbx-[clip:rect(0,0,0,0)]" }, "Loading...")
], -1)
]))) : A("", !0)
])
]),
_: 3
}, 8, ["title", "showModalBuilder", "type", "maxWidth"]));
}
};
class Fr {
static getHistory(e) {
const t = e + this.HISTORY_KEY_SUFFIX, r = localStorage.getItem(t);
return r ? JSON.parse(r) : [];
}
static addToHistory(e, t) {
const r = e + this.HISTORY_KEY_SUFFIX;
let o = this.getHistory(e);
o.push(t), o.length > this.MAX_HISTORY_SIZE && (o = o.slice(o.length - this.MAX_HISTORY_SIZE)), localStorage.setItem(r, JSON.stringify(o));
}
static clearHistory(e) {
const t = e + this.HISTORY_KEY_SUFFIX;
localStorage.removeItem(t);
}
}
be(Fr, "HISTORY_KEY_SUFFIX", "-history"), be(Fr, "MAX_HISTORY_SIZE", 10);
const ho = {
fontBase: [
"none",
"pbx-text-xs",
"pbx-text-sm",
"pbx-text-base",
"pbx-text-lg",
"pbx-text-xl",
"pbx-text-2xl",
"pbx-text-3xl",
"pbx-text-4xl",
"pbx-text-5xl",
"pbx-text-6xl",
"pbx-text-7xl",
"pbx-text-8xl",
"pbx-text-9xl"
],
fontDesktop: [
"none",
"lg:pbx-text-xs",
"lg:pbx-text-sm",
"lg:pbx-text-base",
"lg:pbx-text-lg",
"lg:pbx-text-xl",
"lg:pbx-text-2xl",
"lg:pbx-text-3xl",
"lg:pbx-text-4xl",
"lg:pbx-text-5xl",
"lg:pbx-text-6xl",
"lg:pbx-text-7xl",
"lg:pbx-text-8xl",
"lg:pbx-text-9xl"
],
fontTablet: [
"none",
"md:pbx-text-xs",
"md:pbx-text-sm",
"md:pbx-text-base",
"md:pbx-text-lg",
"md:pbx-text-xl",
"md:pbx-text-2xl",
"md:pbx-text-3xl",
"md:pbx-text-4xl",
"md:pbx-text-5xl",
"md:pbx-text-6xl",
"md:pbx-text-7xl",
"md:pbx-text-8xl",
"md:pbx-text-9xl"
],
fontMobile: [
"none",
"sm:pbx-text-xs",
"sm:pbx-text-sm",
"sm:pbx-text-base",
"sm:pbx-text-lg",
"sm:pbx-text-xl",
"sm:pbx-text-2xl",
"sm:pbx-text-3xl",
"sm:pbx-text-4xl",
"sm:pbx-text-5xl",
"sm:pbx-text-6xl",
"sm:pbx-text-7xl",
"sm:pbx-text-8xl",
"sm:pbx-text-9xl"
]
}, Fi = {
backgroundColorVariables: [
"none",
"pbx-bg-white",
"pbx-bg-black",
"pbx-bg-slate-50",
"pbx-bg-slate-100",
"pbx-bg-slate-200",
"pbx-bg-slate-300",
"pbx-bg-slate-400",
"pbx-bg-slate-500",
"pbx-bg-slate-600",
"pbx-bg-slate-700",
"pbx-bg-slate-800",
"pbx-bg-slate-900",
"pbx-bg-gray-50",
"pbx-bg-gray-100",
"pbx-bg-gray-200",
"pbx-bg-gray-300",
"pbx-bg-gray-400",
"pbx-bg-gray-500",
"pbx-bg-gray-600",
"pbx-bg-gray-700",
"pbx-bg-gray-800",
"pbx-bg-gray-900",
"pbx-bg-zinc-50",
"pbx-bg-zinc-100",
"pbx-bg-zinc-200",
"pbx-bg-zinc-300",
"pbx-bg-zinc-400",
"pbx-bg-zinc-500",
"pbx-bg-zinc-600",
"pbx-bg-zinc-700",
"pbx-bg-zinc-800",
"pbx-bg-zinc-900",
"pbx-bg-neutral-50",
"pbx-bg-neutral-100",
"pbx-bg-neutral-200",
"pbx-bg-neutral-300",
"pbx-bg-neutral-400",
"pbx-bg-neutral-500",
"pbx-bg-neutral-600",
"pbx-bg-neutral-700",
"pbx-bg-neutral-800",
"pbx-bg-neutral-900",
"pbx-bg-stone-50",
"pbx-bg-stone-100",
"pbx-bg-stone-200",
"pbx-bg-stone-300",
"pbx-bg-stone-400",
"pbx-bg-stone-500",
"pbx-bg-stone-600",
"pbx-bg-stone-700",
"pbx-bg-stone-800",
"pbx-bg-stone-900",
"pbx-bg-red-50",
"pbx-bg-red-100",
"pbx-bg-red-200",
"pbx-bg-red-300",
"pbx-bg-red-400",
"pbx-bg-red-500",
"pbx-bg-red-600",
"pbx-bg-red-700",
"pbx-bg-red-800",
"pbx-bg-red-900",
"pbx-bg-orange-50",
"pbx-bg-orange-100",
"pbx-bg-orange-200",
"pbx-bg-orange-300",
"pbx-bg-orange-400",
"pbx-bg-orange-500",
"pbx-bg-orange-600",
"pbx-bg-orange-700",
"pbx-bg-orange-800",
"pbx-bg-orange-900",
"pbx-bg-amber-50",
"pbx-bg-amber-100",
"pbx-bg-amber-200",
"pbx-bg-amber-300",
"pbx-bg-amber-400",
"pbx-bg-amber-500",
"pbx-bg-amber-600",
"pbx-bg-amber-700",
"pbx-bg-amber-800",
"pbx-bg-amber-900",
"pbx-bg-yellow-50",
"pbx-bg-yellow-100",
"pbx-bg-yellow-200",
"pbx-bg-yellow-300",
"pbx-bg-yellow-400",
"pbx-bg-yellow-500",
"pbx-bg-yellow-600",
"pbx-bg-yellow-700",
"pbx-bg-yellow-800",
"pbx-bg-yellow-900",
"pbx-bg-lime-50",
"pbx-bg-lime-100",
"pbx-bg-lime-200",
"pbx-bg-lime-300",
"pbx-bg-lime-400",
"pbx-bg-lime-500",
"pbx-bg-lime-600",
"pbx-bg-lime-700",
"pbx-bg-lime-800",
"pbx-bg-lime-900",
"pbx-bg-green-50",
"pbx-bg-green-100",
"pbx-bg-green-200",
"pbx-bg-green-300",
"pbx-bg-green-400",
"pbx-bg-green-500",
"pbx-bg-green-600",
"pbx-bg-green-700",
"pbx-bg-green-800",
"pbx-bg-green-900",
"pbx-bg-emerald-50",
"pbx-bg-emerald-100",
"pbx-bg-emerald-200",
"pbx-bg-emerald-300",
"pbx-bg-emerald-400",
"pbx-bg-emerald-500",
"pbx-bg-emerald-600",
"pbx-bg-emerald-700",
"pbx-bg-emerald-800",
"pbx-bg-emerald-900",
"pbx-bg-teal-50",
"pbx-bg-teal-100",
"pbx-bg-teal-200",
"pbx-bg-teal-300",
"pbx-bg-teal-400",
"pbx-bg-teal-500",
"pbx-bg-teal-600",
"pbx-bg-teal-700",
"pbx-bg-teal-800",
"pbx-bg-teal-900",
"pbx-bg-cyan-50",
"pbx-bg-cyan-100",
"pbx-bg-cyan-200",
"pbx-bg-cyan-300",
"pbx-bg-cyan-400",
"pbx-bg-cyan-500",
"pbx-bg-cyan-600",
"pbx-bg-cyan-700",
"pbx-bg-cyan-800",
"pbx-bg-cyan-900",
"pbx-bg-sky-50",
"pbx-bg-sky-100",
"pbx-bg-sky-200",
"pbx-bg-sky-300",
"pbx-bg-sky-400",
"pbx-bg-sky-500",
"pbx-bg-sky-600",
"pbx-bg-sky-700",
"pbx-bg-sky-800",
"pbx-bg-sky-900",
"pbx-bg-blue-50",
"pbx-bg-blue-100",
"pbx-bg-blue-200",
"pbx-bg-blue-300",
"pbx-bg-blue-400",
"pbx-bg-blue-500",
"pbx-bg-blue-600",
"pbx-bg-blue-700",
"pbx-bg-blue-800",
"pbx-bg-blue-900",
"pbx-bg-indigo-50",
"pbx-bg-indigo-100",
"pbx-bg-indigo-200",
"pbx-bg-indigo-300",
"pbx-bg-indigo-400",
"pbx-bg-indigo-500",
"pbx-bg-indigo-600",
"pbx-bg-indigo-700",
"pbx-bg-indigo-800",
"pbx-bg-indigo-900",
"pbx-bg-violet-50",
"pbx-bg-violet-100",
"pbx-bg-violet-200",
"pbx-bg-violet-300",
"pbx-bg-violet-400",
"pbx-bg-violet-500",
"pbx-bg-violet-600",
"pbx-bg-violet-700",
"pbx-bg-violet-800",
"pbx-bg-violet-900",
"pbx-bg-purple-50",
"pbx-bg-purple-100",
"pbx-bg-purple-200",
"pbx-bg-purple-300",
"pbx-bg-purple-400",
"pbx-bg-purple-500",
"pbx-bg-purple-600",
"pbx-bg-purple-700",
"pbx-bg-purple-800",
"pbx-bg-purple-900",
"pbx-bg-fuchsia-50",
"pbx-bg-fuchsia-100",
"pbx-bg-fuchsia-200",
"pbx-bg-fuchsia-300",
"pbx-bg-fuchsia-400",
"pbx-bg-fuchsia-500",
"pbx-bg-fuchsia-600",
"pbx-bg-fuchsia-700",
"pbx-bg-fuchsia-800",
"pbx-bg-fuchsia-900",
"pbx-bg-pink-50",
"pbx-bg-pink-100",
"pbx-bg-pink-200",
"pbx-bg-pink-300",
"pbx-bg-pink-400",
"pbx-bg-pink-500",
"pbx-bg-pink-600",
"pbx-bg-pink-700",
"pbx-bg-pink-800",
"pbx-bg-pink-900",
"pbx-bg-rose-50",
"pbx-bg-rose-100",
"pbx-bg-rose-200",
"pbx-bg-rose-300",
"pbx-bg-rose-400",
"pbx-bg-rose-500",
"pbx-bg-rose-600",
"pbx-bg-rose-700",
"pbx-bg-rose-800",
"pbx-bg-rose-900"
],
textColorVariables: [
"none",
"pbx-text-white",
"pbx-text-black",
"pbx-text-slate-50",
"pbx-text-slate-100",
"pbx-text-slate-200",
"pbx-text-slate-300",
"pbx-text-slate-400",
"pbx-text-slate-500",
"pbx-text-slate-600",
"pbx-text-slate-700",
"pbx-text-slate-800",
"pbx-text-slate-900",
"pbx-text-gray-50",
"pbx-text-gray-100",
"pbx-text-gray-200",
"pbx-text-gray-300",
"pbx-text-gray-400",
"pbx-text-gray-500",
"pbx-text-gray-600",
"pbx-text-gray-700",
"pbx-text-gray-800",
"pbx-text-gray-900",
"pbx-text-zinc-50",
"pbx-text-zinc-100",
"pbx-text-zinc-200",
"pbx-text-zinc-300",
"pbx-text-zinc-400",
"pbx-text-zinc-500",
"pbx-text-zinc-600",
"pbx-text-zinc-700",
"pbx-text-zinc-800",
"pbx-text-zinc-900",
"pbx-text-neutral-50",
"pbx-text-neutral-100",
"pbx-text-neutral-200",
"pbx-text-neutral-300",
"pbx-text-neutral-400",
"pbx-text-neutral-500",
"pbx-text-neutral-600",
"pbx-text-neutral-700",
"pbx-text-neutral-800",
"pbx-text-neutral-900",
"pbx-text-stone-50",
"pbx-text-stone-100",
"pbx-text-stone-200",
"pbx-text-stone-300",
"pbx-text-stone-400",
"pbx-text-stone-500",
"pbx-text-stone-600",
"pbx-text-stone-700",
"pbx-text-stone-800",
"pbx-text-stone-900",
"pbx-text-red-50",
"pbx-text-red-100",
"pbx-text-red-200",
"pbx-text-red-300",
"pbx-text-red-400",
"pbx-text-red-500",
"pbx-text-red-600",
"pbx-text-red-700",
"pbx-text-red-800",
"pbx-text-red-900",
"pbx-text-orange-50",
"pbx-text-orange-100",
"pbx-text-orange-200",
"pbx-text-orange-300",
"pbx-text-orange-400",
"pbx-text-orange-500",
"pbx-text-orange-600",
"pbx-text-orange-700",
"pbx-text-orange-800",
"pbx-text-orange-900",
"pbx-text-amber-50",
"pbx-text-amber-100",
"pbx-text-amber-200",
"pbx-text-amber-300",
"pbx-text-amber-400",
"pbx-text-amber-500",
"pbx-text-amber-600",
"pbx-text-amber-700",
"pbx-text-amber-800",
"pbx-text-amber-900",
"pbx-text-yellow-50",
"pbx-text-yellow-100",
"pbx-text-yellow-200",
"pbx-text-yellow-300",
"pbx-text-yellow-400",
"pbx-text-yellow-500",
"pbx-text-yellow-600",
"pbx-text-yellow-700",
"pbx-text-yellow-800",
"pbx-text-yellow-900",
"pbx-text-lime-50",
"pbx-text-lime-100",
"pbx-text-lime-200",
"pbx-text-lime-300",
"pbx-text-lime-400",
"pbx-text-lime-500",
"pbx-text-lime-600",
"pbx-text-lime-700",
"pbx-text-lime-800",
"pbx-text-lime-900",
"pbx-text-green-50",
"pbx-text-green-100",
"pbx-text-green-200",
"pbx-text-green-300",
"pbx-text-green-400",
"pbx-text-green-500",
"pbx-text-green-600",
"pbx-text-green-700",
"pbx-text-green-800",
"pbx-text-green-900",
"pbx-text-emerald-50",
"pbx-text-emerald-100",
"pbx-text-emerald-200",
"pbx-text-emerald-300",
"pbx-text-emerald-400",
"pbx-text-emerald-500",
"pbx-text-emerald-600",
"pbx-text-emerald-700",
"pbx-text-emerald-800",
"pbx-text-emerald-900",
"pbx-text-teal-50",
"pbx-text-teal-100",
"pbx-text-teal-200",
"pbx-text-teal-300",
"pbx-text-teal-400",
"pbx-text-teal-500",
"pbx-text-teal-600",
"pbx-text-teal-700",
"pbx-text-teal-800",
"pbx-text-teal-900",
"pbx-text-cyan-50",
"pbx-text-cyan-100",
"pbx-text-cyan-200",
"pbx-text-cyan-300",
"pbx-text-cyan-400",
"pbx-text-cyan-500",
"pbx-text-cyan-600",
"pbx-text-cyan-700",
"pbx-text-cyan-800",
"pbx-text-cyan-900",
"pbx-text-sky-50",
"pbx-text-sky-100",
"pbx-text-sky-200",
"pbx-text-sky-300",
"pbx-text-sky-400",
"pbx-text-sky-500",
"pbx-text-sky-600",
"pbx-text-sky-700",
"pbx-text-sky-800",
"pbx-text-sky-900",
"pbx-text-blue-50",
"pbx-text-blue-100",
"pbx-text-blue-200",
"pbx-text-blue-300",
"pbx-text-blue-400",
"pbx-text-blue-500",
"pbx-text-blue-600",
"pbx-text-blue-700",
"pbx-text-blue-800",
"pbx-text-blue-900",
"pbx-text-indigo-50",
"pbx-text-indigo-100",
"pbx-text-indigo-200",
"pbx-text-indigo-300",
"pbx-text-indigo-400",
"pbx-text-indigo-500",
"pbx-text-indigo-600",
"pbx-text-indigo-700",
"pbx-text-indigo-800",
"pbx-text-indigo-900",
"pbx-text-violet-50",
"pbx-text-violet-100",
"pbx-text-violet-200",
"pbx-text-violet-300",
"pbx-text-violet-400",
"pbx-text-violet-500",
"pbx-text-violet-600",
"pbx-text-violet-700",
"pbx-text-violet-800",
"pbx-text-violet-900",
"pbx-text-purple-50",
"pbx-text-purple-100",
"pbx-text-purple-200",
"pbx-text-purple-300",
"pbx-text-purple-400",
"pbx-text-purple-500",
"pbx-text-purple-600",
"pbx-text-purple-700",
"pbx-text-purple-800",
"pbx-text-purple-900",
"pbx-text-fuchsia-50",
"pbx-text-fuchsia-100",
"pbx-text-fuchsia-200",
"pbx-text-fuchsia-300",
"pbx-text-fuchsia-400",
"pbx-text-fuchsia-500",
"pbx-text-fuchsia-600",
"pbx-text-fuchsia-700",
"pbx-text-fuchsia-800",
"pbx-text-fuchsia-900",
"pbx-text-pink-50",
"pbx-text-pink-100",
"pbx-text-pink-200",
"pbx-text-pink-300",
"pbx-text-pink-400",
"pbx-text-pink-500",
"pbx-text-pink-600",
"pbx-text-pink-700",
"pbx-text-pink-800",
"pbx-text-pink-900",
"pbx-text-rose-50",
"pbx-text-rose-100",
"pbx-text-rose-200",
"pbx-text-rose-300",
"pbx-text-rose-400",
"pbx-text-rose-500",
"pbx-text-rose-600",
"pbx-text-rose-700",
"pbx-text-rose-800",
"pbx-text-rose-900"
]
}, Hi = {
opacities: [
"none",
"pbx-opacity-0",
"pbx-opacity-5",
"pbx-opacity-10",
"pbx-opacity-20",
"pbx-opacity-25",
"pbx-opacity-30",
"pbx-opacity-40",
"pbx-opacity-50",
"pbx-opacity-60",
"pbx-opacity-70",
"pbx-opacity-75",
"pbx-opacity-80",
"pbx-opacity-90",
"pbx-opacity-95",
"pbx-opacity-100"
],
backgroundOpacities: [
"none",
"pbx-bg-opacity-0",
"pbx-bg-opacity-5",
"pbx-bg-opacity-10",
"pbx-bg-opacity-20",
"pbx-bg-opacity-25",
"pbx-bg-opacity-30",
"pbx-bg-opacity-40",
"pbx-bg-opacity-50",
"pbx-bg-opacity-60",
"pbx-bg-opacity-70",
"pbx-bg-opacity-75",
"pbx-bg-opacity-80",
"pbx-bg-opacity-90",
"pbx-bg-opacity-95",
"pbx-bg-opacity-100"
]
}, Vr = {
fontWeight: [
"none",
"pbx-font-thin",
"pbx-font-extralight",
"pbx-font-light",
"pbx-font-normal",
"pbx-font-medium",
"pbx-font-bold",
"pbx-font-extrabold",
"pbx-font-black"
],
fontFamily: [
"none",
"pbx-font-sans",
"pbx-font-serif",
"pbx-font-mono",
"pbx-font-arial",
"pbx-font-helvetica",
"pbx-font-georgia",
"pbx-font-times",
"pbx-font-times-new-roman",
"pbx-font-courier",
"pbx-font-courier-new",
"pbx-font-verdana",
"pbx-font-tahoma",
"pbx-font-trebuchet",
"pbx-font-garamond",
"pbx-font-palantino",
"pbx-font-bookman",
"pbx-font-comic-sans",
"pbx-font-impact",
"pbx-font-lucida",
"pbx-font-lucida-console",
"pbx-font-lucida-sans",
"pbx-font-candara",
"pbx-font-optima",
"pbx-font-avenir",
"pbx-font-futura",
"pbx-font-calibri",
"pbx-font-cambria",
"pbx-font-didot",
"pbx-font-franklin-gothic",
"pbx-font-rockwell",
"pbx-font-baskerville"
],
fontStyle: ["none", "pbx-italic", "pbx-non-italic"]
}, An = {
verticalPadding: [
"none",
"lg:pbx-py-0",
"lg:pbx-py-0.5",
"lg:pbx-py-1",
"lg:pbx-py-1.5",
"lg:pbx-py-2",
"lg:pbx-py-2.5",
"lg:pbx-py-3",
"lg:pbx-py-3.5",
"lg:pbx-py-4",
"lg:pbx-py-5",
"lg:pbx-py-6",
"lg:pbx-py-7",
"lg:pbx-py-8",
"lg:pbx-py-9",
"lg:pbx-py-10",
"lg:pbx-py-11",
"lg:pbx-py-12",
"lg:pbx-py-14",
"lg:pbx-py-16",
"lg:pbx-py-20",
"lg:pbx-py-24",
"lg:pbx-py-28",
"lg:pbx-py-32",
"lg:pbx-py-36",
"lg:pbx-py-40",
"lg:pbx-py-44",
"lg:pbx-py-48",
"lg:pbx-py-52",
"lg:pbx-py-56",
"lg:pbx-py-60",
"lg:pbx-py-64",
"lg:pbx-py-72",
"lg:pbx-py-80",
"lg:pbx-py-96"
],
horizontalPadding: [
"none",
"lg:pbx-px-0",
"lg:pbx-px-0.5",
"lg:pbx-px-1",
"lg:pbx-px-1.5",
"lg:pbx-px-2",
"lg:pbx-px-2.5",
"lg:pbx-px-3",
"lg:pbx-px-3.5",
"lg:pbx-px-4",
"lg:pbx-px-5",
"lg:pbx-px-6",
"lg:pbx-px-7",
"lg:pbx-px-8",
"lg:pbx-px-9",
"lg:pbx-px-10",
"lg:pbx-px-11",
"lg:pbx-px-12",
"lg:pbx-px-14",
"lg:pbx-px-16",
"lg:pbx-px-20",
"lg:pbx-px-24",
"lg:pbx-px-28",
"lg:pbx-px-32",
"lg:pbx-px-36",
"lg:pbx-px-40",
"lg:pbx-px-44",
"lg:pbx-px-48",
"lg:pbx-px-52",
"lg:pbx-px-56",
"lg:pbx-px-60",
"lg:pbx-px-64",
"lg:pbx-px-72",
"lg:pbx-px-80",
"lg:pbx-px-96"
],
verticalMargin: [
"none",
"lg:pbx-my-0",
"lg:pbx-my-0.5",
"lg:pbx-my-1",
"lg:pbx-my-1.5",
"lg:pbx-my-2",
"lg:pbx-my-2.5",
"lg:pbx-my-3",
"lg:pbx-my-3.5",
"lg:pbx-my-4",
"lg:pbx-my-5",
"lg:pbx-my-6",
"lg:pbx-my-7",
"lg:pbx-my-8",
"lg:pbx-my-9",
"lg:pbx-my-10",
"lg:pbx-my-11",
"lg:pbx-my-12",
"lg:pbx-my-14",
"lg:pbx-my-16",
"lg:pbx-my-20",
"lg:pbx-my-24",
"lg:pbx-my-28",
"lg:pbx-my-32",
"lg:pbx-my-36",
"lg:pbx-my-40",
"lg:pbx-my-44",
"lg:pbx-my-48",
"lg:pbx-my-52",
"lg:pbx-my-56",
"lg:pbx-my-60",
"lg:pbx-my-64",
"lg:pbx-my-72",
"lg:pbx-my-80",
"lg:pbx-my-96"
],
horizontalMargin: [
"none",
"lg:pbx-mx-0",
"lg:pbx-mx-0.5",
"lg:pbx-mx-1",
"lg:pbx-mx-1.5",
"lg:pbx-mx-2",
"lg:pbx-mx-2.5",
"lg:pbx-mx-3",
"lg:pbx-mx-3.5",
"lg:pbx-mx-4",
"lg:pbx-mx-5",
"lg:pbx-mx-6",
"lg:pbx-mx-7",
"lg:pbx-mx-8",
"lg:pbx-mx-9",
"lg:pbx-mx-10",
"lg:pbx-mx-11",
"lg:pbx-mx-12",
"lg:pbx-mx-14",
"lg:pbx-mx-16",
"lg:pbx-mx-20",
"lg:pbx-mx-24",
"lg:pbx-mx-28",
"lg:pbx-mx-32",
"lg:pbx-mx-36",
"lg:pbx-mx-40",
"lg:pbx-mx-44",
"lg:pbx-mx-48",
"lg:pbx-mx-52",
"lg:pbx-mx-56",
"lg:pbx-mx-60",
"lg:pbx-mx-64",
"lg:pbx-mx-72",
"lg:pbx-mx-80",
"lg:pbx-mx-96"
]
}, jt = {
roundedGlobal: [
"none",
"pbx-rounded-sm",
"pbx-rounded",
"pbx-rounded-md",
"pbx-rounded-lg",
"pbx-rounded-xl",
"pbx-rounded-2xl",
"pbx-rounded-3xl",
"pbx-rounded-full"
],
roundedTopLeft: [
"none",
"pbx-rounded-tl-sm",
"pbx-rounded-tl",
"pbx-rounded-tl-md",
"pbx-rounded-tl-lg",
"pbx-rounded-tl-xl",
"pbx-rounded-tl-2xl",
"pbx-rounded-tl-3xl",
"pbx-rounded-tl-full"
],
roundedTopRight: [
"none",
"pbx-rounded-tr-sm",
"pbx-rounded-tr",
"pbx-rounded-tr-md",
"pbx-rounded-tr-lg",
"pbx-rounded-tr-xl",
"pbx-rounded-tr-2xl",
"pbx-rounded-tr-3xl",
"pbx-rounded-tr-full"
],
roundedBottomLeft: [
"none",
"pbx-rounded-bl-sm",
"pbx-rounded-bl",
"pbx-rounded-bl-md",
"pbx-rounded-bl-lg",
"pbx-rounded-bl-xl",
"pbx-rounded-bl-2xl",
"pbx-rounded-bl-3xl",
"pbx-rounded-bl-full"
],
roundedBottomRight: [
"none",
"pbx-rounded-br-sm",
"pbx-rounded-br",
"pbx-rounded-br-md",
"pbx-rounded-br-lg",
"pbx-rounded-br-xl",
"pbx-rounded-br-2xl",
"pbx-rounded-br-3xl",
"pbx-rounded-br-full"
]
}, Wr = {
borderStyle: [
"none",
"pbx-border-solid",
"pbx-border-dashed",
"pbx-border-dotted",
"pbx-border-double",
"pbx-border-hidden"
],
borderWidth: [
"none",
"pbx-border",
// 1px
"pbx-border-2",
// 2px
"pbx-border-4",
// 4px
"pbx-border-8"
// 8px
],
borderColor: [
"none",
"pbx-border-white",
"pbx-border-black",
"pbx-border-slate-50",
"pbx-border-slate-100",
"pbx-border-slate-200",
"pbx-border-slate-300",
"pbx-border-slate-400",
"pbx-border-slate-500",
"pbx-border-slate-600",
"pbx-border-slate-700",
"pbx-border-slate-800",
"pbx-border-slate-900",
"pbx-border-gray-50",
"pbx-border-gray-100",
"pbx-border-gray-200",
"pbx-border-gray-300",
"pbx-border-gray-400",
"pbx-border-gray-500",
"pbx-border-gray-600",
"pbx-border-gray-700",
"pbx-border-gray-800",
"pbx-border-gray-900",
"pbx-border-zinc-50",
"pbx-border-zinc-100",
"pbx-border-zinc-200",
"pbx-border-zinc-300",
"pbx-border-zinc-400",
"pbx-border-zinc-500",
"pbx-border-zinc-600",
"pbx-border-zinc-700",
"pbx-border-zinc-800",
"pbx-border-zinc-900",
"pbx-border-neutral-50",
"pbx-border-neutral-100",
"pbx-border-neutral-200",
"pbx-border-neutral-300",
"pbx-border-neutral-400",
"pbx-border-neutral-500",
"pbx-border-neutral-600",
"pbx-border-neutral-700",
"pbx-border-neutral-800",
"pbx-border-neutral-900",
"pbx-border-stone-50",
"pbx-border-stone-100",
"pbx-border-stone-200",
"pbx-border-stone-300",
"pbx-border-stone-400",
"pbx-border-stone-500",
"pbx-border-stone-600",
"pbx-border-stone-700",
"pbx-border-stone-800",
"pbx-border-stone-900",
"pbx-border-red-50",
"pbx-border-red-100",
"pbx-border-red-200",
"pbx-border-red-300",
"pbx-border-red-400",
"pbx-border-red-500",
"pbx-border-red-600",
"pbx-border-red-700",
"pbx-border-red-800",
"pbx-border-red-900",
"pbx-border-orange-50",
"pbx-border-orange-100",
"pbx-border-orange-200",
"pbx-border-orange-300",
"pbx-border-orange-400",
"pbx-border-orange-500",
"pbx-border-orange-600",
"pbx-border-orange-700",
"pbx-border-orange-800",
"pbx-border-orange-900",
"pbx-border-amber-50",
"pbx-border-amber-100",
"pbx-border-amber-200",
"pbx-border-amber-300",
"pbx-border-amber-400",
"pbx-border-amber-500",
"pbx-border-amber-600",
"pbx-border-amber-700",
"pbx-border-amber-800",
"pbx-border-amber-900",
"pbx-border-yellow-50",
"pbx-border-yellow-100",
"pbx-border-yellow-200",
"pbx-border-yellow-300",
"pbx-border-yellow-400",
"pbx-border-yellow-500",
"pbx-border-yellow-600",
"pbx-border-yellow-700",
"pbx-border-yellow-800",
"pbx-border-yellow-900",
"pbx-border-lime-50",
"pbx-border-lime-100",
"pbx-border-lime-200",
"pbx-border-lime-300",
"pbx-border-lime-400",
"pbx-border-lime-500",
"pbx-border-lime-600",
"pbx-border-lime-700",
"pbx-border-lime-800",
"pbx-border-lime-900",
"pbx-border-green-50",
"pbx-border-green-100",
"pbx-border-green-200",
"pbx-border-green-300",
"pbx-border-green-400",
"pbx-border-green-500",
"pbx-border-green-600",
"pbx-border-green-700",
"pbx-border-green-800",
"pbx-border-green-900",
"pbx-border-emerald-50",
"pbx-border-emerald-100",
"pbx-border-emerald-200",
"pbx-border-emerald-300",
"pbx-border-emerald-400",
"pbx-border-emerald-500",
"pbx-border-emerald-600",
"pbx-border-emerald-700",
"pbx-border-emerald-800",
"pbx-border-emerald-900",
"pbx-border-teal-50",
"pbx-border-teal-100",
"pbx-border-teal-200",
"pbx-border-teal-300",
"pbx-border-teal-400",
"pbx-border-teal-500",
"pbx-border-teal-600",
"pbx-border-teal-700",
"pbx-border-teal-800",
"pbx-border-teal-900",
"pbx-border-cyan-50",
"pbx-border-cyan-100",
"pbx-border-cyan-200",
"pbx-border-cyan-300",
"pbx-border-cyan-400",
"pbx-border-cyan-500",
"pbx-border-cyan-600",
"pbx-border-cyan-700",
"pbx-border-cyan-800",
"pbx-border-cyan-900",
"pbx-border-sky-50",
"pbx-border-sky-100",
"pbx-border-sky-200",
"pbx-border-sky-300",
"pbx-border-sky-400",
"pbx-border-sky-500",
"pbx-border-sky-600",
"pbx-border-sky-700",
"pbx-border-sky-800",
"pbx-border-sky-900",
"pbx-border-blue-50",
"pbx-border-blue-100",
"pbx-border-blue-200",
"pbx-border-blue-300",
"pbx-border-blue-400",
"pbx-border-blue-500",
"pbx-border-blue-600",
"pbx-border-blue-700",
"pbx-border-blue-800",
"pbx-border-blue-900",
"pbx-border-indigo-50",
"pbx-border-indigo-100",
"pbx-border-indigo-200",
"pbx-border-indigo-300",
"pbx-border-indigo-400",
"pbx-border-indigo-500",
"pbx-border-indigo-600",
"pbx-border-indigo-700",
"pbx-border-indigo-800",
"pbx-border-indigo-900",
"pbx-border-violet-50",
"pbx-border-violet-100",
"pbx-border-violet-200",
"pbx-border-violet-300",
"pbx-border-violet-400",
"pbx-border-violet-500",
"pbx-border-violet-600",
"pbx-border-violet-700",
"pbx-border-violet-800",
"pbx-border-violet-900",
"pbx-border-purple-50",
"pbx-border-purple-100",
"pbx-border-purple-200",
"pbx-border-purple-300",
"pbx-border-purple-400",
"pbx-border-purple-500",
"pbx-border-purple-600",
"pbx-border-purple-700",
"pbx-border-purple-800",
"pbx-border-purple-900",
"pbx-border-fuchsia-50",
"pbx-border-fuchsia-100",
"pbx-border-fuchsia-200",
"pbx-border-fuchsia-300",
"pbx-border-fuchsia-400",
"pbx-border-fuchsia-500",
"pbx-border-fuchsia-600",
"pbx-border-fuchsia-700",
"pbx-border-fuchsia-800",
"pbx-border-fuchsia-900",
"pbx-border-pink-50",
"pbx-border-pink-100",
"pbx-border-pink-200",
"pbx-border-pink-300",
"pbx-border-pink-400",
"pbx-border-pink-500",
"pbx-border-pink-600",
"pbx-border-pink-700",
"pbx-border-pink-800",
"pbx-border-pink-900",
"pbx-border-rose-50",
"pbx-border-rose-100",
"pbx-border-rose-200",
"pbx-border-rose-300",
"pbx-border-rose-400",
"pbx-border-rose-500",
"pbx-border-rose-600",
"pbx-border-rose-700",
"pbx-border-rose-800",
"pbx-border-rose-900"
]
};
let fi;
const rb = new Uint8Array(16);
function ob() {
if (!fi && (fi = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !fi))
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
return fi(rb);
}
const Ie = [];
for (let n = 0; n < 256; ++n)
Ie.push((n + 256).toString(16).slice(1));
function ib(n, e = 0) {
return Ie[n[e + 0]] + Ie[n[e + 1]] + Ie[n[e + 2]] + Ie[n[e + 3]] + "-" + Ie[n[e + 4]] + Ie[n[e + 5]] + "-" + Ie[n[e + 6]] + Ie[n[e + 7]] + "-" + Ie[n[e + 8]] + Ie[n[e + 9]] + "-" + Ie[n[e + 10]] + Ie[n[e + 11]] + Ie[n[e + 12]] + Ie[n[e + 13]] + Ie[n[e + 14]] + Ie[n[e + 15]];
}
const sb = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), wc = {
randomUUID: sb
};
function Sc(n, e, t) {
if (wc.randomUUID && !n)
return wc.randomUUID();
n = n || {};
const r = n.random || (n.rng || ob)();
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, ib(r);
}
const Pe = function(e = 200) {
return new Promise((t) => {
setTimeout(t, e);
});
}, Tn = function(n) {
return !n || typeof n == "object" && n.constructor === Object && Object.keys(n).length === 0;
};
function _u(n, e) {
if (!n)
return console.warn("No valid pagebuilder element passed"), "";
const t = n.cloneNode(!0);
if (t.removeAttribute("id"), t.querySelectorAll(
"[data-componentid], [data-component-title], #page-builder-editor-editable-area"
).forEach((i) => {
i.removeAttribute("data-componentid"), i.removeAttribute("data-component-title"), i.id === "page-builder-editor-editable-area" && i.removeAttribute("id");
}), e && e && typeof e.imageUrlPrefix == "string") {
const i = e.imageUrlPrefix;
t.querySelectorAll("img").forEach((l) => {
const a = l.getAttribute("src") || "";
!a.startsWith("http") && // extra safety
i && !a.startsWith(i) && l.setAttribute("src", i + a.replace(/^\/+/, ""));
});
}
const o = (i) => {
for (let s = i.childNodes.length - 1; s >= 0; s--) {
const l = i.childNodes[s];
l.nodeType === Node.COMMENT_NODE ? i.removeChild(l) : l.nodeType === Node.ELEMENT_NODE && o(l);
}
};
return o(t), t.outerHTML;
}
const lb = [
"en",
"zh-Hans",
"fr",
"ja",
"ru",
"es",
"pt",
"de",
"ar",
"hi"
];
class ab {
constructor(e) {
// Class properties with types
be(this, "fontSizeRegex", /^(sm:|md:|lg:|xl:|2xl:)?pbx-text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/);
be(this, "pageBuilderStateStore");
be(this, "getLocalStorageItemName");
be(this, "getApplyImageToSelection");
be(this, "getHyberlinkEnable");
be(this, "getComponents");
be(this, "getComponent");
be(this, "getElement");
be(this, "getComponentArrayAddMethod");
be(this, "NoneListernesTags");
be(this, "hasStartedEditing", !1);
// Hold data from Database or Backend for updated post
be(this, "originalComponents");
// Holds data to be mounted when pagebuilder is not yet present in the DOM
be(this, "savedMountComponents", null);
be(this, "pendingMountComponents", null);
be(this, "isPageBuilderMissingOnStart", !1);
// Add a class-level WeakMap to track elements and their listeners
// Use class-level WeakMap from being a local variable inside addListenersToEditableElements to a private class-level property.
// This ensures that the map persists across multiple calls to the method and retains knowledge of
// which elements already have listeners.
// This prevents multiple event listeners being attached to the same HTML elements
be(this, "elementsWithListeners", /* @__PURE__ */ new WeakMap());
/**
* Handles the mouseover event for editable elements, showing a hover state.
* @param {Event} e - The mouse event.
* @param {HTMLElement} element - The element being hovered over.
* @private
*/
be(this, "handleMouseOver", (e, t) => {
e.preventDefault(), e.stopPropagation();
const r = document.querySelector("#pagebuilder");
if (!r) return;
const o = r.querySelector("[hovered]");
o && o.removeAttribute("hovered"), t.hasAttribute("selected") || t.setAttribute("hovered", "");
});
/**
* Handles the mouseleave event for editable elements, removing the hover state.
* @param {Event} e - The mouse event.
* @private
*/
be(this, "handleMouseLeave", (e) => {
e.preventDefault(), e.stopPropagation();
const t = document.querySelector("#pagebuilder");
if (!t) return;
const r = t.querySelector("[hovered]");
r && r.removeAttribute("hovered");
});
/**
* Attaches click, mouseover, and mouseleave event listeners to all editable elements in the page builder.
* @private
*/
be(this, "addListenersToEditableElements", async () => {
const e = document.querySelector("#pagebuilder");
e && (await ce(), e.querySelectorAll("section *").forEach((t) => {
if (this.isEditableElement(t)) {
const r = t;
if (this.elementsWithListeners.has(r)) {
const l = this.elementsWithListeners.get(r);
l && (r.removeEventListener("click", l.click), r.removeEventListener("mouseover", l.mouseover), r.removeEventListener("mouseleave", l.mouseleave));
}
const o = (l) => this.handleElementClick(l, r), i = (l) => this.handleMouseOver(l, r), s = (l) => this.handleMouseLeave(l);
r.addEventListener("click", o), r.addEventListener("mouseover", i), r.addEventListener("mouseleave", s), this.elementsWithListeners.set(r, {
click: o,
mouseover: i,
mouseleave: s
});
}
}));
});
/**
* Handles the click event for editable elements, setting the element as selected.
* @param {Event} e - The click event.
* @param {HTMLElement} element - The clicked element.
* @private
*/
be(this, "handleElementClick", async (e, t) => {
e.preventDefault(), e.stopPropagation();
const r = document.querySelector("#pagebuilder");
if (!r) return;
this.pageBuilderStateStore.setMenuRight(!0);
const o = r.querySelector("[selected]");
o && o.removeAttribute("selected"), t.removeAttribute("hovered"), t.setAttribute("selected", ""), this.pageBuilderStateStore.setElement(t), await this.handleAutoSave();
});
/**
* Triggers an auto-save of the current page builder content to local storage if enabled.
*/
be(this, "handleAutoSave", async () => {
this.startEditing();
const e = this.pageBuilderStateStore.getPageBuilderConfig;
if (e && e.userSettings && typeof e.userSettings.autoSave == "boolean" && e.userSettings.autoSave !== !1) {
if (this.pageBuilderStateStore.getIsSaving) return;
try {
this.pageBuilderStateStore.setIsSaving(!0), this.saveDomComponentsToLocalStorage(), await Pe(400);
} catch (t) {
console.error("Error trying auto save.", t);
} finally {
this.pageBuilderStateStore.setIsSaving(!1);
}
}
if (e && !e.userSettings)
try {
this.pageBuilderStateStore.setIsSaving(!0), this.saveDomComponentsToLocalStorage(), await Pe(400);
} catch (t) {
console.error("Error trying saving.", t);
} finally {
this.pageBuilderStateStore.setIsSaving(!1);
}
});
/**
* Manually saves the current page builder content to local storage.
*/
be(this, "handleManualSave", async (e) => {
this.pageBuilderStateStore.setIsSaving(!0), e || this.clearHtmlSelection(), this.startEditing(), this.saveDomComponentsToLocalStorage(), await Pe(300), this.pageBuilderStateStore.setIsSaving(!1);
});
/**
* Ensures that a text area element has content, adding a visual indicator if it's empty.
*/
be(this, "ensureTextAreaHasContent", () => {
if (!this.getElement.value || typeof this.getElement.value.innerHTML != "string")
return;
const e = this.getElement.value, t = e.tagName;
["DIV"].includes(t) && e.tagName.toLowerCase() !== "img" && e.textContent && Number(e.textContent.length) === 0 ? (e.classList.add("h-6"), e.classList.add("bg-red-50")) : (e.classList.remove("h-6"), e.classList.remove("bg-red-50"));
});
/**
* Handles text input for an element, updating its content.
* @param {string} textContentVueModel - The new text content from the Vue model.
* @returns {Promise<void>}
*/
be(this, "handleTextInput", async (e) => {
var t;
typeof ((t = this.getElement.value) == null ? void 0 : t.innerHTML) == "string" && (typeof this.getElement.value.innerHTML == "string" && (await ce(), this.getElement.value.textContent = e, this.pageBuilderStateStore.setTextAreaVueModel(this.getElement.value.innerHTML), this.getElement.value.innerHTML = e), this.ensureTextAreaHasContent());
});
this.hasStartedEditing = !1, this.pageBuilderStateStore = e, this.getApplyImageToSelection = I(
() => this.pageBuilderStateStore.getApplyImageToSelection
), this.getLocalStorageItemName = I(
() => this.pageBuilderStateStore.getLocalStorageItemName
), this.getHyberlinkEnable = I(() => this.pageBuilderStateStore.getHyberlinkEnable), this.getComponents = I(() => this.pageBuilderStateStore.getComponents), this.getComponent = I(() => this.pageBuilderStateStore.getComponent), this.getElement = I(() => this.pageBuilderStateStore.getElement), this.getComponentArrayAddMethod = I(
() => this.pageBuilderStateStore.getComponentArrayAddMethod
), this.NoneListernesTags = [
"P",
"H1",
"H2",
"H3",
"H4",
"H5",
"H6",
"IFRAME",
"UL",
"OL",
"LI",
"EM",
"STRONG",
"B",
"A",
"SPAN",
"BLOCKQUOTE",
"BR",
"PRE",
"CODE",
"MARK",
"DEL",
"INS",
"U",
"FIGURE",
"FIGCAPTION"
];
}
/**
* Returns an array of available languages.
* @returns {AvailableLanguage[]} An array of available language codes.
*/
availableLanguage() {
return lb;
}
/**
* Sets the current language in the page builder state.
* @param {string} lang - The language code to set.
*/
changeLanguage(e) {
this.pageBuilderStateStore.setCurrentLanguage(e);
}
/**
* Deselects any selected or hovered elements in the builder UI.
* @returns {Promise<void>}
*/
async clearHtmlSelection() {
this.pageBuilderStateStore.setComponent(null), this.pageBuilderStateStore.setElement(null), await this.removeHoveredAndSelected();
}
/**
* Ensures that the `updateOrCreate` configuration is valid and sets default values if necessary.
* @param {PageBuilderConfig} config - The page builder configuration.
* @private
*/
ensureUpdateOrCreateConfig(e) {
if (!e.updateOrCreate || e.updateOrCreate && Tn(e.updateOrCreate)) {
const t = {
...e,
updateOrCreate: {
formType: "create",
formName: "post"
}
};
this.pageBuilderStateStore.setPageBuilderConfig(t);
return;
}
if (e.updateOrCreate && typeof e.updateOrCreate.formType == "string" && (e.updateOrCreate.formType === "create" || e.updateOrCreate.formType === "update") && typeof e.updateOrCreate.formName != "string" || typeof e.updateOrCreate.formName == "string" && e.updateOrCreate.formName.length === 0) {
const t = {
...e,
updateOrCreate: {
formType: e.updateOrCreate.formType,
formName: "post"
}
};
this.pageBuilderStateStore.setPageBuilderConfig(t);
}
if (e.updateOrCreate && typeof e.updateOrCreate.formType != "string" || typeof e.updateOrCreate.formType == "string" && e.updateOrCreate.formType !== "create" && e.updateOrCreate.formType !== "update" && typeof e.updateOrCreate.formName == "string" && e.updateOrCreate.formName.length !== 0) {
const t = {
...e,
updateOrCreate: {
formType: "create",
formName: e.updateOrCreate.formName
}
};
this.pageBuilderStateStore.setPageBuilderConfig(t);
return;
}
if (e.updateOrCreate && typeof e.updateOrCreate.formType == "string" && e.updateOrCreate.formType !== "create" && e.updateOrCreate.formType !== "update" && typeof e.formName != "string") {
const t = {
...e,
updateOrCreate: {
formType: "create",
formName: "post"
}
};
this.pageBuilderStateStore.setPageBuilderConfig(t);
}
}
/**
* Validates the user-provided components array.
* @param {unknown} components - The components data to validate.
* @returns {{error: true, warning: string, status: string} | {error: true, reason: string} | undefined} An error object if validation fails, otherwise undefined.
* @private
*/
validateUserProvidedComponents(e) {
const t = this.pageBuilderStateStore.getPageBuilderConfig && this.pageBuilderStateStore.getPageBuilderConfig.updateOrCreate && this.pageBuilderStateStore.getPageBuilderConfig.updateOrCreate.formType;
if (Array.isArray(e) && e.length >= 1 && t === "create" && e)
return {
error: !0,
warning: "You cannot set formType to create in your configuration while also passing a components data array to the Page Builder. Please set formType to update.",
status: "validation_failed"
};
if (!Array.isArray(e))
return {
error: !0,
reason: "Components data must be an array."
};
const r = e[0];
if (r && "html_code" in r && typeof r.html_code != "string")
return {
error: !0,
reason: "The 'html_code' property in the first object must be a string."
};
if (Array.isArray(e) && e.length >= 1 && (!r || !("html_code" in r)))
return {
error: !0,
reason: "The first object in the array must include an 'html_code' key."
};
}
/**
* Ensures that the language configuration is valid and sets default values if necessary.
* @param {PageBuilderConfig} config - The page builder configuration.
* @private
*/
ensureLanguage(e) {
const t = "en", r = ["en", "zh-Hans", "fr", "ja", "ru", "es", "pt", "de", "ar", "hi"];
let o = !1;
const i = e.userSettings, s = i && i.language;
if ((!i || Tn(i) || !s || Tn(s)) && (o = !0), o) {
const l = {
...e,
userSettings: {
...i,
language: {
default: t,
enable: r
}
}
};
this.pageBuilderStateStore.setPageBuilderConfig(l);
return;
}
if (s && Array.isArray(s.enable) && s.default && !s.enable.includes(s.default)) {
const l = [...s.enable, s.default], a = {
...e,
userSettings: {
...i,
language: {
...s,
enable: l
}
}
};
this.pageBuilderStateStore.setPageBuilderConfig(a);
}
}
/**
* Validates the entire page builder configuration.
* @param {PageBuilderConfig} config - The page builder configuration.
* @private
*/
validateConfig(e) {
const t = {
updateOrCreate: {
formType: "create",
formName: "post"
}
};
(!e || e && Object.keys(e).length === 0 && e.constructor === Object) && this.pageBuilderStateStore.setPageBuilderConfig(t), e && Object.keys(e).length !== 0 && e.constructor === Object && this.ensureUpdateOrCreateConfig(e), this.ensureLanguage(e);
}
/**
* Saves user settings to local storage.
* @param {string} newLang - The new language to save.
*/
saveUserSettingsStorage(e) {
localStorage.setItem(
"userSettingsPageBuilder",
JSON.stringify({ userSettings: { lang: e } })
);
}
/**
* Initializes the Page Builder.
* @param {PageBuilderConfig} config - The configuration object for the Page Builder.
* @param {BuilderResourceData} [passedComponentsArray] - Optional array of components to load.
* @returns {Promise<StartBuilderResult>} A result object indicating success or failure.
*/
async startBuilder(e, t) {
this.pageBuilderStateStore.setBuilderStarted(!0);
const r = document.querySelector("#pagebuilder");
let o;
try {
this.originalComponents = t, this.pageBuilderStateStore.setPageBuilderConfig(e), this.validateConfig(e), o = this.validateUserProvidedComponents(t), this.updateLocalStorageItemName(), this.initializeHistory(), t && (this.savedMountComponents = t), r || (this.isPageBuilderMissingOnStart = !0), t && !r && (this.pendingMountComponents = t), r && this.completeBuilderInitialization(t);
const i = {
message: "Page builder started successfully."
};
return o && (i.validation = o), Array.isArray(t) && t.length >= 0 && (i.passedComponentsArray = t), i;
} catch (i) {
return console.error("Not able to start the Page Builder", i), {
error: !0,
reason: "Failed to start the Page Builder due to an unexpected error."
};
}
}
/**
* Completes the builder initialization process once the DOM is ready.
* @param {BuilderResourceData} [passedComponentsArray] - Optional array of components to load.
* @returns {Promise<void>}
*/
async completeBuilderInitialization(e) {
this.pageBuilderStateStore.setIsLoadingGlobal(!0), await Pe(400), this.deleteAllComponentsFromDOM();
const t = this.pageBuilderStateStore.getPageBuilderConfig, r = t && t.updateOrCreate && t.updateOrCreate.formType, o = this.getSavedPageHtml();
if (await this.clearHtmlSelection(), r === "update" || r === "create") {
if (!this.pendingMountComponents) {
if (!e && this.isPageBuilderMissingOnStart && o) {
await this.completeMountProcess(o);
return;
}
if (e && !o) {
const i = this.renderComponentsToHtml(e);
await this.completeMountProcess(i, !0), this.saveDomComponentsToLocalStorage();
return;
}
if (e && o) {
const i = this.renderComponentsToHtml(e);
await this.completeMountProcess(i, !0), await Pe(500), this.pageBuilderStateStore.setHasLocalDraftForUpdate(!0);
return;
}
if (!e && o && !this.savedMountComponents) {
await this.completeMountProcess(o);
return;
}
if (!e && this.savedMountComponents && o) {
const i = this.renderComponentsToHtml(this.savedMountComponents);
await this.completeMountProcess(i);
return;
}
if (!e && !o && this.isPageBuilderMissingOnStart) {
const i = this.renderComponentsToHtml([]);
await this.completeMountProcess(i);
return;
}
if (!this.isPageBuilderMissingOnStart && !o && !e) {
const i = this.renderComponentsToHtml([]);
await this.completeMountProcess(i);
return;
}
}
if (this.pendingMountComponents) {
if (o && this.isPageBuilderMissingOnStart) {
const i = this.renderComponentsToHtml(this.pendingMountComponents);
await this.completeMountProcess(i, !0), await Pe(500), this.pageBuilderStateStore.setHasLocalDraftForUpdate(!0), this.pendingMountComponents = null;
return;
}
if (!o && e && this.isPageBuilderMissingOnStart) {
const i = this.renderComponentsToHtml(this.pendingMountComponents);
await this.completeMountProcess(i, !0), this.saveDomComponentsToLocalStorage();
return;
}
if (!e && !o && this.isPageBuilderMissingOnStart) {
const i = this.renderComponentsToHtml(this.pendingMountComponents);
await this.completeMountProcess(i, !0), this.saveDomComponentsToLocalStorage();
return;
}
}
}
}
/**
* Converts an array of ComponentObject into a single HTML string.
*
* @returns {string} A single HTML string containing all components.
*/
renderComponentsToHtml(e) {
return !e || Array.isArray(e) && e.length === 0 ? '<div id="pagebuilder" class="pbx-text-black pbx-font-sans"></div>' : e.map((r) => r.html_code).join(`
`);
}
/**
* Completes the mounting process by loading components into the DOM and setting up listeners.
* @param {string} html - The HTML string of components to mount.
* @param {boolean} [useConfigPageSettings] - Whether to use page settings from the passed data.
* @private
*/
async completeMountProcess(e, t) {
await this.mountComponentsToDOM(e, t), this.deleteOldPageBuilderLocalStorage(), this.pageBuilderStateStore.setIsRestoring(!1), this.pageBuilderStateStore.setIsLoadingGlobal(!1);
}
/**
* Applies CSS class changes to the currently selected element.
* @param {string | undefined} cssUserSelection - The user's CSS class selection.
* @param {string[]} CSSArray - The array of possible CSS classes for this property.
* @param {string} mutationName - The name of the store mutation to call.
* @returns {string | undefined} The previously applied CSS class.
* @private
*/
applyElementClassChanges(e, t, r) {
const o = this.getElement.value;
if (!o) return;
const i = t.find((l) => o.classList.contains(l));
let s = i || "none";
if (e === void 0) {
if (typeof r == "string" && r.length > 2 && r in this.pageBuilderStateStore && typeof this.pageBuilderStateStore[r] == "function") {
const l = this.pageBuilderStateStore[r];
l(s);
}
return i;
}
if (typeof e == "string" && e !== "none" ? (s && o.classList.contains(s) && o.classList.remove(s), o.classList.add(e), s = e) : typeof e == "string" && e === "none" && s && (o.classList.remove(s), s = e), typeof r == "string" && r.length > 2 && r in this.pageBuilderStateStore && typeof this.pageBuilderStateStore[r] == "function") {
const l = this.pageBuilderStateStore[r];
l(s), this.pageBuilderStateStore.setElement(o);
}
return i;
}
/**
* Removes all CSS classes from the main page builder container.
* @returns {Promise<void>}
*/
async clearClassesFromPage() {
const e = document.querySelector("#pagebuilder");
e && (e.removeAttribute("class"), this.initializeElementStyles(), await ce());
}
/**
* Removes all inline styles from the main page builder container.
* @returns {Promise<void>}
*/
async clearInlineStylesFromPage() {
const e = document.querySelector("#pagebuilder");
e && (e.removeAttribute("style"), this.initializeElementStyles(), await ce());
}
/**
* Selects the main page builder container for global styling.
* @returns {Promise<void>}
*/
async globalPageStyles() {
const e = document.querySelector("#pagebuilder");
e && (await this.clearHtmlSelection(), this.pageBuilderStateStore.setElement(e), e.setAttribute("data-global-selected", "true"), await ce());
}
/**
* Handles changes to the font weight of the selected element.
* @param {string} [userSelectedFontWeight] - The selected font weight class.
*/
handleFontWeight(e) {
this.applyElementClassChanges(
e,
Vr.fontWeight,
"setFontWeight"
);
}
/**
* Handles changes to the base font size of the selected element.
* @param {string} [userSelectedFontSize] - The selected font size class.
*/
handleFontSizeBase(e) {
this.applyElementClassChanges(e, ho.fontBase, "setFontBase");
}
/**
* Handles changes to the desktop font size of the selected element.
* @param {string} [userSelectedFontSize] - The selected font size class for desktop.
*/
handleFontSizeDesktop(e) {
const t = this.getElement.value;
if (!t) return;
const r = {
"pbx-text-9xl": "pbx-text-6xl",
"pbx-text-8xl": "pbx-text-5xl",
"pbx-text-7xl": "pbx-text-4xl",
"pbx-text-6xl": "pbx-text-3xl",
"pbx-text-5xl": "pbx-text-3xl",
"pbx-text-4xl": "pbx-text-2xl",
"pbx-text-3xl": "pbx-text-1xl",
"pbx-text-2xl": "pbx-text-lg",
"pbx-text-xl": "pbx-text-base",
"pbx-text-lg": "pbx-text-sm",
"pbx-text-base": "pbx-text-xs",
"pbx-text-sm": "pbx-text-xs",
"pbx-text-xs": "pbx-text-xs"
};
if (e) {
Array.from(t.classList).forEach((a) => {
this.fontSizeRegex.test(a) && t.classList.remove(a);
});
const i = e.replace(/^lg:/, ""), s = r[i] || i, l = `lg:${i}`;
s !== i ? t.classList.add(s, l) : t.classList.add(s);
}
const o = ho.fontDesktop.find((i) => t.classList.contains(i));
e || this.pageBuilderStateStore.setFontDesktop("none"), o && !e && this.pageBuilderStateStore.setFontDesktop(o);
}
/**
* Applies helper CSS classes to elements, such as wrapping them or adding responsive text classes.
* @param {HTMLElement} element - The element to process.
* @private
*/
applyHelperCSSToElements(e) {
if (this.wrapElementInDivIfExcluded(e), e.tagName === "DIV" && e.children.length === 1 && ["H1", "H2", "H3", "H4", "H5", "H6"].includes(e.children[0].tagName)) {
const t = e.children[0];
e.classList.forEach((r) => {
this.fontSizeRegex.test(r) && e.classList.remove(r);
}), t.tagName === "H2" && e.classList.add("pbx-text-2xl", "lg:pbx-text-4xl", "pbx-font-medium"), t.tagName === "H3" && e.classList.add("pbx-text-1xl", "lg:pbx-text-3xl", "pbx-font-medium");
}
}
/**
* Toggles the visibility of the TipTap modal for rich text editing.
* @param {boolean} status - Whether to show or hide the modal.
* @returns {Promise<void>}
*/
async toggleTipTapModal(e) {
this.pageBuilderStateStore.setShowModalTipTap(e), await ce(), await this.addListenersToEditableElements(), e || await this.handleAutoSave();
}
/**
* Wraps an element in a div if it's an excluded tag and adjacent to an image.
* @param {HTMLElement} element - The element to potentially wrap.
* @private
*/
wrapElementInDivIfExcluded(e) {
var t;
if (e && this.NoneListernesTags.includes(e.tagName) && (e.previousElementSibling && e.previousElementSibling.tagName === "IMG" || e.nextElementSibling && e.nextElementSibling.tagName === "IMG")) {
const r = document.createElement("div");
(t = e.parentNode) == null || t.insertBefore(r, e), r.appendChild(e);
}
}
/**
* Checks if an element is editable based on its tag name.
* @param {Element | null} el - The element to check.
* @returns {boolean} True if the element is editable, false otherwise.
*/
isEditableElement(e) {
return e ? !this.NoneListernesTags.includes(e.tagName) : !1;
}
getHistoryBaseKey() {
return this.getLocalStorageItemName.value;
}
initializeHistory() {
const e = this.getHistoryBaseKey();
if (e) {
const t = Fr.getHistory(e);
this.pageBuilderStateStore.setHistoryIndex(t.length - 1), this.pageBuilderStateStore.setHistoryLength(t.length);
}
}
/**
* Clones a component object and prepares it for insertion into the DOM by adding unique IDs and prefixes.
* @param {ComponentObject} componentObject - The component object to clone.
* @returns {ComponentObject} The cloned and prepared component object.
*/
cloneCompObjForDOMInsertion(e) {
const t = { ...e }, r = document.querySelector("#page-builder-wrapper");
r && this.getComponentArrayAddMethod.value === "unshift" && r.scrollTo({
top: 0,
behavior: "smooth"
});
const i = new DOMParser().parseFromString(t.html_code || "", "text/html");
i.querySelectorAll("*").forEach((a) => {
this.applyHelperCSSToElements(a);
});
const l = i.querySelector("section");
return l && (l.querySelectorAll("[class]").forEach((a) => {
a.setAttribute(
"class",
this.addTailwindPrefixToClasses(a.getAttribute("class") || "", "pbx-")
);
}), l.dataset.componentid = Sc(), t.title && l.setAttribute("data-component-title", t.title), t.id = l.dataset.componentid, t.html_code = l.outerHTML), t;
}
/**
* Removes the 'hovered' and 'selected' attributes from all elements in the page builder.
* @private
*/
async removeHoveredAndSelected() {
const e = document.querySelector("#pagebuilder");
if (!e) return;
const t = e.querySelector("[hovered]");
t && t.removeAttribute("hovered");
const r = e.querySelector("[selected]");
r && r.removeAttribute("selected");
}
/**
* Syncs the CSS classes of the currently selected element to the state store.
* @private
*/
async syncCurrentClasses() {
var t;
const e = Array.from(((t = this.getElement.value) == null ? void 0 : t.classList) || []);
this.pageBuilderStateStore.setCurrentClasses(e);
}
/**
* Syncs the inline styles of the currently selected element to the state store.
* @private
*/
async syncCurrentStyles() {
var t;
const e = (t = this.getElement.value) == null ? void 0 : t.getAttribute("style");
if (e) {
const r = this.parseStyleString(e);
this.pageBuilderStateStore.setCurrentStyles(r);
} else
this.pageBuilderStateStore.setCurrentStyles({});
}
/**
* Adds a CSS class to the currently selected element.
* @param {string} userSelectedClass - The class to add.
*/
handleAddClasses(e) {
var t, r;
if (typeof e == "string" && e.trim() !== "" && !e.includes(" ") && // Check if class (with prefix) already exists
!((t = this.getElement.value) != null && t.classList.contains("pbx-" + e.trim()))) {
const o = e.trim(), i = o.startsWith("pbx-") ? o : "pbx-" + o;
(r = this.getElement.value) == null || r.classList.add(i), this.pageBuilderStateStore.setElement(this.getElement.value), this.pageBuilderStateStore.setClass(i);
}
}
/**
* Adds or updates an inline style property on the currently selected element.
* @param {string} property - The CSS property to add/update.
* @param {string} value - The value of the CSS property.
*/
handleAddStyle(e, t) {
const r = this.getElement.value;
!r || !e || !t || (r.style.setProperty(e, t), this.pageBuilderStateStore.setElement(r));
}
/**
* Removes an inline style property from the currently selected element.
* @param {string} property - The CSS property to remove.
*/
handleRemoveStyle(e) {
const t = this.getElement.value;
!t || !e || (t.style.removeProperty(e), this.pageBuilderStateStore.setElement(t));
}
/**
* Handles changes to the font family of the selected element.
* @param {string} [userSelectedFontFamily] - The selected font family class.
*/
handleFontFamily(e) {
this.applyElementClassChanges(
e,
Vr.fontFamily,
"setFontFamily"
);
}
/**
* Handles changes to the font style of the selected element.
* @param {string} [userSelectedFontStyle] - The selected font style class.
*/
handleFontStyle(e) {
this.applyElementClassChanges(
e,
Vr.fontStyle,
"setFontStyle"
);
}
/**
* Handles changes to the vertical padding of the selected element.
* @param {string} [userSelectedVerticalPadding] - The selected vertical padding class.
*/
handleVerticalPadding(e) {
this.applyElementClassChanges(
e,
An.verticalPadding,
"setFontVerticalPadding"
);
}
/**
* Handles changes to the horizontal padding of the selected element.
* @param {string} [userSelectedHorizontalPadding] - The selected horizontal padding class.
*/
handleHorizontalPadding(e) {
this.applyElementClassChanges(
e,
An.horizontalPadding,
"setFontHorizontalPadding"
);
}
/**
* Handles changes to the vertical margin of the selected element.
* @param {string} [userSelectedVerticalMargin] - The selected vertical margin class.
*/
handleVerticalMargin(e) {
this.applyElementClassChanges(
e,
An.verticalMargin,
"setFontVerticalMargin"
);
}
/**
* Handles changes to the horizontal margin of the selected element.
* @param {string} [userSelectedHorizontalMargin] - The selected horizontal margin class.
*/
handleHorizontalMargin(e) {
this.applyElementClassChanges(
e,
An.horizontalMargin,
"setFontHorizontalMargin"
);
}
/**
* Handles changes to the border style of the selected element.
* @param {string} [borderStyle] - The selected border style class.
*/
handleBorderStyle(e) {
this.applyElementClassChanges(
e,
Wr.borderStyle,
"setBorderStyle"
);
}
/**
* Handles changes to the border width of the selected element.
* @param {string} [borderWidth] - The selected border width class.
*/
handleBorderWidth(e) {
this.applyElementClassChanges(
e,
Wr.borderWidth,
"setBorderWidth"
);
}
/**
* Handles changes to the border color of the selected element.
* @param {string} [borderColor] - The selected border color class.
*/
handleBorderColor(e) {
this.applyElementClassChanges(
e,
Wr.borderColor,
"setBorderColor"
);
}
// border color, style & width / end
/**
* Handles changes to the background color of the selected element.
* @param {string} [color] - The selected background color class.
*/
handleBackgroundColor(e) {
this.applyElementClassChanges(
e,
Fi.backgroundColorVariables,
"setBackgroundColor"
);
}
/**
* Handles changes to the text color of the selected element.
* @param {string} [color] - The selected text color class.
*/
handleTextColor(e) {
this.applyElementClassChanges(e, Fi.textColorVariables, "setTextColor");
}
/**
* Handles changes to the global border radius of the selected element.
* @param {string} [borderRadiusGlobal] - The selected global border radius class.
*/
handleBorderRadiusGlobal(e) {
this.applyElementClassChanges(
e,
jt.roundedGlobal,
"setBorderRadiusGlobal"
);
}
/**
* Handles changes to the top-left border radius of the selected element.
* @param {string} [borderRadiusTopLeft] - The selected top-left border radius class.
*/
handleBorderRadiusTopLeft(e) {
this.applyElementClassChanges(
e,
jt.roundedTopLeft,
"setBorderRadiusTopLeft"
);
}
/**
* Handles changes to the top-right border radius of the selected element.
* @param {string} [borderRadiusTopRight] - The selected top-right border radius class.
*/
handleBorderRadiusTopRight(e) {
this.applyElementClassChanges(
e,
jt.roundedTopRight,
"setBorderRadiusTopRight"
);
}
/**
* Handles changes to the bottom-left border radius of the selected element.
* @param {string} [borderRadiusBottomleft] - The selected bottom-left border radius class.
*/
handleBorderRadiusBottomleft(e) {
this.applyElementClassChanges(
e,
jt.roundedBottomLeft,
"setBorderRadiusBottomleft"
);
}
/**
* Handles changes to the bottom-right border radius of the selected element.
* @param {string} [borderRadiusBottomRight] - The selected bottom-right border radius class.
*/
handleBorderRadiusBottomRight(e) {
this.applyElementClassChanges(
e,
jt.roundedBottomRight,
"setBorderRadiusBottomRight"
);
}
// border radius / end
/**
* Handles changes to the tablet font size of the selected element.
* @param {string} [userSelectedFontSize] - The selected font size class for tablet.
*/
handleFontSizeTablet(e) {
this.applyElementClassChanges(
e,
ho.fontTablet,
"setFontTablet"
);
}
/**
* Handles changes to the mobile font size of the selected element.
* @param {string} [userSelectedFontSize] - The selected font size class for mobile.
*/
handleFontSizeMobile(e) {
this.applyElementClassChanges(
e,
ho.fontMobile,
"setFontMobile"
);
}
/**
* Handles changes to the background opacity of the selected element.
* @param {string} [opacity] - The selected background opacity class.
*/
handleBackgroundOpacity(e) {
this.applyElementClassChanges(
e,
Hi.backgroundOpacities,
"setBackgroundOpacity"
);
}
/**
* Handles changes to the opacity of the selected element.
* @param {string} [opacity] - The selected opacity class.
*/
handleOpacity(e) {
this.applyElementClassChanges(e, Hi.opacities, "setOpacity");
}
/**
* Removes all components from both the builder state and the DOM.
* @private
*/
deleteAllComponentsFromDOM() {
this.pageBuilderStateStore.setComponents([]);
const e = document.querySelector("#pagebuilder");
e && e.querySelectorAll("section[data-componentid]").forEach((t) => t.remove());
}
async undo() {
this.pageBuilderStateStore.setIsLoadingGlobal(!0), await Pe(300);
const e = this.getHistoryBaseKey();
if (!e) return;
const t = Fr.getHistory(e);
if (t.length > 1 && this.pageBuilderStateStore.getHistoryIndex > 0) {
this.pageBuilderStateStore.setHistoryIndex(this.pageBuilderStateStore.getHistoryIndex - 1);
const r = t[this.pageBuilderStateStore.getHistoryIndex], o = this.renderComponentsToHtml(r.components);
await this.mountComponentsToDOM(o, !1, r.pageSettings);
}
this.pageBuilderStateStore.setIsLoadingGlobal(!1);
}
async redo() {
this.pageBuilderStateStore.setIsLoadingGlobal(!0), await Pe(300);
const e = this.getHistoryBaseKey();
if (!e) return;
const t = Fr.getHistory(e);
if (t.length > 0 && this.pageBuilderStateStore.getHistoryIndex < t.length - 1) {
this.pageBuilderStateStore.setHistoryIndex(this.pageBuilderStateStore.getHistoryIndex + 1);
const r = t[this.pageBuilderStateStore.getHistoryIndex], o = this.renderComponentsToHtml(r.components);
await this.mountComponentsToDOM(o, !1, r.pageSettings);
}
this.pageBuilderStateStore.setIsLoadingGlobal(!1);
}
hasVisibleContent(e) {
if (!e) return !1;
if (e.querySelector("img, video, iframe, input, button, a, h1, h2, h3, h4, h5, h6, p, li, blockquote, pre, code, table")) return !0;
const r = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, null);
for (; r.nextNode(); )
if (r.currentNode.nodeValue && r.currentNode.nodeValue.trim() !== "")
return !0;
return !1;
}
isSectionEmpty(e) {
return !this.hasVisibleContent(e);
}
/**
* Deletes the currently selected component from the DOM and the state.
* @returns {Promise<void>}
*/
async deleteComponentFromDOM() {
var i;
this.syncDomToStoreOnly(), await ce();
const e = this.pageBuilderStateStore.getComponents;
if (!e) return;
const t = e.findIndex(
(s) => {
var l;
return s.id === ((l = this.getComponent.value) == null ? void 0 : l.id);
}
);
if (t === -1)
return;
const r = [
...e.slice(0, t),
...e.slice(t + 1)
];
this.pageBuilderStateStore.setComponents(r);
const o = document.querySelector("#pagebuilder");
if (o && ((i = this.getComponent.value) != null && i.id)) {
const s = o.querySelector(
`section[data-componentid="${this.getComponent.value.id}"]`
);
s && s.remove();
}
await ce(), await this.addListenersToEditableElements(), this.pageBuilderStateStore.setComponent(null), this.pageBuilderStateStore.setElement(null), await this.handleAutoSave();
}
/**
* Deletes the currently selected element from the DOM and stores it for potential restoration.
* @returns {Promise<void>}
*/
async deleteElementFromDOM() {
const e = this.getElement.value;
if (!e) return;
if (e.removeAttribute("selected"), !e.parentNode) {
this.pageBuilderStateStore.setComponent(null), this.pageBuilderStateStore.setElement(null);
return;
}
const t = e.closest("section");
if (e.tagName === "SECTION")
this.deleteComponentFromDOM();
else if (e.remove(), t && this.isSectionEmpty(t)) {
const r = t.getAttribute("data-componentid");
if (r) {
const o = this.pageBuilderStateStore.getComponents;
if (o) {
const i = o.findIndex((s) => s.id === r);
if (i !== -1) {
const s = [
...o.slice(0, i),
...o.slice(i + 1)
];
this.pageBuilderStateStore.setComponents(s), t.remove();
}
}
}
}
this.handleAutoSave(), this.pageBuilderStateStore.setComponent(null), this.pageBuilderStateStore.setElement(null), await this.clearHtmlSelection(), await ce(), await this.addListenersToEditableElements();
}
/**
* Removes a CSS class from the currently selected element.
* @param {string} userSelectedClass - The class to remove.
*/
handleRemoveClasses(e) {
var t, r;
(t = this.getElement.value) != null && t.classList.contains(e) && ((r = this.getElement.value) == null || r.classList.remove(e), this.pageBuilderStateStore.setElement(this.getElement.value), this.pageBuilderStateStore.removeClass(e));
}
/**
* Reorders the currently selected component up or down in the component list.
* @param {number} direction - The direction to move the component (-1 for up, 1 for down).
*/
async reorderComponent(e) {
if (!this.getComponents.value || !this.getComponent.value || this.getComponents.value.length <= 1) return;
const t = this.getComponent.value, r = this.getComponents.value.findIndex(
(l) => l.id === t.id
);
if (r === -1)
return;
const o = r + e;
if (o < 0 || o >= this.getComponents.value.length)
return;
this.getComponents.value.splice(r, 1), this.getComponents.value.splice(o, 0, t), await ce();
const i = document.querySelector("#page-builder-wrapper"), s = i == null ? void 0 : i.querySelector(
`section[data-componentid="${t.id}"]`
);
if (s) {
s.classList.add("pbx-reorder-highlight");
const l = s.previousElementSibling, a = s.nextElementSibling;
if (l && l.tagName === "SECTION" && l.classList.add("pbx-sibling-highlight"), a && a.tagName === "SECTION" && a.classList.add("pbx-sibling-highlight"), i) {
const c = s.offsetTop - i.offsetTop;
i.scrollTop = c - i.clientHeight / 2, setTimeout(() => {
s.classList.remove("pbx-reorder-highlight"), l && l.tagName === "SECTION" && l.classList.remove("pbx-sibling-highlight"), a && a.tagName === "SECTION" && a.classList.remove("pbx-sibling-highlight");
}, 200);
}
}
}
/**
* Checks if the currently selected component can be moved up.
* @returns {boolean} True if the component can be moved up, false otherwise.
*/
canMoveUp() {
return !this.getComponents.value || !this.getComponent.value ? !1 : this.getComponents.value.findIndex(
(t) => {
var r;
return t.id === ((r = this.getComponent.value) == null ? void 0 : r.id);
}
) > 0;
}
/**
* Checks if the currently selected component can be moved down.
* @returns {boolean} True if the component can be moved down, false otherwise.
*/
canMoveDown() {
return !this.getComponents.value || !this.getComponent.value ? !1 : this.getComponents.value.findIndex(
(t) => {
var r;
return t.id === ((r = this.getComponent.value) == null ? void 0 : r.id);
}
) < this.getComponents.value.length - 1;
}
/**
* Checks if the selected element or its first child is an iframe.
* @returns {boolean} True if it is an iframe, false otherwise.
*/
ElOrFirstChildIsIframe() {
var e, t, r;
return ((e = this.getElement.value) == null ? void 0 : e.tagName) === "IFRAME" || ((r = (t = this.getElement.value) == null ? void 0 : t.firstElementChild) == null ? void 0 : r.tagName) === "IFRAME";
}
/**
* Checks if the selected element is a valid text container (i.e., does not contain images or divs).
* @returns {boolean | undefined} True if it's a valid text element, otherwise undefined.
*/
isSelectedElementValidText() {
var r, o, i, s;
let e = !1;
const t = (r = this.getElement.value) == null ? void 0 : r.children;
if (!(((o = this.getElement.value) == null ? void 0 : o.tagName) === "IMG" || ((s = (i = this.getElement.value) == null ? void 0 : i.firstElementChild) == null ? void 0 : s.tagName) === "IFRAME") && t)
return Array.from(t).forEach((l) => {
(l == null ? void 0 : l.tagName) === "IMG" || (l == null ? void 0 : l.tagName) === "DIV" ? e = !1 : e = !0;
}), e;
}
/**
* Generates a preview of the current page design.
*/
previewCurrentDesign() {
this.pageBuilderStateStore.setElement(null);
const e = document.querySelector("#pagebuilder");
if (e && e) {
const t = _u(
e,
this.pageBuilderStateStore.getPageBuilderConfig ? this.pageBuilderStateStore.getPageBuilderConfig : void 0
), r = JSON.stringify([t]);
this.pageBuilderStateStore.setCurrentLayoutPreview(r);
}
}
/**
* Sanitizes a string to be used as a key in local storage.
* @param {string} input - The string to sanitize.
* @returns {string} The sanitized string.
*/
sanitizeForLocalStorage(e) {
return e.trim().toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
}
/**
* Clones an element and removes selection-related attributes from the clone.
* @param {HTMLElement} element - The element to clone.
* @returns {HTMLElement} The sanitized clone.
* @private
*/
cloneAndRemoveSelectionAttributes(e) {
const t = e.cloneNode(!0);
return t.querySelectorAll("[hovered]").forEach((r) => r.removeAttribute("hovered")), t.querySelectorAll("[selected]").forEach((r) => r.removeAttribute("selected")), t.removeAttribute("hovered"), t.removeAttribute("selected"), t;
}
/**
* Syncs the current DOM state of components to the in-memory store.
* @private
*/
syncDomToStoreOnly() {
const e = document.querySelector("#pagebuilder");
if (!e) return;
const t = [];
e.querySelectorAll("section[data-componentid]").forEach((r) => {
const o = this.cloneAndRemoveSelectionAttributes(r);
t.push({
html_code: o.outerHTML,
id: o.getAttribute("data-componentid"),
title: o.getAttribute("data-component-title") || "Untitled Component"
});
}), this.pageBuilderStateStore.setComponents(t);
}
/**
* Saves the current DOM state of components to local storage.
* @private
*/
saveDomComponentsToLocalStorage() {
this.updateLocalStorageItemName();
const e = document.querySelector("#pagebuilder");
if (!e) return;
const t = e.querySelector("[hovered]");
t && t.removeAttribute("hovered");
const r = [];
e.querySelectorAll("section[data-componentid]").forEach((l) => {
const a = this.cloneAndRemoveSelectionAttributes(l);
a.removeAttribute("data-componentid"), r.push({
html_code: a.outerHTML,
title: a.getAttribute("data-component-title") || "Untitled Component"
});
});
const o = {
classes: e.className || "",
style: e.getAttribute("style") || e.style.cssText || ""
}, i = {
components: r,
pageBuilderContentSavedAt: (/* @__PURE__ */ new Date()).toISOString(),
pageSettings: o
}, s = this.getHistoryBaseKey();
if (s) {
const l = localStorage.getItem(s);
if (l || localStorage.setItem(s, JSON.stringify(i)), l) {
const a = JSON.parse(l), c = a.components || [], u = (i.components || []).some((h, b) => {
const m = c[b];
return (
// New component added
!m || // Component HTML changed
m.html_code !== h.html_code
);
}), f = a.pageSettings && a.pageSettings.classes !== i.pageSettings.classes || a.pageSettings && a.pageSettings.style !== i.pageSettings.style;
if (u || f) {
localStorage.setItem(s, JSON.stringify(i));
let h = Fr.getHistory(s);
const b = h[h.length - 1];
if (b) {
const m = JSON.stringify(b.components), x = JSON.stringify(i.components), v = JSON.stringify(b.pageSettings), C = JSON.stringify(i.pageSettings);
if (m === x && v === C)
return;
}
this.pageBuilderStateStore.getHistoryIndex < h.length - 1 && (h = h.slice(0, this.pageBuilderStateStore.getHistoryIndex + 1)), h.push(i), h.length > 10 && (h = h.slice(h.length - 10)), localStorage.setItem(s + "-history", JSON.stringify(h)), this.pageBuilderStateStore.setHistoryIndex(h.length - 1), this.pageBuilderStateStore.setHistoryLength(h.length);
return;
}
}
}
}
/**
* Removes the current page's components from local storage.
* @private
*/
async removeCurrentComponentsFromLocalStorage() {
this.updateLocalStorageItemName(), await ce();
const e = this.getLocalStorageItemName.value;
e && localStorage.removeItem(e);
}
/**
* Handles the form submission process, clearing local storage and the DOM.
* @returns {Promise<void>}
*/
async handleFormSubmission() {
await this.removeCurrentComponentsFromLocalStorage(), this.deleteAllComponentsFromDOM(), this.pageBuilderStateStore.setComponents([]);
}
/**
* Parses a CSS style string into a key-value object.
* @param {string} style - The style string to parse.
* @returns {Record<string, string>} The parsed style object.
* @private
*/
parseStyleString(e) {
return e.split(";").map((t) => t.trim()).filter(Boolean).reduce(
(t, r) => {
const [o, i] = r.split(":").map((s) => s.trim());
return o && i && (t[o] = i), t;
},
{}
);
}
/**
* Deletes old page builder data from local storage (older than 2 weeks).
*/
deleteOldPageBuilderLocalStorage() {
const e = this.pageBuilderStateStore.getPageBuilderConfig;
if ((e && e.updateOrCreate && e.updateOrCreate.formType) === "update") {
let r = 0;
const o = [], i = new Date(Date.now() - 14 * 24 * 60 * 60 * 1e3);
for (let s = 0; s < localStorage.length; s++) {
const l = localStorage.key(s);
if (l && l.startsWith("page-builder-update-resource-"))
try {
const a = localStorage.getItem(l);
if (!a) continue;
const p = JSON.parse(a).pageBuilderContentSavedAt;
p && new Date(p) < i && (r++, o.push({
Number: r,
Key: l,
SavedAt: p
}), localStorage.removeItem(l));
} catch {
}
}
o.length > 0 && (console.info(
`Deleted ${o.length} localStorage item(s) older than ${i} days:`
), console.table(o));
}
}
/**
* Sets a flag to indicate that the user has started editing.
*/
startEditing() {
this.hasStartedEditing = !0;
}
/**
* Resumes editing from a draft saved in local storage.
* @returns {Promise<void>}
*/
async resumeEditingFromDraft() {
this.updateLocalStorageItemName();
const e = this.getSavedPageHtml();
e && (await Pe(400), this.pageBuilderStateStore.setIsLoadingResumeEditing(!0), await this.mountComponentsToDOM(e), this.pageBuilderStateStore.setIsLoadingResumeEditing(!1)), await ce(), await this.addListenersToEditableElements(), this.pageBuilderStateStore.setIsLoadingResumeEditing(!1);
}
/**
* Restores the original content that was loaded when the builder started.
* @returns {Promise<void>}
*/
async restoreOriginalContent() {
if (this.updateLocalStorageItemName(), this.pageBuilderStateStore.setIsRestoring(!0), await Pe(400), Array.isArray(this.originalComponents)) {
await this.clearClassesFromPage(), await this.clearInlineStylesFromPage();
const e = this.renderComponentsToHtml(this.originalComponents);
await this.mountComponentsToDOM(e), this.removeCurrentComponentsFromLocalStorage();
}
await ce(), await this.addListenersToEditableElements(), this.pageBuilderStateStore.setIsRestoring(!1);
}
/**
* Gets the local storage key for the current resource.
* @returns {string | null} The local storage key.
*/
getStorageItemNameForResource() {
return this.getLocalStorageItemName.value;
}
/**
* Retrieves the saved page HTML from local storage.
* @returns {string | false} The HTML string or false if not found.
*/
getSavedPageHtml() {
if (!this.getLocalStorageItemName.value) return !1;
const e = this.getLocalStorageItemName.value;
if (!e) return !1;
const t = localStorage.getItem(e);
if (!t) return !1;
const r = JSON.parse(t);
if (r && Array.isArray(r.components)) {
const o = r.pageSettings && r.pageSettings.classes || "", i = r.pageSettings && r.pageSettings.style || "", s = r.components.map((l) => {
const p = new DOMParser().parseFromString(l.html_code, "text/html").querySelector("section");
return p ? (p.removeAttribute("data-componentid"), p.outerHTML) : l.html_code;
}).join(`
`);
return `<div id="pagebuilder" class="${o}" style="${i}">
${s}
</div>`;
}
return !1;
}
/**
* Applies a selected image to the current element.
* @param {ImageObject} image - The image object to apply.
* @returns {Promise<void>}
*/
async applySelectedImage(e) {
this.pageBuilderStateStore.setApplyImageToSelection(e), this.getElement.value && this.getApplyImageToSelection.value && this.getApplyImageToSelection.value.src && (await ce(), this.pageBuilderStateStore.setBasePrimaryImage(`${this.getApplyImageToSelection.value.src}`), await this.handleAutoSave());
}
/**
* Sets the base primary image from the currently selected element if it's an image.
* @private
*/
setBasePrimaryImageFromSelectedElement() {
if (!this.getElement.value) return;
const e = document.createElement("div");
e.innerHTML = this.getElement.value.outerHTML;
const t = e.getElementsByTagName("img"), r = e.getElementsByTagName("div");
if (t.length === 1 && r.length === 0) {
this.pageBuilderStateStore.setBasePrimaryImage(t[0].src);
return;
}
this.pageBuilderStateStore.setBasePrimaryImage(null);
}
/**
* Adds or removes a hyperlink from the selected element.
* @param {boolean} hyperlinkEnable - Whether to enable or disable the hyperlink.
* @param {string | null} urlInput - The URL for the hyperlink.
* @param {boolean} openHyperlinkInNewTab - Whether the link should open in a new tab.
* @private
*/
addHyperlinkToElement(e, t, r) {
if (!this.getElement.value || !(this.getElement.value instanceof HTMLElement) || typeof this.getElement.value.closest != "function")
return;
const o = this.getElement.value.closest("a"), i = this.getElement.value.querySelector("a");
this.pageBuilderStateStore.setHyperlinkError(null);
const s = /^https?:\/\//, l = M(!0);
if (e === !0 && t !== null && (l.value = s.test(t)), l.value === !1) {
this.pageBuilderStateStore.setHyperlinkMessage(null), this.pageBuilderStateStore.setHyperlinkError("URL is not valid");
return;
}
if (e === !0 && typeof t == "string") {
if (i !== null && t.length !== 0) {
i.href = t, r === !0 && (i.target = "_blank"), r === !1 && i.removeAttribute("target"), i.textContent = this.getElement.value.textContent, this.pageBuilderStateStore.setHyperlinkMessage("Succesfully updated element hyperlink"), this.pageBuilderStateStore.setElementContainsHyperlink(!0);
return;
}
if (i === null && t.length !== 0 && o === null) {
const a = document.createElement("a");
a.href = t, r === !0 && (a.target = "_blank"), a.textContent = this.getElement.value.textContent, this.getElement.value.textContent = "", this.getElement.value.appendChild(a), this.pageBuilderStateStore.setHyperlinkMessage("Successfully added hyperlink to element"), this.pageBuilderStateStore.setElementContainsHyperlink(!0);
return;
}
}
if (e === !1 && t === "removeHyperlink") {
const a = this.getElement.value.textContent || "", c = document.createTextNode(a);
this.getElement.value.textContent = "", this.getElement.value.appendChild(c), this.pageBuilderStateStore.setHyberlinkEnable(!1), this.pageBuilderStateStore.setElementContainsHyperlink(!1);
}
}
/**
* Checks if the selected element contains a hyperlink and updates the state accordingly.
* @private
*/
checkForHyperlink() {
if (!this.getElement.value) return;
const e = this.getElement.value.querySelector("a");
if (e !== null) {
this.pageBuilderStateStore.setHyberlinkEnable(!0), this.pageBuilderStateStore.setElementContainsHyperlink(!0), this.pageBuilderStateStore.setHyperlinkInput(e.href), this.pageBuilderStateStore.setHyperlinkMessage(null), this.pageBuilderStateStore.setHyperlinkError(null), e.target === "_blank" && this.pageBuilderStateStore.setOpenHyperlinkInNewTab(!0), e.target !== "_blank" && this.pageBuilderStateStore.setOpenHyperlinkInNewTab(!1);
return;
}
this.pageBuilderStateStore.setElementContainsHyperlink(!1), this.pageBuilderStateStore.setHyperlinkInput(""), this.pageBuilderStateStore.setHyperlinkError(null), this.pageBuilderStateStore.setHyperlinkMessage(null), this.pageBuilderStateStore.setHyberlinkEnable(!1);
}
/**
* Handles all hyperlink-related actions for the selected element.
* @param {boolean} [hyperlinkEnable] - Whether to enable or disable the hyperlink.
* @param {string | null} [urlInput] - The URL for the hyperlink.
* @param {boolean} [openHyperlinkInNewTab] - Whether the link should open in a new tab.
*/
handleHyperlink(e, t, r) {
var s;
if (this.pageBuilderStateStore.setHyperlinkAbility(!0), !this.getElement.value || !(this.getElement.value instanceof HTMLElement) || typeof this.getElement.value.closest != "function")
return;
this.getElement.value.closest("a") !== null && this.pageBuilderStateStore.setHyperlinkAbility(!1);
const i = (s = this.getElement.value) == null ? void 0 : s.tagName.toUpperCase();
if (i !== "P" && i !== "H1" && i !== "H2" && i !== "H3" && i !== "H4" && i !== "H5" && i !== "H6" && this.pageBuilderStateStore.setHyperlinkAbility(!1), e === void 0) {
this.checkForHyperlink();
return;
}
this.addHyperlinkToElement(e, t || null, r || !1);
}
/**
* Adds a new component to the page builder.
* @param {ComponentObject} componentObject - The component to add.
* @returns {Promise<void>}
*/
async addComponent(e) {
try {
const t = this.cloneCompObjForDOMInsertion({
html_code: e.html_code,
id: e.id,
title: e.title
});
this.pageBuilderStateStore.setPushComponents({
component: t,
componentArrayAddMethod: this.getComponentArrayAddMethod.value ? this.getComponentArrayAddMethod.value : "push"
});
const r = document.querySelector("#page-builder-wrapper");
r && this.getComponentArrayAddMethod.value === "push" && r.scrollTo({
top: r.scrollHeight + 50,
behavior: "smooth"
}), await ce(), await this.addListenersToEditableElements(), await this.handleAutoSave();
} catch (t) {
console.error("Error adding component:", t);
}
}
/**
* Adds a prefix to Tailwind CSS classes in a string.
* @param {string} classList - The string of classes.
* @param {string} [prefix='pbx-'] - The prefix to add.
* @returns {string} The prefixed class string.
* @private
*/
addTailwindPrefixToClasses(e, t = "pbx-") {
return e.split(/\s+/).map((r) => {
if (!r || r.startsWith(t)) return r;
const o = r.split(":"), i = o.pop();
return i.startsWith(t) ? r : [...o, t + i].join(":");
}).join(" ");
}
/**
* Converts a style object to a CSS string.
* @param {string | Record<string, string> | null | undefined} styleObj - The style object.
* @returns {string} The CSS style string.
* @private
*/
convertStyleObjectToString(e) {
return e ? typeof e == "string" ? e : Object.entries(e).map(([t, r]) => `${t.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${r};`).join(" ") : "";
}
/**
* Parses a string of HTML and extracts builder components and global page settings.
* - This method expects an **HTML string** containing one or more `<section>...</section>` elements (such as the output from `getSavedPageHtml()` or a previously saved builder HTML string).
* - **Do NOT pass a JSON string** (such as the result of `JSON.stringify(componentsArray)`) to this method. Passing a JSON string to `DOMParser.parseFromString(..., 'text/html')` will not produce valid DOM nodes. Instead, it will treat the JSON as plain text, resulting in a `<html><head></head><body>{...json...}</body></html>` structure, not real HTML elements.
* - If you pass a JSON string, you will see lots of `\n` and strange HTML, because the parser is just wrapping your JSON in a `<body>` tag as text.
*
* Why only HTML?
* - It enforces a single source of truth for builder state (HTML).
* - It prevents misuse (e.g., passing JSON to a DOM parser, which is always a bug).
* - It makes your documentation and support much simpler.
*
* @param htmlString - The HTML string to parse (must contain `<section>...</section>` elements, not JSON).
* @returns An object with `components` (array of builder components) and `pageSettings` (global styles for the page).
*/
parsePageBuilderHTML(e) {
const r = new DOMParser().parseFromString(e, "text/html");
r.querySelectorAll("[class]").forEach((c) => {
const p = c.getAttribute("class") || "", u = this.addTailwindPrefixToClasses(p);
c.setAttribute("class", u);
});
const o = r.querySelector("#pagebuilder");
let i = {
classes: "",
style: {}
};
if (o) {
const c = o.getAttribute("style") || "";
i = {
classes: o.className || "",
style: this.parseStyleString(c)
};
}
let s = r.querySelectorAll("section");
o && (s = o.querySelectorAll("section"));
const l = Array.from(s).filter(
(c) => !c.parentElement || c.parentElement.tagName.toLowerCase() !== "section"
);
let a = [];
if (l.length > 0 && (a = l.map((c) => ({
id: null,
html_code: c.outerHTML.trim(),
title: c.getAttribute("data-component-title") || "Untitled Component"
}))), l.length === 0) {
const c = o || r.body, p = Array.from(c.children);
if (p.length > 0 && (a = p.map((u) => {
const f = r.createElement("section");
return f.setAttribute("data-component-title", "Untitled Component"), f.innerHTML = u.outerHTML.trim(), {
id: null,
html_code: f.outerHTML.trim(),
title: "Untitled Component"
};
})), p.length === 0) {
const u = r.createElement("section");
u.setAttribute("data-component-title", "Untitled Component"), u.innerHTML = c.innerHTML.trim(), a = [
{
id: null,
html_code: u.outerHTML.trim(),
title: "Untitled Component"
}
];
}
}
return {
components: a,
pageSettings: i
};
}
/**
* Applies modified components by mounting them to the DOM and attaching listeners.
* @param htmlString - The HTML string to apply
* @returns {Promise<string | null>} - Returns error message if failed, otherwise null
*/
async applyModifiedHTML(e) {
if (!e || typeof e == "string" && e.length === 0)
return "No HTML content was provided. Please ensure a valid HTML string is passed.";
if (/<section[\s>]/i.test(e))
return "Error: The <section> tag cannot be used as it is already included inside this component.";
const t = document.createElement("div");
t.innerHTML = e.trim();
const r = t.firstElementChild;
if (!r)
return "Could not parse element from HTML string.";
const o = this.pageBuilderStateStore.getElement;
return o && o.parentElement && (o.replaceWith(r), this.pageBuilderStateStore.setElement(r)), await this.addListenersToEditableElements(), await ce(), null;
}
validateMountingHTML(e, t) {
const r = e.trim(), o = e.match(/<section\b[^>]*>/gi) || [], i = e.match(/<\/section>/gi) || [];
if (!e || e.trim().length === 0) {
const a = "No HTML content was provided. Please ensure a valid HTML string is passed.";
return t && t.logError && console.error(a), a;
}
if (o.length !== i.length) {
const a = "Uneven <section> tags detected in the provided HTML. Each component must be wrapped in its own properly paired <section>...</section>. Ensure that all <section> tags have a matching closing </section> tag.";
return t && t.logError && console.error(a), a;
}
const s = document.createElement("div");
if (s.innerHTML = r, s.querySelector("section section")) {
const a = "Nested <section> tags are not allowed. Please ensure that no <section> is placed inside another <section>.";
return t && t.logError && console.error(a), a;
}
if (r.startsWith("[") || r.startsWith("{")) {
const a = "Brackets [] or curly braces {} are not valid HTML. They are used for data formats like JSON.";
return t && t.logError && console.error(a), a;
}
return null;
}
/**
* Applies modified components by mounting them to the DOM and attaching listeners.
* @param htmlString - The HTML string to apply
* @returns {Promise<string | null>} - Returns error message if failed, otherwise null
*/
async applyModifiedComponents(e) {
const t = e.trim();
if ((e.match(/<section\b[^>]*>/gi) || []).length === 0)
return "No <section> tags found. Each component must be wrapped in a <section> tag.";
const o = this.validateMountingHTML(t);
return o || (await this.mountComponentsToDOM(t), await this.addListenersToEditableElements(), await ce(), null);
}
/**
* Mounts builder components to the DOM from an HTML string.
*
* Input format detection:
* - If the input starts with `[` or `{`: treated as JSON (array or object).
* - If the input starts with `<`: treated as HTML.
*
* This function should be used when:
* - Restoring the builder from a published HTML snapshot.
* - Importing a static HTML export.
* - Loading the builder from previously published or saved HTML (e.g., from `getSavedPageHtml()`).
*
* Typical use cases include restoring a published state, importing templates, or previewing published content.
*/
async mountComponentsToDOM(e, t, r) {
var s, l;
const o = e.trim();
if (!this.validateMountingHTML(o, { logError: !0 }))
try {
const c = new DOMParser().parseFromString(e, "text/html"), p = c.querySelector("#pagebuilder"), u = document.querySelector("#pagebuilder");
let f = null;
t && (f = ((s = this.pageBuilderStateStore.getPageBuilderConfig) == null ? void 0 : s.pageSettings) || null), !r && !f && p && (f = {
classes: p.className || "",
style: p.getAttribute("style") || ""
}), f || (f = ((l = this.pageBuilderStateStore.getPageBuilderConfig) == null ? void 0 : l.pageSettings) || null), !r && f && u && (u.removeAttribute("class"), u.removeAttribute("style"), u.className = f.classes || "", u.setAttribute(
"style",
this.convertStyleObjectToString(f.style)
)), r && u && (u.removeAttribute("class"), u.removeAttribute("style"), u.className = r.classes || "", u.setAttribute(
"style",
this.convertStyleObjectToString(r.style)
));
const h = c.querySelectorAll("section"), b = [];
h.forEach((m) => {
m.querySelectorAll("[class]").forEach((S) => {
S.setAttribute(
"class",
this.addTailwindPrefixToClasses(S.getAttribute("class") || "", "pbx-")
);
});
const x = m;
x.hasAttribute("data-componentid") || x.setAttribute("data-componentid", Sc());
const v = x.getAttribute("data-componentid"), C = x.getAttribute("data-component-title") || "Untitled Component";
x.setAttribute("data-component-title", C), b.push({
html_code: x.outerHTML,
id: v,
title: C
});
}), this.pageBuilderStateStore.setComponents(b), await this.clearHtmlSelection(), await ce(), await this.addListenersToEditableElements();
} catch (a) {
console.error("Error parsing HTML components:", a), this.deleteAllComponentsFromDOM(), await this.clearHtmlSelection(), await ce(), await this.addListenersToEditableElements();
}
}
updateLocalStorageItemName() {
const e = this.pageBuilderStateStore.getPageBuilderConfig && this.pageBuilderStateStore.getPageBuilderConfig.updateOrCreate && this.pageBuilderStateStore.getPageBuilderConfig.updateOrCreate.formType, t = this.pageBuilderStateStore.getPageBuilderConfig && this.pageBuilderStateStore.getPageBuilderConfig.updateOrCreate && this.pageBuilderStateStore.getPageBuilderConfig.updateOrCreate.formName, r = this.pageBuilderStateStore.getPageBuilderConfig && this.pageBuilderStateStore.getPageBuilderConfig.resourceData;
if (e === "create") {
if (t && t.length > 0) {
this.pageBuilderStateStore.setLocalStorageItemName(
`page-builder-create-resource-${this.sanitizeForLocalStorage(t)}`
);
return;
}
this.pageBuilderStateStore.setLocalStorageItemName("page-builder-create-resource");
return;
}
if (e === "update") {
if (typeof t == "string" && t.length > 0) {
if (r && r != null && !r.title && (!r.id || typeof r.id == "string")) {
this.pageBuilderStateStore.setLocalStorageItemName(
`page-builder-update-resource-${this.sanitizeForLocalStorage(t)}`
);
return;
}
if (r && r != null && r.title && typeof r.title == "string" && r.title.length > 0 && (!r.id || typeof r.id == "string")) {
this.pageBuilderStateStore.setLocalStorageItemName(
`page-builder-update-resource-${this.sanitizeForLocalStorage(t)}-${this.sanitizeForLocalStorage(r.title)}`
);
return;
}
if (r && r != null && !r.title && typeof r.title != "string" && (r.id || typeof r.id == "number")) {
this.pageBuilderStateStore.setLocalStorageItemName(
`page-builder-update-resource-${this.sanitizeForLocalStorage(t)}-${this.sanitizeForLocalStorage(String(r.id))}`
);
return;
}
if (r && r != null && r.title && typeof r.title == "string" && r.title.length > 0 && (r.id || typeof r.id == "number")) {
this.pageBuilderStateStore.setLocalStorageItemName(
`page-builder-update-resource-${this.sanitizeForLocalStorage(t)}-${this.sanitizeForLocalStorage(r.title)}-${this.sanitizeForLocalStorage(String(r.id))}`
);
return;
}
}
if (!t || typeof t == "string" && t.length === 0) {
if (r && r != null && !r.title && (!r.id || typeof r.id == "string")) {
this.pageBuilderStateStore.setLocalStorageItemName("page-builder-update-resource");
return;
}
if (r && r != null && r.title && typeof r.title == "string" && r.title.length > 0 && (!r.id || typeof r.id == "string")) {
this.pageBuilderStateStore.setLocalStorageItemName(
`page-builder-update-resource-${this.sanitizeForLocalStorage(r.title)}`
);
return;
}
if (r && r != null && !r.title && typeof r.title != "string" && (r.id || typeof r.id == "number")) {
this.pageBuilderStateStore.setLocalStorageItemName(
`page-builder-update-resource-${this.sanitizeForLocalStorage(String(r.id))}`
);
return;
}
if (r && r != null && r.title && typeof r.title == "string" && r.title.length > 0 && (r.id || typeof r.id == "number")) {
this.pageBuilderStateStore.setLocalStorageItemName(
`page-builder-update-resource-${this.sanitizeForLocalStorage(r.title)}-${this.sanitizeForLocalStorage(String(r.id))}`
);
return;
}
}
}
}
/**
* Initializes the styles for the currently selected element.
*/
async initializeElementStyles() {
await ce(), this.setBasePrimaryImageFromSelectedElement(), this.handleHyperlink(void 0, null, !1), this.handleOpacity(void 0), this.handleBackgroundOpacity(void 0), this.handleBackgroundColor(void 0), this.handleTextColor(void 0), this.handleBorderStyle(void 0), this.handleBorderWidth(void 0), this.handleBorderColor(void 0), this.handleBorderRadiusGlobal(void 0), this.handleBorderRadiusTopLeft(void 0), this.handleBorderRadiusTopRight(void 0), this.handleBorderRadiusBottomleft(void 0), this.handleBorderRadiusBottomRight(void 0), this.handleFontSizeBase(void 0), this.handleFontSizeDesktop(void 0), this.handleFontSizeTablet(void 0), this.handleFontSizeMobile(void 0), this.handleFontWeight(void 0), this.handleFontFamily(void 0), this.handleFontStyle(void 0), this.handleVerticalPadding(void 0), this.handleHorizontalPadding(void 0), this.handleVerticalMargin(void 0), this.handleHorizontalMargin(void 0), await this.syncCurrentClasses(), await this.syncCurrentStyles();
}
}
let ji = null;
function cb(n) {
ji || (ji = n);
}
function Ce() {
if (!ji)
throw new Error(
"PageBuilder has not been initialized. Please call app.use(pageBuilder) in your main application file."
);
return ji;
}
const pb = (n, e, t) => {
const r = n[e];
return r ? typeof r == "function" ? r() : Promise.resolve(r) : new Promise((o, i) => {
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
i.bind(
null,
new Error(
"Unknown variable dynamic import: " + e + (e.split("/").length !== t ? ". Note that variables only represent file names one level deep." : "")
)
)
);
});
}, Il = M({});
async function Lu(n) {
try {
const e = await pb(/* @__PURE__ */ Object.assign({ "../locales/ar.json": () => import("./ar-B67ZvnES.js"), "../locales/de.json": () => import("./de-2iNkasP-.js"), "../locales/en.json": () => import("./en-BkPMvlrf.js"), "../locales/es.json": () => import("./es-CoKtBPFg.js"), "../locales/fr.json": () => import("./fr-Bb-szPYF.js"), "../locales/hi.json": () => import("./hi-Z-tSAHna.js"), "../locales/ja.json": () => import("./ja-BsFKC04n.js"), "../locales/pt.json": () => import("./pt-CR27KWIb.js"), "../locales/ru.json": () => import("./ru-CVy3Csm4.js"), "../locales/zh-Hans.json": () => import("./zh-Hans-9bdCn2lI.js") }), `../locales/${n}.json`, 3);
Il.value = e.default;
} catch (e) {
console.error(`Could not load translations for language: ${n}`, e), n !== "en" && await Lu("en");
}
}
function Me() {
function n(e) {
return Il.value[e] || e;
}
return {
translate: n,
loadTranslations: Lu,
currentTranslations: Nh(Il)
};
}
const ub = { class: "pbx-flex pbx-flex-col pbx-items-center pbx-justify-center pbx-myPrimaryGap" }, db = { class: "pbx-flex pbx-gap-2 pbx-items-center pbx-justify-center" }, fb = ["disabled"], hb = ["disabled"], bb = {
__name: "ComponentTopMenu",
setup(n) {
const { translate: e } = Me(), t = Ce(), r = M(!1), o = M(""), i = M(1), s = M(""), l = M(""), a = M(""), c = M(null), p = M(null), u = M(null), f = M(null), h = M(null), b = I(() => t.canMoveUp()), m = I(() => t.canMoveDown()), x = function() {
r.value = !0, o.value = "delete", i.value = 2, s.value = e("Remove Component?"), l.value = e("Are you sure you want to remove this Component?"), a.value = e("Close"), c.value = null, p.value = e("Delete"), u.value = function() {
r.value = !1;
}, h.value = async function() {
await t.deleteComponentFromDOM(), r.value = !1;
};
};
return (v, C) => (w(), E(Z, null, [
j(yr, {
showDynamicModalBuilder: r.value,
type: o.value,
gridColumnAmount: i.value,
title: s.value,
description: l.value,
firstButtonText: a.value,
secondButtonText: c.value,
thirdButtonText: p.value,
onFirstModalButtonFunctionDynamicModalBuilder: u.value,
onSecondModalButtonFunctionDynamicModalBuilder: f.value,
onThirdModalButtonFunctionDynamicModalBuilder: h.value
}, {
default: V(() => C[3] || (C[3] = [
d("header", null, null, -1),
d("main", null, null, -1)
])),
_: 1,
__: [3]
}, 8, ["showDynamicModalBuilder", "type", "gridColumnAmount", "title", "description", "firstButtonText", "secondButtonText", "thirdButtonText", "onFirstModalButtonFunctionDynamicModalBuilder", "onSecondModalButtonFunctionDynamicModalBuilder", "onThirdModalButtonFunctionDynamicModalBuilder"]),
d("div", ub, [
d("div", db, [
d("div", {
onClick: C[0] || (C[0] = (S) => x()),
class: "pbx-h-10 pbx-w-10 pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-50 pbx-aspect-square hover:pbx-bg-myPrimaryErrorColor hover:pbx-text-white pbx-text-myPrimaryErrorColor"
}, C[4] || (C[4] = [
d("span", { class: "material-symbols-outlined" }, " delete_forever ", -1)
]))
]),
d("button", {
type: "button",
onClick: C[1] || (C[1] = (S) => y(t).reorderComponent(-1)),
disabled: !b.value,
class: X(["pbx-h-10 pbx-w-10 pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-50 pbx-aspect-square pbx-text-black", [
b.value ? "hover:pbx-bg-myPrimaryLinkColor hover:pbx-text-white focus-visible:pbx-ring-0 pbx-cursor-pointer" : "pbx-cursor-not-allowed pbx-bg-opacity-20 hover:pbx-bg-gray-200"
]])
}, C[5] || (C[5] = [
d("span", { class: "material-symbols-outlined" }, " move_up ", -1)
]), 10, fb),
d("button", {
type: "button",
onClick: C[2] || (C[2] = (S) => y(t).reorderComponent(1)),
disabled: !m.value,
class: X(["pbx-h-10 pbx-w-10 pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-50 pbx-aspect-square pbx-text-black", [
m.value ? "hover:pbx-bg-myPrimaryLinkColor hover:pbx-text-white focus-visible:pbx-ring-0 pbx-cursor-pointer" : "pbx-cursor-not-allowed pbx-bg-opacity-20 hover:pbx-bg-gray-200"
]])
}, C[6] || (C[6] = [
d("span", { class: "material-symbols-outlined" }, " move_down ", -1)
]), 10, hb)
])
], 64));
}
};
function $e(n) {
this.content = n;
}
$e.prototype = {
constructor: $e,
find: function(n) {
for (var e = 0; e < this.content.length; e += 2)
if (this.content[e] === n) return e;
return -1;
},
// :: (string) → ?any
// Retrieve the value stored under `key`, or return undefined when
// no such key exists.
get: function(n) {
var e = this.find(n);
return e == -1 ? void 0 : this.content[e + 1];
},
// :: (string, any, ?string) → OrderedMap
// Create a new map by replacing the value of `key` with a new
// value, or adding a binding to the end of the map. If `newKey` is
// given, the key of the binding will be replaced with that key.
update: function(n, e, t) {
var r = t && t != n ? this.remove(t) : this, o = r.find(n), i = r.content.slice();
return o == -1 ? i.push(t || n, e) : (i[o + 1] = e, t && (i[o] = t)), new $e(i);
},
// :: (string) → OrderedMap
// Return a map with the given key removed, if it existed.
remove: function(n) {
var e = this.find(n);
if (e == -1) return this;
var t = this.content.slice();
return t.splice(e, 2), new $e(t);
},
// :: (string, any) → OrderedMap
// Add a new key to the start of the map.
addToStart: function(n, e) {
return new $e([n, e].concat(this.remove(n).content));
},
// :: (string, any) → OrderedMap
// Add a new key to the end of the map.
addToEnd: function(n, e) {
var t = this.remove(n).content.slice();
return t.push(n, e), new $e(t);
},
// :: (string, string, any) → OrderedMap
// Add a key after the given key. If `place` is not found, the new
// key is added to the end.
addBefore: function(n, e, t) {
var r = this.remove(e), o = r.content.slice(), i = r.find(n);
return o.splice(i == -1 ? o.length : i, 0, e, t), new $e(o);
},
// :: ((key: string, value: any))
// Call the given function for each key/value pair in the map, in
// order.
forEach: function(n) {
for (var e = 0; e < this.content.length; e += 2)
n(this.content[e], this.content[e + 1]);
},
// :: (union<Object, OrderedMap>) → OrderedMap
// Create a new map by prepending the keys in this map that don't
// appear in `map` before the keys in `map`.
prepend: function(n) {
return n = $e.from(n), n.size ? new $e(n.content.concat(this.subtract(n).content)) : this;
},
// :: (union<Object, OrderedMap>) → OrderedMap
// Create a new map by appending the keys in this map that don't
// appear in `map` after the keys in `map`.
append: function(n) {
return n = $e.from(n), n.size ? new $e(this.subtract(n).content.concat(n.content)) : this;
},
// :: (union<Object, OrderedMap>) → OrderedMap
// Create a map containing all the keys in this map that don't
// appear in `map`.
subtract: function(n) {
var e = this;
n = $e.from(n);
for (var t = 0; t < n.content.length; t += 2)
e = e.remove(n.content[t]);
return e;
},
// :: () → Object
// Turn ordered map into a plain object.
toObject: function() {
var n = {};
return this.forEach(function(e, t) {
n[e] = t;
}), n;
},
// :: number
// The amount of keys in this map.
get size() {
return this.content.length >> 1;
}
};
$e.from = function(n) {
if (n instanceof $e) return n;
var e = [];
if (n) for (var t in n) e.push(t, n[t]);
return new $e(e);
};
function Nu(n, e, t) {
for (let r = 0; ; r++) {
if (r == n.childCount || r == e.childCount)
return n.childCount == e.childCount ? null : t;
let o = n.child(r), i = e.child(r);
if (o == i) {
t += o.nodeSize;
continue;
}
if (!o.sameMarkup(i))
return t;
if (o.isText && o.text != i.text) {
for (let s = 0; o.text[s] == i.text[s]; s++)
t++;
return t;
}
if (o.content.size || i.content.size) {
let s = Nu(o.content, i.content, t + 1);
if (s != null)
return s;
}
t += o.nodeSize;
}
}
function Du(n, e, t, r) {
for (let o = n.childCount, i = e.childCount; ; ) {
if (o == 0 || i == 0)
return o == i ? null : { a: t, b: r };
let s = n.child(--o), l = e.child(--i), a = s.nodeSize;
if (s == l) {
t -= a, r -= a;
continue;
}
if (!s.sameMarkup(l))
return { a: t, b: r };
if (s.isText && s.text != l.text) {
let c = 0, p = Math.min(s.text.length, l.text.length);
for (; c < p && s.text[s.text.length - c - 1] == l.text[l.text.length - c - 1]; )
c++, t--, r--;
return { a: t, b: r };
}
if (s.content.size || l.content.size) {
let c = Du(s.content, l.content, t - 1, r - 1);
if (c)
return c;
}
t -= a, r -= a;
}
}
class D {
/**
@internal
*/
constructor(e, t) {
if (this.content = e, this.size = t || 0, t == null)
for (let r = 0; r < e.length; r++)
this.size += e[r].nodeSize;
}
/**
Invoke a callback for all descendant nodes between the given two
positions (relative to start of this fragment). Doesn't descend
into a node when the callback returns `false`.
*/
nodesBetween(e, t, r, o = 0, i) {
for (let s = 0, l = 0; l < t; s++) {
let a = this.content[s], c = l + a.nodeSize;
if (c > e && r(a, o + l, i || null, s) !== !1 && a.content.size) {
let p = l + 1;
a.nodesBetween(Math.max(0, e - p), Math.min(a.content.size, t - p), r, o + p);
}
l = c;
}
}
/**
Call the given callback for every descendant node. `pos` will be
relative to the start of the fragment. The callback may return
`false` to prevent traversal of a given node's children.
*/
descendants(e) {
this.nodesBetween(0, this.size, e);
}
/**
Extract the text between `from` and `to`. See the same method on
[`Node`](https://prosemirror.net/docs/ref/#model.Node.textBetween).
*/
textBetween(e, t, r, o) {
let i = "", s = !0;
return this.nodesBetween(e, t, (l, a) => {
let c = l.isText ? l.text.slice(Math.max(e, a) - a, t - a) : l.isLeaf ? o ? typeof o == "function" ? o(l) : o : l.type.spec.leafText ? l.type.spec.leafText(l) : "" : "";
l.isBlock && (l.isLeaf && c || l.isTextblock) && r && (s ? s = !1 : i += r), i += c;
}, 0), i;
}
/**
Create a new fragment containing the combined content of this
fragment and the other.
*/
append(e) {
if (!e.size)
return this;
if (!this.size)
return e;
let t = this.lastChild, r = e.firstChild, o = this.content.slice(), i = 0;
for (t.isText && t.sameMarkup(r) && (o[o.length - 1] = t.withText(t.text + r.text), i = 1); i < e.content.length; i++)
o.push(e.content[i]);
return new D(o, this.size + e.size);
}
/**
Cut out the sub-fragment between the two given positions.
*/
cut(e, t = this.size) {
if (e == 0 && t == this.size)
return this;
let r = [], o = 0;
if (t > e)
for (let i = 0, s = 0; s < t; i++) {
let l = this.content[i], a = s + l.nodeSize;
a > e && ((s < e || a > t) && (l.isText ? l = l.cut(Math.max(0, e - s), Math.min(l.text.length, t - s)) : l = l.cut(Math.max(0, e - s - 1), Math.min(l.content.size, t - s - 1))), r.push(l), o += l.nodeSize), s = a;
}
return new D(r, o);
}
/**
@internal
*/
cutByIndex(e, t) {
return e == t ? D.empty : e == 0 && t == this.content.length ? this : new D(this.content.slice(e, t));
}
/**
Create a new fragment in which the node at the given index is
replaced by the given node.
*/
replaceChild(e, t) {
let r = this.content[e];
if (r == t)
return this;
let o = this.content.slice(), i = this.size + t.nodeSize - r.nodeSize;
return o[e] = t, new D(o, i);
}
/**
Create a new fragment by prepending the given node to this
fragment.
*/
addToStart(e) {
return new D([e].concat(this.content), this.size + e.nodeSize);
}
/**
Create a new fragment by appending the given node to this
fragment.
*/
addToEnd(e) {
return new D(this.content.concat(e), this.size + e.nodeSize);
}
/**
Compare this fragment to another one.
*/
eq(e) {
if (this.content.length != e.content.length)
return !1;
for (let t = 0; t < this.content.length; t++)
if (!this.content[t].eq(e.content[t]))
return !1;
return !0;
}
/**
The first child of the fragment, or `null` if it is empty.
*/
get firstChild() {
return this.content.length ? this.content[0] : null;
}
/**
The last child of the fragment, or `null` if it is empty.
*/
get lastChild() {
return this.content.length ? this.content[this.content.length - 1] : null;
}
/**
The number of child nodes in this fragment.
*/
get childCount() {
return this.content.length;
}
/**
Get the child node at the given index. Raise an error when the
index is out of range.
*/
child(e) {
let t = this.content[e];
if (!t)
throw new RangeError("Index " + e + " out of range for " + this);
return t;
}
/**
Get the child node at the given index, if it exists.
*/
maybeChild(e) {
return this.content[e] || null;
}
/**
Call `f` for every child node, passing the node, its offset
into this parent node, and its index.
*/
forEach(e) {
for (let t = 0, r = 0; t < this.content.length; t++) {
let o = this.content[t];
e(o, r, t), r += o.nodeSize;
}
}
/**
Find the first position at which this fragment and another
fragment differ, or `null` if they are the same.
*/
findDiffStart(e, t = 0) {
return Nu(this, e, t);
}
/**
Find the first position, searching from the end, at which this
fragment and the given fragment differ, or `null` if they are
the same. Since this position will not be the same in both
nodes, an object with two separate positions is returned.
*/
findDiffEnd(e, t = this.size, r = e.size) {
return Du(this, e, t, r);
}
/**
Find the index and inner offset corresponding to a given relative
position in this fragment. The result object will be reused
(overwritten) the next time the function is called. @internal
*/
findIndex(e, t = -1) {
if (e == 0)
return hi(0, e);
if (e == this.size)
return hi(this.content.length, e);
if (e > this.size || e < 0)
throw new RangeError(`Position ${e} outside of fragment (${this})`);
for (let r = 0, o = 0; ; r++) {
let i = this.child(r), s = o + i.nodeSize;
if (s >= e)
return s == e || t > 0 ? hi(r + 1, s) : hi(r, o);
o = s;
}
}
/**
Return a debugging string that describes this fragment.
*/
toString() {
return "<" + this.toStringInner() + ">";
}
/**
@internal
*/
toStringInner() {
return this.content.join(", ");
}
/**
Create a JSON-serializeable representation of this fragment.
*/
toJSON() {
return this.content.length ? this.content.map((e) => e.toJSON()) : null;
}
/**
Deserialize a fragment from its JSON representation.
*/
static fromJSON(e, t) {
if (!t)
return D.empty;
if (!Array.isArray(t))
throw new RangeError("Invalid input for Fragment.fromJSON");
return new D(t.map(e.nodeFromJSON));
}
/**
Build a fragment from an array of nodes. Ensures that adjacent
text nodes with the same marks are joined together.
*/
static fromArray(e) {
if (!e.length)
return D.empty;
let t, r = 0;
for (let o = 0; o < e.length; o++) {
let i = e[o];
r += i.nodeSize, o && i.isText && e[o - 1].sameMarkup(i) ? (t || (t = e.slice(0, o)), t[t.length - 1] = i.withText(t[t.length - 1].text + i.text)) : t && t.push(i);
}
return new D(t || e, r);
}
/**
Create a fragment from something that can be interpreted as a
set of nodes. For `null`, it returns the empty fragment. For a
fragment, the fragment itself. For a node or array of nodes, a
fragment containing those nodes.
*/
static from(e) {
if (!e)
return D.empty;
if (e instanceof D)
return e;
if (Array.isArray(e))
return this.fromArray(e);
if (e.attrs)
return new D([e], e.nodeSize);
throw new RangeError("Can not convert " + e + " to a Fragment" + (e.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
}
}
D.empty = new D([], 0);
const Zs = { index: 0, offset: 0 };
function hi(n, e) {
return Zs.index = n, Zs.offset = e, Zs;
}
function zi(n, e) {
if (n === e)
return !0;
if (!(n && typeof n == "object") || !(e && typeof e == "object"))
return !1;
let t = Array.isArray(n);
if (Array.isArray(e) != t)
return !1;
if (t) {
if (n.length != e.length)
return !1;
for (let r = 0; r < n.length; r++)
if (!zi(n[r], e[r]))
return !1;
} else {
for (let r in n)
if (!(r in e) || !zi(n[r], e[r]))
return !1;
for (let r in e)
if (!(r in n))
return !1;
}
return !0;
}
let me = class $l {
/**
@internal
*/
constructor(e, t) {
this.type = e, this.attrs = t;
}
/**
Given a set of marks, create a new set which contains this one as
well, in the right position. If this mark is already in the set,
the set itself is returned. If any marks that are set to be
[exclusive](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) with this mark are present,
those are replaced by this one.
*/
addToSet(e) {
let t, r = !1;
for (let o = 0; o < e.length; o++) {
let i = e[o];
if (this.eq(i))
return e;
if (this.type.excludes(i.type))
t || (t = e.slice(0, o));
else {
if (i.type.excludes(this.type))
return e;
!r && i.type.rank > this.type.rank && (t || (t = e.slice(0, o)), t.push(this), r = !0), t && t.push(i);
}
}
return t || (t = e.slice()), r || t.push(this), t;
}
/**
Remove this mark from the given set, returning a new set. If this
mark is not in the set, the set itself is returned.
*/
removeFromSet(e) {
for (let t = 0; t < e.length; t++)
if (this.eq(e[t]))
return e.slice(0, t).concat(e.slice(t + 1));
return e;
}
/**
Test whether this mark is in the given set of marks.
*/
isInSet(e) {
for (let t = 0; t < e.length; t++)
if (this.eq(e[t]))
return !0;
return !1;
}
/**
Test whether this mark has the same type and attributes as
another mark.
*/
eq(e) {
return this == e || this.type == e.type && zi(this.attrs, e.attrs);
}
/**
Convert this mark to a JSON-serializeable representation.
*/
toJSON() {
let e = { type: this.type.name };
for (let t in this.attrs) {
e.attrs = this.attrs;
break;
}
return e;
}
/**
Deserialize a mark from JSON.
*/
static fromJSON(e, t) {
if (!t)
throw new RangeError("Invalid input for Mark.fromJSON");
let r = e.marks[t.type];
if (!r)
throw new RangeError(`There is no mark type ${t.type} in this schema`);
let o = r.create(t.attrs);
return r.checkAttrs(o.attrs), o;
}
/**
Test whether two sets of marks are identical.
*/
static sameSet(e, t) {
if (e == t)
return !0;
if (e.length != t.length)
return !1;
for (let r = 0; r < e.length; r++)
if (!e[r].eq(t[r]))
return !1;
return !0;
}
/**
Create a properly sorted mark set from null, a single mark, or an
unsorted array of marks.
*/
static setFrom(e) {
if (!e || Array.isArray(e) && e.length == 0)
return $l.none;
if (e instanceof $l)
return [e];
let t = e.slice();
return t.sort((r, o) => r.type.rank - o.type.rank), t;
}
};
me.none = [];
class Vi extends Error {
}
class z {
/**
Create a slice. When specifying a non-zero open depth, you must
make sure that there are nodes of at least that depth at the
appropriate side of the fragment—i.e. if the fragment is an
empty paragraph node, `openStart` and `openEnd` can't be greater
than 1.
It is not necessary for the content of open nodes to conform to
the schema's content constraints, though it should be a valid
start/end/middle for such a node, depending on which sides are
open.
*/
constructor(e, t, r) {
this.content = e, this.openStart = t, this.openEnd = r;
}
/**
The size this slice would add when inserted into a document.
*/
get size() {
return this.content.size - this.openStart - this.openEnd;
}
/**
@internal
*/
insertAt(e, t) {
let r = $u(this.content, e + this.openStart, t);
return r && new z(r, this.openStart, this.openEnd);
}
/**
@internal
*/
removeBetween(e, t) {
return new z(Iu(this.content, e + this.openStart, t + this.openStart), this.openStart, this.openEnd);
}
/**
Tests whether this slice is equal to another slice.
*/
eq(e) {
return this.content.eq(e.content) && this.openStart == e.openStart && this.openEnd == e.openEnd;
}
/**
@internal
*/
toString() {
return this.content + "(" + this.openStart + "," + this.openEnd + ")";
}
/**
Convert a slice to a JSON-serializable representation.
*/
toJSON() {
if (!this.content.size)
return null;
let e = { content: this.content.toJSON() };
return this.openStart > 0 && (e.openStart = this.openStart), this.openEnd > 0 && (e.openEnd = this.openEnd), e;
}
/**
Deserialize a slice from its JSON representation.
*/
static fromJSON(e, t) {
if (!t)
return z.empty;
let r = t.openStart || 0, o = t.openEnd || 0;
if (typeof r != "number" || typeof o != "number")
throw new RangeError("Invalid input for Slice.fromJSON");
return new z(D.fromJSON(e, t.content), r, o);
}
/**
Create a slice from a fragment by taking the maximum possible
open value on both side of the fragment.
*/
static maxOpen(e, t = !0) {
let r = 0, o = 0;
for (let i = e.firstChild; i && !i.isLeaf && (t || !i.type.spec.isolating); i = i.firstChild)
r++;
for (let i = e.lastChild; i && !i.isLeaf && (t || !i.type.spec.isolating); i = i.lastChild)
o++;
return new z(e, r, o);
}
}
z.empty = new z(D.empty, 0, 0);
function Iu(n, e, t) {
let { index: r, offset: o } = n.findIndex(e), i = n.maybeChild(r), { index: s, offset: l } = n.findIndex(t);
if (o == e || i.isText) {
if (l != t && !n.child(s).isText)
throw new RangeError("Removing non-flat range");
return n.cut(0, e).append(n.cut(t));
}
if (r != s)
throw new RangeError("Removing non-flat range");
return n.replaceChild(r, i.copy(Iu(i.content, e - o - 1, t - o - 1)));
}
function $u(n, e, t, r) {
let { index: o, offset: i } = n.findIndex(e), s = n.maybeChild(o);
if (i == e || s.isText)
return n.cut(0, e).append(t).append(n.cut(e));
let l = $u(s.content, e - i - 1, t);
return l && n.replaceChild(o, s.copy(l));
}
function mb(n, e, t) {
if (t.openStart > n.depth)
throw new Vi("Inserted content deeper than insertion position");
if (n.depth - t.openStart != e.depth - t.openEnd)
throw new Vi("Inconsistent open depths");
return Ru(n, e, t, 0);
}
function Ru(n, e, t, r) {
let o = n.index(r), i = n.node(r);
if (o == e.index(r) && r < n.depth - t.openStart) {
let s = Ru(n, e, t, r + 1);
return i.copy(i.content.replaceChild(o, s));
} else if (t.content.size)
if (!t.openStart && !t.openEnd && n.depth == r && e.depth == r) {
let s = n.parent, l = s.content;
return fr(s, l.cut(0, n.parentOffset).append(t.content).append(l.cut(e.parentOffset)));
} else {
let { start: s, end: l } = xb(t, n);
return fr(i, Hu(n, s, l, e, r));
}
else return fr(i, Wi(n, e, r));
}
function Fu(n, e) {
if (!e.type.compatibleContent(n.type))
throw new Vi("Cannot join " + e.type.name + " onto " + n.type.name);
}
function Rl(n, e, t) {
let r = n.node(t);
return Fu(r, e.node(t)), r;
}
function dr(n, e) {
let t = e.length - 1;
t >= 0 && n.isText && n.sameMarkup(e[t]) ? e[t] = n.withText(e[t].text + n.text) : e.push(n);
}
function vo(n, e, t, r) {
let o = (e || n).node(t), i = 0, s = e ? e.index(t) : o.childCount;
n && (i = n.index(t), n.depth > t ? i++ : n.textOffset && (dr(n.nodeAfter, r), i++));
for (let l = i; l < s; l++)
dr(o.child(l), r);
e && e.depth == t && e.textOffset && dr(e.nodeBefore, r);
}
function fr(n, e) {
return n.type.checkContent(e), n.copy(e);
}
function Hu(n, e, t, r, o) {
let i = n.depth > o && Rl(n, e, o + 1), s = r.depth > o && Rl(t, r, o + 1), l = [];
return vo(null, n, o, l), i && s && e.index(o) == t.index(o) ? (Fu(i, s), dr(fr(i, Hu(n, e, t, r, o + 1)), l)) : (i && dr(fr(i, Wi(n, e, o + 1)), l), vo(e, t, o, l), s && dr(fr(s, Wi(t, r, o + 1)), l)), vo(r, null, o, l), new D(l);
}
function Wi(n, e, t) {
let r = [];
if (vo(null, n, t, r), n.depth > t) {
let o = Rl(n, e, t + 1);
dr(fr(o, Wi(n, e, t + 1)), r);
}
return vo(e, null, t, r), new D(r);
}
function xb(n, e) {
let t = e.depth - n.openStart, o = e.node(t).copy(n.content);
for (let i = t - 1; i >= 0; i--)
o = e.node(i).copy(D.from(o));
return {
start: o.resolveNoCache(n.openStart + t),
end: o.resolveNoCache(o.content.size - n.openEnd - t)
};
}
class Do {
/**
@internal
*/
constructor(e, t, r) {
this.pos = e, this.path = t, this.parentOffset = r, this.depth = t.length / 3 - 1;
}
/**
@internal
*/
resolveDepth(e) {
return e == null ? this.depth : e < 0 ? this.depth + e : e;
}
/**
The parent node that the position points into. Note that even if
a position points into a text node, that node is not considered
the parent—text nodes are ‘flat’ in this model, and have no content.
*/
get parent() {
return this.node(this.depth);
}
/**
The root node in which the position was resolved.
*/
get doc() {
return this.node(0);
}
/**
The ancestor node at the given level. `p.node(p.depth)` is the
same as `p.parent`.
*/
node(e) {
return this.path[this.resolveDepth(e) * 3];
}
/**
The index into the ancestor at the given level. If this points
at the 3rd node in the 2nd paragraph on the top level, for
example, `p.index(0)` is 1 and `p.index(1)` is 2.
*/
index(e) {
return this.path[this.resolveDepth(e) * 3 + 1];
}
/**
The index pointing after this position into the ancestor at the
given level.
*/
indexAfter(e) {
return e = this.resolveDepth(e), this.index(e) + (e == this.depth && !this.textOffset ? 0 : 1);
}
/**
The (absolute) position at the start of the node at the given
level.
*/
start(e) {
return e = this.resolveDepth(e), e == 0 ? 0 : this.path[e * 3 - 1] + 1;
}
/**
The (absolute) position at the end of the node at the given
level.
*/
end(e) {
return e = this.resolveDepth(e), this.start(e) + this.node(e).content.size;
}
/**
The (absolute) position directly before the wrapping node at the
given level, or, when `depth` is `this.depth + 1`, the original
position.
*/
before(e) {
if (e = this.resolveDepth(e), !e)
throw new RangeError("There is no position before the top-level node");
return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1];
}
/**
The (absolute) position directly after the wrapping node at the
given level, or the original position when `depth` is `this.depth + 1`.
*/
after(e) {
if (e = this.resolveDepth(e), !e)
throw new RangeError("There is no position after the top-level node");
return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1] + this.path[e * 3].nodeSize;
}
/**
When this position points into a text node, this returns the
distance between the position and the start of the text node.
Will be zero for positions that point between nodes.
*/
get textOffset() {
return this.pos - this.path[this.path.length - 1];
}
/**
Get the node directly after the position, if any. If the position
points into a text node, only the part of that node after the
position is returned.
*/
get nodeAfter() {
let e = this.parent, t = this.index(this.depth);
if (t == e.childCount)
return null;
let r = this.pos - this.path[this.path.length - 1], o = e.child(t);
return r ? e.child(t).cut(r) : o;
}
/**
Get the node directly before the position, if any. If the
position points into a text node, only the part of that node
before the position is returned.
*/
get nodeBefore() {
let e = this.index(this.depth), t = this.pos - this.path[this.path.length - 1];
return t ? this.parent.child(e).cut(0, t) : e == 0 ? null : this.parent.child(e - 1);
}
/**
Get the position at the given index in the parent node at the
given depth (which defaults to `this.depth`).
*/
posAtIndex(e, t) {
t = this.resolveDepth(t);
let r = this.path[t * 3], o = t == 0 ? 0 : this.path[t * 3 - 1] + 1;
for (let i = 0; i < e; i++)
o += r.child(i).nodeSize;
return o;
}
/**
Get the marks at this position, factoring in the surrounding
marks' [`inclusive`](https://prosemirror.net/docs/ref/#model.MarkSpec.inclusive) property. If the
position is at the start of a non-empty node, the marks of the
node after it (if any) are returned.
*/
marks() {
let e = this.parent, t = this.index();
if (e.content.size == 0)
return me.none;
if (this.textOffset)
return e.child(t).marks;
let r = e.maybeChild(t - 1), o = e.maybeChild(t);
if (!r) {
let l = r;
r = o, o = l;
}
let i = r.marks;
for (var s = 0; s < i.length; s++)
i[s].type.spec.inclusive === !1 && (!o || !i[s].isInSet(o.marks)) && (i = i[s--].removeFromSet(i));
return i;
}
/**
Get the marks after the current position, if any, except those
that are non-inclusive and not present at position `$end`. This
is mostly useful for getting the set of marks to preserve after a
deletion. Will return `null` if this position is at the end of
its parent node or its parent node isn't a textblock (in which
case no marks should be preserved).
*/
marksAcross(e) {
let t = this.parent.maybeChild(this.index());
if (!t || !t.isInline)
return null;
let r = t.marks, o = e.parent.maybeChild(e.index());
for (var i = 0; i < r.length; i++)
r[i].type.spec.inclusive === !1 && (!o || !r[i].isInSet(o.marks)) && (r = r[i--].removeFromSet(r));
return r;
}
/**
The depth up to which this position and the given (non-resolved)
position share the same parent nodes.
*/
sharedDepth(e) {
for (let t = this.depth; t > 0; t--)
if (this.start(t) <= e && this.end(t) >= e)
return t;
return 0;
}
/**
Returns a range based on the place where this position and the
given position diverge around block content. If both point into
the same textblock, for example, a range around that textblock
will be returned. If they point into different blocks, the range
around those blocks in their shared ancestor is returned. You can
pass in an optional predicate that will be called with a parent
node to see if a range into that parent is acceptable.
*/
blockRange(e = this, t) {
if (e.pos < this.pos)
return e.blockRange(this);
for (let r = this.depth - (this.parent.inlineContent || this.pos == e.pos ? 1 : 0); r >= 0; r--)
if (e.pos <= this.end(r) && (!t || t(this.node(r))))
return new Ui(this, e, r);
return null;
}
/**
Query whether the given position shares the same parent node.
*/
sameParent(e) {
return this.pos - this.parentOffset == e.pos - e.parentOffset;
}
/**
Return the greater of this and the given position.
*/
max(e) {
return e.pos > this.pos ? e : this;
}
/**
Return the smaller of this and the given position.
*/
min(e) {
return e.pos < this.pos ? e : this;
}
/**
@internal
*/
toString() {
let e = "";
for (let t = 1; t <= this.depth; t++)
e += (e ? "/" : "") + this.node(t).type.name + "_" + this.index(t - 1);
return e + ":" + this.parentOffset;
}
/**
@internal
*/
static resolve(e, t) {
if (!(t >= 0 && t <= e.content.size))
throw new RangeError("Position " + t + " out of range");
let r = [], o = 0, i = t;
for (let s = e; ; ) {
let { index: l, offset: a } = s.content.findIndex(i), c = i - a;
if (r.push(s, l, o + a), !c || (s = s.child(l), s.isText))
break;
i = c - 1, o += a + 1;
}
return new Do(t, r, i);
}
/**
@internal
*/
static resolveCached(e, t) {
let r = kc.get(e);
if (r)
for (let i = 0; i < r.elts.length; i++) {
let s = r.elts[i];
if (s.pos == t)
return s;
}
else
kc.set(e, r = new gb());
let o = r.elts[r.i] = Do.resolve(e, t);
return r.i = (r.i + 1) % yb, o;
}
}
class gb {
constructor() {
this.elts = [], this.i = 0;
}
}
const yb = 12, kc = /* @__PURE__ */ new WeakMap();
class Ui {
/**
Construct a node range. `$from` and `$to` should point into the
same node until at least the given `depth`, since a node range
denotes an adjacent set of nodes in a single parent node.
*/
constructor(e, t, r) {
this.$from = e, this.$to = t, this.depth = r;
}
/**
The position at the start of the range.
*/
get start() {
return this.$from.before(this.depth + 1);
}
/**
The position at the end of the range.
*/
get end() {
return this.$to.after(this.depth + 1);
}
/**
The parent node that the range points into.
*/
get parent() {
return this.$from.node(this.depth);
}
/**
The start index of the range in the parent node.
*/
get startIndex() {
return this.$from.index(this.depth);
}
/**
The end index of the range in the parent node.
*/
get endIndex() {
return this.$to.indexAfter(this.depth);
}
}
const vb = /* @__PURE__ */ Object.create(null);
let $n = class Fl {
/**
@internal
*/
constructor(e, t, r, o = me.none) {
this.type = e, this.attrs = t, this.marks = o, this.content = r || D.empty;
}
/**
The array of this node's child nodes.
*/
get children() {
return this.content.content;
}
/**
The size of this node, as defined by the integer-based [indexing
scheme](https://prosemirror.net/docs/guide/#doc.indexing). For text nodes, this is the
amount of characters. For other leaf nodes, it is one. For
non-leaf nodes, it is the size of the content plus two (the
start and end token).
*/
get nodeSize() {
return this.isLeaf ? 1 : 2 + this.content.size;
}
/**
The number of children that the node has.
*/
get childCount() {
return this.content.childCount;
}
/**
Get the child node at the given index. Raises an error when the
index is out of range.
*/
child(e) {
return this.content.child(e);
}
/**
Get the child node at the given index, if it exists.
*/
maybeChild(e) {
return this.content.maybeChild(e);
}
/**
Call `f` for every child node, passing the node, its offset
into this parent node, and its index.
*/
forEach(e) {
this.content.forEach(e);
}
/**
Invoke a callback for all descendant nodes recursively between
the given two positions that are relative to start of this
node's content. The callback is invoked with the node, its
position relative to the original node (method receiver),
its parent node, and its child index. When the callback returns
false for a given node, that node's children will not be
recursed over. The last parameter can be used to specify a
starting position to count from.
*/
nodesBetween(e, t, r, o = 0) {
this.content.nodesBetween(e, t, r, o, this);
}
/**
Call the given callback for every descendant node. Doesn't
descend into a node when the callback returns `false`.
*/
descendants(e) {
this.nodesBetween(0, this.content.size, e);
}
/**
Concatenates all the text nodes found in this fragment and its
children.
*/
get textContent() {
return this.isLeaf && this.type.spec.leafText ? this.type.spec.leafText(this) : this.textBetween(0, this.content.size, "");
}
/**
Get all text between positions `from` and `to`. When
`blockSeparator` is given, it will be inserted to separate text
from different block nodes. If `leafText` is given, it'll be
inserted for every non-text leaf node encountered, otherwise
[`leafText`](https://prosemirror.net/docs/ref/#model.NodeSpec^leafText) will be used.
*/
textBetween(e, t, r, o) {
return this.content.textBetween(e, t, r, o);
}
/**
Returns this node's first child, or `null` if there are no
children.
*/
get firstChild() {
return this.content.firstChild;
}
/**
Returns this node's last child, or `null` if there are no
children.
*/
get lastChild() {
return this.content.lastChild;
}
/**
Test whether two nodes represent the same piece of document.
*/
eq(e) {
return this == e || this.sameMarkup(e) && this.content.eq(e.content);
}
/**
Compare the markup (type, attributes, and marks) of this node to
those of another. Returns `true` if both have the same markup.
*/
sameMarkup(e) {
return this.hasMarkup(e.type, e.attrs, e.marks);
}
/**
Check whether this node's markup correspond to the given type,
attributes, and marks.
*/
hasMarkup(e, t, r) {
return this.type == e && zi(this.attrs, t || e.defaultAttrs || vb) && me.sameSet(this.marks, r || me.none);
}
/**
Create a new node with the same markup as this node, containing
the given content (or empty, if no content is given).
*/
copy(e = null) {
return e == this.content ? this : new Fl(this.type, this.attrs, e, this.marks);
}
/**
Create a copy of this node, with the given set of marks instead
of the node's own marks.
*/
mark(e) {
return e == this.marks ? this : new Fl(this.type, this.attrs, this.content, e);
}
/**
Create a copy of this node with only the content between the
given positions. If `to` is not given, it defaults to the end of
the node.
*/
cut(e, t = this.content.size) {
return e == 0 && t == this.content.size ? this : this.copy(this.content.cut(e, t));
}
/**
Cut out the part of the document between the given positions, and
return it as a `Slice` object.
*/
slice(e, t = this.content.size, r = !1) {
if (e == t)
return z.empty;
let o = this.resolve(e), i = this.resolve(t), s = r ? 0 : o.sharedDepth(t), l = o.start(s), c = o.node(s).content.cut(o.pos - l, i.pos - l);
return new z(c, o.depth - s, i.depth - s);
}
/**
Replace the part of the document between the given positions with
the given slice. The slice must 'fit', meaning its open sides
must be able to connect to the surrounding content, and its
content nodes must be valid children for the node they are placed
into. If any of this is violated, an error of type
[`ReplaceError`](https://prosemirror.net/docs/ref/#model.ReplaceError) is thrown.
*/
replace(e, t, r) {
return mb(this.resolve(e), this.resolve(t), r);
}
/**
Find the node directly after the given position.
*/
nodeAt(e) {
for (let t = this; ; ) {
let { index: r, offset: o } = t.content.findIndex(e);
if (t = t.maybeChild(r), !t)
return null;
if (o == e || t.isText)
return t;
e -= o + 1;
}
}
/**
Find the (direct) child node after the given offset, if any,
and return it along with its index and offset relative to this
node.
*/
childAfter(e) {
let { index: t, offset: r } = this.content.findIndex(e);
return { node: this.content.maybeChild(t), index: t, offset: r };
}
/**
Find the (direct) child node before the given offset, if any,
and return it along with its index and offset relative to this
node.
*/
childBefore(e) {
if (e == 0)
return { node: null, index: 0, offset: 0 };
let { index: t, offset: r } = this.content.findIndex(e);
if (r < e)
return { node: this.content.child(t), index: t, offset: r };
let o = this.content.child(t - 1);
return { node: o, index: t - 1, offset: r - o.nodeSize };
}
/**
Resolve the given position in the document, returning an
[object](https://prosemirror.net/docs/ref/#model.ResolvedPos) with information about its context.
*/
resolve(e) {
return Do.resolveCached(this, e);
}
/**
@internal
*/
resolveNoCache(e) {
return Do.resolve(this, e);
}
/**
Test whether a given mark or mark type occurs in this document
between the two given positions.
*/
rangeHasMark(e, t, r) {
let o = !1;
return t > e && this.nodesBetween(e, t, (i) => (r.isInSet(i.marks) && (o = !0), !o)), o;
}
/**
True when this is a block (non-inline node)
*/
get isBlock() {
return this.type.isBlock;
}
/**
True when this is a textblock node, a block node with inline
content.
*/
get isTextblock() {
return this.type.isTextblock;
}
/**
True when this node allows inline content.
*/
get inlineContent() {
return this.type.inlineContent;
}
/**
True when this is an inline node (a text node or a node that can
appear among text).
*/
get isInline() {
return this.type.isInline;
}
/**
True when this is a text node.
*/
get isText() {
return this.type.isText;
}
/**
True when this is a leaf node.
*/
get isLeaf() {
return this.type.isLeaf;
}
/**
True when this is an atom, i.e. when it does not have directly
editable content. This is usually the same as `isLeaf`, but can
be configured with the [`atom` property](https://prosemirror.net/docs/ref/#model.NodeSpec.atom)
on a node's spec (typically used when the node is displayed as
an uneditable [node view](https://prosemirror.net/docs/ref/#view.NodeView)).
*/
get isAtom() {
return this.type.isAtom;
}
/**
Return a string representation of this node for debugging
purposes.
*/
toString() {
if (this.type.spec.toDebugString)
return this.type.spec.toDebugString(this);
let e = this.type.name;
return this.content.size && (e += "(" + this.content.toStringInner() + ")"), ju(this.marks, e);
}
/**
Get the content match in this node at the given index.
*/
contentMatchAt(e) {
let t = this.type.contentMatch.matchFragment(this.content, 0, e);
if (!t)
throw new Error("Called contentMatchAt on a node with invalid content");
return t;
}
/**
Test whether replacing the range between `from` and `to` (by
child index) with the given replacement fragment (which defaults
to the empty fragment) would leave the node's content valid. You
can optionally pass `start` and `end` indices into the
replacement fragment.
*/
canReplace(e, t, r = D.empty, o = 0, i = r.childCount) {
let s = this.contentMatchAt(e).matchFragment(r, o, i), l = s && s.matchFragment(this.content, t);
if (!l || !l.validEnd)
return !1;
for (let a = o; a < i; a++)
if (!this.type.allowsMarks(r.child(a).marks))
return !1;
return !0;
}
/**
Test whether replacing the range `from` to `to` (by index) with
a node of the given type would leave the node's content valid.
*/
canReplaceWith(e, t, r, o) {
if (o && !this.type.allowsMarks(o))
return !1;
let i = this.contentMatchAt(e).matchType(r), s = i && i.matchFragment(this.content, t);
return s ? s.validEnd : !1;
}
/**
Test whether the given node's content could be appended to this
node. If that node is empty, this will only return true if there
is at least one node type that can appear in both nodes (to avoid
merging completely incompatible nodes).
*/
canAppend(e) {
return e.content.size ? this.canReplace(this.childCount, this.childCount, e.content) : this.type.compatibleContent(e.type);
}
/**
Check whether this node and its descendants conform to the
schema, and raise an exception when they do not.
*/
check() {
this.type.checkContent(this.content), this.type.checkAttrs(this.attrs);
let e = me.none;
for (let t = 0; t < this.marks.length; t++) {
let r = this.marks[t];
r.type.checkAttrs(r.attrs), e = r.addToSet(e);
}
if (!me.sameSet(e, this.marks))
throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t) => t.type.name)}`);
this.content.forEach((t) => t.check());
}
/**
Return a JSON-serializeable representation of this node.
*/
toJSON() {
let e = { type: this.type.name };
for (let t in this.attrs) {
e.attrs = this.attrs;
break;
}
return this.content.size && (e.content = this.content.toJSON()), this.marks.length && (e.marks = this.marks.map((t) => t.toJSON())), e;
}
/**
Deserialize a node from its JSON representation.
*/
static fromJSON(e, t) {
if (!t)
throw new RangeError("Invalid input for Node.fromJSON");
let r;
if (t.marks) {
if (!Array.isArray(t.marks))
throw new RangeError("Invalid mark data for Node.fromJSON");
r = t.marks.map(e.markFromJSON);
}
if (t.type == "text") {
if (typeof t.text != "string")
throw new RangeError("Invalid text node in JSON");
return e.text(t.text, r);
}
let o = D.fromJSON(e, t.content), i = e.nodeType(t.type).create(t.attrs, o, r);
return i.type.checkAttrs(i.attrs), i;
}
};
$n.prototype.text = void 0;
class qi extends $n {
/**
@internal
*/
constructor(e, t, r, o) {
if (super(e, t, null, o), !r)
throw new RangeError("Empty text nodes are not allowed");
this.text = r;
}
toString() {
return this.type.spec.toDebugString ? this.type.spec.toDebugString(this) : ju(this.marks, JSON.stringify(this.text));
}
get textContent() {
return this.text;
}
textBetween(e, t) {
return this.text.slice(e, t);
}
get nodeSize() {
return this.text.length;
}
mark(e) {
return e == this.marks ? this : new qi(this.type, this.attrs, this.text, e);
}
withText(e) {
return e == this.text ? this : new qi(this.type, this.attrs, e, this.marks);
}
cut(e = 0, t = this.text.length) {
return e == 0 && t == this.text.length ? this : this.withText(this.text.slice(e, t));
}
eq(e) {
return this.sameMarkup(e) && this.text == e.text;
}
toJSON() {
let e = super.toJSON();
return e.text = this.text, e;
}
}
function ju(n, e) {
for (let t = n.length - 1; t >= 0; t--)
e = n[t].type.name + "(" + e + ")";
return e;
}
class vr {
/**
@internal
*/
constructor(e) {
this.validEnd = e, this.next = [], this.wrapCache = [];
}
/**
@internal
*/
static parse(e, t) {
let r = new wb(e, t);
if (r.next == null)
return vr.empty;
let o = zu(r);
r.next && r.err("Unexpected trailing text");
let i = Ob(Tb(o));
return Bb(i, r), i;
}
/**
Match a node type, returning a match after that node if
successful.
*/
matchType(e) {
for (let t = 0; t < this.next.length; t++)
if (this.next[t].type == e)
return this.next[t].next;
return null;
}
/**
Try to match a fragment. Returns the resulting match when
successful.
*/
matchFragment(e, t = 0, r = e.childCount) {
let o = this;
for (let i = t; o && i < r; i++)
o = o.matchType(e.child(i).type);
return o;
}
/**
@internal
*/
get inlineContent() {
return this.next.length != 0 && this.next[0].type.isInline;
}
/**
Get the first matching node type at this match position that can
be generated.
*/
get defaultType() {
for (let e = 0; e < this.next.length; e++) {
let { type: t } = this.next[e];
if (!(t.isText || t.hasRequiredAttrs()))
return t;
}
return null;
}
/**
@internal
*/
compatible(e) {
for (let t = 0; t < this.next.length; t++)
for (let r = 0; r < e.next.length; r++)
if (this.next[t].type == e.next[r].type)
return !0;
return !1;
}
/**
Try to match the given fragment, and if that fails, see if it can
be made to match by inserting nodes in front of it. When
successful, return a fragment of inserted nodes (which may be
empty if nothing had to be inserted). When `toEnd` is true, only
return a fragment if the resulting match goes to the end of the
content expression.
*/
fillBefore(e, t = !1, r = 0) {
let o = [this];
function i(s, l) {
let a = s.matchFragment(e, r);
if (a && (!t || a.validEnd))
return D.from(l.map((c) => c.createAndFill()));
for (let c = 0; c < s.next.length; c++) {
let { type: p, next: u } = s.next[c];
if (!(p.isText || p.hasRequiredAttrs()) && o.indexOf(u) == -1) {
o.push(u);
let f = i(u, l.concat(p));
if (f)
return f;
}
}
return null;
}
return i(this, []);
}
/**
Find a set of wrapping node types that would allow a node of the
given type to appear at this position. The result may be empty
(when it fits directly) and will be null when no such wrapping
exists.
*/
findWrapping(e) {
for (let r = 0; r < this.wrapCache.length; r += 2)
if (this.wrapCache[r] == e)
return this.wrapCache[r + 1];
let t = this.computeWrapping(e);
return this.wrapCache.push(e, t), t;
}
/**
@internal
*/
computeWrapping(e) {
let t = /* @__PURE__ */ Object.create(null), r = [{ match: this, type: null, via: null }];
for (; r.length; ) {
let o = r.shift(), i = o.match;
if (i.matchType(e)) {
let s = [];
for (let l = o; l.type; l = l.via)
s.push(l.type);
return s.reverse();
}
for (let s = 0; s < i.next.length; s++) {
let { type: l, next: a } = i.next[s];
!l.isLeaf && !l.hasRequiredAttrs() && !(l.name in t) && (!o.type || a.validEnd) && (r.push({ match: l.contentMatch, type: l, via: o }), t[l.name] = !0);
}
}
return null;
}
/**
The number of outgoing edges this node has in the finite
automaton that describes the content expression.
*/
get edgeCount() {
return this.next.length;
}
/**
Get the _n_th outgoing edge from this node in the finite
automaton that describes the content expression.
*/
edge(e) {
if (e >= this.next.length)
throw new RangeError(`There's no ${e}th edge in this content match`);
return this.next[e];
}
/**
@internal
*/
toString() {
let e = [];
function t(r) {
e.push(r);
for (let o = 0; o < r.next.length; o++)
e.indexOf(r.next[o].next) == -1 && t(r.next[o].next);
}
return t(this), e.map((r, o) => {
let i = o + (r.validEnd ? "*" : " ") + " ";
for (let s = 0; s < r.next.length; s++)
i += (s ? ", " : "") + r.next[s].type.name + "->" + e.indexOf(r.next[s].next);
return i;
}).join(`
`);
}
}
vr.empty = new vr(!0);
class wb {
constructor(e, t) {
this.string = e, this.nodeTypes = t, this.inline = null, this.pos = 0, this.tokens = e.split(/\s*(?=\b|\W|$)/), this.tokens[this.tokens.length - 1] == "" && this.tokens.pop(), this.tokens[0] == "" && this.tokens.shift();
}
get next() {
return this.tokens[this.pos];
}
eat(e) {
return this.next == e && (this.pos++ || !0);
}
err(e) {
throw new SyntaxError(e + " (in content expression '" + this.string + "')");
}
}
function zu(n) {
let e = [];
do
e.push(Sb(n));
while (n.eat("|"));
return e.length == 1 ? e[0] : { type: "choice", exprs: e };
}
function Sb(n) {
let e = [];
do
e.push(kb(n));
while (n.next && n.next != ")" && n.next != "|");
return e.length == 1 ? e[0] : { type: "seq", exprs: e };
}
function kb(n) {
let e = Eb(n);
for (; ; )
if (n.eat("+"))
e = { type: "plus", expr: e };
else if (n.eat("*"))
e = { type: "star", expr: e };
else if (n.eat("?"))
e = { type: "opt", expr: e };
else if (n.eat("{"))
e = Cb(n, e);
else
break;
return e;
}
function Cc(n) {
/\D/.test(n.next) && n.err("Expected number, got '" + n.next + "'");
let e = Number(n.next);
return n.pos++, e;
}
function Cb(n, e) {
let t = Cc(n), r = t;
return n.eat(",") && (n.next != "}" ? r = Cc(n) : r = -1), n.eat("}") || n.err("Unclosed braced range"), { type: "range", min: t, max: r, expr: e };
}
function Mb(n, e) {
let t = n.nodeTypes, r = t[e];
if (r)
return [r];
let o = [];
for (let i in t) {
let s = t[i];
s.isInGroup(e) && o.push(s);
}
return o.length == 0 && n.err("No node type or group '" + e + "' found"), o;
}
function Eb(n) {
if (n.eat("(")) {
let e = zu(n);
return n.eat(")") || n.err("Missing closing paren"), e;
} else if (/\W/.test(n.next))
n.err("Unexpected token '" + n.next + "'");
else {
let e = Mb(n, n.next).map((t) => (n.inline == null ? n.inline = t.isInline : n.inline != t.isInline && n.err("Mixing inline and block content"), { type: "name", value: t }));
return n.pos++, e.length == 1 ? e[0] : { type: "choice", exprs: e };
}
}
function Tb(n) {
let e = [[]];
return o(i(n, 0), t()), e;
function t() {
return e.push([]) - 1;
}
function r(s, l, a) {
let c = { term: a, to: l };
return e[s].push(c), c;
}
function o(s, l) {
s.forEach((a) => a.to = l);
}
function i(s, l) {
if (s.type == "choice")
return s.exprs.reduce((a, c) => a.concat(i(c, l)), []);
if (s.type == "seq")
for (let a = 0; ; a++) {
let c = i(s.exprs[a], l);
if (a == s.exprs.length - 1)
return c;
o(c, l = t());
}
else if (s.type == "star") {
let a = t();
return r(l, a), o(i(s.expr, a), a), [r(a)];
} else if (s.type == "plus") {
let a = t();
return o(i(s.expr, l), a), o(i(s.expr, a), a), [r(a)];
} else {
if (s.type == "opt")
return [r(l)].concat(i(s.expr, l));
if (s.type == "range") {
let a = l;
for (let c = 0; c < s.min; c++) {
let p = t();
o(i(s.expr, a), p), a = p;
}
if (s.max == -1)
o(i(s.expr, a), a);
else
for (let c = s.min; c < s.max; c++) {
let p = t();
r(a, p), o(i(s.expr, a), p), a = p;
}
return [r(a)];
} else {
if (s.type == "name")
return [r(l, void 0, s.value)];
throw new Error("Unknown expr type");
}
}
}
}
function Vu(n, e) {
return e - n;
}
function Mc(n, e) {
let t = [];
return r(e), t.sort(Vu);
function r(o) {
let i = n[o];
if (i.length == 1 && !i[0].term)
return r(i[0].to);
t.push(o);
for (let s = 0; s < i.length; s++) {
let { term: l, to: a } = i[s];
!l && t.indexOf(a) == -1 && r(a);
}
}
}
function Ob(n) {
let e = /* @__PURE__ */ Object.create(null);
return t(Mc(n, 0));
function t(r) {
let o = [];
r.forEach((s) => {
n[s].forEach(({ term: l, to: a }) => {
if (!l)
return;
let c;
for (let p = 0; p < o.length; p++)
o[p][0] == l && (c = o[p][1]);
Mc(n, a).forEach((p) => {
c || o.push([l, c = []]), c.indexOf(p) == -1 && c.push(p);
});
});
});
let i = e[r.join(",")] = new vr(r.indexOf(n.length - 1) > -1);
for (let s = 0; s < o.length; s++) {
let l = o[s][1].sort(Vu);
i.next.push({ type: o[s][0], next: e[l.join(",")] || t(l) });
}
return i;
}
}
function Bb(n, e) {
for (let t = 0, r = [n]; t < r.length; t++) {
let o = r[t], i = !o.validEnd, s = [];
for (let l = 0; l < o.next.length; l++) {
let { type: a, next: c } = o.next[l];
s.push(a.name), i && !(a.isText || a.hasRequiredAttrs()) && (i = !1), r.indexOf(c) == -1 && r.push(c);
}
i && e.err("Only non-generatable nodes (" + s.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)");
}
}
function Wu(n) {
let e = /* @__PURE__ */ Object.create(null);
for (let t in n) {
let r = n[t];
if (!r.hasDefault)
return null;
e[t] = r.default;
}
return e;
}
function Uu(n, e) {
let t = /* @__PURE__ */ Object.create(null);
for (let r in n) {
let o = e && e[r];
if (o === void 0) {
let i = n[r];
if (i.hasDefault)
o = i.default;
else
throw new RangeError("No value supplied for attribute " + r);
}
t[r] = o;
}
return t;
}
function qu(n, e, t, r) {
for (let o in e)
if (!(o in n))
throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);
for (let o in n) {
let i = n[o];
i.validate && i.validate(e[o]);
}
}
function Ku(n, e) {
let t = /* @__PURE__ */ Object.create(null);
if (e)
for (let r in e)
t[r] = new Ab(n, r, e[r]);
return t;
}
let Ec = class Gu {
/**
@internal
*/
constructor(e, t, r) {
this.name = e, this.schema = t, this.spec = r, this.markSet = null, this.groups = r.group ? r.group.split(" ") : [], this.attrs = Ku(e, r.attrs), this.defaultAttrs = Wu(this.attrs), this.contentMatch = null, this.inlineContent = null, this.isBlock = !(r.inline || e == "text"), this.isText = e == "text";
}
/**
True if this is an inline type.
*/
get isInline() {
return !this.isBlock;
}
/**
True if this is a textblock type, a block that contains inline
content.
*/
get isTextblock() {
return this.isBlock && this.inlineContent;
}
/**
True for node types that allow no content.
*/
get isLeaf() {
return this.contentMatch == vr.empty;
}
/**
True when this node is an atom, i.e. when it does not have
directly editable content.
*/
get isAtom() {
return this.isLeaf || !!this.spec.atom;
}
/**
Return true when this node type is part of the given
[group](https://prosemirror.net/docs/ref/#model.NodeSpec.group).
*/
isInGroup(e) {
return this.groups.indexOf(e) > -1;
}
/**
The node type's [whitespace](https://prosemirror.net/docs/ref/#model.NodeSpec.whitespace) option.
*/
get whitespace() {
return this.spec.whitespace || (this.spec.code ? "pre" : "normal");
}
/**
Tells you whether this node type has any required attributes.
*/
hasRequiredAttrs() {
for (let e in this.attrs)
if (this.attrs[e].isRequired)
return !0;
return !1;
}
/**
Indicates whether this node allows some of the same content as
the given node type.
*/
compatibleContent(e) {
return this == e || this.contentMatch.compatible(e.contentMatch);
}
/**
@internal
*/
computeAttrs(e) {
return !e && this.defaultAttrs ? this.defaultAttrs : Uu(this.attrs, e);
}
/**
Create a `Node` of this type. The given attributes are
checked and defaulted (you can pass `null` to use the type's
defaults entirely, if no required attributes exist). `content`
may be a `Fragment`, a node, an array of nodes, or
`null`. Similarly `marks` may be `null` to default to the empty
set of marks.
*/
create(e = null, t, r) {
if (this.isText)
throw new Error("NodeType.create can't construct text nodes");
return new $n(this, this.computeAttrs(e), D.from(t), me.setFrom(r));
}
/**
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but check the given content
against the node type's content restrictions, and throw an error
if it doesn't match.
*/
createChecked(e = null, t, r) {
return t = D.from(t), this.checkContent(t), new $n(this, this.computeAttrs(e), t, me.setFrom(r));
}
/**
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but see if it is
necessary to add nodes to the start or end of the given fragment
to make it fit the node. If no fitting wrapping can be found,
return null. Note that, due to the fact that required nodes can
always be created, this will always succeed if you pass null or
`Fragment.empty` as content.
*/
createAndFill(e = null, t, r) {
if (e = this.computeAttrs(e), t = D.from(t), t.size) {
let s = this.contentMatch.fillBefore(t);
if (!s)
return null;
t = s.append(t);
}
let o = this.contentMatch.matchFragment(t), i = o && o.fillBefore(D.empty, !0);
return i ? new $n(this, e, t.append(i), me.setFrom(r)) : null;
}
/**
Returns true if the given fragment is valid content for this node
type.
*/
validContent(e) {
let t = this.contentMatch.matchFragment(e);
if (!t || !t.validEnd)
return !1;
for (let r = 0; r < e.childCount; r++)
if (!this.allowsMarks(e.child(r).marks))
return !1;
return !0;
}
/**
Throws a RangeError if the given fragment is not valid content for this
node type.
@internal
*/
checkContent(e) {
if (!this.validContent(e))
throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0, 50)}`);
}
/**
@internal
*/
checkAttrs(e) {
qu(this.attrs, e, "node", this.name);
}
/**
Check whether the given mark type is allowed in this node.
*/
allowsMarkType(e) {
return this.markSet == null || this.markSet.indexOf(e) > -1;
}
/**
Test whether the given set of marks are allowed in this node.
*/
allowsMarks(e) {
if (this.markSet == null)
return !0;
for (let t = 0; t < e.length; t++)
if (!this.allowsMarkType(e[t].type))
return !1;
return !0;
}
/**
Removes the marks that are not allowed in this node from the given set.
*/
allowedMarks(e) {
if (this.markSet == null)
return e;
let t;
for (let r = 0; r < e.length; r++)
this.allowsMarkType(e[r].type) ? t && t.push(e[r]) : t || (t = e.slice(0, r));
return t ? t.length ? t : me.none : e;
}
/**
@internal
*/
static compile(e, t) {
let r = /* @__PURE__ */ Object.create(null);
e.forEach((i, s) => r[i] = new Gu(i, t, s));
let o = t.spec.topNode || "doc";
if (!r[o])
throw new RangeError("Schema is missing its top node type ('" + o + "')");
if (!r.text)
throw new RangeError("Every schema needs a 'text' type");
for (let i in r.text.attrs)
throw new RangeError("The text node type should not have attributes");
return r;
}
};
function Pb(n, e, t) {
let r = t.split("|");
return (o) => {
let i = o === null ? "null" : typeof o;
if (r.indexOf(i) < 0)
throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`);
};
}
class Ab {
constructor(e, t, r) {
this.hasDefault = Object.prototype.hasOwnProperty.call(r, "default"), this.default = r.default, this.validate = typeof r.validate == "string" ? Pb(e, t, r.validate) : r.validate;
}
get isRequired() {
return !this.hasDefault;
}
}
class Ls {
/**
@internal
*/
constructor(e, t, r, o) {
this.name = e, this.rank = t, this.schema = r, this.spec = o, this.attrs = Ku(e, o.attrs), this.excluded = null;
let i = Wu(this.attrs);
this.instance = i ? new me(this, i) : null;
}
/**
Create a mark of this type. `attrs` may be `null` or an object
containing only some of the mark's attributes. The others, if
they have defaults, will be added.
*/
create(e = null) {
return !e && this.instance ? this.instance : new me(this, Uu(this.attrs, e));
}
/**
@internal
*/
static compile(e, t) {
let r = /* @__PURE__ */ Object.create(null), o = 0;
return e.forEach((i, s) => r[i] = new Ls(i, o++, t, s)), r;
}
/**
When there is a mark of this type in the given set, a new set
without it is returned. Otherwise, the input set is returned.
*/
removeFromSet(e) {
for (var t = 0; t < e.length; t++)
e[t].type == this && (e = e.slice(0, t).concat(e.slice(t + 1)), t--);
return e;
}
/**
Tests whether there is a mark of this type in the given set.
*/
isInSet(e) {
for (let t = 0; t < e.length; t++)
if (e[t].type == this)
return e[t];
}
/**
@internal
*/
checkAttrs(e) {
qu(this.attrs, e, "mark", this.name);
}
/**
Queries whether a given mark type is
[excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
*/
excludes(e) {
return this.excluded.indexOf(e) > -1;
}
}
class Ju {
/**
Construct a schema from a schema [specification](https://prosemirror.net/docs/ref/#model.SchemaSpec).
*/
constructor(e) {
this.linebreakReplacement = null, this.cached = /* @__PURE__ */ Object.create(null);
let t = this.spec = {};
for (let o in e)
t[o] = e[o];
t.nodes = $e.from(e.nodes), t.marks = $e.from(e.marks || {}), this.nodes = Ec.compile(this.spec.nodes, this), this.marks = Ls.compile(this.spec.marks, this);
let r = /* @__PURE__ */ Object.create(null);
for (let o in this.nodes) {
if (o in this.marks)
throw new RangeError(o + " can not be both a node and a mark");
let i = this.nodes[o], s = i.spec.content || "", l = i.spec.marks;
if (i.contentMatch = r[s] || (r[s] = vr.parse(s, this.nodes)), i.inlineContent = i.contentMatch.inlineContent, i.spec.linebreakReplacement) {
if (this.linebreakReplacement)
throw new RangeError("Multiple linebreak nodes defined");
if (!i.isInline || !i.isLeaf)
throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");
this.linebreakReplacement = i;
}
i.markSet = l == "_" ? null : l ? Tc(this, l.split(" ")) : l == "" || !i.inlineContent ? [] : null;
}
for (let o in this.marks) {
let i = this.marks[o], s = i.spec.excludes;
i.excluded = s == null ? [i] : s == "" ? [] : Tc(this, s.split(" "));
}
this.nodeFromJSON = this.nodeFromJSON.bind(this), this.markFromJSON = this.markFromJSON.bind(this), this.topNodeType = this.nodes[this.spec.topNode || "doc"], this.cached.wrappings = /* @__PURE__ */ Object.create(null);
}
/**
Create a node in this schema. The `type` may be a string or a
`NodeType` instance. Attributes will be extended with defaults,
`content` may be a `Fragment`, `null`, a `Node`, or an array of
nodes.
*/
node(e, t = null, r, o) {
if (typeof e == "string")
e = this.nodeType(e);
else if (e instanceof Ec) {
if (e.schema != this)
throw new RangeError("Node type from different schema used (" + e.name + ")");
} else throw new RangeError("Invalid node type: " + e);
return e.createChecked(t, r, o);
}
/**
Create a text node in the schema. Empty text nodes are not
allowed.
*/
text(e, t) {
let r = this.nodes.text;
return new qi(r, r.defaultAttrs, e, me.setFrom(t));
}
/**
Create a mark with the given type and attributes.
*/
mark(e, t) {
return typeof e == "string" && (e = this.marks[e]), e.create(t);
}
/**
Deserialize a node from its JSON representation. This method is
bound.
*/
nodeFromJSON(e) {
return $n.fromJSON(this, e);
}
/**
Deserialize a mark from its JSON representation. This method is
bound.
*/
markFromJSON(e) {
return me.fromJSON(this, e);
}
/**
@internal
*/
nodeType(e) {
let t = this.nodes[e];
if (!t)
throw new RangeError("Unknown node type: " + e);
return t;
}
}
function Tc(n, e) {
let t = [];
for (let r = 0; r < e.length; r++) {
let o = e[r], i = n.marks[o], s = i;
if (i)
t.push(i);
else
for (let l in n.marks) {
let a = n.marks[l];
(o == "_" || a.spec.group && a.spec.group.split(" ").indexOf(o) > -1) && t.push(s = a);
}
if (!s)
throw new SyntaxError("Unknown mark type: '" + e[r] + "'");
}
return t;
}
function _b(n) {
return n.tag != null;
}
function Lb(n) {
return n.style != null;
}
let wo = class Hl {
/**
Create a parser that targets the given schema, using the given
parsing rules.
*/
constructor(e, t) {
this.schema = e, this.rules = t, this.tags = [], this.styles = [];
let r = this.matchedStyles = [];
t.forEach((o) => {
if (_b(o))
this.tags.push(o);
else if (Lb(o)) {
let i = /[^=]*/.exec(o.style)[0];
r.indexOf(i) < 0 && r.push(i), this.styles.push(o);
}
}), this.normalizeLists = !this.tags.some((o) => {
if (!/^(ul|ol)\b/.test(o.tag) || !o.node)
return !1;
let i = e.nodes[o.node];
return i.contentMatch.matchType(i);
});
}
/**
Parse a document from the content of a DOM node.
*/
parse(e, t = {}) {
let r = new Bc(this, t, !1);
return r.addAll(e, me.none, t.from, t.to), r.finish();
}
/**
Parses the content of the given DOM node, like
[`parse`](https://prosemirror.net/docs/ref/#model.DOMParser.parse), and takes the same set of
options. But unlike that method, which produces a whole node,
this one returns a slice that is open at the sides, meaning that
the schema constraints aren't applied to the start of nodes to
the left of the input and the end of nodes at the end.
*/
parseSlice(e, t = {}) {
let r = new Bc(this, t, !0);
return r.addAll(e, me.none, t.from, t.to), z.maxOpen(r.finish());
}
/**
@internal
*/
matchTag(e, t, r) {
for (let o = r ? this.tags.indexOf(r) + 1 : 0; o < this.tags.length; o++) {
let i = this.tags[o];
if (Ib(e, i.tag) && (i.namespace === void 0 || e.namespaceURI == i.namespace) && (!i.context || t.matchesContext(i.context))) {
if (i.getAttrs) {
let s = i.getAttrs(e);
if (s === !1)
continue;
i.attrs = s || void 0;
}
return i;
}
}
}
/**
@internal
*/
matchStyle(e, t, r, o) {
for (let i = o ? this.styles.indexOf(o) + 1 : 0; i < this.styles.length; i++) {
let s = this.styles[i], l = s.style;
if (!(l.indexOf(e) != 0 || s.context && !r.matchesContext(s.context) || // Test that the style string either precisely matches the prop,
// or has an '=' sign after the prop, followed by the given
// value.
l.length > e.length && (l.charCodeAt(e.length) != 61 || l.slice(e.length + 1) != t))) {
if (s.getAttrs) {
let a = s.getAttrs(t);
if (a === !1)
continue;
s.attrs = a || void 0;
}
return s;
}
}
}
/**
@internal
*/
static schemaRules(e) {
let t = [];
function r(o) {
let i = o.priority == null ? 50 : o.priority, s = 0;
for (; s < t.length; s++) {
let l = t[s];
if ((l.priority == null ? 50 : l.priority) < i)
break;
}
t.splice(s, 0, o);
}
for (let o in e.marks) {
let i = e.marks[o].spec.parseDOM;
i && i.forEach((s) => {
r(s = Pc(s)), s.mark || s.ignore || s.clearMark || (s.mark = o);
});
}
for (let o in e.nodes) {
let i = e.nodes[o].spec.parseDOM;
i && i.forEach((s) => {
r(s = Pc(s)), s.node || s.ignore || s.mark || (s.node = o);
});
}
return t;
}
/**
Construct a DOM parser using the parsing rules listed in a
schema's [node specs](https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM), reordered by
[priority](https://prosemirror.net/docs/ref/#model.ParseRule.priority).
*/
static fromSchema(e) {
return e.cached.domParser || (e.cached.domParser = new Hl(e, Hl.schemaRules(e)));
}
};
const Yu = {
address: !0,
article: !0,
aside: !0,
blockquote: !0,
canvas: !0,
dd: !0,
div: !0,
dl: !0,
fieldset: !0,
figcaption: !0,
figure: !0,
footer: !0,
form: !0,
h1: !0,
h2: !0,
h3: !0,
h4: !0,
h5: !0,
h6: !0,
header: !0,
hgroup: !0,
hr: !0,
li: !0,
noscript: !0,
ol: !0,
output: !0,
p: !0,
pre: !0,
section: !0,
table: !0,
tfoot: !0,
ul: !0
}, Nb = {
head: !0,
noscript: !0,
object: !0,
script: !0,
style: !0,
title: !0
}, Xu = { ol: !0, ul: !0 }, Io = 1, jl = 2, So = 4;
function Oc(n, e, t) {
return e != null ? (e ? Io : 0) | (e === "full" ? jl : 0) : n && n.whitespace == "pre" ? Io | jl : t & ~So;
}
class bi {
constructor(e, t, r, o, i, s) {
this.type = e, this.attrs = t, this.marks = r, this.solid = o, this.options = s, this.content = [], this.activeMarks = me.none, this.match = i || (s & So ? null : e.contentMatch);
}
findWrapping(e) {
if (!this.match) {
if (!this.type)
return [];
let t = this.type.contentMatch.fillBefore(D.from(e));
if (t)
this.match = this.type.contentMatch.matchFragment(t);
else {
let r = this.type.contentMatch, o;
return (o = r.findWrapping(e.type)) ? (this.match = r, o) : null;
}
}
return this.match.findWrapping(e.type);
}
finish(e) {
if (!(this.options & Io)) {
let r = this.content[this.content.length - 1], o;
if (r && r.isText && (o = /[ \t\r\n\u000c]+$/.exec(r.text))) {
let i = r;
r.text.length == o[0].length ? this.content.pop() : this.content[this.content.length - 1] = i.withText(i.text.slice(0, i.text.length - o[0].length));
}
}
let t = D.from(this.content);
return !e && this.match && (t = t.append(this.match.fillBefore(D.empty, !0))), this.type ? this.type.create(this.attrs, t, this.marks) : t;
}
inlineContext(e) {
return this.type ? this.type.inlineContent : this.content.length ? this.content[0].isInline : e.parentNode && !Yu.hasOwnProperty(e.parentNode.nodeName.toLowerCase());
}
}
class Bc {
constructor(e, t, r) {
this.parser = e, this.options = t, this.isOpen = r, this.open = 0, this.localPreserveWS = !1;
let o = t.topNode, i, s = Oc(null, t.preserveWhitespace, 0) | (r ? So : 0);
o ? i = new bi(o.type, o.attrs, me.none, !0, t.topMatch || o.type.contentMatch, s) : r ? i = new bi(null, null, me.none, !0, null, s) : i = new bi(e.schema.topNodeType, null, me.none, !0, null, s), this.nodes = [i], this.find = t.findPositions, this.needsBlock = !1;
}
get top() {
return this.nodes[this.open];
}
// Add a DOM node to the content. Text is inserted as text node,
// otherwise, the node is passed to `addElement` or, if it has a
// `style` attribute, `addElementWithStyles`.
addDOM(e, t) {
e.nodeType == 3 ? this.addTextNode(e, t) : e.nodeType == 1 && this.addElement(e, t);
}
addTextNode(e, t) {
let r = e.nodeValue, o = this.top, i = o.options & jl ? "full" : this.localPreserveWS || (o.options & Io) > 0;
if (i === "full" || o.inlineContext(e) || /[^ \t\r\n\u000c]/.test(r)) {
if (i)
i !== "full" ? r = r.replace(/\r?\n|\r/g, " ") : r = r.replace(/\r\n?/g, `
`);
else if (r = r.replace(/[ \t\r\n\u000c]+/g, " "), /^[ \t\r\n\u000c]/.test(r) && this.open == this.nodes.length - 1) {
let s = o.content[o.content.length - 1], l = e.previousSibling;
(!s || l && l.nodeName == "BR" || s.isText && /[ \t\r\n\u000c]$/.test(s.text)) && (r = r.slice(1));
}
r && this.insertNode(this.parser.schema.text(r), t, !/\S/.test(r)), this.findInText(e);
} else
this.findInside(e);
}
// Try to find a handler for the given tag and use that to parse. If
// none is found, the element's content nodes are added directly.
addElement(e, t, r) {
let o = this.localPreserveWS, i = this.top;
(e.tagName == "PRE" || /pre/.test(e.style && e.style.whiteSpace)) && (this.localPreserveWS = !0);
let s = e.nodeName.toLowerCase(), l;
Xu.hasOwnProperty(s) && this.parser.normalizeLists && Db(e);
let a = this.options.ruleFromNode && this.options.ruleFromNode(e) || (l = this.parser.matchTag(e, this, r));
e: if (a ? a.ignore : Nb.hasOwnProperty(s))
this.findInside(e), this.ignoreFallback(e, t);
else if (!a || a.skip || a.closeParent) {
a && a.closeParent ? this.open = Math.max(0, this.open - 1) : a && a.skip.nodeType && (e = a.skip);
let c, p = this.needsBlock;
if (Yu.hasOwnProperty(s))
i.content.length && i.content[0].isInline && this.open && (this.open--, i = this.top), c = !0, i.type || (this.needsBlock = !0);
else if (!e.firstChild) {
this.leafFallback(e, t);
break e;
}
let u = a && a.skip ? t : this.readStyles(e, t);
u && this.addAll(e, u), c && this.sync(i), this.needsBlock = p;
} else {
let c = this.readStyles(e, t);
c && this.addElementByRule(e, a, c, a.consuming === !1 ? l : void 0);
}
this.localPreserveWS = o;
}
// Called for leaf DOM nodes that would otherwise be ignored
leafFallback(e, t) {
e.nodeName == "BR" && this.top.type && this.top.type.inlineContent && this.addTextNode(e.ownerDocument.createTextNode(`
`), t);
}
// Called for ignored nodes
ignoreFallback(e, t) {
e.nodeName == "BR" && (!this.top.type || !this.top.type.inlineContent) && this.findPlace(this.parser.schema.text("-"), t, !0);
}
// Run any style parser associated with the node's styles. Either
// return an updated array of marks, or null to indicate some of the
// styles had a rule with `ignore` set.
readStyles(e, t) {
let r = e.style;
if (r && r.length)
for (let o = 0; o < this.parser.matchedStyles.length; o++) {
let i = this.parser.matchedStyles[o], s = r.getPropertyValue(i);
if (s)
for (let l = void 0; ; ) {
let a = this.parser.matchStyle(i, s, this, l);
if (!a)
break;
if (a.ignore)
return null;
if (a.clearMark ? t = t.filter((c) => !a.clearMark(c)) : t = t.concat(this.parser.schema.marks[a.mark].create(a.attrs)), a.consuming === !1)
l = a;
else
break;
}
}
return t;
}
// Look up a handler for the given node. If none are found, return
// false. Otherwise, apply it, use its return value to drive the way
// the node's content is wrapped, and return true.
addElementByRule(e, t, r, o) {
let i, s;
if (t.node)
if (s = this.parser.schema.nodes[t.node], s.isLeaf)
this.insertNode(s.create(t.attrs), r, e.nodeName == "BR") || this.leafFallback(e, r);
else {
let a = this.enter(s, t.attrs || null, r, t.preserveWhitespace);
a && (i = !0, r = a);
}
else {
let a = this.parser.schema.marks[t.mark];
r = r.concat(a.create(t.attrs));
}
let l = this.top;
if (s && s.isLeaf)
this.findInside(e);
else if (o)
this.addElement(e, r, o);
else if (t.getContent)
this.findInside(e), t.getContent(e, this.parser.schema).forEach((a) => this.insertNode(a, r, !1));
else {
let a = e;
typeof t.contentElement == "string" ? a = e.querySelector(t.contentElement) : typeof t.contentElement == "function" ? a = t.contentElement(e) : t.contentElement && (a = t.contentElement), this.findAround(e, a, !0), this.addAll(a, r), this.findAround(e, a, !1);
}
i && this.sync(l) && this.open--;
}
// Add all child nodes between `startIndex` and `endIndex` (or the
// whole node, if not given). If `sync` is passed, use it to
// synchronize after every block element.
addAll(e, t, r, o) {
let i = r || 0;
for (let s = r ? e.childNodes[r] : e.firstChild, l = o == null ? null : e.childNodes[o]; s != l; s = s.nextSibling, ++i)
this.findAtPoint(e, i), this.addDOM(s, t);
this.findAtPoint(e, i);
}
// Try to find a way to fit the given node type into the current
// context. May add intermediate wrappers and/or leave non-solid
// nodes that we're in.
findPlace(e, t, r) {
let o, i;
for (let s = this.open, l = 0; s >= 0; s--) {
let a = this.nodes[s], c = a.findWrapping(e);
if (c && (!o || o.length > c.length + l) && (o = c, i = a, !c.length))
break;
if (a.solid) {
if (r)
break;
l += 2;
}
}
if (!o)
return null;
this.sync(i);
for (let s = 0; s < o.length; s++)
t = this.enterInner(o[s], null, t, !1);
return t;
}
// Try to insert the given node, adjusting the context when needed.
insertNode(e, t, r) {
if (e.isInline && this.needsBlock && !this.top.type) {
let i = this.textblockFromContext();
i && (t = this.enterInner(i, null, t));
}
let o = this.findPlace(e, t, r);
if (o) {
this.closeExtra();
let i = this.top;
i.match && (i.match = i.match.matchType(e.type));
let s = me.none;
for (let l of o.concat(e.marks))
(i.type ? i.type.allowsMarkType(l.type) : Ac(l.type, e.type)) && (s = l.addToSet(s));
return i.content.push(e.mark(s)), !0;
}
return !1;
}
// Try to start a node of the given type, adjusting the context when
// necessary.
enter(e, t, r, o) {
let i = this.findPlace(e.create(t), r, !1);
return i && (i = this.enterInner(e, t, r, !0, o)), i;
}
// Open a node of the given type
enterInner(e, t, r, o = !1, i) {
this.closeExtra();
let s = this.top;
s.match = s.match && s.match.matchType(e);
let l = Oc(e, i, s.options);
s.options & So && s.content.length == 0 && (l |= So);
let a = me.none;
return r = r.filter((c) => (s.type ? s.type.allowsMarkType(c.type) : Ac(c.type, e)) ? (a = c.addToSet(a), !1) : !0), this.nodes.push(new bi(e, t, a, o, null, l)), this.open++, r;
}
// Make sure all nodes above this.open are finished and added to
// their parents
closeExtra(e = !1) {
let t = this.nodes.length - 1;
if (t > this.open) {
for (; t > this.open; t--)
this.nodes[t - 1].content.push(this.nodes[t].finish(e));
this.nodes.length = this.open + 1;
}
}
finish() {
return this.open = 0, this.closeExtra(this.isOpen), this.nodes[0].finish(!!(this.isOpen || this.options.topOpen));
}
sync(e) {
for (let t = this.open; t >= 0; t--) {
if (this.nodes[t] == e)
return this.open = t, !0;
this.localPreserveWS && (this.nodes[t].options |= Io);
}
return !1;
}
get currentPos() {
this.closeExtra();
let e = 0;
for (let t = this.open; t >= 0; t--) {
let r = this.nodes[t].content;
for (let o = r.length - 1; o >= 0; o--)
e += r[o].nodeSize;
t && e++;
}
return e;
}
findAtPoint(e, t) {
if (this.find)
for (let r = 0; r < this.find.length; r++)
this.find[r].node == e && this.find[r].offset == t && (this.find[r].pos = this.currentPos);
}
findInside(e) {
if (this.find)
for (let t = 0; t < this.find.length; t++)
this.find[t].pos == null && e.nodeType == 1 && e.contains(this.find[t].node) && (this.find[t].pos = this.currentPos);
}
findAround(e, t, r) {
if (e != t && this.find)
for (let o = 0; o < this.find.length; o++)
this.find[o].pos == null && e.nodeType == 1 && e.contains(this.find[o].node) && t.compareDocumentPosition(this.find[o].node) & (r ? 2 : 4) && (this.find[o].pos = this.currentPos);
}
findInText(e) {
if (this.find)
for (let t = 0; t < this.find.length; t++)
this.find[t].node == e && (this.find[t].pos = this.currentPos - (e.nodeValue.length - this.find[t].offset));
}
// Determines whether the given context string matches this context.
matchesContext(e) {
if (e.indexOf("|") > -1)
return e.split(/\s*\|\s*/).some(this.matchesContext, this);
let t = e.split("/"), r = this.options.context, o = !this.isOpen && (!r || r.parent.type == this.nodes[0].type), i = -(r ? r.depth + 1 : 0) + (o ? 0 : 1), s = (l, a) => {
for (; l >= 0; l--) {
let c = t[l];
if (c == "") {
if (l == t.length - 1 || l == 0)
continue;
for (; a >= i; a--)
if (s(l - 1, a))
return !0;
return !1;
} else {
let p = a > 0 || a == 0 && o ? this.nodes[a].type : r && a >= i ? r.node(a - i).type : null;
if (!p || p.name != c && !p.isInGroup(c))
return !1;
a--;
}
}
return !0;
};
return s(t.length - 1, this.open);
}
textblockFromContext() {
let e = this.options.context;
if (e)
for (let t = e.depth; t >= 0; t--) {
let r = e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;
if (r && r.isTextblock && r.defaultAttrs)
return r;
}
for (let t in this.parser.schema.nodes) {
let r = this.parser.schema.nodes[t];
if (r.isTextblock && r.defaultAttrs)
return r;
}
}
}
function Db(n) {
for (let e = n.firstChild, t = null; e; e = e.nextSibling) {
let r = e.nodeType == 1 ? e.nodeName.toLowerCase() : null;
r && Xu.hasOwnProperty(r) && t ? (t.appendChild(e), e = t) : r == "li" ? t = e : r && (t = null);
}
}
function Ib(n, e) {
return (n.matches || n.msMatchesSelector || n.webkitMatchesSelector || n.mozMatchesSelector).call(n, e);
}
function Pc(n) {
let e = {};
for (let t in n)
e[t] = n[t];
return e;
}
function Ac(n, e) {
let t = e.schema.nodes;
for (let r in t) {
let o = t[r];
if (!o.allowsMarkType(n))
continue;
let i = [], s = (l) => {
i.push(l);
for (let a = 0; a < l.edgeCount; a++) {
let { type: c, next: p } = l.edge(a);
if (c == e || i.indexOf(p) < 0 && s(p))
return !0;
}
};
if (s(o.contentMatch))
return !0;
}
}
class Or {
/**
Create a serializer. `nodes` should map node names to functions
that take a node and return a description of the corresponding
DOM. `marks` does the same for mark names, but also gets an
argument that tells it whether the mark's content is block or
inline content (for typical use, it'll always be inline). A mark
serializer may be `null` to indicate that marks of that type
should not be serialized.
*/
constructor(e, t) {
this.nodes = e, this.marks = t;
}
/**
Serialize the content of this fragment to a DOM fragment. When
not in the browser, the `document` option, containing a DOM
document, should be passed so that the serializer can create
nodes.
*/
serializeFragment(e, t = {}, r) {
r || (r = el(t).createDocumentFragment());
let o = r, i = [];
return e.forEach((s) => {
if (i.length || s.marks.length) {
let l = 0, a = 0;
for (; l < i.length && a < s.marks.length; ) {
let c = s.marks[a];
if (!this.marks[c.type.name]) {
a++;
continue;
}
if (!c.eq(i[l][0]) || c.type.spec.spanning === !1)
break;
l++, a++;
}
for (; l < i.length; )
o = i.pop()[1];
for (; a < s.marks.length; ) {
let c = s.marks[a++], p = this.serializeMark(c, s.isInline, t);
p && (i.push([c, o]), o.appendChild(p.dom), o = p.contentDOM || p.dom);
}
}
o.appendChild(this.serializeNodeInner(s, t));
}), r;
}
/**
@internal
*/
serializeNodeInner(e, t) {
let { dom: r, contentDOM: o } = Bi(el(t), this.nodes[e.type.name](e), null, e.attrs);
if (o) {
if (e.isLeaf)
throw new RangeError("Content hole not allowed in a leaf node spec");
this.serializeFragment(e.content, t, o);
}
return r;
}
/**
Serialize this node to a DOM node. This can be useful when you
need to serialize a part of a document, as opposed to the whole
document. To serialize a whole document, use
[`serializeFragment`](https://prosemirror.net/docs/ref/#model.DOMSerializer.serializeFragment) on
its [content](https://prosemirror.net/docs/ref/#model.Node.content).
*/
serializeNode(e, t = {}) {
let r = this.serializeNodeInner(e, t);
for (let o = e.marks.length - 1; o >= 0; o--) {
let i = this.serializeMark(e.marks[o], e.isInline, t);
i && ((i.contentDOM || i.dom).appendChild(r), r = i.dom);
}
return r;
}
/**
@internal
*/
serializeMark(e, t, r = {}) {
let o = this.marks[e.type.name];
return o && Bi(el(r), o(e, t), null, e.attrs);
}
static renderSpec(e, t, r = null, o) {
return Bi(e, t, r, o);
}
/**
Build a serializer using the [`toDOM`](https://prosemirror.net/docs/ref/#model.NodeSpec.toDOM)
properties in a schema's node and mark specs.
*/
static fromSchema(e) {
return e.cached.domSerializer || (e.cached.domSerializer = new Or(this.nodesFromSchema(e), this.marksFromSchema(e)));
}
/**
Gather the serializers in a schema's node specs into an object.
This can be useful as a base to build a custom serializer from.
*/
static nodesFromSchema(e) {
let t = _c(e.nodes);
return t.text || (t.text = (r) => r.text), t;
}
/**
Gather the serializers in a schema's mark specs into an object.
*/
static marksFromSchema(e) {
return _c(e.marks);
}
}
function _c(n) {
let e = {};
for (let t in n) {
let r = n[t].spec.toDOM;
r && (e[t] = r);
}
return e;
}
function el(n) {
return n.document || window.document;
}
const Lc = /* @__PURE__ */ new WeakMap();
function $b(n) {
let e = Lc.get(n);
return e === void 0 && Lc.set(n, e = Rb(n)), e;
}
function Rb(n) {
let e = null;
function t(r) {
if (r && typeof r == "object")
if (Array.isArray(r))
if (typeof r[0] == "string")
e || (e = []), e.push(r);
else
for (let o = 0; o < r.length; o++)
t(r[o]);
else
for (let o in r)
t(r[o]);
}
return t(n), e;
}
function Bi(n, e, t, r) {
if (typeof e == "string")
return { dom: n.createTextNode(e) };
if (e.nodeType != null)
return { dom: e };
if (e.dom && e.dom.nodeType != null)
return e;
let o = e[0], i;
if (typeof o != "string")
throw new RangeError("Invalid array passed to renderSpec");
if (r && (i = $b(r)) && i.indexOf(e) > -1)
throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");
let s = o.indexOf(" ");
s > 0 && (t = o.slice(0, s), o = o.slice(s + 1));
let l, a = t ? n.createElementNS(t, o) : n.createElement(o), c = e[1], p = 1;
if (c && typeof c == "object" && c.nodeType == null && !Array.isArray(c)) {
p = 2;
for (let u in c)
if (c[u] != null) {
let f = u.indexOf(" ");
f > 0 ? a.setAttributeNS(u.slice(0, f), u.slice(f + 1), c[u]) : a.setAttribute(u, c[u]);
}
}
for (let u = p; u < e.length; u++) {
let f = e[u];
if (f === 0) {
if (u < e.length - 1 || u > p)
throw new RangeError("Content hole must be the only child of its parent node");
return { dom: a, contentDOM: a };
} else {
let { dom: h, contentDOM: b } = Bi(n, f, t, r);
if (a.appendChild(h), b) {
if (l)
throw new RangeError("Multiple content holes");
l = b;
}
}
}
return { dom: a, contentDOM: l };
}
const Qu = 65535, Zu = Math.pow(2, 16);
function Fb(n, e) {
return n + e * Zu;
}
function Nc(n) {
return n & Qu;
}
function Hb(n) {
return (n - (n & Qu)) / Zu;
}
const ed = 1, td = 2, Pi = 4, nd = 8;
class zl {
/**
@internal
*/
constructor(e, t, r) {
this.pos = e, this.delInfo = t, this.recover = r;
}
/**
Tells you whether the position was deleted, that is, whether the
step removed the token on the side queried (via the `assoc`)
argument from the document.
*/
get deleted() {
return (this.delInfo & nd) > 0;
}
/**
Tells you whether the token before the mapped position was deleted.
*/
get deletedBefore() {
return (this.delInfo & (ed | Pi)) > 0;
}
/**
True when the token after the mapped position was deleted.
*/
get deletedAfter() {
return (this.delInfo & (td | Pi)) > 0;
}
/**
Tells whether any of the steps mapped through deletes across the
position (including both the token before and after the
position).
*/
get deletedAcross() {
return (this.delInfo & Pi) > 0;
}
}
class lt {
/**
Create a position map. The modifications to the document are
represented as an array of numbers, in which each group of three
represents a modified chunk as `[start, oldSize, newSize]`.
*/
constructor(e, t = !1) {
if (this.ranges = e, this.inverted = t, !e.length && lt.empty)
return lt.empty;
}
/**
@internal
*/
recover(e) {
let t = 0, r = Nc(e);
if (!this.inverted)
for (let o = 0; o < r; o++)
t += this.ranges[o * 3 + 2] - this.ranges[o * 3 + 1];
return this.ranges[r * 3] + t + Hb(e);
}
mapResult(e, t = 1) {
return this._map(e, t, !1);
}
map(e, t = 1) {
return this._map(e, t, !0);
}
/**
@internal
*/
_map(e, t, r) {
let o = 0, i = this.inverted ? 2 : 1, s = this.inverted ? 1 : 2;
for (let l = 0; l < this.ranges.length; l += 3) {
let a = this.ranges[l] - (this.inverted ? o : 0);
if (a > e)
break;
let c = this.ranges[l + i], p = this.ranges[l + s], u = a + c;
if (e <= u) {
let f = c ? e == a ? -1 : e == u ? 1 : t : t, h = a + o + (f < 0 ? 0 : p);
if (r)
return h;
let b = e == (t < 0 ? a : u) ? null : Fb(l / 3, e - a), m = e == a ? td : e == u ? ed : Pi;
return (t < 0 ? e != a : e != u) && (m |= nd), new zl(h, m, b);
}
o += p - c;
}
return r ? e + o : new zl(e + o, 0, null);
}
/**
@internal
*/
touches(e, t) {
let r = 0, o = Nc(t), i = this.inverted ? 2 : 1, s = this.inverted ? 1 : 2;
for (let l = 0; l < this.ranges.length; l += 3) {
let a = this.ranges[l] - (this.inverted ? r : 0);
if (a > e)
break;
let c = this.ranges[l + i], p = a + c;
if (e <= p && l == o * 3)
return !0;
r += this.ranges[l + s] - c;
}
return !1;
}
/**
Calls the given function on each of the changed ranges included in
this map.
*/
forEach(e) {
let t = this.inverted ? 2 : 1, r = this.inverted ? 1 : 2;
for (let o = 0, i = 0; o < this.ranges.length; o += 3) {
let s = this.ranges[o], l = s - (this.inverted ? i : 0), a = s + (this.inverted ? 0 : i), c = this.ranges[o + t], p = this.ranges[o + r];
e(l, l + c, a, a + p), i += p - c;
}
}
/**
Create an inverted version of this map. The result can be used to
map positions in the post-step document to the pre-step document.
*/
invert() {
return new lt(this.ranges, !this.inverted);
}
/**
@internal
*/
toString() {
return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
}
/**
Create a map that moves all positions by offset `n` (which may be
negative). This can be useful when applying steps meant for a
sub-document to a larger document, or vice-versa.
*/
static offset(e) {
return e == 0 ? lt.empty : new lt(e < 0 ? [0, -e, 0] : [0, 0, e]);
}
}
lt.empty = new lt([]);
class $o {
/**
Create a new mapping with the given position maps.
*/
constructor(e, t, r = 0, o = e ? e.length : 0) {
this.mirror = t, this.from = r, this.to = o, this._maps = e || [], this.ownData = !(e || t);
}
/**
The step maps in this mapping.
*/
get maps() {
return this._maps;
}
/**
Create a mapping that maps only through a part of this one.
*/
slice(e = 0, t = this.maps.length) {
return new $o(this._maps, this.mirror, e, t);
}
/**
Add a step map to the end of this mapping. If `mirrors` is
given, it should be the index of the step map that is the mirror
image of this one.
*/
appendMap(e, t) {
this.ownData || (this._maps = this._maps.slice(), this.mirror = this.mirror && this.mirror.slice(), this.ownData = !0), this.to = this._maps.push(e), t != null && this.setMirror(this._maps.length - 1, t);
}
/**
Add all the step maps in a given mapping to this one (preserving
mirroring information).
*/
appendMapping(e) {
for (let t = 0, r = this._maps.length; t < e._maps.length; t++) {
let o = e.getMirror(t);
this.appendMap(e._maps[t], o != null && o < t ? r + o : void 0);
}
}
/**
Finds the offset of the step map that mirrors the map at the
given offset, in this mapping (as per the second argument to
`appendMap`).
*/
getMirror(e) {
if (this.mirror) {
for (let t = 0; t < this.mirror.length; t++)
if (this.mirror[t] == e)
return this.mirror[t + (t % 2 ? -1 : 1)];
}
}
/**
@internal
*/
setMirror(e, t) {
this.mirror || (this.mirror = []), this.mirror.push(e, t);
}
/**
Append the inverse of the given mapping to this one.
*/
appendMappingInverted(e) {
for (let t = e.maps.length - 1, r = this._maps.length + e._maps.length; t >= 0; t--) {
let o = e.getMirror(t);
this.appendMap(e._maps[t].invert(), o != null && o > t ? r - o - 1 : void 0);
}
}
/**
Create an inverted version of this mapping.
*/
invert() {
let e = new $o();
return e.appendMappingInverted(this), e;
}
/**
Map a position through this mapping.
*/
map(e, t = 1) {
if (this.mirror)
return this._map(e, t, !0);
for (let r = this.from; r < this.to; r++)
e = this._maps[r].map(e, t);
return e;
}
/**
Map a position through this mapping, returning a mapping
result.
*/
mapResult(e, t = 1) {
return this._map(e, t, !1);
}
/**
@internal
*/
_map(e, t, r) {
let o = 0;
for (let i = this.from; i < this.to; i++) {
let s = this._maps[i], l = s.mapResult(e, t);
if (l.recover != null) {
let a = this.getMirror(i);
if (a != null && a > i && a < this.to) {
i = a, e = this._maps[a].recover(l.recover);
continue;
}
}
o |= l.delInfo, e = l.pos;
}
return r ? e : new zl(e, o, null);
}
}
const tl = /* @__PURE__ */ Object.create(null);
class Ke {
/**
Get the step map that represents the changes made by this step,
and which can be used to transform between positions in the old
and the new document.
*/
getMap() {
return lt.empty;
}
/**
Try to merge this step with another one, to be applied directly
after it. Returns the merged step when possible, null if the
steps can't be merged.
*/
merge(e) {
return null;
}
/**
Deserialize a step from its JSON representation. Will call
through to the step class' own implementation of this method.
*/
static fromJSON(e, t) {
if (!t || !t.stepType)
throw new RangeError("Invalid input for Step.fromJSON");
let r = tl[t.stepType];
if (!r)
throw new RangeError(`No step type ${t.stepType} defined`);
return r.fromJSON(e, t);
}
/**
To be able to serialize steps to JSON, each step needs a string
ID to attach to its JSON representation. Use this method to
register an ID for your step classes. Try to pick something
that's unlikely to clash with steps from other modules.
*/
static jsonID(e, t) {
if (e in tl)
throw new RangeError("Duplicate use of step JSON ID " + e);
return tl[e] = t, t.prototype.jsonID = e, t;
}
}
class Ee {
/**
@internal
*/
constructor(e, t) {
this.doc = e, this.failed = t;
}
/**
Create a successful step result.
*/
static ok(e) {
return new Ee(e, null);
}
/**
Create a failed step result.
*/
static fail(e) {
return new Ee(null, e);
}
/**
Call [`Node.replace`](https://prosemirror.net/docs/ref/#model.Node.replace) with the given
arguments. Create a successful result if it succeeds, and a
failed one if it throws a `ReplaceError`.
*/
static fromReplace(e, t, r, o) {
try {
return Ee.ok(e.replace(t, r, o));
} catch (i) {
if (i instanceof Vi)
return Ee.fail(i.message);
throw i;
}
}
}
function ka(n, e, t) {
let r = [];
for (let o = 0; o < n.childCount; o++) {
let i = n.child(o);
i.content.size && (i = i.copy(ka(i.content, e, i))), i.isInline && (i = e(i, t, o)), r.push(i);
}
return D.fromArray(r);
}
class _n extends Ke {
/**
Create a mark step.
*/
constructor(e, t, r) {
super(), this.from = e, this.to = t, this.mark = r;
}
apply(e) {
let t = e.slice(this.from, this.to), r = e.resolve(this.from), o = r.node(r.sharedDepth(this.to)), i = new z(ka(t.content, (s, l) => !s.isAtom || !l.type.allowsMarkType(this.mark.type) ? s : s.mark(this.mark.addToSet(s.marks)), o), t.openStart, t.openEnd);
return Ee.fromReplace(e, this.from, this.to, i);
}
invert() {
return new zt(this.from, this.to, this.mark);
}
map(e) {
let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1);
return t.deleted && r.deleted || t.pos >= r.pos ? null : new _n(t.pos, r.pos, this.mark);
}
merge(e) {
return e instanceof _n && e.mark.eq(this.mark) && this.from <= e.to && this.to >= e.from ? new _n(Math.min(this.from, e.from), Math.max(this.to, e.to), this.mark) : null;
}
toJSON() {
return {
stepType: "addMark",
mark: this.mark.toJSON(),
from: this.from,
to: this.to
};
}
/**
@internal
*/
static fromJSON(e, t) {
if (typeof t.from != "number" || typeof t.to != "number")
throw new RangeError("Invalid input for AddMarkStep.fromJSON");
return new _n(t.from, t.to, e.markFromJSON(t.mark));
}
}
Ke.jsonID("addMark", _n);
class zt extends Ke {
/**
Create a mark-removing step.
*/
constructor(e, t, r) {
super(), this.from = e, this.to = t, this.mark = r;
}
apply(e) {
let t = e.slice(this.from, this.to), r = new z(ka(t.content, (o) => o.mark(this.mark.removeFromSet(o.marks)), e), t.openStart, t.openEnd);
return Ee.fromReplace(e, this.from, this.to, r);
}
invert() {
return new _n(this.from, this.to, this.mark);
}
map(e) {
let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1);
return t.deleted && r.deleted || t.pos >= r.pos ? null : new zt(t.pos, r.pos, this.mark);
}
merge(e) {
return e instanceof zt && e.mark.eq(this.mark) && this.from <= e.to && this.to >= e.from ? new zt(Math.min(this.from, e.from), Math.max(this.to, e.to), this.mark) : null;
}
toJSON() {
return {
stepType: "removeMark",
mark: this.mark.toJSON(),
from: this.from,
to: this.to
};
}
/**
@internal
*/
static fromJSON(e, t) {
if (typeof t.from != "number" || typeof t.to != "number")
throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");
return new zt(t.from, t.to, e.markFromJSON(t.mark));
}
}
Ke.jsonID("removeMark", zt);
class Ln extends Ke {
/**
Create a node mark step.
*/
constructor(e, t) {
super(), this.pos = e, this.mark = t;
}
apply(e) {
let t = e.nodeAt(this.pos);
if (!t)
return Ee.fail("No node at mark step's position");
let r = t.type.create(t.attrs, null, this.mark.addToSet(t.marks));
return Ee.fromReplace(e, this.pos, this.pos + 1, new z(D.from(r), 0, t.isLeaf ? 0 : 1));
}
invert(e) {
let t = e.nodeAt(this.pos);
if (t) {
let r = this.mark.addToSet(t.marks);
if (r.length == t.marks.length) {
for (let o = 0; o < t.marks.length; o++)
if (!t.marks[o].isInSet(r))
return new Ln(this.pos, t.marks[o]);
return new Ln(this.pos, this.mark);
}
}
return new wr(this.pos, this.mark);
}
map(e) {
let t = e.mapResult(this.pos, 1);
return t.deletedAfter ? null : new Ln(t.pos, this.mark);
}
toJSON() {
return { stepType: "addNodeMark", pos: this.pos, mark: this.mark.toJSON() };
}
/**
@internal
*/
static fromJSON(e, t) {
if (typeof t.pos != "number")
throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");
return new Ln(t.pos, e.markFromJSON(t.mark));
}
}
Ke.jsonID("addNodeMark", Ln);
class wr extends Ke {
/**
Create a mark-removing step.
*/
constructor(e, t) {
super(), this.pos = e, this.mark = t;
}
apply(e) {
let t = e.nodeAt(this.pos);
if (!t)
return Ee.fail("No node at mark step's position");
let r = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks));
return Ee.fromReplace(e, this.pos, this.pos + 1, new z(D.from(r), 0, t.isLeaf ? 0 : 1));
}
invert(e) {
let t = e.nodeAt(this.pos);
return !t || !this.mark.isInSet(t.marks) ? this : new Ln(this.pos, this.mark);
}
map(e) {
let t = e.mapResult(this.pos, 1);
return t.deletedAfter ? null : new wr(t.pos, this.mark);
}
toJSON() {
return { stepType: "removeNodeMark", pos: this.pos, mark: this.mark.toJSON() };
}
/**
@internal
*/
static fromJSON(e, t) {
if (typeof t.pos != "number")
throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
return new wr(t.pos, e.markFromJSON(t.mark));
}
}
Ke.jsonID("removeNodeMark", wr);
class _e extends Ke {
/**
The given `slice` should fit the 'gap' between `from` and
`to`—the depths must line up, and the surrounding nodes must be
able to be joined with the open sides of the slice. When
`structure` is true, the step will fail if the content between
from and to is not just a sequence of closing and then opening
tokens (this is to guard against rebased replace steps
overwriting something they weren't supposed to).
*/
constructor(e, t, r, o = !1) {
super(), this.from = e, this.to = t, this.slice = r, this.structure = o;
}
apply(e) {
return this.structure && Vl(e, this.from, this.to) ? Ee.fail("Structure replace would overwrite content") : Ee.fromReplace(e, this.from, this.to, this.slice);
}
getMap() {
return new lt([this.from, this.to - this.from, this.slice.size]);
}
invert(e) {
return new _e(this.from, this.from + this.slice.size, e.slice(this.from, this.to));
}
map(e) {
let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1);
return t.deletedAcross && r.deletedAcross ? null : new _e(t.pos, Math.max(t.pos, r.pos), this.slice, this.structure);
}
merge(e) {
if (!(e instanceof _e) || e.structure || this.structure)
return null;
if (this.from + this.slice.size == e.from && !this.slice.openEnd && !e.slice.openStart) {
let t = this.slice.size + e.slice.size == 0 ? z.empty : new z(this.slice.content.append(e.slice.content), this.slice.openStart, e.slice.openEnd);
return new _e(this.from, this.to + (e.to - e.from), t, this.structure);
} else if (e.to == this.from && !this.slice.openStart && !e.slice.openEnd) {
let t = this.slice.size + e.slice.size == 0 ? z.empty : new z(e.slice.content.append(this.slice.content), e.slice.openStart, this.slice.openEnd);
return new _e(e.from, this.to, t, this.structure);
} else
return null;
}
toJSON() {
let e = { stepType: "replace", from: this.from, to: this.to };
return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
}
/**
@internal
*/
static fromJSON(e, t) {
if (typeof t.from != "number" || typeof t.to != "number")
throw new RangeError("Invalid input for ReplaceStep.fromJSON");
return new _e(t.from, t.to, z.fromJSON(e, t.slice), !!t.structure);
}
}
Ke.jsonID("replace", _e);
class Le extends Ke {
/**
Create a replace-around step with the given range and gap.
`insert` should be the point in the slice into which the content
of the gap should be moved. `structure` has the same meaning as
it has in the [`ReplaceStep`](https://prosemirror.net/docs/ref/#transform.ReplaceStep) class.
*/
constructor(e, t, r, o, i, s, l = !1) {
super(), this.from = e, this.to = t, this.gapFrom = r, this.gapTo = o, this.slice = i, this.insert = s, this.structure = l;
}
apply(e) {
if (this.structure && (Vl(e, this.from, this.gapFrom) || Vl(e, this.gapTo, this.to)))
return Ee.fail("Structure gap-replace would overwrite content");
let t = e.slice(this.gapFrom, this.gapTo);
if (t.openStart || t.openEnd)
return Ee.fail("Gap is not a flat range");
let r = this.slice.insertAt(this.insert, t.content);
return r ? Ee.fromReplace(e, this.from, this.to, r) : Ee.fail("Content does not fit in gap");
}
getMap() {
return new lt([
this.from,
this.gapFrom - this.from,
this.insert,
this.gapTo,
this.to - this.gapTo,
this.slice.size - this.insert
]);
}
invert(e) {
let t = this.gapTo - this.gapFrom;
return new Le(this.from, this.from + this.slice.size + t, this.from + this.insert, this.from + this.insert + t, e.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
}
map(e) {
let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1), o = this.from == this.gapFrom ? t.pos : e.map(this.gapFrom, -1), i = this.to == this.gapTo ? r.pos : e.map(this.gapTo, 1);
return t.deletedAcross && r.deletedAcross || o < t.pos || i > r.pos ? null : new Le(t.pos, r.pos, o, i, this.slice, this.insert, this.structure);
}
toJSON() {
let e = {
stepType: "replaceAround",
from: this.from,
to: this.to,
gapFrom: this.gapFrom,
gapTo: this.gapTo,
insert: this.insert
};
return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e;
}
/**
@internal
*/
static fromJSON(e, t) {
if (typeof t.from != "number" || typeof t.to != "number" || typeof t.gapFrom != "number" || typeof t.gapTo != "number" || typeof t.insert != "number")
throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
return new Le(t.from, t.to, t.gapFrom, t.gapTo, z.fromJSON(e, t.slice), t.insert, !!t.structure);
}
}
Ke.jsonID("replaceAround", Le);
function Vl(n, e, t) {
let r = n.resolve(e), o = t - e, i = r.depth;
for (; o > 0 && i > 0 && r.indexAfter(i) == r.node(i).childCount; )
i--, o--;
if (o > 0) {
let s = r.node(i).maybeChild(r.indexAfter(i));
for (; o > 0; ) {
if (!s || s.isLeaf)
return !0;
s = s.firstChild, o--;
}
}
return !1;
}
function jb(n, e, t, r) {
let o = [], i = [], s, l;
n.doc.nodesBetween(e, t, (a, c, p) => {
if (!a.isInline)
return;
let u = a.marks;
if (!r.isInSet(u) && p.type.allowsMarkType(r.type)) {
let f = Math.max(c, e), h = Math.min(c + a.nodeSize, t), b = r.addToSet(u);
for (let m = 0; m < u.length; m++)
u[m].isInSet(b) || (s && s.to == f && s.mark.eq(u[m]) ? s.to = h : o.push(s = new zt(f, h, u[m])));
l && l.to == f ? l.to = h : i.push(l = new _n(f, h, r));
}
}), o.forEach((a) => n.step(a)), i.forEach((a) => n.step(a));
}
function zb(n, e, t, r) {
let o = [], i = 0;
n.doc.nodesBetween(e, t, (s, l) => {
if (!s.isInline)
return;
i++;
let a = null;
if (r instanceof Ls) {
let c = s.marks, p;
for (; p = r.isInSet(c); )
(a || (a = [])).push(p), c = p.removeFromSet(c);
} else r ? r.isInSet(s.marks) && (a = [r]) : a = s.marks;
if (a && a.length) {
let c = Math.min(l + s.nodeSize, t);
for (let p = 0; p < a.length; p++) {
let u = a[p], f;
for (let h = 0; h < o.length; h++) {
let b = o[h];
b.step == i - 1 && u.eq(o[h].style) && (f = b);
}
f ? (f.to = c, f.step = i) : o.push({ style: u, from: Math.max(l, e), to: c, step: i });
}
}
}), o.forEach((s) => n.step(new zt(s.from, s.to, s.style)));
}
function Ca(n, e, t, r = t.contentMatch, o = !0) {
let i = n.doc.nodeAt(e), s = [], l = e + 1;
for (let a = 0; a < i.childCount; a++) {
let c = i.child(a), p = l + c.nodeSize, u = r.matchType(c.type);
if (!u)
s.push(new _e(l, p, z.empty));
else {
r = u;
for (let f = 0; f < c.marks.length; f++)
t.allowsMarkType(c.marks[f].type) || n.step(new zt(l, p, c.marks[f]));
if (o && c.isText && t.whitespace != "pre") {
let f, h = /\r?\n|\r/g, b;
for (; f = h.exec(c.text); )
b || (b = new z(D.from(t.schema.text(" ", t.allowedMarks(c.marks))), 0, 0)), s.push(new _e(l + f.index, l + f.index + f[0].length, b));
}
}
l = p;
}
if (!r.validEnd) {
let a = r.fillBefore(D.empty, !0);
n.replace(l, l, new z(a, 0, 0));
}
for (let a = s.length - 1; a >= 0; a--)
n.step(s[a]);
}
function Vb(n, e, t) {
return (e == 0 || n.canReplace(e, n.childCount)) && (t == n.childCount || n.canReplace(0, t));
}
function io(n) {
let t = n.parent.content.cutByIndex(n.startIndex, n.endIndex);
for (let r = n.depth; ; --r) {
let o = n.$from.node(r), i = n.$from.index(r), s = n.$to.indexAfter(r);
if (r < n.depth && o.canReplace(i, s, t))
return r;
if (r == 0 || o.type.spec.isolating || !Vb(o, i, s))
break;
}
return null;
}
function Wb(n, e, t) {
let { $from: r, $to: o, depth: i } = e, s = r.before(i + 1), l = o.after(i + 1), a = s, c = l, p = D.empty, u = 0;
for (let b = i, m = !1; b > t; b--)
m || r.index(b) > 0 ? (m = !0, p = D.from(r.node(b).copy(p)), u++) : a--;
let f = D.empty, h = 0;
for (let b = i, m = !1; b > t; b--)
m || o.after(b + 1) < o.end(b) ? (m = !0, f = D.from(o.node(b).copy(f)), h++) : c++;
n.step(new Le(a, c, s, l, new z(p.append(f), u, h), p.size - u, !0));
}
function Ma(n, e, t = null, r = n) {
let o = Ub(n, e), i = o && qb(r, e);
return i ? o.map(Dc).concat({ type: e, attrs: t }).concat(i.map(Dc)) : null;
}
function Dc(n) {
return { type: n, attrs: null };
}
function Ub(n, e) {
let { parent: t, startIndex: r, endIndex: o } = n, i = t.contentMatchAt(r).findWrapping(e);
if (!i)
return null;
let s = i.length ? i[0] : e;
return t.canReplaceWith(r, o, s) ? i : null;
}
function qb(n, e) {
let { parent: t, startIndex: r, endIndex: o } = n, i = t.child(r), s = e.contentMatch.findWrapping(i.type);
if (!s)
return null;
let a = (s.length ? s[s.length - 1] : e).contentMatch;
for (let c = r; a && c < o; c++)
a = a.matchType(t.child(c).type);
return !a || !a.validEnd ? null : s;
}
function Kb(n, e, t) {
let r = D.empty;
for (let s = t.length - 1; s >= 0; s--) {
if (r.size) {
let l = t[s].type.contentMatch.matchFragment(r);
if (!l || !l.validEnd)
throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper");
}
r = D.from(t[s].type.create(t[s].attrs, r));
}
let o = e.start, i = e.end;
n.step(new Le(o, i, o, i, new z(r, 0, 0), t.length, !0));
}
function Gb(n, e, t, r, o) {
if (!r.isTextblock)
throw new RangeError("Type given to setBlockType should be a textblock");
let i = n.steps.length;
n.doc.nodesBetween(e, t, (s, l) => {
let a = typeof o == "function" ? o(s) : o;
if (s.isTextblock && !s.hasMarkup(r, a) && Jb(n.doc, n.mapping.slice(i).map(l), r)) {
let c = null;
if (r.schema.linebreakReplacement) {
let h = r.whitespace == "pre", b = !!r.contentMatch.matchType(r.schema.linebreakReplacement);
h && !b ? c = !1 : !h && b && (c = !0);
}
c === !1 && od(n, s, l, i), Ca(n, n.mapping.slice(i).map(l, 1), r, void 0, c === null);
let p = n.mapping.slice(i), u = p.map(l, 1), f = p.map(l + s.nodeSize, 1);
return n.step(new Le(u, f, u + 1, f - 1, new z(D.from(r.create(a, null, s.marks)), 0, 0), 1, !0)), c === !0 && rd(n, s, l, i), !1;
}
});
}
function rd(n, e, t, r) {
e.forEach((o, i) => {
if (o.isText) {
let s, l = /\r?\n|\r/g;
for (; s = l.exec(o.text); ) {
let a = n.mapping.slice(r).map(t + 1 + i + s.index);
n.replaceWith(a, a + 1, e.type.schema.linebreakReplacement.create());
}
}
});
}
function od(n, e, t, r) {
e.forEach((o, i) => {
if (o.type == o.type.schema.linebreakReplacement) {
let s = n.mapping.slice(r).map(t + 1 + i);
n.replaceWith(s, s + 1, e.type.schema.text(`
`));
}
});
}
function Jb(n, e, t) {
let r = n.resolve(e), o = r.index();
return r.parent.canReplaceWith(o, o + 1, t);
}
function Yb(n, e, t, r, o) {
let i = n.doc.nodeAt(e);
if (!i)
throw new RangeError("No node at given position");
t || (t = i.type);
let s = t.create(r, null, o || i.marks);
if (i.isLeaf)
return n.replaceWith(e, e + i.nodeSize, s);
if (!t.validContent(i.content))
throw new RangeError("Invalid content for node type " + t.name);
n.step(new Le(e, e + i.nodeSize, e + 1, e + i.nodeSize - 1, new z(D.from(s), 0, 0), 1, !0));
}
function an(n, e, t = 1, r) {
let o = n.resolve(e), i = o.depth - t, s = r && r[r.length - 1] || o.parent;
if (i < 0 || o.parent.type.spec.isolating || !o.parent.canReplace(o.index(), o.parent.childCount) || !s.type.validContent(o.parent.content.cutByIndex(o.index(), o.parent.childCount)))
return !1;
for (let c = o.depth - 1, p = t - 2; c > i; c--, p--) {
let u = o.node(c), f = o.index(c);
if (u.type.spec.isolating)
return !1;
let h = u.content.cutByIndex(f, u.childCount), b = r && r[p + 1];
b && (h = h.replaceChild(0, b.type.create(b.attrs)));
let m = r && r[p] || u;
if (!u.canReplace(f + 1, u.childCount) || !m.type.validContent(h))
return !1;
}
let l = o.indexAfter(i), a = r && r[0];
return o.node(i).canReplaceWith(l, l, a ? a.type : o.node(i + 1).type);
}
function Xb(n, e, t = 1, r) {
let o = n.doc.resolve(e), i = D.empty, s = D.empty;
for (let l = o.depth, a = o.depth - t, c = t - 1; l > a; l--, c--) {
i = D.from(o.node(l).copy(i));
let p = r && r[c];
s = D.from(p ? p.type.create(p.attrs, s) : o.node(l).copy(s));
}
n.step(new _e(e, e, new z(i.append(s), t, t), !0));
}
function Wn(n, e) {
let t = n.resolve(e), r = t.index();
return id(t.nodeBefore, t.nodeAfter) && t.parent.canReplace(r, r + 1);
}
function Qb(n, e) {
e.content.size || n.type.compatibleContent(e.type);
let t = n.contentMatchAt(n.childCount), { linebreakReplacement: r } = n.type.schema;
for (let o = 0; o < e.childCount; o++) {
let i = e.child(o), s = i.type == r ? n.type.schema.nodes.text : i.type;
if (t = t.matchType(s), !t || !n.type.allowsMarks(i.marks))
return !1;
}
return t.validEnd;
}
function id(n, e) {
return !!(n && e && !n.isLeaf && Qb(n, e));
}
function Ns(n, e, t = -1) {
let r = n.resolve(e);
for (let o = r.depth; ; o--) {
let i, s, l = r.index(o);
if (o == r.depth ? (i = r.nodeBefore, s = r.nodeAfter) : t > 0 ? (i = r.node(o + 1), l++, s = r.node(o).maybeChild(l)) : (i = r.node(o).maybeChild(l - 1), s = r.node(o + 1)), i && !i.isTextblock && id(i, s) && r.node(o).canReplace(l, l + 1))
return e;
if (o == 0)
break;
e = t < 0 ? r.before(o) : r.after(o);
}
}
function Zb(n, e, t) {
let r = null, { linebreakReplacement: o } = n.doc.type.schema, i = n.doc.resolve(e - t), s = i.node().type;
if (o && s.inlineContent) {
let p = s.whitespace == "pre", u = !!s.contentMatch.matchType(o);
p && !u ? r = !1 : !p && u && (r = !0);
}
let l = n.steps.length;
if (r === !1) {
let p = n.doc.resolve(e + t);
od(n, p.node(), p.before(), l);
}
s.inlineContent && Ca(n, e + t - 1, s, i.node().contentMatchAt(i.index()), r == null);
let a = n.mapping.slice(l), c = a.map(e - t);
if (n.step(new _e(c, a.map(e + t, -1), z.empty, !0)), r === !0) {
let p = n.doc.resolve(c);
rd(n, p.node(), p.before(), n.steps.length);
}
return n;
}
function em(n, e, t) {
let r = n.resolve(e);
if (r.parent.canReplaceWith(r.index(), r.index(), t))
return e;
if (r.parentOffset == 0)
for (let o = r.depth - 1; o >= 0; o--) {
let i = r.index(o);
if (r.node(o).canReplaceWith(i, i, t))
return r.before(o + 1);
if (i > 0)
return null;
}
if (r.parentOffset == r.parent.content.size)
for (let o = r.depth - 1; o >= 0; o--) {
let i = r.indexAfter(o);
if (r.node(o).canReplaceWith(i, i, t))
return r.after(o + 1);
if (i < r.node(o).childCount)
return null;
}
return null;
}
function sd(n, e, t) {
let r = n.resolve(e);
if (!t.content.size)
return e;
let o = t.content;
for (let i = 0; i < t.openStart; i++)
o = o.firstChild.content;
for (let i = 1; i <= (t.openStart == 0 && t.size ? 2 : 1); i++)
for (let s = r.depth; s >= 0; s--) {
let l = s == r.depth ? 0 : r.pos <= (r.start(s + 1) + r.end(s + 1)) / 2 ? -1 : 1, a = r.index(s) + (l > 0 ? 1 : 0), c = r.node(s), p = !1;
if (i == 1)
p = c.canReplace(a, a, o);
else {
let u = c.contentMatchAt(a).findWrapping(o.firstChild.type);
p = u && c.canReplaceWith(a, a, u[0]);
}
if (p)
return l == 0 ? r.pos : l < 0 ? r.before(s + 1) : r.after(s + 1);
}
return null;
}
function Ds(n, e, t = e, r = z.empty) {
if (e == t && !r.size)
return null;
let o = n.resolve(e), i = n.resolve(t);
return ld(o, i, r) ? new _e(e, t, r) : new tm(o, i, r).fit();
}
function ld(n, e, t) {
return !t.openStart && !t.openEnd && n.start() == e.start() && n.parent.canReplace(n.index(), e.index(), t.content);
}
class tm {
constructor(e, t, r) {
this.$from = e, this.$to = t, this.unplaced = r, this.frontier = [], this.placed = D.empty;
for (let o = 0; o <= e.depth; o++) {
let i = e.node(o);
this.frontier.push({
type: i.type,
match: i.contentMatchAt(e.indexAfter(o))
});
}
for (let o = e.depth; o > 0; o--)
this.placed = D.from(e.node(o).copy(this.placed));
}
get depth() {
return this.frontier.length - 1;
}
fit() {
for (; this.unplaced.size; ) {
let c = this.findFittable();
c ? this.placeNodes(c) : this.openMore() || this.dropNode();
}
let e = this.mustMoveInline(), t = this.placed.size - this.depth - this.$from.depth, r = this.$from, o = this.close(e < 0 ? this.$to : r.doc.resolve(e));
if (!o)
return null;
let i = this.placed, s = r.depth, l = o.depth;
for (; s && l && i.childCount == 1; )
i = i.firstChild.content, s--, l--;
let a = new z(i, s, l);
return e > -1 ? new Le(r.pos, e, this.$to.pos, this.$to.end(), a, t) : a.size || r.pos != this.$to.pos ? new _e(r.pos, o.pos, a) : null;
}
// Find a position on the start spine of `this.unplaced` that has
// content that can be moved somewhere on the frontier. Returns two
// depths, one for the slice and one for the frontier.
findFittable() {
let e = this.unplaced.openStart;
for (let t = this.unplaced.content, r = 0, o = this.unplaced.openEnd; r < e; r++) {
let i = t.firstChild;
if (t.childCount > 1 && (o = 0), i.type.spec.isolating && o <= r) {
e = r;
break;
}
t = i.content;
}
for (let t = 1; t <= 2; t++)
for (let r = t == 1 ? e : this.unplaced.openStart; r >= 0; r--) {
let o, i = null;
r ? (i = nl(this.unplaced.content, r - 1).firstChild, o = i.content) : o = this.unplaced.content;
let s = o.firstChild;
for (let l = this.depth; l >= 0; l--) {
let { type: a, match: c } = this.frontier[l], p, u = null;
if (t == 1 && (s ? c.matchType(s.type) || (u = c.fillBefore(D.from(s), !1)) : i && a.compatibleContent(i.type)))
return { sliceDepth: r, frontierDepth: l, parent: i, inject: u };
if (t == 2 && s && (p = c.findWrapping(s.type)))
return { sliceDepth: r, frontierDepth: l, parent: i, wrap: p };
if (i && c.matchType(i.type))
break;
}
}
}
openMore() {
let { content: e, openStart: t, openEnd: r } = this.unplaced, o = nl(e, t);
return !o.childCount || o.firstChild.isLeaf ? !1 : (this.unplaced = new z(e, t + 1, Math.max(r, o.size + t >= e.size - r ? t + 1 : 0)), !0);
}
dropNode() {
let { content: e, openStart: t, openEnd: r } = this.unplaced, o = nl(e, t);
if (o.childCount <= 1 && t > 0) {
let i = e.size - t <= t + o.size;
this.unplaced = new z(bo(e, t - 1, 1), t - 1, i ? t - 1 : r);
} else
this.unplaced = new z(bo(e, t, 1), t, r);
}
// Move content from the unplaced slice at `sliceDepth` to the
// frontier node at `frontierDepth`. Close that frontier node when
// applicable.
placeNodes({ sliceDepth: e, frontierDepth: t, parent: r, inject: o, wrap: i }) {
for (; this.depth > t; )
this.closeFrontierNode();
if (i)
for (let m = 0; m < i.length; m++)
this.openFrontierNode(i[m]);
let s = this.unplaced, l = r ? r.content : s.content, a = s.openStart - e, c = 0, p = [], { match: u, type: f } = this.frontier[t];
if (o) {
for (let m = 0; m < o.childCount; m++)
p.push(o.child(m));
u = u.matchFragment(o);
}
let h = l.size + e - (s.content.size - s.openEnd);
for (; c < l.childCount; ) {
let m = l.child(c), x = u.matchType(m.type);
if (!x)
break;
c++, (c > 1 || a == 0 || m.content.size) && (u = x, p.push(ad(m.mark(f.allowedMarks(m.marks)), c == 1 ? a : 0, c == l.childCount ? h : -1)));
}
let b = c == l.childCount;
b || (h = -1), this.placed = mo(this.placed, t, D.from(p)), this.frontier[t].match = u, b && h < 0 && r && r.type == this.frontier[this.depth].type && this.frontier.length > 1 && this.closeFrontierNode();
for (let m = 0, x = l; m < h; m++) {
let v = x.lastChild;
this.frontier.push({ type: v.type, match: v.contentMatchAt(v.childCount) }), x = v.content;
}
this.unplaced = b ? e == 0 ? z.empty : new z(bo(s.content, e - 1, 1), e - 1, h < 0 ? s.openEnd : e - 1) : new z(bo(s.content, e, c), s.openStart, s.openEnd);
}
mustMoveInline() {
if (!this.$to.parent.isTextblock)
return -1;
let e = this.frontier[this.depth], t;
if (!e.type.isTextblock || !rl(this.$to, this.$to.depth, e.type, e.match, !1) || this.$to.depth == this.depth && (t = this.findCloseLevel(this.$to)) && t.depth == this.depth)
return -1;
let { depth: r } = this.$to, o = this.$to.after(r);
for (; r > 1 && o == this.$to.end(--r); )
++o;
return o;
}
findCloseLevel(e) {
e: for (let t = Math.min(this.depth, e.depth); t >= 0; t--) {
let { match: r, type: o } = this.frontier[t], i = t < e.depth && e.end(t + 1) == e.pos + (e.depth - (t + 1)), s = rl(e, t, o, r, i);
if (s) {
for (let l = t - 1; l >= 0; l--) {
let { match: a, type: c } = this.frontier[l], p = rl(e, l, c, a, !0);
if (!p || p.childCount)
continue e;
}
return { depth: t, fit: s, move: i ? e.doc.resolve(e.after(t + 1)) : e };
}
}
}
close(e) {
let t = this.findCloseLevel(e);
if (!t)
return null;
for (; this.depth > t.depth; )
this.closeFrontierNode();
t.fit.childCount && (this.placed = mo(this.placed, t.depth, t.fit)), e = t.move;
for (let r = t.depth + 1; r <= e.depth; r++) {
let o = e.node(r), i = o.type.contentMatch.fillBefore(o.content, !0, e.index(r));
this.openFrontierNode(o.type, o.attrs, i);
}
return e;
}
openFrontierNode(e, t = null, r) {
let o = this.frontier[this.depth];
o.match = o.match.matchType(e), this.placed = mo(this.placed, this.depth, D.from(e.create(t, r))), this.frontier.push({ type: e, match: e.contentMatch });
}
closeFrontierNode() {
let t = this.frontier.pop().match.fillBefore(D.empty, !0);
t.childCount && (this.placed = mo(this.placed, this.frontier.length, t));
}
}
function bo(n, e, t) {
return e == 0 ? n.cutByIndex(t, n.childCount) : n.replaceChild(0, n.firstChild.copy(bo(n.firstChild.content, e - 1, t)));
}
function mo(n, e, t) {
return e == 0 ? n.append(t) : n.replaceChild(n.childCount - 1, n.lastChild.copy(mo(n.lastChild.content, e - 1, t)));
}
function nl(n, e) {
for (let t = 0; t < e; t++)
n = n.firstChild.content;
return n;
}
function ad(n, e, t) {
if (e <= 0)
return n;
let r = n.content;
return e > 1 && (r = r.replaceChild(0, ad(r.firstChild, e - 1, r.childCount == 1 ? t - 1 : 0))), e > 0 && (r = n.type.contentMatch.fillBefore(r).append(r), t <= 0 && (r = r.append(n.type.contentMatch.matchFragment(r).fillBefore(D.empty, !0)))), n.copy(r);
}
function rl(n, e, t, r, o) {
let i = n.node(e), s = o ? n.indexAfter(e) : n.index(e);
if (s == i.childCount && !t.compatibleContent(i.type))
return null;
let l = r.fillBefore(i.content, !0, s);
return l && !nm(t, i.content, s) ? l : null;
}
function nm(n, e, t) {
for (let r = t; r < e.childCount; r++)
if (!n.allowsMarks(e.child(r).marks))
return !0;
return !1;
}
function rm(n) {
return n.spec.defining || n.spec.definingForContent;
}
function om(n, e, t, r) {
if (!r.size)
return n.deleteRange(e, t);
let o = n.doc.resolve(e), i = n.doc.resolve(t);
if (ld(o, i, r))
return n.step(new _e(e, t, r));
let s = pd(o, n.doc.resolve(t));
s[s.length - 1] == 0 && s.pop();
let l = -(o.depth + 1);
s.unshift(l);
for (let f = o.depth, h = o.pos - 1; f > 0; f--, h--) {
let b = o.node(f).type.spec;
if (b.defining || b.definingAsContext || b.isolating)
break;
s.indexOf(f) > -1 ? l = f : o.before(f) == h && s.splice(1, 0, -f);
}
let a = s.indexOf(l), c = [], p = r.openStart;
for (let f = r.content, h = 0; ; h++) {
let b = f.firstChild;
if (c.push(b), h == r.openStart)
break;
f = b.content;
}
for (let f = p - 1; f >= 0; f--) {
let h = c[f], b = rm(h.type);
if (b && !h.sameMarkup(o.node(Math.abs(l) - 1)))
p = f;
else if (b || !h.type.isTextblock)
break;
}
for (let f = r.openStart; f >= 0; f--) {
let h = (f + p + 1) % (r.openStart + 1), b = c[h];
if (b)
for (let m = 0; m < s.length; m++) {
let x = s[(m + a) % s.length], v = !0;
x < 0 && (v = !1, x = -x);
let C = o.node(x - 1), S = o.index(x - 1);
if (C.canReplaceWith(S, S, b.type, b.marks))
return n.replace(o.before(x), v ? i.after(x) : t, new z(cd(r.content, 0, r.openStart, h), h, r.openEnd));
}
}
let u = n.steps.length;
for (let f = s.length - 1; f >= 0 && (n.replace(e, t, r), !(n.steps.length > u)); f--) {
let h = s[f];
h < 0 || (e = o.before(h), t = i.after(h));
}
}
function cd(n, e, t, r, o) {
if (e < t) {
let i = n.firstChild;
n = n.replaceChild(0, i.copy(cd(i.content, e + 1, t, r, i)));
}
if (e > r) {
let i = o.contentMatchAt(0), s = i.fillBefore(n).append(n);
n = s.append(i.matchFragment(s).fillBefore(D.empty, !0));
}
return n;
}
function im(n, e, t, r) {
if (!r.isInline && e == t && n.doc.resolve(e).parent.content.size) {
let o = em(n.doc, e, r.type);
o != null && (e = t = o);
}
n.replaceRange(e, t, new z(D.from(r), 0, 0));
}
function sm(n, e, t) {
let r = n.doc.resolve(e), o = n.doc.resolve(t), i = pd(r, o);
for (let s = 0; s < i.length; s++) {
let l = i[s], a = s == i.length - 1;
if (a && l == 0 || r.node(l).type.contentMatch.validEnd)
return n.delete(r.start(l), o.end(l));
if (l > 0 && (a || r.node(l - 1).canReplace(r.index(l - 1), o.indexAfter(l - 1))))
return n.delete(r.before(l), o.after(l));
}
for (let s = 1; s <= r.depth && s <= o.depth; s++)
if (e - r.start(s) == r.depth - s && t > r.end(s) && o.end(s) - t != o.depth - s && r.start(s - 1) == o.start(s - 1) && r.node(s - 1).canReplace(r.index(s - 1), o.index(s - 1)))
return n.delete(r.before(s), t);
n.delete(e, t);
}
function pd(n, e) {
let t = [], r = Math.min(n.depth, e.depth);
for (let o = r; o >= 0; o--) {
let i = n.start(o);
if (i < n.pos - (n.depth - o) || e.end(o) > e.pos + (e.depth - o) || n.node(o).type.spec.isolating || e.node(o).type.spec.isolating)
break;
(i == e.start(o) || o == n.depth && o == e.depth && n.parent.inlineContent && e.parent.inlineContent && o && e.start(o - 1) == i - 1) && t.push(o);
}
return t;
}
class Ur extends Ke {
/**
Construct an attribute step.
*/
constructor(e, t, r) {
super(), this.pos = e, this.attr = t, this.value = r;
}
apply(e) {
let t = e.nodeAt(this.pos);
if (!t)
return Ee.fail("No node at attribute step's position");
let r = /* @__PURE__ */ Object.create(null);
for (let i in t.attrs)
r[i] = t.attrs[i];
r[this.attr] = this.value;
let o = t.type.create(r, null, t.marks);
return Ee.fromReplace(e, this.pos, this.pos + 1, new z(D.from(o), 0, t.isLeaf ? 0 : 1));
}
getMap() {
return lt.empty;
}
invert(e) {
return new Ur(this.pos, this.attr, e.nodeAt(this.pos).attrs[this.attr]);
}
map(e) {
let t = e.mapResult(this.pos, 1);
return t.deletedAfter ? null : new Ur(t.pos, this.attr, this.value);
}
toJSON() {
return { stepType: "attr", pos: this.pos, attr: this.attr, value: this.value };
}
static fromJSON(e, t) {
if (typeof t.pos != "number" || typeof t.attr != "string")
throw new RangeError("Invalid input for AttrStep.fromJSON");
return new Ur(t.pos, t.attr, t.value);
}
}
Ke.jsonID("attr", Ur);
class Ro extends Ke {
/**
Construct an attribute step.
*/
constructor(e, t) {
super(), this.attr = e, this.value = t;
}
apply(e) {
let t = /* @__PURE__ */ Object.create(null);
for (let o in e.attrs)
t[o] = e.attrs[o];
t[this.attr] = this.value;
let r = e.type.create(t, e.content, e.marks);
return Ee.ok(r);
}
getMap() {
return lt.empty;
}
invert(e) {
return new Ro(this.attr, e.attrs[this.attr]);
}
map(e) {
return this;
}
toJSON() {
return { stepType: "docAttr", attr: this.attr, value: this.value };
}
static fromJSON(e, t) {
if (typeof t.attr != "string")
throw new RangeError("Invalid input for DocAttrStep.fromJSON");
return new Ro(t.attr, t.value);
}
}
Ke.jsonID("docAttr", Ro);
let Kr = class extends Error {
};
Kr = function n(e) {
let t = Error.call(this, e);
return t.__proto__ = n.prototype, t;
};
Kr.prototype = Object.create(Error.prototype);
Kr.prototype.constructor = Kr;
Kr.prototype.name = "TransformError";
class ud {
/**
Create a transform that starts with the given document.
*/
constructor(e) {
this.doc = e, this.steps = [], this.docs = [], this.mapping = new $o();
}
/**
The starting document.
*/
get before() {
return this.docs.length ? this.docs[0] : this.doc;
}
/**
Apply a new step in this transform, saving the result. Throws an
error when the step fails.
*/
step(e) {
let t = this.maybeStep(e);
if (t.failed)
throw new Kr(t.failed);
return this;
}
/**
Try to apply a step in this transformation, ignoring it if it
fails. Returns the step result.
*/
maybeStep(e) {
let t = e.apply(this.doc);
return t.failed || this.addStep(e, t.doc), t;
}
/**
True when the document has been changed (when there are any
steps).
*/
get docChanged() {
return this.steps.length > 0;
}
/**
@internal
*/
addStep(e, t) {
this.docs.push(this.doc), this.steps.push(e), this.mapping.appendMap(e.getMap()), this.doc = t;
}
/**
Replace the part of the document between `from` and `to` with the
given `slice`.
*/
replace(e, t = e, r = z.empty) {
let o = Ds(this.doc, e, t, r);
return o && this.step(o), this;
}
/**
Replace the given range with the given content, which may be a
fragment, node, or array of nodes.
*/
replaceWith(e, t, r) {
return this.replace(e, t, new z(D.from(r), 0, 0));
}
/**
Delete the content between the given positions.
*/
delete(e, t) {
return this.replace(e, t, z.empty);
}
/**
Insert the given content at the given position.
*/
insert(e, t) {
return this.replaceWith(e, e, t);
}
/**
Replace a range of the document with a given slice, using
`from`, `to`, and the slice's
[`openStart`](https://prosemirror.net/docs/ref/#model.Slice.openStart) property as hints, rather
than fixed start and end points. This method may grow the
replaced area or close open nodes in the slice in order to get a
fit that is more in line with WYSIWYG expectations, by dropping
fully covered parent nodes of the replaced region when they are
marked [non-defining as
context](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext), or including an
open parent node from the slice that _is_ marked as [defining
its content](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).
This is the method, for example, to handle paste. The similar
[`replace`](https://prosemirror.net/docs/ref/#transform.Transform.replace) method is a more
primitive tool which will _not_ move the start and end of its given
range, and is useful in situations where you need more precise
control over what happens.
*/
replaceRange(e, t, r) {
return om(this, e, t, r), this;
}
/**
Replace the given range with a node, but use `from` and `to` as
hints, rather than precise positions. When from and to are the same
and are at the start or end of a parent node in which the given
node doesn't fit, this method may _move_ them out towards a parent
that does allow the given node to be placed. When the given range
completely covers a parent node, this method may completely replace
that parent node.
*/
replaceRangeWith(e, t, r) {
return im(this, e, t, r), this;
}
/**
Delete the given range, expanding it to cover fully covered
parent nodes until a valid replace is found.
*/
deleteRange(e, t) {
return sm(this, e, t), this;
}
/**
Split the content in the given range off from its parent, if there
is sibling content before or after it, and move it up the tree to
the depth specified by `target`. You'll probably want to use
[`liftTarget`](https://prosemirror.net/docs/ref/#transform.liftTarget) to compute `target`, to make
sure the lift is valid.
*/
lift(e, t) {
return Wb(this, e, t), this;
}
/**
Join the blocks around the given position. If depth is 2, their
last and first siblings are also joined, and so on.
*/
join(e, t = 1) {
return Zb(this, e, t), this;
}
/**
Wrap the given [range](https://prosemirror.net/docs/ref/#model.NodeRange) in the given set of wrappers.
The wrappers are assumed to be valid in this position, and should
probably be computed with [`findWrapping`](https://prosemirror.net/docs/ref/#transform.findWrapping).
*/
wrap(e, t) {
return Kb(this, e, t), this;
}
/**
Set the type of all textblocks (partly) between `from` and `to` to
the given node type with the given attributes.
*/
setBlockType(e, t = e, r, o = null) {
return Gb(this, e, t, r, o), this;
}
/**
Change the type, attributes, and/or marks of the node at `pos`.
When `type` isn't given, the existing node type is preserved,
*/
setNodeMarkup(e, t, r = null, o) {
return Yb(this, e, t, r, o), this;
}
/**
Set a single attribute on a given node to a new value.
The `pos` addresses the document content. Use `setDocAttribute`
to set attributes on the document itself.
*/
setNodeAttribute(e, t, r) {
return this.step(new Ur(e, t, r)), this;
}
/**
Set a single attribute on the document to a new value.
*/
setDocAttribute(e, t) {
return this.step(new Ro(e, t)), this;
}
/**
Add a mark to the node at position `pos`.
*/
addNodeMark(e, t) {
return this.step(new Ln(e, t)), this;
}
/**
Remove a mark (or all marks of the given type) from the node at
position `pos`.
*/
removeNodeMark(e, t) {
let r = this.doc.nodeAt(e);
if (!r)
throw new RangeError("No node at position " + e);
if (t instanceof me)
t.isInSet(r.marks) && this.step(new wr(e, t));
else {
let o = r.marks, i, s = [];
for (; i = t.isInSet(o); )
s.push(new wr(e, i)), o = i.removeFromSet(o);
for (let l = s.length - 1; l >= 0; l--)
this.step(s[l]);
}
return this;
}
/**
Split the node at the given position, and optionally, if `depth` is
greater than one, any number of nodes above that. By default, the
parts split off will inherit the node type of the original node.
This can be changed by passing an array of types and attributes to
use after the split (with the outermost nodes coming first).
*/
split(e, t = 1, r) {
return Xb(this, e, t, r), this;
}
/**
Add the given mark to the inline content between `from` and `to`.
*/
addMark(e, t, r) {
return jb(this, e, t, r), this;
}
/**
Remove marks from inline nodes between `from` and `to`. When
`mark` is a single mark, remove precisely that mark. When it is
a mark type, remove all marks of that type. When it is null,
remove all marks of any type.
*/
removeMark(e, t, r) {
return zb(this, e, t, r), this;
}
/**
Removes all marks and nodes from the content of the node at
`pos` that don't match the given new parent node type. Accepts
an optional starting [content match](https://prosemirror.net/docs/ref/#model.ContentMatch) as
third argument.
*/
clearIncompatible(e, t, r) {
return Ca(this, e, t, r), this;
}
}
const ol = /* @__PURE__ */ Object.create(null);
class te {
/**
Initialize a selection with the head and anchor and ranges. If no
ranges are given, constructs a single range across `$anchor` and
`$head`.
*/
constructor(e, t, r) {
this.$anchor = e, this.$head = t, this.ranges = r || [new lm(e.min(t), e.max(t))];
}
/**
The selection's anchor, as an unresolved position.
*/
get anchor() {
return this.$anchor.pos;
}
/**
The selection's head.
*/
get head() {
return this.$head.pos;
}
/**
The lower bound of the selection's main range.
*/
get from() {
return this.$from.pos;
}
/**
The upper bound of the selection's main range.
*/
get to() {
return this.$to.pos;
}
/**
The resolved lower bound of the selection's main range.
*/
get $from() {
return this.ranges[0].$from;
}
/**
The resolved upper bound of the selection's main range.
*/
get $to() {
return this.ranges[0].$to;
}
/**
Indicates whether the selection contains any content.
*/
get empty() {
let e = this.ranges;
for (let t = 0; t < e.length; t++)
if (e[t].$from.pos != e[t].$to.pos)
return !1;
return !0;
}
/**
Get the content of this selection as a slice.
*/
content() {
return this.$from.doc.slice(this.from, this.to, !0);
}
/**
Replace the selection with a slice or, if no slice is given,
delete the selection. Will append to the given transaction.
*/
replace(e, t = z.empty) {
let r = t.content.lastChild, o = null;
for (let l = 0; l < t.openEnd; l++)
o = r, r = r.lastChild;
let i = e.steps.length, s = this.ranges;
for (let l = 0; l < s.length; l++) {
let { $from: a, $to: c } = s[l], p = e.mapping.slice(i);
e.replaceRange(p.map(a.pos), p.map(c.pos), l ? z.empty : t), l == 0 && Rc(e, i, (r ? r.isInline : o && o.isTextblock) ? -1 : 1);
}
}
/**
Replace the selection with the given node, appending the changes
to the given transaction.
*/
replaceWith(e, t) {
let r = e.steps.length, o = this.ranges;
for (let i = 0; i < o.length; i++) {
let { $from: s, $to: l } = o[i], a = e.mapping.slice(r), c = a.map(s.pos), p = a.map(l.pos);
i ? e.deleteRange(c, p) : (e.replaceRangeWith(c, p, t), Rc(e, r, t.isInline ? -1 : 1));
}
}
/**
Find a valid cursor or leaf node selection starting at the given
position and searching back if `dir` is negative, and forward if
positive. When `textOnly` is true, only consider cursor
selections. Will return null when no valid selection position is
found.
*/
static findFrom(e, t, r = !1) {
let o = e.parent.inlineContent ? new Q(e) : Dr(e.node(0), e.parent, e.pos, e.index(), t, r);
if (o)
return o;
for (let i = e.depth - 1; i >= 0; i--) {
let s = t < 0 ? Dr(e.node(0), e.node(i), e.before(i + 1), e.index(i), t, r) : Dr(e.node(0), e.node(i), e.after(i + 1), e.index(i) + 1, t, r);
if (s)
return s;
}
return null;
}
/**
Find a valid cursor or leaf node selection near the given
position. Searches forward first by default, but if `bias` is
negative, it will search backwards first.
*/
static near(e, t = 1) {
return this.findFrom(e, t) || this.findFrom(e, -t) || new ct(e.node(0));
}
/**
Find the cursor or leaf node selection closest to the start of
the given document. Will return an
[`AllSelection`](https://prosemirror.net/docs/ref/#state.AllSelection) if no valid position
exists.
*/
static atStart(e) {
return Dr(e, e, 0, 0, 1) || new ct(e);
}
/**
Find the cursor or leaf node selection closest to the end of the
given document.
*/
static atEnd(e) {
return Dr(e, e, e.content.size, e.childCount, -1) || new ct(e);
}
/**
Deserialize the JSON representation of a selection. Must be
implemented for custom classes (as a static class method).
*/
static fromJSON(e, t) {
if (!t || !t.type)
throw new RangeError("Invalid input for Selection.fromJSON");
let r = ol[t.type];
if (!r)
throw new RangeError(`No selection type ${t.type} defined`);
return r.fromJSON(e, t);
}
/**
To be able to deserialize selections from JSON, custom selection
classes must register themselves with an ID string, so that they
can be disambiguated. Try to pick something that's unlikely to
clash with classes from other modules.
*/
static jsonID(e, t) {
if (e in ol)
throw new RangeError("Duplicate use of selection JSON ID " + e);
return ol[e] = t, t.prototype.jsonID = e, t;
}
/**
Get a [bookmark](https://prosemirror.net/docs/ref/#state.SelectionBookmark) for this selection,
which is a value that can be mapped without having access to a
current document, and later resolved to a real selection for a
given document again. (This is used mostly by the history to
track and restore old selections.) The default implementation of
this method just converts the selection to a text selection and
returns the bookmark for that.
*/
getBookmark() {
return Q.between(this.$anchor, this.$head).getBookmark();
}
}
te.prototype.visible = !0;
class lm {
/**
Create a range.
*/
constructor(e, t) {
this.$from = e, this.$to = t;
}
}
let Ic = !1;
function $c(n) {
!Ic && !n.parent.inlineContent && (Ic = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + n.parent.type.name + ")"));
}
class Q extends te {
/**
Construct a text selection between the given points.
*/
constructor(e, t = e) {
$c(e), $c(t), super(e, t);
}
/**
Returns a resolved position if this is a cursor selection (an
empty text selection), and null otherwise.
*/
get $cursor() {
return this.$anchor.pos == this.$head.pos ? this.$head : null;
}
map(e, t) {
let r = e.resolve(t.map(this.head));
if (!r.parent.inlineContent)
return te.near(r);
let o = e.resolve(t.map(this.anchor));
return new Q(o.parent.inlineContent ? o : r, r);
}
replace(e, t = z.empty) {
if (super.replace(e, t), t == z.empty) {
let r = this.$from.marksAcross(this.$to);
r && e.ensureMarks(r);
}
}
eq(e) {
return e instanceof Q && e.anchor == this.anchor && e.head == this.head;
}
getBookmark() {
return new Is(this.anchor, this.head);
}
toJSON() {
return { type: "text", anchor: this.anchor, head: this.head };
}
/**
@internal
*/
static fromJSON(e, t) {
if (typeof t.anchor != "number" || typeof t.head != "number")
throw new RangeError("Invalid input for TextSelection.fromJSON");
return new Q(e.resolve(t.anchor), e.resolve(t.head));
}
/**
Create a text selection from non-resolved positions.
*/
static create(e, t, r = t) {
let o = e.resolve(t);
return new this(o, r == t ? o : e.resolve(r));
}
/**
Return a text selection that spans the given positions or, if
they aren't text positions, find a text selection near them.
`bias` determines whether the method searches forward (default)
or backwards (negative number) first. Will fall back to calling
[`Selection.near`](https://prosemirror.net/docs/ref/#state.Selection^near) when the document
doesn't contain a valid text position.
*/
static between(e, t, r) {
let o = e.pos - t.pos;
if ((!r || o) && (r = o >= 0 ? 1 : -1), !t.parent.inlineContent) {
let i = te.findFrom(t, r, !0) || te.findFrom(t, -r, !0);
if (i)
t = i.$head;
else
return te.near(t, r);
}
return e.parent.inlineContent || (o == 0 ? e = t : (e = (te.findFrom(e, -r, !0) || te.findFrom(e, r, !0)).$anchor, e.pos < t.pos != o < 0 && (e = t))), new Q(e, t);
}
}
te.jsonID("text", Q);
class Is {
constructor(e, t) {
this.anchor = e, this.head = t;
}
map(e) {
return new Is(e.map(this.anchor), e.map(this.head));
}
resolve(e) {
return Q.between(e.resolve(this.anchor), e.resolve(this.head));
}
}
class J extends te {
/**
Create a node selection. Does not verify the validity of its
argument.
*/
constructor(e) {
let t = e.nodeAfter, r = e.node(0).resolve(e.pos + t.nodeSize);
super(e, r), this.node = t;
}
map(e, t) {
let { deleted: r, pos: o } = t.mapResult(this.anchor), i = e.resolve(o);
return r ? te.near(i) : new J(i);
}
content() {
return new z(D.from(this.node), 0, 0);
}
eq(e) {
return e instanceof J && e.anchor == this.anchor;
}
toJSON() {
return { type: "node", anchor: this.anchor };
}
getBookmark() {
return new Ea(this.anchor);
}
/**
@internal
*/
static fromJSON(e, t) {
if (typeof t.anchor != "number")
throw new RangeError("Invalid input for NodeSelection.fromJSON");
return new J(e.resolve(t.anchor));
}
/**
Create a node selection from non-resolved positions.
*/
static create(e, t) {
return new J(e.resolve(t));
}
/**
Determines whether the given node may be selected as a node
selection.
*/
static isSelectable(e) {
return !e.isText && e.type.spec.selectable !== !1;
}
}
J.prototype.visible = !1;
te.jsonID("node", J);
class Ea {
constructor(e) {
this.anchor = e;
}
map(e) {
let { deleted: t, pos: r } = e.mapResult(this.anchor);
return t ? new Is(r, r) : new Ea(r);
}
resolve(e) {
let t = e.resolve(this.anchor), r = t.nodeAfter;
return r && J.isSelectable(r) ? new J(t) : te.near(t);
}
}
class ct extends te {
/**
Create an all-selection over the given document.
*/
constructor(e) {
super(e.resolve(0), e.resolve(e.content.size));
}
replace(e, t = z.empty) {
if (t == z.empty) {
e.delete(0, e.doc.content.size);
let r = te.atStart(e.doc);
r.eq(e.selection) || e.setSelection(r);
} else
super.replace(e, t);
}
toJSON() {
return { type: "all" };
}
/**
@internal
*/
static fromJSON(e) {
return new ct(e);
}
map(e) {
return new ct(e);
}
eq(e) {
return e instanceof ct;
}
getBookmark() {
return am;
}
}
te.jsonID("all", ct);
const am = {
map() {
return this;
},
resolve(n) {
return new ct(n);
}
};
function Dr(n, e, t, r, o, i = !1) {
if (e.inlineContent)
return Q.create(n, t);
for (let s = r - (o > 0 ? 0 : 1); o > 0 ? s < e.childCount : s >= 0; s += o) {
let l = e.child(s);
if (l.isAtom) {
if (!i && J.isSelectable(l))
return J.create(n, t - (o < 0 ? l.nodeSize : 0));
} else {
let a = Dr(n, l, t + o, o < 0 ? l.childCount : 0, o, i);
if (a)
return a;
}
t += l.nodeSize * o;
}
return null;
}
function Rc(n, e, t) {
let r = n.steps.length - 1;
if (r < e)
return;
let o = n.steps[r];
if (!(o instanceof _e || o instanceof Le))
return;
let i = n.mapping.maps[r], s;
i.forEach((l, a, c, p) => {
s == null && (s = p);
}), n.setSelection(te.near(n.doc.resolve(s), t));
}
const Fc = 1, mi = 2, Hc = 4;
class cm extends ud {
/**
@internal
*/
constructor(e) {
super(e.doc), this.curSelectionFor = 0, this.updated = 0, this.meta = /* @__PURE__ */ Object.create(null), this.time = Date.now(), this.curSelection = e.selection, this.storedMarks = e.storedMarks;
}
/**
The transaction's current selection. This defaults to the editor
selection [mapped](https://prosemirror.net/docs/ref/#state.Selection.map) through the steps in the
transaction, but can be overwritten with
[`setSelection`](https://prosemirror.net/docs/ref/#state.Transaction.setSelection).
*/
get selection() {
return this.curSelectionFor < this.steps.length && (this.curSelection = this.curSelection.map(this.doc, this.mapping.slice(this.curSelectionFor)), this.curSelectionFor = this.steps.length), this.curSelection;
}
/**
Update the transaction's current selection. Will determine the
selection that the editor gets when the transaction is applied.
*/
setSelection(e) {
if (e.$from.doc != this.doc)
throw new RangeError("Selection passed to setSelection must point at the current document");
return this.curSelection = e, this.curSelectionFor = this.steps.length, this.updated = (this.updated | Fc) & ~mi, this.storedMarks = null, this;
}
/**
Whether the selection was explicitly updated by this transaction.
*/
get selectionSet() {
return (this.updated & Fc) > 0;
}
/**
Set the current stored marks.
*/
setStoredMarks(e) {
return this.storedMarks = e, this.updated |= mi, this;
}
/**
Make sure the current stored marks or, if that is null, the marks
at the selection, match the given set of marks. Does nothing if
this is already the case.
*/
ensureMarks(e) {
return me.sameSet(this.storedMarks || this.selection.$from.marks(), e) || this.setStoredMarks(e), this;
}
/**
Add a mark to the set of stored marks.
*/
addStoredMark(e) {
return this.ensureMarks(e.addToSet(this.storedMarks || this.selection.$head.marks()));
}
/**
Remove a mark or mark type from the set of stored marks.
*/
removeStoredMark(e) {
return this.ensureMarks(e.removeFromSet(this.storedMarks || this.selection.$head.marks()));
}
/**
Whether the stored marks were explicitly set for this transaction.
*/
get storedMarksSet() {
return (this.updated & mi) > 0;
}
/**
@internal
*/
addStep(e, t) {
super.addStep(e, t), this.updated = this.updated & ~mi, this.storedMarks = null;
}
/**
Update the timestamp for the transaction.
*/
setTime(e) {
return this.time = e, this;
}
/**
Replace the current selection with the given slice.
*/
replaceSelection(e) {
return this.selection.replace(this, e), this;
}
/**
Replace the selection with the given node. When `inheritMarks` is
true and the content is inline, it inherits the marks from the
place where it is inserted.
*/
replaceSelectionWith(e, t = !0) {
let r = this.selection;
return t && (e = e.mark(this.storedMarks || (r.empty ? r.$from.marks() : r.$from.marksAcross(r.$to) || me.none))), r.replaceWith(this, e), this;
}
/**
Delete the selection.
*/
deleteSelection() {
return this.selection.replace(this), this;
}
/**
Replace the given range, or the selection if no range is given,
with a text node containing the given string.
*/
insertText(e, t, r) {
let o = this.doc.type.schema;
if (t == null)
return e ? this.replaceSelectionWith(o.text(e), !0) : this.deleteSelection();
{
if (r == null && (r = t), r = r ?? t, !e)
return this.deleteRange(t, r);
let i = this.storedMarks;
if (!i) {
let s = this.doc.resolve(t);
i = r == t ? s.marks() : s.marksAcross(this.doc.resolve(r));
}
return this.replaceRangeWith(t, r, o.text(e, i)), this.selection.empty || this.setSelection(te.near(this.selection.$to)), this;
}
}
/**
Store a metadata property in this transaction, keyed either by
name or by plugin.
*/
setMeta(e, t) {
return this.meta[typeof e == "string" ? e : e.key] = t, this;
}
/**
Retrieve a metadata property for a given name or plugin.
*/
getMeta(e) {
return this.meta[typeof e == "string" ? e : e.key];
}
/**
Returns true if this transaction doesn't contain any metadata,
and can thus safely be extended.
*/
get isGeneric() {
for (let e in this.meta)
return !1;
return !0;
}
/**
Indicate that the editor should scroll the selection into view
when updated to the state produced by this transaction.
*/
scrollIntoView() {
return this.updated |= Hc, this;
}
/**
True when this transaction has had `scrollIntoView` called on it.
*/
get scrolledIntoView() {
return (this.updated & Hc) > 0;
}
}
function jc(n, e) {
return !e || !n ? n : n.bind(e);
}
class xo {
constructor(e, t, r) {
this.name = e, this.init = jc(t.init, r), this.apply = jc(t.apply, r);
}
}
const pm = [
new xo("doc", {
init(n) {
return n.doc || n.schema.topNodeType.createAndFill();
},
apply(n) {
return n.doc;
}
}),
new xo("selection", {
init(n, e) {
return n.selection || te.atStart(e.doc);
},
apply(n) {
return n.selection;
}
}),
new xo("storedMarks", {
init(n) {
return n.storedMarks || null;
},
apply(n, e, t, r) {
return r.selection.$cursor ? n.storedMarks : null;
}
}),
new xo("scrollToSelection", {
init() {
return 0;
},
apply(n, e) {
return n.scrolledIntoView ? e + 1 : e;
}
})
];
class il {
constructor(e, t) {
this.schema = e, this.plugins = [], this.pluginsByKey = /* @__PURE__ */ Object.create(null), this.fields = pm.slice(), t && t.forEach((r) => {
if (this.pluginsByKey[r.key])
throw new RangeError("Adding different instances of a keyed plugin (" + r.key + ")");
this.plugins.push(r), this.pluginsByKey[r.key] = r, r.spec.state && this.fields.push(new xo(r.key, r.spec.state, r));
});
}
}
class Hr {
/**
@internal
*/
constructor(e) {
this.config = e;
}
/**
The schema of the state's document.
*/
get schema() {
return this.config.schema;
}
/**
The plugins that are active in this state.
*/
get plugins() {
return this.config.plugins;
}
/**
Apply the given transaction to produce a new state.
*/
apply(e) {
return this.applyTransaction(e).state;
}
/**
@internal
*/
filterTransaction(e, t = -1) {
for (let r = 0; r < this.config.plugins.length; r++)
if (r != t) {
let o = this.config.plugins[r];
if (o.spec.filterTransaction && !o.spec.filterTransaction.call(o, e, this))
return !1;
}
return !0;
}
/**
Verbose variant of [`apply`](https://prosemirror.net/docs/ref/#state.EditorState.apply) that
returns the precise transactions that were applied (which might
be influenced by the [transaction
hooks](https://prosemirror.net/docs/ref/#state.PluginSpec.filterTransaction) of
plugins) along with the new state.
*/
applyTransaction(e) {
if (!this.filterTransaction(e))
return { state: this, transactions: [] };
let t = [e], r = this.applyInner(e), o = null;
for (; ; ) {
let i = !1;
for (let s = 0; s < this.config.plugins.length; s++) {
let l = this.config.plugins[s];
if (l.spec.appendTransaction) {
let a = o ? o[s].n : 0, c = o ? o[s].state : this, p = a < t.length && l.spec.appendTransaction.call(l, a ? t.slice(a) : t, c, r);
if (p && r.filterTransaction(p, s)) {
if (p.setMeta("appendedTransaction", e), !o) {
o = [];
for (let u = 0; u < this.config.plugins.length; u++)
o.push(u < s ? { state: r, n: t.length } : { state: this, n: 0 });
}
t.push(p), r = r.applyInner(p), i = !0;
}
o && (o[s] = { state: r, n: t.length });
}
}
if (!i)
return { state: r, transactions: t };
}
}
/**
@internal
*/
applyInner(e) {
if (!e.before.eq(this.doc))
throw new RangeError("Applying a mismatched transaction");
let t = new Hr(this.config), r = this.config.fields;
for (let o = 0; o < r.length; o++) {
let i = r[o];
t[i.name] = i.apply(e, this[i.name], this, t);
}
return t;
}
/**
Start a [transaction](https://prosemirror.net/docs/ref/#state.Transaction) from this state.
*/
get tr() {
return new cm(this);
}
/**
Create a new state.
*/
static create(e) {
let t = new il(e.doc ? e.doc.type.schema : e.schema, e.plugins), r = new Hr(t);
for (let o = 0; o < t.fields.length; o++)
r[t.fields[o].name] = t.fields[o].init(e, r);
return r;
}
/**
Create a new state based on this one, but with an adjusted set
of active plugins. State fields that exist in both sets of
plugins are kept unchanged. Those that no longer exist are
dropped, and those that are new are initialized using their
[`init`](https://prosemirror.net/docs/ref/#state.StateField.init) method, passing in the new
configuration object..
*/
reconfigure(e) {
let t = new il(this.schema, e.plugins), r = t.fields, o = new Hr(t);
for (let i = 0; i < r.length; i++) {
let s = r[i].name;
o[s] = this.hasOwnProperty(s) ? this[s] : r[i].init(e, o);
}
return o;
}
/**
Serialize this state to JSON. If you want to serialize the state
of plugins, pass an object mapping property names to use in the
resulting JSON object to plugin objects. The argument may also be
a string or number, in which case it is ignored, to support the
way `JSON.stringify` calls `toString` methods.
*/
toJSON(e) {
let t = { doc: this.doc.toJSON(), selection: this.selection.toJSON() };
if (this.storedMarks && (t.storedMarks = this.storedMarks.map((r) => r.toJSON())), e && typeof e == "object")
for (let r in e) {
if (r == "doc" || r == "selection")
throw new RangeError("The JSON fields `doc` and `selection` are reserved");
let o = e[r], i = o.spec.state;
i && i.toJSON && (t[r] = i.toJSON.call(o, this[o.key]));
}
return t;
}
/**
Deserialize a JSON representation of a state. `config` should
have at least a `schema` field, and should contain array of
plugins to initialize the state with. `pluginFields` can be used
to deserialize the state of plugins, by associating plugin
instances with the property names they use in the JSON object.
*/
static fromJSON(e, t, r) {
if (!t)
throw new RangeError("Invalid input for EditorState.fromJSON");
if (!e.schema)
throw new RangeError("Required config field 'schema' missing");
let o = new il(e.schema, e.plugins), i = new Hr(o);
return o.fields.forEach((s) => {
if (s.name == "doc")
i.doc = $n.fromJSON(e.schema, t.doc);
else if (s.name == "selection")
i.selection = te.fromJSON(i.doc, t.selection);
else if (s.name == "storedMarks")
t.storedMarks && (i.storedMarks = t.storedMarks.map(e.schema.markFromJSON));
else {
if (r)
for (let l in r) {
let a = r[l], c = a.spec.state;
if (a.key == s.name && c && c.fromJSON && Object.prototype.hasOwnProperty.call(t, l)) {
i[s.name] = c.fromJSON.call(a, e, t[l], i);
return;
}
}
i[s.name] = s.init(e, i);
}
}), i;
}
}
function dd(n, e, t) {
for (let r in n) {
let o = n[r];
o instanceof Function ? o = o.bind(e) : r == "handleDOMEvents" && (o = dd(o, e, {})), t[r] = o;
}
return t;
}
class Oe {
/**
Create a plugin.
*/
constructor(e) {
this.spec = e, this.props = {}, e.props && dd(e.props, this, this.props), this.key = e.key ? e.key.key : fd("plugin");
}
/**
Extract the plugin's state field from an editor state.
*/
getState(e) {
return e[this.key];
}
}
const sl = /* @__PURE__ */ Object.create(null);
function fd(n) {
return n in sl ? n + "$" + ++sl[n] : (sl[n] = 0, n + "$");
}
class Ze {
/**
Create a plugin key.
*/
constructor(e = "key") {
this.key = fd(e);
}
/**
Get the active plugin with this key, if any, from an editor
state.
*/
get(e) {
return e.config.pluginsByKey[this.key];
}
/**
Get the plugin's state from an editor state.
*/
getState(e) {
return e[this.key];
}
}
const Re = function(n) {
for (var e = 0; ; e++)
if (n = n.previousSibling, !n)
return e;
}, Gr = function(n) {
let e = n.assignedSlot || n.parentNode;
return e && e.nodeType == 11 ? e.host : e;
};
let Wl = null;
const rn = function(n, e, t) {
let r = Wl || (Wl = document.createRange());
return r.setEnd(n, t ?? n.nodeValue.length), r.setStart(n, e || 0), r;
}, um = function() {
Wl = null;
}, Sr = function(n, e, t, r) {
return t && (zc(n, e, t, r, -1) || zc(n, e, t, r, 1));
}, dm = /^(img|br|input|textarea|hr)$/i;
function zc(n, e, t, r, o) {
for (var i; ; ) {
if (n == t && e == r)
return !0;
if (e == (o < 0 ? 0 : yt(n))) {
let s = n.parentNode;
if (!s || s.nodeType != 1 || Zo(n) || dm.test(n.nodeName) || n.contentEditable == "false")
return !1;
e = Re(n) + (o < 0 ? 0 : 1), n = s;
} else if (n.nodeType == 1) {
let s = n.childNodes[e + (o < 0 ? -1 : 0)];
if (s.nodeType == 1 && s.contentEditable == "false")
if (!((i = s.pmViewDesc) === null || i === void 0) && i.ignoreForSelection)
e += o;
else
return !1;
else
n = s, e = o < 0 ? yt(n) : 0;
} else
return !1;
}
}
function yt(n) {
return n.nodeType == 3 ? n.nodeValue.length : n.childNodes.length;
}
function fm(n, e) {
for (; ; ) {
if (n.nodeType == 3 && e)
return n;
if (n.nodeType == 1 && e > 0) {
if (n.contentEditable == "false")
return null;
n = n.childNodes[e - 1], e = yt(n);
} else if (n.parentNode && !Zo(n))
e = Re(n), n = n.parentNode;
else
return null;
}
}
function hm(n, e) {
for (; ; ) {
if (n.nodeType == 3 && e < n.nodeValue.length)
return n;
if (n.nodeType == 1 && e < n.childNodes.length) {
if (n.contentEditable == "false")
return null;
n = n.childNodes[e], e = 0;
} else if (n.parentNode && !Zo(n))
e = Re(n) + 1, n = n.parentNode;
else
return null;
}
}
function bm(n, e, t) {
for (let r = e == 0, o = e == yt(n); r || o; ) {
if (n == t)
return !0;
let i = Re(n);
if (n = n.parentNode, !n)
return !1;
r = r && i == 0, o = o && i == yt(n);
}
}
function Zo(n) {
let e;
for (let t = n; t && !(e = t.pmViewDesc); t = t.parentNode)
;
return e && e.node && e.node.isBlock && (e.dom == n || e.contentDOM == n);
}
const $s = function(n) {
return n.focusNode && Sr(n.focusNode, n.focusOffset, n.anchorNode, n.anchorOffset);
};
function sr(n, e) {
let t = document.createEvent("Event");
return t.initEvent("keydown", !0, !0), t.keyCode = n, t.key = t.code = e, t;
}
function mm(n) {
let e = n.activeElement;
for (; e && e.shadowRoot; )
e = e.shadowRoot.activeElement;
return e;
}
function xm(n, e, t) {
if (n.caretPositionFromPoint)
try {
let r = n.caretPositionFromPoint(e, t);
if (r)
return { node: r.offsetNode, offset: Math.min(yt(r.offsetNode), r.offset) };
} catch {
}
if (n.caretRangeFromPoint) {
let r = n.caretRangeFromPoint(e, t);
if (r)
return { node: r.startContainer, offset: Math.min(yt(r.startContainer), r.startOffset) };
}
}
const qt = typeof navigator < "u" ? navigator : null, Vc = typeof document < "u" ? document : null, Un = qt && qt.userAgent || "", Ul = /Edge\/(\d+)/.exec(Un), hd = /MSIE \d/.exec(Un), ql = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Un), nt = !!(hd || ql || Ul), Rn = hd ? document.documentMode : ql ? +ql[1] : Ul ? +Ul[1] : 0, Lt = !nt && /gecko\/(\d+)/i.test(Un);
Lt && +(/Firefox\/(\d+)/.exec(Un) || [0, 0])[1];
const Kl = !nt && /Chrome\/(\d+)/.exec(Un), qe = !!Kl, bd = Kl ? +Kl[1] : 0, Je = !nt && !!qt && /Apple Computer/.test(qt.vendor), Jr = Je && (/Mobile\/\w+/.test(Un) || !!qt && qt.maxTouchPoints > 2), gt = Jr || (qt ? /Mac/.test(qt.platform) : !1), gm = qt ? /Win/.test(qt.platform) : !1, sn = /Android \d/.test(Un), ei = !!Vc && "webkitFontSmoothing" in Vc.documentElement.style, ym = ei ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0;
function vm(n) {
let e = n.defaultView && n.defaultView.visualViewport;
return e ? {
left: 0,
right: e.width,
top: 0,
bottom: e.height
} : {
left: 0,
right: n.documentElement.clientWidth,
top: 0,
bottom: n.documentElement.clientHeight
};
}
function Qt(n, e) {
return typeof n == "number" ? n : n[e];
}
function wm(n) {
let e = n.getBoundingClientRect(), t = e.width / n.offsetWidth || 1, r = e.height / n.offsetHeight || 1;
return {
left: e.left,
right: e.left + n.clientWidth * t,
top: e.top,
bottom: e.top + n.clientHeight * r
};
}
function Wc(n, e, t) {
let r = n.someProp("scrollThreshold") || 0, o = n.someProp("scrollMargin") || 5, i = n.dom.ownerDocument;
for (let s = t || n.dom; s; ) {
if (s.nodeType != 1) {
s = Gr(s);
continue;
}
let l = s, a = l == i.body, c = a ? vm(i) : wm(l), p = 0, u = 0;
if (e.top < c.top + Qt(r, "top") ? u = -(c.top - e.top + Qt(o, "top")) : e.bottom > c.bottom - Qt(r, "bottom") && (u = e.bottom - e.top > c.bottom - c.top ? e.top + Qt(o, "top") - c.top : e.bottom - c.bottom + Qt(o, "bottom")), e.left < c.left + Qt(r, "left") ? p = -(c.left - e.left + Qt(o, "left")) : e.right > c.right - Qt(r, "right") && (p = e.right - c.right + Qt(o, "right")), p || u)
if (a)
i.defaultView.scrollBy(p, u);
else {
let h = l.scrollLeft, b = l.scrollTop;
u && (l.scrollTop += u), p && (l.scrollLeft += p);
let m = l.scrollLeft - h, x = l.scrollTop - b;
e = { left: e.left - m, top: e.top - x, right: e.right - m, bottom: e.bottom - x };
}
let f = a ? "fixed" : getComputedStyle(s).position;
if (/^(fixed|sticky)$/.test(f))
break;
s = f == "absolute" ? s.offsetParent : Gr(s);
}
}
function Sm(n) {
let e = n.dom.getBoundingClientRect(), t = Math.max(0, e.top), r, o;
for (let i = (e.left + e.right) / 2, s = t + 1; s < Math.min(innerHeight, e.bottom); s += 5) {
let l = n.root.elementFromPoint(i, s);
if (!l || l == n.dom || !n.dom.contains(l))
continue;
let a = l.getBoundingClientRect();
if (a.top >= t - 20) {
r = l, o = a.top;
break;
}
}
return { refDOM: r, refTop: o, stack: md(n.dom) };
}
function md(n) {
let e = [], t = n.ownerDocument;
for (let r = n; r && (e.push({ dom: r, top: r.scrollTop, left: r.scrollLeft }), n != t); r = Gr(r))
;
return e;
}
function km({ refDOM: n, refTop: e, stack: t }) {
let r = n ? n.getBoundingClientRect().top : 0;
xd(t, r == 0 ? 0 : r - e);
}
function xd(n, e) {
for (let t = 0; t < n.length; t++) {
let { dom: r, top: o, left: i } = n[t];
r.scrollTop != o + e && (r.scrollTop = o + e), r.scrollLeft != i && (r.scrollLeft = i);
}
}
let Pr = null;
function Cm(n) {
if (n.setActive)
return n.setActive();
if (Pr)
return n.focus(Pr);
let e = md(n);
n.focus(Pr == null ? {
get preventScroll() {
return Pr = { preventScroll: !0 }, !0;
}
} : void 0), Pr || (Pr = !1, xd(e, 0));
}
function gd(n, e) {
let t, r = 2e8, o, i = 0, s = e.top, l = e.top, a, c;
for (let p = n.firstChild, u = 0; p; p = p.nextSibling, u++) {
let f;
if (p.nodeType == 1)
f = p.getClientRects();
else if (p.nodeType == 3)
f = rn(p).getClientRects();
else
continue;
for (let h = 0; h < f.length; h++) {
let b = f[h];
if (b.top <= s && b.bottom >= l) {
s = Math.max(b.bottom, s), l = Math.min(b.top, l);
let m = b.left > e.left ? b.left - e.left : b.right < e.left ? e.left - b.right : 0;
if (m < r) {
t = p, r = m, o = m && t.nodeType == 3 ? {
left: b.right < e.left ? b.right : b.left,
top: e.top
} : e, p.nodeType == 1 && m && (i = u + (e.left >= (b.left + b.right) / 2 ? 1 : 0));
continue;
}
} else b.top > e.top && !a && b.left <= e.left && b.right >= e.left && (a = p, c = { left: Math.max(b.left, Math.min(b.right, e.left)), top: b.top });
!t && (e.left >= b.right && e.top >= b.top || e.left >= b.left && e.top >= b.bottom) && (i = u + 1);
}
}
return !t && a && (t = a, o = c, r = 0), t && t.nodeType == 3 ? Mm(t, o) : !t || r && t.nodeType == 1 ? { node: n, offset: i } : gd(t, o);
}
function Mm(n, e) {
let t = n.nodeValue.length, r = document.createRange();
for (let o = 0; o < t; o++) {
r.setEnd(n, o + 1), r.setStart(n, o);
let i = Sn(r, 1);
if (i.top != i.bottom && Ta(e, i))
return { node: n, offset: o + (e.left >= (i.left + i.right) / 2 ? 1 : 0) };
}
return { node: n, offset: 0 };
}
function Ta(n, e) {
return n.left >= e.left - 1 && n.left <= e.right + 1 && n.top >= e.top - 1 && n.top <= e.bottom + 1;
}
function Em(n, e) {
let t = n.parentNode;
return t && /^li$/i.test(t.nodeName) && e.left < n.getBoundingClientRect().left ? t : n;
}
function Tm(n, e, t) {
let { node: r, offset: o } = gd(e, t), i = -1;
if (r.nodeType == 1 && !r.firstChild) {
let s = r.getBoundingClientRect();
i = s.left != s.right && t.left > (s.left + s.right) / 2 ? 1 : -1;
}
return n.docView.posFromDOM(r, o, i);
}
function Om(n, e, t, r) {
let o = -1;
for (let i = e, s = !1; i != n.dom; ) {
let l = n.docView.nearestDesc(i, !0), a;
if (!l)
return null;
if (l.dom.nodeType == 1 && (l.node.isBlock && l.parent || !l.contentDOM) && // Ignore elements with zero-size bounding rectangles
((a = l.dom.getBoundingClientRect()).width || a.height) && (l.node.isBlock && l.parent && (!s && a.left > r.left || a.top > r.top ? o = l.posBefore : (!s && a.right < r.left || a.bottom < r.top) && (o = l.posAfter), s = !0), !l.contentDOM && o < 0 && !l.node.isText))
return (l.node.isBlock ? r.top < (a.top + a.bottom) / 2 : r.left < (a.left + a.right) / 2) ? l.posBefore : l.posAfter;
i = l.dom.parentNode;
}
return o > -1 ? o : n.docView.posFromDOM(e, t, -1);
}
function yd(n, e, t) {
let r = n.childNodes.length;
if (r && t.top < t.bottom)
for (let o = Math.max(0, Math.min(r - 1, Math.floor(r * (e.top - t.top) / (t.bottom - t.top)) - 2)), i = o; ; ) {
let s = n.childNodes[i];
if (s.nodeType == 1) {
let l = s.getClientRects();
for (let a = 0; a < l.length; a++) {
let c = l[a];
if (Ta(e, c))
return yd(s, e, c);
}
}
if ((i = (i + 1) % r) == o)
break;
}
return n;
}
function Bm(n, e) {
let t = n.dom.ownerDocument, r, o = 0, i = xm(t, e.left, e.top);
i && ({ node: r, offset: o } = i);
let s = (n.root.elementFromPoint ? n.root : t).elementFromPoint(e.left, e.top), l;
if (!s || !n.dom.contains(s.nodeType != 1 ? s.parentNode : s)) {
let c = n.dom.getBoundingClientRect();
if (!Ta(e, c) || (s = yd(n.dom, e, c), !s))
return null;
}
if (Je)
for (let c = s; r && c; c = Gr(c))
c.draggable && (r = void 0);
if (s = Em(s, e), r) {
if (Lt && r.nodeType == 1 && (o = Math.min(o, r.childNodes.length), o < r.childNodes.length)) {
let p = r.childNodes[o], u;
p.nodeName == "IMG" && (u = p.getBoundingClientRect()).right <= e.left && u.bottom > e.top && o++;
}
let c;
ei && o && r.nodeType == 1 && (c = r.childNodes[o - 1]).nodeType == 1 && c.contentEditable == "false" && c.getBoundingClientRect().top >= e.top && o--, r == n.dom && o == r.childNodes.length - 1 && r.lastChild.nodeType == 1 && e.top > r.lastChild.getBoundingClientRect().bottom ? l = n.state.doc.content.size : (o == 0 || r.nodeType != 1 || r.childNodes[o - 1].nodeName != "BR") && (l = Om(n, r, o, e));
}
l == null && (l = Tm(n, s, e));
let a = n.docView.nearestDesc(s, !0);
return { pos: l, inside: a ? a.posAtStart - a.border : -1 };
}
function Uc(n) {
return n.top < n.bottom || n.left < n.right;
}
function Sn(n, e) {
let t = n.getClientRects();
if (t.length) {
let r = t[e < 0 ? 0 : t.length - 1];
if (Uc(r))
return r;
}
return Array.prototype.find.call(t, Uc) || n.getBoundingClientRect();
}
const Pm = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
function vd(n, e, t) {
let { node: r, offset: o, atom: i } = n.docView.domFromPos(e, t < 0 ? -1 : 1), s = ei || Lt;
if (r.nodeType == 3)
if (s && (Pm.test(r.nodeValue) || (t < 0 ? !o : o == r.nodeValue.length))) {
let a = Sn(rn(r, o, o), t);
if (Lt && o && /\s/.test(r.nodeValue[o - 1]) && o < r.nodeValue.length) {
let c = Sn(rn(r, o - 1, o - 1), -1);
if (c.top == a.top) {
let p = Sn(rn(r, o, o + 1), -1);
if (p.top != a.top)
return po(p, p.left < c.left);
}
}
return a;
} else {
let a = o, c = o, p = t < 0 ? 1 : -1;
return t < 0 && !o ? (c++, p = -1) : t >= 0 && o == r.nodeValue.length ? (a--, p = 1) : t < 0 ? a-- : c++, po(Sn(rn(r, a, c), p), p < 0);
}
if (!n.state.doc.resolve(e - (i || 0)).parent.inlineContent) {
if (i == null && o && (t < 0 || o == yt(r))) {
let a = r.childNodes[o - 1];
if (a.nodeType == 1)
return ll(a.getBoundingClientRect(), !1);
}
if (i == null && o < yt(r)) {
let a = r.childNodes[o];
if (a.nodeType == 1)
return ll(a.getBoundingClientRect(), !0);
}
return ll(r.getBoundingClientRect(), t >= 0);
}
if (i == null && o && (t < 0 || o == yt(r))) {
let a = r.childNodes[o - 1], c = a.nodeType == 3 ? rn(a, yt(a) - (s ? 0 : 1)) : a.nodeType == 1 && (a.nodeName != "BR" || !a.nextSibling) ? a : null;
if (c)
return po(Sn(c, 1), !1);
}
if (i == null && o < yt(r)) {
let a = r.childNodes[o];
for (; a.pmViewDesc && a.pmViewDesc.ignoreForCoords; )
a = a.nextSibling;
let c = a ? a.nodeType == 3 ? rn(a, 0, s ? 0 : 1) : a.nodeType == 1 ? a : null : null;
if (c)
return po(Sn(c, -1), !0);
}
return po(Sn(r.nodeType == 3 ? rn(r) : r, -t), t >= 0);
}
function po(n, e) {
if (n.width == 0)
return n;
let t = e ? n.left : n.right;
return { top: n.top, bottom: n.bottom, left: t, right: t };
}
function ll(n, e) {
if (n.height == 0)
return n;
let t = e ? n.top : n.bottom;
return { top: t, bottom: t, left: n.left, right: n.right };
}
function wd(n, e, t) {
let r = n.state, o = n.root.activeElement;
r != e && n.updateState(e), o != n.dom && n.focus();
try {
return t();
} finally {
r != e && n.updateState(r), o != n.dom && o && o.focus();
}
}
function Am(n, e, t) {
let r = e.selection, o = t == "up" ? r.$from : r.$to;
return wd(n, e, () => {
let { node: i } = n.docView.domFromPos(o.pos, t == "up" ? -1 : 1);
for (; ; ) {
let l = n.docView.nearestDesc(i, !0);
if (!l)
break;
if (l.node.isBlock) {
i = l.contentDOM || l.dom;
break;
}
i = l.dom.parentNode;
}
let s = vd(n, o.pos, 1);
for (let l = i.firstChild; l; l = l.nextSibling) {
let a;
if (l.nodeType == 1)
a = l.getClientRects();
else if (l.nodeType == 3)
a = rn(l, 0, l.nodeValue.length).getClientRects();
else
continue;
for (let c = 0; c < a.length; c++) {
let p = a[c];
if (p.bottom > p.top + 1 && (t == "up" ? s.top - p.top > (p.bottom - s.top) * 2 : p.bottom - s.bottom > (s.bottom - p.top) * 2))
return !1;
}
}
return !0;
});
}
const _m = /[\u0590-\u08ac]/;
function Lm(n, e, t) {
let { $head: r } = e.selection;
if (!r.parent.isTextblock)
return !1;
let o = r.parentOffset, i = !o, s = o == r.parent.content.size, l = n.domSelection();
return l ? !_m.test(r.parent.textContent) || !l.modify ? t == "left" || t == "backward" ? i : s : wd(n, e, () => {
let { focusNode: a, focusOffset: c, anchorNode: p, anchorOffset: u } = n.domSelectionRange(), f = l.caretBidiLevel;
l.modify("move", t, "character");
let h = r.depth ? n.docView.domAfterPos(r.before()) : n.dom, { focusNode: b, focusOffset: m } = n.domSelectionRange(), x = b && !h.contains(b.nodeType == 1 ? b : b.parentNode) || a == b && c == m;
try {
l.collapse(p, u), a && (a != p || c != u) && l.extend && l.extend(a, c);
} catch {
}
return f != null && (l.caretBidiLevel = f), x;
}) : r.pos == r.start() || r.pos == r.end();
}
let qc = null, Kc = null, Gc = !1;
function Nm(n, e, t) {
return qc == e && Kc == t ? Gc : (qc = e, Kc = t, Gc = t == "up" || t == "down" ? Am(n, e, t) : Lm(n, e, t));
}
const wt = 0, Jc = 1, cr = 2, Kt = 3;
class ti {
constructor(e, t, r, o) {
this.parent = e, this.children = t, this.dom = r, this.contentDOM = o, this.dirty = wt, r.pmViewDesc = this;
}
// Used to check whether a given description corresponds to a
// widget/mark/node.
matchesWidget(e) {
return !1;
}
matchesMark(e) {
return !1;
}
matchesNode(e, t, r) {
return !1;
}
matchesHack(e) {
return !1;
}
// When parsing in-editor content (in domchange.js), we allow
// descriptions to determine the parse rules that should be used to
// parse them.
parseRule() {
return null;
}
// Used by the editor's event handler to ignore events that come
// from certain descs.
stopEvent(e) {
return !1;
}
// The size of the content represented by this desc.
get size() {
let e = 0;
for (let t = 0; t < this.children.length; t++)
e += this.children[t].size;
return e;
}
// For block nodes, this represents the space taken up by their
// start/end tokens.
get border() {
return 0;
}
destroy() {
this.parent = void 0, this.dom.pmViewDesc == this && (this.dom.pmViewDesc = void 0);
for (let e = 0; e < this.children.length; e++)
this.children[e].destroy();
}
posBeforeChild(e) {
for (let t = 0, r = this.posAtStart; ; t++) {
let o = this.children[t];
if (o == e)
return r;
r += o.size;
}
}
get posBefore() {
return this.parent.posBeforeChild(this);
}
get posAtStart() {
return this.parent ? this.parent.posBeforeChild(this) + this.border : 0;
}
get posAfter() {
return this.posBefore + this.size;
}
get posAtEnd() {
return this.posAtStart + this.size - 2 * this.border;
}
localPosFromDOM(e, t, r) {
if (this.contentDOM && this.contentDOM.contains(e.nodeType == 1 ? e : e.parentNode))
if (r < 0) {
let i, s;
if (e == this.contentDOM)
i = e.childNodes[t - 1];
else {
for (; e.parentNode != this.contentDOM; )
e = e.parentNode;
i = e.previousSibling;
}
for (; i && !((s = i.pmViewDesc) && s.parent == this); )
i = i.previousSibling;
return i ? this.posBeforeChild(s) + s.size : this.posAtStart;
} else {
let i, s;
if (e == this.contentDOM)
i = e.childNodes[t];
else {
for (; e.parentNode != this.contentDOM; )
e = e.parentNode;
i = e.nextSibling;
}
for (; i && !((s = i.pmViewDesc) && s.parent == this); )
i = i.nextSibling;
return i ? this.posBeforeChild(s) : this.posAtEnd;
}
let o;
if (e == this.dom && this.contentDOM)
o = t > Re(this.contentDOM);
else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM))
o = e.compareDocumentPosition(this.contentDOM) & 2;
else if (this.dom.firstChild) {
if (t == 0)
for (let i = e; ; i = i.parentNode) {
if (i == this.dom) {
o = !1;
break;
}
if (i.previousSibling)
break;
}
if (o == null && t == e.childNodes.length)
for (let i = e; ; i = i.parentNode) {
if (i == this.dom) {
o = !0;
break;
}
if (i.nextSibling)
break;
}
}
return o ?? r > 0 ? this.posAtEnd : this.posAtStart;
}
nearestDesc(e, t = !1) {
for (let r = !0, o = e; o; o = o.parentNode) {
let i = this.getDesc(o), s;
if (i && (!t || i.node))
if (r && (s = i.nodeDOM) && !(s.nodeType == 1 ? s.contains(e.nodeType == 1 ? e : e.parentNode) : s == e))
r = !1;
else
return i;
}
}
getDesc(e) {
let t = e.pmViewDesc;
for (let r = t; r; r = r.parent)
if (r == this)
return t;
}
posFromDOM(e, t, r) {
for (let o = e; o; o = o.parentNode) {
let i = this.getDesc(o);
if (i)
return i.localPosFromDOM(e, t, r);
}
return -1;
}
// Find the desc for the node after the given pos, if any. (When a
// parent node overrode rendering, there might not be one.)
descAt(e) {
for (let t = 0, r = 0; t < this.children.length; t++) {
let o = this.children[t], i = r + o.size;
if (r == e && i != r) {
for (; !o.border && o.children.length; )
for (let s = 0; s < o.children.length; s++) {
let l = o.children[s];
if (l.size) {
o = l;
break;
}
}
return o;
}
if (e < i)
return o.descAt(e - r - o.border);
r = i;
}
}
domFromPos(e, t) {
if (!this.contentDOM)
return { node: this.dom, offset: 0, atom: e + 1 };
let r = 0, o = 0;
for (let i = 0; r < this.children.length; r++) {
let s = this.children[r], l = i + s.size;
if (l > e || s instanceof kd) {
o = e - i;
break;
}
i = l;
}
if (o)
return this.children[r].domFromPos(o - this.children[r].border, t);
for (let i; r && !(i = this.children[r - 1]).size && i instanceof Sd && i.side >= 0; r--)
;
if (t <= 0) {
let i, s = !0;
for (; i = r ? this.children[r - 1] : null, !(!i || i.dom.parentNode == this.contentDOM); r--, s = !1)
;
return i && t && s && !i.border && !i.domAtom ? i.domFromPos(i.size, t) : { node: this.contentDOM, offset: i ? Re(i.dom) + 1 : 0 };
} else {
let i, s = !0;
for (; i = r < this.children.length ? this.children[r] : null, !(!i || i.dom.parentNode == this.contentDOM); r++, s = !1)
;
return i && s && !i.border && !i.domAtom ? i.domFromPos(0, t) : { node: this.contentDOM, offset: i ? Re(i.dom) : this.contentDOM.childNodes.length };
}
}
// Used to find a DOM range in a single parent for a given changed
// range.
parseRange(e, t, r = 0) {
if (this.children.length == 0)
return { node: this.contentDOM, from: e, to: t, fromOffset: 0, toOffset: this.contentDOM.childNodes.length };
let o = -1, i = -1;
for (let s = r, l = 0; ; l++) {
let a = this.children[l], c = s + a.size;
if (o == -1 && e <= c) {
let p = s + a.border;
if (e >= p && t <= c - a.border && a.node && a.contentDOM && this.contentDOM.contains(a.contentDOM))
return a.parseRange(e, t, p);
e = s;
for (let u = l; u > 0; u--) {
let f = this.children[u - 1];
if (f.size && f.dom.parentNode == this.contentDOM && !f.emptyChildAt(1)) {
o = Re(f.dom) + 1;
break;
}
e -= f.size;
}
o == -1 && (o = 0);
}
if (o > -1 && (c > t || l == this.children.length - 1)) {
t = c;
for (let p = l + 1; p < this.children.length; p++) {
let u = this.children[p];
if (u.size && u.dom.parentNode == this.contentDOM && !u.emptyChildAt(-1)) {
i = Re(u.dom);
break;
}
t += u.size;
}
i == -1 && (i = this.contentDOM.childNodes.length);
break;
}
s = c;
}
return { node: this.contentDOM, from: e, to: t, fromOffset: o, toOffset: i };
}
emptyChildAt(e) {
if (this.border || !this.contentDOM || !this.children.length)
return !1;
let t = this.children[e < 0 ? 0 : this.children.length - 1];
return t.size == 0 || t.emptyChildAt(e);
}
domAfterPos(e) {
let { node: t, offset: r } = this.domFromPos(e, 0);
if (t.nodeType != 1 || r == t.childNodes.length)
throw new RangeError("No node after pos " + e);
return t.childNodes[r];
}
// View descs are responsible for setting any selection that falls
// entirely inside of them, so that custom implementations can do
// custom things with the selection. Note that this falls apart when
// a selection starts in such a node and ends in another, in which
// case we just use whatever domFromPos produces as a best effort.
setSelection(e, t, r, o = !1) {
let i = Math.min(e, t), s = Math.max(e, t);
for (let h = 0, b = 0; h < this.children.length; h++) {
let m = this.children[h], x = b + m.size;
if (i > b && s < x)
return m.setSelection(e - b - m.border, t - b - m.border, r, o);
b = x;
}
let l = this.domFromPos(e, e ? -1 : 1), a = t == e ? l : this.domFromPos(t, t ? -1 : 1), c = r.root.getSelection(), p = r.domSelectionRange(), u = !1;
if ((Lt || Je) && e == t) {
let { node: h, offset: b } = l;
if (h.nodeType == 3) {
if (u = !!(b && h.nodeValue[b - 1] == `
`), u && b == h.nodeValue.length)
for (let m = h, x; m; m = m.parentNode) {
if (x = m.nextSibling) {
x.nodeName == "BR" && (l = a = { node: x.parentNode, offset: Re(x) + 1 });
break;
}
let v = m.pmViewDesc;
if (v && v.node && v.node.isBlock)
break;
}
} else {
let m = h.childNodes[b - 1];
u = m && (m.nodeName == "BR" || m.contentEditable == "false");
}
}
if (Lt && p.focusNode && p.focusNode != a.node && p.focusNode.nodeType == 1) {
let h = p.focusNode.childNodes[p.focusOffset];
h && h.contentEditable == "false" && (o = !0);
}
if (!(o || u && Je) && Sr(l.node, l.offset, p.anchorNode, p.anchorOffset) && Sr(a.node, a.offset, p.focusNode, p.focusOffset))
return;
let f = !1;
if ((c.extend || e == t) && !u) {
c.collapse(l.node, l.offset);
try {
e != t && c.extend(a.node, a.offset), f = !0;
} catch {
}
}
if (!f) {
if (e > t) {
let b = l;
l = a, a = b;
}
let h = document.createRange();
h.setEnd(a.node, a.offset), h.setStart(l.node, l.offset), c.removeAllRanges(), c.addRange(h);
}
}
ignoreMutation(e) {
return !this.contentDOM && e.type != "selection";
}
get contentLost() {
return this.contentDOM && this.contentDOM != this.dom && !this.dom.contains(this.contentDOM);
}
// Remove a subtree of the element tree that has been touched
// by a DOM change, so that the next update will redraw it.
markDirty(e, t) {
for (let r = 0, o = 0; o < this.children.length; o++) {
let i = this.children[o], s = r + i.size;
if (r == s ? e <= s && t >= r : e < s && t > r) {
let l = r + i.border, a = s - i.border;
if (e >= l && t <= a) {
this.dirty = e == r || t == s ? cr : Jc, e == l && t == a && (i.contentLost || i.dom.parentNode != this.contentDOM) ? i.dirty = Kt : i.markDirty(e - l, t - l);
return;
} else
i.dirty = i.dom == i.contentDOM && i.dom.parentNode == this.contentDOM && !i.children.length ? cr : Kt;
}
r = s;
}
this.dirty = cr;
}
markParentsDirty() {
let e = 1;
for (let t = this.parent; t; t = t.parent, e++) {
let r = e == 1 ? cr : Jc;
t.dirty < r && (t.dirty = r);
}
}
get domAtom() {
return !1;
}
get ignoreForCoords() {
return !1;
}
get ignoreForSelection() {
return !1;
}
isText(e) {
return !1;
}
}
class Sd extends ti {
constructor(e, t, r, o) {
let i, s = t.type.toDOM;
if (typeof s == "function" && (s = s(r, () => {
if (!i)
return o;
if (i.parent)
return i.parent.posBeforeChild(i);
})), !t.type.spec.raw) {
if (s.nodeType != 1) {
let l = document.createElement("span");
l.appendChild(s), s = l;
}
s.contentEditable = "false", s.classList.add("ProseMirror-widget");
}
super(e, [], s, null), this.widget = t, this.widget = t, i = this;
}
matchesWidget(e) {
return this.dirty == wt && e.type.eq(this.widget.type);
}
parseRule() {
return { ignore: !0 };
}
stopEvent(e) {
let t = this.widget.spec.stopEvent;
return t ? t(e) : !1;
}
ignoreMutation(e) {
return e.type != "selection" || this.widget.spec.ignoreSelection;
}
destroy() {
this.widget.type.destroy(this.dom), super.destroy();
}
get domAtom() {
return !0;
}
get ignoreForSelection() {
return !!this.widget.type.spec.relaxedSide;
}
get side() {
return this.widget.type.side;
}
}
class Dm extends ti {
constructor(e, t, r, o) {
super(e, [], t, null), this.textDOM = r, this.text = o;
}
get size() {
return this.text.length;
}
localPosFromDOM(e, t) {
return e != this.textDOM ? this.posAtStart + (t ? this.size : 0) : this.posAtStart + t;
}
domFromPos(e) {
return { node: this.textDOM, offset: e };
}
ignoreMutation(e) {
return e.type === "characterData" && e.target.nodeValue == e.oldValue;
}
}
class kr extends ti {
constructor(e, t, r, o, i) {
super(e, [], r, o), this.mark = t, this.spec = i;
}
static create(e, t, r, o) {
let i = o.nodeViews[t.type.name], s = i && i(t, o, r);
return (!s || !s.dom) && (s = Or.renderSpec(document, t.type.spec.toDOM(t, r), null, t.attrs)), new kr(e, t, s.dom, s.contentDOM || s.dom, s);
}
parseRule() {
return this.dirty & Kt || this.mark.type.spec.reparseInView ? null : { mark: this.mark.type.name, attrs: this.mark.attrs, contentElement: this.contentDOM };
}
matchesMark(e) {
return this.dirty != Kt && this.mark.eq(e);
}
markDirty(e, t) {
if (super.markDirty(e, t), this.dirty != wt) {
let r = this.parent;
for (; !r.node; )
r = r.parent;
r.dirty < this.dirty && (r.dirty = this.dirty), this.dirty = wt;
}
}
slice(e, t, r) {
let o = kr.create(this.parent, this.mark, !0, r), i = this.children, s = this.size;
t < s && (i = Jl(i, t, s, r)), e > 0 && (i = Jl(i, 0, e, r));
for (let l = 0; l < i.length; l++)
i[l].parent = o;
return o.children = i, o;
}
ignoreMutation(e) {
return this.spec.ignoreMutation ? this.spec.ignoreMutation(e) : super.ignoreMutation(e);
}
destroy() {
this.spec.destroy && this.spec.destroy(), super.destroy();
}
}
class Fn extends ti {
constructor(e, t, r, o, i, s, l, a, c) {
super(e, [], i, s), this.node = t, this.outerDeco = r, this.innerDeco = o, this.nodeDOM = l;
}
// By default, a node is rendered using the `toDOM` method from the
// node type spec. But client code can use the `nodeViews` spec to
// supply a custom node view, which can influence various aspects of
// the way the node works.
//
// (Using subclassing for this was intentionally decided against,
// since it'd require exposing a whole slew of finicky
// implementation details to the user code that they probably will
// never need.)
static create(e, t, r, o, i, s) {
let l = i.nodeViews[t.type.name], a, c = l && l(t, i, () => {
if (!a)
return s;
if (a.parent)
return a.parent.posBeforeChild(a);
}, r, o), p = c && c.dom, u = c && c.contentDOM;
if (t.isText) {
if (!p)
p = document.createTextNode(t.text);
else if (p.nodeType != 3)
throw new RangeError("Text must be rendered as a DOM text node");
} else p || ({ dom: p, contentDOM: u } = Or.renderSpec(document, t.type.spec.toDOM(t), null, t.attrs));
!u && !t.isText && p.nodeName != "BR" && (p.hasAttribute("contenteditable") || (p.contentEditable = "false"), t.type.spec.draggable && (p.draggable = !0));
let f = p;
return p = Ed(p, r, t), c ? a = new Im(e, t, r, o, p, u || null, f, c, i, s + 1) : t.isText ? new Rs(e, t, r, o, p, f, i) : new Fn(e, t, r, o, p, u || null, f, i, s + 1);
}
parseRule() {
if (this.node.type.spec.reparseInView)
return null;
let e = { node: this.node.type.name, attrs: this.node.attrs };
if (this.node.type.whitespace == "pre" && (e.preserveWhitespace = "full"), !this.contentDOM)
e.getContent = () => this.node.content;
else if (!this.contentLost)
e.contentElement = this.contentDOM;
else {
for (let t = this.children.length - 1; t >= 0; t--) {
let r = this.children[t];
if (this.dom.contains(r.dom.parentNode)) {
e.contentElement = r.dom.parentNode;
break;
}
}
e.contentElement || (e.getContent = () => D.empty);
}
return e;
}
matchesNode(e, t, r) {
return this.dirty == wt && e.eq(this.node) && Ki(t, this.outerDeco) && r.eq(this.innerDeco);
}
get size() {
return this.node.nodeSize;
}
get border() {
return this.node.isLeaf ? 0 : 1;
}
// Syncs `this.children` to match `this.node.content` and the local
// decorations, possibly introducing nesting for marks. Then, in a
// separate step, syncs the DOM inside `this.contentDOM` to
// `this.children`.
updateChildren(e, t) {
let r = this.node.inlineContent, o = t, i = e.composing ? this.localCompositionInfo(e, t) : null, s = i && i.pos > -1 ? i : null, l = i && i.pos < 0, a = new Rm(this, s && s.node, e);
jm(this.node, this.innerDeco, (c, p, u) => {
c.spec.marks ? a.syncToMarks(c.spec.marks, r, e) : c.type.side >= 0 && !u && a.syncToMarks(p == this.node.childCount ? me.none : this.node.child(p).marks, r, e), a.placeWidget(c, e, o);
}, (c, p, u, f) => {
a.syncToMarks(c.marks, r, e);
let h;
a.findNodeMatch(c, p, u, f) || l && e.state.selection.from > o && e.state.selection.to < o + c.nodeSize && (h = a.findIndexWithChild(i.node)) > -1 && a.updateNodeAt(c, p, u, h, e) || a.updateNextNode(c, p, u, e, f, o) || a.addNode(c, p, u, e, o), o += c.nodeSize;
}), a.syncToMarks([], r, e), this.node.isTextblock && a.addTextblockHacks(), a.destroyRest(), (a.changed || this.dirty == cr) && (s && this.protectLocalComposition(e, s), Cd(this.contentDOM, this.children, e), Jr && zm(this.dom));
}
localCompositionInfo(e, t) {
let { from: r, to: o } = e.state.selection;
if (!(e.state.selection instanceof Q) || r < t || o > t + this.node.content.size)
return null;
let i = e.input.compositionNode;
if (!i || !this.dom.contains(i.parentNode))
return null;
if (this.node.inlineContent) {
let s = i.nodeValue, l = Vm(this.node.content, s, r - t, o - t);
return l < 0 ? null : { node: i, pos: l, text: s };
} else
return { node: i, pos: -1, text: "" };
}
protectLocalComposition(e, { node: t, pos: r, text: o }) {
if (this.getDesc(t))
return;
let i = t;
for (; i.parentNode != this.contentDOM; i = i.parentNode) {
for (; i.previousSibling; )
i.parentNode.removeChild(i.previousSibling);
for (; i.nextSibling; )
i.parentNode.removeChild(i.nextSibling);
i.pmViewDesc && (i.pmViewDesc = void 0);
}
let s = new Dm(this, i, t, o);
e.input.compositionNodes.push(s), this.children = Jl(this.children, r, r + o.length, e, s);
}
// If this desc must be updated to match the given node decoration,
// do so and return true.
update(e, t, r, o) {
return this.dirty == Kt || !e.sameMarkup(this.node) ? !1 : (this.updateInner(e, t, r, o), !0);
}
updateInner(e, t, r, o) {
this.updateOuterDeco(t), this.node = e, this.innerDeco = r, this.contentDOM && this.updateChildren(o, this.posAtStart), this.dirty = wt;
}
updateOuterDeco(e) {
if (Ki(e, this.outerDeco))
return;
let t = this.nodeDOM.nodeType != 1, r = this.dom;
this.dom = Md(this.dom, this.nodeDOM, Gl(this.outerDeco, this.node, t), Gl(e, this.node, t)), this.dom != r && (r.pmViewDesc = void 0, this.dom.pmViewDesc = this), this.outerDeco = e;
}
// Mark this node as being the selected node.
selectNode() {
this.nodeDOM.nodeType == 1 && this.nodeDOM.classList.add("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && (this.dom.draggable = !0);
}
// Remove selected node marking from this node.
deselectNode() {
this.nodeDOM.nodeType == 1 && (this.nodeDOM.classList.remove("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && this.dom.removeAttribute("draggable"));
}
get domAtom() {
return this.node.isAtom;
}
}
function Yc(n, e, t, r, o) {
Ed(r, e, n);
let i = new Fn(void 0, n, e, t, r, r, r, o, 0);
return i.contentDOM && i.updateChildren(o, 0), i;
}
class Rs extends Fn {
constructor(e, t, r, o, i, s, l) {
super(e, t, r, o, i, null, s, l, 0);
}
parseRule() {
let e = this.nodeDOM.parentNode;
for (; e && e != this.dom && !e.pmIsDeco; )
e = e.parentNode;
return { skip: e || !0 };
}
update(e, t, r, o) {
return this.dirty == Kt || this.dirty != wt && !this.inParent() || !e.sameMarkup(this.node) ? !1 : (this.updateOuterDeco(t), (this.dirty != wt || e.text != this.node.text) && e.text != this.nodeDOM.nodeValue && (this.nodeDOM.nodeValue = e.text, o.trackWrites == this.nodeDOM && (o.trackWrites = null)), this.node = e, this.dirty = wt, !0);
}
inParent() {
let e = this.parent.contentDOM;
for (let t = this.nodeDOM; t; t = t.parentNode)
if (t == e)
return !0;
return !1;
}
domFromPos(e) {
return { node: this.nodeDOM, offset: e };
}
localPosFromDOM(e, t, r) {
return e == this.nodeDOM ? this.posAtStart + Math.min(t, this.node.text.length) : super.localPosFromDOM(e, t, r);
}
ignoreMutation(e) {
return e.type != "characterData" && e.type != "selection";
}
slice(e, t, r) {
let o = this.node.cut(e, t), i = document.createTextNode(o.text);
return new Rs(this.parent, o, this.outerDeco, this.innerDeco, i, i, r);
}
markDirty(e, t) {
super.markDirty(e, t), this.dom != this.nodeDOM && (e == 0 || t == this.nodeDOM.nodeValue.length) && (this.dirty = Kt);
}
get domAtom() {
return !1;
}
isText(e) {
return this.node.text == e;
}
}
class kd extends ti {
parseRule() {
return { ignore: !0 };
}
matchesHack(e) {
return this.dirty == wt && this.dom.nodeName == e;
}
get domAtom() {
return !0;
}
get ignoreForCoords() {
return this.dom.nodeName == "IMG";
}
}
class Im extends Fn {
constructor(e, t, r, o, i, s, l, a, c, p) {
super(e, t, r, o, i, s, l, c, p), this.spec = a;
}
// A custom `update` method gets to decide whether the update goes
// through. If it does, and there's a `contentDOM` node, our logic
// updates the children.
update(e, t, r, o) {
if (this.dirty == Kt)
return !1;
if (this.spec.update && (this.node.type == e.type || this.spec.multiType)) {
let i = this.spec.update(e, t, r);
return i && this.updateInner(e, t, r, o), i;
} else return !this.contentDOM && !e.isLeaf ? !1 : super.update(e, t, r, o);
}
selectNode() {
this.spec.selectNode ? this.spec.selectNode() : super.selectNode();
}
deselectNode() {
this.spec.deselectNode ? this.spec.deselectNode() : super.deselectNode();
}
setSelection(e, t, r, o) {
this.spec.setSelection ? this.spec.setSelection(e, t, r.root) : super.setSelection(e, t, r, o);
}
destroy() {
this.spec.destroy && this.spec.destroy(), super.destroy();
}
stopEvent(e) {
return this.spec.stopEvent ? this.spec.stopEvent(e) : !1;
}
ignoreMutation(e) {
return this.spec.ignoreMutation ? this.spec.ignoreMutation(e) : super.ignoreMutation(e);
}
}
function Cd(n, e, t) {
let r = n.firstChild, o = !1;
for (let i = 0; i < e.length; i++) {
let s = e[i], l = s.dom;
if (l.parentNode == n) {
for (; l != r; )
r = Xc(r), o = !0;
r = r.nextSibling;
} else
o = !0, n.insertBefore(l, r);
if (s instanceof kr) {
let a = r ? r.previousSibling : n.lastChild;
Cd(s.contentDOM, s.children, t), r = a ? a.nextSibling : n.firstChild;
}
}
for (; r; )
r = Xc(r), o = !0;
o && t.trackWrites == n && (t.trackWrites = null);
}
const ko = function(n) {
n && (this.nodeName = n);
};
ko.prototype = /* @__PURE__ */ Object.create(null);
const pr = [new ko()];
function Gl(n, e, t) {
if (n.length == 0)
return pr;
let r = t ? pr[0] : new ko(), o = [r];
for (let i = 0; i < n.length; i++) {
let s = n[i].type.attrs;
if (s) {
s.nodeName && o.push(r = new ko(s.nodeName));
for (let l in s) {
let a = s[l];
a != null && (t && o.length == 1 && o.push(r = new ko(e.isInline ? "span" : "div")), l == "class" ? r.class = (r.class ? r.class + " " : "") + a : l == "style" ? r.style = (r.style ? r.style + ";" : "") + a : l != "nodeName" && (r[l] = a));
}
}
}
return o;
}
function Md(n, e, t, r) {
if (t == pr && r == pr)
return e;
let o = e;
for (let i = 0; i < r.length; i++) {
let s = r[i], l = t[i];
if (i) {
let a;
l && l.nodeName == s.nodeName && o != n && (a = o.parentNode) && a.nodeName.toLowerCase() == s.nodeName || (a = document.createElement(s.nodeName), a.pmIsDeco = !0, a.appendChild(o), l = pr[0]), o = a;
}
$m(o, l || pr[0], s);
}
return o;
}
function $m(n, e, t) {
for (let r in e)
r != "class" && r != "style" && r != "nodeName" && !(r in t) && n.removeAttribute(r);
for (let r in t)
r != "class" && r != "style" && r != "nodeName" && t[r] != e[r] && n.setAttribute(r, t[r]);
if (e.class != t.class) {
let r = e.class ? e.class.split(" ").filter(Boolean) : [], o = t.class ? t.class.split(" ").filter(Boolean) : [];
for (let i = 0; i < r.length; i++)
o.indexOf(r[i]) == -1 && n.classList.remove(r[i]);
for (let i = 0; i < o.length; i++)
r.indexOf(o[i]) == -1 && n.classList.add(o[i]);
n.classList.length == 0 && n.removeAttribute("class");
}
if (e.style != t.style) {
if (e.style) {
let r = /\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g, o;
for (; o = r.exec(e.style); )
n.style.removeProperty(o[1]);
}
t.style && (n.style.cssText += t.style);
}
}
function Ed(n, e, t) {
return Md(n, n, pr, Gl(e, t, n.nodeType != 1));
}
function Ki(n, e) {
if (n.length != e.length)
return !1;
for (let t = 0; t < n.length; t++)
if (!n[t].type.eq(e[t].type))
return !1;
return !0;
}
function Xc(n) {
let e = n.nextSibling;
return n.parentNode.removeChild(n), e;
}
class Rm {
constructor(e, t, r) {
this.lock = t, this.view = r, this.index = 0, this.stack = [], this.changed = !1, this.top = e, this.preMatch = Fm(e.node.content, e);
}
// Destroy and remove the children between the given indices in
// `this.top`.
destroyBetween(e, t) {
if (e != t) {
for (let r = e; r < t; r++)
this.top.children[r].destroy();
this.top.children.splice(e, t - e), this.changed = !0;
}
}
// Destroy all remaining children in `this.top`.
destroyRest() {
this.destroyBetween(this.index, this.top.children.length);
}
// Sync the current stack of mark descs with the given array of
// marks, reusing existing mark descs when possible.
syncToMarks(e, t, r) {
let o = 0, i = this.stack.length >> 1, s = Math.min(i, e.length);
for (; o < s && (o == i - 1 ? this.top : this.stack[o + 1 << 1]).matchesMark(e[o]) && e[o].type.spec.spanning !== !1; )
o++;
for (; o < i; )
this.destroyRest(), this.top.dirty = wt, this.index = this.stack.pop(), this.top = this.stack.pop(), i--;
for (; i < e.length; ) {
this.stack.push(this.top, this.index + 1);
let l = -1;
for (let a = this.index; a < Math.min(this.index + 3, this.top.children.length); a++) {
let c = this.top.children[a];
if (c.matchesMark(e[i]) && !this.isLocked(c.dom)) {
l = a;
break;
}
}
if (l > -1)
l > this.index && (this.changed = !0, this.destroyBetween(this.index, l)), this.top = this.top.children[this.index];
else {
let a = kr.create(this.top, e[i], t, r);
this.top.children.splice(this.index, 0, a), this.top = a, this.changed = !0;
}
this.index = 0, i++;
}
}
// Try to find a node desc matching the given data. Skip over it and
// return true when successful.
findNodeMatch(e, t, r, o) {
let i = -1, s;
if (o >= this.preMatch.index && (s = this.preMatch.matches[o - this.preMatch.index]).parent == this.top && s.matchesNode(e, t, r))
i = this.top.children.indexOf(s, this.index);
else
for (let l = this.index, a = Math.min(this.top.children.length, l + 5); l < a; l++) {
let c = this.top.children[l];
if (c.matchesNode(e, t, r) && !this.preMatch.matched.has(c)) {
i = l;
break;
}
}
return i < 0 ? !1 : (this.destroyBetween(this.index, i), this.index++, !0);
}
updateNodeAt(e, t, r, o, i) {
let s = this.top.children[o];
return s.dirty == Kt && s.dom == s.contentDOM && (s.dirty = cr), s.update(e, t, r, i) ? (this.destroyBetween(this.index, o), this.index++, !0) : !1;
}
findIndexWithChild(e) {
for (; ; ) {
let t = e.parentNode;
if (!t)
return -1;
if (t == this.top.contentDOM) {
let r = e.pmViewDesc;
if (r) {
for (let o = this.index; o < this.top.children.length; o++)
if (this.top.children[o] == r)
return o;
}
return -1;
}
e = t;
}
}
// Try to update the next node, if any, to the given data. Checks
// pre-matches to avoid overwriting nodes that could still be used.
updateNextNode(e, t, r, o, i, s) {
for (let l = this.index; l < this.top.children.length; l++) {
let a = this.top.children[l];
if (a instanceof Fn) {
let c = this.preMatch.matched.get(a);
if (c != null && c != i)
return !1;
let p = a.dom, u, f = this.isLocked(p) && !(e.isText && a.node && a.node.isText && a.nodeDOM.nodeValue == e.text && a.dirty != Kt && Ki(t, a.outerDeco));
if (!f && a.update(e, t, r, o))
return this.destroyBetween(this.index, l), a.dom != p && (this.changed = !0), this.index++, !0;
if (!f && (u = this.recreateWrapper(a, e, t, r, o, s)))
return this.destroyBetween(this.index, l), this.top.children[this.index] = u, u.contentDOM && (u.dirty = cr, u.updateChildren(o, s + 1), u.dirty = wt), this.changed = !0, this.index++, !0;
break;
}
}
return !1;
}
// When a node with content is replaced by a different node with
// identical content, move over its children.
recreateWrapper(e, t, r, o, i, s) {
if (e.dirty || t.isAtom || !e.children.length || !e.node.content.eq(t.content) || !Ki(r, e.outerDeco) || !o.eq(e.innerDeco))
return null;
let l = Fn.create(this.top, t, r, o, i, s);
if (l.contentDOM) {
l.children = e.children, e.children = [];
for (let a of l.children)
a.parent = l;
}
return e.destroy(), l;
}
// Insert the node as a newly created node desc.
addNode(e, t, r, o, i) {
let s = Fn.create(this.top, e, t, r, o, i);
s.contentDOM && s.updateChildren(o, i + 1), this.top.children.splice(this.index++, 0, s), this.changed = !0;
}
placeWidget(e, t, r) {
let o = this.index < this.top.children.length ? this.top.children[this.index] : null;
if (o && o.matchesWidget(e) && (e == o.widget || !o.widget.type.toDOM.parentNode))
this.index++;
else {
let i = new Sd(this.top, e, t, r);
this.top.children.splice(this.index++, 0, i), this.changed = !0;
}
}
// Make sure a textblock looks and behaves correctly in
// contentEditable.
addTextblockHacks() {
let e = this.top.children[this.index - 1], t = this.top;
for (; e instanceof kr; )
t = e, e = t.children[t.children.length - 1];
(!e || // Empty textblock
!(e instanceof Rs) || /\n$/.test(e.node.text) || this.view.requiresGeckoHackNode && /\s$/.test(e.node.text)) && ((Je || qe) && e && e.dom.contentEditable == "false" && this.addHackNode("IMG", t), this.addHackNode("BR", this.top));
}
addHackNode(e, t) {
if (t == this.top && this.index < t.children.length && t.children[this.index].matchesHack(e))
this.index++;
else {
let r = document.createElement(e);
e == "IMG" && (r.className = "ProseMirror-separator", r.alt = ""), e == "BR" && (r.className = "ProseMirror-trailingBreak");
let o = new kd(this.top, [], r, null);
t != this.top ? t.children.push(o) : t.children.splice(this.index++, 0, o), this.changed = !0;
}
}
isLocked(e) {
return this.lock && (e == this.lock || e.nodeType == 1 && e.contains(this.lock.parentNode));
}
}
function Fm(n, e) {
let t = e, r = t.children.length, o = n.childCount, i = /* @__PURE__ */ new Map(), s = [];
e: for (; o > 0; ) {
let l;
for (; ; )
if (r) {
let c = t.children[r - 1];
if (c instanceof kr)
t = c, r = c.children.length;
else {
l = c, r--;
break;
}
} else {
if (t == e)
break e;
r = t.parent.children.indexOf(t), t = t.parent;
}
let a = l.node;
if (a) {
if (a != n.child(o - 1))
break;
--o, i.set(l, o), s.push(l);
}
}
return { index: o, matched: i, matches: s.reverse() };
}
function Hm(n, e) {
return n.type.side - e.type.side;
}
function jm(n, e, t, r) {
let o = e.locals(n), i = 0;
if (o.length == 0) {
for (let c = 0; c < n.childCount; c++) {
let p = n.child(c);
r(p, o, e.forChild(i, p), c), i += p.nodeSize;
}
return;
}
let s = 0, l = [], a = null;
for (let c = 0; ; ) {
let p, u;
for (; s < o.length && o[s].to == i; ) {
let x = o[s++];
x.widget && (p ? (u || (u = [p])).push(x) : p = x);
}
if (p)
if (u) {
u.sort(Hm);
for (let x = 0; x < u.length; x++)
t(u[x], c, !!a);
} else
t(p, c, !!a);
let f, h;
if (a)
h = -1, f = a, a = null;
else if (c < n.childCount)
h = c, f = n.child(c++);
else
break;
for (let x = 0; x < l.length; x++)
l[x].to <= i && l.splice(x--, 1);
for (; s < o.length && o[s].from <= i && o[s].to > i; )
l.push(o[s++]);
let b = i + f.nodeSize;
if (f.isText) {
let x = b;
s < o.length && o[s].from < x && (x = o[s].from);
for (let v = 0; v < l.length; v++)
l[v].to < x && (x = l[v].to);
x < b && (a = f.cut(x - i), f = f.cut(0, x - i), b = x, h = -1);
} else
for (; s < o.length && o[s].to < b; )
s++;
let m = f.isInline && !f.isLeaf ? l.filter((x) => !x.inline) : l.slice();
r(f, m, e.forChild(i, f), h), i = b;
}
}
function zm(n) {
if (n.nodeName == "UL" || n.nodeName == "OL") {
let e = n.style.cssText;
n.style.cssText = e + "; list-style: square !important", window.getComputedStyle(n).listStyle, n.style.cssText = e;
}
}
function Vm(n, e, t, r) {
for (let o = 0, i = 0; o < n.childCount && i <= r; ) {
let s = n.child(o++), l = i;
if (i += s.nodeSize, !s.isText)
continue;
let a = s.text;
for (; o < n.childCount; ) {
let c = n.child(o++);
if (i += c.nodeSize, !c.isText)
break;
a += c.text;
}
if (i >= t) {
if (i >= r && a.slice(r - e.length - l, r - l) == e)
return r - e.length;
let c = l < r ? a.lastIndexOf(e, r - l - 1) : -1;
if (c >= 0 && c + e.length + l >= t)
return l + c;
if (t == r && a.length >= r + e.length - l && a.slice(r - l, r - l + e.length) == e)
return r;
}
}
return -1;
}
function Jl(n, e, t, r, o) {
let i = [];
for (let s = 0, l = 0; s < n.length; s++) {
let a = n[s], c = l, p = l += a.size;
c >= t || p <= e ? i.push(a) : (c < e && i.push(a.slice(0, e - c, r)), o && (i.push(o), o = void 0), p > t && i.push(a.slice(t - c, a.size, r)));
}
return i;
}
function Oa(n, e = null) {
let t = n.domSelectionRange(), r = n.state.doc;
if (!t.focusNode)
return null;
let o = n.docView.nearestDesc(t.focusNode), i = o && o.size == 0, s = n.docView.posFromDOM(t.focusNode, t.focusOffset, 1);
if (s < 0)
return null;
let l = r.resolve(s), a, c;
if ($s(t)) {
for (a = s; o && !o.node; )
o = o.parent;
let u = o.node;
if (o && u.isAtom && J.isSelectable(u) && o.parent && !(u.isInline && bm(t.focusNode, t.focusOffset, o.dom))) {
let f = o.posBefore;
c = new J(s == f ? l : r.resolve(f));
}
} else {
if (t instanceof n.dom.ownerDocument.defaultView.Selection && t.rangeCount > 1) {
let u = s, f = s;
for (let h = 0; h < t.rangeCount; h++) {
let b = t.getRangeAt(h);
u = Math.min(u, n.docView.posFromDOM(b.startContainer, b.startOffset, 1)), f = Math.max(f, n.docView.posFromDOM(b.endContainer, b.endOffset, -1));
}
if (u < 0)
return null;
[a, s] = f == n.state.selection.anchor ? [f, u] : [u, f], l = r.resolve(s);
} else
a = n.docView.posFromDOM(t.anchorNode, t.anchorOffset, 1);
if (a < 0)
return null;
}
let p = r.resolve(a);
if (!c) {
let u = e == "pointer" || n.state.selection.head < l.pos && !i ? 1 : -1;
c = Ba(n, p, l, u);
}
return c;
}
function Td(n) {
return n.editable ? n.hasFocus() : Bd(n) && document.activeElement && document.activeElement.contains(n.dom);
}
function cn(n, e = !1) {
let t = n.state.selection;
if (Od(n, t), !!Td(n)) {
if (!e && n.input.mouseDown && n.input.mouseDown.allowDefault && qe) {
let r = n.domSelectionRange(), o = n.domObserver.currentSelection;
if (r.anchorNode && o.anchorNode && Sr(r.anchorNode, r.anchorOffset, o.anchorNode, o.anchorOffset)) {
n.input.mouseDown.delayedSelectionSync = !0, n.domObserver.setCurSelection();
return;
}
}
if (n.domObserver.disconnectSelection(), n.cursorWrapper)
Um(n);
else {
let { anchor: r, head: o } = t, i, s;
Qc && !(t instanceof Q) && (t.$from.parent.inlineContent || (i = Zc(n, t.from)), !t.empty && !t.$from.parent.inlineContent && (s = Zc(n, t.to))), n.docView.setSelection(r, o, n, e), Qc && (i && ep(i), s && ep(s)), t.visible ? n.dom.classList.remove("ProseMirror-hideselection") : (n.dom.classList.add("ProseMirror-hideselection"), "onselectionchange" in document && Wm(n));
}
n.domObserver.setCurSelection(), n.domObserver.connectSelection();
}
}
const Qc = Je || qe && bd < 63;
function Zc(n, e) {
let { node: t, offset: r } = n.docView.domFromPos(e, 0), o = r < t.childNodes.length ? t.childNodes[r] : null, i = r ? t.childNodes[r - 1] : null;
if (Je && o && o.contentEditable == "false")
return al(o);
if ((!o || o.contentEditable == "false") && (!i || i.contentEditable == "false")) {
if (o)
return al(o);
if (i)
return al(i);
}
}
function al(n) {
return n.contentEditable = "true", Je && n.draggable && (n.draggable = !1, n.wasDraggable = !0), n;
}
function ep(n) {
n.contentEditable = "false", n.wasDraggable && (n.draggable = !0, n.wasDraggable = null);
}
function Wm(n) {
let e = n.dom.ownerDocument;
e.removeEventListener("selectionchange", n.input.hideSelectionGuard);
let t = n.domSelectionRange(), r = t.anchorNode, o = t.anchorOffset;
e.addEventListener("selectionchange", n.input.hideSelectionGuard = () => {
(t.anchorNode != r || t.anchorOffset != o) && (e.removeEventListener("selectionchange", n.input.hideSelectionGuard), setTimeout(() => {
(!Td(n) || n.state.selection.visible) && n.dom.classList.remove("ProseMirror-hideselection");
}, 20));
});
}
function Um(n) {
let e = n.domSelection(), t = document.createRange();
if (!e)
return;
let r = n.cursorWrapper.dom, o = r.nodeName == "IMG";
o ? t.setStart(r.parentNode, Re(r) + 1) : t.setStart(r, 0), t.collapse(!0), e.removeAllRanges(), e.addRange(t), !o && !n.state.selection.visible && nt && Rn <= 11 && (r.disabled = !0, r.disabled = !1);
}
function Od(n, e) {
if (e instanceof J) {
let t = n.docView.descAt(e.from);
t != n.lastSelectedViewDesc && (tp(n), t && t.selectNode(), n.lastSelectedViewDesc = t);
} else
tp(n);
}
function tp(n) {
n.lastSelectedViewDesc && (n.lastSelectedViewDesc.parent && n.lastSelectedViewDesc.deselectNode(), n.lastSelectedViewDesc = void 0);
}
function Ba(n, e, t, r) {
return n.someProp("createSelectionBetween", (o) => o(n, e, t)) || Q.between(e, t, r);
}
function np(n) {
return n.editable && !n.hasFocus() ? !1 : Bd(n);
}
function Bd(n) {
let e = n.domSelectionRange();
if (!e.anchorNode)
return !1;
try {
return n.dom.contains(e.anchorNode.nodeType == 3 ? e.anchorNode.parentNode : e.anchorNode) && (n.editable || n.dom.contains(e.focusNode.nodeType == 3 ? e.focusNode.parentNode : e.focusNode));
} catch {
return !1;
}
}
function qm(n) {
let e = n.docView.domFromPos(n.state.selection.anchor, 0), t = n.domSelectionRange();
return Sr(e.node, e.offset, t.anchorNode, t.anchorOffset);
}
function Yl(n, e) {
let { $anchor: t, $head: r } = n.selection, o = e > 0 ? t.max(r) : t.min(r), i = o.parent.inlineContent ? o.depth ? n.doc.resolve(e > 0 ? o.after() : o.before()) : null : o;
return i && te.findFrom(i, e);
}
function kn(n, e) {
return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()), !0;
}
function rp(n, e, t) {
let r = n.state.selection;
if (r instanceof Q)
if (t.indexOf("s") > -1) {
let { $head: o } = r, i = o.textOffset ? null : e < 0 ? o.nodeBefore : o.nodeAfter;
if (!i || i.isText || !i.isLeaf)
return !1;
let s = n.state.doc.resolve(o.pos + i.nodeSize * (e < 0 ? -1 : 1));
return kn(n, new Q(r.$anchor, s));
} else if (r.empty) {
if (n.endOfTextblock(e > 0 ? "forward" : "backward")) {
let o = Yl(n.state, e);
return o && o instanceof J ? kn(n, o) : !1;
} else if (!(gt && t.indexOf("m") > -1)) {
let o = r.$head, i = o.textOffset ? null : e < 0 ? o.nodeBefore : o.nodeAfter, s;
if (!i || i.isText)
return !1;
let l = e < 0 ? o.pos - i.nodeSize : o.pos;
return i.isAtom || (s = n.docView.descAt(l)) && !s.contentDOM ? J.isSelectable(i) ? kn(n, new J(e < 0 ? n.state.doc.resolve(o.pos - i.nodeSize) : o)) : ei ? kn(n, new Q(n.state.doc.resolve(e < 0 ? l : l + i.nodeSize))) : !1 : !1;
}
} else return !1;
else {
if (r instanceof J && r.node.isInline)
return kn(n, new Q(e > 0 ? r.$to : r.$from));
{
let o = Yl(n.state, e);
return o ? kn(n, o) : !1;
}
}
}
function Gi(n) {
return n.nodeType == 3 ? n.nodeValue.length : n.childNodes.length;
}
function Co(n, e) {
let t = n.pmViewDesc;
return t && t.size == 0 && (e < 0 || n.nextSibling || n.nodeName != "BR");
}
function Ar(n, e) {
return e < 0 ? Km(n) : Gm(n);
}
function Km(n) {
let e = n.domSelectionRange(), t = e.focusNode, r = e.focusOffset;
if (!t)
return;
let o, i, s = !1;
for (Lt && t.nodeType == 1 && r < Gi(t) && Co(t.childNodes[r], -1) && (s = !0); ; )
if (r > 0) {
if (t.nodeType != 1)
break;
{
let l = t.childNodes[r - 1];
if (Co(l, -1))
o = t, i = --r;
else if (l.nodeType == 3)
t = l, r = t.nodeValue.length;
else
break;
}
} else {
if (Pd(t))
break;
{
let l = t.previousSibling;
for (; l && Co(l, -1); )
o = t.parentNode, i = Re(l), l = l.previousSibling;
if (l)
t = l, r = Gi(t);
else {
if (t = t.parentNode, t == n.dom)
break;
r = 0;
}
}
}
s ? Xl(n, t, r) : o && Xl(n, o, i);
}
function Gm(n) {
let e = n.domSelectionRange(), t = e.focusNode, r = e.focusOffset;
if (!t)
return;
let o = Gi(t), i, s;
for (; ; )
if (r < o) {
if (t.nodeType != 1)
break;
let l = t.childNodes[r];
if (Co(l, 1))
i = t, s = ++r;
else
break;
} else {
if (Pd(t))
break;
{
let l = t.nextSibling;
for (; l && Co(l, 1); )
i = l.parentNode, s = Re(l) + 1, l = l.nextSibling;
if (l)
t = l, r = 0, o = Gi(t);
else {
if (t = t.parentNode, t == n.dom)
break;
r = o = 0;
}
}
}
i && Xl(n, i, s);
}
function Pd(n) {
let e = n.pmViewDesc;
return e && e.node && e.node.isBlock;
}
function Jm(n, e) {
for (; n && e == n.childNodes.length && !Zo(n); )
e = Re(n) + 1, n = n.parentNode;
for (; n && e < n.childNodes.length; ) {
let t = n.childNodes[e];
if (t.nodeType == 3)
return t;
if (t.nodeType == 1 && t.contentEditable == "false")
break;
n = t, e = 0;
}
}
function Ym(n, e) {
for (; n && !e && !Zo(n); )
e = Re(n), n = n.parentNode;
for (; n && e; ) {
let t = n.childNodes[e - 1];
if (t.nodeType == 3)
return t;
if (t.nodeType == 1 && t.contentEditable == "false")
break;
n = t, e = n.childNodes.length;
}
}
function Xl(n, e, t) {
if (e.nodeType != 3) {
let i, s;
(s = Jm(e, t)) ? (e = s, t = 0) : (i = Ym(e, t)) && (e = i, t = i.nodeValue.length);
}
let r = n.domSelection();
if (!r)
return;
if ($s(r)) {
let i = document.createRange();
i.setEnd(e, t), i.setStart(e, t), r.removeAllRanges(), r.addRange(i);
} else r.extend && r.extend(e, t);
n.domObserver.setCurSelection();
let { state: o } = n;
setTimeout(() => {
n.state == o && cn(n);
}, 50);
}
function op(n, e) {
let t = n.state.doc.resolve(e);
if (!(qe || gm) && t.parent.inlineContent) {
let o = n.coordsAtPos(e);
if (e > t.start()) {
let i = n.coordsAtPos(e - 1), s = (i.top + i.bottom) / 2;
if (s > o.top && s < o.bottom && Math.abs(i.left - o.left) > 1)
return i.left < o.left ? "ltr" : "rtl";
}
if (e < t.end()) {
let i = n.coordsAtPos(e + 1), s = (i.top + i.bottom) / 2;
if (s > o.top && s < o.bottom && Math.abs(i.left - o.left) > 1)
return i.left > o.left ? "ltr" : "rtl";
}
}
return getComputedStyle(n.dom).direction == "rtl" ? "rtl" : "ltr";
}
function ip(n, e, t) {
let r = n.state.selection;
if (r instanceof Q && !r.empty || t.indexOf("s") > -1 || gt && t.indexOf("m") > -1)
return !1;
let { $from: o, $to: i } = r;
if (!o.parent.inlineContent || n.endOfTextblock(e < 0 ? "up" : "down")) {
let s = Yl(n.state, e);
if (s && s instanceof J)
return kn(n, s);
}
if (!o.parent.inlineContent) {
let s = e < 0 ? o : i, l = r instanceof ct ? te.near(s, e) : te.findFrom(s, e);
return l ? kn(n, l) : !1;
}
return !1;
}
function sp(n, e) {
if (!(n.state.selection instanceof Q))
return !0;
let { $head: t, $anchor: r, empty: o } = n.state.selection;
if (!t.sameParent(r))
return !0;
if (!o)
return !1;
if (n.endOfTextblock(e > 0 ? "forward" : "backward"))
return !0;
let i = !t.textOffset && (e < 0 ? t.nodeBefore : t.nodeAfter);
if (i && !i.isText) {
let s = n.state.tr;
return e < 0 ? s.delete(t.pos - i.nodeSize, t.pos) : s.delete(t.pos, t.pos + i.nodeSize), n.dispatch(s), !0;
}
return !1;
}
function lp(n, e, t) {
n.domObserver.stop(), e.contentEditable = t, n.domObserver.start();
}
function Xm(n) {
if (!Je || n.state.selection.$head.parentOffset > 0)
return !1;
let { focusNode: e, focusOffset: t } = n.domSelectionRange();
if (e && e.nodeType == 1 && t == 0 && e.firstChild && e.firstChild.contentEditable == "false") {
let r = e.firstChild;
lp(n, r, "true"), setTimeout(() => lp(n, r, "false"), 20);
}
return !1;
}
function Qm(n) {
let e = "";
return n.ctrlKey && (e += "c"), n.metaKey && (e += "m"), n.altKey && (e += "a"), n.shiftKey && (e += "s"), e;
}
function Zm(n, e) {
let t = e.keyCode, r = Qm(e);
if (t == 8 || gt && t == 72 && r == "c")
return sp(n, -1) || Ar(n, -1);
if (t == 46 && !e.shiftKey || gt && t == 68 && r == "c")
return sp(n, 1) || Ar(n, 1);
if (t == 13 || t == 27)
return !0;
if (t == 37 || gt && t == 66 && r == "c") {
let o = t == 37 ? op(n, n.state.selection.from) == "ltr" ? -1 : 1 : -1;
return rp(n, o, r) || Ar(n, o);
} else if (t == 39 || gt && t == 70 && r == "c") {
let o = t == 39 ? op(n, n.state.selection.from) == "ltr" ? 1 : -1 : 1;
return rp(n, o, r) || Ar(n, o);
} else {
if (t == 38 || gt && t == 80 && r == "c")
return ip(n, -1, r) || Ar(n, -1);
if (t == 40 || gt && t == 78 && r == "c")
return Xm(n) || ip(n, 1, r) || Ar(n, 1);
if (r == (gt ? "m" : "c") && (t == 66 || t == 73 || t == 89 || t == 90))
return !0;
}
return !1;
}
function Pa(n, e) {
n.someProp("transformCopied", (h) => {
e = h(e, n);
});
let t = [], { content: r, openStart: o, openEnd: i } = e;
for (; o > 1 && i > 1 && r.childCount == 1 && r.firstChild.childCount == 1; ) {
o--, i--;
let h = r.firstChild;
t.push(h.type.name, h.attrs != h.type.defaultAttrs ? h.attrs : null), r = h.content;
}
let s = n.someProp("clipboardSerializer") || Or.fromSchema(n.state.schema), l = Id(), a = l.createElement("div");
a.appendChild(s.serializeFragment(r, { document: l }));
let c = a.firstChild, p, u = 0;
for (; c && c.nodeType == 1 && (p = Dd[c.nodeName.toLowerCase()]); ) {
for (let h = p.length - 1; h >= 0; h--) {
let b = l.createElement(p[h]);
for (; a.firstChild; )
b.appendChild(a.firstChild);
a.appendChild(b), u++;
}
c = a.firstChild;
}
c && c.nodeType == 1 && c.setAttribute("data-pm-slice", `${o} ${i}${u ? ` -${u}` : ""} ${JSON.stringify(t)}`);
let f = n.someProp("clipboardTextSerializer", (h) => h(e, n)) || e.content.textBetween(0, e.content.size, `
`);
return { dom: a, text: f, slice: e };
}
function Ad(n, e, t, r, o) {
let i = o.parent.type.spec.code, s, l;
if (!t && !e)
return null;
let a = e && (r || i || !t);
if (a) {
if (n.someProp("transformPastedText", (f) => {
e = f(e, i || r, n);
}), i)
return e ? new z(D.from(n.state.schema.text(e.replace(/\r\n?/g, `
`))), 0, 0) : z.empty;
let u = n.someProp("clipboardTextParser", (f) => f(e, o, r, n));
if (u)
l = u;
else {
let f = o.marks(), { schema: h } = n.state, b = Or.fromSchema(h);
s = document.createElement("div"), e.split(/(?:\r\n?|\n)+/).forEach((m) => {
let x = s.appendChild(document.createElement("p"));
m && x.appendChild(b.serializeNode(h.text(m, f)));
});
}
} else
n.someProp("transformPastedHTML", (u) => {
t = u(t, n);
}), s = rx(t), ei && ox(s);
let c = s && s.querySelector("[data-pm-slice]"), p = c && /^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice") || "");
if (p && p[3])
for (let u = +p[3]; u > 0; u--) {
let f = s.firstChild;
for (; f && f.nodeType != 1; )
f = f.nextSibling;
if (!f)
break;
s = f;
}
if (l || (l = (n.someProp("clipboardParser") || n.someProp("domParser") || wo.fromSchema(n.state.schema)).parseSlice(s, {
preserveWhitespace: !!(a || p),
context: o,
ruleFromNode(f) {
return f.nodeName == "BR" && !f.nextSibling && f.parentNode && !ex.test(f.parentNode.nodeName) ? { ignore: !0 } : null;
}
})), p)
l = ix(ap(l, +p[1], +p[2]), p[4]);
else if (l = z.maxOpen(tx(l.content, o), !0), l.openStart || l.openEnd) {
let u = 0, f = 0;
for (let h = l.content.firstChild; u < l.openStart && !h.type.spec.isolating; u++, h = h.firstChild)
;
for (let h = l.content.lastChild; f < l.openEnd && !h.type.spec.isolating; f++, h = h.lastChild)
;
l = ap(l, u, f);
}
return n.someProp("transformPasted", (u) => {
l = u(l, n);
}), l;
}
const ex = /^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;
function tx(n, e) {
if (n.childCount < 2)
return n;
for (let t = e.depth; t >= 0; t--) {
let o = e.node(t).contentMatchAt(e.index(t)), i, s = [];
if (n.forEach((l) => {
if (!s)
return;
let a = o.findWrapping(l.type), c;
if (!a)
return s = null;
if (c = s.length && i.length && Ld(a, i, l, s[s.length - 1], 0))
s[s.length - 1] = c;
else {
s.length && (s[s.length - 1] = Nd(s[s.length - 1], i.length));
let p = _d(l, a);
s.push(p), o = o.matchType(p.type), i = a;
}
}), s)
return D.from(s);
}
return n;
}
function _d(n, e, t = 0) {
for (let r = e.length - 1; r >= t; r--)
n = e[r].create(null, D.from(n));
return n;
}
function Ld(n, e, t, r, o) {
if (o < n.length && o < e.length && n[o] == e[o]) {
let i = Ld(n, e, t, r.lastChild, o + 1);
if (i)
return r.copy(r.content.replaceChild(r.childCount - 1, i));
if (r.contentMatchAt(r.childCount).matchType(o == n.length - 1 ? t.type : n[o + 1]))
return r.copy(r.content.append(D.from(_d(t, n, o + 1))));
}
}
function Nd(n, e) {
if (e == 0)
return n;
let t = n.content.replaceChild(n.childCount - 1, Nd(n.lastChild, e - 1)), r = n.contentMatchAt(n.childCount).fillBefore(D.empty, !0);
return n.copy(t.append(r));
}
function Ql(n, e, t, r, o, i) {
let s = e < 0 ? n.firstChild : n.lastChild, l = s.content;
return n.childCount > 1 && (i = 0), o < r - 1 && (l = Ql(l, e, t, r, o + 1, i)), o >= t && (l = e < 0 ? s.contentMatchAt(0).fillBefore(l, i <= o).append(l) : l.append(s.contentMatchAt(s.childCount).fillBefore(D.empty, !0))), n.replaceChild(e < 0 ? 0 : n.childCount - 1, s.copy(l));
}
function ap(n, e, t) {
return e < n.openStart && (n = new z(Ql(n.content, -1, e, n.openStart, 0, n.openEnd), e, n.openEnd)), t < n.openEnd && (n = new z(Ql(n.content, 1, t, n.openEnd, 0, 0), n.openStart, t)), n;
}
const Dd = {
thead: ["table"],
tbody: ["table"],
tfoot: ["table"],
caption: ["table"],
colgroup: ["table"],
col: ["table", "colgroup"],
tr: ["table", "tbody"],
td: ["table", "tbody", "tr"],
th: ["table", "tbody", "tr"]
};
let cp = null;
function Id() {
return cp || (cp = document.implementation.createHTMLDocument("title"));
}
let cl = null;
function nx(n) {
let e = window.trustedTypes;
return e ? (cl || (cl = e.defaultPolicy || e.createPolicy("ProseMirrorClipboard", { createHTML: (t) => t })), cl.createHTML(n)) : n;
}
function rx(n) {
let e = /^(\s*<meta [^>]*>)*/.exec(n);
e && (n = n.slice(e[0].length));
let t = Id().createElement("div"), r = /<([a-z][^>\s]+)/i.exec(n), o;
if ((o = r && Dd[r[1].toLowerCase()]) && (n = o.map((i) => "<" + i + ">").join("") + n + o.map((i) => "</" + i + ">").reverse().join("")), t.innerHTML = nx(n), o)
for (let i = 0; i < o.length; i++)
t = t.querySelector(o[i]) || t;
return t;
}
function ox(n) {
let e = n.querySelectorAll(qe ? "span:not([class]):not([style])" : "span.Apple-converted-space");
for (let t = 0; t < e.length; t++) {
let r = e[t];
r.childNodes.length == 1 && r.textContent == " " && r.parentNode && r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "), r);
}
}
function ix(n, e) {
if (!n.size)
return n;
let t = n.content.firstChild.type.schema, r;
try {
r = JSON.parse(e);
} catch {
return n;
}
let { content: o, openStart: i, openEnd: s } = n;
for (let l = r.length - 2; l >= 0; l -= 2) {
let a = t.nodes[r[l]];
if (!a || a.hasRequiredAttrs())
break;
o = D.from(a.create(r[l + 1], o)), i++, s++;
}
return new z(o, i, s);
}
const Ye = {}, Xe = {}, sx = { touchstart: !0, touchmove: !0 };
class lx {
constructor() {
this.shiftKey = !1, this.mouseDown = null, this.lastKeyCode = null, this.lastKeyCodeTime = 0, this.lastClick = { time: 0, x: 0, y: 0, type: "", button: 0 }, this.lastSelectionOrigin = null, this.lastSelectionTime = 0, this.lastIOSEnter = 0, this.lastIOSEnterFallbackTimeout = -1, this.lastFocus = 0, this.lastTouch = 0, this.lastChromeDelete = 0, this.composing = !1, this.compositionNode = null, this.composingTimeout = -1, this.compositionNodes = [], this.compositionEndedAt = -2e8, this.compositionID = 1, this.compositionPendingChanges = 0, this.domChangeCount = 0, this.eventHandlers = /* @__PURE__ */ Object.create(null), this.hideSelectionGuard = null;
}
}
function ax(n) {
for (let e in Ye) {
let t = Ye[e];
n.dom.addEventListener(e, n.input.eventHandlers[e] = (r) => {
px(n, r) && !Aa(n, r) && (n.editable || !(r.type in Xe)) && t(n, r);
}, sx[e] ? { passive: !0 } : void 0);
}
Je && n.dom.addEventListener("input", () => null), Zl(n);
}
function Nn(n, e) {
n.input.lastSelectionOrigin = e, n.input.lastSelectionTime = Date.now();
}
function cx(n) {
n.domObserver.stop();
for (let e in n.input.eventHandlers)
n.dom.removeEventListener(e, n.input.eventHandlers[e]);
clearTimeout(n.input.composingTimeout), clearTimeout(n.input.lastIOSEnterFallbackTimeout);
}
function Zl(n) {
n.someProp("handleDOMEvents", (e) => {
for (let t in e)
n.input.eventHandlers[t] || n.dom.addEventListener(t, n.input.eventHandlers[t] = (r) => Aa(n, r));
});
}
function Aa(n, e) {
return n.someProp("handleDOMEvents", (t) => {
let r = t[e.type];
return r ? r(n, e) || e.defaultPrevented : !1;
});
}
function px(n, e) {
if (!e.bubbles)
return !0;
if (e.defaultPrevented)
return !1;
for (let t = e.target; t != n.dom; t = t.parentNode)
if (!t || t.nodeType == 11 || t.pmViewDesc && t.pmViewDesc.stopEvent(e))
return !1;
return !0;
}
function ux(n, e) {
!Aa(n, e) && Ye[e.type] && (n.editable || !(e.type in Xe)) && Ye[e.type](n, e);
}
Xe.keydown = (n, e) => {
let t = e;
if (n.input.shiftKey = t.keyCode == 16 || t.shiftKey, !Rd(n, t) && (n.input.lastKeyCode = t.keyCode, n.input.lastKeyCodeTime = Date.now(), !(sn && qe && t.keyCode == 13)))
if (t.keyCode != 229 && n.domObserver.forceFlush(), Jr && t.keyCode == 13 && !t.ctrlKey && !t.altKey && !t.metaKey) {
let r = Date.now();
n.input.lastIOSEnter = r, n.input.lastIOSEnterFallbackTimeout = setTimeout(() => {
n.input.lastIOSEnter == r && (n.someProp("handleKeyDown", (o) => o(n, sr(13, "Enter"))), n.input.lastIOSEnter = 0);
}, 200);
} else n.someProp("handleKeyDown", (r) => r(n, t)) || Zm(n, t) ? t.preventDefault() : Nn(n, "key");
};
Xe.keyup = (n, e) => {
e.keyCode == 16 && (n.input.shiftKey = !1);
};
Xe.keypress = (n, e) => {
let t = e;
if (Rd(n, t) || !t.charCode || t.ctrlKey && !t.altKey || gt && t.metaKey)
return;
if (n.someProp("handleKeyPress", (o) => o(n, t))) {
t.preventDefault();
return;
}
let r = n.state.selection;
if (!(r instanceof Q) || !r.$from.sameParent(r.$to)) {
let o = String.fromCharCode(t.charCode), i = () => n.state.tr.insertText(o).scrollIntoView();
!/[\r\n]/.test(o) && !n.someProp("handleTextInput", (s) => s(n, r.$from.pos, r.$to.pos, o, i)) && n.dispatch(i()), t.preventDefault();
}
};
function Fs(n) {
return { left: n.clientX, top: n.clientY };
}
function dx(n, e) {
let t = e.x - n.clientX, r = e.y - n.clientY;
return t * t + r * r < 100;
}
function _a(n, e, t, r, o) {
if (r == -1)
return !1;
let i = n.state.doc.resolve(r);
for (let s = i.depth + 1; s > 0; s--)
if (n.someProp(e, (l) => s > i.depth ? l(n, t, i.nodeAfter, i.before(s), o, !0) : l(n, t, i.node(s), i.before(s), o, !1)))
return !0;
return !1;
}
function qr(n, e, t) {
if (n.focused || n.focus(), n.state.selection.eq(e))
return;
let r = n.state.tr.setSelection(e);
r.setMeta("pointer", !0), n.dispatch(r);
}
function fx(n, e) {
if (e == -1)
return !1;
let t = n.state.doc.resolve(e), r = t.nodeAfter;
return r && r.isAtom && J.isSelectable(r) ? (qr(n, new J(t)), !0) : !1;
}
function hx(n, e) {
if (e == -1)
return !1;
let t = n.state.selection, r, o;
t instanceof J && (r = t.node);
let i = n.state.doc.resolve(e);
for (let s = i.depth + 1; s > 0; s--) {
let l = s > i.depth ? i.nodeAfter : i.node(s);
if (J.isSelectable(l)) {
r && t.$from.depth > 0 && s >= t.$from.depth && i.before(t.$from.depth + 1) == t.$from.pos ? o = i.before(t.$from.depth) : o = i.before(s);
break;
}
}
return o != null ? (qr(n, J.create(n.state.doc, o)), !0) : !1;
}
function bx(n, e, t, r, o) {
return _a(n, "handleClickOn", e, t, r) || n.someProp("handleClick", (i) => i(n, e, r)) || (o ? hx(n, t) : fx(n, t));
}
function mx(n, e, t, r) {
return _a(n, "handleDoubleClickOn", e, t, r) || n.someProp("handleDoubleClick", (o) => o(n, e, r));
}
function xx(n, e, t, r) {
return _a(n, "handleTripleClickOn", e, t, r) || n.someProp("handleTripleClick", (o) => o(n, e, r)) || gx(n, t, r);
}
function gx(n, e, t) {
if (t.button != 0)
return !1;
let r = n.state.doc;
if (e == -1)
return r.inlineContent ? (qr(n, Q.create(r, 0, r.content.size)), !0) : !1;
let o = r.resolve(e);
for (let i = o.depth + 1; i > 0; i--) {
let s = i > o.depth ? o.nodeAfter : o.node(i), l = o.before(i);
if (s.inlineContent)
qr(n, Q.create(r, l + 1, l + 1 + s.content.size));
else if (J.isSelectable(s))
qr(n, J.create(r, l));
else
continue;
return !0;
}
}
function La(n) {
return Ji(n);
}
const $d = gt ? "metaKey" : "ctrlKey";
Ye.mousedown = (n, e) => {
let t = e;
n.input.shiftKey = t.shiftKey;
let r = La(n), o = Date.now(), i = "singleClick";
o - n.input.lastClick.time < 500 && dx(t, n.input.lastClick) && !t[$d] && n.input.lastClick.button == t.button && (n.input.lastClick.type == "singleClick" ? i = "doubleClick" : n.input.lastClick.type == "doubleClick" && (i = "tripleClick")), n.input.lastClick = { time: o, x: t.clientX, y: t.clientY, type: i, button: t.button };
let s = n.posAtCoords(Fs(t));
s && (i == "singleClick" ? (n.input.mouseDown && n.input.mouseDown.done(), n.input.mouseDown = new yx(n, s, t, !!r)) : (i == "doubleClick" ? mx : xx)(n, s.pos, s.inside, t) ? t.preventDefault() : Nn(n, "pointer"));
};
class yx {
constructor(e, t, r, o) {
this.view = e, this.pos = t, this.event = r, this.flushed = o, this.delayedSelectionSync = !1, this.mightDrag = null, this.startDoc = e.state.doc, this.selectNode = !!r[$d], this.allowDefault = r.shiftKey;
let i, s;
if (t.inside > -1)
i = e.state.doc.nodeAt(t.inside), s = t.inside;
else {
let p = e.state.doc.resolve(t.pos);
i = p.parent, s = p.depth ? p.before() : 0;
}
const l = o ? null : r.target, a = l ? e.docView.nearestDesc(l, !0) : null;
this.target = a && a.dom.nodeType == 1 ? a.dom : null;
let { selection: c } = e.state;
(r.button == 0 && i.type.spec.draggable && i.type.spec.selectable !== !1 || c instanceof J && c.from <= s && c.to > s) && (this.mightDrag = {
node: i,
pos: s,
addAttr: !!(this.target && !this.target.draggable),
setUneditable: !!(this.target && Lt && !this.target.hasAttribute("contentEditable"))
}), this.target && this.mightDrag && (this.mightDrag.addAttr || this.mightDrag.setUneditable) && (this.view.domObserver.stop(), this.mightDrag.addAttr && (this.target.draggable = !0), this.mightDrag.setUneditable && setTimeout(() => {
this.view.input.mouseDown == this && this.target.setAttribute("contentEditable", "false");
}, 20), this.view.domObserver.start()), e.root.addEventListener("mouseup", this.up = this.up.bind(this)), e.root.addEventListener("mousemove", this.move = this.move.bind(this)), Nn(e, "pointer");
}
done() {
this.view.root.removeEventListener("mouseup", this.up), this.view.root.removeEventListener("mousemove", this.move), this.mightDrag && this.target && (this.view.domObserver.stop(), this.mightDrag.addAttr && this.target.removeAttribute("draggable"), this.mightDrag.setUneditable && this.target.removeAttribute("contentEditable"), this.view.domObserver.start()), this.delayedSelectionSync && setTimeout(() => cn(this.view)), this.view.input.mouseDown = null;
}
up(e) {
if (this.done(), !this.view.dom.contains(e.target))
return;
let t = this.pos;
this.view.state.doc != this.startDoc && (t = this.view.posAtCoords(Fs(e))), this.updateAllowDefault(e), this.allowDefault || !t ? Nn(this.view, "pointer") : bx(this.view, t.pos, t.inside, e, this.selectNode) ? e.preventDefault() : e.button == 0 && (this.flushed || // Safari ignores clicks on draggable elements
Je && this.mightDrag && !this.mightDrag.node.isAtom || // Chrome will sometimes treat a node selection as a
// cursor, but still report that the node is selected
// when asked through getSelection. You'll then get a
// situation where clicking at the point where that
// (hidden) cursor is doesn't change the selection, and
// thus doesn't get a reaction from ProseMirror. This
// works around that.
qe && !this.view.state.selection.visible && Math.min(Math.abs(t.pos - this.view.state.selection.from), Math.abs(t.pos - this.view.state.selection.to)) <= 2) ? (qr(this.view, te.near(this.view.state.doc.resolve(t.pos))), e.preventDefault()) : Nn(this.view, "pointer");
}
move(e) {
this.updateAllowDefault(e), Nn(this.view, "pointer"), e.buttons == 0 && this.done();
}
updateAllowDefault(e) {
!this.allowDefault && (Math.abs(this.event.x - e.clientX) > 4 || Math.abs(this.event.y - e.clientY) > 4) && (this.allowDefault = !0);
}
}
Ye.touchstart = (n) => {
n.input.lastTouch = Date.now(), La(n), Nn(n, "pointer");
};
Ye.touchmove = (n) => {
n.input.lastTouch = Date.now(), Nn(n, "pointer");
};
Ye.contextmenu = (n) => La(n);
function Rd(n, e) {
return n.composing ? !0 : Je && Math.abs(e.timeStamp - n.input.compositionEndedAt) < 500 ? (n.input.compositionEndedAt = -2e8, !0) : !1;
}
const vx = sn ? 5e3 : -1;
Xe.compositionstart = Xe.compositionupdate = (n) => {
if (!n.composing) {
n.domObserver.flush();
let { state: e } = n, t = e.selection.$to;
if (e.selection instanceof Q && (e.storedMarks || !t.textOffset && t.parentOffset && t.nodeBefore.marks.some((r) => r.type.spec.inclusive === !1)))
n.markCursor = n.state.storedMarks || t.marks(), Ji(n, !0), n.markCursor = null;
else if (Ji(n, !e.selection.empty), Lt && e.selection.empty && t.parentOffset && !t.textOffset && t.nodeBefore.marks.length) {
let r = n.domSelectionRange();
for (let o = r.focusNode, i = r.focusOffset; o && o.nodeType == 1 && i != 0; ) {
let s = i < 0 ? o.lastChild : o.childNodes[i - 1];
if (!s)
break;
if (s.nodeType == 3) {
let l = n.domSelection();
l && l.collapse(s, s.nodeValue.length);
break;
} else
o = s, i = -1;
}
}
n.input.composing = !0;
}
Fd(n, vx);
};
Xe.compositionend = (n, e) => {
n.composing && (n.input.composing = !1, n.input.compositionEndedAt = e.timeStamp, n.input.compositionPendingChanges = n.domObserver.pendingRecords().length ? n.input.compositionID : 0, n.input.compositionNode = null, n.input.compositionPendingChanges && Promise.resolve().then(() => n.domObserver.flush()), n.input.compositionID++, Fd(n, 20));
};
function Fd(n, e) {
clearTimeout(n.input.composingTimeout), e > -1 && (n.input.composingTimeout = setTimeout(() => Ji(n), e));
}
function Hd(n) {
for (n.composing && (n.input.composing = !1, n.input.compositionEndedAt = Sx()); n.input.compositionNodes.length > 0; )
n.input.compositionNodes.pop().markParentsDirty();
}
function wx(n) {
let e = n.domSelectionRange();
if (!e.focusNode)
return null;
let t = fm(e.focusNode, e.focusOffset), r = hm(e.focusNode, e.focusOffset);
if (t && r && t != r) {
let o = r.pmViewDesc, i = n.domObserver.lastChangedTextNode;
if (t == i || r == i)
return i;
if (!o || !o.isText(r.nodeValue))
return r;
if (n.input.compositionNode == r) {
let s = t.pmViewDesc;
if (!(!s || !s.isText(t.nodeValue)))
return r;
}
}
return t || r;
}
function Sx() {
let n = document.createEvent("Event");
return n.initEvent("event", !0, !0), n.timeStamp;
}
function Ji(n, e = !1) {
if (!(sn && n.domObserver.flushingSoon >= 0)) {
if (n.domObserver.forceFlush(), Hd(n), e || n.docView && n.docView.dirty) {
let t = Oa(n), r = n.state.selection;
return t && !t.eq(r) ? n.dispatch(n.state.tr.setSelection(t)) : (n.markCursor || e) && !r.$from.node(r.$from.sharedDepth(r.to)).inlineContent ? n.dispatch(n.state.tr.deleteSelection()) : n.updateState(n.state), !0;
}
return !1;
}
}
function kx(n, e) {
if (!n.dom.parentNode)
return;
let t = n.dom.parentNode.appendChild(document.createElement("div"));
t.appendChild(e), t.style.cssText = "position: fixed; left: -10000px; top: 10px";
let r = getSelection(), o = document.createRange();
o.selectNodeContents(e), n.dom.blur(), r.removeAllRanges(), r.addRange(o), setTimeout(() => {
t.parentNode && t.parentNode.removeChild(t), n.focus();
}, 50);
}
const Fo = nt && Rn < 15 || Jr && ym < 604;
Ye.copy = Xe.cut = (n, e) => {
let t = e, r = n.state.selection, o = t.type == "cut";
if (r.empty)
return;
let i = Fo ? null : t.clipboardData, s = r.content(), { dom: l, text: a } = Pa(n, s);
i ? (t.preventDefault(), i.clearData(), i.setData("text/html", l.innerHTML), i.setData("text/plain", a)) : kx(n, l), o && n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent", "cut"));
};
function Cx(n) {
return n.openStart == 0 && n.openEnd == 0 && n.content.childCount == 1 ? n.content.firstChild : null;
}
function Mx(n, e) {
if (!n.dom.parentNode)
return;
let t = n.input.shiftKey || n.state.selection.$from.parent.type.spec.code, r = n.dom.parentNode.appendChild(document.createElement(t ? "textarea" : "div"));
t || (r.contentEditable = "true"), r.style.cssText = "position: fixed; left: -10000px; top: 10px", r.focus();
let o = n.input.shiftKey && n.input.lastKeyCode != 45;
setTimeout(() => {
n.focus(), r.parentNode && r.parentNode.removeChild(r), t ? Ho(n, r.value, null, o, e) : Ho(n, r.textContent, r.innerHTML, o, e);
}, 50);
}
function Ho(n, e, t, r, o) {
let i = Ad(n, e, t, r, n.state.selection.$from);
if (n.someProp("handlePaste", (a) => a(n, o, i || z.empty)))
return !0;
if (!i)
return !1;
let s = Cx(i), l = s ? n.state.tr.replaceSelectionWith(s, r) : n.state.tr.replaceSelection(i);
return n.dispatch(l.scrollIntoView().setMeta("paste", !0).setMeta("uiEvent", "paste")), !0;
}
function jd(n) {
let e = n.getData("text/plain") || n.getData("Text");
if (e)
return e;
let t = n.getData("text/uri-list");
return t ? t.replace(/\r?\n/g, " ") : "";
}
Xe.paste = (n, e) => {
let t = e;
if (n.composing && !sn)
return;
let r = Fo ? null : t.clipboardData, o = n.input.shiftKey && n.input.lastKeyCode != 45;
r && Ho(n, jd(r), r.getData("text/html"), o, t) ? t.preventDefault() : Mx(n, t);
};
class zd {
constructor(e, t, r) {
this.slice = e, this.move = t, this.node = r;
}
}
const Ex = gt ? "altKey" : "ctrlKey";
function Vd(n, e) {
let t = n.someProp("dragCopies", (r) => !r(e));
return t ?? !e[Ex];
}
Ye.dragstart = (n, e) => {
let t = e, r = n.input.mouseDown;
if (r && r.done(), !t.dataTransfer)
return;
let o = n.state.selection, i = o.empty ? null : n.posAtCoords(Fs(t)), s;
if (!(i && i.pos >= o.from && i.pos <= (o instanceof J ? o.to - 1 : o.to))) {
if (r && r.mightDrag)
s = J.create(n.state.doc, r.mightDrag.pos);
else if (t.target && t.target.nodeType == 1) {
let u = n.docView.nearestDesc(t.target, !0);
u && u.node.type.spec.draggable && u != n.docView && (s = J.create(n.state.doc, u.posBefore));
}
}
let l = (s || n.state.selection).content(), { dom: a, text: c, slice: p } = Pa(n, l);
(!t.dataTransfer.files.length || !qe || bd > 120) && t.dataTransfer.clearData(), t.dataTransfer.setData(Fo ? "Text" : "text/html", a.innerHTML), t.dataTransfer.effectAllowed = "copyMove", Fo || t.dataTransfer.setData("text/plain", c), n.dragging = new zd(p, Vd(n, t), s);
};
Ye.dragend = (n) => {
let e = n.dragging;
window.setTimeout(() => {
n.dragging == e && (n.dragging = null);
}, 50);
};
Xe.dragover = Xe.dragenter = (n, e) => e.preventDefault();
Xe.drop = (n, e) => {
let t = e, r = n.dragging;
if (n.dragging = null, !t.dataTransfer)
return;
let o = n.posAtCoords(Fs(t));
if (!o)
return;
let i = n.state.doc.resolve(o.pos), s = r && r.slice;
s ? n.someProp("transformPasted", (b) => {
s = b(s, n);
}) : s = Ad(n, jd(t.dataTransfer), Fo ? null : t.dataTransfer.getData("text/html"), !1, i);
let l = !!(r && Vd(n, t));
if (n.someProp("handleDrop", (b) => b(n, t, s || z.empty, l))) {
t.preventDefault();
return;
}
if (!s)
return;
t.preventDefault();
let a = s ? sd(n.state.doc, i.pos, s) : i.pos;
a == null && (a = i.pos);
let c = n.state.tr;
if (l) {
let { node: b } = r;
b ? b.replace(c) : c.deleteSelection();
}
let p = c.mapping.map(a), u = s.openStart == 0 && s.openEnd == 0 && s.content.childCount == 1, f = c.doc;
if (u ? c.replaceRangeWith(p, p, s.content.firstChild) : c.replaceRange(p, p, s), c.doc.eq(f))
return;
let h = c.doc.resolve(p);
if (u && J.isSelectable(s.content.firstChild) && h.nodeAfter && h.nodeAfter.sameMarkup(s.content.firstChild))
c.setSelection(new J(h));
else {
let b = c.mapping.map(a);
c.mapping.maps[c.mapping.maps.length - 1].forEach((m, x, v, C) => b = C), c.setSelection(Ba(n, h, c.doc.resolve(b)));
}
n.focus(), n.dispatch(c.setMeta("uiEvent", "drop"));
};
Ye.focus = (n) => {
n.input.lastFocus = Date.now(), n.focused || (n.domObserver.stop(), n.dom.classList.add("ProseMirror-focused"), n.domObserver.start(), n.focused = !0, setTimeout(() => {
n.docView && n.hasFocus() && !n.domObserver.currentSelection.eq(n.domSelectionRange()) && cn(n);
}, 20));
};
Ye.blur = (n, e) => {
let t = e;
n.focused && (n.domObserver.stop(), n.dom.classList.remove("ProseMirror-focused"), n.domObserver.start(), t.relatedTarget && n.dom.contains(t.relatedTarget) && n.domObserver.currentSelection.clear(), n.focused = !1);
};
Ye.beforeinput = (n, e) => {
if (qe && sn && e.inputType == "deleteContentBackward") {
n.domObserver.flushSoon();
let { domChangeCount: r } = n.input;
setTimeout(() => {
if (n.input.domChangeCount != r || (n.dom.blur(), n.focus(), n.someProp("handleKeyDown", (i) => i(n, sr(8, "Backspace")))))
return;
let { $cursor: o } = n.state.selection;
o && o.pos > 0 && n.dispatch(n.state.tr.delete(o.pos - 1, o.pos).scrollIntoView());
}, 50);
}
};
for (let n in Xe)
Ye[n] = Xe[n];
function jo(n, e) {
if (n == e)
return !0;
for (let t in n)
if (n[t] !== e[t])
return !1;
for (let t in e)
if (!(t in n))
return !1;
return !0;
}
class Yi {
constructor(e, t) {
this.toDOM = e, this.spec = t || hr, this.side = this.spec.side || 0;
}
map(e, t, r, o) {
let { pos: i, deleted: s } = e.mapResult(t.from + o, this.side < 0 ? -1 : 1);
return s ? null : new vt(i - r, i - r, this);
}
valid() {
return !0;
}
eq(e) {
return this == e || e instanceof Yi && (this.spec.key && this.spec.key == e.spec.key || this.toDOM == e.toDOM && jo(this.spec, e.spec));
}
destroy(e) {
this.spec.destroy && this.spec.destroy(e);
}
}
class Hn {
constructor(e, t) {
this.attrs = e, this.spec = t || hr;
}
map(e, t, r, o) {
let i = e.map(t.from + o, this.spec.inclusiveStart ? -1 : 1) - r, s = e.map(t.to + o, this.spec.inclusiveEnd ? 1 : -1) - r;
return i >= s ? null : new vt(i, s, this);
}
valid(e, t) {
return t.from < t.to;
}
eq(e) {
return this == e || e instanceof Hn && jo(this.attrs, e.attrs) && jo(this.spec, e.spec);
}
static is(e) {
return e.type instanceof Hn;
}
destroy() {
}
}
class Na {
constructor(e, t) {
this.attrs = e, this.spec = t || hr;
}
map(e, t, r, o) {
let i = e.mapResult(t.from + o, 1);
if (i.deleted)
return null;
let s = e.mapResult(t.to + o, -1);
return s.deleted || s.pos <= i.pos ? null : new vt(i.pos - r, s.pos - r, this);
}
valid(e, t) {
let { index: r, offset: o } = e.content.findIndex(t.from), i;
return o == t.from && !(i = e.child(r)).isText && o + i.nodeSize == t.to;
}
eq(e) {
return this == e || e instanceof Na && jo(this.attrs, e.attrs) && jo(this.spec, e.spec);
}
destroy() {
}
}
class vt {
/**
@internal
*/
constructor(e, t, r) {
this.from = e, this.to = t, this.type = r;
}
/**
@internal
*/
copy(e, t) {
return new vt(e, t, this.type);
}
/**
@internal
*/
eq(e, t = 0) {
return this.type.eq(e.type) && this.from + t == e.from && this.to + t == e.to;
}
/**
@internal
*/
map(e, t, r) {
return this.type.map(e, this, t, r);
}
/**
Creates a widget decoration, which is a DOM node that's shown in
the document at the given position. It is recommended that you
delay rendering the widget by passing a function that will be
called when the widget is actually drawn in a view, but you can
also directly pass a DOM node. `getPos` can be used to find the
widget's current document position.
*/
static widget(e, t, r) {
return new vt(e, e, new Yi(t, r));
}
/**
Creates an inline decoration, which adds the given attributes to
each inline node between `from` and `to`.
*/
static inline(e, t, r, o) {
return new vt(e, t, new Hn(r, o));
}
/**
Creates a node decoration. `from` and `to` should point precisely
before and after a node in the document. That node, and only that
node, will receive the given attributes.
*/
static node(e, t, r, o) {
return new vt(e, t, new Na(r, o));
}
/**
The spec provided when creating this decoration. Can be useful
if you've stored extra information in that object.
*/
get spec() {
return this.type.spec;
}
/**
@internal
*/
get inline() {
return this.type instanceof Hn;
}
/**
@internal
*/
get widget() {
return this.type instanceof Yi;
}
}
const Ir = [], hr = {};
class Te {
/**
@internal
*/
constructor(e, t) {
this.local = e.length ? e : Ir, this.children = t.length ? t : Ir;
}
/**
Create a set of decorations, using the structure of the given
document. This will consume (modify) the `decorations` array, so
you must make a copy if you want need to preserve that.
*/
static create(e, t) {
return t.length ? Xi(t, e, 0, hr) : ze;
}
/**
Find all decorations in this set which touch the given range
(including decorations that start or end directly at the
boundaries) and match the given predicate on their spec. When
`start` and `end` are omitted, all decorations in the set are
considered. When `predicate` isn't given, all decorations are
assumed to match.
*/
find(e, t, r) {
let o = [];
return this.findInner(e ?? 0, t ?? 1e9, o, 0, r), o;
}
findInner(e, t, r, o, i) {
for (let s = 0; s < this.local.length; s++) {
let l = this.local[s];
l.from <= t && l.to >= e && (!i || i(l.spec)) && r.push(l.copy(l.from + o, l.to + o));
}
for (let s = 0; s < this.children.length; s += 3)
if (this.children[s] < t && this.children[s + 1] > e) {
let l = this.children[s] + 1;
this.children[s + 2].findInner(e - l, t - l, r, o + l, i);
}
}
/**
Map the set of decorations in response to a change in the
document.
*/
map(e, t, r) {
return this == ze || e.maps.length == 0 ? this : this.mapInner(e, t, 0, 0, r || hr);
}
/**
@internal
*/
mapInner(e, t, r, o, i) {
let s;
for (let l = 0; l < this.local.length; l++) {
let a = this.local[l].map(e, r, o);
a && a.type.valid(t, a) ? (s || (s = [])).push(a) : i.onRemove && i.onRemove(this.local[l].spec);
}
return this.children.length ? Tx(this.children, s || [], e, t, r, o, i) : s ? new Te(s.sort(br), Ir) : ze;
}
/**
Add the given array of decorations to the ones in the set,
producing a new set. Consumes the `decorations` array. Needs
access to the current document to create the appropriate tree
structure.
*/
add(e, t) {
return t.length ? this == ze ? Te.create(e, t) : this.addInner(e, t, 0) : this;
}
addInner(e, t, r) {
let o, i = 0;
e.forEach((l, a) => {
let c = a + r, p;
if (p = Ud(t, l, c)) {
for (o || (o = this.children.slice()); i < o.length && o[i] < a; )
i += 3;
o[i] == a ? o[i + 2] = o[i + 2].addInner(l, p, c + 1) : o.splice(i, 0, a, a + l.nodeSize, Xi(p, l, c + 1, hr)), i += 3;
}
});
let s = Wd(i ? qd(t) : t, -r);
for (let l = 0; l < s.length; l++)
s[l].type.valid(e, s[l]) || s.splice(l--, 1);
return new Te(s.length ? this.local.concat(s).sort(br) : this.local, o || this.children);
}
/**
Create a new set that contains the decorations in this set, minus
the ones in the given array.
*/
remove(e) {
return e.length == 0 || this == ze ? this : this.removeInner(e, 0);
}
removeInner(e, t) {
let r = this.children, o = this.local;
for (let i = 0; i < r.length; i += 3) {
let s, l = r[i] + t, a = r[i + 1] + t;
for (let p = 0, u; p < e.length; p++)
(u = e[p]) && u.from > l && u.to < a && (e[p] = null, (s || (s = [])).push(u));
if (!s)
continue;
r == this.children && (r = this.children.slice());
let c = r[i + 2].removeInner(s, l + 1);
c != ze ? r[i + 2] = c : (r.splice(i, 3), i -= 3);
}
if (o.length) {
for (let i = 0, s; i < e.length; i++)
if (s = e[i])
for (let l = 0; l < o.length; l++)
o[l].eq(s, t) && (o == this.local && (o = this.local.slice()), o.splice(l--, 1));
}
return r == this.children && o == this.local ? this : o.length || r.length ? new Te(o, r) : ze;
}
forChild(e, t) {
if (this == ze)
return this;
if (t.isLeaf)
return Te.empty;
let r, o;
for (let l = 0; l < this.children.length; l += 3)
if (this.children[l] >= e) {
this.children[l] == e && (r = this.children[l + 2]);
break;
}
let i = e + 1, s = i + t.content.size;
for (let l = 0; l < this.local.length; l++) {
let a = this.local[l];
if (a.from < s && a.to > i && a.type instanceof Hn) {
let c = Math.max(i, a.from) - i, p = Math.min(s, a.to) - i;
c < p && (o || (o = [])).push(a.copy(c, p));
}
}
if (o) {
let l = new Te(o.sort(br), Ir);
return r ? new On([l, r]) : l;
}
return r || ze;
}
/**
@internal
*/
eq(e) {
if (this == e)
return !0;
if (!(e instanceof Te) || this.local.length != e.local.length || this.children.length != e.children.length)
return !1;
for (let t = 0; t < this.local.length; t++)
if (!this.local[t].eq(e.local[t]))
return !1;
for (let t = 0; t < this.children.length; t += 3)
if (this.children[t] != e.children[t] || this.children[t + 1] != e.children[t + 1] || !this.children[t + 2].eq(e.children[t + 2]))
return !1;
return !0;
}
/**
@internal
*/
locals(e) {
return Da(this.localsInner(e));
}
/**
@internal
*/
localsInner(e) {
if (this == ze)
return Ir;
if (e.inlineContent || !this.local.some(Hn.is))
return this.local;
let t = [];
for (let r = 0; r < this.local.length; r++)
this.local[r].type instanceof Hn || t.push(this.local[r]);
return t;
}
forEachSet(e) {
e(this);
}
}
Te.empty = new Te([], []);
Te.removeOverlap = Da;
const ze = Te.empty;
class On {
constructor(e) {
this.members = e;
}
map(e, t) {
const r = this.members.map((o) => o.map(e, t, hr));
return On.from(r);
}
forChild(e, t) {
if (t.isLeaf)
return Te.empty;
let r = [];
for (let o = 0; o < this.members.length; o++) {
let i = this.members[o].forChild(e, t);
i != ze && (i instanceof On ? r = r.concat(i.members) : r.push(i));
}
return On.from(r);
}
eq(e) {
if (!(e instanceof On) || e.members.length != this.members.length)
return !1;
for (let t = 0; t < this.members.length; t++)
if (!this.members[t].eq(e.members[t]))
return !1;
return !0;
}
locals(e) {
let t, r = !0;
for (let o = 0; o < this.members.length; o++) {
let i = this.members[o].localsInner(e);
if (i.length)
if (!t)
t = i;
else {
r && (t = t.slice(), r = !1);
for (let s = 0; s < i.length; s++)
t.push(i[s]);
}
}
return t ? Da(r ? t : t.sort(br)) : Ir;
}
// Create a group for the given array of decoration sets, or return
// a single set when possible.
static from(e) {
switch (e.length) {
case 0:
return ze;
case 1:
return e[0];
default:
return new On(e.every((t) => t instanceof Te) ? e : e.reduce((t, r) => t.concat(r instanceof Te ? r : r.members), []));
}
}
forEachSet(e) {
for (let t = 0; t < this.members.length; t++)
this.members[t].forEachSet(e);
}
}
function Tx(n, e, t, r, o, i, s) {
let l = n.slice();
for (let c = 0, p = i; c < t.maps.length; c++) {
let u = 0;
t.maps[c].forEach((f, h, b, m) => {
let x = m - b - (h - f);
for (let v = 0; v < l.length; v += 3) {
let C = l[v + 1];
if (C < 0 || f > C + p - u)
continue;
let S = l[v] + p - u;
h >= S ? l[v + 1] = f <= S ? -2 : -1 : f >= p && x && (l[v] += x, l[v + 1] += x);
}
u += x;
}), p = t.maps[c].map(p, -1);
}
let a = !1;
for (let c = 0; c < l.length; c += 3)
if (l[c + 1] < 0) {
if (l[c + 1] == -2) {
a = !0, l[c + 1] = -1;
continue;
}
let p = t.map(n[c] + i), u = p - o;
if (u < 0 || u >= r.content.size) {
a = !0;
continue;
}
let f = t.map(n[c + 1] + i, -1), h = f - o, { index: b, offset: m } = r.content.findIndex(u), x = r.maybeChild(b);
if (x && m == u && m + x.nodeSize == h) {
let v = l[c + 2].mapInner(t, x, p + 1, n[c] + i + 1, s);
v != ze ? (l[c] = u, l[c + 1] = h, l[c + 2] = v) : (l[c + 1] = -2, a = !0);
} else
a = !0;
}
if (a) {
let c = Ox(l, n, e, t, o, i, s), p = Xi(c, r, 0, s);
e = p.local;
for (let u = 0; u < l.length; u += 3)
l[u + 1] < 0 && (l.splice(u, 3), u -= 3);
for (let u = 0, f = 0; u < p.children.length; u += 3) {
let h = p.children[u];
for (; f < l.length && l[f] < h; )
f += 3;
l.splice(f, 0, p.children[u], p.children[u + 1], p.children[u + 2]);
}
}
return new Te(e.sort(br), l);
}
function Wd(n, e) {
if (!e || !n.length)
return n;
let t = [];
for (let r = 0; r < n.length; r++) {
let o = n[r];
t.push(new vt(o.from + e, o.to + e, o.type));
}
return t;
}
function Ox(n, e, t, r, o, i, s) {
function l(a, c) {
for (let p = 0; p < a.local.length; p++) {
let u = a.local[p].map(r, o, c);
u ? t.push(u) : s.onRemove && s.onRemove(a.local[p].spec);
}
for (let p = 0; p < a.children.length; p += 3)
l(a.children[p + 2], a.children[p] + c + 1);
}
for (let a = 0; a < n.length; a += 3)
n[a + 1] == -1 && l(n[a + 2], e[a] + i + 1);
return t;
}
function Ud(n, e, t) {
if (e.isLeaf)
return null;
let r = t + e.nodeSize, o = null;
for (let i = 0, s; i < n.length; i++)
(s = n[i]) && s.from > t && s.to < r && ((o || (o = [])).push(s), n[i] = null);
return o;
}
function qd(n) {
let e = [];
for (let t = 0; t < n.length; t++)
n[t] != null && e.push(n[t]);
return e;
}
function Xi(n, e, t, r) {
let o = [], i = !1;
e.forEach((l, a) => {
let c = Ud(n, l, a + t);
if (c) {
i = !0;
let p = Xi(c, l, t + a + 1, r);
p != ze && o.push(a, a + l.nodeSize, p);
}
});
let s = Wd(i ? qd(n) : n, -t).sort(br);
for (let l = 0; l < s.length; l++)
s[l].type.valid(e, s[l]) || (r.onRemove && r.onRemove(s[l].spec), s.splice(l--, 1));
return s.length || o.length ? new Te(s, o) : ze;
}
function br(n, e) {
return n.from - e.from || n.to - e.to;
}
function Da(n) {
let e = n;
for (let t = 0; t < e.length - 1; t++) {
let r = e[t];
if (r.from != r.to)
for (let o = t + 1; o < e.length; o++) {
let i = e[o];
if (i.from == r.from) {
i.to != r.to && (e == n && (e = n.slice()), e[o] = i.copy(i.from, r.to), pp(e, o + 1, i.copy(r.to, i.to)));
continue;
} else {
i.from < r.to && (e == n && (e = n.slice()), e[t] = r.copy(r.from, i.from), pp(e, o, r.copy(i.from, r.to)));
break;
}
}
}
return e;
}
function pp(n, e, t) {
for (; e < n.length && br(t, n[e]) > 0; )
e++;
n.splice(e, 0, t);
}
function pl(n) {
let e = [];
return n.someProp("decorations", (t) => {
let r = t(n.state);
r && r != ze && e.push(r);
}), n.cursorWrapper && e.push(Te.create(n.state.doc, [n.cursorWrapper.deco])), On.from(e);
}
const Bx = {
childList: !0,
characterData: !0,
characterDataOldValue: !0,
attributes: !0,
attributeOldValue: !0,
subtree: !0
}, Px = nt && Rn <= 11;
class Ax {
constructor() {
this.anchorNode = null, this.anchorOffset = 0, this.focusNode = null, this.focusOffset = 0;
}
set(e) {
this.anchorNode = e.anchorNode, this.anchorOffset = e.anchorOffset, this.focusNode = e.focusNode, this.focusOffset = e.focusOffset;
}
clear() {
this.anchorNode = this.focusNode = null;
}
eq(e) {
return e.anchorNode == this.anchorNode && e.anchorOffset == this.anchorOffset && e.focusNode == this.focusNode && e.focusOffset == this.focusOffset;
}
}
class _x {
constructor(e, t) {
this.view = e, this.handleDOMChange = t, this.queue = [], this.flushingSoon = -1, this.observer = null, this.currentSelection = new Ax(), this.onCharData = null, this.suppressingSelectionUpdates = !1, this.lastChangedTextNode = null, this.observer = window.MutationObserver && new window.MutationObserver((r) => {
for (let o = 0; o < r.length; o++)
this.queue.push(r[o]);
nt && Rn <= 11 && r.some((o) => o.type == "childList" && o.removedNodes.length || o.type == "characterData" && o.oldValue.length > o.target.nodeValue.length) ? this.flushSoon() : this.flush();
}), Px && (this.onCharData = (r) => {
this.queue.push({ target: r.target, type: "characterData", oldValue: r.prevValue }), this.flushSoon();
}), this.onSelectionChange = this.onSelectionChange.bind(this);
}
flushSoon() {
this.flushingSoon < 0 && (this.flushingSoon = window.setTimeout(() => {
this.flushingSoon = -1, this.flush();
}, 20));
}
forceFlush() {
this.flushingSoon > -1 && (window.clearTimeout(this.flushingSoon), this.flushingSoon = -1, this.flush());
}
start() {
this.observer && (this.observer.takeRecords(), this.observer.observe(this.view.dom, Bx)), this.onCharData && this.view.dom.addEventListener("DOMCharacterDataModified", this.onCharData), this.connectSelection();
}
stop() {
if (this.observer) {
let e = this.observer.takeRecords();
if (e.length) {
for (let t = 0; t < e.length; t++)
this.queue.push(e[t]);
window.setTimeout(() => this.flush(), 20);
}
this.observer.disconnect();
}
this.onCharData && this.view.dom.removeEventListener("DOMCharacterDataModified", this.onCharData), this.disconnectSelection();
}
connectSelection() {
this.view.dom.ownerDocument.addEventListener("selectionchange", this.onSelectionChange);
}
disconnectSelection() {
this.view.dom.ownerDocument.removeEventListener("selectionchange", this.onSelectionChange);
}
suppressSelectionUpdates() {
this.suppressingSelectionUpdates = !0, setTimeout(() => this.suppressingSelectionUpdates = !1, 50);
}
onSelectionChange() {
if (np(this.view)) {
if (this.suppressingSelectionUpdates)
return cn(this.view);
if (nt && Rn <= 11 && !this.view.state.selection.empty) {
let e = this.view.domSelectionRange();
if (e.focusNode && Sr(e.focusNode, e.focusOffset, e.anchorNode, e.anchorOffset))
return this.flushSoon();
}
this.flush();
}
}
setCurSelection() {
this.currentSelection.set(this.view.domSelectionRange());
}
ignoreSelectionChange(e) {
if (!e.focusNode)
return !0;
let t = /* @__PURE__ */ new Set(), r;
for (let i = e.focusNode; i; i = Gr(i))
t.add(i);
for (let i = e.anchorNode; i; i = Gr(i))
if (t.has(i)) {
r = i;
break;
}
let o = r && this.view.docView.nearestDesc(r);
if (o && o.ignoreMutation({
type: "selection",
target: r.nodeType == 3 ? r.parentNode : r
}))
return this.setCurSelection(), !0;
}
pendingRecords() {
if (this.observer)
for (let e of this.observer.takeRecords())
this.queue.push(e);
return this.queue;
}
flush() {
let { view: e } = this;
if (!e.docView || this.flushingSoon > -1)
return;
let t = this.pendingRecords();
t.length && (this.queue = []);
let r = e.domSelectionRange(), o = !this.suppressingSelectionUpdates && !this.currentSelection.eq(r) && np(e) && !this.ignoreSelectionChange(r), i = -1, s = -1, l = !1, a = [];
if (e.editable)
for (let p = 0; p < t.length; p++) {
let u = this.registerMutation(t[p], a);
u && (i = i < 0 ? u.from : Math.min(u.from, i), s = s < 0 ? u.to : Math.max(u.to, s), u.typeOver && (l = !0));
}
if (Lt && a.length) {
let p = a.filter((u) => u.nodeName == "BR");
if (p.length == 2) {
let [u, f] = p;
u.parentNode && u.parentNode.parentNode == f.parentNode ? f.remove() : u.remove();
} else {
let { focusNode: u } = this.currentSelection;
for (let f of p) {
let h = f.parentNode;
h && h.nodeName == "LI" && (!u || Dx(e, u) != h) && f.remove();
}
}
}
let c = null;
i < 0 && o && e.input.lastFocus > Date.now() - 200 && Math.max(e.input.lastTouch, e.input.lastClick.time) < Date.now() - 300 && $s(r) && (c = Oa(e)) && c.eq(te.near(e.state.doc.resolve(0), 1)) ? (e.input.lastFocus = 0, cn(e), this.currentSelection.set(r), e.scrollToSelection()) : (i > -1 || o) && (i > -1 && (e.docView.markDirty(i, s), Lx(e)), this.handleDOMChange(i, s, l, a), e.docView && e.docView.dirty ? e.updateState(e.state) : this.currentSelection.eq(r) || cn(e), this.currentSelection.set(r));
}
registerMutation(e, t) {
if (t.indexOf(e.target) > -1)
return null;
let r = this.view.docView.nearestDesc(e.target);
if (e.type == "attributes" && (r == this.view.docView || e.attributeName == "contenteditable" || // Firefox sometimes fires spurious events for null/empty styles
e.attributeName == "style" && !e.oldValue && !e.target.getAttribute("style")) || !r || r.ignoreMutation(e))
return null;
if (e.type == "childList") {
for (let p = 0; p < e.addedNodes.length; p++) {
let u = e.addedNodes[p];
t.push(u), u.nodeType == 3 && (this.lastChangedTextNode = u);
}
if (r.contentDOM && r.contentDOM != r.dom && !r.contentDOM.contains(e.target))
return { from: r.posBefore, to: r.posAfter };
let o = e.previousSibling, i = e.nextSibling;
if (nt && Rn <= 11 && e.addedNodes.length)
for (let p = 0; p < e.addedNodes.length; p++) {
let { previousSibling: u, nextSibling: f } = e.addedNodes[p];
(!u || Array.prototype.indexOf.call(e.addedNodes, u) < 0) && (o = u), (!f || Array.prototype.indexOf.call(e.addedNodes, f) < 0) && (i = f);
}
let s = o && o.parentNode == e.target ? Re(o) + 1 : 0, l = r.localPosFromDOM(e.target, s, -1), a = i && i.parentNode == e.target ? Re(i) : e.target.childNodes.length, c = r.localPosFromDOM(e.target, a, 1);
return { from: l, to: c };
} else return e.type == "attributes" ? { from: r.posAtStart - r.border, to: r.posAtEnd + r.border } : (this.lastChangedTextNode = e.target, {
from: r.posAtStart,
to: r.posAtEnd,
// An event was generated for a text change that didn't change
// any text. Mark the dom change to fall back to assuming the
// selection was typed over with an identical value if it can't
// find another change.
typeOver: e.target.nodeValue == e.oldValue
});
}
}
let up = /* @__PURE__ */ new WeakMap(), dp = !1;
function Lx(n) {
if (!up.has(n) && (up.set(n, null), ["normal", "nowrap", "pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace) !== -1)) {
if (n.requiresGeckoHackNode = Lt, dp)
return;
console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."), dp = !0;
}
}
function fp(n, e) {
let t = e.startContainer, r = e.startOffset, o = e.endContainer, i = e.endOffset, s = n.domAtPos(n.state.selection.anchor);
return Sr(s.node, s.offset, o, i) && ([t, r, o, i] = [o, i, t, r]), { anchorNode: t, anchorOffset: r, focusNode: o, focusOffset: i };
}
function Nx(n, e) {
if (e.getComposedRanges) {
let o = e.getComposedRanges(n.root)[0];
if (o)
return fp(n, o);
}
let t;
function r(o) {
o.preventDefault(), o.stopImmediatePropagation(), t = o.getTargetRanges()[0];
}
return n.dom.addEventListener("beforeinput", r, !0), document.execCommand("indent"), n.dom.removeEventListener("beforeinput", r, !0), t ? fp(n, t) : null;
}
function Dx(n, e) {
for (let t = e.parentNode; t && t != n.dom; t = t.parentNode) {
let r = n.docView.nearestDesc(t, !0);
if (r && r.node.isBlock)
return t;
}
return null;
}
function Ix(n, e, t) {
let { node: r, fromOffset: o, toOffset: i, from: s, to: l } = n.docView.parseRange(e, t), a = n.domSelectionRange(), c, p = a.anchorNode;
if (p && n.dom.contains(p.nodeType == 1 ? p : p.parentNode) && (c = [{ node: p, offset: a.anchorOffset }], $s(a) || c.push({ node: a.focusNode, offset: a.focusOffset })), qe && n.input.lastKeyCode === 8)
for (let x = i; x > o; x--) {
let v = r.childNodes[x - 1], C = v.pmViewDesc;
if (v.nodeName == "BR" && !C) {
i = x;
break;
}
if (!C || C.size)
break;
}
let u = n.state.doc, f = n.someProp("domParser") || wo.fromSchema(n.state.schema), h = u.resolve(s), b = null, m = f.parse(r, {
topNode: h.parent,
topMatch: h.parent.contentMatchAt(h.index()),
topOpen: !0,
from: o,
to: i,
preserveWhitespace: h.parent.type.whitespace == "pre" ? "full" : !0,
findPositions: c,
ruleFromNode: $x,
context: h
});
if (c && c[0].pos != null) {
let x = c[0].pos, v = c[1] && c[1].pos;
v == null && (v = x), b = { anchor: x + s, head: v + s };
}
return { doc: m, sel: b, from: s, to: l };
}
function $x(n) {
let e = n.pmViewDesc;
if (e)
return e.parseRule();
if (n.nodeName == "BR" && n.parentNode) {
if (Je && /^(ul|ol)$/i.test(n.parentNode.nodeName)) {
let t = document.createElement("div");
return t.appendChild(document.createElement("li")), { skip: t };
} else if (n.parentNode.lastChild == n || Je && /^(tr|table)$/i.test(n.parentNode.nodeName))
return { ignore: !0 };
} else if (n.nodeName == "IMG" && n.getAttribute("mark-placeholder"))
return { ignore: !0 };
return null;
}
const Rx = /^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;
function Fx(n, e, t, r, o) {
let i = n.input.compositionPendingChanges || (n.composing ? n.input.compositionID : 0);
if (n.input.compositionPendingChanges = 0, e < 0) {
let F = n.input.lastSelectionTime > Date.now() - 50 ? n.input.lastSelectionOrigin : null, W = Oa(n, F);
if (W && !n.state.selection.eq(W)) {
if (qe && sn && n.input.lastKeyCode === 13 && Date.now() - 100 < n.input.lastKeyCodeTime && n.someProp("handleKeyDown", (N) => N(n, sr(13, "Enter"))))
return;
let L = n.state.tr.setSelection(W);
F == "pointer" ? L.setMeta("pointer", !0) : F == "key" && L.scrollIntoView(), i && L.setMeta("composition", i), n.dispatch(L);
}
return;
}
let s = n.state.doc.resolve(e), l = s.sharedDepth(t);
e = s.before(l + 1), t = n.state.doc.resolve(t).after(l + 1);
let a = n.state.selection, c = Ix(n, e, t), p = n.state.doc, u = p.slice(c.from, c.to), f, h;
n.input.lastKeyCode === 8 && Date.now() - 100 < n.input.lastKeyCodeTime ? (f = n.state.selection.to, h = "end") : (f = n.state.selection.from, h = "start"), n.input.lastKeyCode = null;
let b = zx(u.content, c.doc.content, c.from, f, h);
if (b && n.input.domChangeCount++, (Jr && n.input.lastIOSEnter > Date.now() - 225 || sn) && o.some((F) => F.nodeType == 1 && !Rx.test(F.nodeName)) && (!b || b.endA >= b.endB) && n.someProp("handleKeyDown", (F) => F(n, sr(13, "Enter")))) {
n.input.lastIOSEnter = 0;
return;
}
if (!b)
if (r && a instanceof Q && !a.empty && a.$head.sameParent(a.$anchor) && !n.composing && !(c.sel && c.sel.anchor != c.sel.head))
b = { start: a.from, endA: a.to, endB: a.to };
else {
if (c.sel) {
let F = hp(n, n.state.doc, c.sel);
if (F && !F.eq(n.state.selection)) {
let W = n.state.tr.setSelection(F);
i && W.setMeta("composition", i), n.dispatch(W);
}
}
return;
}
n.state.selection.from < n.state.selection.to && b.start == b.endB && n.state.selection instanceof Q && (b.start > n.state.selection.from && b.start <= n.state.selection.from + 2 && n.state.selection.from >= c.from ? b.start = n.state.selection.from : b.endA < n.state.selection.to && b.endA >= n.state.selection.to - 2 && n.state.selection.to <= c.to && (b.endB += n.state.selection.to - b.endA, b.endA = n.state.selection.to)), nt && Rn <= 11 && b.endB == b.start + 1 && b.endA == b.start && b.start > c.from && c.doc.textBetween(b.start - c.from - 1, b.start - c.from + 1) == " " && (b.start--, b.endA--, b.endB--);
let m = c.doc.resolveNoCache(b.start - c.from), x = c.doc.resolveNoCache(b.endB - c.from), v = p.resolve(b.start), C = m.sameParent(x) && m.parent.inlineContent && v.end() >= b.endA, S;
if ((Jr && n.input.lastIOSEnter > Date.now() - 225 && (!C || o.some((F) => F.nodeName == "DIV" || F.nodeName == "P")) || !C && m.pos < c.doc.content.size && (!m.sameParent(x) || !m.parent.inlineContent) && !/\S/.test(c.doc.textBetween(m.pos, x.pos, "", "")) && (S = te.findFrom(c.doc.resolve(m.pos + 1), 1, !0)) && S.head > m.pos) && n.someProp("handleKeyDown", (F) => F(n, sr(13, "Enter")))) {
n.input.lastIOSEnter = 0;
return;
}
if (n.state.selection.anchor > b.start && jx(p, b.start, b.endA, m, x) && n.someProp("handleKeyDown", (F) => F(n, sr(8, "Backspace")))) {
sn && qe && n.domObserver.suppressSelectionUpdates();
return;
}
qe && b.endB == b.start && (n.input.lastChromeDelete = Date.now()), sn && !C && m.start() != x.start() && x.parentOffset == 0 && m.depth == x.depth && c.sel && c.sel.anchor == c.sel.head && c.sel.head == b.endA && (b.endB -= 2, x = c.doc.resolveNoCache(b.endB - c.from), setTimeout(() => {
n.someProp("handleKeyDown", function(F) {
return F(n, sr(13, "Enter"));
});
}, 20));
let g = b.start, O = b.endA, T = (F) => {
let W = F || n.state.tr.replace(g, O, c.doc.slice(b.start - c.from, b.endB - c.from));
if (c.sel) {
let L = hp(n, W.doc, c.sel);
L && !(qe && n.composing && L.empty && (b.start != b.endB || n.input.lastChromeDelete < Date.now() - 100) && (L.head == g || L.head == W.mapping.map(O) - 1) || nt && L.empty && L.head == g) && W.setSelection(L);
}
return i && W.setMeta("composition", i), W.scrollIntoView();
}, B;
if (C) {
if (m.pos == x.pos) {
nt && Rn <= 11 && m.parentOffset == 0 && (n.domObserver.suppressSelectionUpdates(), setTimeout(() => cn(n), 20));
let F = T(n.state.tr.delete(g, O)), W = p.resolve(b.start).marksAcross(p.resolve(b.endA));
W && F.ensureMarks(W), n.dispatch(F);
} else if (
// Adding or removing a mark
b.endA == b.endB && (B = Hx(m.parent.content.cut(m.parentOffset, x.parentOffset), v.parent.content.cut(v.parentOffset, b.endA - v.start())))
) {
let F = T(n.state.tr);
B.type == "add" ? F.addMark(g, O, B.mark) : F.removeMark(g, O, B.mark), n.dispatch(F);
} else if (m.parent.child(m.index()).isText && m.index() == x.index() - (x.textOffset ? 0 : 1)) {
let F = m.parent.textBetween(m.parentOffset, x.parentOffset), W = () => T(n.state.tr.insertText(F, g, O));
n.someProp("handleTextInput", (L) => L(n, g, O, F, W)) || n.dispatch(W());
}
} else
n.dispatch(T());
}
function hp(n, e, t) {
return Math.max(t.anchor, t.head) > e.content.size ? null : Ba(n, e.resolve(t.anchor), e.resolve(t.head));
}
function Hx(n, e) {
let t = n.firstChild.marks, r = e.firstChild.marks, o = t, i = r, s, l, a;
for (let p = 0; p < r.length; p++)
o = r[p].removeFromSet(o);
for (let p = 0; p < t.length; p++)
i = t[p].removeFromSet(i);
if (o.length == 1 && i.length == 0)
l = o[0], s = "add", a = (p) => p.mark(l.addToSet(p.marks));
else if (o.length == 0 && i.length == 1)
l = i[0], s = "remove", a = (p) => p.mark(l.removeFromSet(p.marks));
else
return null;
let c = [];
for (let p = 0; p < e.childCount; p++)
c.push(a(e.child(p)));
if (D.from(c).eq(n))
return { mark: l, type: s };
}
function jx(n, e, t, r, o) {
if (
// The content must have shrunk
t - e <= o.pos - r.pos || // newEnd must point directly at or after the end of the block that newStart points into
ul(r, !0, !1) < o.pos
)
return !1;
let i = n.resolve(e);
if (!r.parent.isTextblock) {
let l = i.nodeAfter;
return l != null && t == e + l.nodeSize;
}
if (i.parentOffset < i.parent.content.size || !i.parent.isTextblock)
return !1;
let s = n.resolve(ul(i, !0, !0));
return !s.parent.isTextblock || s.pos > t || ul(s, !0, !1) < t ? !1 : r.parent.content.cut(r.parentOffset).eq(s.parent.content);
}
function ul(n, e, t) {
let r = n.depth, o = e ? n.end() : n.pos;
for (; r > 0 && (e || n.indexAfter(r) == n.node(r).childCount); )
r--, o++, e = !1;
if (t) {
let i = n.node(r).maybeChild(n.indexAfter(r));
for (; i && !i.isLeaf; )
i = i.firstChild, o++;
}
return o;
}
function zx(n, e, t, r, o) {
let i = n.findDiffStart(e, t);
if (i == null)
return null;
let { a: s, b: l } = n.findDiffEnd(e, t + n.size, t + e.size);
if (o == "end") {
let a = Math.max(0, i - Math.min(s, l));
r -= s + a - i;
}
if (s < i && n.size < e.size) {
let a = r <= i && r >= s ? i - r : 0;
i -= a, i && i < e.size && bp(e.textBetween(i - 1, i + 1)) && (i += a ? 1 : -1), l = i + (l - s), s = i;
} else if (l < i) {
let a = r <= i && r >= l ? i - r : 0;
i -= a, i && i < n.size && bp(n.textBetween(i - 1, i + 1)) && (i += a ? 1 : -1), s = i + (s - l), l = i;
}
return { start: i, endA: s, endB: l };
}
function bp(n) {
if (n.length != 2)
return !1;
let e = n.charCodeAt(0), t = n.charCodeAt(1);
return e >= 56320 && e <= 57343 && t >= 55296 && t <= 56319;
}
class Kd {
/**
Create a view. `place` may be a DOM node that the editor should
be appended to, a function that will place it into the document,
or an object whose `mount` property holds the node to use as the
document container. If it is `null`, the editor will not be
added to the document.
*/
constructor(e, t) {
this._root = null, this.focused = !1, this.trackWrites = null, this.mounted = !1, this.markCursor = null, this.cursorWrapper = null, this.lastSelectedViewDesc = void 0, this.input = new lx(), this.prevDirectPlugins = [], this.pluginViews = [], this.requiresGeckoHackNode = !1, this.dragging = null, this._props = t, this.state = t.state, this.directPlugins = t.plugins || [], this.directPlugins.forEach(vp), this.dispatch = this.dispatch.bind(this), this.dom = e && e.mount || document.createElement("div"), e && (e.appendChild ? e.appendChild(this.dom) : typeof e == "function" ? e(this.dom) : e.mount && (this.mounted = !0)), this.editable = gp(this), xp(this), this.nodeViews = yp(this), this.docView = Yc(this.state.doc, mp(this), pl(this), this.dom, this), this.domObserver = new _x(this, (r, o, i, s) => Fx(this, r, o, i, s)), this.domObserver.start(), ax(this), this.updatePluginViews();
}
/**
Holds `true` when a
[composition](https://w3c.github.io/uievents/#events-compositionevents)
is active.
*/
get composing() {
return this.input.composing;
}
/**
The view's current [props](https://prosemirror.net/docs/ref/#view.EditorProps).
*/
get props() {
if (this._props.state != this.state) {
let e = this._props;
this._props = {};
for (let t in e)
this._props[t] = e[t];
this._props.state = this.state;
}
return this._props;
}
/**
Update the view's props. Will immediately cause an update to
the DOM.
*/
update(e) {
e.handleDOMEvents != this._props.handleDOMEvents && Zl(this);
let t = this._props;
this._props = e, e.plugins && (e.plugins.forEach(vp), this.directPlugins = e.plugins), this.updateStateInner(e.state, t);
}
/**
Update the view by updating existing props object with the object
given as argument. Equivalent to `view.update(Object.assign({},
view.props, props))`.
*/
setProps(e) {
let t = {};
for (let r in this._props)
t[r] = this._props[r];
t.state = this.state;
for (let r in e)
t[r] = e[r];
this.update(t);
}
/**
Update the editor's `state` prop, without touching any of the
other props.
*/
updateState(e) {
this.updateStateInner(e, this._props);
}
updateStateInner(e, t) {
var r;
let o = this.state, i = !1, s = !1;
e.storedMarks && this.composing && (Hd(this), s = !0), this.state = e;
let l = o.plugins != e.plugins || this._props.plugins != t.plugins;
if (l || this._props.plugins != t.plugins || this._props.nodeViews != t.nodeViews) {
let h = yp(this);
Wx(h, this.nodeViews) && (this.nodeViews = h, i = !0);
}
(l || t.handleDOMEvents != this._props.handleDOMEvents) && Zl(this), this.editable = gp(this), xp(this);
let a = pl(this), c = mp(this), p = o.plugins != e.plugins && !o.doc.eq(e.doc) ? "reset" : e.scrollToSelection > o.scrollToSelection ? "to selection" : "preserve", u = i || !this.docView.matchesNode(e.doc, c, a);
(u || !e.selection.eq(o.selection)) && (s = !0);
let f = p == "preserve" && s && this.dom.style.overflowAnchor == null && Sm(this);
if (s) {
this.domObserver.stop();
let h = u && (nt || qe) && !this.composing && !o.selection.empty && !e.selection.empty && Vx(o.selection, e.selection);
if (u) {
let b = qe ? this.trackWrites = this.domSelectionRange().focusNode : null;
this.composing && (this.input.compositionNode = wx(this)), (i || !this.docView.update(e.doc, c, a, this)) && (this.docView.updateOuterDeco(c), this.docView.destroy(), this.docView = Yc(e.doc, c, a, this.dom, this)), b && !this.trackWrites && (h = !0);
}
h || !(this.input.mouseDown && this.domObserver.currentSelection.eq(this.domSelectionRange()) && qm(this)) ? cn(this, h) : (Od(this, e.selection), this.domObserver.setCurSelection()), this.domObserver.start();
}
this.updatePluginViews(o), !((r = this.dragging) === null || r === void 0) && r.node && !o.doc.eq(e.doc) && this.updateDraggedNode(this.dragging, o), p == "reset" ? this.dom.scrollTop = 0 : p == "to selection" ? this.scrollToSelection() : f && km(f);
}
/**
@internal
*/
scrollToSelection() {
let e = this.domSelectionRange().focusNode;
if (!(!e || !this.dom.contains(e.nodeType == 1 ? e : e.parentNode))) {
if (!this.someProp("handleScrollToSelection", (t) => t(this))) if (this.state.selection instanceof J) {
let t = this.docView.domAfterPos(this.state.selection.from);
t.nodeType == 1 && Wc(this, t.getBoundingClientRect(), e);
} else
Wc(this, this.coordsAtPos(this.state.selection.head, 1), e);
}
}
destroyPluginViews() {
let e;
for (; e = this.pluginViews.pop(); )
e.destroy && e.destroy();
}
updatePluginViews(e) {
if (!e || e.plugins != this.state.plugins || this.directPlugins != this.prevDirectPlugins) {
this.prevDirectPlugins = this.directPlugins, this.destroyPluginViews();
for (let t = 0; t < this.directPlugins.length; t++) {
let r = this.directPlugins[t];
r.spec.view && this.pluginViews.push(r.spec.view(this));
}
for (let t = 0; t < this.state.plugins.length; t++) {
let r = this.state.plugins[t];
r.spec.view && this.pluginViews.push(r.spec.view(this));
}
} else
for (let t = 0; t < this.pluginViews.length; t++) {
let r = this.pluginViews[t];
r.update && r.update(this, e);
}
}
updateDraggedNode(e, t) {
let r = e.node, o = -1;
if (this.state.doc.nodeAt(r.from) == r.node)
o = r.from;
else {
let i = r.from + (this.state.doc.content.size - t.doc.content.size);
(i > 0 && this.state.doc.nodeAt(i)) == r.node && (o = i);
}
this.dragging = new zd(e.slice, e.move, o < 0 ? void 0 : J.create(this.state.doc, o));
}
someProp(e, t) {
let r = this._props && this._props[e], o;
if (r != null && (o = t ? t(r) : r))
return o;
for (let s = 0; s < this.directPlugins.length; s++) {
let l = this.directPlugins[s].props[e];
if (l != null && (o = t ? t(l) : l))
return o;
}
let i = this.state.plugins;
if (i)
for (let s = 0; s < i.length; s++) {
let l = i[s].props[e];
if (l != null && (o = t ? t(l) : l))
return o;
}
}
/**
Query whether the view has focus.
*/
hasFocus() {
if (nt) {
let e = this.root.activeElement;
if (e == this.dom)
return !0;
if (!e || !this.dom.contains(e))
return !1;
for (; e && this.dom != e && this.dom.contains(e); ) {
if (e.contentEditable == "false")
return !1;
e = e.parentElement;
}
return !0;
}
return this.root.activeElement == this.dom;
}
/**
Focus the editor.
*/
focus() {
this.domObserver.stop(), this.editable && Cm(this.dom), cn(this), this.domObserver.start();
}
/**
Get the document root in which the editor exists. This will
usually be the top-level `document`, but might be a [shadow
DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Shadow_DOM)
root if the editor is inside one.
*/
get root() {
let e = this._root;
if (e == null) {
for (let t = this.dom.parentNode; t; t = t.parentNode)
if (t.nodeType == 9 || t.nodeType == 11 && t.host)
return t.getSelection || (Object.getPrototypeOf(t).getSelection = () => t.ownerDocument.getSelection()), this._root = t;
}
return e || document;
}
/**
When an existing editor view is moved to a new document or
shadow tree, call this to make it recompute its root.
*/
updateRoot() {
this._root = null;
}
/**
Given a pair of viewport coordinates, return the document
position that corresponds to them. May return null if the given
coordinates aren't inside of the editor. When an object is
returned, its `pos` property is the position nearest to the
coordinates, and its `inside` property holds the position of the
inner node that the position falls inside of, or -1 if it is at
the top level, not in any node.
*/
posAtCoords(e) {
return Bm(this, e);
}
/**
Returns the viewport rectangle at a given document position.
`left` and `right` will be the same number, as this returns a
flat cursor-ish rectangle. If the position is between two things
that aren't directly adjacent, `side` determines which element
is used. When < 0, the element before the position is used,
otherwise the element after.
*/
coordsAtPos(e, t = 1) {
return vd(this, e, t);
}
/**
Find the DOM position that corresponds to the given document
position. When `side` is negative, find the position as close as
possible to the content before the position. When positive,
prefer positions close to the content after the position. When
zero, prefer as shallow a position as possible.
Note that you should **not** mutate the editor's internal DOM,
only inspect it (and even that is usually not necessary).
*/
domAtPos(e, t = 0) {
return this.docView.domFromPos(e, t);
}
/**
Find the DOM node that represents the document node after the
given position. May return `null` when the position doesn't point
in front of a node or if the node is inside an opaque node view.
This is intended to be able to call things like
`getBoundingClientRect` on that DOM node. Do **not** mutate the
editor DOM directly, or add styling this way, since that will be
immediately overriden by the editor as it redraws the node.
*/
nodeDOM(e) {
let t = this.docView.descAt(e);
return t ? t.nodeDOM : null;
}
/**
Find the document position that corresponds to a given DOM
position. (Whenever possible, it is preferable to inspect the
document structure directly, rather than poking around in the
DOM, but sometimes—for example when interpreting an event
target—you don't have a choice.)
The `bias` parameter can be used to influence which side of a DOM
node to use when the position is inside a leaf node.
*/
posAtDOM(e, t, r = -1) {
let o = this.docView.posFromDOM(e, t, r);
if (o == null)
throw new RangeError("DOM position not inside the editor");
return o;
}
/**
Find out whether the selection is at the end of a textblock when
moving in a given direction. When, for example, given `"left"`,
it will return true if moving left from the current cursor
position would leave that position's parent textblock. Will apply
to the view's current state by default, but it is possible to
pass a different state.
*/
endOfTextblock(e, t) {
return Nm(this, t || this.state, e);
}
/**
Run the editor's paste logic with the given HTML string. The
`event`, if given, will be passed to the
[`handlePaste`](https://prosemirror.net/docs/ref/#view.EditorProps.handlePaste) hook.
*/
pasteHTML(e, t) {
return Ho(this, "", e, !1, t || new ClipboardEvent("paste"));
}
/**
Run the editor's paste logic with the given plain-text input.
*/
pasteText(e, t) {
return Ho(this, e, null, !0, t || new ClipboardEvent("paste"));
}
/**
Serialize the given slice as it would be if it was copied from
this editor. Returns a DOM element that contains a
representation of the slice as its children, a textual
representation, and the transformed slice (which can be
different from the given input due to hooks like
[`transformCopied`](https://prosemirror.net/docs/ref/#view.EditorProps.transformCopied)).
*/
serializeForClipboard(e) {
return Pa(this, e);
}
/**
Removes the editor from the DOM and destroys all [node
views](https://prosemirror.net/docs/ref/#view.NodeView).
*/
destroy() {
this.docView && (cx(this), this.destroyPluginViews(), this.mounted ? (this.docView.update(this.state.doc, [], pl(this), this), this.dom.textContent = "") : this.dom.parentNode && this.dom.parentNode.removeChild(this.dom), this.docView.destroy(), this.docView = null, um());
}
/**
This is true when the view has been
[destroyed](https://prosemirror.net/docs/ref/#view.EditorView.destroy) (and thus should not be
used anymore).
*/
get isDestroyed() {
return this.docView == null;
}
/**
Used for testing.
*/
dispatchEvent(e) {
return ux(this, e);
}
/**
@internal
*/
domSelectionRange() {
let e = this.domSelection();
return e ? Je && this.root.nodeType === 11 && mm(this.dom.ownerDocument) == this.dom && Nx(this, e) || e : { focusNode: null, focusOffset: 0, anchorNode: null, anchorOffset: 0 };
}
/**
@internal
*/
domSelection() {
return this.root.getSelection();
}
}
Kd.prototype.dispatch = function(n) {
let e = this._props.dispatchTransaction;
e ? e.call(this, n) : this.updateState(this.state.apply(n));
};
function mp(n) {
let e = /* @__PURE__ */ Object.create(null);
return e.class = "ProseMirror", e.contenteditable = String(n.editable), n.someProp("attributes", (t) => {
if (typeof t == "function" && (t = t(n.state)), t)
for (let r in t)
r == "class" ? e.class += " " + t[r] : r == "style" ? e.style = (e.style ? e.style + ";" : "") + t[r] : !e[r] && r != "contenteditable" && r != "nodeName" && (e[r] = String(t[r]));
}), e.translate || (e.translate = "no"), [vt.node(0, n.state.doc.content.size, e)];
}
function xp(n) {
if (n.markCursor) {
let e = document.createElement("img");
e.className = "ProseMirror-separator", e.setAttribute("mark-placeholder", "true"), e.setAttribute("alt", ""), n.cursorWrapper = { dom: e, deco: vt.widget(n.state.selection.from, e, { raw: !0, marks: n.markCursor }) };
} else
n.cursorWrapper = null;
}
function gp(n) {
return !n.someProp("editable", (e) => e(n.state) === !1);
}
function Vx(n, e) {
let t = Math.min(n.$anchor.sharedDepth(n.head), e.$anchor.sharedDepth(e.head));
return n.$anchor.start(t) != e.$anchor.start(t);
}
function yp(n) {
let e = /* @__PURE__ */ Object.create(null);
function t(r) {
for (let o in r)
Object.prototype.hasOwnProperty.call(e, o) || (e[o] = r[o]);
}
return n.someProp("nodeViews", t), n.someProp("markViews", t), e;
}
function Wx(n, e) {
let t = 0, r = 0;
for (let o in n) {
if (n[o] != e[o])
return !0;
t++;
}
for (let o in e)
r++;
return t != r;
}
function vp(n) {
if (n.spec.state || n.spec.filterTransaction || n.spec.appendTransaction)
throw new RangeError("Plugins passed directly to the view must not have a state component");
}
var Vn = {
8: "Backspace",
9: "Tab",
10: "Enter",
12: "NumLock",
13: "Enter",
16: "Shift",
17: "Control",
18: "Alt",
20: "CapsLock",
27: "Escape",
32: " ",
33: "PageUp",
34: "PageDown",
35: "End",
36: "Home",
37: "ArrowLeft",
38: "ArrowUp",
39: "ArrowRight",
40: "ArrowDown",
44: "PrintScreen",
45: "Insert",
46: "Delete",
59: ";",
61: "=",
91: "Meta",
92: "Meta",
106: "*",
107: "+",
108: ",",
109: "-",
110: ".",
111: "/",
144: "NumLock",
145: "ScrollLock",
160: "Shift",
161: "Shift",
162: "Control",
163: "Control",
164: "Alt",
165: "Alt",
173: "-",
186: ";",
187: "=",
188: ",",
189: "-",
190: ".",
191: "/",
192: "`",
219: "[",
220: "\\",
221: "]",
222: "'"
}, Qi = {
48: ")",
49: "!",
50: "@",
51: "#",
52: "$",
53: "%",
54: "^",
55: "&",
56: "*",
57: "(",
59: ":",
61: "+",
173: "_",
186: ":",
187: "+",
188: "<",
189: "_",
190: ">",
191: "?",
192: "~",
219: "{",
220: "|",
221: "}",
222: '"'
}, Ux = typeof navigator < "u" && /Mac/.test(navigator.platform), qx = typeof navigator < "u" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
for (var Fe = 0; Fe < 10; Fe++) Vn[48 + Fe] = Vn[96 + Fe] = String(Fe);
for (var Fe = 1; Fe <= 24; Fe++) Vn[Fe + 111] = "F" + Fe;
for (var Fe = 65; Fe <= 90; Fe++)
Vn[Fe] = String.fromCharCode(Fe + 32), Qi[Fe] = String.fromCharCode(Fe);
for (var dl in Vn) Qi.hasOwnProperty(dl) || (Qi[dl] = Vn[dl]);
function Kx(n) {
var e = Ux && n.metaKey && n.shiftKey && !n.ctrlKey && !n.altKey || qx && n.shiftKey && n.key && n.key.length == 1 || n.key == "Unidentified", t = !e && n.key || (n.shiftKey ? Qi : Vn)[n.keyCode] || n.key || "Unidentified";
return t == "Esc" && (t = "Escape"), t == "Del" && (t = "Delete"), t == "Left" && (t = "ArrowLeft"), t == "Up" && (t = "ArrowUp"), t == "Right" && (t = "ArrowRight"), t == "Down" && (t = "ArrowDown"), t;
}
const Gx = typeof navigator < "u" && /Mac|iP(hone|[oa]d)/.test(navigator.platform), Jx = typeof navigator < "u" && /Win/.test(navigator.platform);
function Yx(n) {
let e = n.split(/-(?!$)/), t = e[e.length - 1];
t == "Space" && (t = " ");
let r, o, i, s;
for (let l = 0; l < e.length - 1; l++) {
let a = e[l];
if (/^(cmd|meta|m)$/i.test(a))
s = !0;
else if (/^a(lt)?$/i.test(a))
r = !0;
else if (/^(c|ctrl|control)$/i.test(a))
o = !0;
else if (/^s(hift)?$/i.test(a))
i = !0;
else if (/^mod$/i.test(a))
Gx ? s = !0 : o = !0;
else
throw new Error("Unrecognized modifier name: " + a);
}
return r && (t = "Alt-" + t), o && (t = "Ctrl-" + t), s && (t = "Meta-" + t), i && (t = "Shift-" + t), t;
}
function Xx(n) {
let e = /* @__PURE__ */ Object.create(null);
for (let t in n)
e[Yx(t)] = n[t];
return e;
}
function fl(n, e, t = !0) {
return e.altKey && (n = "Alt-" + n), e.ctrlKey && (n = "Ctrl-" + n), e.metaKey && (n = "Meta-" + n), t && e.shiftKey && (n = "Shift-" + n), n;
}
function Qx(n) {
return new Oe({ props: { handleKeyDown: Gd(n) } });
}
function Gd(n) {
let e = Xx(n);
return function(t, r) {
let o = Kx(r), i, s = e[fl(o, r)];
if (s && s(t.state, t.dispatch, t))
return !0;
if (o.length == 1 && o != " ") {
if (r.shiftKey) {
let l = e[fl(o, r, !1)];
if (l && l(t.state, t.dispatch, t))
return !0;
}
if ((r.altKey || r.metaKey || r.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
!(Jx && r.ctrlKey && r.altKey) && (i = Vn[r.keyCode]) && i != o) {
let l = e[fl(i, r)];
if (l && l(t.state, t.dispatch, t))
return !0;
}
}
return !1;
};
}
const Ia = (n, e) => n.selection.empty ? !1 : (e && e(n.tr.deleteSelection().scrollIntoView()), !0);
function Jd(n, e) {
let { $cursor: t } = n.selection;
return !t || (e ? !e.endOfTextblock("backward", n) : t.parentOffset > 0) ? null : t;
}
const Yd = (n, e, t) => {
let r = Jd(n, t);
if (!r)
return !1;
let o = $a(r);
if (!o) {
let s = r.blockRange(), l = s && io(s);
return l == null ? !1 : (e && e(n.tr.lift(s, l).scrollIntoView()), !0);
}
let i = o.nodeBefore;
if (sf(n, o, e, -1))
return !0;
if (r.parent.content.size == 0 && (Yr(i, "end") || J.isSelectable(i)))
for (let s = r.depth; ; s--) {
let l = Ds(n.doc, r.before(s), r.after(s), z.empty);
if (l && l.slice.size < l.to - l.from) {
if (e) {
let a = n.tr.step(l);
a.setSelection(Yr(i, "end") ? te.findFrom(a.doc.resolve(a.mapping.map(o.pos, -1)), -1) : J.create(a.doc, o.pos - i.nodeSize)), e(a.scrollIntoView());
}
return !0;
}
if (s == 1 || r.node(s - 1).childCount > 1)
break;
}
return i.isAtom && o.depth == r.depth - 1 ? (e && e(n.tr.delete(o.pos - i.nodeSize, o.pos).scrollIntoView()), !0) : !1;
}, Zx = (n, e, t) => {
let r = Jd(n, t);
if (!r)
return !1;
let o = $a(r);
return o ? Xd(n, o, e) : !1;
}, eg = (n, e, t) => {
let r = Zd(n, t);
if (!r)
return !1;
let o = Ra(r);
return o ? Xd(n, o, e) : !1;
};
function Xd(n, e, t) {
let r = e.nodeBefore, o = r, i = e.pos - 1;
for (; !o.isTextblock; i--) {
if (o.type.spec.isolating)
return !1;
let p = o.lastChild;
if (!p)
return !1;
o = p;
}
let s = e.nodeAfter, l = s, a = e.pos + 1;
for (; !l.isTextblock; a++) {
if (l.type.spec.isolating)
return !1;
let p = l.firstChild;
if (!p)
return !1;
l = p;
}
let c = Ds(n.doc, i, a, z.empty);
if (!c || c.from != i || c instanceof _e && c.slice.size >= a - i)
return !1;
if (t) {
let p = n.tr.step(c);
p.setSelection(Q.create(p.doc, i)), t(p.scrollIntoView());
}
return !0;
}
function Yr(n, e, t = !1) {
for (let r = n; r; r = e == "start" ? r.firstChild : r.lastChild) {
if (r.isTextblock)
return !0;
if (t && r.childCount != 1)
return !1;
}
return !1;
}
const Qd = (n, e, t) => {
let { $head: r, empty: o } = n.selection, i = r;
if (!o)
return !1;
if (r.parent.isTextblock) {
if (t ? !t.endOfTextblock("backward", n) : r.parentOffset > 0)
return !1;
i = $a(r);
}
let s = i && i.nodeBefore;
return !s || !J.isSelectable(s) ? !1 : (e && e(n.tr.setSelection(J.create(n.doc, i.pos - s.nodeSize)).scrollIntoView()), !0);
};
function $a(n) {
if (!n.parent.type.spec.isolating)
for (let e = n.depth - 1; e >= 0; e--) {
if (n.index(e) > 0)
return n.doc.resolve(n.before(e + 1));
if (n.node(e).type.spec.isolating)
break;
}
return null;
}
function Zd(n, e) {
let { $cursor: t } = n.selection;
return !t || (e ? !e.endOfTextblock("forward", n) : t.parentOffset < t.parent.content.size) ? null : t;
}
const ef = (n, e, t) => {
let r = Zd(n, t);
if (!r)
return !1;
let o = Ra(r);
if (!o)
return !1;
let i = o.nodeAfter;
if (sf(n, o, e, 1))
return !0;
if (r.parent.content.size == 0 && (Yr(i, "start") || J.isSelectable(i))) {
let s = Ds(n.doc, r.before(), r.after(), z.empty);
if (s && s.slice.size < s.to - s.from) {
if (e) {
let l = n.tr.step(s);
l.setSelection(Yr(i, "start") ? te.findFrom(l.doc.resolve(l.mapping.map(o.pos)), 1) : J.create(l.doc, l.mapping.map(o.pos))), e(l.scrollIntoView());
}
return !0;
}
}
return i.isAtom && o.depth == r.depth - 1 ? (e && e(n.tr.delete(o.pos, o.pos + i.nodeSize).scrollIntoView()), !0) : !1;
}, tf = (n, e, t) => {
let { $head: r, empty: o } = n.selection, i = r;
if (!o)
return !1;
if (r.parent.isTextblock) {
if (t ? !t.endOfTextblock("forward", n) : r.parentOffset < r.parent.content.size)
return !1;
i = Ra(r);
}
let s = i && i.nodeAfter;
return !s || !J.isSelectable(s) ? !1 : (e && e(n.tr.setSelection(J.create(n.doc, i.pos)).scrollIntoView()), !0);
};
function Ra(n) {
if (!n.parent.type.spec.isolating)
for (let e = n.depth - 1; e >= 0; e--) {
let t = n.node(e);
if (n.index(e) + 1 < t.childCount)
return n.doc.resolve(n.after(e + 1));
if (t.type.spec.isolating)
break;
}
return null;
}
const tg = (n, e) => {
let t = n.selection, r = t instanceof J, o;
if (r) {
if (t.node.isTextblock || !Wn(n.doc, t.from))
return !1;
o = t.from;
} else if (o = Ns(n.doc, t.from, -1), o == null)
return !1;
if (e) {
let i = n.tr.join(o);
r && i.setSelection(J.create(i.doc, o - n.doc.resolve(o).nodeBefore.nodeSize)), e(i.scrollIntoView());
}
return !0;
}, ng = (n, e) => {
let t = n.selection, r;
if (t instanceof J) {
if (t.node.isTextblock || !Wn(n.doc, t.to))
return !1;
r = t.to;
} else if (r = Ns(n.doc, t.to, 1), r == null)
return !1;
return e && e(n.tr.join(r).scrollIntoView()), !0;
}, rg = (n, e) => {
let { $from: t, $to: r } = n.selection, o = t.blockRange(r), i = o && io(o);
return i == null ? !1 : (e && e(n.tr.lift(o, i).scrollIntoView()), !0);
}, nf = (n, e) => {
let { $head: t, $anchor: r } = n.selection;
return !t.parent.type.spec.code || !t.sameParent(r) ? !1 : (e && e(n.tr.insertText(`
`).scrollIntoView()), !0);
};
function Fa(n) {
for (let e = 0; e < n.edgeCount; e++) {
let { type: t } = n.edge(e);
if (t.isTextblock && !t.hasRequiredAttrs())
return t;
}
return null;
}
const og = (n, e) => {
let { $head: t, $anchor: r } = n.selection;
if (!t.parent.type.spec.code || !t.sameParent(r))
return !1;
let o = t.node(-1), i = t.indexAfter(-1), s = Fa(o.contentMatchAt(i));
if (!s || !o.canReplaceWith(i, i, s))
return !1;
if (e) {
let l = t.after(), a = n.tr.replaceWith(l, l, s.createAndFill());
a.setSelection(te.near(a.doc.resolve(l), 1)), e(a.scrollIntoView());
}
return !0;
}, rf = (n, e) => {
let t = n.selection, { $from: r, $to: o } = t;
if (t instanceof ct || r.parent.inlineContent || o.parent.inlineContent)
return !1;
let i = Fa(o.parent.contentMatchAt(o.indexAfter()));
if (!i || !i.isTextblock)
return !1;
if (e) {
let s = (!r.parentOffset && o.index() < o.parent.childCount ? r : o).pos, l = n.tr.insert(s, i.createAndFill());
l.setSelection(Q.create(l.doc, s + 1)), e(l.scrollIntoView());
}
return !0;
}, of = (n, e) => {
let { $cursor: t } = n.selection;
if (!t || t.parent.content.size)
return !1;
if (t.depth > 1 && t.after() != t.end(-1)) {
let i = t.before();
if (an(n.doc, i))
return e && e(n.tr.split(i).scrollIntoView()), !0;
}
let r = t.blockRange(), o = r && io(r);
return o == null ? !1 : (e && e(n.tr.lift(r, o).scrollIntoView()), !0);
};
function ig(n) {
return (e, t) => {
let { $from: r, $to: o } = e.selection;
if (e.selection instanceof J && e.selection.node.isBlock)
return !r.parentOffset || !an(e.doc, r.pos) ? !1 : (t && t(e.tr.split(r.pos).scrollIntoView()), !0);
if (!r.depth)
return !1;
let i = [], s, l, a = !1, c = !1;
for (let h = r.depth; ; h--)
if (r.node(h).isBlock) {
a = r.end(h) == r.pos + (r.depth - h), c = r.start(h) == r.pos - (r.depth - h), l = Fa(r.node(h - 1).contentMatchAt(r.indexAfter(h - 1))), i.unshift(a && l ? { type: l } : null), s = h;
break;
} else {
if (h == 1)
return !1;
i.unshift(null);
}
let p = e.tr;
(e.selection instanceof Q || e.selection instanceof ct) && p.deleteSelection();
let u = p.mapping.map(r.pos), f = an(p.doc, u, i.length, i);
if (f || (i[0] = l ? { type: l } : null, f = an(p.doc, u, i.length, i)), !f)
return !1;
if (p.split(u, i.length, i), !a && c && r.node(s).type != l) {
let h = p.mapping.map(r.before(s)), b = p.doc.resolve(h);
l && r.node(s - 1).canReplaceWith(b.index(), b.index() + 1, l) && p.setNodeMarkup(p.mapping.map(r.before(s)), l);
}
return t && t(p.scrollIntoView()), !0;
};
}
const sg = ig(), lg = (n, e) => {
let { $from: t, to: r } = n.selection, o, i = t.sharedDepth(r);
return i == 0 ? !1 : (o = t.before(i), e && e(n.tr.setSelection(J.create(n.doc, o))), !0);
};
function ag(n, e, t) {
let r = e.nodeBefore, o = e.nodeAfter, i = e.index();
return !r || !o || !r.type.compatibleContent(o.type) ? !1 : !r.content.size && e.parent.canReplace(i - 1, i) ? (t && t(n.tr.delete(e.pos - r.nodeSize, e.pos).scrollIntoView()), !0) : !e.parent.canReplace(i, i + 1) || !(o.isTextblock || Wn(n.doc, e.pos)) ? !1 : (t && t(n.tr.join(e.pos).scrollIntoView()), !0);
}
function sf(n, e, t, r) {
let o = e.nodeBefore, i = e.nodeAfter, s, l, a = o.type.spec.isolating || i.type.spec.isolating;
if (!a && ag(n, e, t))
return !0;
let c = !a && e.parent.canReplace(e.index(), e.index() + 1);
if (c && (s = (l = o.contentMatchAt(o.childCount)).findWrapping(i.type)) && l.matchType(s[0] || i.type).validEnd) {
if (t) {
let h = e.pos + i.nodeSize, b = D.empty;
for (let v = s.length - 1; v >= 0; v--)
b = D.from(s[v].create(null, b));
b = D.from(o.copy(b));
let m = n.tr.step(new Le(e.pos - 1, h, e.pos, h, new z(b, 1, 0), s.length, !0)), x = m.doc.resolve(h + 2 * s.length);
x.nodeAfter && x.nodeAfter.type == o.type && Wn(m.doc, x.pos) && m.join(x.pos), t(m.scrollIntoView());
}
return !0;
}
let p = i.type.spec.isolating || r > 0 && a ? null : te.findFrom(e, 1), u = p && p.$from.blockRange(p.$to), f = u && io(u);
if (f != null && f >= e.depth)
return t && t(n.tr.lift(u, f).scrollIntoView()), !0;
if (c && Yr(i, "start", !0) && Yr(o, "end")) {
let h = o, b = [];
for (; b.push(h), !h.isTextblock; )
h = h.lastChild;
let m = i, x = 1;
for (; !m.isTextblock; m = m.firstChild)
x++;
if (h.canReplace(h.childCount, h.childCount, m.content)) {
if (t) {
let v = D.empty;
for (let S = b.length - 1; S >= 0; S--)
v = D.from(b[S].copy(v));
let C = n.tr.step(new Le(e.pos - b.length, e.pos + i.nodeSize, e.pos + x, e.pos + i.nodeSize - x, new z(v, b.length, 0), 0, !0));
t(C.scrollIntoView());
}
return !0;
}
}
return !1;
}
function lf(n) {
return function(e, t) {
let r = e.selection, o = n < 0 ? r.$from : r.$to, i = o.depth;
for (; o.node(i).isInline; ) {
if (!i)
return !1;
i--;
}
return o.node(i).isTextblock ? (t && t(e.tr.setSelection(Q.create(e.doc, n < 0 ? o.start(i) : o.end(i)))), !0) : !1;
};
}
const cg = lf(-1), pg = lf(1);
function ug(n, e = null) {
return function(t, r) {
let { $from: o, $to: i } = t.selection, s = o.blockRange(i), l = s && Ma(s, n, e);
return l ? (r && r(t.tr.wrap(s, l).scrollIntoView()), !0) : !1;
};
}
function wp(n, e = null) {
return function(t, r) {
let o = !1;
for (let i = 0; i < t.selection.ranges.length && !o; i++) {
let { $from: { pos: s }, $to: { pos: l } } = t.selection.ranges[i];
t.doc.nodesBetween(s, l, (a, c) => {
if (o)
return !1;
if (!(!a.isTextblock || a.hasMarkup(n, e)))
if (a.type == n)
o = !0;
else {
let p = t.doc.resolve(c), u = p.index();
o = p.parent.canReplaceWith(u, u + 1, n);
}
});
}
if (!o)
return !1;
if (r) {
let i = t.tr;
for (let s = 0; s < t.selection.ranges.length; s++) {
let { $from: { pos: l }, $to: { pos: a } } = t.selection.ranges[s];
i.setBlockType(l, a, n, e);
}
r(i.scrollIntoView());
}
return !0;
};
}
function Ha(...n) {
return function(e, t, r) {
for (let o = 0; o < n.length; o++)
if (n[o](e, t, r))
return !0;
return !1;
};
}
Ha(Ia, Yd, Qd);
Ha(Ia, ef, tf);
Ha(nf, rf, of, sg);
typeof navigator < "u" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : typeof os < "u" && os.platform && os.platform() == "darwin";
function dg(n, e = null) {
return function(t, r) {
let { $from: o, $to: i } = t.selection, s = o.blockRange(i);
if (!s)
return !1;
let l = r ? t.tr : null;
return fg(l, s, n, e) ? (r && r(l.scrollIntoView()), !0) : !1;
};
}
function fg(n, e, t, r = null) {
let o = !1, i = e, s = e.$from.doc;
if (e.depth >= 2 && e.$from.node(e.depth - 1).type.compatibleContent(t) && e.startIndex == 0) {
if (e.$from.index(e.depth - 1) == 0)
return !1;
let a = s.resolve(e.start - 2);
i = new Ui(a, a, e.depth), e.endIndex < e.parent.childCount && (e = new Ui(e.$from, s.resolve(e.$to.end(e.depth)), e.depth)), o = !0;
}
let l = Ma(i, t, r, e);
return l ? (n && hg(n, e, l, o, t), !0) : !1;
}
function hg(n, e, t, r, o) {
let i = D.empty;
for (let p = t.length - 1; p >= 0; p--)
i = D.from(t[p].type.create(t[p].attrs, i));
n.step(new Le(e.start - (r ? 2 : 0), e.end, e.start, e.end, new z(i, 0, 0), t.length, !0));
let s = 0;
for (let p = 0; p < t.length; p++)
t[p].type == o && (s = p + 1);
let l = t.length - s, a = e.start + t.length - (r ? 2 : 0), c = e.parent;
for (let p = e.startIndex, u = e.endIndex, f = !0; p < u; p++, f = !1)
!f && an(n.doc, a, l) && (n.split(a, l), a += 2 * l), a += c.child(p).nodeSize;
return n;
}
function bg(n) {
return function(e, t) {
let { $from: r, $to: o } = e.selection, i = r.blockRange(o, (s) => s.childCount > 0 && s.firstChild.type == n);
return i ? t ? r.node(i.depth - 1).type == n ? mg(e, t, n, i) : xg(e, t, i) : !0 : !1;
};
}
function mg(n, e, t, r) {
let o = n.tr, i = r.end, s = r.$to.end(r.depth);
i < s && (o.step(new Le(i - 1, s, i, s, new z(D.from(t.create(null, r.parent.copy())), 1, 0), 1, !0)), r = new Ui(o.doc.resolve(r.$from.pos), o.doc.resolve(s), r.depth));
const l = io(r);
if (l == null)
return !1;
o.lift(r, l);
let a = o.doc.resolve(o.mapping.map(i, -1) - 1);
return Wn(o.doc, a.pos) && a.nodeBefore.type == a.nodeAfter.type && o.join(a.pos), e(o.scrollIntoView()), !0;
}
function xg(n, e, t) {
let r = n.tr, o = t.parent;
for (let h = t.end, b = t.endIndex - 1, m = t.startIndex; b > m; b--)
h -= o.child(b).nodeSize, r.delete(h - 1, h + 1);
let i = r.doc.resolve(t.start), s = i.nodeAfter;
if (r.mapping.map(t.end) != t.start + i.nodeAfter.nodeSize)
return !1;
let l = t.startIndex == 0, a = t.endIndex == o.childCount, c = i.node(-1), p = i.index(-1);
if (!c.canReplace(p + (l ? 0 : 1), p + 1, s.content.append(a ? D.empty : D.from(o))))
return !1;
let u = i.pos, f = u + s.nodeSize;
return r.step(new Le(u - (l ? 1 : 0), f + (a ? 1 : 0), u + 1, f - 1, new z((l ? D.empty : D.from(o.copy(D.empty))).append(a ? D.empty : D.from(o.copy(D.empty))), l ? 0 : 1, a ? 0 : 1), l ? 0 : 1)), e(r.scrollIntoView()), !0;
}
function gg(n) {
return function(e, t) {
let { $from: r, $to: o } = e.selection, i = r.blockRange(o, (c) => c.childCount > 0 && c.firstChild.type == n);
if (!i)
return !1;
let s = i.startIndex;
if (s == 0)
return !1;
let l = i.parent, a = l.child(s - 1);
if (a.type != n)
return !1;
if (t) {
let c = a.lastChild && a.lastChild.type == l.type, p = D.from(c ? n.create() : null), u = new z(D.from(n.create(null, D.from(l.type.create(null, p)))), c ? 3 : 1, 0), f = i.start, h = i.end;
t(e.tr.step(new Le(f - (c ? 3 : 1), h, f, h, u, 1, !0)).scrollIntoView());
}
return !0;
};
}
function Hs(n) {
const { state: e, transaction: t } = n;
let { selection: r } = t, { doc: o } = t, { storedMarks: i } = t;
return {
...e,
apply: e.apply.bind(e),
applyTransaction: e.applyTransaction.bind(e),
plugins: e.plugins,
schema: e.schema,
reconfigure: e.reconfigure.bind(e),
toJSON: e.toJSON.bind(e),
get storedMarks() {
return i;
},
get selection() {
return r;
},
get doc() {
return o;
},
get tr() {
return r = t.selection, o = t.doc, i = t.storedMarks, t;
}
};
}
class js {
constructor(e) {
this.editor = e.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = e.state;
}
get hasCustomState() {
return !!this.customState;
}
get state() {
return this.customState || this.editor.state;
}
get commands() {
const { rawCommands: e, editor: t, state: r } = this, { view: o } = t, { tr: i } = r, s = this.buildProps(i);
return Object.fromEntries(Object.entries(e).map(([l, a]) => [l, (...p) => {
const u = a(...p)(s);
return !i.getMeta("preventDispatch") && !this.hasCustomState && o.dispatch(i), u;
}]));
}
get chain() {
return () => this.createChain();
}
get can() {
return () => this.createCan();
}
createChain(e, t = !0) {
const { rawCommands: r, editor: o, state: i } = this, { view: s } = o, l = [], a = !!e, c = e || i.tr, p = () => (!a && t && !c.getMeta("preventDispatch") && !this.hasCustomState && s.dispatch(c), l.every((f) => f === !0)), u = {
...Object.fromEntries(Object.entries(r).map(([f, h]) => [f, (...m) => {
const x = this.buildProps(c, t), v = h(...m)(x);
return l.push(v), u;
}])),
run: p
};
return u;
}
createCan(e) {
const { rawCommands: t, state: r } = this, o = !1, i = e || r.tr, s = this.buildProps(i, o);
return {
...Object.fromEntries(Object.entries(t).map(([a, c]) => [a, (...p) => c(...p)({ ...s, dispatch: void 0 })])),
chain: () => this.createChain(i, o)
};
}
buildProps(e, t = !0) {
const { rawCommands: r, editor: o, state: i } = this, { view: s } = o, l = {
tr: e,
editor: o,
view: s,
state: Hs({
state: i,
transaction: e
}),
dispatch: t ? () => {
} : void 0,
chain: () => this.createChain(e, t),
can: () => this.createCan(e),
get commands() {
return Object.fromEntries(Object.entries(r).map(([a, c]) => [a, (...p) => c(...p)(l)]));
}
};
return l;
}
}
class yg {
constructor() {
this.callbacks = {};
}
on(e, t) {
return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), this;
}
emit(e, ...t) {
const r = this.callbacks[e];
return r && r.forEach((o) => o.apply(this, t)), this;
}
off(e, t) {
const r = this.callbacks[e];
return r && (t ? this.callbacks[e] = r.filter((o) => o !== t) : delete this.callbacks[e]), this;
}
once(e, t) {
const r = (...o) => {
this.off(e, r), t.apply(this, o);
};
return this.on(e, r);
}
removeAllListeners() {
this.callbacks = {};
}
}
function U(n, e, t) {
return n.config[e] === void 0 && n.parent ? U(n.parent, e, t) : typeof n.config[e] == "function" ? n.config[e].bind({
...t,
parent: n.parent ? U(n.parent, e, t) : null
}) : n.config[e];
}
function zs(n) {
const e = n.filter((o) => o.type === "extension"), t = n.filter((o) => o.type === "node"), r = n.filter((o) => o.type === "mark");
return {
baseExtensions: e,
nodeExtensions: t,
markExtensions: r
};
}
function af(n) {
const e = [], { nodeExtensions: t, markExtensions: r } = zs(n), o = [...t, ...r], i = {
default: null,
rendered: !0,
renderHTML: null,
parseHTML: null,
keepOnSplit: !0,
isRequired: !1
};
return n.forEach((s) => {
const l = {
name: s.name,
options: s.options,
storage: s.storage,
extensions: o
}, a = U(s, "addGlobalAttributes", l);
if (!a)
return;
a().forEach((p) => {
p.types.forEach((u) => {
Object.entries(p.attributes).forEach(([f, h]) => {
e.push({
type: u,
name: f,
attribute: {
...i,
...h
}
});
});
});
});
}), o.forEach((s) => {
const l = {
name: s.name,
options: s.options,
storage: s.storage
}, a = U(s, "addAttributes", l);
if (!a)
return;
const c = a();
Object.entries(c).forEach(([p, u]) => {
const f = {
...i,
...u
};
typeof (f == null ? void 0 : f.default) == "function" && (f.default = f.default()), f != null && f.isRequired && (f == null ? void 0 : f.default) === void 0 && delete f.default, e.push({
type: s.name,
name: p,
attribute: f
});
});
}), e;
}
function De(n, e) {
if (typeof n == "string") {
if (!e.nodes[n])
throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);
return e.nodes[n];
}
return n;
}
function He(...n) {
return n.filter((e) => !!e).reduce((e, t) => {
const r = { ...e };
return Object.entries(t).forEach(([o, i]) => {
if (!r[o]) {
r[o] = i;
return;
}
if (o === "class") {
const l = i ? String(i).split(" ") : [], a = r[o] ? r[o].split(" ") : [], c = l.filter((p) => !a.includes(p));
r[o] = [...a, ...c].join(" ");
} else if (o === "style") {
const l = i ? i.split(";").map((p) => p.trim()).filter(Boolean) : [], a = r[o] ? r[o].split(";").map((p) => p.trim()).filter(Boolean) : [], c = /* @__PURE__ */ new Map();
a.forEach((p) => {
const [u, f] = p.split(":").map((h) => h.trim());
c.set(u, f);
}), l.forEach((p) => {
const [u, f] = p.split(":").map((h) => h.trim());
c.set(u, f);
}), r[o] = Array.from(c.entries()).map(([p, u]) => `${p}: ${u}`).join("; ");
} else
r[o] = i;
}), r;
}, {});
}
function ea(n, e) {
return e.filter((t) => t.type === n.type.name).filter((t) => t.attribute.rendered).map((t) => t.attribute.renderHTML ? t.attribute.renderHTML(n.attrs) || {} : {
[t.name]: n.attrs[t.name]
}).reduce((t, r) => He(t, r), {});
}
function cf(n) {
return typeof n == "function";
}
function oe(n, e = void 0, ...t) {
return cf(n) ? e ? n.bind(e)(...t) : n(...t) : n;
}
function vg(n = {}) {
return Object.keys(n).length === 0 && n.constructor === Object;
}
function wg(n) {
return typeof n != "string" ? n : n.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(n) : n === "true" ? !0 : n === "false" ? !1 : n;
}
function Sp(n, e) {
return "style" in n ? n : {
...n,
getAttrs: (t) => {
const r = n.getAttrs ? n.getAttrs(t) : n.attrs;
if (r === !1)
return !1;
const o = e.reduce((i, s) => {
const l = s.attribute.parseHTML ? s.attribute.parseHTML(t) : wg(t.getAttribute(s.name));
return l == null ? i : {
...i,
[s.name]: l
};
}, {});
return { ...r, ...o };
}
};
}
function kp(n) {
return Object.fromEntries(
// @ts-ignore
Object.entries(n).filter(([e, t]) => e === "attrs" && vg(t) ? !1 : t != null)
);
}
function Sg(n, e) {
var t;
const r = af(n), { nodeExtensions: o, markExtensions: i } = zs(n), s = (t = o.find((c) => U(c, "topNode"))) === null || t === void 0 ? void 0 : t.name, l = Object.fromEntries(o.map((c) => {
const p = r.filter((v) => v.type === c.name), u = {
name: c.name,
options: c.options,
storage: c.storage,
editor: e
}, f = n.reduce((v, C) => {
const S = U(C, "extendNodeSchema", u);
return {
...v,
...S ? S(c) : {}
};
}, {}), h = kp({
...f,
content: oe(U(c, "content", u)),
marks: oe(U(c, "marks", u)),
group: oe(U(c, "group", u)),
inline: oe(U(c, "inline", u)),
atom: oe(U(c, "atom", u)),
selectable: oe(U(c, "selectable", u)),
draggable: oe(U(c, "draggable", u)),
code: oe(U(c, "code", u)),
whitespace: oe(U(c, "whitespace", u)),
linebreakReplacement: oe(U(c, "linebreakReplacement", u)),
defining: oe(U(c, "defining", u)),
isolating: oe(U(c, "isolating", u)),
attrs: Object.fromEntries(p.map((v) => {
var C;
return [v.name, { default: (C = v == null ? void 0 : v.attribute) === null || C === void 0 ? void 0 : C.default }];
}))
}), b = oe(U(c, "parseHTML", u));
b && (h.parseDOM = b.map((v) => Sp(v, p)));
const m = U(c, "renderHTML", u);
m && (h.toDOM = (v) => m({
node: v,
HTMLAttributes: ea(v, p)
}));
const x = U(c, "renderText", u);
return x && (h.toText = x), [c.name, h];
})), a = Object.fromEntries(i.map((c) => {
const p = r.filter((x) => x.type === c.name), u = {
name: c.name,
options: c.options,
storage: c.storage,
editor: e
}, f = n.reduce((x, v) => {
const C = U(v, "extendMarkSchema", u);
return {
...x,
...C ? C(c) : {}
};
}, {}), h = kp({
...f,
inclusive: oe(U(c, "inclusive", u)),
excludes: oe(U(c, "excludes", u)),
group: oe(U(c, "group", u)),
spanning: oe(U(c, "spanning", u)),
code: oe(U(c, "code", u)),
attrs: Object.fromEntries(p.map((x) => {
var v;
return [x.name, { default: (v = x == null ? void 0 : x.attribute) === null || v === void 0 ? void 0 : v.default }];
}))
}), b = oe(U(c, "parseHTML", u));
b && (h.parseDOM = b.map((x) => Sp(x, p)));
const m = U(c, "renderHTML", u);
return m && (h.toDOM = (x) => m({
mark: x,
HTMLAttributes: ea(x, p)
})), [c.name, h];
}));
return new Ju({
topNode: s,
nodes: l,
marks: a
});
}
function hl(n, e) {
return e.nodes[n] || e.marks[n] || null;
}
function Cp(n, e) {
return Array.isArray(e) ? e.some((t) => (typeof t == "string" ? t : t.name) === n.name) : e;
}
function ja(n, e) {
const t = Or.fromSchema(e).serializeFragment(n), o = document.implementation.createHTMLDocument().createElement("div");
return o.appendChild(t), o.innerHTML;
}
const kg = (n, e = 500) => {
let t = "";
const r = n.parentOffset;
return n.parent.nodesBetween(Math.max(0, r - e), r, (o, i, s, l) => {
var a, c;
const p = ((c = (a = o.type.spec).toText) === null || c === void 0 ? void 0 : c.call(a, {
node: o,
pos: i,
parent: s,
index: l
})) || o.textContent || "%leaf%";
t += o.isAtom && !o.isText ? p : p.slice(0, Math.max(0, r - i));
}), t;
};
function za(n) {
return Object.prototype.toString.call(n) === "[object RegExp]";
}
class Vs {
constructor(e) {
this.find = e.find, this.handler = e.handler;
}
}
const Cg = (n, e) => {
if (za(e))
return e.exec(n);
const t = e(n);
if (!t)
return null;
const r = [t.text];
return r.index = t.index, r.input = n, r.data = t.data, t.replaceWith && (t.text.includes(t.replaceWith) || console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'), r.push(t.replaceWith)), r;
};
function xi(n) {
var e;
const { editor: t, from: r, to: o, text: i, rules: s, plugin: l } = n, { view: a } = t;
if (a.composing)
return !1;
const c = a.state.doc.resolve(r);
if (
// check for code node
c.parent.type.spec.code || !((e = c.nodeBefore || c.nodeAfter) === null || e === void 0) && e.marks.find((f) => f.type.spec.code)
)
return !1;
let p = !1;
const u = kg(c) + i;
return s.forEach((f) => {
if (p)
return;
const h = Cg(u, f.find);
if (!h)
return;
const b = a.state.tr, m = Hs({
state: a.state,
transaction: b
}), x = {
from: r - (h[0].length - i.length),
to: o
}, { commands: v, chain: C, can: S } = new js({
editor: t,
state: m
});
f.handler({
state: m,
range: x,
match: h,
commands: v,
chain: C,
can: S
}) === null || !b.steps.length || (b.setMeta(l, {
transform: b,
from: r,
to: o,
text: i
}), a.dispatch(b), p = !0);
}), p;
}
function Mg(n) {
const { editor: e, rules: t } = n, r = new Oe({
state: {
init() {
return null;
},
apply(o, i, s) {
const l = o.getMeta(r);
if (l)
return l;
const a = o.getMeta("applyInputRules");
return !!a && setTimeout(() => {
let { text: p } = a;
typeof p == "string" ? p = p : p = ja(D.from(p), s.schema);
const { from: u } = a, f = u + p.length;
xi({
editor: e,
from: u,
to: f,
text: p,
rules: t,
plugin: r
});
}), o.selectionSet || o.docChanged ? null : i;
}
},
props: {
handleTextInput(o, i, s, l) {
return xi({
editor: e,
from: i,
to: s,
text: l,
rules: t,
plugin: r
});
},
handleDOMEvents: {
compositionend: (o) => (setTimeout(() => {
const { $cursor: i } = o.state.selection;
i && xi({
editor: e,
from: i.pos,
to: i.pos,
text: "",
rules: t,
plugin: r
});
}), !1)
},
// add support for input rules to trigger on enter
// this is useful for example for code blocks
handleKeyDown(o, i) {
if (i.key !== "Enter")
return !1;
const { $cursor: s } = o.state.selection;
return s ? xi({
editor: e,
from: s.pos,
to: s.pos,
text: `
`,
rules: t,
plugin: r
}) : !1;
}
},
// @ts-ignore
isInputRules: !0
});
return r;
}
function Eg(n) {
return Object.prototype.toString.call(n).slice(8, -1);
}
function gi(n) {
return Eg(n) !== "Object" ? !1 : n.constructor === Object && Object.getPrototypeOf(n) === Object.prototype;
}
function Ws(n, e) {
const t = { ...n };
return gi(n) && gi(e) && Object.keys(e).forEach((r) => {
gi(e[r]) && gi(n[r]) ? t[r] = Ws(n[r], e[r]) : t[r] = e[r];
}), t;
}
class un {
constructor(e = {}) {
this.type = "mark", this.name = "mark", this.parent = null, this.child = null, this.config = {
name: this.name,
defaultOptions: {}
}, this.config = {
...this.config,
...e
}, this.name = this.config.name, e.defaultOptions && Object.keys(e.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`), this.options = this.config.defaultOptions, this.config.addOptions && (this.options = oe(U(this, "addOptions", {
name: this.name
}))), this.storage = oe(U(this, "addStorage", {
name: this.name,
options: this.options
})) || {};
}
static create(e = {}) {
return new un(e);
}
configure(e = {}) {
const t = this.extend({
...this.config,
addOptions: () => Ws(this.options, e)
});
return t.name = this.name, t.parent = this.parent, t;
}
extend(e = {}) {
const t = new un(e);
return t.parent = this, this.child = t, t.name = e.name ? e.name : t.parent.name, e.defaultOptions && Object.keys(e.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`), t.options = oe(U(t, "addOptions", {
name: t.name
})), t.storage = oe(U(t, "addStorage", {
name: t.name,
options: t.options
})), t;
}
static handleExit({ editor: e, mark: t }) {
const { tr: r } = e.state, o = e.state.selection.$from;
if (o.pos === o.end()) {
const s = o.marks();
if (!!!s.find((c) => (c == null ? void 0 : c.type.name) === t.name))
return !1;
const a = s.find((c) => (c == null ? void 0 : c.type.name) === t.name);
return a && r.removeStoredMark(a), r.insertText(" ", o.pos), e.view.dispatch(r), !0;
}
return !1;
}
}
function Tg(n) {
return typeof n == "number";
}
class Og {
constructor(e) {
this.find = e.find, this.handler = e.handler;
}
}
const Bg = (n, e, t) => {
if (za(e))
return [...n.matchAll(e)];
const r = e(n, t);
return r ? r.map((o) => {
const i = [o.text];
return i.index = o.index, i.input = n, i.data = o.data, o.replaceWith && (o.text.includes(o.replaceWith) || console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'), i.push(o.replaceWith)), i;
}) : [];
};
function Pg(n) {
const { editor: e, state: t, from: r, to: o, rule: i, pasteEvent: s, dropEvent: l } = n, { commands: a, chain: c, can: p } = new js({
editor: e,
state: t
}), u = [];
return t.doc.nodesBetween(r, o, (h, b) => {
if (!h.isTextblock || h.type.spec.code)
return;
const m = Math.max(r, b), x = Math.min(o, b + h.content.size), v = h.textBetween(m - b, x - b, void 0, "");
Bg(v, i.find, s).forEach((S) => {
if (S.index === void 0)
return;
const g = m + S.index + 1, O = g + S[0].length, T = {
from: t.tr.mapping.map(g),
to: t.tr.mapping.map(O)
}, B = i.handler({
state: t,
range: T,
match: S,
commands: a,
chain: c,
can: p,
pasteEvent: s,
dropEvent: l
});
u.push(B);
});
}), u.every((h) => h !== null);
}
let yi = null;
const Ag = (n) => {
var e;
const t = new ClipboardEvent("paste", {
clipboardData: new DataTransfer()
});
return (e = t.clipboardData) === null || e === void 0 || e.setData("text/html", n), t;
};
function _g(n) {
const { editor: e, rules: t } = n;
let r = null, o = !1, i = !1, s = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, l;
try {
l = typeof DragEvent < "u" ? new DragEvent("drop") : null;
} catch {
l = null;
}
const a = ({ state: p, from: u, to: f, rule: h, pasteEvt: b }) => {
const m = p.tr, x = Hs({
state: p,
transaction: m
});
if (!(!Pg({
editor: e,
state: x,
from: Math.max(u - 1, 0),
to: f.b - 1,
rule: h,
pasteEvent: b,
dropEvent: l
}) || !m.steps.length)) {
try {
l = typeof DragEvent < "u" ? new DragEvent("drop") : null;
} catch {
l = null;
}
return s = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, m;
}
};
return t.map((p) => new Oe({
// we register a global drag handler to track the current drag source element
view(u) {
const f = (b) => {
var m;
r = !((m = u.dom.parentElement) === null || m === void 0) && m.contains(b.target) ? u.dom.parentElement : null, r && (yi = e);
}, h = () => {
yi && (yi = null);
};
return window.addEventListener("dragstart", f), window.addEventListener("dragend", h), {
destroy() {
window.removeEventListener("dragstart", f), window.removeEventListener("dragend", h);
}
};
},
props: {
handleDOMEvents: {
drop: (u, f) => {
if (i = r === u.dom.parentElement, l = f, !i) {
const h = yi;
h != null && h.isEditable && setTimeout(() => {
const b = h.state.selection;
b && h.commands.deleteRange({ from: b.from, to: b.to });
}, 10);
}
return !1;
},
paste: (u, f) => {
var h;
const b = (h = f.clipboardData) === null || h === void 0 ? void 0 : h.getData("text/html");
return s = f, o = !!(b != null && b.includes("data-pm-slice")), !1;
}
}
},
appendTransaction: (u, f, h) => {
const b = u[0], m = b.getMeta("uiEvent") === "paste" && !o, x = b.getMeta("uiEvent") === "drop" && !i, v = b.getMeta("applyPasteRules"), C = !!v;
if (!m && !x && !C)
return;
if (C) {
let { text: O } = v;
typeof O == "string" ? O = O : O = ja(D.from(O), h.schema);
const { from: T } = v, B = T + O.length, F = Ag(O);
return a({
rule: p,
state: h,
from: T,
to: { b: B },
pasteEvt: F
});
}
const S = f.doc.content.findDiffStart(h.doc.content), g = f.doc.content.findDiffEnd(h.doc.content);
if (!(!Tg(S) || !g || S === g.b))
return a({
rule: p,
state: h,
from: S,
to: g,
pasteEvt: s
});
}
}));
}
function Lg(n) {
const e = n.filter((t, r) => n.indexOf(t) !== r);
return Array.from(new Set(e));
}
class jr {
constructor(e, t) {
this.splittableMarks = [], this.editor = t, this.extensions = jr.resolve(e), this.schema = Sg(this.extensions, t), this.setupExtensions();
}
/**
* Returns a flattened and sorted extension list while
* also checking for duplicated extensions and warns the user.
* @param extensions An array of Tiptap extensions
* @returns An flattened and sorted array of Tiptap extensions
*/
static resolve(e) {
const t = jr.sort(jr.flatten(e)), r = Lg(t.map((o) => o.name));
return r.length && console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map((o) => `'${o}'`).join(", ")}]. This can lead to issues.`), t;
}
/**
* Create a flattened array of extensions by traversing the `addExtensions` field.
* @param extensions An array of Tiptap extensions
* @returns A flattened array of Tiptap extensions
*/
static flatten(e) {
return e.map((t) => {
const r = {
name: t.name,
options: t.options,
storage: t.storage
}, o = U(t, "addExtensions", r);
return o ? [t, ...this.flatten(o())] : t;
}).flat(10);
}
/**
* Sort extensions by priority.
* @param extensions An array of Tiptap extensions
* @returns A sorted array of Tiptap extensions by priority
*/
static sort(e) {
return e.sort((r, o) => {
const i = U(r, "priority") || 100, s = U(o, "priority") || 100;
return i > s ? -1 : i < s ? 1 : 0;
});
}
/**
* Get all commands from the extensions.
* @returns An object with all commands where the key is the command name and the value is the command function
*/
get commands() {
return this.extensions.reduce((e, t) => {
const r = {
name: t.name,
options: t.options,
storage: t.storage,
editor: this.editor,
type: hl(t.name, this.schema)
}, o = U(t, "addCommands", r);
return o ? {
...e,
...o()
} : e;
}, {});
}
/**
* Get all registered Prosemirror plugins from the extensions.
* @returns An array of Prosemirror plugins
*/
get plugins() {
const { editor: e } = this, t = jr.sort([...this.extensions].reverse()), r = [], o = [], i = t.map((s) => {
const l = {
name: s.name,
options: s.options,
storage: s.storage,
editor: e,
type: hl(s.name, this.schema)
}, a = [], c = U(s, "addKeyboardShortcuts", l);
let p = {};
if (s.type === "mark" && U(s, "exitable", l) && (p.ArrowRight = () => un.handleExit({ editor: e, mark: s })), c) {
const m = Object.fromEntries(Object.entries(c()).map(([x, v]) => [x, () => v({ editor: e })]));
p = { ...p, ...m };
}
const u = Qx(p);
a.push(u);
const f = U(s, "addInputRules", l);
Cp(s, e.options.enableInputRules) && f && r.push(...f());
const h = U(s, "addPasteRules", l);
Cp(s, e.options.enablePasteRules) && h && o.push(...h());
const b = U(s, "addProseMirrorPlugins", l);
if (b) {
const m = b();
a.push(...m);
}
return a;
}).flat();
return [
Mg({
editor: e,
rules: r
}),
..._g({
editor: e,
rules: o
}),
...i
];
}
/**
* Get all attributes from the extensions.
* @returns An array of attributes
*/
get attributes() {
return af(this.extensions);
}
/**
* Get all node views from the extensions.
* @returns An object with all node views where the key is the node name and the value is the node view function
*/
get nodeViews() {
const { editor: e } = this, { nodeExtensions: t } = zs(this.extensions);
return Object.fromEntries(t.filter((r) => !!U(r, "addNodeView")).map((r) => {
const o = this.attributes.filter((a) => a.type === r.name), i = {
name: r.name,
options: r.options,
storage: r.storage,
editor: e,
type: De(r.name, this.schema)
}, s = U(r, "addNodeView", i);
if (!s)
return [];
const l = (a, c, p, u, f) => {
const h = ea(a, o);
return s()({
// pass-through
node: a,
view: c,
getPos: p,
decorations: u,
innerDecorations: f,
// tiptap-specific
editor: e,
extension: r,
HTMLAttributes: h
});
};
return [r.name, l];
}));
}
/**
* Go through all extensions, create extension storages & setup marks
* & bind editor event listener.
*/
setupExtensions() {
this.extensions.forEach((e) => {
var t;
this.editor.extensionStorage[e.name] = e.storage;
const r = {
name: e.name,
options: e.options,
storage: e.storage,
editor: this.editor,
type: hl(e.name, this.schema)
};
e.type === "mark" && (!((t = oe(U(e, "keepOnSplit", r))) !== null && t !== void 0) || t) && this.splittableMarks.push(e.name);
const o = U(e, "onBeforeCreate", r), i = U(e, "onCreate", r), s = U(e, "onUpdate", r), l = U(e, "onSelectionUpdate", r), a = U(e, "onTransaction", r), c = U(e, "onFocus", r), p = U(e, "onBlur", r), u = U(e, "onDestroy", r);
o && this.editor.on("beforeCreate", o), i && this.editor.on("create", i), s && this.editor.on("update", s), l && this.editor.on("selectionUpdate", l), a && this.editor.on("transaction", a), c && this.editor.on("focus", c), p && this.editor.on("blur", p), u && this.editor.on("destroy", u);
});
}
}
class je {
constructor(e = {}) {
this.type = "extension", this.name = "extension", this.parent = null, this.child = null, this.config = {
name: this.name,
defaultOptions: {}
}, this.config = {
...this.config,
...e
}, this.name = this.config.name, e.defaultOptions && Object.keys(e.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`), this.options = this.config.defaultOptions, this.config.addOptions && (this.options = oe(U(this, "addOptions", {
name: this.name
}))), this.storage = oe(U(this, "addStorage", {
name: this.name,
options: this.options
})) || {};
}
static create(e = {}) {
return new je(e);
}
configure(e = {}) {
const t = this.extend({
...this.config,
addOptions: () => Ws(this.options, e)
});
return t.name = this.name, t.parent = this.parent, t;
}
extend(e = {}) {
const t = new je({ ...this.config, ...e });
return t.parent = this, this.child = t, t.name = e.name ? e.name : t.parent.name, e.defaultOptions && Object.keys(e.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`), t.options = oe(U(t, "addOptions", {
name: t.name
})), t.storage = oe(U(t, "addStorage", {
name: t.name,
options: t.options
})), t;
}
}
function pf(n, e, t) {
const { from: r, to: o } = e, { blockSeparator: i = `
`, textSerializers: s = {} } = t || {};
let l = "";
return n.nodesBetween(r, o, (a, c, p, u) => {
var f;
a.isBlock && c > r && (l += i);
const h = s == null ? void 0 : s[a.type.name];
if (h)
return p && (l += h({
node: a,
pos: c,
parent: p,
index: u,
range: e
})), !1;
a.isText && (l += (f = a == null ? void 0 : a.text) === null || f === void 0 ? void 0 : f.slice(Math.max(r, c) - c, o - c));
}), l;
}
function Va(n) {
return Object.fromEntries(Object.entries(n.nodes).filter(([, e]) => e.spec.toText).map(([e, t]) => [e, t.spec.toText]));
}
const Ng = je.create({
name: "clipboardTextSerializer",
addOptions() {
return {
blockSeparator: void 0
};
},
addProseMirrorPlugins() {
return [
new Oe({
key: new Ze("clipboardTextSerializer"),
props: {
clipboardTextSerializer: () => {
const { editor: n } = this, { state: e, schema: t } = n, { doc: r, selection: o } = e, { ranges: i } = o, s = Math.min(...i.map((p) => p.$from.pos)), l = Math.max(...i.map((p) => p.$to.pos)), a = Va(t);
return pf(r, { from: s, to: l }, {
...this.options.blockSeparator !== void 0 ? { blockSeparator: this.options.blockSeparator } : {},
textSerializers: a
});
}
}
})
];
}
}), Dg = () => ({ editor: n, view: e }) => (requestAnimationFrame(() => {
var t;
n.isDestroyed || (e.dom.blur(), (t = window == null ? void 0 : window.getSelection()) === null || t === void 0 || t.removeAllRanges());
}), !0), Ig = (n = !1) => ({ commands: e }) => e.setContent("", n), $g = () => ({ state: n, tr: e, dispatch: t }) => {
const { selection: r } = e, { ranges: o } = r;
return t && o.forEach(({ $from: i, $to: s }) => {
n.doc.nodesBetween(i.pos, s.pos, (l, a) => {
if (l.type.isText)
return;
const { doc: c, mapping: p } = e, u = c.resolve(p.map(a)), f = c.resolve(p.map(a + l.nodeSize)), h = u.blockRange(f);
if (!h)
return;
const b = io(h);
if (l.type.isTextblock) {
const { defaultType: m } = u.parent.contentMatchAt(u.index());
e.setNodeMarkup(h.start, m);
}
(b || b === 0) && e.lift(h, b);
});
}), !0;
}, Rg = (n) => (e) => n(e), Fg = () => ({ state: n, dispatch: e }) => rf(n, e), Hg = (n, e) => ({ editor: t, tr: r }) => {
const { state: o } = t, i = o.doc.slice(n.from, n.to);
r.deleteRange(n.from, n.to);
const s = r.mapping.map(e);
return r.insert(s, i.content), r.setSelection(new Q(r.doc.resolve(Math.max(s - 1, 0)))), !0;
}, jg = () => ({ tr: n, dispatch: e }) => {
const { selection: t } = n, r = t.$anchor.node();
if (r.content.size > 0)
return !1;
const o = n.selection.$anchor;
for (let i = o.depth; i > 0; i -= 1)
if (o.node(i).type === r.type) {
if (e) {
const l = o.before(i), a = o.after(i);
n.delete(l, a).scrollIntoView();
}
return !0;
}
return !1;
}, zg = (n) => ({ tr: e, state: t, dispatch: r }) => {
const o = De(n, t.schema), i = e.selection.$anchor;
for (let s = i.depth; s > 0; s -= 1)
if (i.node(s).type === o) {
if (r) {
const a = i.before(s), c = i.after(s);
e.delete(a, c).scrollIntoView();
}
return !0;
}
return !1;
}, Vg = (n) => ({ tr: e, dispatch: t }) => {
const { from: r, to: o } = n;
return t && e.delete(r, o), !0;
}, Wg = () => ({ state: n, dispatch: e }) => Ia(n, e), Ug = () => ({ commands: n }) => n.keyboardShortcut("Enter"), qg = () => ({ state: n, dispatch: e }) => og(n, e);
function Zi(n, e, t = { strict: !0 }) {
const r = Object.keys(e);
return r.length ? r.every((o) => t.strict ? e[o] === n[o] : za(e[o]) ? e[o].test(n[o]) : e[o] === n[o]) : !0;
}
function uf(n, e, t = {}) {
return n.find((r) => r.type === e && Zi(
// Only check equality for the attributes that are provided
Object.fromEntries(Object.keys(t).map((o) => [o, r.attrs[o]])),
t
));
}
function Mp(n, e, t = {}) {
return !!uf(n, e, t);
}
function Wa(n, e, t) {
var r;
if (!n || !e)
return;
let o = n.parent.childAfter(n.parentOffset);
if ((!o.node || !o.node.marks.some((p) => p.type === e)) && (o = n.parent.childBefore(n.parentOffset)), !o.node || !o.node.marks.some((p) => p.type === e) || (t = t || ((r = o.node.marks[0]) === null || r === void 0 ? void 0 : r.attrs), !uf([...o.node.marks], e, t)))
return;
let s = o.index, l = n.start() + o.offset, a = s + 1, c = l + o.node.nodeSize;
for (; s > 0 && Mp([...n.parent.child(s - 1).marks], e, t); )
s -= 1, l -= n.parent.child(s).nodeSize;
for (; a < n.parent.childCount && Mp([...n.parent.child(a).marks], e, t); )
c += n.parent.child(a).nodeSize, a += 1;
return {
from: l,
to: c
};
}
function qn(n, e) {
if (typeof n == "string") {
if (!e.marks[n])
throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);
return e.marks[n];
}
return n;
}
const Kg = (n, e = {}) => ({ tr: t, state: r, dispatch: o }) => {
const i = qn(n, r.schema), { doc: s, selection: l } = t, { $from: a, from: c, to: p } = l;
if (o) {
const u = Wa(a, i, e);
if (u && u.from <= c && u.to >= p) {
const f = Q.create(s, u.from, u.to);
t.setSelection(f);
}
}
return !0;
}, Gg = (n) => (e) => {
const t = typeof n == "function" ? n(e) : n;
for (let r = 0; r < t.length; r += 1)
if (t[r](e))
return !0;
return !1;
};
function Ua(n) {
return n instanceof Q;
}
function ln(n = 0, e = 0, t = 0) {
return Math.min(Math.max(n, e), t);
}
function df(n, e = null) {
if (!e)
return null;
const t = te.atStart(n), r = te.atEnd(n);
if (e === "start" || e === !0)
return t;
if (e === "end")
return r;
const o = t.from, i = r.to;
return e === "all" ? Q.create(n, ln(0, o, i), ln(n.content.size, o, i)) : Q.create(n, ln(e, o, i), ln(e, o, i));
}
function Jg() {
return navigator.platform === "Android" || /android/i.test(navigator.userAgent);
}
function qa() {
return [
"iPad Simulator",
"iPhone Simulator",
"iPod Simulator",
"iPad",
"iPhone",
"iPod"
].includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document;
}
const Yg = (n = null, e = {}) => ({ editor: t, view: r, tr: o, dispatch: i }) => {
e = {
scrollIntoView: !0,
...e
};
const s = () => {
(qa() || Jg()) && r.dom.focus(), requestAnimationFrame(() => {
t.isDestroyed || (r.focus(), e != null && e.scrollIntoView && t.commands.scrollIntoView());
});
};
if (r.hasFocus() && n === null || n === !1)
return !0;
if (i && n === null && !Ua(t.state.selection))
return s(), !0;
const l = df(o.doc, n) || t.state.selection, a = t.state.selection.eq(l);
return i && (a || o.setSelection(l), a && o.storedMarks && o.setStoredMarks(o.storedMarks), s()), !0;
}, Xg = (n, e) => (t) => n.every((r, o) => e(r, { ...t, index: o })), Qg = (n, e) => ({ tr: t, commands: r }) => r.insertContentAt({ from: t.selection.from, to: t.selection.to }, n, e), ff = (n) => {
const e = n.childNodes;
for (let t = e.length - 1; t >= 0; t -= 1) {
const r = e[t];
r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? n.removeChild(r) : r.nodeType === 1 && ff(r);
}
return n;
};
function vi(n) {
const e = `<body>${n}</body>`, t = new window.DOMParser().parseFromString(e, "text/html").body;
return ff(t);
}
function zo(n, e, t) {
if (n instanceof $n || n instanceof D)
return n;
t = {
slice: !0,
parseOptions: {},
...t
};
const r = typeof n == "object" && n !== null, o = typeof n == "string";
if (r)
try {
if (Array.isArray(n) && n.length > 0)
return D.fromArray(n.map((l) => e.nodeFromJSON(l)));
const s = e.nodeFromJSON(n);
return t.errorOnInvalidContent && s.check(), s;
} catch (i) {
if (t.errorOnInvalidContent)
throw new Error("[tiptap error]: Invalid JSON content", { cause: i });
return console.warn("[tiptap warn]: Invalid content.", "Passed value:", n, "Error:", i), zo("", e, t);
}
if (o) {
if (t.errorOnInvalidContent) {
let s = !1, l = "";
const a = new Ju({
topNode: e.spec.topNode,
marks: e.spec.marks,
// Prosemirror's schemas are executed such that: the last to execute, matches last
// This means that we can add a catch-all node at the end of the schema to catch any content that we don't know how to handle
nodes: e.spec.nodes.append({
__tiptap__private__unknown__catch__all__node: {
content: "inline*",
group: "block",
parseDOM: [
{
tag: "*",
getAttrs: (c) => (s = !0, l = typeof c == "string" ? c : c.outerHTML, null)
}
]
}
})
});
if (t.slice ? wo.fromSchema(a).parseSlice(vi(n), t.parseOptions) : wo.fromSchema(a).parse(vi(n), t.parseOptions), t.errorOnInvalidContent && s)
throw new Error("[tiptap error]: Invalid HTML content", { cause: new Error(`Invalid element found: ${l}`) });
}
const i = wo.fromSchema(e);
return t.slice ? i.parseSlice(vi(n), t.parseOptions).content : i.parse(vi(n), t.parseOptions);
}
return zo("", e, t);
}
function Zg(n, e, t) {
const r = n.steps.length - 1;
if (r < e)
return;
const o = n.steps[r];
if (!(o instanceof _e || o instanceof Le))
return;
const i = n.mapping.maps[r];
let s = 0;
i.forEach((l, a, c, p) => {
s === 0 && (s = p);
}), n.setSelection(te.near(n.doc.resolve(s), t));
}
const ey = (n) => !("type" in n), ty = (n, e, t) => ({ tr: r, dispatch: o, editor: i }) => {
var s;
if (o) {
t = {
parseOptions: i.options.parseOptions,
updateSelection: !0,
applyInputRules: !1,
applyPasteRules: !1,
...t
};
let l;
const a = (x) => {
i.emit("contentError", {
editor: i,
error: x,
disableCollaboration: () => {
i.storage.collaboration && (i.storage.collaboration.isDisabled = !0);
}
});
}, c = {
preserveWhitespace: "full",
...t.parseOptions
};
if (!t.errorOnInvalidContent && !i.options.enableContentCheck && i.options.emitContentError)
try {
zo(e, i.schema, {
parseOptions: c,
errorOnInvalidContent: !0
});
} catch (x) {
a(x);
}
try {
l = zo(e, i.schema, {
parseOptions: c,
errorOnInvalidContent: (s = t.errorOnInvalidContent) !== null && s !== void 0 ? s : i.options.enableContentCheck
});
} catch (x) {
return a(x), !1;
}
let { from: p, to: u } = typeof n == "number" ? { from: n, to: n } : { from: n.from, to: n.to }, f = !0, h = !0;
if ((ey(l) ? l : [l]).forEach((x) => {
x.check(), f = f ? x.isText && x.marks.length === 0 : !1, h = h ? x.isBlock : !1;
}), p === u && h) {
const { parent: x } = r.doc.resolve(p);
x.isTextblock && !x.type.spec.code && !x.childCount && (p -= 1, u += 1);
}
let m;
if (f) {
if (Array.isArray(e))
m = e.map((x) => x.text || "").join("");
else if (e instanceof D) {
let x = "";
e.forEach((v) => {
v.text && (x += v.text);
}), m = x;
} else typeof e == "object" && e && e.text ? m = e.text : m = e;
r.insertText(m, p, u);
} else
m = l, r.replaceWith(p, u, m);
t.updateSelection && Zg(r, r.steps.length - 1, -1), t.applyInputRules && r.setMeta("applyInputRules", { from: p, text: m }), t.applyPasteRules && r.setMeta("applyPasteRules", { from: p, text: m });
}
return !0;
}, ny = () => ({ state: n, dispatch: e }) => tg(n, e), ry = () => ({ state: n, dispatch: e }) => ng(n, e), oy = () => ({ state: n, dispatch: e }) => Yd(n, e), iy = () => ({ state: n, dispatch: e }) => ef(n, e), sy = () => ({ state: n, dispatch: e, tr: t }) => {
try {
const r = Ns(n.doc, n.selection.$from.pos, -1);
return r == null ? !1 : (t.join(r, 2), e && e(t), !0);
} catch {
return !1;
}
}, ly = () => ({ state: n, dispatch: e, tr: t }) => {
try {
const r = Ns(n.doc, n.selection.$from.pos, 1);
return r == null ? !1 : (t.join(r, 2), e && e(t), !0);
} catch {
return !1;
}
}, ay = () => ({ state: n, dispatch: e }) => Zx(n, e), cy = () => ({ state: n, dispatch: e }) => eg(n, e);
function hf() {
return typeof navigator < "u" ? /Mac/.test(navigator.platform) : !1;
}
function py(n) {
const e = n.split(/-(?!$)/);
let t = e[e.length - 1];
t === "Space" && (t = " ");
let r, o, i, s;
for (let l = 0; l < e.length - 1; l += 1) {
const a = e[l];
if (/^(cmd|meta|m)$/i.test(a))
s = !0;
else if (/^a(lt)?$/i.test(a))
r = !0;
else if (/^(c|ctrl|control)$/i.test(a))
o = !0;
else if (/^s(hift)?$/i.test(a))
i = !0;
else if (/^mod$/i.test(a))
qa() || hf() ? s = !0 : o = !0;
else
throw new Error(`Unrecognized modifier name: ${a}`);
}
return r && (t = `Alt-${t}`), o && (t = `Ctrl-${t}`), s && (t = `Meta-${t}`), i && (t = `Shift-${t}`), t;
}
const uy = (n) => ({ editor: e, view: t, tr: r, dispatch: o }) => {
const i = py(n).split(/-(?!$)/), s = i.find((c) => !["Alt", "Ctrl", "Meta", "Shift"].includes(c)), l = new KeyboardEvent("keydown", {
key: s === "Space" ? " " : s,
altKey: i.includes("Alt"),
ctrlKey: i.includes("Ctrl"),
metaKey: i.includes("Meta"),
shiftKey: i.includes("Shift"),
bubbles: !0,
cancelable: !0
}), a = e.captureTransaction(() => {
t.someProp("handleKeyDown", (c) => c(t, l));
});
return a == null || a.steps.forEach((c) => {
const p = c.map(r.mapping);
p && o && r.maybeStep(p);
}), !0;
};
function Vo(n, e, t = {}) {
const { from: r, to: o, empty: i } = n.selection, s = e ? De(e, n.schema) : null, l = [];
n.doc.nodesBetween(r, o, (u, f) => {
if (u.isText)
return;
const h = Math.max(r, f), b = Math.min(o, f + u.nodeSize);
l.push({
node: u,
from: h,
to: b
});
});
const a = o - r, c = l.filter((u) => s ? s.name === u.node.type.name : !0).filter((u) => Zi(u.node.attrs, t, { strict: !1 }));
return i ? !!c.length : c.reduce((u, f) => u + f.to - f.from, 0) >= a;
}
const dy = (n, e = {}) => ({ state: t, dispatch: r }) => {
const o = De(n, t.schema);
return Vo(t, o, e) ? rg(t, r) : !1;
}, fy = () => ({ state: n, dispatch: e }) => of(n, e), hy = (n) => ({ state: e, dispatch: t }) => {
const r = De(n, e.schema);
return bg(r)(e, t);
}, by = () => ({ state: n, dispatch: e }) => nf(n, e);
function Us(n, e) {
return e.nodes[n] ? "node" : e.marks[n] ? "mark" : null;
}
function Ep(n, e) {
const t = typeof e == "string" ? [e] : e;
return Object.keys(n).reduce((r, o) => (t.includes(o) || (r[o] = n[o]), r), {});
}
const my = (n, e) => ({ tr: t, state: r, dispatch: o }) => {
let i = null, s = null;
const l = Us(typeof n == "string" ? n : n.name, r.schema);
return l ? (l === "node" && (i = De(n, r.schema)), l === "mark" && (s = qn(n, r.schema)), o && t.selection.ranges.forEach((a) => {
r.doc.nodesBetween(a.$from.pos, a.$to.pos, (c, p) => {
i && i === c.type && t.setNodeMarkup(p, void 0, Ep(c.attrs, e)), s && c.marks.length && c.marks.forEach((u) => {
s === u.type && t.addMark(p, p + c.nodeSize, s.create(Ep(u.attrs, e)));
});
});
}), !0) : !1;
}, xy = () => ({ tr: n, dispatch: e }) => (e && n.scrollIntoView(), !0), gy = () => ({ tr: n, dispatch: e }) => {
if (e) {
const t = new ct(n.doc);
n.setSelection(t);
}
return !0;
}, yy = () => ({ state: n, dispatch: e }) => Qd(n, e), vy = () => ({ state: n, dispatch: e }) => tf(n, e), wy = () => ({ state: n, dispatch: e }) => lg(n, e), Sy = () => ({ state: n, dispatch: e }) => pg(n, e), ky = () => ({ state: n, dispatch: e }) => cg(n, e);
function ta(n, e, t = {}, r = {}) {
return zo(n, e, {
slice: !1,
parseOptions: t,
errorOnInvalidContent: r.errorOnInvalidContent
});
}
const Cy = (n, e = !1, t = {}, r = {}) => ({ editor: o, tr: i, dispatch: s, commands: l }) => {
var a, c;
const { doc: p } = i;
if (t.preserveWhitespace !== "full") {
const u = ta(n, o.schema, t, {
errorOnInvalidContent: (a = r.errorOnInvalidContent) !== null && a !== void 0 ? a : o.options.enableContentCheck
});
return s && i.replaceWith(0, p.content.size, u).setMeta("preventUpdate", !e), !0;
}
return s && i.setMeta("preventUpdate", !e), l.insertContentAt({ from: 0, to: p.content.size }, n, {
parseOptions: t,
errorOnInvalidContent: (c = r.errorOnInvalidContent) !== null && c !== void 0 ? c : o.options.enableContentCheck
});
};
function bf(n, e) {
const t = qn(e, n.schema), { from: r, to: o, empty: i } = n.selection, s = [];
i ? (n.storedMarks && s.push(...n.storedMarks), s.push(...n.selection.$head.marks())) : n.doc.nodesBetween(r, o, (a) => {
s.push(...a.marks);
});
const l = s.find((a) => a.type.name === t.name);
return l ? { ...l.attrs } : {};
}
function My(n, e) {
const t = new ud(n);
return e.forEach((r) => {
r.steps.forEach((o) => {
t.step(o);
});
}), t;
}
function Ey(n) {
for (let e = 0; e < n.edgeCount; e += 1) {
const { type: t } = n.edge(e);
if (t.isTextblock && !t.hasRequiredAttrs())
return t;
}
return null;
}
function Ty(n, e, t) {
const r = [];
return n.nodesBetween(e.from, e.to, (o, i) => {
t(o) && r.push({
node: o,
pos: i
});
}), r;
}
function Oy(n, e) {
for (let t = n.depth; t > 0; t -= 1) {
const r = n.node(t);
if (e(r))
return {
pos: t > 0 ? n.before(t) : 0,
start: n.start(t),
depth: t,
node: r
};
}
}
function Ka(n) {
return (e) => Oy(e.$from, n);
}
function mf(n, e) {
const t = {
from: 0,
to: n.content.size
};
return pf(n, t, e);
}
function By(n, e) {
const t = De(e, n.schema), { from: r, to: o } = n.selection, i = [];
n.doc.nodesBetween(r, o, (l) => {
i.push(l);
});
const s = i.reverse().find((l) => l.type.name === t.name);
return s ? { ...s.attrs } : {};
}
function xf(n, e) {
const t = Us(typeof e == "string" ? e : e.name, n.schema);
return t === "node" ? By(n, e) : t === "mark" ? bf(n, e) : {};
}
function Py(n, e = JSON.stringify) {
const t = {};
return n.filter((r) => {
const o = e(r);
return Object.prototype.hasOwnProperty.call(t, o) ? !1 : t[o] = !0;
});
}
function Ay(n) {
const e = Py(n);
return e.length === 1 ? e : e.filter((t, r) => !e.filter((i, s) => s !== r).some((i) => t.oldRange.from >= i.oldRange.from && t.oldRange.to <= i.oldRange.to && t.newRange.from >= i.newRange.from && t.newRange.to <= i.newRange.to));
}
function _y(n) {
const { mapping: e, steps: t } = n, r = [];
return e.maps.forEach((o, i) => {
const s = [];
if (o.ranges.length)
o.forEach((l, a) => {
s.push({ from: l, to: a });
});
else {
const { from: l, to: a } = t[i];
if (l === void 0 || a === void 0)
return;
s.push({ from: l, to: a });
}
s.forEach(({ from: l, to: a }) => {
const c = e.slice(i).map(l, -1), p = e.slice(i).map(a), u = e.invert().map(c, -1), f = e.invert().map(p);
r.push({
oldRange: {
from: u,
to: f
},
newRange: {
from: c,
to: p
}
});
});
}), Ay(r);
}
function Ga(n, e, t) {
const r = [];
return n === e ? t.resolve(n).marks().forEach((o) => {
const i = t.resolve(n), s = Wa(i, o.type);
s && r.push({
mark: o,
...s
});
}) : t.nodesBetween(n, e, (o, i) => {
!o || (o == null ? void 0 : o.nodeSize) === void 0 || r.push(...o.marks.map((s) => ({
from: i,
to: i + o.nodeSize,
mark: s
})));
}), r;
}
function Ai(n, e, t) {
return Object.fromEntries(Object.entries(t).filter(([r]) => {
const o = n.find((i) => i.type === e && i.name === r);
return o ? o.attribute.keepOnSplit : !1;
}));
}
function na(n, e, t = {}) {
const { empty: r, ranges: o } = n.selection, i = e ? qn(e, n.schema) : null;
if (r)
return !!(n.storedMarks || n.selection.$from.marks()).filter((u) => i ? i.name === u.type.name : !0).find((u) => Zi(u.attrs, t, { strict: !1 }));
let s = 0;
const l = [];
if (o.forEach(({ $from: u, $to: f }) => {
const h = u.pos, b = f.pos;
n.doc.nodesBetween(h, b, (m, x) => {
if (!m.isText && !m.marks.length)
return;
const v = Math.max(h, x), C = Math.min(b, x + m.nodeSize), S = C - v;
s += S, l.push(...m.marks.map((g) => ({
mark: g,
from: v,
to: C
})));
});
}), s === 0)
return !1;
const a = l.filter((u) => i ? i.name === u.mark.type.name : !0).filter((u) => Zi(u.mark.attrs, t, { strict: !1 })).reduce((u, f) => u + f.to - f.from, 0), c = l.filter((u) => i ? u.mark.type !== i && u.mark.type.excludes(i) : !0).reduce((u, f) => u + f.to - f.from, 0);
return (a > 0 ? a + c : a) >= s;
}
function Ly(n, e, t = {}) {
if (!e)
return Vo(n, null, t) || na(n, null, t);
const r = Us(e, n.schema);
return r === "node" ? Vo(n, e, t) : r === "mark" ? na(n, e, t) : !1;
}
function Tp(n, e) {
const { nodeExtensions: t } = zs(e), r = t.find((s) => s.name === n);
if (!r)
return !1;
const o = {
name: r.name,
options: r.options,
storage: r.storage
}, i = oe(U(r, "group", o));
return typeof i != "string" ? !1 : i.split(" ").includes("list");
}
function Ja(n, { checkChildren: e = !0, ignoreWhitespace: t = !1 } = {}) {
var r;
if (t) {
if (n.type.name === "hardBreak")
return !0;
if (n.isText)
return /^\s*$/m.test((r = n.text) !== null && r !== void 0 ? r : "");
}
if (n.isText)
return !n.text;
if (n.isAtom || n.isLeaf)
return !1;
if (n.content.childCount === 0)
return !0;
if (e) {
let o = !0;
return n.content.forEach((i) => {
o !== !1 && (Ja(i, { ignoreWhitespace: t, checkChildren: e }) || (o = !1));
}), o;
}
return !1;
}
function gf(n) {
return n instanceof J;
}
function yf(n, e, t) {
const o = n.state.doc.content.size, i = ln(e, 0, o), s = ln(t, 0, o), l = n.coordsAtPos(i), a = n.coordsAtPos(s, -1), c = Math.min(l.top, a.top), p = Math.max(l.bottom, a.bottom), u = Math.min(l.left, a.left), f = Math.max(l.right, a.right), h = f - u, b = p - c, v = {
top: c,
bottom: p,
left: u,
right: f,
width: h,
height: b,
x: u,
y: c
};
return {
...v,
toJSON: () => v
};
}
function Ny(n, e, t) {
var r;
const { selection: o } = e;
let i = null;
if (Ua(o) && (i = o.$cursor), i) {
const l = (r = n.storedMarks) !== null && r !== void 0 ? r : i.marks();
return !!t.isInSet(l) || !l.some((a) => a.type.excludes(t));
}
const { ranges: s } = o;
return s.some(({ $from: l, $to: a }) => {
let c = l.depth === 0 ? n.doc.inlineContent && n.doc.type.allowsMarkType(t) : !1;
return n.doc.nodesBetween(l.pos, a.pos, (p, u, f) => {
if (c)
return !1;
if (p.isInline) {
const h = !f || f.type.allowsMarkType(t), b = !!t.isInSet(p.marks) || !p.marks.some((m) => m.type.excludes(t));
c = h && b;
}
return !c;
}), c;
});
}
const Dy = (n, e = {}) => ({ tr: t, state: r, dispatch: o }) => {
const { selection: i } = t, { empty: s, ranges: l } = i, a = qn(n, r.schema);
if (o)
if (s) {
const c = bf(r, a);
t.addStoredMark(a.create({
...c,
...e
}));
} else
l.forEach((c) => {
const p = c.$from.pos, u = c.$to.pos;
r.doc.nodesBetween(p, u, (f, h) => {
const b = Math.max(h, p), m = Math.min(h + f.nodeSize, u);
f.marks.find((v) => v.type === a) ? f.marks.forEach((v) => {
a === v.type && t.addMark(b, m, a.create({
...v.attrs,
...e
}));
}) : t.addMark(b, m, a.create(e));
});
});
return Ny(r, t, a);
}, Iy = (n, e) => ({ tr: t }) => (t.setMeta(n, e), !0), $y = (n, e = {}) => ({ state: t, dispatch: r, chain: o }) => {
const i = De(n, t.schema);
let s;
return t.selection.$anchor.sameParent(t.selection.$head) && (s = t.selection.$anchor.parent.attrs), i.isTextblock ? o().command(({ commands: l }) => wp(i, { ...s, ...e })(t) ? !0 : l.clearNodes()).command(({ state: l }) => wp(i, { ...s, ...e })(l, r)).run() : (console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'), !1);
}, Ry = (n) => ({ tr: e, dispatch: t }) => {
if (t) {
const { doc: r } = e, o = ln(n, 0, r.content.size), i = J.create(r, o);
e.setSelection(i);
}
return !0;
}, Fy = (n) => ({ tr: e, dispatch: t }) => {
if (t) {
const { doc: r } = e, { from: o, to: i } = typeof n == "number" ? { from: n, to: n } : n, s = Q.atStart(r).from, l = Q.atEnd(r).to, a = ln(o, s, l), c = ln(i, s, l), p = Q.create(r, a, c);
e.setSelection(p);
}
return !0;
}, Hy = (n) => ({ state: e, dispatch: t }) => {
const r = De(n, e.schema);
return gg(r)(e, t);
};
function Op(n, e) {
const t = n.storedMarks || n.selection.$to.parentOffset && n.selection.$from.marks();
if (t) {
const r = t.filter((o) => e == null ? void 0 : e.includes(o.type.name));
n.tr.ensureMarks(r);
}
}
const jy = ({ keepMarks: n = !0 } = {}) => ({ tr: e, state: t, dispatch: r, editor: o }) => {
const { selection: i, doc: s } = e, { $from: l, $to: a } = i, c = o.extensionManager.attributes, p = Ai(c, l.node().type.name, l.node().attrs);
if (i instanceof J && i.node.isBlock)
return !l.parentOffset || !an(s, l.pos) ? !1 : (r && (n && Op(t, o.extensionManager.splittableMarks), e.split(l.pos).scrollIntoView()), !0);
if (!l.parent.isBlock)
return !1;
const u = a.parentOffset === a.parent.content.size, f = l.depth === 0 ? void 0 : Ey(l.node(-1).contentMatchAt(l.indexAfter(-1)));
let h = u && f ? [
{
type: f,
attrs: p
}
] : void 0, b = an(e.doc, e.mapping.map(l.pos), 1, h);
if (!h && !b && an(e.doc, e.mapping.map(l.pos), 1, f ? [{ type: f }] : void 0) && (b = !0, h = f ? [
{
type: f,
attrs: p
}
] : void 0), r) {
if (b && (i instanceof Q && e.deleteSelection(), e.split(e.mapping.map(l.pos), 1, h), f && !u && !l.parentOffset && l.parent.type !== f)) {
const m = e.mapping.map(l.before()), x = e.doc.resolve(m);
l.node(-1).canReplaceWith(x.index(), x.index() + 1, f) && e.setNodeMarkup(e.mapping.map(l.before()), f);
}
n && Op(t, o.extensionManager.splittableMarks), e.scrollIntoView();
}
return b;
}, zy = (n, e = {}) => ({ tr: t, state: r, dispatch: o, editor: i }) => {
var s;
const l = De(n, r.schema), { $from: a, $to: c } = r.selection, p = r.selection.node;
if (p && p.isBlock || a.depth < 2 || !a.sameParent(c))
return !1;
const u = a.node(-1);
if (u.type !== l)
return !1;
const f = i.extensionManager.attributes;
if (a.parent.content.size === 0 && a.node(-1).childCount === a.indexAfter(-1)) {
if (a.depth === 2 || a.node(-3).type !== l || a.index(-2) !== a.node(-2).childCount - 1)
return !1;
if (o) {
let v = D.empty;
const C = a.index(-1) ? 1 : a.index(-2) ? 2 : 3;
for (let F = a.depth - C; F >= a.depth - 3; F -= 1)
v = D.from(a.node(F).copy(v));
const S = a.indexAfter(-1) < a.node(-2).childCount ? 1 : a.indexAfter(-2) < a.node(-3).childCount ? 2 : 3, g = {
...Ai(f, a.node().type.name, a.node().attrs),
...e
}, O = ((s = l.contentMatch.defaultType) === null || s === void 0 ? void 0 : s.createAndFill(g)) || void 0;
v = v.append(D.from(l.createAndFill(null, O) || void 0));
const T = a.before(a.depth - (C - 1));
t.replace(T, a.after(-S), new z(v, 4 - C, 0));
let B = -1;
t.doc.nodesBetween(T, t.doc.content.size, (F, W) => {
if (B > -1)
return !1;
F.isTextblock && F.content.size === 0 && (B = W + 1);
}), B > -1 && t.setSelection(Q.near(t.doc.resolve(B))), t.scrollIntoView();
}
return !0;
}
const h = c.pos === a.end() ? u.contentMatchAt(0).defaultType : null, b = {
...Ai(f, u.type.name, u.attrs),
...e
}, m = {
...Ai(f, a.node().type.name, a.node().attrs),
...e
};
t.delete(a.pos, c.pos);
const x = h ? [
{ type: l, attrs: b },
{ type: h, attrs: m }
] : [{ type: l, attrs: b }];
if (!an(t.doc, a.pos, 2))
return !1;
if (o) {
const { selection: v, storedMarks: C } = r, { splittableMarks: S } = i.extensionManager, g = C || v.$to.parentOffset && v.$from.marks();
if (t.split(a.pos, 2, x).scrollIntoView(), !g || !o)
return !0;
const O = g.filter((T) => S.includes(T.type.name));
t.ensureMarks(O);
}
return !0;
}, bl = (n, e) => {
const t = Ka((s) => s.type === e)(n.selection);
if (!t)
return !0;
const r = n.doc.resolve(Math.max(0, t.pos - 1)).before(t.depth);
if (r === void 0)
return !0;
const o = n.doc.nodeAt(r);
return t.node.type === (o == null ? void 0 : o.type) && Wn(n.doc, t.pos) && n.join(t.pos), !0;
}, ml = (n, e) => {
const t = Ka((s) => s.type === e)(n.selection);
if (!t)
return !0;
const r = n.doc.resolve(t.start).after(t.depth);
if (r === void 0)
return !0;
const o = n.doc.nodeAt(r);
return t.node.type === (o == null ? void 0 : o.type) && Wn(n.doc, r) && n.join(r), !0;
}, Vy = (n, e, t, r = {}) => ({ editor: o, tr: i, state: s, dispatch: l, chain: a, commands: c, can: p }) => {
const { extensions: u, splittableMarks: f } = o.extensionManager, h = De(n, s.schema), b = De(e, s.schema), { selection: m, storedMarks: x } = s, { $from: v, $to: C } = m, S = v.blockRange(C), g = x || m.$to.parentOffset && m.$from.marks();
if (!S)
return !1;
const O = Ka((T) => Tp(T.type.name, u))(m);
if (S.depth >= 1 && O && S.depth - O.depth <= 1) {
if (O.node.type === h)
return c.liftListItem(b);
if (Tp(O.node.type.name, u) && h.validContent(O.node.content) && l)
return a().command(() => (i.setNodeMarkup(O.pos, h), !0)).command(() => bl(i, h)).command(() => ml(i, h)).run();
}
return !t || !g || !l ? a().command(() => p().wrapInList(h, r) ? !0 : c.clearNodes()).wrapInList(h, r).command(() => bl(i, h)).command(() => ml(i, h)).run() : a().command(() => {
const T = p().wrapInList(h, r), B = g.filter((F) => f.includes(F.type.name));
return i.ensureMarks(B), T ? !0 : c.clearNodes();
}).wrapInList(h, r).command(() => bl(i, h)).command(() => ml(i, h)).run();
}, Wy = (n, e = {}, t = {}) => ({ state: r, commands: o }) => {
const { extendEmptyMarkRange: i = !1 } = t, s = qn(n, r.schema);
return na(r, s, e) ? o.unsetMark(s, { extendEmptyMarkRange: i }) : o.setMark(s, e);
}, Uy = (n, e, t = {}) => ({ state: r, commands: o }) => {
const i = De(n, r.schema), s = De(e, r.schema), l = Vo(r, i, t);
let a;
return r.selection.$anchor.sameParent(r.selection.$head) && (a = r.selection.$anchor.parent.attrs), l ? o.setNode(s, a) : o.setNode(i, { ...a, ...t });
}, qy = (n, e = {}) => ({ state: t, commands: r }) => {
const o = De(n, t.schema);
return Vo(t, o, e) ? r.lift(o) : r.wrapIn(o, e);
}, Ky = () => ({ state: n, dispatch: e }) => {
const t = n.plugins;
for (let r = 0; r < t.length; r += 1) {
const o = t[r];
let i;
if (o.spec.isInputRules && (i = o.getState(n))) {
if (e) {
const s = n.tr, l = i.transform;
for (let a = l.steps.length - 1; a >= 0; a -= 1)
s.step(l.steps[a].invert(l.docs[a]));
if (i.text) {
const a = s.doc.resolve(i.from).marks();
s.replaceWith(i.from, i.to, n.schema.text(i.text, a));
} else
s.delete(i.from, i.to);
}
return !0;
}
}
return !1;
}, Gy = () => ({ tr: n, dispatch: e }) => {
const { selection: t } = n, { empty: r, ranges: o } = t;
return r || e && o.forEach((i) => {
n.removeMark(i.$from.pos, i.$to.pos);
}), !0;
}, Jy = (n, e = {}) => ({ tr: t, state: r, dispatch: o }) => {
var i;
const { extendEmptyMarkRange: s = !1 } = e, { selection: l } = t, a = qn(n, r.schema), { $from: c, empty: p, ranges: u } = l;
if (!o)
return !0;
if (p && s) {
let { from: f, to: h } = l;
const b = (i = c.marks().find((x) => x.type === a)) === null || i === void 0 ? void 0 : i.attrs, m = Wa(c, a, b);
m && (f = m.from, h = m.to), t.removeMark(f, h, a);
} else
u.forEach((f) => {
t.removeMark(f.$from.pos, f.$to.pos, a);
});
return t.removeStoredMark(a), !0;
}, Yy = (n, e = {}) => ({ tr: t, state: r, dispatch: o }) => {
let i = null, s = null;
const l = Us(typeof n == "string" ? n : n.name, r.schema);
return l ? (l === "node" && (i = De(n, r.schema)), l === "mark" && (s = qn(n, r.schema)), o && t.selection.ranges.forEach((a) => {
const c = a.$from.pos, p = a.$to.pos;
let u, f, h, b;
t.selection.empty ? r.doc.nodesBetween(c, p, (m, x) => {
i && i === m.type && (h = Math.max(x, c), b = Math.min(x + m.nodeSize, p), u = x, f = m);
}) : r.doc.nodesBetween(c, p, (m, x) => {
x < c && i && i === m.type && (h = Math.max(x, c), b = Math.min(x + m.nodeSize, p), u = x, f = m), x >= c && x <= p && (i && i === m.type && t.setNodeMarkup(x, void 0, {
...m.attrs,
...e
}), s && m.marks.length && m.marks.forEach((v) => {
if (s === v.type) {
const C = Math.max(x, c), S = Math.min(x + m.nodeSize, p);
t.addMark(C, S, s.create({
...v.attrs,
...e
}));
}
}));
}), f && (u !== void 0 && t.setNodeMarkup(u, void 0, {
...f.attrs,
...e
}), s && f.marks.length && f.marks.forEach((m) => {
s === m.type && t.addMark(h, b, s.create({
...m.attrs,
...e
}));
}));
}), !0) : !1;
}, Xy = (n, e = {}) => ({ state: t, dispatch: r }) => {
const o = De(n, t.schema);
return ug(o, e)(t, r);
}, Qy = (n, e = {}) => ({ state: t, dispatch: r }) => {
const o = De(n, t.schema);
return dg(o, e)(t, r);
};
var Zy = /* @__PURE__ */ Object.freeze({
__proto__: null,
blur: Dg,
clearContent: Ig,
clearNodes: $g,
command: Rg,
createParagraphNear: Fg,
cut: Hg,
deleteCurrentNode: jg,
deleteNode: zg,
deleteRange: Vg,
deleteSelection: Wg,
enter: Ug,
exitCode: qg,
extendMarkRange: Kg,
first: Gg,
focus: Yg,
forEach: Xg,
insertContent: Qg,
insertContentAt: ty,
joinBackward: oy,
joinDown: ry,
joinForward: iy,
joinItemBackward: sy,
joinItemForward: ly,
joinTextblockBackward: ay,
joinTextblockForward: cy,
joinUp: ny,
keyboardShortcut: uy,
lift: dy,
liftEmptyBlock: fy,
liftListItem: hy,
newlineInCode: by,
resetAttributes: my,
scrollIntoView: xy,
selectAll: gy,
selectNodeBackward: yy,
selectNodeForward: vy,
selectParentNode: wy,
selectTextblockEnd: Sy,
selectTextblockStart: ky,
setContent: Cy,
setMark: Dy,
setMeta: Iy,
setNode: $y,
setNodeSelection: Ry,
setTextSelection: Fy,
sinkListItem: Hy,
splitBlock: jy,
splitListItem: zy,
toggleList: Vy,
toggleMark: Wy,
toggleNode: Uy,
toggleWrap: qy,
undoInputRule: Ky,
unsetAllMarks: Gy,
unsetMark: Jy,
updateAttributes: Yy,
wrapIn: Xy,
wrapInList: Qy
});
const e0 = je.create({
name: "commands",
addCommands() {
return {
...Zy
};
}
}), t0 = je.create({
name: "drop",
addProseMirrorPlugins() {
return [
new Oe({
key: new Ze("tiptapDrop"),
props: {
handleDrop: (n, e, t, r) => {
this.editor.emit("drop", {
editor: this.editor,
event: e,
slice: t,
moved: r
});
}
}
})
];
}
}), n0 = je.create({
name: "editable",
addProseMirrorPlugins() {
return [
new Oe({
key: new Ze("editable"),
props: {
editable: () => this.editor.options.editable
}
})
];
}
}), r0 = new Ze("focusEvents"), o0 = je.create({
name: "focusEvents",
addProseMirrorPlugins() {
const { editor: n } = this;
return [
new Oe({
key: r0,
props: {
handleDOMEvents: {
focus: (e, t) => {
n.isFocused = !0;
const r = n.state.tr.setMeta("focus", { event: t }).setMeta("addToHistory", !1);
return e.dispatch(r), !1;
},
blur: (e, t) => {
n.isFocused = !1;
const r = n.state.tr.setMeta("blur", { event: t }).setMeta("addToHistory", !1);
return e.dispatch(r), !1;
}
}
}
})
];
}
}), i0 = je.create({
name: "keymap",
addKeyboardShortcuts() {
const n = () => this.editor.commands.first(({ commands: s }) => [
() => s.undoInputRule(),
// maybe convert first text block node to default node
() => s.command(({ tr: l }) => {
const { selection: a, doc: c } = l, { empty: p, $anchor: u } = a, { pos: f, parent: h } = u, b = u.parent.isTextblock && f > 0 ? l.doc.resolve(f - 1) : u, m = b.parent.type.spec.isolating, x = u.pos - u.parentOffset, v = m && b.parent.childCount === 1 ? x === u.pos : te.atStart(c).from === f;
return !p || !h.type.isTextblock || h.textContent.length || !v || v && u.parent.type.name === "paragraph" ? !1 : s.clearNodes();
}),
() => s.deleteSelection(),
() => s.joinBackward(),
() => s.selectNodeBackward()
]), e = () => this.editor.commands.first(({ commands: s }) => [
() => s.deleteSelection(),
() => s.deleteCurrentNode(),
() => s.joinForward(),
() => s.selectNodeForward()
]), r = {
Enter: () => this.editor.commands.first(({ commands: s }) => [
() => s.newlineInCode(),
() => s.createParagraphNear(),
() => s.liftEmptyBlock(),
() => s.splitBlock()
]),
"Mod-Enter": () => this.editor.commands.exitCode(),
Backspace: n,
"Mod-Backspace": n,
"Shift-Backspace": n,
Delete: e,
"Mod-Delete": e,
"Mod-a": () => this.editor.commands.selectAll()
}, o = {
...r
}, i = {
...r,
"Ctrl-h": n,
"Alt-Backspace": n,
"Ctrl-d": e,
"Ctrl-Alt-Backspace": e,
"Alt-Delete": e,
"Alt-d": e,
"Ctrl-a": () => this.editor.commands.selectTextblockStart(),
"Ctrl-e": () => this.editor.commands.selectTextblockEnd()
};
return qa() || hf() ? i : o;
},
addProseMirrorPlugins() {
return [
// With this plugin we check if the whole document was selected and deleted.
// In this case we will additionally call `clearNodes()` to convert e.g. a heading
// to a paragraph if necessary.
// This is an alternative to ProseMirror's `AllSelection`, which doesn’t work well
// with many other commands.
new Oe({
key: new Ze("clearDocument"),
appendTransaction: (n, e, t) => {
if (n.some((m) => m.getMeta("composition")))
return;
const r = n.some((m) => m.docChanged) && !e.doc.eq(t.doc), o = n.some((m) => m.getMeta("preventClearDocument"));
if (!r || o)
return;
const { empty: i, from: s, to: l } = e.selection, a = te.atStart(e.doc).from, c = te.atEnd(e.doc).to;
if (i || !(s === a && l === c) || !Ja(t.doc))
return;
const f = t.tr, h = Hs({
state: t,
transaction: f
}), { commands: b } = new js({
editor: this.editor,
state: h
});
if (b.clearNodes(), !!f.steps.length)
return f;
}
})
];
}
}), s0 = je.create({
name: "paste",
addProseMirrorPlugins() {
return [
new Oe({
key: new Ze("tiptapPaste"),
props: {
handlePaste: (n, e, t) => {
this.editor.emit("paste", {
editor: this.editor,
event: e,
slice: t
});
}
}
})
];
}
}), l0 = je.create({
name: "tabindex",
addProseMirrorPlugins() {
return [
new Oe({
key: new Ze("tabindex"),
props: {
attributes: () => this.editor.isEditable ? { tabindex: "0" } : {}
}
})
];
}
});
class lr {
get name() {
return this.node.type.name;
}
constructor(e, t, r = !1, o = null) {
this.currentNode = null, this.actualDepth = null, this.isBlock = r, this.resolvedPos = e, this.editor = t, this.currentNode = o;
}
get node() {
return this.currentNode || this.resolvedPos.node();
}
get element() {
return this.editor.view.domAtPos(this.pos).node;
}
get depth() {
var e;
return (e = this.actualDepth) !== null && e !== void 0 ? e : this.resolvedPos.depth;
}
get pos() {
return this.resolvedPos.pos;
}
get content() {
return this.node.content;
}
set content(e) {
let t = this.from, r = this.to;
if (this.isBlock) {
if (this.content.size === 0) {
console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);
return;
}
t = this.from + 1, r = this.to - 1;
}
this.editor.commands.insertContentAt({ from: t, to: r }, e);
}
get attributes() {
return this.node.attrs;
}
get textContent() {
return this.node.textContent;
}
get size() {
return this.node.nodeSize;
}
get from() {
return this.isBlock ? this.pos : this.resolvedPos.start(this.resolvedPos.depth);
}
get range() {
return {
from: this.from,
to: this.to
};
}
get to() {
return this.isBlock ? this.pos + this.size : this.resolvedPos.end(this.resolvedPos.depth) + (this.node.isText ? 0 : 1);
}
get parent() {
if (this.depth === 0)
return null;
const e = this.resolvedPos.start(this.resolvedPos.depth - 1), t = this.resolvedPos.doc.resolve(e);
return new lr(t, this.editor);
}
get before() {
let e = this.resolvedPos.doc.resolve(this.from - (this.isBlock ? 1 : 2));
return e.depth !== this.depth && (e = this.resolvedPos.doc.resolve(this.from - 3)), new lr(e, this.editor);
}
get after() {
let e = this.resolvedPos.doc.resolve(this.to + (this.isBlock ? 2 : 1));
return e.depth !== this.depth && (e = this.resolvedPos.doc.resolve(this.to + 3)), new lr(e, this.editor);
}
get children() {
const e = [];
return this.node.content.forEach((t, r) => {
const o = t.isBlock && !t.isTextblock, i = t.isAtom && !t.isText, s = this.pos + r + (i ? 0 : 1);
if (s < 0 || s > this.resolvedPos.doc.nodeSize - 2)
return;
const l = this.resolvedPos.doc.resolve(s);
if (!o && l.depth <= this.depth)
return;
const a = new lr(l, this.editor, o, o ? t : null);
o && (a.actualDepth = this.depth + 1), e.push(new lr(l, this.editor, o, o ? t : null));
}), e;
}
get firstChild() {
return this.children[0] || null;
}
get lastChild() {
const e = this.children;
return e[e.length - 1] || null;
}
closest(e, t = {}) {
let r = null, o = this.parent;
for (; o && !r; ) {
if (o.node.type.name === e)
if (Object.keys(t).length > 0) {
const i = o.node.attrs, s = Object.keys(t);
for (let l = 0; l < s.length; l += 1) {
const a = s[l];
if (i[a] !== t[a])
break;
}
} else
r = o;
o = o.parent;
}
return r;
}
querySelector(e, t = {}) {
return this.querySelectorAll(e, t, !0)[0] || null;
}
querySelectorAll(e, t = {}, r = !1) {
let o = [];
if (!this.children || this.children.length === 0)
return o;
const i = Object.keys(t);
return this.children.forEach((s) => {
r && o.length > 0 || (s.node.type.name === e && i.every((a) => t[a] === s.node.attrs[a]) && o.push(s), !(r && o.length > 0) && (o = o.concat(s.querySelectorAll(e, t, r))));
}), o;
}
setAttribute(e) {
const { tr: t } = this.editor.state;
t.setNodeMarkup(this.from, void 0, {
...this.node.attrs,
...e
}), this.editor.view.dispatch(t);
}
}
const a0 = `.ProseMirror {
position: relative;
}
.ProseMirror {
word-wrap: break-word;
white-space: pre-wrap;
white-space: break-spaces;
-webkit-font-variant-ligatures: none;
font-variant-ligatures: none;
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
}
.ProseMirror [contenteditable="false"] {
white-space: normal;
}
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
white-space: pre-wrap;
}
.ProseMirror pre {
white-space: pre-wrap;
}
img.ProseMirror-separator {
display: inline !important;
border: none !important;
margin: 0 !important;
width: 0 !important;
height: 0 !important;
}
.ProseMirror-gapcursor {
display: none;
pointer-events: none;
position: absolute;
margin: 0;
}
.ProseMirror-gapcursor:after {
content: "";
display: block;
position: absolute;
top: -2px;
width: 20px;
border-top: 1px solid black;
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}
@keyframes ProseMirror-cursor-blink {
to {
visibility: hidden;
}
}
.ProseMirror-hideselection *::selection {
background: transparent;
}
.ProseMirror-hideselection *::-moz-selection {
background: transparent;
}
.ProseMirror-hideselection * {
caret-color: transparent;
}
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}
.tippy-box[data-animation=fade][data-state=hidden] {
opacity: 0
}`;
function c0(n, e, t) {
const r = document.querySelector("style[data-tiptap-style]");
if (r !== null)
return r;
const o = document.createElement("style");
return e && o.setAttribute("nonce", e), o.setAttribute("data-tiptap-style", ""), o.innerHTML = n, document.getElementsByTagName("head")[0].appendChild(o), o;
}
let p0 = class extends yg {
constructor(e = {}) {
super(), this.isFocused = !1, this.isInitialized = !1, this.extensionStorage = {}, this.options = {
element: document.createElement("div"),
content: "",
injectCSS: !0,
injectNonce: void 0,
extensions: [],
autofocus: !1,
editable: !0,
editorProps: {},
parseOptions: {},
coreExtensionOptions: {},
enableInputRules: !0,
enablePasteRules: !0,
enableCoreExtensions: !0,
enableContentCheck: !1,
emitContentError: !1,
onBeforeCreate: () => null,
onCreate: () => null,
onUpdate: () => null,
onSelectionUpdate: () => null,
onTransaction: () => null,
onFocus: () => null,
onBlur: () => null,
onDestroy: () => null,
onContentError: ({ error: t }) => {
throw t;
},
onPaste: () => null,
onDrop: () => null
}, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.setOptions(e), this.createExtensionManager(), this.createCommandManager(), this.createSchema(), this.on("beforeCreate", this.options.onBeforeCreate), this.emit("beforeCreate", { editor: this }), this.on("contentError", this.options.onContentError), this.createView(), this.injectCSS(), this.on("create", this.options.onCreate), this.on("update", this.options.onUpdate), this.on("selectionUpdate", this.options.onSelectionUpdate), this.on("transaction", this.options.onTransaction), this.on("focus", this.options.onFocus), this.on("blur", this.options.onBlur), this.on("destroy", this.options.onDestroy), this.on("drop", ({ event: t, slice: r, moved: o }) => this.options.onDrop(t, r, o)), this.on("paste", ({ event: t, slice: r }) => this.options.onPaste(t, r)), window.setTimeout(() => {
this.isDestroyed || (this.commands.focus(this.options.autofocus), this.emit("create", { editor: this }), this.isInitialized = !0);
}, 0);
}
/**
* Returns the editor storage.
*/
get storage() {
return this.extensionStorage;
}
/**
* An object of all registered commands.
*/
get commands() {
return this.commandManager.commands;
}
/**
* Create a command chain to call multiple commands at once.
*/
chain() {
return this.commandManager.chain();
}
/**
* Check if a command or a command chain can be executed. Without executing it.
*/
can() {
return this.commandManager.can();
}
/**
* Inject CSS styles.
*/
injectCSS() {
this.options.injectCSS && document && (this.css = c0(a0, this.options.injectNonce));
}
/**
* Update editor options.
*
* @param options A list of options
*/
setOptions(e = {}) {
this.options = {
...this.options,
...e
}, !(!this.view || !this.state || this.isDestroyed) && (this.options.editorProps && this.view.setProps(this.options.editorProps), this.view.updateState(this.state));
}
/**
* Update editable state of the editor.
*/
setEditable(e, t = !0) {
this.setOptions({ editable: e }), t && this.emit("update", { editor: this, transaction: this.state.tr });
}
/**
* Returns whether the editor is editable.
*/
get isEditable() {
return this.options.editable && this.view && this.view.editable;
}
/**
* Returns the editor state.
*/
get state() {
return this.view.state;
}
/**
* Register a ProseMirror plugin.
*
* @param plugin A ProseMirror plugin
* @param handlePlugins Control how to merge the plugin into the existing plugins.
* @returns The new editor state
*/
registerPlugin(e, t) {
const r = cf(t) ? t(e, [...this.state.plugins]) : [...this.state.plugins, e], o = this.state.reconfigure({ plugins: r });
return this.view.updateState(o), o;
}
/**
* Unregister a ProseMirror plugin.
*
* @param nameOrPluginKeyToRemove The plugins name
* @returns The new editor state or undefined if the editor is destroyed
*/
unregisterPlugin(e) {
if (this.isDestroyed)
return;
const t = this.state.plugins;
let r = t;
if ([].concat(e).forEach((i) => {
const s = typeof i == "string" ? `${i}$` : i.key;
r = r.filter((l) => !l.key.startsWith(s));
}), t.length === r.length)
return;
const o = this.state.reconfigure({
plugins: r
});
return this.view.updateState(o), o;
}
/**
* Creates an extension manager.
*/
createExtensionManager() {
var e, t;
const o = [...this.options.enableCoreExtensions ? [
n0,
Ng.configure({
blockSeparator: (t = (e = this.options.coreExtensionOptions) === null || e === void 0 ? void 0 : e.clipboardTextSerializer) === null || t === void 0 ? void 0 : t.blockSeparator
}),
e0,
o0,
i0,
l0,
t0,
s0
].filter((i) => typeof this.options.enableCoreExtensions == "object" ? this.options.enableCoreExtensions[i.name] !== !1 : !0) : [], ...this.options.extensions].filter((i) => ["extension", "node", "mark"].includes(i == null ? void 0 : i.type));
this.extensionManager = new jr(o, this);
}
/**
* Creates an command manager.
*/
createCommandManager() {
this.commandManager = new js({
editor: this
});
}
/**
* Creates a ProseMirror schema.
*/
createSchema() {
this.schema = this.extensionManager.schema;
}
/**
* Creates a ProseMirror view.
*/
createView() {
var e;
let t;
try {
t = ta(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
} catch (s) {
if (!(s instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(s.message))
throw s;
this.emit("contentError", {
editor: this,
error: s,
disableCollaboration: () => {
this.storage.collaboration && (this.storage.collaboration.isDisabled = !0), this.options.extensions = this.options.extensions.filter((l) => l.name !== "collaboration"), this.createExtensionManager();
}
}), t = ta(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: !1 });
}
const r = df(t, this.options.autofocus);
this.view = new Kd(this.options.element, {
...this.options.editorProps,
attributes: {
// add `role="textbox"` to the editor element
role: "textbox",
...(e = this.options.editorProps) === null || e === void 0 ? void 0 : e.attributes
},
dispatchTransaction: this.dispatchTransaction.bind(this),
state: Hr.create({
doc: t,
selection: r || void 0
})
});
const o = this.state.reconfigure({
plugins: this.extensionManager.plugins
});
this.view.updateState(o), this.createNodeViews(), this.prependClass();
const i = this.view.dom;
i.editor = this;
}
/**
* Creates all node views.
*/
createNodeViews() {
this.view.isDestroyed || this.view.setProps({
nodeViews: this.extensionManager.nodeViews
});
}
/**
* Prepend class name to element.
*/
prependClass() {
this.view.dom.className = `tiptap ${this.view.dom.className}`;
}
captureTransaction(e) {
this.isCapturingTransaction = !0, e(), this.isCapturingTransaction = !1;
const t = this.capturedTransaction;
return this.capturedTransaction = null, t;
}
/**
* The callback over which to send transactions (state updates) produced by the view.
*
* @param transaction An editor state transaction
*/
dispatchTransaction(e) {
if (this.view.isDestroyed)
return;
if (this.isCapturingTransaction) {
if (!this.capturedTransaction) {
this.capturedTransaction = e;
return;
}
e.steps.forEach((s) => {
var l;
return (l = this.capturedTransaction) === null || l === void 0 ? void 0 : l.step(s);
});
return;
}
const t = this.state.apply(e), r = !this.state.selection.eq(t.selection);
this.emit("beforeTransaction", {
editor: this,
transaction: e,
nextState: t
}), this.view.updateState(t), this.emit("transaction", {
editor: this,
transaction: e
}), r && this.emit("selectionUpdate", {
editor: this,
transaction: e
});
const o = e.getMeta("focus"), i = e.getMeta("blur");
o && this.emit("focus", {
editor: this,
event: o.event,
transaction: e
}), i && this.emit("blur", {
editor: this,
event: i.event,
transaction: e
}), !(!e.docChanged || e.getMeta("preventUpdate")) && this.emit("update", {
editor: this,
transaction: e
});
}
/**
* Get attributes of the currently selected node or mark.
*/
getAttributes(e) {
return xf(this.state, e);
}
isActive(e, t) {
const r = typeof e == "string" ? e : null, o = typeof e == "string" ? t : e;
return Ly(this.state, r, o);
}
/**
* Get the document as JSON.
*/
getJSON() {
return this.state.doc.toJSON();
}
/**
* Get the document as HTML.
*/
getHTML() {
return ja(this.state.doc.content, this.schema);
}
/**
* Get the document as text.
*/
getText(e) {
const { blockSeparator: t = `
`, textSerializers: r = {} } = e || {};
return mf(this.state.doc, {
blockSeparator: t,
textSerializers: {
...Va(this.schema),
...r
}
});
}
/**
* Check if there is no content.
*/
get isEmpty() {
return Ja(this.state.doc);
}
/**
* Get the number of characters for the current document.
*
* @deprecated
*/
getCharacterCount() {
return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'), this.state.doc.content.size - 2;
}
/**
* Destroy the editor.
*/
destroy() {
if (this.emit("destroy"), this.view) {
const e = this.view.dom;
e && e.editor && delete e.editor, this.view.destroy();
}
this.removeAllListeners();
}
/**
* Check if the editor is already destroyed.
*/
get isDestroyed() {
var e;
return !(!((e = this.view) === null || e === void 0) && e.docView);
}
$node(e, t) {
var r;
return ((r = this.$doc) === null || r === void 0 ? void 0 : r.querySelector(e, t)) || null;
}
$nodes(e, t) {
var r;
return ((r = this.$doc) === null || r === void 0 ? void 0 : r.querySelectorAll(e, t)) || null;
}
$pos(e) {
const t = this.state.doc.resolve(e);
return new lr(t, this);
}
get $doc() {
return this.$pos(0);
}
};
function Xr(n) {
return new Vs({
find: n.find,
handler: ({ state: e, range: t, match: r }) => {
const o = oe(n.getAttributes, void 0, r);
if (o === !1 || o === null)
return null;
const { tr: i } = e, s = r[r.length - 1], l = r[0];
if (s) {
const a = l.search(/\S/), c = t.from + l.indexOf(s), p = c + s.length;
if (Ga(t.from, t.to, e.doc).filter((h) => h.mark.type.excluded.find((m) => m === n.type && m !== h.mark.type)).filter((h) => h.to > c).length)
return null;
p < t.to && i.delete(p, t.to), c > t.from && i.delete(t.from + a, c);
const f = t.from + a + s.length;
i.addMark(t.from + a, f, n.type.create(o || {})), i.removeStoredMark(n.type);
}
}
});
}
function u0(n) {
return new Vs({
find: n.find,
handler: ({ state: e, range: t, match: r }) => {
const o = oe(n.getAttributes, void 0, r) || {}, { tr: i } = e, s = t.from;
let l = t.to;
const a = n.type.create(o);
if (r[1]) {
const c = r[0].lastIndexOf(r[1]);
let p = s + c;
p > l ? p = l : l = p + r[1].length;
const u = r[0][r[0].length - 1];
i.insertText(u, s + r[0].length - 1), i.replaceWith(p, l, a);
} else if (r[0]) {
const c = n.type.isInline ? s : s - 1;
i.insert(c, n.type.create(o)).delete(i.mapping.map(s), i.mapping.map(l));
}
i.scrollIntoView();
}
});
}
function ra(n) {
return new Vs({
find: n.find,
handler: ({ state: e, range: t, match: r }) => {
const o = e.doc.resolve(t.from), i = oe(n.getAttributes, void 0, r) || {};
if (!o.node(-1).canReplaceWith(o.index(-1), o.indexAfter(-1), n.type))
return null;
e.tr.delete(t.from, t.to).setBlockType(t.from, t.from, n.type, i);
}
});
}
function Wo(n) {
return new Vs({
find: n.find,
handler: ({ state: e, range: t, match: r, chain: o }) => {
const i = oe(n.getAttributes, void 0, r) || {}, s = e.tr.delete(t.from, t.to), a = s.doc.resolve(t.from).blockRange(), c = a && Ma(a, n.type, i);
if (!c)
return null;
if (s.wrap(a, c), n.keepMarks && n.editor) {
const { selection: u, storedMarks: f } = e, { splittableMarks: h } = n.editor.extensionManager, b = f || u.$to.parentOffset && u.$from.marks();
if (b) {
const m = b.filter((x) => h.includes(x.type.name));
s.ensureMarks(m);
}
}
if (n.keepAttributes) {
const u = n.type.name === "bulletList" || n.type.name === "orderedList" ? "listItem" : "taskList";
o().updateAttributes(u, i).run();
}
const p = s.doc.resolve(t.from - 1).nodeBefore;
p && p.type === n.type && Wn(s.doc, t.from - 1) && (!n.joinPredicate || n.joinPredicate(r, p)) && s.join(t.from - 1);
}
});
}
let Dt = class oa {
constructor(e = {}) {
this.type = "node", this.name = "node", this.parent = null, this.child = null, this.config = {
name: this.name,
defaultOptions: {}
}, this.config = {
...this.config,
...e
}, this.name = this.config.name, e.defaultOptions && Object.keys(e.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`), this.options = this.config.defaultOptions, this.config.addOptions && (this.options = oe(U(this, "addOptions", {
name: this.name
}))), this.storage = oe(U(this, "addStorage", {
name: this.name,
options: this.options
})) || {};
}
static create(e = {}) {
return new oa(e);
}
configure(e = {}) {
const t = this.extend({
...this.config,
addOptions: () => Ws(this.options, e)
});
return t.name = this.name, t.parent = this.parent, t;
}
extend(e = {}) {
const t = new oa(e);
return t.parent = this, this.child = t, t.name = e.name ? e.name : t.parent.name, e.defaultOptions && Object.keys(e.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`), t.options = oe(U(t, "addOptions", {
name: t.name
})), t.storage = oe(U(t, "addStorage", {
name: t.name,
options: t.options
})), t;
}
};
function Cr(n) {
return new Og({
find: n.find,
handler: ({ state: e, range: t, match: r, pasteEvent: o }) => {
const i = oe(n.getAttributes, void 0, r, o);
if (i === !1 || i === null)
return null;
const { tr: s } = e, l = r[r.length - 1], a = r[0];
let c = t.to;
if (l) {
const p = a.search(/\S/), u = t.from + a.indexOf(l), f = u + l.length;
if (Ga(t.from, t.to, e.doc).filter((b) => b.mark.type.excluded.find((x) => x === n.type && x !== b.mark.type)).filter((b) => b.to > u).length)
return null;
f < t.to && s.delete(f, t.to), u > t.from && s.delete(t.from + p, u), c = t.from + p + l.length, s.addMark(t.from + p, c, n.type.create(i || {})), s.removeStoredMark(n.type);
}
}
});
}
function d0(n, e) {
const { selection: t } = n, { $from: r } = t;
if (t instanceof J) {
const i = r.index();
return r.parent.canReplaceWith(i, i + 1, e);
}
let o = r.depth;
for (; o >= 0; ) {
const i = r.index(o);
if (r.node(o).contentMatchAt(i).matchType(e))
return !0;
o -= 1;
}
return !1;
}
var rt = "top", kt = "bottom", Ct = "right", ot = "left", Ya = "auto", ni = [rt, kt, Ct, ot], Qr = "start", Uo = "end", f0 = "clippingParents", vf = "viewport", uo = "popper", h0 = "reference", Bp = /* @__PURE__ */ ni.reduce(function(n, e) {
return n.concat([e + "-" + Qr, e + "-" + Uo]);
}, []), wf = /* @__PURE__ */ [].concat(ni, [Ya]).reduce(function(n, e) {
return n.concat([e, e + "-" + Qr, e + "-" + Uo]);
}, []), b0 = "beforeRead", m0 = "read", x0 = "afterRead", g0 = "beforeMain", y0 = "main", v0 = "afterMain", w0 = "beforeWrite", S0 = "write", k0 = "afterWrite", C0 = [b0, m0, x0, g0, y0, v0, w0, S0, k0];
function Gt(n) {
return n ? (n.nodeName || "").toLowerCase() : null;
}
function pt(n) {
if (n == null)
return window;
if (n.toString() !== "[object Window]") {
var e = n.ownerDocument;
return e && e.defaultView || window;
}
return n;
}
function Mr(n) {
var e = pt(n).Element;
return n instanceof e || n instanceof Element;
}
function St(n) {
var e = pt(n).HTMLElement;
return n instanceof e || n instanceof HTMLElement;
}
function Xa(n) {
if (typeof ShadowRoot > "u")
return !1;
var e = pt(n).ShadowRoot;
return n instanceof e || n instanceof ShadowRoot;
}
function M0(n) {
var e = n.state;
Object.keys(e.elements).forEach(function(t) {
var r = e.styles[t] || {}, o = e.attributes[t] || {}, i = e.elements[t];
!St(i) || !Gt(i) || (Object.assign(i.style, r), Object.keys(o).forEach(function(s) {
var l = o[s];
l === !1 ? i.removeAttribute(s) : i.setAttribute(s, l === !0 ? "" : l);
}));
});
}
function E0(n) {
var e = n.state, t = {
popper: {
position: e.options.strategy,
left: "0",
top: "0",
margin: "0"
},
arrow: {
position: "absolute"
},
reference: {}
};
return Object.assign(e.elements.popper.style, t.popper), e.styles = t, e.elements.arrow && Object.assign(e.elements.arrow.style, t.arrow), function() {
Object.keys(e.elements).forEach(function(r) {
var o = e.elements[r], i = e.attributes[r] || {}, s = Object.keys(e.styles.hasOwnProperty(r) ? e.styles[r] : t[r]), l = s.reduce(function(a, c) {
return a[c] = "", a;
}, {});
!St(o) || !Gt(o) || (Object.assign(o.style, l), Object.keys(i).forEach(function(a) {
o.removeAttribute(a);
}));
});
};
}
const Sf = {
name: "applyStyles",
enabled: !0,
phase: "write",
fn: M0,
effect: E0,
requires: ["computeStyles"]
};
function Wt(n) {
return n.split("-")[0];
}
var mr = Math.max, es = Math.min, Zr = Math.round;
function ia() {
var n = navigator.userAgentData;
return n != null && n.brands && Array.isArray(n.brands) ? n.brands.map(function(e) {
return e.brand + "/" + e.version;
}).join(" ") : navigator.userAgent;
}
function kf() {
return !/^((?!chrome|android).)*safari/i.test(ia());
}
function eo(n, e, t) {
e === void 0 && (e = !1), t === void 0 && (t = !1);
var r = n.getBoundingClientRect(), o = 1, i = 1;
e && St(n) && (o = n.offsetWidth > 0 && Zr(r.width) / n.offsetWidth || 1, i = n.offsetHeight > 0 && Zr(r.height) / n.offsetHeight || 1);
var s = Mr(n) ? pt(n) : window, l = s.visualViewport, a = !kf() && t, c = (r.left + (a && l ? l.offsetLeft : 0)) / o, p = (r.top + (a && l ? l.offsetTop : 0)) / i, u = r.width / o, f = r.height / i;
return {
width: u,
height: f,
top: p,
right: c + u,
bottom: p + f,
left: c,
x: c,
y: p
};
}
function Qa(n) {
var e = eo(n), t = n.offsetWidth, r = n.offsetHeight;
return Math.abs(e.width - t) <= 1 && (t = e.width), Math.abs(e.height - r) <= 1 && (r = e.height), {
x: n.offsetLeft,
y: n.offsetTop,
width: t,
height: r
};
}
function Cf(n, e) {
var t = e.getRootNode && e.getRootNode();
if (n.contains(e))
return !0;
if (t && Xa(t)) {
var r = e;
do {
if (r && n.isSameNode(r))
return !0;
r = r.parentNode || r.host;
} while (r);
}
return !1;
}
function dn(n) {
return pt(n).getComputedStyle(n);
}
function T0(n) {
return ["table", "td", "th"].indexOf(Gt(n)) >= 0;
}
function Kn(n) {
return ((Mr(n) ? n.ownerDocument : (
// $FlowFixMe[prop-missing]
n.document
)) || window.document).documentElement;
}
function qs(n) {
return Gt(n) === "html" ? n : (
// this is a quicker (but less type safe) way to save quite some bytes from the bundle
// $FlowFixMe[incompatible-return]
// $FlowFixMe[prop-missing]
n.assignedSlot || // step into the shadow DOM of the parent of a slotted node
n.parentNode || // DOM Element detected
(Xa(n) ? n.host : null) || // ShadowRoot detected
// $FlowFixMe[incompatible-call]: HTMLElement is a Node
Kn(n)
);
}
function Pp(n) {
return !St(n) || // https://github.com/popperjs/popper-core/issues/837
dn(n).position === "fixed" ? null : n.offsetParent;
}
function O0(n) {
var e = /firefox/i.test(ia()), t = /Trident/i.test(ia());
if (t && St(n)) {
var r = dn(n);
if (r.position === "fixed")
return null;
}
var o = qs(n);
for (Xa(o) && (o = o.host); St(o) && ["html", "body"].indexOf(Gt(o)) < 0; ) {
var i = dn(o);
if (i.transform !== "none" || i.perspective !== "none" || i.contain === "paint" || ["transform", "perspective"].indexOf(i.willChange) !== -1 || e && i.willChange === "filter" || e && i.filter && i.filter !== "none")
return o;
o = o.parentNode;
}
return null;
}
function ri(n) {
for (var e = pt(n), t = Pp(n); t && T0(t) && dn(t).position === "static"; )
t = Pp(t);
return t && (Gt(t) === "html" || Gt(t) === "body" && dn(t).position === "static") ? e : t || O0(n) || e;
}
function Za(n) {
return ["top", "bottom"].indexOf(n) >= 0 ? "x" : "y";
}
function Mo(n, e, t) {
return mr(n, es(e, t));
}
function B0(n, e, t) {
var r = Mo(n, e, t);
return r > t ? t : r;
}
function Mf() {
return {
top: 0,
right: 0,
bottom: 0,
left: 0
};
}
function Ef(n) {
return Object.assign({}, Mf(), n);
}
function Tf(n, e) {
return e.reduce(function(t, r) {
return t[r] = n, t;
}, {});
}
var P0 = function(e, t) {
return e = typeof e == "function" ? e(Object.assign({}, t.rects, {
placement: t.placement
})) : e, Ef(typeof e != "number" ? e : Tf(e, ni));
};
function A0(n) {
var e, t = n.state, r = n.name, o = n.options, i = t.elements.arrow, s = t.modifiersData.popperOffsets, l = Wt(t.placement), a = Za(l), c = [ot, Ct].indexOf(l) >= 0, p = c ? "height" : "width";
if (!(!i || !s)) {
var u = P0(o.padding, t), f = Qa(i), h = a === "y" ? rt : ot, b = a === "y" ? kt : Ct, m = t.rects.reference[p] + t.rects.reference[a] - s[a] - t.rects.popper[p], x = s[a] - t.rects.reference[a], v = ri(i), C = v ? a === "y" ? v.clientHeight || 0 : v.clientWidth || 0 : 0, S = m / 2 - x / 2, g = u[h], O = C - f[p] - u[b], T = C / 2 - f[p] / 2 + S, B = Mo(g, T, O), F = a;
t.modifiersData[r] = (e = {}, e[F] = B, e.centerOffset = B - T, e);
}
}
function _0(n) {
var e = n.state, t = n.options, r = t.element, o = r === void 0 ? "[data-popper-arrow]" : r;
o != null && (typeof o == "string" && (o = e.elements.popper.querySelector(o), !o) || Cf(e.elements.popper, o) && (e.elements.arrow = o));
}
const L0 = {
name: "arrow",
enabled: !0,
phase: "main",
fn: A0,
effect: _0,
requires: ["popperOffsets"],
requiresIfExists: ["preventOverflow"]
};
function to(n) {
return n.split("-")[1];
}
var N0 = {
top: "auto",
right: "auto",
bottom: "auto",
left: "auto"
};
function D0(n, e) {
var t = n.x, r = n.y, o = e.devicePixelRatio || 1;
return {
x: Zr(t * o) / o || 0,
y: Zr(r * o) / o || 0
};
}
function Ap(n) {
var e, t = n.popper, r = n.popperRect, o = n.placement, i = n.variation, s = n.offsets, l = n.position, a = n.gpuAcceleration, c = n.adaptive, p = n.roundOffsets, u = n.isFixed, f = s.x, h = f === void 0 ? 0 : f, b = s.y, m = b === void 0 ? 0 : b, x = typeof p == "function" ? p({
x: h,
y: m
}) : {
x: h,
y: m
};
h = x.x, m = x.y;
var v = s.hasOwnProperty("x"), C = s.hasOwnProperty("y"), S = ot, g = rt, O = window;
if (c) {
var T = ri(t), B = "clientHeight", F = "clientWidth";
if (T === pt(t) && (T = Kn(t), dn(T).position !== "static" && l === "absolute" && (B = "scrollHeight", F = "scrollWidth")), T = T, o === rt || (o === ot || o === Ct) && i === Uo) {
g = kt;
var W = u && T === O && O.visualViewport ? O.visualViewport.height : (
// $FlowFixMe[prop-missing]
T[B]
);
m -= W - r.height, m *= a ? 1 : -1;
}
if (o === ot || (o === rt || o === kt) && i === Uo) {
S = Ct;
var L = u && T === O && O.visualViewport ? O.visualViewport.width : (
// $FlowFixMe[prop-missing]
T[F]
);
h -= L - r.width, h *= a ? 1 : -1;
}
}
var N = Object.assign({
position: l
}, c && N0), $ = p === !0 ? D0({
x: h,
y: m
}, pt(t)) : {
x: h,
y: m
};
if (h = $.x, m = $.y, a) {
var K;
return Object.assign({}, N, (K = {}, K[g] = C ? "0" : "", K[S] = v ? "0" : "", K.transform = (O.devicePixelRatio || 1) <= 1 ? "translate(" + h + "px, " + m + "px)" : "translate3d(" + h + "px, " + m + "px, 0)", K));
}
return Object.assign({}, N, (e = {}, e[g] = C ? m + "px" : "", e[S] = v ? h + "px" : "", e.transform = "", e));
}
function I0(n) {
var e = n.state, t = n.options, r = t.gpuAcceleration, o = r === void 0 ? !0 : r, i = t.adaptive, s = i === void 0 ? !0 : i, l = t.roundOffsets, a = l === void 0 ? !0 : l, c = {
placement: Wt(e.placement),
variation: to(e.placement),
popper: e.elements.popper,
popperRect: e.rects.popper,
gpuAcceleration: o,
isFixed: e.options.strategy === "fixed"
};
e.modifiersData.popperOffsets != null && (e.styles.popper = Object.assign({}, e.styles.popper, Ap(Object.assign({}, c, {
offsets: e.modifiersData.popperOffsets,
position: e.options.strategy,
adaptive: s,
roundOffsets: a
})))), e.modifiersData.arrow != null && (e.styles.arrow = Object.assign({}, e.styles.arrow, Ap(Object.assign({}, c, {
offsets: e.modifiersData.arrow,
position: "absolute",
adaptive: !1,
roundOffsets: a
})))), e.attributes.popper = Object.assign({}, e.attributes.popper, {
"data-popper-placement": e.placement
});
}
const $0 = {
name: "computeStyles",
enabled: !0,
phase: "beforeWrite",
fn: I0,
data: {}
};
var wi = {
passive: !0
};
function R0(n) {
var e = n.state, t = n.instance, r = n.options, o = r.scroll, i = o === void 0 ? !0 : o, s = r.resize, l = s === void 0 ? !0 : s, a = pt(e.elements.popper), c = [].concat(e.scrollParents.reference, e.scrollParents.popper);
return i && c.forEach(function(p) {
p.addEventListener("scroll", t.update, wi);
}), l && a.addEventListener("resize", t.update, wi), function() {
i && c.forEach(function(p) {
p.removeEventListener("scroll", t.update, wi);
}), l && a.removeEventListener("resize", t.update, wi);
};
}
const F0 = {
name: "eventListeners",
enabled: !0,
phase: "write",
fn: function() {
},
effect: R0,
data: {}
};
var H0 = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
};
function _i(n) {
return n.replace(/left|right|bottom|top/g, function(e) {
return H0[e];
});
}
var j0 = {
start: "end",
end: "start"
};
function _p(n) {
return n.replace(/start|end/g, function(e) {
return j0[e];
});
}
function ec(n) {
var e = pt(n), t = e.pageXOffset, r = e.pageYOffset;
return {
scrollLeft: t,
scrollTop: r
};
}
function tc(n) {
return eo(Kn(n)).left + ec(n).scrollLeft;
}
function z0(n, e) {
var t = pt(n), r = Kn(n), o = t.visualViewport, i = r.clientWidth, s = r.clientHeight, l = 0, a = 0;
if (o) {
i = o.width, s = o.height;
var c = kf();
(c || !c && e === "fixed") && (l = o.offsetLeft, a = o.offsetTop);
}
return {
width: i,
height: s,
x: l + tc(n),
y: a
};
}
function V0(n) {
var e, t = Kn(n), r = ec(n), o = (e = n.ownerDocument) == null ? void 0 : e.body, i = mr(t.scrollWidth, t.clientWidth, o ? o.scrollWidth : 0, o ? o.clientWidth : 0), s = mr(t.scrollHeight, t.clientHeight, o ? o.scrollHeight : 0, o ? o.clientHeight : 0), l = -r.scrollLeft + tc(n), a = -r.scrollTop;
return dn(o || t).direction === "rtl" && (l += mr(t.clientWidth, o ? o.clientWidth : 0) - i), {
width: i,
height: s,
x: l,
y: a
};
}
function nc(n) {
var e = dn(n), t = e.overflow, r = e.overflowX, o = e.overflowY;
return /auto|scroll|overlay|hidden/.test(t + o + r);
}
function Of(n) {
return ["html", "body", "#document"].indexOf(Gt(n)) >= 0 ? n.ownerDocument.body : St(n) && nc(n) ? n : Of(qs(n));
}
function Eo(n, e) {
var t;
e === void 0 && (e = []);
var r = Of(n), o = r === ((t = n.ownerDocument) == null ? void 0 : t.body), i = pt(r), s = o ? [i].concat(i.visualViewport || [], nc(r) ? r : []) : r, l = e.concat(s);
return o ? l : (
// $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
l.concat(Eo(qs(s)))
);
}
function sa(n) {
return Object.assign({}, n, {
left: n.x,
top: n.y,
right: n.x + n.width,
bottom: n.y + n.height
});
}
function W0(n, e) {
var t = eo(n, !1, e === "fixed");
return t.top = t.top + n.clientTop, t.left = t.left + n.clientLeft, t.bottom = t.top + n.clientHeight, t.right = t.left + n.clientWidth, t.width = n.clientWidth, t.height = n.clientHeight, t.x = t.left, t.y = t.top, t;
}
function Lp(n, e, t) {
return e === vf ? sa(z0(n, t)) : Mr(e) ? W0(e, t) : sa(V0(Kn(n)));
}
function U0(n) {
var e = Eo(qs(n)), t = ["absolute", "fixed"].indexOf(dn(n).position) >= 0, r = t && St(n) ? ri(n) : n;
return Mr(r) ? e.filter(function(o) {
return Mr(o) && Cf(o, r) && Gt(o) !== "body";
}) : [];
}
function q0(n, e, t, r) {
var o = e === "clippingParents" ? U0(n) : [].concat(e), i = [].concat(o, [t]), s = i[0], l = i.reduce(function(a, c) {
var p = Lp(n, c, r);
return a.top = mr(p.top, a.top), a.right = es(p.right, a.right), a.bottom = es(p.bottom, a.bottom), a.left = mr(p.left, a.left), a;
}, Lp(n, s, r));
return l.width = l.right - l.left, l.height = l.bottom - l.top, l.x = l.left, l.y = l.top, l;
}
function Bf(n) {
var e = n.reference, t = n.element, r = n.placement, o = r ? Wt(r) : null, i = r ? to(r) : null, s = e.x + e.width / 2 - t.width / 2, l = e.y + e.height / 2 - t.height / 2, a;
switch (o) {
case rt:
a = {
x: s,
y: e.y - t.height
};
break;
case kt:
a = {
x: s,
y: e.y + e.height
};
break;
case Ct:
a = {
x: e.x + e.width,
y: l
};
break;
case ot:
a = {
x: e.x - t.width,
y: l
};
break;
default:
a = {
x: e.x,
y: e.y
};
}
var c = o ? Za(o) : null;
if (c != null) {
var p = c === "y" ? "height" : "width";
switch (i) {
case Qr:
a[c] = a[c] - (e[p] / 2 - t[p] / 2);
break;
case Uo:
a[c] = a[c] + (e[p] / 2 - t[p] / 2);
break;
}
}
return a;
}
function qo(n, e) {
e === void 0 && (e = {});
var t = e, r = t.placement, o = r === void 0 ? n.placement : r, i = t.strategy, s = i === void 0 ? n.strategy : i, l = t.boundary, a = l === void 0 ? f0 : l, c = t.rootBoundary, p = c === void 0 ? vf : c, u = t.elementContext, f = u === void 0 ? uo : u, h = t.altBoundary, b = h === void 0 ? !1 : h, m = t.padding, x = m === void 0 ? 0 : m, v = Ef(typeof x != "number" ? x : Tf(x, ni)), C = f === uo ? h0 : uo, S = n.rects.popper, g = n.elements[b ? C : f], O = q0(Mr(g) ? g : g.contextElement || Kn(n.elements.popper), a, p, s), T = eo(n.elements.reference), B = Bf({
reference: T,
element: S,
placement: o
}), F = sa(Object.assign({}, S, B)), W = f === uo ? F : T, L = {
top: O.top - W.top + v.top,
bottom: W.bottom - O.bottom + v.bottom,
left: O.left - W.left + v.left,
right: W.right - O.right + v.right
}, N = n.modifiersData.offset;
if (f === uo && N) {
var $ = N[o];
Object.keys(L).forEach(function(K) {
var ae = [Ct, kt].indexOf(K) >= 0 ? 1 : -1, he = [rt, kt].indexOf(K) >= 0 ? "y" : "x";
L[K] += $[he] * ae;
});
}
return L;
}
function K0(n, e) {
e === void 0 && (e = {});
var t = e, r = t.placement, o = t.boundary, i = t.rootBoundary, s = t.padding, l = t.flipVariations, a = t.allowedAutoPlacements, c = a === void 0 ? wf : a, p = to(r), u = p ? l ? Bp : Bp.filter(function(b) {
return to(b) === p;
}) : ni, f = u.filter(function(b) {
return c.indexOf(b) >= 0;
});
f.length === 0 && (f = u);
var h = f.reduce(function(b, m) {
return b[m] = qo(n, {
placement: m,
boundary: o,
rootBoundary: i,
padding: s
})[Wt(m)], b;
}, {});
return Object.keys(h).sort(function(b, m) {
return h[b] - h[m];
});
}
function G0(n) {
if (Wt(n) === Ya)
return [];
var e = _i(n);
return [_p(n), e, _p(e)];
}
function J0(n) {
var e = n.state, t = n.options, r = n.name;
if (!e.modifiersData[r]._skip) {
for (var o = t.mainAxis, i = o === void 0 ? !0 : o, s = t.altAxis, l = s === void 0 ? !0 : s, a = t.fallbackPlacements, c = t.padding, p = t.boundary, u = t.rootBoundary, f = t.altBoundary, h = t.flipVariations, b = h === void 0 ? !0 : h, m = t.allowedAutoPlacements, x = e.options.placement, v = Wt(x), C = v === x, S = a || (C || !b ? [_i(x)] : G0(x)), g = [x].concat(S).reduce(function(Mt, it) {
return Mt.concat(Wt(it) === Ya ? K0(e, {
placement: it,
boundary: p,
rootBoundary: u,
padding: c,
flipVariations: b,
allowedAutoPlacements: m
}) : it);
}, []), O = e.rects.reference, T = e.rects.popper, B = /* @__PURE__ */ new Map(), F = !0, W = g[0], L = 0; L < g.length; L++) {
var N = g[L], $ = Wt(N), K = to(N) === Qr, ae = [rt, kt].indexOf($) >= 0, he = ae ? "width" : "height", ue = qo(e, {
placement: N,
boundary: p,
rootBoundary: u,
altBoundary: f,
padding: c
}), ie = ae ? K ? Ct : ot : K ? kt : rt;
O[he] > T[he] && (ie = _i(ie));
var G = _i(ie), re = [];
if (i && re.push(ue[$] <= 0), l && re.push(ue[ie] <= 0, ue[G] <= 0), re.every(function(Mt) {
return Mt;
})) {
W = N, F = !1;
break;
}
B.set(N, re);
}
if (F)
for (var ut = b ? 3 : 1, Jt = function(it) {
var st = g.find(function(fn) {
var et = B.get(fn);
if (et)
return et.slice(0, it).every(function(hn) {
return hn;
});
});
if (st)
return W = st, "break";
}, dt = ut; dt > 0; dt--) {
var Yt = Jt(dt);
if (Yt === "break") break;
}
e.placement !== W && (e.modifiersData[r]._skip = !0, e.placement = W, e.reset = !0);
}
}
const Y0 = {
name: "flip",
enabled: !0,
phase: "main",
fn: J0,
requiresIfExists: ["offset"],
data: {
_skip: !1
}
};
function Np(n, e, t) {
return t === void 0 && (t = {
x: 0,
y: 0
}), {
top: n.top - e.height - t.y,
right: n.right - e.width + t.x,
bottom: n.bottom - e.height + t.y,
left: n.left - e.width - t.x
};
}
function Dp(n) {
return [rt, Ct, kt, ot].some(function(e) {
return n[e] >= 0;
});
}
function X0(n) {
var e = n.state, t = n.name, r = e.rects.reference, o = e.rects.popper, i = e.modifiersData.preventOverflow, s = qo(e, {
elementContext: "reference"
}), l = qo(e, {
altBoundary: !0
}), a = Np(s, r), c = Np(l, o, i), p = Dp(a), u = Dp(c);
e.modifiersData[t] = {
referenceClippingOffsets: a,
popperEscapeOffsets: c,
isReferenceHidden: p,
hasPopperEscaped: u
}, e.attributes.popper = Object.assign({}, e.attributes.popper, {
"data-popper-reference-hidden": p,
"data-popper-escaped": u
});
}
const Q0 = {
name: "hide",
enabled: !0,
phase: "main",
requiresIfExists: ["preventOverflow"],
fn: X0
};
function Z0(n, e, t) {
var r = Wt(n), o = [ot, rt].indexOf(r) >= 0 ? -1 : 1, i = typeof t == "function" ? t(Object.assign({}, e, {
placement: n
})) : t, s = i[0], l = i[1];
return s = s || 0, l = (l || 0) * o, [ot, Ct].indexOf(r) >= 0 ? {
x: l,
y: s
} : {
x: s,
y: l
};
}
function ev(n) {
var e = n.state, t = n.options, r = n.name, o = t.offset, i = o === void 0 ? [0, 0] : o, s = wf.reduce(function(p, u) {
return p[u] = Z0(u, e.rects, i), p;
}, {}), l = s[e.placement], a = l.x, c = l.y;
e.modifiersData.popperOffsets != null && (e.modifiersData.popperOffsets.x += a, e.modifiersData.popperOffsets.y += c), e.modifiersData[r] = s;
}
const tv = {
name: "offset",
enabled: !0,
phase: "main",
requires: ["popperOffsets"],
fn: ev
};
function nv(n) {
var e = n.state, t = n.name;
e.modifiersData[t] = Bf({
reference: e.rects.reference,
element: e.rects.popper,
placement: e.placement
});
}
const rv = {
name: "popperOffsets",
enabled: !0,
phase: "read",
fn: nv,
data: {}
};
function ov(n) {
return n === "x" ? "y" : "x";
}
function iv(n) {
var e = n.state, t = n.options, r = n.name, o = t.mainAxis, i = o === void 0 ? !0 : o, s = t.altAxis, l = s === void 0 ? !1 : s, a = t.boundary, c = t.rootBoundary, p = t.altBoundary, u = t.padding, f = t.tether, h = f === void 0 ? !0 : f, b = t.tetherOffset, m = b === void 0 ? 0 : b, x = qo(e, {
boundary: a,
rootBoundary: c,
padding: u,
altBoundary: p
}), v = Wt(e.placement), C = to(e.placement), S = !C, g = Za(v), O = ov(g), T = e.modifiersData.popperOffsets, B = e.rects.reference, F = e.rects.popper, W = typeof m == "function" ? m(Object.assign({}, e.rects, {
placement: e.placement
})) : m, L = typeof W == "number" ? {
mainAxis: W,
altAxis: W
} : Object.assign({
mainAxis: 0,
altAxis: 0
}, W), N = e.modifiersData.offset ? e.modifiersData.offset[e.placement] : null, $ = {
x: 0,
y: 0
};
if (T) {
if (i) {
var K, ae = g === "y" ? rt : ot, he = g === "y" ? kt : Ct, ue = g === "y" ? "height" : "width", ie = T[g], G = ie + x[ae], re = ie - x[he], ut = h ? -F[ue] / 2 : 0, Jt = C === Qr ? B[ue] : F[ue], dt = C === Qr ? -F[ue] : -B[ue], Yt = e.elements.arrow, Mt = h && Yt ? Qa(Yt) : {
width: 0,
height: 0
}, it = e.modifiersData["arrow#persistent"] ? e.modifiersData["arrow#persistent"].padding : Mf(), st = it[ae], fn = it[he], et = Mo(0, B[ue], Mt[ue]), hn = S ? B[ue] / 2 - ut - et - st - L.mainAxis : Jt - et - st - L.mainAxis, Et = S ? -B[ue] / 2 + ut + et + fn + L.mainAxis : dt + et + fn + L.mainAxis, Tt = e.elements.arrow && ri(e.elements.arrow), Gn = Tt ? g === "y" ? Tt.clientTop || 0 : Tt.clientLeft || 0 : 0, bn = (K = N == null ? void 0 : N[g]) != null ? K : 0, Jn = ie + hn - bn - Gn, Yn = ie + Et - bn, mn = Mo(h ? es(G, Jn) : G, ie, h ? mr(re, Yn) : re);
T[g] = mn, $[g] = mn - ie;
}
if (l) {
var xn, Xn = g === "x" ? rt : ot, Qn = g === "x" ? kt : Ct, Ot = T[O], It = O === "y" ? "height" : "width", gn = Ot + x[Xn], ft = Ot - x[Qn], yn = [rt, ot].indexOf(v) !== -1, Zn = (xn = N == null ? void 0 : N[O]) != null ? xn : 0, er = yn ? gn : Ot - B[It] - F[It] - Zn + L.altAxis, tr = yn ? Ot + B[It] + F[It] - Zn - L.altAxis : ft, nr = h && yn ? B0(er, Ot, tr) : Mo(h ? er : gn, Ot, h ? tr : ft);
T[O] = nr, $[O] = nr - Ot;
}
e.modifiersData[r] = $;
}
}
const sv = {
name: "preventOverflow",
enabled: !0,
phase: "main",
fn: iv,
requiresIfExists: ["offset"]
};
function lv(n) {
return {
scrollLeft: n.scrollLeft,
scrollTop: n.scrollTop
};
}
function av(n) {
return n === pt(n) || !St(n) ? ec(n) : lv(n);
}
function cv(n) {
var e = n.getBoundingClientRect(), t = Zr(e.width) / n.offsetWidth || 1, r = Zr(e.height) / n.offsetHeight || 1;
return t !== 1 || r !== 1;
}
function pv(n, e, t) {
t === void 0 && (t = !1);
var r = St(e), o = St(e) && cv(e), i = Kn(e), s = eo(n, o, t), l = {
scrollLeft: 0,
scrollTop: 0
}, a = {
x: 0,
y: 0
};
return (r || !r && !t) && ((Gt(e) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
nc(i)) && (l = av(e)), St(e) ? (a = eo(e, !0), a.x += e.clientLeft, a.y += e.clientTop) : i && (a.x = tc(i))), {
x: s.left + l.scrollLeft - a.x,
y: s.top + l.scrollTop - a.y,
width: s.width,
height: s.height
};
}
function uv(n) {
var e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), r = [];
n.forEach(function(i) {
e.set(i.name, i);
});
function o(i) {
t.add(i.name);
var s = [].concat(i.requires || [], i.requiresIfExists || []);
s.forEach(function(l) {
if (!t.has(l)) {
var a = e.get(l);
a && o(a);
}
}), r.push(i);
}
return n.forEach(function(i) {
t.has(i.name) || o(i);
}), r;
}
function dv(n) {
var e = uv(n);
return C0.reduce(function(t, r) {
return t.concat(e.filter(function(o) {
return o.phase === r;
}));
}, []);
}
function fv(n) {
var e;
return function() {
return e || (e = new Promise(function(t) {
Promise.resolve().then(function() {
e = void 0, t(n());
});
})), e;
};
}
function hv(n) {
var e = n.reduce(function(t, r) {
var o = t[r.name];
return t[r.name] = o ? Object.assign({}, o, r, {
options: Object.assign({}, o.options, r.options),
data: Object.assign({}, o.data, r.data)
}) : r, t;
}, {});
return Object.keys(e).map(function(t) {
return e[t];
});
}
var Ip = {
placement: "bottom",
modifiers: [],
strategy: "absolute"
};
function $p() {
for (var n = arguments.length, e = new Array(n), t = 0; t < n; t++)
e[t] = arguments[t];
return !e.some(function(r) {
return !(r && typeof r.getBoundingClientRect == "function");
});
}
function bv(n) {
n === void 0 && (n = {});
var e = n, t = e.defaultModifiers, r = t === void 0 ? [] : t, o = e.defaultOptions, i = o === void 0 ? Ip : o;
return function(l, a, c) {
c === void 0 && (c = i);
var p = {
placement: "bottom",
orderedModifiers: [],
options: Object.assign({}, Ip, i),
modifiersData: {},
elements: {
reference: l,
popper: a
},
attributes: {},
styles: {}
}, u = [], f = !1, h = {
state: p,
setOptions: function(v) {
var C = typeof v == "function" ? v(p.options) : v;
m(), p.options = Object.assign({}, i, p.options, C), p.scrollParents = {
reference: Mr(l) ? Eo(l) : l.contextElement ? Eo(l.contextElement) : [],
popper: Eo(a)
};
var S = dv(hv([].concat(r, p.options.modifiers)));
return p.orderedModifiers = S.filter(function(g) {
return g.enabled;
}), b(), h.update();
},
// Sync update – it will always be executed, even if not necessary. This
// is useful for low frequency updates where sync behavior simplifies the
// logic.
// For high frequency updates (e.g. `resize` and `scroll` events), always
// prefer the async Popper#update method
forceUpdate: function() {
if (!f) {
var v = p.elements, C = v.reference, S = v.popper;
if ($p(C, S)) {
p.rects = {
reference: pv(C, ri(S), p.options.strategy === "fixed"),
popper: Qa(S)
}, p.reset = !1, p.placement = p.options.placement, p.orderedModifiers.forEach(function(L) {
return p.modifiersData[L.name] = Object.assign({}, L.data);
});
for (var g = 0; g < p.orderedModifiers.length; g++) {
if (p.reset === !0) {
p.reset = !1, g = -1;
continue;
}
var O = p.orderedModifiers[g], T = O.fn, B = O.options, F = B === void 0 ? {} : B, W = O.name;
typeof T == "function" && (p = T({
state: p,
options: F,
name: W,
instance: h
}) || p);
}
}
}
},
// Async and optimistically optimized update – it will not be executed if
// not necessary (debounced to run at most once-per-tick)
update: fv(function() {
return new Promise(function(x) {
h.forceUpdate(), x(p);
});
}),
destroy: function() {
m(), f = !0;
}
};
if (!$p(l, a))
return h;
h.setOptions(c).then(function(x) {
!f && c.onFirstUpdate && c.onFirstUpdate(x);
});
function b() {
p.orderedModifiers.forEach(function(x) {
var v = x.name, C = x.options, S = C === void 0 ? {} : C, g = x.effect;
if (typeof g == "function") {
var O = g({
state: p,
name: v,
instance: h,
options: S
}), T = function() {
};
u.push(O || T);
}
});
}
function m() {
u.forEach(function(x) {
return x();
}), u = [];
}
return h;
};
}
var mv = [F0, rv, $0, Sf, tv, Y0, sv, L0, Q0], xv = /* @__PURE__ */ bv({
defaultModifiers: mv
}), gv = "tippy-box", Pf = "tippy-content", yv = "tippy-backdrop", Af = "tippy-arrow", _f = "tippy-svg-arrow", or = {
passive: !0,
capture: !0
}, Lf = function() {
return document.body;
};
function vv(n, e) {
return {}.hasOwnProperty.call(n, e);
}
function xl(n, e, t) {
if (Array.isArray(n)) {
var r = n[e];
return r ?? (Array.isArray(t) ? t[e] : t);
}
return n;
}
function rc(n, e) {
var t = {}.toString.call(n);
return t.indexOf("[object") === 0 && t.indexOf(e + "]") > -1;
}
function Nf(n, e) {
return typeof n == "function" ? n.apply(void 0, e) : n;
}
function Rp(n, e) {
if (e === 0)
return n;
var t;
return function(r) {
clearTimeout(t), t = setTimeout(function() {
n(r);
}, e);
};
}
function wv(n, e) {
var t = Object.assign({}, n);
return e.forEach(function(r) {
delete t[r];
}), t;
}
function Sv(n) {
return n.split(/\s+/).filter(Boolean);
}
function $r(n) {
return [].concat(n);
}
function Fp(n, e) {
n.indexOf(e) === -1 && n.push(e);
}
function kv(n) {
return n.filter(function(e, t) {
return n.indexOf(e) === t;
});
}
function Cv(n) {
return n.split("-")[0];
}
function ts(n) {
return [].slice.call(n);
}
function Hp(n) {
return Object.keys(n).reduce(function(e, t) {
return n[t] !== void 0 && (e[t] = n[t]), e;
}, {});
}
function To() {
return document.createElement("div");
}
function Ko(n) {
return ["Element", "Fragment"].some(function(e) {
return rc(n, e);
});
}
function Mv(n) {
return rc(n, "NodeList");
}
function Ev(n) {
return rc(n, "MouseEvent");
}
function Tv(n) {
return !!(n && n._tippy && n._tippy.reference === n);
}
function Ov(n) {
return Ko(n) ? [n] : Mv(n) ? ts(n) : Array.isArray(n) ? n : ts(document.querySelectorAll(n));
}
function gl(n, e) {
n.forEach(function(t) {
t && (t.style.transitionDuration = e + "ms");
});
}
function jp(n, e) {
n.forEach(function(t) {
t && t.setAttribute("data-state", e);
});
}
function Bv(n) {
var e, t = $r(n), r = t[0];
return r != null && (e = r.ownerDocument) != null && e.body ? r.ownerDocument : document;
}
function Pv(n, e) {
var t = e.clientX, r = e.clientY;
return n.every(function(o) {
var i = o.popperRect, s = o.popperState, l = o.props, a = l.interactiveBorder, c = Cv(s.placement), p = s.modifiersData.offset;
if (!p)
return !0;
var u = c === "bottom" ? p.top.y : 0, f = c === "top" ? p.bottom.y : 0, h = c === "right" ? p.left.x : 0, b = c === "left" ? p.right.x : 0, m = i.top - r + u > a, x = r - i.bottom - f > a, v = i.left - t + h > a, C = t - i.right - b > a;
return m || x || v || C;
});
}
function yl(n, e, t) {
var r = e + "EventListener";
["transitionend", "webkitTransitionEnd"].forEach(function(o) {
n[r](o, t);
});
}
function zp(n, e) {
for (var t = e; t; ) {
var r;
if (n.contains(t))
return !0;
t = t.getRootNode == null || (r = t.getRootNode()) == null ? void 0 : r.host;
}
return !1;
}
var Ht = {
isTouch: !1
}, Vp = 0;
function Av() {
Ht.isTouch || (Ht.isTouch = !0, window.performance && document.addEventListener("mousemove", Df));
}
function Df() {
var n = performance.now();
n - Vp < 20 && (Ht.isTouch = !1, document.removeEventListener("mousemove", Df)), Vp = n;
}
function _v() {
var n = document.activeElement;
if (Tv(n)) {
var e = n._tippy;
n.blur && !e.state.isVisible && n.blur();
}
}
function Lv() {
document.addEventListener("touchstart", Av, or), window.addEventListener("blur", _v);
}
var Nv = typeof window < "u" && typeof document < "u", Dv = Nv ? (
// @ts-ignore
!!window.msCrypto
) : !1;
function _r(n) {
var e = n === "destroy" ? "n already-" : " ";
return [n + "() was called on a" + e + "destroyed instance. This is a no-op but", "indicates a potential memory leak."].join(" ");
}
function Wp(n) {
var e = /[ \t]{2,}/g, t = /^[ \t]*/gm;
return n.replace(e, " ").replace(t, "").trim();
}
function Iv(n) {
return Wp(`
%ctippy.js
%c` + Wp(n) + `
%c👷 This is a development-only message. It will be removed in production.
`);
}
function If(n) {
return [
Iv(n),
// title
"color: #00C584; font-size: 1.3em; font-weight: bold;",
// message
"line-height: 1.5",
// footer
"color: #a6a095;"
];
}
var Go;
process.env.NODE_ENV !== "production" && $v();
function $v() {
Go = /* @__PURE__ */ new Set();
}
function on(n, e) {
if (n && !Go.has(e)) {
var t;
Go.add(e), (t = console).warn.apply(t, If(e));
}
}
function la(n, e) {
if (n && !Go.has(e)) {
var t;
Go.add(e), (t = console).error.apply(t, If(e));
}
}
function Rv(n) {
var e = !n, t = Object.prototype.toString.call(n) === "[object Object]" && !n.addEventListener;
la(e, ["tippy() was passed", "`" + String(n) + "`", "as its targets (first) argument. Valid types are: String, Element,", "Element[], or NodeList."].join(" ")), la(t, ["tippy() was passed a plain object which is not supported as an argument", "for virtual positioning. Use props.getReferenceClientRect instead."].join(" "));
}
var $f = {
animateFill: !1,
followCursor: !1,
inlinePositioning: !1,
sticky: !1
}, Fv = {
allowHTML: !1,
animation: "fade",
arrow: !0,
content: "",
inertia: !1,
maxWidth: 350,
role: "tooltip",
theme: "",
zIndex: 9999
}, at = Object.assign({
appendTo: Lf,
aria: {
content: "auto",
expanded: "auto"
},
delay: 0,
duration: [300, 250],
getReferenceClientRect: null,
hideOnClick: !0,
ignoreAttributes: !1,
interactive: !1,
interactiveBorder: 2,
interactiveDebounce: 0,
moveTransition: "",
offset: [0, 10],
onAfterUpdate: function() {
},
onBeforeUpdate: function() {
},
onCreate: function() {
},
onDestroy: function() {
},
onHidden: function() {
},
onHide: function() {
},
onMount: function() {
},
onShow: function() {
},
onShown: function() {
},
onTrigger: function() {
},
onUntrigger: function() {
},
onClickOutside: function() {
},
placement: "top",
plugins: [],
popperOptions: {},
render: null,
showOnCreate: !1,
touch: !0,
trigger: "mouseenter focus",
triggerTarget: null
}, $f, Fv), Hv = Object.keys(at), jv = function(e) {
process.env.NODE_ENV !== "production" && Ff(e, []);
var t = Object.keys(e);
t.forEach(function(r) {
at[r] = e[r];
});
};
function Rf(n) {
var e = n.plugins || [], t = e.reduce(function(r, o) {
var i = o.name, s = o.defaultValue;
if (i) {
var l;
r[i] = n[i] !== void 0 ? n[i] : (l = at[i]) != null ? l : s;
}
return r;
}, {});
return Object.assign({}, n, t);
}
function zv(n, e) {
var t = e ? Object.keys(Rf(Object.assign({}, at, {
plugins: e
}))) : Hv, r = t.reduce(function(o, i) {
var s = (n.getAttribute("data-tippy-" + i) || "").trim();
if (!s)
return o;
if (i === "content")
o[i] = s;
else
try {
o[i] = JSON.parse(s);
} catch {
o[i] = s;
}
return o;
}, {});
return r;
}
function Up(n, e) {
var t = Object.assign({}, e, {
content: Nf(e.content, [n])
}, e.ignoreAttributes ? {} : zv(n, e.plugins));
return t.aria = Object.assign({}, at.aria, t.aria), t.aria = {
expanded: t.aria.expanded === "auto" ? e.interactive : t.aria.expanded,
content: t.aria.content === "auto" ? e.interactive ? null : "describedby" : t.aria.content
}, t;
}
function Ff(n, e) {
n === void 0 && (n = {}), e === void 0 && (e = []);
var t = Object.keys(n);
t.forEach(function(r) {
var o = wv(at, Object.keys($f)), i = !vv(o, r);
i && (i = e.filter(function(s) {
return s.name === r;
}).length === 0), on(i, ["`" + r + "`", "is not a valid prop. You may have spelled it incorrectly, or if it's", "a plugin, forgot to pass it in an array as props.plugins.", `
`, `All props: https://atomiks.github.io/tippyjs/v6/all-props/
`, "Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "));
});
}
var Vv = function() {
return "innerHTML";
};
function aa(n, e) {
n[Vv()] = e;
}
function qp(n) {
var e = To();
return n === !0 ? e.className = Af : (e.className = _f, Ko(n) ? e.appendChild(n) : aa(e, n)), e;
}
function Kp(n, e) {
Ko(e.content) ? (aa(n, ""), n.appendChild(e.content)) : typeof e.content != "function" && (e.allowHTML ? aa(n, e.content) : n.textContent = e.content);
}
function ca(n) {
var e = n.firstElementChild, t = ts(e.children);
return {
box: e,
content: t.find(function(r) {
return r.classList.contains(Pf);
}),
arrow: t.find(function(r) {
return r.classList.contains(Af) || r.classList.contains(_f);
}),
backdrop: t.find(function(r) {
return r.classList.contains(yv);
})
};
}
function Hf(n) {
var e = To(), t = To();
t.className = gv, t.setAttribute("data-state", "hidden"), t.setAttribute("tabindex", "-1");
var r = To();
r.className = Pf, r.setAttribute("data-state", "hidden"), Kp(r, n.props), e.appendChild(t), t.appendChild(r), o(n.props, n.props);
function o(i, s) {
var l = ca(e), a = l.box, c = l.content, p = l.arrow;
s.theme ? a.setAttribute("data-theme", s.theme) : a.removeAttribute("data-theme"), typeof s.animation == "string" ? a.setAttribute("data-animation", s.animation) : a.removeAttribute("data-animation"), s.inertia ? a.setAttribute("data-inertia", "") : a.removeAttribute("data-inertia"), a.style.maxWidth = typeof s.maxWidth == "number" ? s.maxWidth + "px" : s.maxWidth, s.role ? a.setAttribute("role", s.role) : a.removeAttribute("role"), (i.content !== s.content || i.allowHTML !== s.allowHTML) && Kp(c, n.props), s.arrow ? p ? i.arrow !== s.arrow && (a.removeChild(p), a.appendChild(qp(s.arrow))) : a.appendChild(qp(s.arrow)) : p && a.removeChild(p);
}
return {
popper: e,
onUpdate: o
};
}
Hf.$$tippy = !0;
var Wv = 1, Si = [], vl = [];
function Uv(n, e) {
var t = Up(n, Object.assign({}, at, Rf(Hp(e)))), r, o, i, s = !1, l = !1, a = !1, c = !1, p, u, f, h = [], b = Rp(Jn, t.interactiveDebounce), m, x = Wv++, v = null, C = kv(t.plugins), S = {
// Is the instance currently enabled?
isEnabled: !0,
// Is the tippy currently showing and not transitioning out?
isVisible: !1,
// Has the instance been destroyed?
isDestroyed: !1,
// Is the tippy currently mounted to the DOM?
isMounted: !1,
// Has the tippy finished transitioning in?
isShown: !1
}, g = {
// properties
id: x,
reference: n,
popper: To(),
popperInstance: v,
props: t,
state: S,
plugins: C,
// methods
clearDelayTimeouts: er,
setProps: tr,
setContent: nr,
show: ai,
hide: ci,
hideWithInteractivity: pi,
enable: yn,
disable: Zn,
unmount: Ys,
destroy: ao
};
if (!t.render)
return process.env.NODE_ENV !== "production" && la(!0, "render() function has not been supplied."), g;
var O = t.render(g), T = O.popper, B = O.onUpdate;
T.setAttribute("data-tippy-root", ""), T.id = "tippy-" + g.id, g.popper = T, n._tippy = g, T._tippy = g;
var F = C.map(function(P) {
return P.fn(g);
}), W = n.hasAttribute("aria-expanded");
return Tt(), ut(), ie(), G("onCreate", [g]), t.showOnCreate && gn(), T.addEventListener("mouseenter", function() {
g.props.interactive && g.state.isVisible && g.clearDelayTimeouts();
}), T.addEventListener("mouseleave", function() {
g.props.interactive && g.props.trigger.indexOf("mouseenter") >= 0 && ae().addEventListener("mousemove", b);
}), g;
function L() {
var P = g.props.touch;
return Array.isArray(P) ? P : [P, 0];
}
function N() {
return L()[0] === "hold";
}
function $() {
var P;
return !!((P = g.props.render) != null && P.$$tippy);
}
function K() {
return m || n;
}
function ae() {
var P = K().parentNode;
return P ? Bv(P) : document;
}
function he() {
return ca(T);
}
function ue(P) {
return g.state.isMounted && !g.state.isVisible || Ht.isTouch || p && p.type === "focus" ? 0 : xl(g.props.delay, P ? 0 : 1, at.delay);
}
function ie(P) {
P === void 0 && (P = !1), T.style.pointerEvents = g.props.interactive && !P ? "" : "none", T.style.zIndex = "" + g.props.zIndex;
}
function G(P, q, Y) {
if (Y === void 0 && (Y = !0), F.forEach(function(H) {
H[P] && H[P].apply(H, q);
}), Y) {
var se;
(se = g.props)[P].apply(se, q);
}
}
function re() {
var P = g.props.aria;
if (P.content) {
var q = "aria-" + P.content, Y = T.id, se = $r(g.props.triggerTarget || n);
se.forEach(function(H) {
var _ = H.getAttribute(q);
if (g.state.isVisible)
H.setAttribute(q, _ ? _ + " " + Y : Y);
else {
var le = _ && _.replace(Y, "").trim();
le ? H.setAttribute(q, le) : H.removeAttribute(q);
}
});
}
}
function ut() {
if (!(W || !g.props.aria.expanded)) {
var P = $r(g.props.triggerTarget || n);
P.forEach(function(q) {
g.props.interactive ? q.setAttribute("aria-expanded", g.state.isVisible && q === K() ? "true" : "false") : q.removeAttribute("aria-expanded");
});
}
}
function Jt() {
ae().removeEventListener("mousemove", b), Si = Si.filter(function(P) {
return P !== b;
});
}
function dt(P) {
if (!(Ht.isTouch && (a || P.type === "mousedown"))) {
var q = P.composedPath && P.composedPath()[0] || P.target;
if (!(g.props.interactive && zp(T, q))) {
if ($r(g.props.triggerTarget || n).some(function(Y) {
return zp(Y, q);
})) {
if (Ht.isTouch || g.state.isVisible && g.props.trigger.indexOf("click") >= 0)
return;
} else
G("onClickOutside", [g, P]);
g.props.hideOnClick === !0 && (g.clearDelayTimeouts(), g.hide(), l = !0, setTimeout(function() {
l = !1;
}), g.state.isMounted || st());
}
}
}
function Yt() {
a = !0;
}
function Mt() {
a = !1;
}
function it() {
var P = ae();
P.addEventListener("mousedown", dt, !0), P.addEventListener("touchend", dt, or), P.addEventListener("touchstart", Mt, or), P.addEventListener("touchmove", Yt, or);
}
function st() {
var P = ae();
P.removeEventListener("mousedown", dt, !0), P.removeEventListener("touchend", dt, or), P.removeEventListener("touchstart", Mt, or), P.removeEventListener("touchmove", Yt, or);
}
function fn(P, q) {
hn(P, function() {
!g.state.isVisible && T.parentNode && T.parentNode.contains(T) && q();
});
}
function et(P, q) {
hn(P, q);
}
function hn(P, q) {
var Y = he().box;
function se(H) {
H.target === Y && (yl(Y, "remove", se), q());
}
if (P === 0)
return q();
yl(Y, "remove", u), yl(Y, "add", se), u = se;
}
function Et(P, q, Y) {
Y === void 0 && (Y = !1);
var se = $r(g.props.triggerTarget || n);
se.forEach(function(H) {
H.addEventListener(P, q, Y), h.push({
node: H,
eventType: P,
handler: q,
options: Y
});
});
}
function Tt() {
N() && (Et("touchstart", bn, {
passive: !0
}), Et("touchend", Yn, {
passive: !0
})), Sv(g.props.trigger).forEach(function(P) {
if (P !== "manual")
switch (Et(P, bn), P) {
case "mouseenter":
Et("mouseleave", Yn);
break;
case "focus":
Et(Dv ? "focusout" : "blur", mn);
break;
case "focusin":
Et("focusout", mn);
break;
}
});
}
function Gn() {
h.forEach(function(P) {
var q = P.node, Y = P.eventType, se = P.handler, H = P.options;
q.removeEventListener(Y, se, H);
}), h = [];
}
function bn(P) {
var q, Y = !1;
if (!(!g.state.isEnabled || xn(P) || l)) {
var se = ((q = p) == null ? void 0 : q.type) === "focus";
p = P, m = P.currentTarget, ut(), !g.state.isVisible && Ev(P) && Si.forEach(function(H) {
return H(P);
}), P.type === "click" && (g.props.trigger.indexOf("mouseenter") < 0 || s) && g.props.hideOnClick !== !1 && g.state.isVisible ? Y = !0 : gn(P), P.type === "click" && (s = !Y), Y && !se && ft(P);
}
}
function Jn(P) {
var q = P.target, Y = K().contains(q) || T.contains(q);
if (!(P.type === "mousemove" && Y)) {
var se = It().concat(T).map(function(H) {
var _, le = H._tippy, Bt = (_ = le.popperInstance) == null ? void 0 : _.state;
return Bt ? {
popperRect: H.getBoundingClientRect(),
popperState: Bt,
props: t
} : null;
}).filter(Boolean);
Pv(se, P) && (Jt(), ft(P));
}
}
function Yn(P) {
var q = xn(P) || g.props.trigger.indexOf("click") >= 0 && s;
if (!q) {
if (g.props.interactive) {
g.hideWithInteractivity(P);
return;
}
ft(P);
}
}
function mn(P) {
g.props.trigger.indexOf("focusin") < 0 && P.target !== K() || g.props.interactive && P.relatedTarget && T.contains(P.relatedTarget) || ft(P);
}
function xn(P) {
return Ht.isTouch ? N() !== P.type.indexOf("touch") >= 0 : !1;
}
function Xn() {
Qn();
var P = g.props, q = P.popperOptions, Y = P.placement, se = P.offset, H = P.getReferenceClientRect, _ = P.moveTransition, le = $() ? ca(T).arrow : null, Bt = H ? {
getBoundingClientRect: H,
contextElement: H.contextElement || K()
} : n, co = {
name: "$$tippy",
enabled: !0,
phase: "beforeWrite",
requires: ["computeStyles"],
fn: function(Br) {
var vn = Br.state;
if ($()) {
var Ph = he(), Xs = Ph.box;
["placement", "reference-hidden", "escaped"].forEach(function(di) {
di === "placement" ? Xs.setAttribute("data-placement", vn.placement) : vn.attributes.popper["data-popper-" + di] ? Xs.setAttribute("data-" + di, "") : Xs.removeAttribute("data-" + di);
}), vn.attributes.popper = {};
}
}
}, Xt = [{
name: "offset",
options: {
offset: se
}
}, {
name: "preventOverflow",
options: {
padding: {
top: 2,
bottom: 2,
left: 5,
right: 5
}
}
}, {
name: "flip",
options: {
padding: 5
}
}, {
name: "computeStyles",
options: {
adaptive: !_
}
}, co];
$() && le && Xt.push({
name: "arrow",
options: {
element: le,
padding: 3
}
}), Xt.push.apply(Xt, (q == null ? void 0 : q.modifiers) || []), g.popperInstance = xv(Bt, T, Object.assign({}, q, {
placement: Y,
onFirstUpdate: f,
modifiers: Xt
}));
}
function Qn() {
g.popperInstance && (g.popperInstance.destroy(), g.popperInstance = null);
}
function Ot() {
var P = g.props.appendTo, q, Y = K();
g.props.interactive && P === Lf || P === "parent" ? q = Y.parentNode : q = Nf(P, [Y]), q.contains(T) || q.appendChild(T), g.state.isMounted = !0, Xn(), process.env.NODE_ENV !== "production" && on(g.props.interactive && P === at.appendTo && Y.nextElementSibling !== T, ["Interactive tippy element may not be accessible via keyboard", "navigation because it is not directly after the reference element", "in the DOM source order.", `
`, "Using a wrapper <div> or <span> tag around the reference element", "solves this by creating a new parentNode context.", `
`, "Specifying `appendTo: document.body` silences this warning, but it", "assumes you are using a focus management solution to handle", "keyboard navigation.", `
`, "See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "));
}
function It() {
return ts(T.querySelectorAll("[data-tippy-root]"));
}
function gn(P) {
g.clearDelayTimeouts(), P && G("onTrigger", [g, P]), it();
var q = ue(!0), Y = L(), se = Y[0], H = Y[1];
Ht.isTouch && se === "hold" && H && (q = H), q ? r = setTimeout(function() {
g.show();
}, q) : g.show();
}
function ft(P) {
if (g.clearDelayTimeouts(), G("onUntrigger", [g, P]), !g.state.isVisible) {
st();
return;
}
if (!(g.props.trigger.indexOf("mouseenter") >= 0 && g.props.trigger.indexOf("click") >= 0 && ["mouseleave", "mousemove"].indexOf(P.type) >= 0 && s)) {
var q = ue(!1);
q ? o = setTimeout(function() {
g.state.isVisible && g.hide();
}, q) : i = requestAnimationFrame(function() {
g.hide();
});
}
}
function yn() {
g.state.isEnabled = !0;
}
function Zn() {
g.hide(), g.state.isEnabled = !1;
}
function er() {
clearTimeout(r), clearTimeout(o), cancelAnimationFrame(i);
}
function tr(P) {
if (process.env.NODE_ENV !== "production" && on(g.state.isDestroyed, _r("setProps")), !g.state.isDestroyed) {
G("onBeforeUpdate", [g, P]), Gn();
var q = g.props, Y = Up(n, Object.assign({}, q, Hp(P), {
ignoreAttributes: !0
}));
g.props = Y, Tt(), q.interactiveDebounce !== Y.interactiveDebounce && (Jt(), b = Rp(Jn, Y.interactiveDebounce)), q.triggerTarget && !Y.triggerTarget ? $r(q.triggerTarget).forEach(function(se) {
se.removeAttribute("aria-expanded");
}) : Y.triggerTarget && n.removeAttribute("aria-expanded"), ut(), ie(), B && B(q, Y), g.popperInstance && (Xn(), It().forEach(function(se) {
requestAnimationFrame(se._tippy.popperInstance.forceUpdate);
})), G("onAfterUpdate", [g, P]);
}
}
function nr(P) {
g.setProps({
content: P
});
}
function ai() {
process.env.NODE_ENV !== "production" && on(g.state.isDestroyed, _r("show"));
var P = g.state.isVisible, q = g.state.isDestroyed, Y = !g.state.isEnabled, se = Ht.isTouch && !g.props.touch, H = xl(g.props.duration, 0, at.duration);
if (!(P || q || Y || se) && !K().hasAttribute("disabled") && (G("onShow", [g], !1), g.props.onShow(g) !== !1)) {
if (g.state.isVisible = !0, $() && (T.style.visibility = "visible"), ie(), it(), g.state.isMounted || (T.style.transition = "none"), $()) {
var _ = he(), le = _.box, Bt = _.content;
gl([le, Bt], 0);
}
f = function() {
var Xt;
if (!(!g.state.isVisible || c)) {
if (c = !0, T.offsetHeight, T.style.transition = g.props.moveTransition, $() && g.props.animation) {
var ui = he(), Br = ui.box, vn = ui.content;
gl([Br, vn], H), jp([Br, vn], "visible");
}
re(), ut(), Fp(vl, g), (Xt = g.popperInstance) == null || Xt.forceUpdate(), G("onMount", [g]), g.props.animation && $() && et(H, function() {
g.state.isShown = !0, G("onShown", [g]);
});
}
}, Ot();
}
}
function ci() {
process.env.NODE_ENV !== "production" && on(g.state.isDestroyed, _r("hide"));
var P = !g.state.isVisible, q = g.state.isDestroyed, Y = !g.state.isEnabled, se = xl(g.props.duration, 1, at.duration);
if (!(P || q || Y) && (G("onHide", [g], !1), g.props.onHide(g) !== !1)) {
if (g.state.isVisible = !1, g.state.isShown = !1, c = !1, s = !1, $() && (T.style.visibility = "hidden"), Jt(), st(), ie(!0), $()) {
var H = he(), _ = H.box, le = H.content;
g.props.animation && (gl([_, le], se), jp([_, le], "hidden"));
}
re(), ut(), g.props.animation ? $() && fn(se, g.unmount) : g.unmount();
}
}
function pi(P) {
process.env.NODE_ENV !== "production" && on(g.state.isDestroyed, _r("hideWithInteractivity")), ae().addEventListener("mousemove", b), Fp(Si, b), b(P);
}
function Ys() {
process.env.NODE_ENV !== "production" && on(g.state.isDestroyed, _r("unmount")), g.state.isVisible && g.hide(), g.state.isMounted && (Qn(), It().forEach(function(P) {
P._tippy.unmount();
}), T.parentNode && T.parentNode.removeChild(T), vl = vl.filter(function(P) {
return P !== g;
}), g.state.isMounted = !1, G("onHidden", [g]));
}
function ao() {
process.env.NODE_ENV !== "production" && on(g.state.isDestroyed, _r("destroy")), !g.state.isDestroyed && (g.clearDelayTimeouts(), g.unmount(), Gn(), delete n._tippy, g.state.isDestroyed = !0, G("onDestroy", [g]));
}
}
function so(n, e) {
e === void 0 && (e = {});
var t = at.plugins.concat(e.plugins || []);
process.env.NODE_ENV !== "production" && (Rv(n), Ff(e, t)), Lv();
var r = Object.assign({}, e, {
plugins: t
}), o = Ov(n);
if (process.env.NODE_ENV !== "production") {
var i = Ko(r.content), s = o.length > 1;
on(i && s, ["tippy() was passed an Element as the `content` prop, but more than", "one tippy instance was created by this invocation. This means the", "content element will only be appended to the last tippy instance.", `
`, "Instead, pass the .innerHTML of the element, or use a function that", "returns a cloned version of the element instead.", `
`, `1) content: element.innerHTML
`, "2) content: () => element.cloneNode(true)"].join(" "));
}
var l = o.reduce(function(a, c) {
var p = c && Uv(c, r);
return p && a.push(p), a;
}, []);
return Ko(n) ? l[0] : l;
}
so.defaultProps = at;
so.setDefaultProps = jv;
so.currentInput = Ht;
Object.assign({}, Sf, {
effect: function(e) {
var t = e.state, r = {
popper: {
position: t.options.strategy,
left: "0",
top: "0",
margin: "0"
},
arrow: {
position: "absolute"
},
reference: {}
};
Object.assign(t.elements.popper.style, r.popper), t.styles = r, t.elements.arrow && Object.assign(t.elements.arrow.style, r.arrow);
}
});
so.setDefaultProps({
render: Hf
});
class qv {
constructor({ editor: e, element: t, view: r, tippyOptions: o = {}, updateDelay: i = 250, shouldShow: s }) {
this.preventHide = !1, this.shouldShow = ({ view: l, state: a, from: c, to: p }) => {
const { doc: u, selection: f } = a, { empty: h } = f, b = !u.textBetween(c, p).length && Ua(a.selection), m = this.element.contains(document.activeElement);
return !(!(l.hasFocus() || m) || h || b || !this.editor.isEditable);
}, this.mousedownHandler = () => {
this.preventHide = !0;
}, this.dragstartHandler = () => {
this.hide();
}, this.focusHandler = () => {
setTimeout(() => this.update(this.editor.view));
}, this.blurHandler = ({ event: l }) => {
var a;
if (this.preventHide) {
this.preventHide = !1;
return;
}
l != null && l.relatedTarget && (!((a = this.element.parentNode) === null || a === void 0) && a.contains(l.relatedTarget)) || (l == null ? void 0 : l.relatedTarget) !== this.editor.view.dom && this.hide();
}, this.tippyBlurHandler = (l) => {
this.blurHandler({ event: l });
}, this.handleDebouncedUpdate = (l, a) => {
const c = !(a != null && a.selection.eq(l.state.selection)), p = !(a != null && a.doc.eq(l.state.doc));
!c && !p || (this.updateDebounceTimer && clearTimeout(this.updateDebounceTimer), this.updateDebounceTimer = window.setTimeout(() => {
this.updateHandler(l, c, p, a);
}, this.updateDelay));
}, this.updateHandler = (l, a, c, p) => {
var u, f, h;
const { state: b, composing: m } = l, { selection: x } = b;
if (m || !a && !c)
return;
this.createTooltip();
const { ranges: C } = x, S = Math.min(...C.map((T) => T.$from.pos)), g = Math.max(...C.map((T) => T.$to.pos));
if (!((u = this.shouldShow) === null || u === void 0 ? void 0 : u.call(this, {
editor: this.editor,
element: this.element,
view: l,
state: b,
oldState: p,
from: S,
to: g
}))) {
this.hide();
return;
}
(f = this.tippy) === null || f === void 0 || f.setProps({
getReferenceClientRect: ((h = this.tippyOptions) === null || h === void 0 ? void 0 : h.getReferenceClientRect) || (() => {
if (gf(b.selection)) {
let T = l.nodeDOM(S);
if (T) {
const B = T.dataset.nodeViewWrapper ? T : T.querySelector("[data-node-view-wrapper]");
if (B && (T = B.firstChild), T)
return T.getBoundingClientRect();
}
}
return yf(l, S, g);
})
}), this.show();
}, this.editor = e, this.element = t, this.view = r, this.updateDelay = i, s && (this.shouldShow = s), this.element.addEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.view.dom.addEventListener("dragstart", this.dragstartHandler), this.editor.on("focus", this.focusHandler), this.editor.on("blur", this.blurHandler), this.tippyOptions = o, this.element.remove(), this.element.style.visibility = "visible";
}
createTooltip() {
const { element: e } = this.editor.options, t = !!e.parentElement;
this.element.tabIndex = 0, !(this.tippy || !t) && (this.tippy = so(e, {
duration: 0,
getReferenceClientRect: null,
content: this.element,
interactive: !0,
trigger: "manual",
placement: "top",
hideOnClick: "toggle",
...this.tippyOptions
}), this.tippy.popper.firstChild && this.tippy.popper.firstChild.addEventListener("blur", this.tippyBlurHandler));
}
update(e, t) {
const { state: r } = e, o = r.selection.from !== r.selection.to;
if (this.updateDelay > 0 && o) {
this.handleDebouncedUpdate(e, t);
return;
}
const i = !(t != null && t.selection.eq(e.state.selection)), s = !(t != null && t.doc.eq(e.state.doc));
this.updateHandler(e, i, s, t);
}
show() {
var e;
(e = this.tippy) === null || e === void 0 || e.show();
}
hide() {
var e;
(e = this.tippy) === null || e === void 0 || e.hide();
}
destroy() {
var e, t;
!((e = this.tippy) === null || e === void 0) && e.popper.firstChild && this.tippy.popper.firstChild.removeEventListener("blur", this.tippyBlurHandler), (t = this.tippy) === null || t === void 0 || t.destroy(), this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.view.dom.removeEventListener("dragstart", this.dragstartHandler), this.editor.off("focus", this.focusHandler), this.editor.off("blur", this.blurHandler);
}
}
const jf = (n) => new Oe({
key: typeof n.pluginKey == "string" ? new Ze(n.pluginKey) : n.pluginKey,
view: (e) => new qv({ view: e, ...n })
});
je.create({
name: "bubbleMenu",
addOptions() {
return {
element: null,
tippyOptions: {},
pluginKey: "bubbleMenu",
updateDelay: void 0,
shouldShow: null
};
},
addProseMirrorPlugins() {
return this.options.element ? [
jf({
pluginKey: this.options.pluginKey,
editor: this.editor,
element: this.options.element,
tippyOptions: this.options.tippyOptions,
updateDelay: this.options.updateDelay,
shouldShow: this.options.shouldShow
})
] : [];
}
});
class Kv {
getTextContent(e) {
return mf(e, { textSerializers: Va(this.editor.schema) });
}
constructor({ editor: e, element: t, view: r, tippyOptions: o = {}, shouldShow: i }) {
this.preventHide = !1, this.shouldShow = ({ view: s, state: l }) => {
const { selection: a } = l, { $anchor: c, empty: p } = a, u = c.depth === 1, f = c.parent.isTextblock && !c.parent.type.spec.code && !c.parent.textContent && c.parent.childCount === 0 && !this.getTextContent(c.parent);
return !(!s.hasFocus() || !p || !u || !f || !this.editor.isEditable);
}, this.mousedownHandler = () => {
this.preventHide = !0;
}, this.focusHandler = () => {
setTimeout(() => this.update(this.editor.view));
}, this.blurHandler = ({ event: s }) => {
var l;
if (this.preventHide) {
this.preventHide = !1;
return;
}
s != null && s.relatedTarget && (!((l = this.element.parentNode) === null || l === void 0) && l.contains(s.relatedTarget)) || (s == null ? void 0 : s.relatedTarget) !== this.editor.view.dom && this.hide();
}, this.tippyBlurHandler = (s) => {
this.blurHandler({ event: s });
}, this.editor = e, this.element = t, this.view = r, i && (this.shouldShow = i), this.element.addEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.editor.on("focus", this.focusHandler), this.editor.on("blur", this.blurHandler), this.tippyOptions = o, this.element.remove(), this.element.style.visibility = "visible";
}
createTooltip() {
const { element: e } = this.editor.options, t = !!e.parentElement;
this.element.tabIndex = 0, !(this.tippy || !t) && (this.tippy = so(e, {
duration: 0,
getReferenceClientRect: null,
content: this.element,
interactive: !0,
trigger: "manual",
placement: "right",
hideOnClick: "toggle",
...this.tippyOptions
}), this.tippy.popper.firstChild && this.tippy.popper.firstChild.addEventListener("blur", this.tippyBlurHandler));
}
update(e, t) {
var r, o, i;
const { state: s } = e, { doc: l, selection: a } = s, { from: c, to: p } = a;
if (t && t.doc.eq(l) && t.selection.eq(a))
return;
if (this.createTooltip(), !((r = this.shouldShow) === null || r === void 0 ? void 0 : r.call(this, {
editor: this.editor,
view: e,
state: s,
oldState: t
}))) {
this.hide();
return;
}
(o = this.tippy) === null || o === void 0 || o.setProps({
getReferenceClientRect: ((i = this.tippyOptions) === null || i === void 0 ? void 0 : i.getReferenceClientRect) || (() => yf(e, c, p))
}), this.show();
}
show() {
var e;
(e = this.tippy) === null || e === void 0 || e.show();
}
hide() {
var e;
(e = this.tippy) === null || e === void 0 || e.hide();
}
destroy() {
var e, t;
!((e = this.tippy) === null || e === void 0) && e.popper.firstChild && this.tippy.popper.firstChild.removeEventListener("blur", this.tippyBlurHandler), (t = this.tippy) === null || t === void 0 || t.destroy(), this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: !0 }), this.editor.off("focus", this.focusHandler), this.editor.off("blur", this.blurHandler);
}
}
const zf = (n) => new Oe({
key: typeof n.pluginKey == "string" ? new Ze(n.pluginKey) : n.pluginKey,
view: (e) => new Kv({ view: e, ...n })
});
je.create({
name: "floatingMenu",
addOptions() {
return {
element: null,
tippyOptions: {},
pluginKey: "floatingMenu",
shouldShow: null
};
},
addProseMirrorPlugins() {
return this.options.element ? [
zf({
pluginKey: this.options.pluginKey,
editor: this.editor,
element: this.options.element,
tippyOptions: this.options.tippyOptions,
shouldShow: this.options.shouldShow
})
] : [];
}
});
Qe({
name: "BubbleMenu",
props: {
pluginKey: {
type: [String, Object],
default: "bubbleMenu"
},
editor: {
type: Object,
required: !0
},
updateDelay: {
type: Number,
default: void 0
},
tippyOptions: {
type: Object,
default: () => ({})
},
shouldShow: {
type: Function,
default: null
}
},
setup(n, { slots: e }) {
const t = M(null);
return pn(() => {
const { updateDelay: r, editor: o, pluginKey: i, shouldShow: s, tippyOptions: l } = n;
o.registerPlugin(jf({
updateDelay: r,
editor: o,
element: t.value,
pluginKey: i,
shouldShow: s,
tippyOptions: l
}));
}), _s(() => {
const { pluginKey: r, editor: o } = n;
o.unregisterPlugin(r);
}), () => {
var r;
return jn("div", { ref: t }, (r = e.default) === null || r === void 0 ? void 0 : r.call(e));
};
}
});
function Gp(n) {
return Ih((e, t) => ({
get() {
return e(), n;
},
set(r) {
n = r, requestAnimationFrame(() => {
requestAnimationFrame(() => {
t();
});
});
}
}));
}
class Gv extends p0 {
constructor(e = {}) {
return super(e), this.contentComponent = null, this.appContext = null, this.reactiveState = Gp(this.view.state), this.reactiveExtensionStorage = Gp(this.extensionStorage), this.on("beforeTransaction", ({ nextState: t }) => {
this.reactiveState.value = t, this.reactiveExtensionStorage.value = this.extensionStorage;
}), Pn(this);
}
get state() {
return this.reactiveState ? this.reactiveState.value : this.view.state;
}
get storage() {
return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage;
}
/**
* Register a ProseMirror plugin.
*/
registerPlugin(e, t) {
const r = super.registerPlugin(e, t);
return this.reactiveState && (this.reactiveState.value = r), r;
}
/**
* Unregister a ProseMirror plugin.
*/
unregisterPlugin(e) {
const t = super.unregisterPlugin(e);
return this.reactiveState && t && (this.reactiveState.value = t), t;
}
}
const Jv = Qe({
name: "EditorContent",
props: {
editor: {
default: null,
type: Object
}
},
setup(n) {
const e = M(), t = Bu();
return ro(() => {
const r = n.editor;
r && r.options.element && e.value && ce(() => {
if (!e.value || !r.options.element.firstChild)
return;
const o = y(e.value);
e.value.append(...r.options.element.childNodes), r.contentComponent = t.ctx._, t && (r.appContext = {
...t.appContext,
// Vue internally uses prototype chain to forward/shadow injects across the entire component chain
// so don't use object spread operator or 'Object.assign' and just set `provides` as is on editor's appContext
// @ts-expect-error forward instance's 'provides' into appContext
provides: t.provides
}), r.setOptions({
element: o
}), r.createNodeViews();
});
}), _s(() => {
const r = n.editor;
r && (r.contentComponent = null, r.appContext = null);
}), { rootEl: e };
},
render() {
return jn("div", {
ref: (n) => {
this.rootEl = n;
}
});
}
});
Qe({
name: "FloatingMenu",
props: {
pluginKey: {
// TODO: TypeScript breaks :(
// type: [String, Object as PropType<Exclude<FloatingMenuPluginProps['pluginKey'], string>>],
type: null,
default: "floatingMenu"
},
editor: {
type: Object,
required: !0
},
tippyOptions: {
type: Object,
default: () => ({})
},
shouldShow: {
type: Function,
default: null
}
},
setup(n, { slots: e }) {
const t = M(null);
return pn(() => {
const { pluginKey: r, editor: o, tippyOptions: i, shouldShow: s } = n;
o.registerPlugin(zf({
pluginKey: r,
editor: o,
element: t.value,
tippyOptions: i,
shouldShow: s
}));
}), _s(() => {
const { pluginKey: r, editor: o } = n;
o.unregisterPlugin(r);
}), () => {
var r;
return jn("div", { ref: t }, (r = e.default) === null || r === void 0 ? void 0 : r.call(e));
};
}
});
Qe({
name: "NodeViewContent",
props: {
as: {
type: String,
default: "div"
}
},
render() {
return jn(this.as, {
style: {
whiteSpace: "pre-wrap"
},
"data-node-view-content": ""
});
}
});
Qe({
name: "NodeViewWrapper",
props: {
as: {
type: String,
default: "div"
}
},
inject: ["onDragStart", "decorationClasses"],
render() {
var n, e;
return jn(this.as, {
// @ts-ignore
class: this.decorationClasses,
style: {
whiteSpace: "normal"
},
"data-node-view-wrapper": "",
// @ts-ignore (https://github.com/vuejs/vue-next/issues/3031)
onDragstart: this.onDragStart
}, (e = (n = this.$slots).default) === null || e === void 0 ? void 0 : e.call(n));
}
});
const Yv = (n = {}) => {
const e = Dh();
return pn(() => {
e.value = new Gv(n);
}), _s(() => {
var t, r, o;
const i = (t = e.value) === null || t === void 0 ? void 0 : t.options.element, s = i == null ? void 0 : i.cloneNode(!0);
(r = i == null ? void 0 : i.parentNode) === null || r === void 0 || r.replaceChild(s, i), (o = e.value) === null || o === void 0 || o.destroy();
}), e;
}, Xv = /^\s*>\s$/, Qv = Dt.create({
name: "blockquote",
addOptions() {
return {
HTMLAttributes: {}
};
},
content: "block+",
group: "block",
defining: !0,
parseHTML() {
return [
{ tag: "blockquote" }
];
},
renderHTML({ HTMLAttributes: n }) {
return ["blockquote", He(this.options.HTMLAttributes, n), 0];
},
addCommands() {
return {
setBlockquote: () => ({ commands: n }) => n.wrapIn(this.name),
toggleBlockquote: () => ({ commands: n }) => n.toggleWrap(this.name),
unsetBlockquote: () => ({ commands: n }) => n.lift(this.name)
};
},
addKeyboardShortcuts() {
return {
"Mod-Shift-b": () => this.editor.commands.toggleBlockquote()
};
},
addInputRules() {
return [
Wo({
find: Xv,
type: this.type
})
];
}
}), Zv = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/, e1 = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g, t1 = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/, n1 = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g, r1 = un.create({
name: "bold",
addOptions() {
return {
HTMLAttributes: {}
};
},
parseHTML() {
return [
{
tag: "strong"
},
{
tag: "b",
getAttrs: (n) => n.style.fontWeight !== "normal" && null
},
{
style: "font-weight=400",
clearMark: (n) => n.type.name === this.name
},
{
style: "font-weight",
getAttrs: (n) => /^(bold(er)?|[5-9]\d{2,})$/.test(n) && null
}
];
},
renderHTML({ HTMLAttributes: n }) {
return ["strong", He(this.options.HTMLAttributes, n), 0];
},
addCommands() {
return {
setBold: () => ({ commands: n }) => n.setMark(this.name),
toggleBold: () => ({ commands: n }) => n.toggleMark(this.name),
unsetBold: () => ({ commands: n }) => n.unsetMark(this.name)
};
},
addKeyboardShortcuts() {
return {
"Mod-b": () => this.editor.commands.toggleBold(),
"Mod-B": () => this.editor.commands.toggleBold()
};
},
addInputRules() {
return [
Xr({
find: Zv,
type: this.type
}),
Xr({
find: t1,
type: this.type
})
];
},
addPasteRules() {
return [
Cr({
find: e1,
type: this.type
}),
Cr({
find: n1,
type: this.type
})
];
}
}), o1 = "listItem", Jp = "textStyle", Yp = /^\s*([-+*])\s$/, i1 = Dt.create({
name: "bulletList",
addOptions() {
return {
itemTypeName: "listItem",
HTMLAttributes: {},
keepMarks: !1,
keepAttributes: !1
};
},
group: "block list",
content() {
return `${this.options.itemTypeName}+`;
},
parseHTML() {
return [
{ tag: "ul" }
];
},
renderHTML({ HTMLAttributes: n }) {
return ["ul", He(this.options.HTMLAttributes, n), 0];
},
addCommands() {
return {
toggleBulletList: () => ({ commands: n, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(o1, this.editor.getAttributes(Jp)).run() : n.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
};
},
addKeyboardShortcuts() {
return {
"Mod-Shift-8": () => this.editor.commands.toggleBulletList()
};
},
addInputRules() {
let n = Wo({
find: Yp,
type: this.type
});
return (this.options.keepMarks || this.options.keepAttributes) && (n = Wo({
find: Yp,
type: this.type,
keepMarks: this.options.keepMarks,
keepAttributes: this.options.keepAttributes,
getAttributes: () => this.editor.getAttributes(Jp),
editor: this.editor
})), [
n
];
}
}), s1 = /(^|[^`])`([^`]+)`(?!`)/, l1 = /(^|[^`])`([^`]+)`(?!`)/g, a1 = un.create({
name: "code",
addOptions() {
return {
HTMLAttributes: {}
};
},
excludes: "_",
code: !0,
exitable: !0,
parseHTML() {
return [
{ tag: "code" }
];
},
renderHTML({ HTMLAttributes: n }) {
return ["code", He(this.options.HTMLAttributes, n), 0];
},
addCommands() {
return {
setCode: () => ({ commands: n }) => n.setMark(this.name),
toggleCode: () => ({ commands: n }) => n.toggleMark(this.name),
unsetCode: () => ({ commands: n }) => n.unsetMark(this.name)
};
},
addKeyboardShortcuts() {
return {
"Mod-e": () => this.editor.commands.toggleCode()
};
},
addInputRules() {
return [
Xr({
find: s1,
type: this.type
})
];
},
addPasteRules() {
return [
Cr({
find: l1,
type: this.type
})
];
}
}), c1 = /^```([a-z]+)?[\s\n]$/, p1 = /^~~~([a-z]+)?[\s\n]$/, u1 = Dt.create({
name: "codeBlock",
addOptions() {
return {
languageClassPrefix: "language-",
exitOnTripleEnter: !0,
exitOnArrowDown: !0,
defaultLanguage: null,
HTMLAttributes: {}
};
},
content: "text*",
marks: "",
group: "block",
code: !0,
defining: !0,
addAttributes() {
return {
language: {
default: this.options.defaultLanguage,
parseHTML: (n) => {
var e;
const { languageClassPrefix: t } = this.options, i = [...((e = n.firstElementChild) === null || e === void 0 ? void 0 : e.classList) || []].filter((s) => s.startsWith(t)).map((s) => s.replace(t, ""))[0];
return i || null;
},
rendered: !1
}
};
},
parseHTML() {
return [
{
tag: "pre",
preserveWhitespace: "full"
}
];
},
renderHTML({ node: n, HTMLAttributes: e }) {
return [
"pre",
He(this.options.HTMLAttributes, e),
[
"code",
{
class: n.attrs.language ? this.options.languageClassPrefix + n.attrs.language : null
},
0
]
];
},
addCommands() {
return {
setCodeBlock: (n) => ({ commands: e }) => e.setNode(this.name, n),
toggleCodeBlock: (n) => ({ commands: e }) => e.toggleNode(this.name, "paragraph", n)
};
},
addKeyboardShortcuts() {
return {
"Mod-Alt-c": () => this.editor.commands.toggleCodeBlock(),
// remove code block when at start of document or code block is empty
Backspace: () => {
const { empty: n, $anchor: e } = this.editor.state.selection, t = e.pos === 1;
return !n || e.parent.type.name !== this.name ? !1 : t || !e.parent.textContent.length ? this.editor.commands.clearNodes() : !1;
},
// exit node on triple enter
Enter: ({ editor: n }) => {
if (!this.options.exitOnTripleEnter)
return !1;
const { state: e } = n, { selection: t } = e, { $from: r, empty: o } = t;
if (!o || r.parent.type !== this.type)
return !1;
const i = r.parentOffset === r.parent.nodeSize - 2, s = r.parent.textContent.endsWith(`
`);
return !i || !s ? !1 : n.chain().command(({ tr: l }) => (l.delete(r.pos - 2, r.pos), !0)).exitCode().run();
},
// exit node on arrow down
ArrowDown: ({ editor: n }) => {
if (!this.options.exitOnArrowDown)
return !1;
const { state: e } = n, { selection: t, doc: r } = e, { $from: o, empty: i } = t;
if (!i || o.parent.type !== this.type || !(o.parentOffset === o.parent.nodeSize - 2))
return !1;
const l = o.after();
return l === void 0 ? !1 : r.nodeAt(l) ? n.commands.command(({ tr: c }) => (c.setSelection(te.near(r.resolve(l))), !0)) : n.commands.exitCode();
}
};
},
addInputRules() {
return [
ra({
find: c1,
type: this.type,
getAttributes: (n) => ({
language: n[1]
})
}),
ra({
find: p1,
type: this.type,
getAttributes: (n) => ({
language: n[1]
})
})
];
},
addProseMirrorPlugins() {
return [
// this plugin creates a code block for pasted content from VS Code
// we can also detect the copied code language
new Oe({
key: new Ze("codeBlockVSCodeHandler"),
props: {
handlePaste: (n, e) => {
if (!e.clipboardData || this.editor.isActive(this.type.name))
return !1;
const t = e.clipboardData.getData("text/plain"), r = e.clipboardData.getData("vscode-editor-data"), o = r ? JSON.parse(r) : void 0, i = o == null ? void 0 : o.mode;
if (!t || !i)
return !1;
const { tr: s, schema: l } = n.state, a = l.text(t.replace(/\r\n?/g, `
`));
return s.replaceSelectionWith(this.type.create({ language: i }, a)), s.selection.$from.parent.type !== this.type && s.setSelection(Q.near(s.doc.resolve(Math.max(0, s.selection.from - 2)))), s.setMeta("paste", !0), n.dispatch(s), !0;
}
}
})
];
}
}), d1 = Dt.create({
name: "doc",
topNode: !0,
content: "block+"
});
function f1(n = {}) {
return new Oe({
view(e) {
return new h1(e, n);
}
});
}
class h1 {
constructor(e, t) {
var r;
this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (r = t.width) !== null && r !== void 0 ? r : 1, this.color = t.color === !1 ? void 0 : t.color || "black", this.class = t.class, this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((o) => {
let i = (s) => {
this[o](s);
};
return e.dom.addEventListener(o, i), { name: o, handler: i };
});
}
destroy() {
this.handlers.forEach(({ name: e, handler: t }) => this.editorView.dom.removeEventListener(e, t));
}
update(e, t) {
this.cursorPos != null && t.doc != e.state.doc && (this.cursorPos > e.state.doc.content.size ? this.setCursor(null) : this.updateOverlay());
}
setCursor(e) {
e != this.cursorPos && (this.cursorPos = e, e == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
}
updateOverlay() {
let e = this.editorView.state.doc.resolve(this.cursorPos), t = !e.parent.inlineContent, r, o = this.editorView.dom, i = o.getBoundingClientRect(), s = i.width / o.offsetWidth, l = i.height / o.offsetHeight;
if (t) {
let u = e.nodeBefore, f = e.nodeAfter;
if (u || f) {
let h = this.editorView.nodeDOM(this.cursorPos - (u ? u.nodeSize : 0));
if (h) {
let b = h.getBoundingClientRect(), m = u ? b.bottom : b.top;
u && f && (m = (m + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2);
let x = this.width / 2 * l;
r = { left: b.left, right: b.right, top: m - x, bottom: m + x };
}
}
}
if (!r) {
let u = this.editorView.coordsAtPos(this.cursorPos), f = this.width / 2 * s;
r = { left: u.left - f, right: u.left + f, top: u.top, bottom: u.bottom };
}
let a = this.editorView.dom.offsetParent;
this.element || (this.element = a.appendChild(document.createElement("div")), this.class && (this.element.className = this.class), this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", this.color && (this.element.style.backgroundColor = this.color)), this.element.classList.toggle("prosemirror-dropcursor-block", t), this.element.classList.toggle("prosemirror-dropcursor-inline", !t);
let c, p;
if (!a || a == document.body && getComputedStyle(a).position == "static")
c = -pageXOffset, p = -pageYOffset;
else {
let u = a.getBoundingClientRect(), f = u.width / a.offsetWidth, h = u.height / a.offsetHeight;
c = u.left - a.scrollLeft * f, p = u.top - a.scrollTop * h;
}
this.element.style.left = (r.left - c) / s + "px", this.element.style.top = (r.top - p) / l + "px", this.element.style.width = (r.right - r.left) / s + "px", this.element.style.height = (r.bottom - r.top) / l + "px";
}
scheduleRemoval(e) {
clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), e);
}
dragover(e) {
if (!this.editorView.editable)
return;
let t = this.editorView.posAtCoords({ left: e.clientX, top: e.clientY }), r = t && t.inside >= 0 && this.editorView.state.doc.nodeAt(t.inside), o = r && r.type.spec.disableDropCursor, i = typeof o == "function" ? o(this.editorView, t, e) : o;
if (t && !i) {
let s = t.pos;
if (this.editorView.dragging && this.editorView.dragging.slice) {
let l = sd(this.editorView.state.doc, s, this.editorView.dragging.slice);
l != null && (s = l);
}
this.setCursor(s), this.scheduleRemoval(5e3);
}
}
dragend() {
this.scheduleRemoval(20);
}
drop() {
this.scheduleRemoval(20);
}
dragleave(e) {
this.editorView.dom.contains(e.relatedTarget) || this.setCursor(null);
}
}
const b1 = je.create({
name: "dropCursor",
addOptions() {
return {
color: "currentColor",
width: 1,
class: void 0
};
},
addProseMirrorPlugins() {
return [
f1(this.options)
];
}
});
class ve extends te {
/**
Create a gap cursor.
*/
constructor(e) {
super(e, e);
}
map(e, t) {
let r = e.resolve(t.map(this.head));
return ve.valid(r) ? new ve(r) : te.near(r);
}
content() {
return z.empty;
}
eq(e) {
return e instanceof ve && e.head == this.head;
}
toJSON() {
return { type: "gapcursor", pos: this.head };
}
/**
@internal
*/
static fromJSON(e, t) {
if (typeof t.pos != "number")
throw new RangeError("Invalid input for GapCursor.fromJSON");
return new ve(e.resolve(t.pos));
}
/**
@internal
*/
getBookmark() {
return new oc(this.anchor);
}
/**
@internal
*/
static valid(e) {
let t = e.parent;
if (t.isTextblock || !m1(e) || !x1(e))
return !1;
let r = t.type.spec.allowGapCursor;
if (r != null)
return r;
let o = t.contentMatchAt(e.index()).defaultType;
return o && o.isTextblock;
}
/**
@internal
*/
static findGapCursorFrom(e, t, r = !1) {
e: for (; ; ) {
if (!r && ve.valid(e))
return e;
let o = e.pos, i = null;
for (let s = e.depth; ; s--) {
let l = e.node(s);
if (t > 0 ? e.indexAfter(s) < l.childCount : e.index(s) > 0) {
i = l.child(t > 0 ? e.indexAfter(s) : e.index(s) - 1);
break;
} else if (s == 0)
return null;
o += t;
let a = e.doc.resolve(o);
if (ve.valid(a))
return a;
}
for (; ; ) {
let s = t > 0 ? i.firstChild : i.lastChild;
if (!s) {
if (i.isAtom && !i.isText && !J.isSelectable(i)) {
e = e.doc.resolve(o + i.nodeSize * t), r = !1;
continue e;
}
break;
}
i = s, o += t;
let l = e.doc.resolve(o);
if (ve.valid(l))
return l;
}
return null;
}
}
}
ve.prototype.visible = !1;
ve.findFrom = ve.findGapCursorFrom;
te.jsonID("gapcursor", ve);
class oc {
constructor(e) {
this.pos = e;
}
map(e) {
return new oc(e.map(this.pos));
}
resolve(e) {
let t = e.resolve(this.pos);
return ve.valid(t) ? new ve(t) : te.near(t);
}
}
function m1(n) {
for (let e = n.depth; e >= 0; e--) {
let t = n.index(e), r = n.node(e);
if (t == 0) {
if (r.type.spec.isolating)
return !0;
continue;
}
for (let o = r.child(t - 1); ; o = o.lastChild) {
if (o.childCount == 0 && !o.inlineContent || o.isAtom || o.type.spec.isolating)
return !0;
if (o.inlineContent)
return !1;
}
}
return !0;
}
function x1(n) {
for (let e = n.depth; e >= 0; e--) {
let t = n.indexAfter(e), r = n.node(e);
if (t == r.childCount) {
if (r.type.spec.isolating)
return !0;
continue;
}
for (let o = r.child(t); ; o = o.firstChild) {
if (o.childCount == 0 && !o.inlineContent || o.isAtom || o.type.spec.isolating)
return !0;
if (o.inlineContent)
return !1;
}
}
return !0;
}
function g1() {
return new Oe({
props: {
decorations: S1,
createSelectionBetween(n, e, t) {
return e.pos == t.pos && ve.valid(t) ? new ve(t) : null;
},
handleClick: v1,
handleKeyDown: y1,
handleDOMEvents: { beforeinput: w1 }
}
});
}
const y1 = Gd({
ArrowLeft: ki("horiz", -1),
ArrowRight: ki("horiz", 1),
ArrowUp: ki("vert", -1),
ArrowDown: ki("vert", 1)
});
function ki(n, e) {
const t = n == "vert" ? e > 0 ? "down" : "up" : e > 0 ? "right" : "left";
return function(r, o, i) {
let s = r.selection, l = e > 0 ? s.$to : s.$from, a = s.empty;
if (s instanceof Q) {
if (!i.endOfTextblock(t) || l.depth == 0)
return !1;
a = !1, l = r.doc.resolve(e > 0 ? l.after() : l.before());
}
let c = ve.findGapCursorFrom(l, e, a);
return c ? (o && o(r.tr.setSelection(new ve(c))), !0) : !1;
};
}
function v1(n, e, t) {
if (!n || !n.editable)
return !1;
let r = n.state.doc.resolve(e);
if (!ve.valid(r))
return !1;
let o = n.posAtCoords({ left: t.clientX, top: t.clientY });
return o && o.inside > -1 && J.isSelectable(n.state.doc.nodeAt(o.inside)) ? !1 : (n.dispatch(n.state.tr.setSelection(new ve(r))), !0);
}
function w1(n, e) {
if (e.inputType != "insertCompositionText" || !(n.state.selection instanceof ve))
return !1;
let { $from: t } = n.state.selection, r = t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);
if (!r)
return !1;
let o = D.empty;
for (let s = r.length - 1; s >= 0; s--)
o = D.from(r[s].createAndFill(null, o));
let i = n.state.tr.replace(t.pos, t.pos, new z(o, 0, 0));
return i.setSelection(Q.near(i.doc.resolve(t.pos + 1))), n.dispatch(i), !1;
}
function S1(n) {
if (!(n.selection instanceof ve))
return null;
let e = document.createElement("div");
return e.className = "ProseMirror-gapcursor", Te.create(n.doc, [vt.widget(n.selection.head, e, { key: "gapcursor" })]);
}
const k1 = je.create({
name: "gapCursor",
addProseMirrorPlugins() {
return [
g1()
];
},
extendNodeSchema(n) {
var e;
const t = {
name: n.name,
options: n.options,
storage: n.storage
};
return {
allowGapCursor: (e = oe(U(n, "allowGapCursor", t))) !== null && e !== void 0 ? e : null
};
}
}), C1 = Dt.create({
name: "hardBreak",
addOptions() {
return {
keepMarks: !0,
HTMLAttributes: {}
};
},
inline: !0,
group: "inline",
selectable: !1,
linebreakReplacement: !0,
parseHTML() {
return [
{ tag: "br" }
];
},
renderHTML({ HTMLAttributes: n }) {
return ["br", He(this.options.HTMLAttributes, n)];
},
renderText() {
return `
`;
},
addCommands() {
return {
setHardBreak: () => ({ commands: n, chain: e, state: t, editor: r }) => n.first([
() => n.exitCode(),
() => n.command(() => {
const { selection: o, storedMarks: i } = t;
if (o.$from.parent.type.spec.isolating)
return !1;
const { keepMarks: s } = this.options, { splittableMarks: l } = r.extensionManager, a = i || o.$to.parentOffset && o.$from.marks();
return e().insertContent({ type: this.name }).command(({ tr: c, dispatch: p }) => {
if (p && a && s) {
const u = a.filter((f) => l.includes(f.type.name));
c.ensureMarks(u);
}
return !0;
}).run();
})
])
};
},
addKeyboardShortcuts() {
return {
"Mod-Enter": () => this.editor.commands.setHardBreak(),
"Shift-Enter": () => this.editor.commands.setHardBreak()
};
}
}), M1 = Dt.create({
name: "heading",
addOptions() {
return {
levels: [1, 2, 3, 4, 5, 6],
HTMLAttributes: {}
};
},
content: "inline*",
group: "block",
defining: !0,
addAttributes() {
return {
level: {
default: 1,
rendered: !1
}
};
},
parseHTML() {
return this.options.levels.map((n) => ({
tag: `h${n}`,
attrs: { level: n }
}));
},
renderHTML({ node: n, HTMLAttributes: e }) {
return [`h${this.options.levels.includes(n.attrs.level) ? n.attrs.level : this.options.levels[0]}`, He(this.options.HTMLAttributes, e), 0];
},
addCommands() {
return {
setHeading: (n) => ({ commands: e }) => this.options.levels.includes(n.level) ? e.setNode(this.name, n) : !1,
toggleHeading: (n) => ({ commands: e }) => this.options.levels.includes(n.level) ? e.toggleNode(this.name, "paragraph", n) : !1
};
},
addKeyboardShortcuts() {
return this.options.levels.reduce((n, e) => ({
...n,
[`Mod-Alt-${e}`]: () => this.editor.commands.toggleHeading({ level: e })
}), {});
},
addInputRules() {
return this.options.levels.map((n) => ra({
find: new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),
type: this.type,
getAttributes: {
level: n
}
}));
}
});
var ns = 200, Ne = function() {
};
Ne.prototype.append = function(e) {
return e.length ? (e = Ne.from(e), !this.length && e || e.length < ns && this.leafAppend(e) || this.length < ns && e.leafPrepend(this) || this.appendInner(e)) : this;
};
Ne.prototype.prepend = function(e) {
return e.length ? Ne.from(e).append(this) : this;
};
Ne.prototype.appendInner = function(e) {
return new E1(this, e);
};
Ne.prototype.slice = function(e, t) {
return e === void 0 && (e = 0), t === void 0 && (t = this.length), e >= t ? Ne.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, t));
};
Ne.prototype.get = function(e) {
if (!(e < 0 || e >= this.length))
return this.getInner(e);
};
Ne.prototype.forEach = function(e, t, r) {
t === void 0 && (t = 0), r === void 0 && (r = this.length), t <= r ? this.forEachInner(e, t, r, 0) : this.forEachInvertedInner(e, t, r, 0);
};
Ne.prototype.map = function(e, t, r) {
t === void 0 && (t = 0), r === void 0 && (r = this.length);
var o = [];
return this.forEach(function(i, s) {
return o.push(e(i, s));
}, t, r), o;
};
Ne.from = function(e) {
return e instanceof Ne ? e : e && e.length ? new Vf(e) : Ne.empty;
};
var Vf = /* @__PURE__ */ function(n) {
function e(r) {
n.call(this), this.values = r;
}
n && (e.__proto__ = n), e.prototype = Object.create(n && n.prototype), e.prototype.constructor = e;
var t = { length: { configurable: !0 }, depth: { configurable: !0 } };
return e.prototype.flatten = function() {
return this.values;
}, e.prototype.sliceInner = function(o, i) {
return o == 0 && i == this.length ? this : new e(this.values.slice(o, i));
}, e.prototype.getInner = function(o) {
return this.values[o];
}, e.prototype.forEachInner = function(o, i, s, l) {
for (var a = i; a < s; a++)
if (o(this.values[a], l + a) === !1)
return !1;
}, e.prototype.forEachInvertedInner = function(o, i, s, l) {
for (var a = i - 1; a >= s; a--)
if (o(this.values[a], l + a) === !1)
return !1;
}, e.prototype.leafAppend = function(o) {
if (this.length + o.length <= ns)
return new e(this.values.concat(o.flatten()));
}, e.prototype.leafPrepend = function(o) {
if (this.length + o.length <= ns)
return new e(o.flatten().concat(this.values));
}, t.length.get = function() {
return this.values.length;
}, t.depth.get = function() {
return 0;
}, Object.defineProperties(e.prototype, t), e;
}(Ne);
Ne.empty = new Vf([]);
var E1 = /* @__PURE__ */ function(n) {
function e(t, r) {
n.call(this), this.left = t, this.right = r, this.length = t.length + r.length, this.depth = Math.max(t.depth, r.depth) + 1;
}
return n && (e.__proto__ = n), e.prototype = Object.create(n && n.prototype), e.prototype.constructor = e, e.prototype.flatten = function() {
return this.left.flatten().concat(this.right.flatten());
}, e.prototype.getInner = function(r) {
return r < this.left.length ? this.left.get(r) : this.right.get(r - this.left.length);
}, e.prototype.forEachInner = function(r, o, i, s) {
var l = this.left.length;
if (o < l && this.left.forEachInner(r, o, Math.min(i, l), s) === !1 || i > l && this.right.forEachInner(r, Math.max(o - l, 0), Math.min(this.length, i) - l, s + l) === !1)
return !1;
}, e.prototype.forEachInvertedInner = function(r, o, i, s) {
var l = this.left.length;
if (o > l && this.right.forEachInvertedInner(r, o - l, Math.max(i, l) - l, s + l) === !1 || i < l && this.left.forEachInvertedInner(r, Math.min(o, l), i, s) === !1)
return !1;
}, e.prototype.sliceInner = function(r, o) {
if (r == 0 && o == this.length)
return this;
var i = this.left.length;
return o <= i ? this.left.slice(r, o) : r >= i ? this.right.slice(r - i, o - i) : this.left.slice(r, i).append(this.right.slice(0, o - i));
}, e.prototype.leafAppend = function(r) {
var o = this.right.leafAppend(r);
if (o)
return new e(this.left, o);
}, e.prototype.leafPrepend = function(r) {
var o = this.left.leafPrepend(r);
if (o)
return new e(o, this.right);
}, e.prototype.appendInner = function(r) {
return this.left.depth >= Math.max(this.right.depth, r.depth) + 1 ? new e(this.left, new e(this.right, r)) : new e(this, r);
}, e;
}(Ne);
const T1 = 500;
class At {
constructor(e, t) {
this.items = e, this.eventCount = t;
}
// Pop the latest event off the branch's history and apply it
// to a document transform.
popEvent(e, t) {
if (this.eventCount == 0)
return null;
let r = this.items.length;
for (; ; r--)
if (this.items.get(r - 1).selection) {
--r;
break;
}
let o, i;
t && (o = this.remapping(r, this.items.length), i = o.maps.length);
let s = e.tr, l, a, c = [], p = [];
return this.items.forEach((u, f) => {
if (!u.step) {
o || (o = this.remapping(r, f + 1), i = o.maps.length), i--, p.push(u);
return;
}
if (o) {
p.push(new $t(u.map));
let h = u.step.map(o.slice(i)), b;
h && s.maybeStep(h).doc && (b = s.mapping.maps[s.mapping.maps.length - 1], c.push(new $t(b, void 0, void 0, c.length + p.length))), i--, b && o.appendMap(b, i);
} else
s.maybeStep(u.step);
if (u.selection)
return l = o ? u.selection.map(o.slice(i)) : u.selection, a = new At(this.items.slice(0, r).append(p.reverse().concat(c)), this.eventCount - 1), !1;
}, this.items.length, 0), { remaining: a, transform: s, selection: l };
}
// Create a new branch with the given transform added.
addTransform(e, t, r, o) {
let i = [], s = this.eventCount, l = this.items, a = !o && l.length ? l.get(l.length - 1) : null;
for (let p = 0; p < e.steps.length; p++) {
let u = e.steps[p].invert(e.docs[p]), f = new $t(e.mapping.maps[p], u, t), h;
(h = a && a.merge(f)) && (f = h, p ? i.pop() : l = l.slice(0, l.length - 1)), i.push(f), t && (s++, t = void 0), o || (a = f);
}
let c = s - r.depth;
return c > B1 && (l = O1(l, c), s -= c), new At(l.append(i), s);
}
remapping(e, t) {
let r = new $o();
return this.items.forEach((o, i) => {
let s = o.mirrorOffset != null && i - o.mirrorOffset >= e ? r.maps.length - o.mirrorOffset : void 0;
r.appendMap(o.map, s);
}, e, t), r;
}
addMaps(e) {
return this.eventCount == 0 ? this : new At(this.items.append(e.map((t) => new $t(t))), this.eventCount);
}
// When the collab module receives remote changes, the history has
// to know about those, so that it can adjust the steps that were
// rebased on top of the remote changes, and include the position
// maps for the remote changes in its array of items.
rebased(e, t) {
if (!this.eventCount)
return this;
let r = [], o = Math.max(0, this.items.length - t), i = e.mapping, s = e.steps.length, l = this.eventCount;
this.items.forEach((f) => {
f.selection && l--;
}, o);
let a = t;
this.items.forEach((f) => {
let h = i.getMirror(--a);
if (h == null)
return;
s = Math.min(s, h);
let b = i.maps[h];
if (f.step) {
let m = e.steps[h].invert(e.docs[h]), x = f.selection && f.selection.map(i.slice(a + 1, h));
x && l++, r.push(new $t(b, m, x));
} else
r.push(new $t(b));
}, o);
let c = [];
for (let f = t; f < s; f++)
c.push(new $t(i.maps[f]));
let p = this.items.slice(0, o).append(c).append(r), u = new At(p, l);
return u.emptyItemCount() > T1 && (u = u.compress(this.items.length - r.length)), u;
}
emptyItemCount() {
let e = 0;
return this.items.forEach((t) => {
t.step || e++;
}), e;
}
// Compressing a branch means rewriting it to push the air (map-only
// items) out. During collaboration, these naturally accumulate
// because each remote change adds one. The `upto` argument is used
// to ensure that only the items below a given level are compressed,
// because `rebased` relies on a clean, untouched set of items in
// order to associate old items with rebased steps.
compress(e = this.items.length) {
let t = this.remapping(0, e), r = t.maps.length, o = [], i = 0;
return this.items.forEach((s, l) => {
if (l >= e)
o.push(s), s.selection && i++;
else if (s.step) {
let a = s.step.map(t.slice(r)), c = a && a.getMap();
if (r--, c && t.appendMap(c, r), a) {
let p = s.selection && s.selection.map(t.slice(r));
p && i++;
let u = new $t(c.invert(), a, p), f, h = o.length - 1;
(f = o.length && o[h].merge(u)) ? o[h] = f : o.push(u);
}
} else s.map && r--;
}, this.items.length, 0), new At(Ne.from(o.reverse()), i);
}
}
At.empty = new At(Ne.empty, 0);
function O1(n, e) {
let t;
return n.forEach((r, o) => {
if (r.selection && e-- == 0)
return t = o, !1;
}), n.slice(t);
}
class $t {
constructor(e, t, r, o) {
this.map = e, this.step = t, this.selection = r, this.mirrorOffset = o;
}
merge(e) {
if (this.step && e.step && !e.selection) {
let t = e.step.merge(this.step);
if (t)
return new $t(t.getMap().invert(), t, this.selection);
}
}
}
class Cn {
constructor(e, t, r, o, i) {
this.done = e, this.undone = t, this.prevRanges = r, this.prevTime = o, this.prevComposition = i;
}
}
const B1 = 20;
function P1(n, e, t, r) {
let o = t.getMeta(xr), i;
if (o)
return o.historyState;
t.getMeta(L1) && (n = new Cn(n.done, n.undone, null, 0, -1));
let s = t.getMeta("appendedTransaction");
if (t.steps.length == 0)
return n;
if (s && s.getMeta(xr))
return s.getMeta(xr).redo ? new Cn(n.done.addTransform(t, void 0, r, Li(e)), n.undone, Xp(t.mapping.maps), n.prevTime, n.prevComposition) : new Cn(n.done, n.undone.addTransform(t, void 0, r, Li(e)), null, n.prevTime, n.prevComposition);
if (t.getMeta("addToHistory") !== !1 && !(s && s.getMeta("addToHistory") === !1)) {
let l = t.getMeta("composition"), a = n.prevTime == 0 || !s && n.prevComposition != l && (n.prevTime < (t.time || 0) - r.newGroupDelay || !A1(t, n.prevRanges)), c = s ? wl(n.prevRanges, t.mapping) : Xp(t.mapping.maps);
return new Cn(n.done.addTransform(t, a ? e.selection.getBookmark() : void 0, r, Li(e)), At.empty, c, t.time, l ?? n.prevComposition);
} else return (i = t.getMeta("rebased")) ? new Cn(n.done.rebased(t, i), n.undone.rebased(t, i), wl(n.prevRanges, t.mapping), n.prevTime, n.prevComposition) : new Cn(n.done.addMaps(t.mapping.maps), n.undone.addMaps(t.mapping.maps), wl(n.prevRanges, t.mapping), n.prevTime, n.prevComposition);
}
function A1(n, e) {
if (!e)
return !1;
if (!n.docChanged)
return !0;
let t = !1;
return n.mapping.maps[0].forEach((r, o) => {
for (let i = 0; i < e.length; i += 2)
r <= e[i + 1] && o >= e[i] && (t = !0);
}), t;
}
function Xp(n) {
let e = [];
for (let t = n.length - 1; t >= 0 && e.length == 0; t--)
n[t].forEach((r, o, i, s) => e.push(i, s));
return e;
}
function wl(n, e) {
if (!n)
return null;
let t = [];
for (let r = 0; r < n.length; r += 2) {
let o = e.map(n[r], 1), i = e.map(n[r + 1], -1);
o <= i && t.push(o, i);
}
return t;
}
function _1(n, e, t) {
let r = Li(e), o = xr.get(e).spec.config, i = (t ? n.undone : n.done).popEvent(e, r);
if (!i)
return null;
let s = i.selection.resolve(i.transform.doc), l = (t ? n.done : n.undone).addTransform(i.transform, e.selection.getBookmark(), o, r), a = new Cn(t ? l : i.remaining, t ? i.remaining : l, null, 0, -1);
return i.transform.setSelection(s).setMeta(xr, { redo: t, historyState: a });
}
let Sl = !1, Qp = null;
function Li(n) {
let e = n.plugins;
if (Qp != e) {
Sl = !1, Qp = e;
for (let t = 0; t < e.length; t++)
if (e[t].spec.historyPreserveItems) {
Sl = !0;
break;
}
}
return Sl;
}
const xr = new Ze("history"), L1 = new Ze("closeHistory");
function N1(n = {}) {
return n = {
depth: n.depth || 100,
newGroupDelay: n.newGroupDelay || 500
}, new Oe({
key: xr,
state: {
init() {
return new Cn(At.empty, At.empty, null, 0, -1);
},
apply(e, t, r) {
return P1(t, r, e, n);
}
},
config: n,
props: {
handleDOMEvents: {
beforeinput(e, t) {
let r = t.inputType, o = r == "historyUndo" ? Uf : r == "historyRedo" ? qf : null;
return o ? (t.preventDefault(), o(e.state, e.dispatch)) : !1;
}
}
}
});
}
function Wf(n, e) {
return (t, r) => {
let o = xr.getState(t);
if (!o || (n ? o.undone : o.done).eventCount == 0)
return !1;
if (r) {
let i = _1(o, t, n);
i && r(e ? i.scrollIntoView() : i);
}
return !0;
};
}
const Uf = Wf(!1, !0), qf = Wf(!0, !0), D1 = je.create({
name: "history",
addOptions() {
return {
depth: 100,
newGroupDelay: 500
};
},
addCommands() {
return {
undo: () => ({ state: n, dispatch: e }) => Uf(n, e),
redo: () => ({ state: n, dispatch: e }) => qf(n, e)
};
},
addProseMirrorPlugins() {
return [
N1(this.options)
];
},
addKeyboardShortcuts() {
return {
"Mod-z": () => this.editor.commands.undo(),
"Shift-Mod-z": () => this.editor.commands.redo(),
"Mod-y": () => this.editor.commands.redo(),
// Russian keyboard layouts
"Mod-я": () => this.editor.commands.undo(),
"Shift-Mod-я": () => this.editor.commands.redo()
};
}
}), I1 = Dt.create({
name: "horizontalRule",
addOptions() {
return {
HTMLAttributes: {}
};
},
group: "block",
parseHTML() {
return [{ tag: "hr" }];
},
renderHTML({ HTMLAttributes: n }) {
return ["hr", He(this.options.HTMLAttributes, n)];
},
addCommands() {
return {
setHorizontalRule: () => ({ chain: n, state: e }) => {
if (!d0(e, e.schema.nodes[this.name]))
return !1;
const { selection: t } = e, { $from: r, $to: o } = t, i = n();
return r.parentOffset === 0 ? i.insertContentAt({
from: Math.max(r.pos - 1, 0),
to: o.pos
}, {
type: this.name
}) : gf(t) ? i.insertContentAt(o.pos, {
type: this.name
}) : i.insertContent({ type: this.name }), i.command(({ tr: s, dispatch: l }) => {
var a;
if (l) {
const { $to: c } = s.selection, p = c.end();
if (c.nodeAfter)
c.nodeAfter.isTextblock ? s.setSelection(Q.create(s.doc, c.pos + 1)) : c.nodeAfter.isBlock ? s.setSelection(J.create(s.doc, c.pos)) : s.setSelection(Q.create(s.doc, c.pos));
else {
const u = (a = c.parent.type.contentMatch.defaultType) === null || a === void 0 ? void 0 : a.create();
u && (s.insert(p, u), s.setSelection(Q.create(s.doc, p + 1)));
}
s.scrollIntoView();
}
return !0;
}).run();
}
};
},
addInputRules() {
return [
u0({
find: /^(?:---|—-|___\s|\*\*\*\s)$/,
type: this.type
})
];
}
}), $1 = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/, R1 = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g, F1 = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/, H1 = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g, j1 = un.create({
name: "italic",
addOptions() {
return {
HTMLAttributes: {}
};
},
parseHTML() {
return [
{
tag: "em"
},
{
tag: "i",
getAttrs: (n) => n.style.fontStyle !== "normal" && null
},
{
style: "font-style=normal",
clearMark: (n) => n.type.name === this.name
},
{
style: "font-style=italic"
}
];
},
renderHTML({ HTMLAttributes: n }) {
return ["em", He(this.options.HTMLAttributes, n), 0];
},
addCommands() {
return {
setItalic: () => ({ commands: n }) => n.setMark(this.name),
toggleItalic: () => ({ commands: n }) => n.toggleMark(this.name),
unsetItalic: () => ({ commands: n }) => n.unsetMark(this.name)
};
},
addKeyboardShortcuts() {
return {
"Mod-i": () => this.editor.commands.toggleItalic(),
"Mod-I": () => this.editor.commands.toggleItalic()
};
},
addInputRules() {
return [
Xr({
find: $1,
type: this.type
}),
Xr({
find: F1,
type: this.type
})
];
},
addPasteRules() {
return [
Cr({
find: R1,
type: this.type
}),
Cr({
find: H1,
type: this.type
})
];
}
}), z1 = Dt.create({
name: "listItem",
addOptions() {
return {
HTMLAttributes: {},
bulletListTypeName: "bulletList",
orderedListTypeName: "orderedList"
};
},
content: "paragraph block*",
defining: !0,
parseHTML() {
return [
{
tag: "li"
}
];
},
renderHTML({ HTMLAttributes: n }) {
return ["li", He(this.options.HTMLAttributes, n), 0];
},
addKeyboardShortcuts() {
return {
Enter: () => this.editor.commands.splitListItem(this.name),
Tab: () => this.editor.commands.sinkListItem(this.name),
"Shift-Tab": () => this.editor.commands.liftListItem(this.name)
};
}
}), V1 = "listItem", Zp = "textStyle", eu = /^(\d+)\.\s$/, W1 = Dt.create({
name: "orderedList",
addOptions() {
return {
itemTypeName: "listItem",
HTMLAttributes: {},
keepMarks: !1,
keepAttributes: !1
};
},
group: "block list",
content() {
return `${this.options.itemTypeName}+`;
},
addAttributes() {
return {
start: {
default: 1,
parseHTML: (n) => n.hasAttribute("start") ? parseInt(n.getAttribute("start") || "", 10) : 1
},
type: {
default: null,
parseHTML: (n) => n.getAttribute("type")
}
};
},
parseHTML() {
return [
{
tag: "ol"
}
];
},
renderHTML({ HTMLAttributes: n }) {
const { start: e, ...t } = n;
return e === 1 ? ["ol", He(this.options.HTMLAttributes, t), 0] : ["ol", He(this.options.HTMLAttributes, n), 0];
},
addCommands() {
return {
toggleOrderedList: () => ({ commands: n, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(V1, this.editor.getAttributes(Zp)).run() : n.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
};
},
addKeyboardShortcuts() {
return {
"Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
};
},
addInputRules() {
let n = Wo({
find: eu,
type: this.type,
getAttributes: (e) => ({ start: +e[1] }),
joinPredicate: (e, t) => t.childCount + t.attrs.start === +e[1]
});
return (this.options.keepMarks || this.options.keepAttributes) && (n = Wo({
find: eu,
type: this.type,
keepMarks: this.options.keepMarks,
keepAttributes: this.options.keepAttributes,
getAttributes: (e) => ({ start: +e[1], ...this.editor.getAttributes(Zp) }),
joinPredicate: (e, t) => t.childCount + t.attrs.start === +e[1],
editor: this.editor
})), [
n
];
}
}), U1 = Dt.create({
name: "paragraph",
priority: 1e3,
addOptions() {
return {
HTMLAttributes: {}
};
},
group: "block",
content: "inline*",
parseHTML() {
return [
{ tag: "p" }
];
},
renderHTML({ HTMLAttributes: n }) {
return ["p", He(this.options.HTMLAttributes, n), 0];
},
addCommands() {
return {
setParagraph: () => ({ commands: n }) => n.setNode(this.name)
};
},
addKeyboardShortcuts() {
return {
"Mod-Alt-0": () => this.editor.commands.setParagraph()
};
}
}), q1 = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, K1 = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, G1 = un.create({
name: "strike",
addOptions() {
return {
HTMLAttributes: {}
};
},
parseHTML() {
return [
{
tag: "s"
},
{
tag: "del"
},
{
tag: "strike"
},
{
style: "text-decoration",
consuming: !1,
getAttrs: (n) => n.includes("line-through") ? {} : !1
}
];
},
renderHTML({ HTMLAttributes: n }) {
return ["s", He(this.options.HTMLAttributes, n), 0];
},
addCommands() {
return {
setStrike: () => ({ commands: n }) => n.setMark(this.name),
toggleStrike: () => ({ commands: n }) => n.toggleMark(this.name),
unsetStrike: () => ({ commands: n }) => n.unsetMark(this.name)
};
},
addKeyboardShortcuts() {
return {
"Mod-Shift-s": () => this.editor.commands.toggleStrike()
};
},
addInputRules() {
return [
Xr({
find: q1,
type: this.type
})
];
},
addPasteRules() {
return [
Cr({
find: K1,
type: this.type
})
];
}
}), J1 = Dt.create({
name: "text",
group: "inline"
}), Y1 = je.create({
name: "starterKit",
addExtensions() {
const n = [];
return this.options.bold !== !1 && n.push(r1.configure(this.options.bold)), this.options.blockquote !== !1 && n.push(Qv.configure(this.options.blockquote)), this.options.bulletList !== !1 && n.push(i1.configure(this.options.bulletList)), this.options.code !== !1 && n.push(a1.configure(this.options.code)), this.options.codeBlock !== !1 && n.push(u1.configure(this.options.codeBlock)), this.options.document !== !1 && n.push(d1.configure(this.options.document)), this.options.dropcursor !== !1 && n.push(b1.configure(this.options.dropcursor)), this.options.gapcursor !== !1 && n.push(k1.configure(this.options.gapcursor)), this.options.hardBreak !== !1 && n.push(C1.configure(this.options.hardBreak)), this.options.heading !== !1 && n.push(M1.configure(this.options.heading)), this.options.history !== !1 && n.push(D1.configure(this.options.history)), this.options.horizontalRule !== !1 && n.push(I1.configure(this.options.horizontalRule)), this.options.italic !== !1 && n.push(j1.configure(this.options.italic)), this.options.listItem !== !1 && n.push(z1.configure(this.options.listItem)), this.options.orderedList !== !1 && n.push(W1.configure(this.options.orderedList)), this.options.paragraph !== !1 && n.push(U1.configure(this.options.paragraph)), this.options.strike !== !1 && n.push(G1.configure(this.options.strike)), this.options.text !== !1 && n.push(J1.configure(this.options.text)), n;
}
}), X1 = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2", Q1 = "ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2", no = (n, e) => {
for (const t in e)
n[t] = e[t];
return n;
}, pa = "numeric", ua = "ascii", da = "alpha", Oo = "asciinumeric", go = "alphanumeric", fa = "domain", Kf = "emoji", Z1 = "scheme", ew = "slashscheme", kl = "whitespace";
function tw(n, e) {
return n in e || (e[n] = []), e[n];
}
function ur(n, e, t) {
e[pa] && (e[Oo] = !0, e[go] = !0), e[ua] && (e[Oo] = !0, e[da] = !0), e[Oo] && (e[go] = !0), e[da] && (e[go] = !0), e[go] && (e[fa] = !0), e[Kf] && (e[fa] = !0);
for (const r in e) {
const o = tw(r, t);
o.indexOf(n) < 0 && o.push(n);
}
}
function nw(n, e) {
const t = {};
for (const r in e)
e[r].indexOf(n) >= 0 && (t[r] = !0);
return t;
}
function tt(n = null) {
this.j = {}, this.jr = [], this.jd = null, this.t = n;
}
tt.groups = {};
tt.prototype = {
accepts() {
return !!this.t;
},
/**
* Follow an existing transition from the given input to the next state.
* Does not mutate.
* @param {string} input character or token type to transition on
* @returns {?State<T>} the next state, if any
*/
go(n) {
const e = this, t = e.j[n];
if (t)
return t;
for (let r = 0; r < e.jr.length; r++) {
const o = e.jr[r][0], i = e.jr[r][1];
if (i && o.test(n))
return i;
}
return e.jd;
},
/**
* Whether the state has a transition for the given input. Set the second
* argument to true to only look for an exact match (and not a default or
* regular-expression-based transition)
* @param {string} input
* @param {boolean} exactOnly
*/
has(n, e = !1) {
return e ? n in this.j : !!this.go(n);
},
/**
* Short for "transition all"; create a transition from the array of items
* in the given list to the same final resulting state.
* @param {string | string[]} inputs Group of inputs to transition on
* @param {Transition<T> | State<T>} [next] Transition options
* @param {Flags} [flags] Collections flags to add token to
* @param {Collections<T>} [groups] Master list of token groups
*/
ta(n, e, t, r) {
for (let o = 0; o < n.length; o++)
this.tt(n[o], e, t, r);
},
/**
* Short for "take regexp transition"; defines a transition for this state
* when it encounters a token which matches the given regular expression
* @param {RegExp} regexp Regular expression transition (populate first)
* @param {T | State<T>} [next] Transition options
* @param {Flags} [flags] Collections flags to add token to
* @param {Collections<T>} [groups] Master list of token groups
* @returns {State<T>} taken after the given input
*/
tr(n, e, t, r) {
r = r || tt.groups;
let o;
return e && e.j ? o = e : (o = new tt(e), t && r && ur(e, t, r)), this.jr.push([n, o]), o;
},
/**
* Short for "take transitions", will take as many sequential transitions as
* the length of the given input and returns the
* resulting final state.
* @param {string | string[]} input
* @param {T | State<T>} [next] Transition options
* @param {Flags} [flags] Collections flags to add token to
* @param {Collections<T>} [groups] Master list of token groups
* @returns {State<T>} taken after the given input
*/
ts(n, e, t, r) {
let o = this;
const i = n.length;
if (!i)
return o;
for (let s = 0; s < i - 1; s++)
o = o.tt(n[s]);
return o.tt(n[i - 1], e, t, r);
},
/**
* Short for "take transition", this is a method for building/working with
* state machines.
*
* If a state already exists for the given input, returns it.
*
* If a token is specified, that state will emit that token when reached by
* the linkify engine.
*
* If no state exists, it will be initialized with some default transitions
* that resemble existing default transitions.
*
* If a state is given for the second argument, that state will be
* transitioned to on the given input regardless of what that input
* previously did.
*
* Specify a token group flags to define groups that this token belongs to.
* The token will be added to corresponding entires in the given groups
* object.
*
* @param {string} input character, token type to transition on
* @param {T | State<T>} [next] Transition options
* @param {Flags} [flags] Collections flags to add token to
* @param {Collections<T>} [groups] Master list of groups
* @returns {State<T>} taken after the given input
*/
tt(n, e, t, r) {
r = r || tt.groups;
const o = this;
if (e && e.j)
return o.j[n] = e, e;
const i = e;
let s, l = o.go(n);
if (l ? (s = new tt(), no(s.j, l.j), s.jr.push.apply(s.jr, l.jr), s.jd = l.jd, s.t = l.t) : s = new tt(), i) {
if (r)
if (s.t && typeof s.t == "string") {
const a = no(nw(s.t, r), t);
ur(i, a, r);
} else t && ur(i, t, r);
s.t = i;
}
return o.j[n] = s, s;
}
};
const ne = (n, e, t, r, o) => n.ta(e, t, r, o), ye = (n, e, t, r, o) => n.tr(e, t, r, o), tu = (n, e, t, r, o) => n.ts(e, t, r, o), R = (n, e, t, r, o) => n.tt(e, t, r, o), nn = "WORD", ha = "UWORD", Gf = "ASCIINUMERICAL", Jf = "ALPHANUMERICAL", Jo = "LOCALHOST", ba = "TLD", ma = "UTLD", Ni = "SCHEME", Rr = "SLASH_SCHEME", ic = "NUM", xa = "WS", sc = "NL", Bo = "OPENBRACE", Po = "CLOSEBRACE", rs = "OPENBRACKET", is = "CLOSEBRACKET", ss = "OPENPAREN", ls = "CLOSEPAREN", as = "OPENANGLEBRACKET", cs = "CLOSEANGLEBRACKET", ps = "FULLWIDTHLEFTPAREN", us = "FULLWIDTHRIGHTPAREN", ds = "LEFTCORNERBRACKET", fs = "RIGHTCORNERBRACKET", hs = "LEFTWHITECORNERBRACKET", bs = "RIGHTWHITECORNERBRACKET", ms = "FULLWIDTHLESSTHAN", xs = "FULLWIDTHGREATERTHAN", gs = "AMPERSAND", ys = "APOSTROPHE", vs = "ASTERISK", Mn = "AT", ws = "BACKSLASH", Ss = "BACKTICK", ks = "CARET", Bn = "COLON", lc = "COMMA", Cs = "DOLLAR", Rt = "DOT", Ms = "EQUALS", ac = "EXCLAMATION", mt = "HYPHEN", Ao = "PERCENT", Es = "PIPE", Ts = "PLUS", Os = "POUND", _o = "QUERY", cc = "QUOTE", Yf = "FULLWIDTHMIDDLEDOT", pc = "SEMI", Ft = "SLASH", Lo = "TILDE", Bs = "UNDERSCORE", Xf = "EMOJI", Ps = "SYM";
var Qf = /* @__PURE__ */ Object.freeze({
__proto__: null,
ALPHANUMERICAL: Jf,
AMPERSAND: gs,
APOSTROPHE: ys,
ASCIINUMERICAL: Gf,
ASTERISK: vs,
AT: Mn,
BACKSLASH: ws,
BACKTICK: Ss,
CARET: ks,
CLOSEANGLEBRACKET: cs,
CLOSEBRACE: Po,
CLOSEBRACKET: is,
CLOSEPAREN: ls,
COLON: Bn,
COMMA: lc,
DOLLAR: Cs,
DOT: Rt,
EMOJI: Xf,
EQUALS: Ms,
EXCLAMATION: ac,
FULLWIDTHGREATERTHAN: xs,
FULLWIDTHLEFTPAREN: ps,
FULLWIDTHLESSTHAN: ms,
FULLWIDTHMIDDLEDOT: Yf,
FULLWIDTHRIGHTPAREN: us,
HYPHEN: mt,
LEFTCORNERBRACKET: ds,
LEFTWHITECORNERBRACKET: hs,
LOCALHOST: Jo,
NL: sc,
NUM: ic,
OPENANGLEBRACKET: as,
OPENBRACE: Bo,
OPENBRACKET: rs,
OPENPAREN: ss,
PERCENT: Ao,
PIPE: Es,
PLUS: Ts,
POUND: Os,
QUERY: _o,
QUOTE: cc,
RIGHTCORNERBRACKET: fs,
RIGHTWHITECORNERBRACKET: bs,
SCHEME: Ni,
SEMI: pc,
SLASH: Ft,
SLASH_SCHEME: Rr,
SYM: Ps,
TILDE: Lo,
TLD: ba,
UNDERSCORE: Bs,
UTLD: ma,
UWORD: ha,
WORD: nn,
WS: xa
});
const Zt = /[a-z]/, fo = new RegExp("\\p{L}", "u"), Cl = new RegExp("\\p{Emoji}", "u"), en = /\d/, Ml = /\s/, nu = "\r", El = `
`, rw = "️", ow = "", Tl = "";
let Ci = null, Mi = null;
function iw(n = []) {
const e = {};
tt.groups = e;
const t = new tt();
Ci == null && (Ci = ru(X1)), Mi == null && (Mi = ru(Q1)), R(t, "'", ys), R(t, "{", Bo), R(t, "}", Po), R(t, "[", rs), R(t, "]", is), R(t, "(", ss), R(t, ")", ls), R(t, "<", as), R(t, ">", cs), R(t, "(", ps), R(t, ")", us), R(t, "「", ds), R(t, "」", fs), R(t, "『", hs), R(t, "』", bs), R(t, "<", ms), R(t, ">", xs), R(t, "&", gs), R(t, "*", vs), R(t, "@", Mn), R(t, "`", Ss), R(t, "^", ks), R(t, ":", Bn), R(t, ",", lc), R(t, "$", Cs), R(t, ".", Rt), R(t, "=", Ms), R(t, "!", ac), R(t, "-", mt), R(t, "%", Ao), R(t, "|", Es), R(t, "+", Ts), R(t, "#", Os), R(t, "?", _o), R(t, '"', cc), R(t, "/", Ft), R(t, ";", pc), R(t, "~", Lo), R(t, "_", Bs), R(t, "\\", ws), R(t, "・", Yf);
const r = ye(t, en, ic, {
[pa]: !0
});
ye(r, en, r);
const o = ye(r, Zt, Gf, {
[Oo]: !0
}), i = ye(r, fo, Jf, {
[go]: !0
}), s = ye(t, Zt, nn, {
[ua]: !0
});
ye(s, en, o), ye(s, Zt, s), ye(o, en, o), ye(o, Zt, o);
const l = ye(t, fo, ha, {
[da]: !0
});
ye(l, Zt), ye(l, en, i), ye(l, fo, l), ye(i, en, i), ye(i, Zt), ye(i, fo, i);
const a = R(t, El, sc, {
[kl]: !0
}), c = R(t, nu, xa, {
[kl]: !0
}), p = ye(t, Ml, xa, {
[kl]: !0
});
R(t, Tl, p), R(c, El, a), R(c, Tl, p), ye(c, Ml, p), R(p, nu), R(p, El), ye(p, Ml, p), R(p, Tl, p);
const u = ye(t, Cl, Xf, {
[Kf]: !0
});
R(u, "#"), ye(u, Cl, u), R(u, rw, u);
const f = R(u, ow);
R(f, "#"), ye(f, Cl, u);
const h = [[Zt, s], [en, o]], b = [[Zt, null], [fo, l], [en, i]];
for (let m = 0; m < Ci.length; m++)
wn(t, Ci[m], ba, nn, h);
for (let m = 0; m < Mi.length; m++)
wn(t, Mi[m], ma, ha, b);
ur(ba, {
tld: !0,
ascii: !0
}, e), ur(ma, {
utld: !0,
alpha: !0
}, e), wn(t, "file", Ni, nn, h), wn(t, "mailto", Ni, nn, h), wn(t, "http", Rr, nn, h), wn(t, "https", Rr, nn, h), wn(t, "ftp", Rr, nn, h), wn(t, "ftps", Rr, nn, h), ur(Ni, {
scheme: !0,
ascii: !0
}, e), ur(Rr, {
slashscheme: !0,
ascii: !0
}, e), n = n.sort((m, x) => m[0] > x[0] ? 1 : -1);
for (let m = 0; m < n.length; m++) {
const x = n[m][0], C = n[m][1] ? {
[Z1]: !0
} : {
[ew]: !0
};
x.indexOf("-") >= 0 ? C[fa] = !0 : Zt.test(x) ? en.test(x) ? C[Oo] = !0 : C[ua] = !0 : C[pa] = !0, tu(t, x, x, C);
}
return tu(t, "localhost", Jo, {
ascii: !0
}), t.jd = new tt(Ps), {
start: t,
tokens: no({
groups: e
}, Qf)
};
}
function Zf(n, e) {
const t = sw(e.replace(/[A-Z]/g, (l) => l.toLowerCase())), r = t.length, o = [];
let i = 0, s = 0;
for (; s < r; ) {
let l = n, a = null, c = 0, p = null, u = -1, f = -1;
for (; s < r && (a = l.go(t[s])); )
l = a, l.accepts() ? (u = 0, f = 0, p = l) : u >= 0 && (u += t[s].length, f++), c += t[s].length, i += t[s].length, s++;
i -= u, s -= f, c -= u, o.push({
t: p.t,
// token type/name
v: e.slice(i - c, i),
// string value
s: i - c,
// start index
e: i
// end index (excluding)
});
}
return o;
}
function sw(n) {
const e = [], t = n.length;
let r = 0;
for (; r < t; ) {
let o = n.charCodeAt(r), i, s = o < 55296 || o > 56319 || r + 1 === t || (i = n.charCodeAt(r + 1)) < 56320 || i > 57343 ? n[r] : n.slice(r, r + 2);
e.push(s), r += s.length;
}
return e;
}
function wn(n, e, t, r, o) {
let i;
const s = e.length;
for (let l = 0; l < s - 1; l++) {
const a = e[l];
n.j[a] ? i = n.j[a] : (i = new tt(r), i.jr = o.slice(), n.j[a] = i), n = i;
}
return i = new tt(t), i.jr = o.slice(), n.j[e[s - 1]] = i, i;
}
function ru(n) {
const e = [], t = [];
let r = 0, o = "0123456789";
for (; r < n.length; ) {
let i = 0;
for (; o.indexOf(n[r + i]) >= 0; )
i++;
if (i > 0) {
e.push(t.join(""));
for (let s = parseInt(n.substring(r, r + i), 10); s > 0; s--)
t.pop();
r += i;
} else
t.push(n[r]), r++;
}
return e;
}
const Yo = {
defaultProtocol: "http",
events: null,
format: ou,
formatHref: ou,
nl2br: !1,
tagName: "a",
target: null,
rel: null,
validate: !0,
truncate: 1 / 0,
className: null,
attributes: null,
ignoreTags: [],
render: null
};
function uc(n, e = null) {
let t = no({}, Yo);
n && (t = no(t, n instanceof uc ? n.o : n));
const r = t.ignoreTags, o = [];
for (let i = 0; i < r.length; i++)
o.push(r[i].toUpperCase());
this.o = t, e && (this.defaultRender = e), this.ignoreTags = o;
}
uc.prototype = {
o: Yo,
/**
* @type string[]
*/
ignoreTags: [],
/**
* @param {IntermediateRepresentation} ir
* @returns {any}
*/
defaultRender(n) {
return n;
},
/**
* Returns true or false based on whether a token should be displayed as a
* link based on the user options.
* @param {MultiToken} token
* @returns {boolean}
*/
check(n) {
return this.get("validate", n.toString(), n);
},
// Private methods
/**
* Resolve an option's value based on the value of the option and the given
* params. If operator and token are specified and the target option is
* callable, automatically calls the function with the given argument.
* @template {keyof Opts} K
* @param {K} key Name of option to use
* @param {string} [operator] will be passed to the target option if it's a
* function. If not specified, RAW function value gets returned
* @param {MultiToken} [token] The token from linkify.tokenize
* @returns {Opts[K] | any}
*/
get(n, e, t) {
const r = e != null;
let o = this.o[n];
return o && (typeof o == "object" ? (o = t.t in o ? o[t.t] : Yo[n], typeof o == "function" && r && (o = o(e, t))) : typeof o == "function" && r && (o = o(e, t.t, t)), o);
},
/**
* @template {keyof Opts} L
* @param {L} key Name of options object to use
* @param {string} [operator]
* @param {MultiToken} [token]
* @returns {Opts[L] | any}
*/
getObj(n, e, t) {
let r = this.o[n];
return typeof r == "function" && e != null && (r = r(e, t.t, t)), r;
},
/**
* Convert the given token to a rendered element that may be added to the
* calling-interface's DOM
* @param {MultiToken} token Token to render to an HTML element
* @returns {any} Render result; e.g., HTML string, DOM element, React
* Component, etc.
*/
render(n) {
const e = n.render(this);
return (this.get("render", null, n) || this.defaultRender)(e, n.t, n);
}
};
function ou(n) {
return n;
}
function eh(n, e) {
this.t = "token", this.v = n, this.tk = e;
}
eh.prototype = {
isLink: !1,
/**
* Return the string this token represents.
* @return {string}
*/
toString() {
return this.v;
},
/**
* What should the value for this token be in the `href` HTML attribute?
* Returns the `.toString` value by default.
* @param {string} [scheme]
* @return {string}
*/
toHref(n) {
return this.toString();
},
/**
* @param {Options} options Formatting options
* @returns {string}
*/
toFormattedString(n) {
const e = this.toString(), t = n.get("truncate", e, this), r = n.get("format", e, this);
return t && r.length > t ? r.substring(0, t) + "…" : r;
},
/**
*
* @param {Options} options
* @returns {string}
*/
toFormattedHref(n) {
return n.get("formatHref", this.toHref(n.get("defaultProtocol")), this);
},
/**
* The start index of this token in the original input string
* @returns {number}
*/
startIndex() {
return this.tk[0].s;
},
/**
* The end index of this token in the original input string (up to this
* index but not including it)
* @returns {number}
*/
endIndex() {
return this.tk[this.tk.length - 1].e;
},
/**
Returns an object of relevant values for this token, which includes keys
* type - Kind of token ('url', 'email', etc.)
* value - Original text
* href - The value that should be added to the anchor tag's href
attribute
@method toObject
@param {string} [protocol] `'http'` by default
*/
toObject(n = Yo.defaultProtocol) {
return {
type: this.t,
value: this.toString(),
isLink: this.isLink,
href: this.toHref(n),
start: this.startIndex(),
end: this.endIndex()
};
},
/**
*
* @param {Options} options Formatting option
*/
toFormattedObject(n) {
return {
type: this.t,
value: this.toFormattedString(n),
isLink: this.isLink,
href: this.toFormattedHref(n),
start: this.startIndex(),
end: this.endIndex()
};
},
/**
* Whether this token should be rendered as a link according to the given options
* @param {Options} options
* @returns {boolean}
*/
validate(n) {
return n.get("validate", this.toString(), this);
},
/**
* Return an object that represents how this link should be rendered.
* @param {Options} options Formattinng options
*/
render(n) {
const e = this, t = this.toHref(n.get("defaultProtocol")), r = n.get("formatHref", t, this), o = n.get("tagName", t, e), i = this.toFormattedString(n), s = {}, l = n.get("className", t, e), a = n.get("target", t, e), c = n.get("rel", t, e), p = n.getObj("attributes", t, e), u = n.getObj("events", t, e);
return s.href = r, l && (s.class = l), a && (s.target = a), c && (s.rel = c), p && no(s, p), {
tagName: o,
attributes: s,
content: i,
eventListeners: u
};
}
};
function Ks(n, e) {
class t extends eh {
constructor(o, i) {
super(o, i), this.t = n;
}
}
for (const r in e)
t.prototype[r] = e[r];
return t.t = n, t;
}
const iu = Ks("email", {
isLink: !0,
toHref() {
return "mailto:" + this.toString();
}
}), su = Ks("text"), lw = Ks("nl"), Ei = Ks("url", {
isLink: !0,
/**
Lowercases relevant parts of the domain and adds the protocol if
required. Note that this will not escape unsafe HTML characters in the
URL.
@param {string} [scheme] default scheme (e.g., 'https')
@return {string} the full href
*/
toHref(n = Yo.defaultProtocol) {
return this.hasProtocol() ? this.v : `${n}://${this.v}`;
},
/**
* Check whether this URL token has a protocol
* @return {boolean}
*/
hasProtocol() {
const n = this.tk;
return n.length >= 2 && n[0].t !== Jo && n[1].t === Bn;
}
}), ht = (n) => new tt(n);
function aw({
groups: n
}) {
const e = n.domain.concat([gs, vs, Mn, ws, Ss, ks, Cs, Ms, mt, ic, Ao, Es, Ts, Os, Ft, Ps, Lo, Bs]), t = [ys, Bn, lc, Rt, ac, Ao, _o, cc, pc, as, cs, Bo, Po, is, rs, ss, ls, ps, us, ds, fs, hs, bs, ms, xs], r = [gs, ys, vs, ws, Ss, ks, Cs, Ms, mt, Bo, Po, Ao, Es, Ts, Os, _o, Ft, Ps, Lo, Bs], o = ht(), i = R(o, Lo);
ne(i, r, i), ne(i, n.domain, i);
const s = ht(), l = ht(), a = ht();
ne(o, n.domain, s), ne(o, n.scheme, l), ne(o, n.slashscheme, a), ne(s, r, i), ne(s, n.domain, s);
const c = R(s, Mn);
R(i, Mn, c), R(l, Mn, c), R(a, Mn, c);
const p = R(i, Rt);
ne(p, r, i), ne(p, n.domain, i);
const u = ht();
ne(c, n.domain, u), ne(u, n.domain, u);
const f = R(u, Rt);
ne(f, n.domain, u);
const h = ht(iu);
ne(f, n.tld, h), ne(f, n.utld, h), R(c, Jo, h);
const b = R(u, mt);
R(b, mt, b), ne(b, n.domain, u), ne(h, n.domain, u), R(h, Rt, f), R(h, mt, b);
const m = R(h, Bn);
ne(m, n.numeric, iu);
const x = R(s, mt), v = R(s, Rt);
R(x, mt, x), ne(x, n.domain, s), ne(v, r, i), ne(v, n.domain, s);
const C = ht(Ei);
ne(v, n.tld, C), ne(v, n.utld, C), ne(C, n.domain, s), ne(C, r, i), R(C, Rt, v), R(C, mt, x), R(C, Mn, c);
const S = R(C, Bn), g = ht(Ei);
ne(S, n.numeric, g);
const O = ht(Ei), T = ht();
ne(O, e, O), ne(O, t, T), ne(T, e, O), ne(T, t, T), R(C, Ft, O), R(g, Ft, O);
const B = R(l, Bn), F = R(a, Bn), W = R(F, Ft), L = R(W, Ft);
ne(l, n.domain, s), R(l, Rt, v), R(l, mt, x), ne(a, n.domain, s), R(a, Rt, v), R(a, mt, x), ne(B, n.domain, O), R(B, Ft, O), R(B, _o, O), ne(L, n.domain, O), ne(L, e, O), R(L, Ft, O);
const N = [
[Bo, Po],
// {}
[rs, is],
// []
[ss, ls],
// ()
[as, cs],
// <>
[ps, us],
// ()
[ds, fs],
// 「」
[hs, bs],
// 『』
[ms, xs]
// <>
];
for (let $ = 0; $ < N.length; $++) {
const [K, ae] = N[$], he = R(O, K);
R(T, K, he), R(he, ae, O);
const ue = ht(Ei);
ne(he, e, ue);
const ie = ht();
ne(he, t), ne(ue, e, ue), ne(ue, t, ie), ne(ie, e, ue), ne(ie, t, ie), R(ue, ae, O), R(ie, ae, O);
}
return R(o, Jo, C), R(o, sc, lw), {
start: o,
tokens: Qf
};
}
function cw(n, e, t) {
let r = t.length, o = 0, i = [], s = [];
for (; o < r; ) {
let l = n, a = null, c = null, p = 0, u = null, f = -1;
for (; o < r && !(a = l.go(t[o].t)); )
s.push(t[o++]);
for (; o < r && (c = a || l.go(t[o].t)); )
a = null, l = c, l.accepts() ? (f = 0, u = l) : f >= 0 && f++, o++, p++;
if (f < 0)
o -= p, o < r && (s.push(t[o]), o++);
else {
s.length > 0 && (i.push(Ol(su, e, s)), s = []), o -= f, p -= f;
const h = u.t, b = t.slice(o - p, o);
i.push(Ol(h, e, b));
}
}
return s.length > 0 && i.push(Ol(su, e, s)), i;
}
function Ol(n, e, t) {
const r = t[0].s, o = t[t.length - 1].e, i = e.slice(r, o);
return new n(i, t);
}
const pw = typeof console < "u" && console && console.warn || (() => {
}), uw = "until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.", ge = {
scanner: null,
parser: null,
tokenQueue: [],
pluginQueue: [],
customSchemes: [],
initialized: !1
};
function dw() {
return tt.groups = {}, ge.scanner = null, ge.parser = null, ge.tokenQueue = [], ge.pluginQueue = [], ge.customSchemes = [], ge.initialized = !1, ge;
}
function lu(n, e = !1) {
if (ge.initialized && pw(`linkifyjs: already initialized - will not register custom scheme "${n}" ${uw}`), !/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))
throw new Error(`linkifyjs: incorrect scheme format.
1. Must only contain digits, lowercase ASCII letters or "-"
2. Cannot start or end with "-"
3. "-" cannot repeat`);
ge.customSchemes.push([n, e]);
}
function fw() {
ge.scanner = iw(ge.customSchemes);
for (let n = 0; n < ge.tokenQueue.length; n++)
ge.tokenQueue[n][1]({
scanner: ge.scanner
});
ge.parser = aw(ge.scanner.tokens);
for (let n = 0; n < ge.pluginQueue.length; n++)
ge.pluginQueue[n][1]({
scanner: ge.scanner,
parser: ge.parser
});
return ge.initialized = !0, ge;
}
function dc(n) {
return ge.initialized || fw(), cw(ge.parser.start, n, Zf(ge.scanner.start, n));
}
dc.scan = Zf;
function th(n, e = null, t = null) {
if (e && typeof e == "object") {
if (t)
throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);
t = e, e = null;
}
const r = new uc(t), o = dc(n), i = [];
for (let s = 0; s < o.length; s++) {
const l = o[s];
l.isLink && (!e || l.t === e) && r.check(l) && i.push(l.toFormattedObject(r));
}
return i;
}
const fc = "[\0- -\u2029 ]", hw = new RegExp(fc), bw = new RegExp(`${fc}$`), mw = new RegExp(fc, "g");
function xw(n) {
return n.length === 1 ? n[0].isLink : n.length === 3 && n[1].isLink ? ["()", "[]"].includes(n[0].value + n[2].value) : !1;
}
function gw(n) {
return new Oe({
key: new Ze("autolink"),
appendTransaction: (e, t, r) => {
const o = e.some((c) => c.docChanged) && !t.doc.eq(r.doc), i = e.some((c) => c.getMeta("preventAutolink"));
if (!o || i)
return;
const { tr: s } = r, l = My(t.doc, [...e]);
if (_y(l).forEach(({ newRange: c }) => {
const p = Ty(r.doc, c, (h) => h.isTextblock);
let u, f;
if (p.length > 1)
u = p[0], f = r.doc.textBetween(u.pos, u.pos + u.node.nodeSize, void 0, " ");
else if (p.length) {
const h = r.doc.textBetween(c.from, c.to, " ", " ");
if (!bw.test(h))
return;
u = p[0], f = r.doc.textBetween(u.pos, c.to, void 0, " ");
}
if (u && f) {
const h = f.split(hw).filter(Boolean);
if (h.length <= 0)
return !1;
const b = h[h.length - 1], m = u.pos + f.lastIndexOf(b);
if (!b)
return !1;
const x = dc(b).map((v) => v.toObject(n.defaultProtocol));
if (!xw(x))
return !1;
x.filter((v) => v.isLink).map((v) => ({
...v,
from: m + v.start + 1,
to: m + v.end + 1
})).filter((v) => r.schema.marks.code ? !r.doc.rangeHasMark(v.from, v.to, r.schema.marks.code) : !0).filter((v) => n.validate(v.value)).filter((v) => n.shouldAutoLink(v.value)).forEach((v) => {
Ga(v.from, v.to, r.doc).some((C) => C.mark.type === n.type) || s.addMark(v.from, v.to, n.type.create({
href: v.href
}));
});
}
}), !!s.steps.length)
return s;
}
});
}
function yw(n) {
return new Oe({
key: new Ze("handleClickLink"),
props: {
handleClick: (e, t, r) => {
var o, i;
if (r.button !== 0 || !e.editable)
return !1;
let s = r.target;
const l = [];
for (; s.nodeName !== "DIV"; )
l.push(s), s = s.parentNode;
if (!l.find((f) => f.nodeName === "A"))
return !1;
const a = xf(e.state, n.type.name), c = r.target, p = (o = c == null ? void 0 : c.href) !== null && o !== void 0 ? o : a.href, u = (i = c == null ? void 0 : c.target) !== null && i !== void 0 ? i : a.target;
return c && p ? (window.open(p, u), !0) : !1;
}
}
});
}
function vw(n) {
return new Oe({
key: new Ze("handlePasteLink"),
props: {
handlePaste: (e, t, r) => {
const { state: o } = e, { selection: i } = o, { empty: s } = i;
if (s)
return !1;
let l = "";
r.content.forEach((c) => {
l += c.textContent;
});
const a = th(l, { defaultProtocol: n.defaultProtocol }).find((c) => c.isLink && c.value === l);
return !l || !a ? !1 : n.editor.commands.setMark(n.type, {
href: a.href
});
}
}
});
}
function rr(n, e) {
const t = [
"http",
"https",
"ftp",
"ftps",
"mailto",
"tel",
"callto",
"sms",
"cid",
"xmpp"
];
return e && e.forEach((r) => {
const o = typeof r == "string" ? r : r.scheme;
o && t.push(o);
}), !n || n.replace(mw, "").match(new RegExp(
// eslint-disable-next-line no-useless-escape
`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,
"i"
));
}
const ww = un.create({
name: "link",
priority: 1e3,
keepOnSplit: !1,
exitable: !0,
onCreate() {
this.options.validate && !this.options.shouldAutoLink && (this.options.shouldAutoLink = this.options.validate, console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")), this.options.protocols.forEach((n) => {
if (typeof n == "string") {
lu(n);
return;
}
lu(n.scheme, n.optionalSlashes);
});
},
onDestroy() {
dw();
},
inclusive() {
return this.options.autolink;
},
addOptions() {
return {
openOnClick: !0,
linkOnPaste: !0,
autolink: !0,
protocols: [],
defaultProtocol: "http",
HTMLAttributes: {
target: "_blank",
rel: "noopener noreferrer nofollow",
class: null
},
isAllowedUri: (n, e) => !!rr(n, e.protocols),
validate: (n) => !!n,
shouldAutoLink: (n) => !!n
};
},
addAttributes() {
return {
href: {
default: null,
parseHTML(n) {
return n.getAttribute("href");
}
},
target: {
default: this.options.HTMLAttributes.target
},
rel: {
default: this.options.HTMLAttributes.rel
},
class: {
default: this.options.HTMLAttributes.class
}
};
},
parseHTML() {
return [
{
tag: "a[href]",
getAttrs: (n) => {
const e = n.getAttribute("href");
return !e || !this.options.isAllowedUri(e, {
defaultValidate: (t) => !!rr(t, this.options.protocols),
protocols: this.options.protocols,
defaultProtocol: this.options.defaultProtocol
}) ? !1 : null;
}
}
];
},
renderHTML({ HTMLAttributes: n }) {
return this.options.isAllowedUri(n.href, {
defaultValidate: (e) => !!rr(e, this.options.protocols),
protocols: this.options.protocols,
defaultProtocol: this.options.defaultProtocol
}) ? ["a", He(this.options.HTMLAttributes, n), 0] : [
"a",
He(this.options.HTMLAttributes, { ...n, href: "" }),
0
];
},
addCommands() {
return {
setLink: (n) => ({ chain: e }) => {
const { href: t } = n;
return this.options.isAllowedUri(t, {
defaultValidate: (r) => !!rr(r, this.options.protocols),
protocols: this.options.protocols,
defaultProtocol: this.options.defaultProtocol
}) ? e().setMark(this.name, n).setMeta("preventAutolink", !0).run() : !1;
},
toggleLink: (n) => ({ chain: e }) => {
const { href: t } = n;
return this.options.isAllowedUri(t, {
defaultValidate: (r) => !!rr(r, this.options.protocols),
protocols: this.options.protocols,
defaultProtocol: this.options.defaultProtocol
}) ? e().toggleMark(this.name, n, { extendEmptyMarkRange: !0 }).setMeta("preventAutolink", !0).run() : !1;
},
unsetLink: () => ({ chain: n }) => n().unsetMark(this.name, { extendEmptyMarkRange: !0 }).setMeta("preventAutolink", !0).run()
};
},
addPasteRules() {
return [
Cr({
find: (n) => {
const e = [];
if (n) {
const { protocols: t, defaultProtocol: r } = this.options, o = th(n).filter((i) => i.isLink && this.options.isAllowedUri(i.value, {
defaultValidate: (s) => !!rr(s, t),
protocols: t,
defaultProtocol: r
}));
o.length && o.forEach((i) => e.push({
text: i.value,
data: {
href: i.href
},
index: i.start
}));
}
return e;
},
type: this.type,
getAttributes: (n) => {
var e;
return {
href: (e = n.data) === null || e === void 0 ? void 0 : e.href
};
}
})
];
},
addProseMirrorPlugins() {
const n = [], { protocols: e, defaultProtocol: t } = this.options;
return this.options.autolink && n.push(gw({
type: this.type,
defaultProtocol: this.options.defaultProtocol,
validate: (r) => this.options.isAllowedUri(r, {
defaultValidate: (o) => !!rr(o, e),
protocols: e,
defaultProtocol: t
}),
shouldAutoLink: this.options.shouldAutoLink
})), this.options.openOnClick === !0 && n.push(yw({
type: this.type
})), this.options.linkOnPaste && n.push(vw({
editor: this.editor,
defaultProtocol: this.options.defaultProtocol,
type: this.type
})), n;
}
});
function Ti(n, e, t) {
return Array.isArray(n) ? (n.length = Math.max(n.length, e), n.splice(e, 1, t), t) : (n[e] = t, t);
}
function Bl(n, e) {
if (Array.isArray(n)) {
n.splice(e, 1);
return;
}
delete n[e];
}
function Sw() {
return nh().__VUE_DEVTOOLS_GLOBAL_HOOK__;
}
function nh() {
return typeof navigator < "u" && typeof window < "u" ? window : typeof globalThis < "u" ? globalThis : {};
}
const kw = typeof Proxy == "function", Cw = "devtools-plugin:setup", Mw = "plugin:settings:set";
let Lr, ga;
function Ew() {
var n;
return Lr !== void 0 || (typeof window < "u" && window.performance ? (Lr = !0, ga = window.performance) : typeof globalThis < "u" && (!((n = globalThis.perf_hooks) === null || n === void 0) && n.performance) ? (Lr = !0, ga = globalThis.perf_hooks.performance) : Lr = !1), Lr;
}
function Tw() {
return Ew() ? ga.now() : Date.now();
}
class Ow {
constructor(e, t) {
this.target = null, this.targetQueue = [], this.onQueue = [], this.plugin = e, this.hook = t;
const r = {};
if (e.settings)
for (const s in e.settings) {
const l = e.settings[s];
r[s] = l.defaultValue;
}
const o = `__vue-devtools-plugin-settings__${e.id}`;
let i = Object.assign({}, r);
try {
const s = localStorage.getItem(o), l = JSON.parse(s);
Object.assign(i, l);
} catch {
}
this.fallbacks = {
getSettings() {
return i;
},
setSettings(s) {
try {
localStorage.setItem(o, JSON.stringify(s));
} catch {
}
i = s;
},
now() {
return Tw();
}
}, t && t.on(Mw, (s, l) => {
s === this.plugin.id && this.fallbacks.setSettings(l);
}), this.proxiedOn = new Proxy({}, {
get: (s, l) => this.target ? this.target.on[l] : (...a) => {
this.onQueue.push({
method: l,
args: a
});
}
}), this.proxiedTarget = new Proxy({}, {
get: (s, l) => this.target ? this.target[l] : l === "on" ? this.proxiedOn : Object.keys(this.fallbacks).includes(l) ? (...a) => (this.targetQueue.push({
method: l,
args: a,
resolve: () => {
}
}), this.fallbacks[l](...a)) : (...a) => new Promise((c) => {
this.targetQueue.push({
method: l,
args: a,
resolve: c
});
})
});
}
async setRealTarget(e) {
this.target = e;
for (const t of this.onQueue)
this.target.on[t.method](...t.args);
for (const t of this.targetQueue)
t.resolve(await this.target[t.method](...t.args));
}
}
function rh(n, e) {
const t = n, r = nh(), o = Sw(), i = kw && t.enableEarlyProxy;
if (o && (r.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !i))
o.emit(Cw, n, e);
else {
const s = i ? new Ow(t, o) : null;
(r.__VUE_DEVTOOLS_PLUGINS__ = r.__VUE_DEVTOOLS_PLUGINS__ || []).push({
pluginDescriptor: t,
setupFn: e,
proxy: s
}), s && e(s.proxiedTarget);
}
}
/*!
* pinia v2.3.1
* (c) 2025 Eduardo San Martin Morote
* @license MIT
*/
let yo;
const Xo = (n) => yo = n, oh = process.env.NODE_ENV !== "production" ? Symbol("pinia") : (
/* istanbul ignore next */
Symbol()
);
function Er(n) {
return n && typeof n == "object" && Object.prototype.toString.call(n) === "[object Object]" && typeof n.toJSON != "function";
}
var Ut;
(function(n) {
n.direct = "direct", n.patchObject = "patch object", n.patchFunction = "patch function";
})(Ut || (Ut = {}));
const Dn = typeof window < "u", au = typeof window == "object" && window.window === window ? window : typeof self == "object" && self.self === self ? self : typeof global == "object" && global.global === global ? global : typeof globalThis == "object" ? globalThis : { HTMLElement: null };
function Bw(n, { autoBom: e = !1 } = {}) {
return e && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(n.type) ? new Blob(["\uFEFF", n], { type: n.type }) : n;
}
function hc(n, e, t) {
const r = new XMLHttpRequest();
r.open("GET", n), r.responseType = "blob", r.onload = function() {
lh(r.response, e, t);
}, r.onerror = function() {
console.error("could not download file");
}, r.send();
}
function ih(n) {
const e = new XMLHttpRequest();
e.open("HEAD", n, !1);
try {
e.send();
} catch {
}
return e.status >= 200 && e.status <= 299;
}
function Di(n) {
try {
n.dispatchEvent(new MouseEvent("click"));
} catch {
const t = document.createEvent("MouseEvents");
t.initMouseEvent("click", !0, !0, window, 0, 0, 0, 80, 20, !1, !1, !1, !1, 0, null), n.dispatchEvent(t);
}
}
const Ii = typeof navigator == "object" ? navigator : { userAgent: "" }, sh = /Macintosh/.test(Ii.userAgent) && /AppleWebKit/.test(Ii.userAgent) && !/Safari/.test(Ii.userAgent), lh = Dn ? (
// Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView or mini program
typeof HTMLAnchorElement < "u" && "download" in HTMLAnchorElement.prototype && !sh ? Pw : (
// Use msSaveOrOpenBlob as a second approach
"msSaveOrOpenBlob" in Ii ? Aw : (
// Fallback to using FileReader and a popup
_w
)
)
) : () => {
};
function Pw(n, e = "download", t) {
const r = document.createElement("a");
r.download = e, r.rel = "noopener", typeof n == "string" ? (r.href = n, r.origin !== location.origin ? ih(r.href) ? hc(n, e, t) : (r.target = "_blank", Di(r)) : Di(r)) : (r.href = URL.createObjectURL(n), setTimeout(function() {
URL.revokeObjectURL(r.href);
}, 4e4), setTimeout(function() {
Di(r);
}, 0));
}
function Aw(n, e = "download", t) {
if (typeof n == "string")
if (ih(n))
hc(n, e, t);
else {
const r = document.createElement("a");
r.href = n, r.target = "_blank", setTimeout(function() {
Di(r);
});
}
else
navigator.msSaveOrOpenBlob(Bw(n, t), e);
}
function _w(n, e, t, r) {
if (r = r || open("", "_blank"), r && (r.document.title = r.document.body.innerText = "downloading..."), typeof n == "string")
return hc(n, e, t);
const o = n.type === "application/octet-stream", i = /constructor/i.test(String(au.HTMLElement)) || "safari" in au, s = /CriOS\/[\d]+/.test(navigator.userAgent);
if ((s || o && i || sh) && typeof FileReader < "u") {
const l = new FileReader();
l.onloadend = function() {
let a = l.result;
if (typeof a != "string")
throw r = null, new Error("Wrong reader.result type");
a = s ? a : a.replace(/^data:[^;]*;/, "data:attachment/file;"), r ? r.location.href = a : location.assign(a), r = null;
}, l.readAsDataURL(n);
} else {
const l = URL.createObjectURL(n);
r ? r.location.assign(l) : location.href = l, r = null, setTimeout(function() {
URL.revokeObjectURL(l);
}, 4e4);
}
}
function Ae(n, e) {
const t = "🍍 " + n;
typeof __VUE_DEVTOOLS_TOAST__ == "function" ? __VUE_DEVTOOLS_TOAST__(t, e) : e === "error" ? console.error(t) : e === "warn" ? console.warn(t) : console.log(t);
}
function bc(n) {
return "_a" in n && "install" in n;
}
function ah() {
if (!("clipboard" in navigator))
return Ae("Your browser doesn't support the Clipboard API", "error"), !0;
}
function ch(n) {
return n instanceof Error && n.message.toLowerCase().includes("document is not focused") ? (Ae('You need to activate the "Emulate a focused page" setting in the "Rendering" panel of devtools.', "warn"), !0) : !1;
}
async function Lw(n) {
if (!ah())
try {
await navigator.clipboard.writeText(JSON.stringify(n.state.value)), Ae("Global state copied to clipboard.");
} catch (e) {
if (ch(e))
return;
Ae("Failed to serialize the state. Check the console for more details.", "error"), console.error(e);
}
}
async function Nw(n) {
if (!ah())
try {
ph(n, JSON.parse(await navigator.clipboard.readText())), Ae("Global state pasted from clipboard.");
} catch (e) {
if (ch(e))
return;
Ae("Failed to deserialize the state from clipboard. Check the console for more details.", "error"), console.error(e);
}
}
async function Dw(n) {
try {
lh(new Blob([JSON.stringify(n.state.value)], {
type: "text/plain;charset=utf-8"
}), "pinia-state.json");
} catch (e) {
Ae("Failed to export the state as JSON. Check the console for more details.", "error"), console.error(e);
}
}
let tn;
function Iw() {
tn || (tn = document.createElement("input"), tn.type = "file", tn.accept = ".json");
function n() {
return new Promise((e, t) => {
tn.onchange = async () => {
const r = tn.files;
if (!r)
return e(null);
const o = r.item(0);
return e(o ? { text: await o.text(), file: o } : null);
}, tn.oncancel = () => e(null), tn.onerror = t, tn.click();
});
}
return n;
}
async function $w(n) {
try {
const t = await Iw()();
if (!t)
return;
const { text: r, file: o } = t;
ph(n, JSON.parse(r)), Ae(`Global state imported from "${o.name}".`);
} catch (e) {
Ae("Failed to import the state from JSON. Check the console for more details.", "error"), console.error(e);
}
}
function ph(n, e) {
for (const t in e) {
const r = n.state.value[t];
r ? Object.assign(r, e[t]) : n.state.value[t] = e[t];
}
}
function Pt(n) {
return {
_custom: {
display: n
}
};
}
const uh = "🍍 Pinia (root)", $i = "_root";
function Rw(n) {
return bc(n) ? {
id: $i,
label: uh
} : {
id: n.$id,
label: n.$id
};
}
function Fw(n) {
if (bc(n)) {
const t = Array.from(n._s.keys()), r = n._s;
return {
state: t.map((i) => ({
editable: !0,
key: i,
value: n.state.value[i]
})),
getters: t.filter((i) => r.get(i)._getters).map((i) => {
const s = r.get(i);
return {
editable: !1,
key: i,
value: s._getters.reduce((l, a) => (l[a] = s[a], l), {})
};
})
};
}
const e = {
state: Object.keys(n.$state).map((t) => ({
editable: !0,
key: t,
value: n.$state[t]
}))
};
return n._getters && n._getters.length && (e.getters = n._getters.map((t) => ({
editable: !1,
key: t,
value: n[t]
}))), n._customProperties.size && (e.customProperties = Array.from(n._customProperties).map((t) => ({
editable: !0,
key: t,
value: n[t]
}))), e;
}
function Hw(n) {
return n ? Array.isArray(n) ? n.reduce((e, t) => (e.keys.push(t.key), e.operations.push(t.type), e.oldValue[t.key] = t.oldValue, e.newValue[t.key] = t.newValue, e), {
oldValue: {},
keys: [],
operations: [],
newValue: {}
}) : {
operation: Pt(n.type),
key: Pt(n.key),
oldValue: n.oldValue,
newValue: n.newValue
} : {};
}
function jw(n) {
switch (n) {
case Ut.direct:
return "mutation";
case Ut.patchFunction:
return "$patch";
case Ut.patchObject:
return "$patch";
default:
return "unknown";
}
}
let zr = !0;
const Ri = [], ir = "pinia:mutations", We = "pinia", { assign: zw } = Object, As = (n) => "🍍 " + n;
function Vw(n, e) {
rh({
id: "dev.esm.pinia",
label: "Pinia 🍍",
logo: "https://pinia.vuejs.org/logo.svg",
packageName: "pinia",
homepage: "https://pinia.vuejs.org",
componentStateTypes: Ri,
app: n
}, (t) => {
typeof t.now != "function" && Ae("You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html."), t.addTimelineLayer({
id: ir,
label: "Pinia 🍍",
color: 15064968
}), t.addInspector({
id: We,
label: "Pinia 🍍",
icon: "storage",
treeFilterPlaceholder: "Search stores",
actions: [
{
icon: "content_copy",
action: () => {
Lw(e);
},
tooltip: "Serialize and copy the state"
},
{
icon: "content_paste",
action: async () => {
await Nw(e), t.sendInspectorTree(We), t.sendInspectorState(We);
},
tooltip: "Replace the state with the content of your clipboard"
},
{
icon: "save",
action: () => {
Dw(e);
},
tooltip: "Save the state as a JSON file"
},
{
icon: "folder_open",
action: async () => {
await $w(e), t.sendInspectorTree(We), t.sendInspectorState(We);
},
tooltip: "Import the state from a JSON file"
}
],
nodeActions: [
{
icon: "restore",
tooltip: 'Reset the state (with "$reset")',
action: (r) => {
const o = e._s.get(r);
o ? typeof o.$reset != "function" ? Ae(`Cannot reset "${r}" store because it doesn't have a "$reset" method implemented.`, "warn") : (o.$reset(), Ae(`Store "${r}" reset.`)) : Ae(`Cannot reset "${r}" store because it wasn't found.`, "warn");
}
}
]
}), t.on.inspectComponent((r, o) => {
const i = r.componentInstance && r.componentInstance.proxy;
if (i && i._pStores) {
const s = r.componentInstance.proxy._pStores;
Object.values(s).forEach((l) => {
r.instanceData.state.push({
type: As(l.$id),
key: "state",
editable: !0,
value: l._isOptionsAPI ? {
_custom: {
value: Ve(l.$state),
actions: [
{
icon: "restore",
tooltip: "Reset the state of this store",
action: () => l.$reset()
}
]
}
} : (
// NOTE: workaround to unwrap transferred refs
Object.keys(l.$state).reduce((a, c) => (a[c] = l.$state[c], a), {})
)
}), l._getters && l._getters.length && r.instanceData.state.push({
type: As(l.$id),
key: "getters",
editable: !1,
value: l._getters.reduce((a, c) => {
try {
a[c] = l[c];
} catch (p) {
a[c] = p;
}
return a;
}, {})
});
});
}
}), t.on.getInspectorTree((r) => {
if (r.app === n && r.inspectorId === We) {
let o = [e];
o = o.concat(Array.from(e._s.values())), r.rootNodes = (r.filter ? o.filter((i) => "$id" in i ? i.$id.toLowerCase().includes(r.filter.toLowerCase()) : uh.toLowerCase().includes(r.filter.toLowerCase())) : o).map(Rw);
}
}), globalThis.$pinia = e, t.on.getInspectorState((r) => {
if (r.app === n && r.inspectorId === We) {
const o = r.nodeId === $i ? e : e._s.get(r.nodeId);
if (!o)
return;
o && (r.nodeId !== $i && (globalThis.$store = Ve(o)), r.state = Fw(o));
}
}), t.on.editInspectorState((r, o) => {
if (r.app === n && r.inspectorId === We) {
const i = r.nodeId === $i ? e : e._s.get(r.nodeId);
if (!i)
return Ae(`store "${r.nodeId}" not found`, "error");
const { path: s } = r;
bc(i) ? s.unshift("state") : (s.length !== 1 || !i._customProperties.has(s[0]) || s[0] in i.$state) && s.unshift("$state"), zr = !1, r.set(i, s, r.state.value), zr = !0;
}
}), t.on.editComponentState((r) => {
if (r.type.startsWith("🍍")) {
const o = r.type.replace(/^🍍\s*/, ""), i = e._s.get(o);
if (!i)
return Ae(`store "${o}" not found`, "error");
const { path: s } = r;
if (s[0] !== "state")
return Ae(`Invalid path for store "${o}":
${s}
Only state can be modified.`);
s[0] = "$state", zr = !1, r.set(i, s, r.state.value), zr = !0;
}
});
});
}
function Ww(n, e) {
Ri.includes(As(e.$id)) || Ri.push(As(e.$id)), rh({
id: "dev.esm.pinia",
label: "Pinia 🍍",
logo: "https://pinia.vuejs.org/logo.svg",
packageName: "pinia",
homepage: "https://pinia.vuejs.org",
componentStateTypes: Ri,
app: n,
settings: {
logStoreChanges: {
label: "Notify about new/deleted stores",
type: "boolean",
defaultValue: !0
}
// useEmojis: {
// label: 'Use emojis in messages ⚡️',
// type: 'boolean',
// defaultValue: true,
// },
}
}, (t) => {
const r = typeof t.now == "function" ? t.now.bind(t) : Date.now;
e.$onAction(({ after: s, onError: l, name: a, args: c }) => {
const p = dh++;
t.addTimelineEvent({
layerId: ir,
event: {
time: r(),
title: "🛫 " + a,
subtitle: "start",
data: {
store: Pt(e.$id),
action: Pt(a),
args: c
},
groupId: p
}
}), s((u) => {
In = void 0, t.addTimelineEvent({
layerId: ir,
event: {
time: r(),
title: "🛬 " + a,
subtitle: "end",
data: {
store: Pt(e.$id),
action: Pt(a),
args: c,
result: u
},
groupId: p
}
});
}), l((u) => {
In = void 0, t.addTimelineEvent({
layerId: ir,
event: {
time: r(),
logType: "error",
title: "💥 " + a,
subtitle: "end",
data: {
store: Pt(e.$id),
action: Pt(a),
args: c,
error: u
},
groupId: p
}
});
});
}, !0), e._customProperties.forEach((s) => {
ee(() => y(e[s]), (l, a) => {
t.notifyComponentUpdate(), t.sendInspectorState(We), zr && t.addTimelineEvent({
layerId: ir,
event: {
time: r(),
title: "Change",
subtitle: s,
data: {
newValue: l,
oldValue: a
},
groupId: In
}
});
}, { deep: !0 });
}), e.$subscribe(({ events: s, type: l }, a) => {
if (t.notifyComponentUpdate(), t.sendInspectorState(We), !zr)
return;
const c = {
time: r(),
title: jw(l),
data: zw({ store: Pt(e.$id) }, Hw(s)),
groupId: In
};
l === Ut.patchFunction ? c.subtitle = "⤵️" : l === Ut.patchObject ? c.subtitle = "🧩" : s && !Array.isArray(s) && (c.subtitle = s.type), s && (c.data["rawEvent(s)"] = {
_custom: {
display: "DebuggerEvent",
type: "object",
tooltip: "raw DebuggerEvent[]",
value: s
}
}), t.addTimelineEvent({
layerId: ir,
event: c
});
}, { detached: !0, flush: "sync" });
const o = e._hotUpdate;
e._hotUpdate = Pn((s) => {
o(s), t.addTimelineEvent({
layerId: ir,
event: {
time: r(),
title: "🔥 " + e.$id,
subtitle: "HMR update",
data: {
store: Pt(e.$id),
info: Pt("HMR update")
}
}
}), t.notifyComponentUpdate(), t.sendInspectorTree(We), t.sendInspectorState(We);
});
const { $dispose: i } = e;
e.$dispose = () => {
i(), t.notifyComponentUpdate(), t.sendInspectorTree(We), t.sendInspectorState(We), t.getSettings().logStoreChanges && Ae(`Disposed "${e.$id}" store 🗑`);
}, t.notifyComponentUpdate(), t.sendInspectorTree(We), t.sendInspectorState(We), t.getSettings().logStoreChanges && Ae(`"${e.$id}" store installed 🆕`);
});
}
let dh = 0, In;
function cu(n, e, t) {
const r = e.reduce((o, i) => (o[i] = Ve(n)[i], o), {});
for (const o in r)
n[o] = function() {
const i = dh, s = t ? new Proxy(n, {
get(...a) {
return In = i, Reflect.get(...a);
},
set(...a) {
return In = i, Reflect.set(...a);
}
}) : n;
In = i;
const l = r[o].apply(s, arguments);
return In = void 0, l;
};
}
function Uw({ app: n, store: e, options: t }) {
if (!e.$id.startsWith("__hot:")) {
if (e._isOptionsAPI = !!t.state, !e._p._testing) {
cu(e, Object.keys(t.actions), e._isOptionsAPI);
const r = e._hotUpdate;
Ve(e)._hotUpdate = function(o) {
r.apply(this, arguments), cu(e, Object.keys(o._hmrPayload.actions), !!e._isOptionsAPI);
};
}
Ww(
n,
// FIXME: is there a way to allow the assignment from Store<Id, S, G, A> to StoreGeneric?
e
);
}
}
function qw() {
const n = Pu(!0), e = n.run(() => M({}));
let t = [], r = [];
const o = Pn({
install(i) {
Xo(o), o._a = i, i.provide(oh, o), i.config.globalProperties.$pinia = o, process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && Dn && Vw(i, o), r.forEach((s) => t.push(s)), r = [];
},
use(i) {
return this._a ? t.push(i) : r.push(i), this;
},
_p: t,
// it's actually undefined here
// @ts-expect-error
_a: null,
_e: n,
_s: /* @__PURE__ */ new Map(),
state: e
});
return process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && Dn && typeof Proxy < "u" && o.use(Uw), o;
}
function fh(n, e) {
for (const t in e) {
const r = e[t];
if (!(t in n))
continue;
const o = n[t];
Er(o) && Er(r) && !No(r) && !Sa(r) ? n[t] = fh(o, r) : n[t] = r;
}
return n;
}
const hh = () => {
};
function pu(n, e, t, r = hh) {
n.push(e);
const o = () => {
const i = n.indexOf(e);
i > -1 && (n.splice(i, 1), r());
};
return !t && Fh() && Hh(o), o;
}
function Nr(n, ...e) {
n.slice().forEach((t) => {
t(...e);
});
}
const Kw = (n) => n(), uu = Symbol(), Pl = Symbol();
function ya(n, e) {
n instanceof Map && e instanceof Map ? e.forEach((t, r) => n.set(r, t)) : n instanceof Set && e instanceof Set && e.forEach(n.add, n);
for (const t in e) {
if (!e.hasOwnProperty(t))
continue;
const r = e[t], o = n[t];
Er(o) && Er(r) && n.hasOwnProperty(t) && !No(r) && !Sa(r) ? n[t] = ya(o, r) : n[t] = r;
}
return n;
}
const Gw = process.env.NODE_ENV !== "production" ? Symbol("pinia:skipHydration") : (
/* istanbul ignore next */
Symbol()
);
function Jw(n) {
return !Er(n) || !n.hasOwnProperty(Gw);
}
const { assign: xt } = Object;
function du(n) {
return !!(No(n) && n.effect);
}
function fu(n, e, t, r) {
const { state: o, actions: i, getters: s } = e, l = t.state.value[n];
let a;
function c() {
!l && (process.env.NODE_ENV === "production" || !r) && (t.state.value[n] = o ? o() : {});
const p = process.env.NODE_ENV !== "production" && r ? (
// use ref() to unwrap refs inside state TODO: check if this is still necessary
yc(M(o ? o() : {}).value)
) : yc(t.state.value[n]);
return xt(p, i, Object.keys(s || {}).reduce((u, f) => (process.env.NODE_ENV !== "production" && f in p && console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${f}" in store "${n}".`), u[f] = Pn(I(() => {
Xo(t);
const h = t._s.get(n);
return s[f].call(h, h);
})), u), {}));
}
return a = va(n, c, e, t, r, !0), a;
}
function va(n, e, t = {}, r, o, i) {
let s;
const l = xt({ actions: {} }, t);
if (process.env.NODE_ENV !== "production" && !r._e.active)
throw new Error("Pinia destroyed");
const a = { deep: !0 };
process.env.NODE_ENV !== "production" && (a.onTrigger = (L) => {
c ? h = L : c == !1 && !B._hotUpdating && (Array.isArray(h) ? h.push(L) : console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."));
});
let c, p, u = [], f = [], h;
const b = r.state.value[n];
!i && !b && (process.env.NODE_ENV === "production" || !o) && (r.state.value[n] = {});
const m = M({});
let x;
function v(L) {
let N;
c = p = !1, process.env.NODE_ENV !== "production" && (h = []), typeof L == "function" ? (L(r.state.value[n]), N = {
type: Ut.patchFunction,
storeId: n,
events: h
}) : (ya(r.state.value[n], L), N = {
type: Ut.patchObject,
payload: L,
storeId: n,
events: h
});
const $ = x = Symbol();
ce().then(() => {
x === $ && (c = !0);
}), p = !0, Nr(u, N, r.state.value[n]);
}
const C = i ? function() {
const { state: N } = t, $ = N ? N() : {};
this.$patch((K) => {
xt(K, $);
});
} : (
/* istanbul ignore next */
process.env.NODE_ENV !== "production" ? () => {
throw new Error(`🍍: Store "${n}" is built using the setup syntax and does not implement $reset().`);
} : hh
);
function S() {
s.stop(), u = [], f = [], r._s.delete(n);
}
const g = (L, N = "") => {
if (uu in L)
return L[Pl] = N, L;
const $ = function() {
Xo(r);
const K = Array.from(arguments), ae = [], he = [];
function ue(re) {
ae.push(re);
}
function ie(re) {
he.push(re);
}
Nr(f, {
args: K,
name: $[Pl],
store: B,
after: ue,
onError: ie
});
let G;
try {
G = L.apply(this && this.$id === n ? this : B, K);
} catch (re) {
throw Nr(he, re), re;
}
return G instanceof Promise ? G.then((re) => (Nr(ae, re), re)).catch((re) => (Nr(he, re), Promise.reject(re))) : (Nr(ae, G), G);
};
return $[uu] = !0, $[Pl] = N, $;
}, O = /* @__PURE__ */ Pn({
actions: {},
getters: {},
state: [],
hotState: m
}), T = {
_p: r,
// _s: scope,
$id: n,
$onAction: pu.bind(null, f),
$patch: v,
$reset: C,
$subscribe(L, N = {}) {
const $ = pu(u, L, N.detached, () => K()), K = s.run(() => ee(() => r.state.value[n], (ae) => {
(N.flush === "sync" ? p : c) && L({
storeId: n,
type: Ut.direct,
events: h
}, ae);
}, xt({}, a, N)));
return $;
},
$dispose: S
}, B = Rh(process.env.NODE_ENV !== "production" || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && Dn ? xt(
{
_hmrPayload: O,
_customProperties: Pn(/* @__PURE__ */ new Set())
// devtools custom properties
},
T
// must be added later
// setupStore
) : T);
r._s.set(n, B);
const W = (r._a && r._a.runWithContext || Kw)(() => r._e.run(() => (s = Pu()).run(() => e({ action: g }))));
for (const L in W) {
const N = W[L];
if (No(N) && !du(N) || Sa(N))
process.env.NODE_ENV !== "production" && o ? Ti(m.value, L, Qs(W, L)) : i || (b && Jw(N) && (No(N) ? N.value = b[L] : ya(N, b[L])), r.state.value[n][L] = N), process.env.NODE_ENV !== "production" && O.state.push(L);
else if (typeof N == "function") {
const $ = process.env.NODE_ENV !== "production" && o ? N : g(N, L);
W[L] = $, process.env.NODE_ENV !== "production" && (O.actions[L] = N), l.actions[L] = N;
} else process.env.NODE_ENV !== "production" && du(N) && (O.getters[L] = i ? (
// @ts-expect-error
t.getters[L]
) : N, Dn && (W._getters || // @ts-expect-error: same
(W._getters = Pn([]))).push(L));
}
if (xt(B, W), xt(Ve(B), W), Object.defineProperty(B, "$state", {
get: () => process.env.NODE_ENV !== "production" && o ? m.value : r.state.value[n],
set: (L) => {
if (process.env.NODE_ENV !== "production" && o)
throw new Error("cannot set hotState");
v((N) => {
xt(N, L);
});
}
}), process.env.NODE_ENV !== "production" && (B._hotUpdate = Pn((L) => {
B._hotUpdating = !0, L._hmrPayload.state.forEach((N) => {
if (N in B.$state) {
const $ = L.$state[N], K = B.$state[N];
typeof $ == "object" && Er($) && Er(K) ? fh($, K) : L.$state[N] = K;
}
Ti(B, N, Qs(L.$state, N));
}), Object.keys(B.$state).forEach((N) => {
N in L.$state || Bl(B, N);
}), c = !1, p = !1, r.state.value[n] = Qs(L._hmrPayload, "hotState"), p = !0, ce().then(() => {
c = !0;
});
for (const N in L._hmrPayload.actions) {
const $ = L[N];
Ti(B, N, g($, N));
}
for (const N in L._hmrPayload.getters) {
const $ = L._hmrPayload.getters[N], K = i ? (
// special handling of options api
I(() => (Xo(r), $.call(B, B)))
) : $;
Ti(B, N, K);
}
Object.keys(B._hmrPayload.getters).forEach((N) => {
N in L._hmrPayload.getters || Bl(B, N);
}), Object.keys(B._hmrPayload.actions).forEach((N) => {
N in L._hmrPayload.actions || Bl(B, N);
}), B._hmrPayload = L._hmrPayload, B._getters = L._getters, B._hotUpdating = !1;
})), process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && Dn) {
const L = {
writable: !0,
configurable: !0,
// avoid warning on devtools trying to display this property
enumerable: !1
};
["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((N) => {
Object.defineProperty(B, N, xt({ value: B[N] }, L));
});
}
return r._p.forEach((L) => {
if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && Dn) {
const N = s.run(() => L({
store: B,
app: r._a,
pinia: r,
options: l
}));
Object.keys(N || {}).forEach(($) => B._customProperties.add($)), xt(B, N);
} else
xt(B, s.run(() => L({
store: B,
app: r._a,
pinia: r,
options: l
})));
}), process.env.NODE_ENV !== "production" && B.$state && typeof B.$state == "object" && typeof B.$state.constructor == "function" && !B.$state.constructor.toString().includes("[native code]") && console.warn(`[🍍]: The "state" must be a plain object. It cannot be
state: () => new MyClass()
Found in store "${B.$id}".`), b && i && t.hydrate && t.hydrate(B.$state, b), c = !0, p = !0, B;
}
/*! #__NO_SIDE_EFFECTS__ */
// @__NO_SIDE_EFFECTS__
function Yw(n, e, t) {
let r, o;
const i = typeof e == "function";
r = n, o = i ? t : e;
function s(l, a) {
const c = $h();
if (l = // in test mode, ignore the argument provided as we can always retrieve a
// pinia instance with getActivePinia()
(process.env.NODE_ENV === "test" && yo && yo._testing ? null : l) || (c ? zn(oh, null) : null), l && Xo(l), process.env.NODE_ENV !== "production" && !yo)
throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
This will fail in production.`);
l = yo, l._s.has(r) || (i ? va(r, e, o, l) : fu(r, o, l), process.env.NODE_ENV !== "production" && (s._pinia = l));
const p = l._s.get(r);
if (process.env.NODE_ENV !== "production" && a) {
const u = "__hot:" + r, f = i ? va(u, e, o, l, !0) : fu(u, xt({}, o), l, !0);
a._hotUpdate(f), delete l.state.value[u], l._s.delete(u);
}
if (process.env.NODE_ENV !== "production" && Dn) {
const u = Bu();
if (u && u.proxy && // avoid adding stores that are just built for hot module replacement
!a) {
const f = u.proxy, h = "_pStores" in f ? f._pStores : f._pStores = {};
h[r] = p;
}
}
return p;
}
return s.$id = r, s;
}
const Xw = /* @__PURE__ */ Yw("pageBuilderState", {
state: () => ({
// Core Page Builder State
componentArrayAddMethod: null,
localStorageItemName: null,
showModalTipTap: !1,
menuRight: !0,
borderStyle: null,
borderWidth: null,
borderColor: null,
borderRadiusGlobal: null,
borderRadiusTopLeft: null,
borderRadiusTopRight: null,
borderRadiusBottomleft: null,
borderRadiusBottomRight: null,
elementContainsHyperlink: null,
hyperlinkAbility: null,
hyperlinkInput: null,
hyperlinkMessage: null,
hyperlinkError: null,
hyberlinkEnable: !1,
openHyperlinkinkInNewTab: null,
opacity: null,
backgroundOpacity: null,
textAreaVueModel: null,
currentClasses: [],
currentStyles: {},
fontVerticalPadding: null,
fontHorizontalPadding: null,
fontVerticalMargin: null,
fontHorizontalMargin: null,
fontStyle: null,
fontFamily: null,
fontWeight: null,
fontBase: null,
fontDesktop: null,
fontTablet: null,
fontMobile: null,
backgroundColor: null,
textColor: null,
element: null,
component: null,
components: [],
basePrimaryImage: null,
configPageBuilder: null,
// Media Library State
applyImageToSelection: { src: "" },
currentPreviewImage: null,
// User State
builderStarted: !1,
isLoadingGlobal: !0,
isSaving: !1,
hasLocalDraftForUpdate: !1,
isResumeEditing: !1,
isRestoring: !1,
currentLanguage: null,
historyIndex: -1,
historyLength: 0
}),
getters: {
// Core Page Builder Getters
getComponentArrayAddMethod(n) {
return n.componentArrayAddMethod;
},
getLocalStorageItemName(n) {
return n.localStorageItemName;
},
getShowModalTipTap(n) {
return n.showModalTipTap;
},
getMenuRight(n) {
return n.menuRight;
},
getBorderStyle(n) {
return n.borderStyle;
},
getBorderWidth(n) {
return n.borderWidth;
},
getBorderColor(n) {
return n.borderColor;
},
getBorderRadiusGlobal(n) {
return n.borderRadiusGlobal;
},
getBorderRadiusTopLeft(n) {
return n.borderRadiusTopLeft;
},
getBorderRadiusTopRight(n) {
return n.borderRadiusTopRight;
},
getBorderRadiusBottomleft(n) {
return n.borderRadiusBottomleft;
},
getBorderRadiusBottomRight(n) {
return n.borderRadiusBottomRight;
},
getElementContainsHyperlink(n) {
return n.elementContainsHyperlink;
},
getHyperlinkAbility(n) {
return n.hyperlinkAbility;
},
getHyperlinkInput(n) {
return n.hyperlinkInput;
},
getHyperlinkMessage(n) {
return n.hyperlinkMessage;
},
getHyperlinkError(n) {
return n.hyperlinkError;
},
getHyberlinkEnable(n) {
return n.hyberlinkEnable;
},
getOpenHyperlinkInNewTab(n) {
return n.openHyperlinkinkInNewTab;
},
getOpacity(n) {
return n.opacity;
},
getBackgroundOpacity(n) {
return n.backgroundOpacity;
},
getTextAreaVueModel(n) {
return n.textAreaVueModel;
},
getCurrentClasses(n) {
return n.currentClasses;
},
getCurrentStyles(n) {
return n.currentStyles;
},
getFontStyle(n) {
return n.fontStyle;
},
getFontVerticalPadding(n) {
return n.fontVerticalPadding;
},
getFontHorizontalPadding(n) {
return n.fontHorizontalPadding;
},
getFontVerticalMargin(n) {
return n.fontVerticalMargin;
},
getFontHorizontalMargin(n) {
return n.fontHorizontalMargin;
},
getFontFamily(n) {
return n.fontFamily;
},
getFontWeight(n) {
return n.fontWeight;
},
getFontBase(n) {
return n.fontBase;
},
getFontDesktop(n) {
return n.fontDesktop;
},
getFontTablet(n) {
return n.fontTablet;
},
getFontMobile(n) {
return n.fontMobile;
},
getBackgroundColor(n) {
return n.backgroundColor;
},
getTextColor(n) {
return n.textColor;
},
getElement(n) {
return n.element;
},
getComponent(n) {
return n.component;
},
getComponents(n) {
return n.components;
},
getBasePrimaryImage(n) {
return n.basePrimaryImage;
},
getPageBuilderConfig(n) {
return n.configPageBuilder;
},
getApplyImageToSelection(n) {
return n.applyImageToSelection;
},
getCurrentPreviewImage(n) {
return n.currentPreviewImage;
},
// User Getters
getBuilderStarted: (n) => n.builderStarted,
getIsLoadingGlobal: (n) => n.isLoadingGlobal,
getIsSaving: (n) => n.isSaving,
getHasLocalDraftForUpdate: (n) => n.hasLocalDraftForUpdate,
getIsLoadingResumeEditing: (n) => n.isResumeEditing,
getIsRestoring: (n) => n.isRestoring,
getCurrentLanguage: (n) => n.currentLanguage,
getHistoryIndex: (n) => n.historyIndex,
getHistoryLength: (n) => n.historyLength
},
actions: {
setComponentArrayAddMethod(n) {
this.componentArrayAddMethod = n;
},
setLocalStorageItemName(n) {
this.localStorageItemName = n;
},
setShowModalTipTap(n) {
this.showModalTipTap = n;
},
setMenuRight(n) {
this.menuRight = n;
},
setBorderStyle(n) {
this.borderStyle = n;
},
setBorderWidth(n) {
this.borderWidth = n;
},
setBorderColor(n) {
this.borderColor = n;
},
setBorderRadiusGlobal(n) {
this.borderRadiusGlobal = n;
},
setBorderRadiusTopLeft(n) {
this.borderRadiusTopLeft = n;
},
setBorderRadiusTopRight(n) {
this.borderRadiusTopRight = n;
},
setBorderRadiusBottomleft(n) {
this.borderRadiusBottomleft = n;
},
setBorderRadiusBottomRight(n) {
this.borderRadiusBottomRight = n;
},
setElementContainsHyperlink(n) {
this.elementContainsHyperlink = n;
},
setHyperlinkAbility(n) {
this.hyperlinkAbility = n;
},
setHyperlinkInput(n) {
this.hyperlinkInput = n;
},
setHyperlinkMessage(n) {
this.hyperlinkMessage = n;
},
setHyperlinkError(n) {
this.hyperlinkError = n;
},
setHyberlinkEnable(n) {
this.hyberlinkEnable = n;
},
setOpenHyperlinkInNewTab(n) {
this.openHyperlinkinkInNewTab = n;
},
setOpacity(n) {
this.opacity = n;
},
setBackgroundOpacity(n) {
this.backgroundOpacity = n;
},
setTextAreaVueModel(n) {
this.textAreaVueModel = n;
},
setClass(n) {
this.currentClasses = [...this.currentClasses, n];
},
removeClass(n) {
this.currentClasses = this.currentClasses.filter((e) => e !== n);
},
setCurrentClasses(n) {
this.currentClasses = Array.from(n);
},
setCurrentStyles(n) {
this.currentStyles = n;
},
setFontVerticalPadding(n) {
this.fontVerticalPadding = n;
},
setFontHorizontalPadding(n) {
this.fontHorizontalPadding = n;
},
setFontVerticalMargin(n) {
this.fontVerticalMargin = n;
},
setFontHorizontalMargin(n) {
this.fontHorizontalMargin = n;
},
setFontStyle(n) {
this.fontStyle = n;
},
setFontFamily(n) {
this.fontFamily = n;
},
setFontWeight(n) {
this.fontWeight = n;
},
setFontBase(n) {
this.fontBase = n;
},
setFontDesktop(n) {
this.fontDesktop = n;
},
setFontTablet(n) {
this.fontTablet = n;
},
setFontMobile(n) {
this.fontMobile = n;
},
setBackgroundColor(n) {
this.backgroundColor = n;
},
setTextColor(n) {
this.textColor = n;
},
setElement(n) {
this.element = null, ce(() => {
this.element = n;
});
},
setComponent(n) {
if (!n) {
this.element = null, this.component = null;
return;
}
this.component = null, ce(() => {
this.component = n;
});
},
setComponents(n) {
this.components = [], ce(() => {
this.components = n || [];
});
},
setPushComponents(n) {
const e = n.componentArrayAddMethod ?? "push";
e === "push" ? this.components.push(n.component) : e === "unshift" && this.components.unshift(n.component);
},
setBasePrimaryImage(n) {
this.element && (this.element.src = n ?? void 0), this.basePrimaryImage = n;
},
setCurrentLayoutPreview(n) {
localStorage.setItem("preview", n);
},
setPageBuilderConfig(n) {
this.configPageBuilder = n;
},
setApplyImageToSelection(n) {
this.applyImageToSelection = n;
},
setCurrentPreviewImage(n) {
this.currentPreviewImage = n;
},
// User Actions
setBuilderStarted(n) {
this.builderStarted = n;
},
setIsLoadingGlobal(n) {
this.isLoadingGlobal = n;
},
setIsSaving(n) {
this.isSaving = n;
},
setHasLocalDraftForUpdate(n) {
this.hasLocalDraftForUpdate = n;
},
setIsLoadingResumeEditing(n) {
this.isResumeEditing = n;
},
setIsRestoring(n) {
this.isRestoring = n;
},
setCurrentLanguage(n) {
this.currentLanguage = n;
},
setHistoryIndex(n) {
this.historyIndex = n;
},
setHistoryLength(n) {
this.historyLength = n;
}
}
}), bh = qw(), Se = Xw(bh), Qw = { class: "pbx-myInputGroup" }, Zw = {
class: "pbx-myPrimaryInputLabel",
for: "roles"
}, eS = {
key: 0,
class: "pbx-min-h-[2.5rem] pbx-flex pbx-items-center pbx-justify-start"
}, tS = { class: "pbx-myPrimaryInputError pbx-mt-2 pbx-mb-0 pbx-py-0 pbx-self-start" }, nS = { class: "pbx-blockease-linear pbx-duration-200 pbx-block pbx-ease-linear" }, rS = { key: 0 }, oS = { class: "pbx-relative pbx-rounded-lg" }, iS = { class: "pbx-flex pbx-justify-between pbx-myPrimaryGap pbx-items-center pbx-pb-2 pbx-mb-2 pbx-px-4 pbx-overflow-x-auto pbx-border-0 pbx-border-b pbx-border-solid pbx-border-gray-200" }, sS = { class: "pbx-px-2 pbx-flex pbx-items-center pbx-justify-start pbx-gap-2 pbx-w-max pbx-p-1 pbx-rounded-full pbx-border-solid pbx-border pbx-border-gray-200 pbx-shadow-sm" }, lS = { class: "pbx-flex pbx-items-center pbx-p-1 pbx-rounded-full pbx-border-solid pbx-border pbx-border-gray-200 pbx-shadow-sm" }, aS = { class: "pbx-px-2 pbx-flex pbx-items-center pbx-justify-start pbx-gap-2 pbx-w-max" }, cS = { class: "pbx-px-2 pbx-flex pbx-items-center pbx-justify-start pbx-gap-2 pbx-w-max" }, pS = { class: "pbx-px-2 pbx-flex pbx-items-center pbx-justify-start pbx-gap-2 pbx-w-max" }, uS = { class: "pbx-px-2 pbx-flex pbx-items-center pbx-justify-start pbx-gap-2 pbx-w-max" }, dS = { class: "pbx-px-2 pbx-flex pbx-items-center pbx-justify-start pbx-gap-2 pbx-w-max" }, fS = { class: "pbx-px-2 pbx-flex pbx-items-center pbx-justify-start pbx-gap-2 pbx-w-max" }, hS = {
__name: "TipTapInput",
setup(n) {
const e = Ce(), { translate: t } = Me(), r = Se, o = M(!1), i = M(""), s = M(1), l = M(""), a = M(""), c = M(""), p = M(null), u = M(null), f = M(null), h = M(null), b = M(null), m = I(() => r.getElement), x = M(""), v = I(() => S.value ? S.value.getHTML() : null), C = M(0);
ee(m, (N) => {
const $ = document.createElement("div");
if (N) {
$.innerHTML = N;
const K = $.textContent;
C.value = K.length;
}
});
const S = Yv({
content: "",
extensions: [
Y1,
ww.configure({
openOnClick: !1
})
],
editorProps: {
attributes: {
class: "prose-sm sm:prose-sm lg:prose-sm focus:outline-none"
}
}
});
ee(v, async (N) => {
e.isSelectedElementValidText() && m.value && (r.setTextAreaVueModel(N), typeof N == "string" && N !== x.value && await e.handleTextInput(N));
});
const g = function() {
e.isSelectedElementValidText() && S.value && S.value.commands.setContent(m.value.innerHTML);
};
ee(m, () => {
g();
});
const O = M(""), T = M(""), B = M(null);
ee(O, (N) => {
T.value = N;
});
const F = function() {
O.value = S.value.getAttributes("link").href, o.value = !0, i.value = "success", s.value = 2, l.value = t("Enter URL"), a.value = t(
"Add a valid URL to transform the selected text into a clickable hyperlink that directs users to the specified web address."
), c.value = t("Close"), p.value = O.value ? "Remove url" : null, u.value = t("Save"), f.value = function() {
o.value = !1, B.value = null;
}, h.value = function() {
S.value.chain().focus().extendMarkRange("link").unsetLink().run(), o.value = !1;
}, b.value = function() {
const N = W();
N || (N || L(), o.value = !1);
};
}, W = function() {
B.value = null;
const N = /^https?:\/\//, $ = M(!0);
return $.value = N.test(T.value), $.value === !1 ? (B.value = "The provided URL is invalid. Please ensure that it begins with 'https://' for proper formatting and security.", !0) : !1;
}, L = function() {
S.value.chain().focus().extendMarkRange("link").setLink({ href: T.value }).run();
};
return jh(() => {
var N;
(N = S.value) == null || N.destroy();
}), pn(() => {
g();
}), (N, $) => (w(), E("div", null, [
j(yr, {
maxWidth: "4xl",
showDynamicModalBuilder: o.value,
type: i.value,
gridColumnAmount: s.value,
title: l.value,
description: a.value,
firstButtonText: c.value,
secondButtonText: p.value,
thirdButtonText: u.value,
onFirstModalButtonFunctionDynamicModalBuilder: f.value,
onSecondModalButtonFunctionDynamicModalBuilder: h.value,
onThirdModalButtonFunctionDynamicModalBuilder: b.value
}, {
default: V(() => [
$[7] || ($[7] = d("header", null, null, -1)),
d("main", null, [
d("div", Qw, [
d("label", Zw, [
d("span", null, k(y(t)("Enter URL")), 1)
]),
xe(d("input", {
"onUpdate:modelValue": $[0] || ($[0] = (K) => O.value = K),
class: "pbx-myPrimaryInput pbx-mt-1 pbx-w-full",
type: "url",
placeholder: "url"
}, null, 512), [
[gr, O.value]
]),
B.value ? (w(), E("div", eS, [
d("p", tS, k(B.value), 1)
])) : A("", !0)
])
])
]),
_: 1,
__: [7]
}, 8, ["showDynamicModalBuilder", "type", "gridColumnAmount", "title", "description", "firstButtonText", "secondButtonText", "thirdButtonText", "onFirstModalButtonFunctionDynamicModalBuilder", "onSecondModalButtonFunctionDynamicModalBuilder", "onThirdModalButtonFunctionDynamicModalBuilder"]),
d("div", nS, [
y(e).isSelectedElementValidText() && y(S) ? (w(), E("div", rS, [
d("div", oS, [
d("div", iS, [
d("div", null, [
d("div", null, [
d("div", sS, [
d("button", {
onClick: $[1] || ($[1] = (K) => y(e).toggleTipTapModal(!1)),
type: "button",
class: "pbx-myPrimaryTag pbx-cursor-pointer"
}, [
$[8] || ($[8] = d("span", { class: "material-symbols-outlined" }, " save ", -1)),
d("span", null, k(y(t)("Save")), 1)
])
])
])
]),
d("div", lS, [
d("div", aS, [
d("button", {
onClick: $[2] || ($[2] = (K) => y(S).chain().focus().setHardBreak().run()),
type: "button",
class: "pbx-myPrimaryTag pbx-cursor-pointer"
}, [
$[9] || ($[9] = d("span", { class: "material-symbols-outlined" }, " keyboard_return ", -1)),
d("span", null, k(y(t)("Line break")), 1)
])
]),
d("div", cS, [
d("button", {
onClick: $[3] || ($[3] = (K) => y(S).chain().focus().toggleBold().run()),
type: "button",
class: X(["pbx-myPrimaryTag pbx-cursor-pointer", { "pbx-bg-myPrimaryLinkColor pbx-text-white": y(S).isActive("bold") }])
}, [
$[10] || ($[10] = d("span", { class: "material-symbols-outlined" }, " format_bold ", -1)),
d("span", null, k(y(t)("Bold")), 1)
], 2)
]),
d("div", pS, [
d("button", {
onClick: F,
type: "button",
class: X(["pbx-myPrimaryTag pbx-cursor-pointer", { "pbx-bg-myPrimaryLinkColor pbx-text-white": y(S).isActive("link") }])
}, [
$[11] || ($[11] = d("span", { class: "material-symbols-outlined" }, " link ", -1)),
d("span", null, k(y(t)("Link")), 1)
], 2)
]),
d("div", uS, [
d("button", {
onClick: $[4] || ($[4] = (K) => y(S).chain().focus().toggleHeading({ level: 2 }).run()),
type: "button",
class: X(["pbx-myPrimaryTag pbx-cursor-pointer", {
"pbx-bg-myPrimaryLinkColor pbx-text-white": y(S).isActive("heading", {
level: 2
})
}])
}, [
$[12] || ($[12] = d("span", { class: "material-symbols-outlined" }, " titlecase ", -1)),
d("span", null, k(y(t)("Header 2")), 1)
], 2)
]),
d("div", dS, [
d("button", {
onClick: $[5] || ($[5] = (K) => y(S).chain().focus().toggleHeading({ level: 3 }).run()),
type: "button",
class: X(["pbx-myPrimaryTag pbx-cursor-pointer", {
"pbx-bg-myPrimaryLinkColor pbx-text-white": y(S).isActive("heading", {
level: 3
})
}])
}, [
$[13] || ($[13] = d("span", { class: "material-symbols-outlined" }, " titlecase ", -1)),
d("span", null, k(y(t)("Header 3")), 1)
], 2)
]),
d("div", fS, [
d("button", {
onClick: $[6] || ($[6] = (K) => y(S).chain().focus().toggleBulletList().run()),
type: "button",
class: X(["pbx-myPrimaryTag pbx-cursor-pointer", {
"pbx-bg-myPrimaryLinkColor pbx-text-white": y(S).isActive("bulletList")
}])
}, [
$[14] || ($[14] = d("span", { class: "material-symbols-outlined" }, " list ", -1)),
d("span", null, k(y(t)("List")), 1)
], 2)
])
])
]),
j(y(Jv), {
id: "page-builder-editor",
editor: y(S),
class: "pbx-p-2 pbx-prounded-lg lg:pbx-min-h-[20rem] lg:pbx-max-h-[30rem] md:pbx-min-h-[20rem] md:pbx-max-h-[20rem] pbx-min-h-[20rem] pbx-max-h-[20rem] pbx-overflow-y-auto"
}, null, 8, ["editor"])
])
])) : A("", !0)
])
]));
}
}, Gs = (n, e) => {
const t = n.__vccOpts || n;
for (const [r, o] of e)
t[r] = o;
return t;
}, bS = {}, mS = { class: "pbx-min-h-40" };
function xS(n, e) {
return w(), E("div", mS, e[0] || (e[0] = [
d("p", { class: "pbx-myPrimaryParagraph" }, [
we(" Provide your own Media Library Component to integrate a custom media picker into the Page Builder. "),
d("br"),
we(" This allows full control over how media is selected and inserted. ")
], -1)
]));
}
const gS = /* @__PURE__ */ Gs(bS, [["render", xS]]), yS = {
key: 0,
class: "pbx-w-full"
}, vS = { key: 1 }, mh = {
__name: "MediaLibraryModal",
props: {
title: {
type: String,
required: !0
},
description: {
required: !0
},
firstButtonText: {
type: String
},
secondButtonText: {
type: String
},
thirdButtonText: {
type: String
},
open: {
required: !0
},
customMediaComponent: {
type: Object,
default: null
}
},
emits: ["firstMediaButtonFunction"],
setup(n, { emit: e }) {
const t = e, r = function() {
t("firstMediaButtonFunction");
};
return En("closeMediaLibraryModal", () => {
r();
}), (i, s) => (w(), pe(Vt, {
title: n.title,
showModalBuilder: n.open,
onCloseMainModalBuilder: r,
maxWidth: "6xl"
}, {
default: V(() => [
n.customMediaComponent ? (w(), E("div", yS, [
(w(), pe(Au(n.customMediaComponent)))
])) : (w(), E("div", vS, [
j(gS)
]))
]),
_: 1
}, 8, ["title", "showModalBuilder"]));
}
};
function wS(n, e, t) {
let r = M(t == null ? void 0 : t.value), o = I(() => n.value !== void 0);
return [I(() => o.value ? n.value : r.value), function(i) {
return o.value || (r.value = i), e == null ? void 0 : e(i);
}];
}
var hu;
let SS = Symbol("headlessui.useid"), kS = 0;
const Js = (hu = gc.useId) != null ? hu : function() {
return gc.inject(SS, () => `${++kS}`)();
};
function ke(n) {
var e;
if (n == null || n.value == null) return null;
let t = (e = n.value.$el) != null ? e : n.value;
return t instanceof Node ? t : null;
}
function _t(n, e, ...t) {
if (n in e) {
let o = e[n];
return typeof o == "function" ? o(...t) : o;
}
let r = new Error(`Tried to handle "${n}" but there is no handler defined. Only defined handlers are: ${Object.keys(e).map((o) => `"${o}"`).join(", ")}.`);
throw Error.captureStackTrace && Error.captureStackTrace(r, _t), r;
}
var CS = Object.defineProperty, MS = (n, e, t) => e in n ? CS(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, bu = (n, e, t) => (MS(n, typeof e != "symbol" ? e + "" : e, t), t);
let ES = class {
constructor() {
bu(this, "current", this.detect()), bu(this, "currentId", 0);
}
set(e) {
this.current !== e && (this.currentId = 0, this.current = e);
}
reset() {
this.set(this.detect());
}
nextId() {
return ++this.currentId;
}
get isServer() {
return this.current === "server";
}
get isClient() {
return this.current === "client";
}
detect() {
return typeof window > "u" || typeof document > "u" ? "server" : "client";
}
}, mc = new ES();
function TS(n) {
if (mc.isServer) return null;
if (n instanceof Node) return n.ownerDocument;
if (n != null && n.hasOwnProperty("value")) {
let e = ke(n);
if (e) return e.ownerDocument;
}
return document;
}
let mu = ["[contentEditable=true]", "[tabindex]", "a[href]", "area[href]", "button:not([disabled])", "iframe", "input:not([disabled])", "select:not([disabled])", "textarea:not([disabled])"].map((n) => `${n}:not([tabindex='-1'])`).join(",");
var OS = ((n) => (n[n.First = 1] = "First", n[n.Previous = 2] = "Previous", n[n.Next = 4] = "Next", n[n.Last = 8] = "Last", n[n.WrapAround = 16] = "WrapAround", n[n.NoScroll = 32] = "NoScroll", n))(OS || {}), BS = ((n) => (n[n.Error = 0] = "Error", n[n.Overflow = 1] = "Overflow", n[n.Success = 2] = "Success", n[n.Underflow = 3] = "Underflow", n))(BS || {}), PS = ((n) => (n[n.Previous = -1] = "Previous", n[n.Next = 1] = "Next", n))(PS || {}), xc = ((n) => (n[n.Strict = 0] = "Strict", n[n.Loose = 1] = "Loose", n))(xc || {});
function xh(n, e = 0) {
var t;
return n === ((t = TS(n)) == null ? void 0 : t.body) ? !1 : _t(e, { 0() {
return n.matches(mu);
}, 1() {
let r = n;
for (; r !== null; ) {
if (r.matches(mu)) return !0;
r = r.parentElement;
}
return !1;
} });
}
var AS = ((n) => (n[n.Keyboard = 0] = "Keyboard", n[n.Mouse = 1] = "Mouse", n))(AS || {});
typeof window < "u" && typeof document < "u" && (document.addEventListener("keydown", (n) => {
n.metaKey || n.altKey || n.ctrlKey || (document.documentElement.dataset.headlessuiFocusVisible = "");
}, !0), document.addEventListener("click", (n) => {
n.detail === 1 ? delete document.documentElement.dataset.headlessuiFocusVisible : n.detail === 0 && (document.documentElement.dataset.headlessuiFocusVisible = "");
}, !0));
function _S(n, e = (t) => t) {
return n.slice().sort((t, r) => {
let o = e(t), i = e(r);
if (o === null || i === null) return 0;
let s = o.compareDocumentPosition(i);
return s & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : s & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
});
}
function LS() {
return /iPhone/gi.test(window.navigator.platform) || /Mac/gi.test(window.navigator.platform) && window.navigator.maxTouchPoints > 0;
}
function NS() {
return /Android/gi.test(window.navigator.userAgent);
}
function DS() {
return LS() || NS();
}
function Oi(n, e, t) {
mc.isServer || ro((r) => {
document.addEventListener(n, e, t), r(() => document.removeEventListener(n, e, t));
});
}
function IS(n, e, t) {
mc.isServer || ro((r) => {
window.addEventListener(n, e, t), r(() => window.removeEventListener(n, e, t));
});
}
function $S(n, e, t = I(() => !0)) {
function r(i, s) {
if (!t.value || i.defaultPrevented) return;
let l = s(i);
if (l === null || !l.getRootNode().contains(l)) return;
let a = function c(p) {
return typeof p == "function" ? c(p()) : Array.isArray(p) || p instanceof Set ? p : [p];
}(n);
for (let c of a) {
if (c === null) continue;
let p = c instanceof HTMLElement ? c : ke(c);
if (p != null && p.contains(l) || i.composed && i.composedPath().includes(p)) return;
}
return !xh(l, xc.Loose) && l.tabIndex !== -1 && i.preventDefault(), e(i, l);
}
let o = M(null);
Oi("pointerdown", (i) => {
var s, l;
t.value && (o.value = ((l = (s = i.composedPath) == null ? void 0 : s.call(i)) == null ? void 0 : l[0]) || i.target);
}, !0), Oi("mousedown", (i) => {
var s, l;
t.value && (o.value = ((l = (s = i.composedPath) == null ? void 0 : s.call(i)) == null ? void 0 : l[0]) || i.target);
}, !0), Oi("click", (i) => {
DS() || o.value && (r(i, () => o.value), o.value = null);
}, !0), Oi("touchend", (i) => r(i, () => i.target instanceof HTMLElement ? i.target : null), !0), IS("blur", (i) => r(i, () => window.document.activeElement instanceof HTMLIFrameElement ? window.document.activeElement : null), !0);
}
function xu(n, e) {
if (n) return n;
let t = e ?? "button";
if (typeof t == "string" && t.toLowerCase() === "button") return "button";
}
function RS(n, e) {
let t = M(xu(n.value.type, n.value.as));
return pn(() => {
t.value = xu(n.value.type, n.value.as);
}), ro(() => {
var r;
t.value || ke(e) && ke(e) instanceof HTMLButtonElement && !((r = ke(e)) != null && r.hasAttribute("type")) && (t.value = "button");
}), t;
}
function gu(n) {
return [n.screenX, n.screenY];
}
function FS() {
let n = M([-1, -1]);
return { wasMoved(e) {
let t = gu(e);
return n.value[0] === t[0] && n.value[1] === t[1] ? !1 : (n.value = t, !0);
}, update(e) {
n.value = gu(e);
} };
}
var wa = ((n) => (n[n.None = 0] = "None", n[n.RenderStrategy = 1] = "RenderStrategy", n[n.Static = 2] = "Static", n))(wa || {}), HS = ((n) => (n[n.Unmount = 0] = "Unmount", n[n.Hidden = 1] = "Hidden", n))(HS || {});
function lo({ visible: n = !0, features: e = 0, ourProps: t, theirProps: r, ...o }) {
var i;
let s = yh(r, t), l = Object.assign(o, { props: s });
if (n || e & 2 && s.static) return Al(l);
if (e & 1) {
let a = (i = s.unmount) == null || i ? 0 : 1;
return _t(a, { 0() {
return null;
}, 1() {
return Al({ ...o, props: { ...s, hidden: !0, style: { display: "none" } } });
} });
}
return Al(l);
}
function Al({ props: n, attrs: e, slots: t, slot: r, name: o }) {
var i, s;
let { as: l, ...a } = vh(n, ["unmount", "static"]), c = (i = t.default) == null ? void 0 : i.call(t, r), p = {};
if (r) {
let u = !1, f = [];
for (let [h, b] of Object.entries(r)) typeof b == "boolean" && (u = !0), b === !0 && f.push(h);
u && (p["data-headlessui-state"] = f.join(" "));
}
if (l === "template") {
if (c = gh(c ?? []), Object.keys(a).length > 0 || Object.keys(e).length > 0) {
let [u, ...f] = c ?? [];
if (!zS(u) || f.length > 0) throw new Error(['Passing props on "template"!', "", `The current component <${o} /> is rendering a "template".`, "However we need to passthrough the following props:", Object.keys(a).concat(Object.keys(e)).map((m) => m.trim()).filter((m, x, v) => v.indexOf(m) === x).sort((m, x) => m.localeCompare(x)).map((m) => ` - ${m}`).join(`
`), "", "You can apply a few solutions:", ['Add an `as="..."` prop, to ensure that we render an actual element instead of a "template".', "Render a single element as the child so that we can forward the props onto that element."].map((m) => ` - ${m}`).join(`
`)].join(`
`));
let h = yh((s = u.props) != null ? s : {}, a, p), b = zh(u, h, !0);
for (let m in h) m.startsWith("on") && (b.props || (b.props = {}), b.props[m] = h[m]);
return b;
}
return Array.isArray(c) && c.length === 1 ? c[0] : c;
}
return jn(l, Object.assign({}, a, p), { default: () => c });
}
function gh(n) {
return n.flatMap((e) => e.type === Z ? gh(e.children) : [e]);
}
function yh(...n) {
if (n.length === 0) return {};
if (n.length === 1) return n[0];
let e = {}, t = {};
for (let r of n) for (let o in r) o.startsWith("on") && typeof r[o] == "function" ? (t[o] != null || (t[o] = []), t[o].push(r[o])) : e[o] = r[o];
if (e.disabled || e["aria-disabled"]) return Object.assign(e, Object.fromEntries(Object.keys(t).map((r) => [r, void 0])));
for (let r in t) Object.assign(e, { [r](o, ...i) {
let s = t[r];
for (let l of s) {
if (o instanceof Event && o.defaultPrevented) return;
l(o, ...i);
}
} });
return e;
}
function jS(n) {
let e = Object.assign({}, n);
for (let t in e) e[t] === void 0 && delete e[t];
return e;
}
function vh(n, e = []) {
let t = Object.assign({}, n);
for (let r of e) r in t && delete t[r];
return t;
}
function zS(n) {
return n == null ? !1 : typeof n.type == "string" || typeof n.type == "object" || typeof n.type == "function";
}
var wh = ((n) => (n[n.None = 1] = "None", n[n.Focusable = 2] = "Focusable", n[n.Hidden = 4] = "Hidden", n))(wh || {});
let VS = Qe({ name: "Hidden", props: { as: { type: [Object, String], default: "div" }, features: { type: Number, default: 1 } }, setup(n, { slots: e, attrs: t }) {
return () => {
var r;
let { features: o, ...i } = n, s = { "aria-hidden": (o & 2) === 2 ? !0 : (r = i["aria-hidden"]) != null ? r : void 0, hidden: (o & 4) === 4 ? !0 : void 0, style: { position: "fixed", top: 1, left: 1, width: 1, height: 0, padding: 0, margin: -1, overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", borderWidth: "0", ...(o & 4) === 4 && (o & 2) !== 2 && { display: "none" } } };
return lo({ ourProps: s, theirProps: i, slot: {}, attrs: t, slots: e, name: "Hidden" });
};
} }), Sh = Symbol("Context");
var Qo = ((n) => (n[n.Open = 1] = "Open", n[n.Closed = 2] = "Closed", n[n.Closing = 4] = "Closing", n[n.Opening = 8] = "Opening", n))(Qo || {});
function WS() {
return zn(Sh, null);
}
function US(n) {
En(Sh, n);
}
var Be = ((n) => (n.Space = " ", n.Enter = "Enter", n.Escape = "Escape", n.Backspace = "Backspace", n.Delete = "Delete", n.ArrowLeft = "ArrowLeft", n.ArrowUp = "ArrowUp", n.ArrowRight = "ArrowRight", n.ArrowDown = "ArrowDown", n.Home = "Home", n.End = "End", n.PageUp = "PageUp", n.PageDown = "PageDown", n.Tab = "Tab", n))(Be || {});
function qS(n) {
throw new Error("Unexpected object: " + n);
}
var Ge = ((n) => (n[n.First = 0] = "First", n[n.Previous = 1] = "Previous", n[n.Next = 2] = "Next", n[n.Last = 3] = "Last", n[n.Specific = 4] = "Specific", n[n.Nothing = 5] = "Nothing", n))(Ge || {});
function KS(n, e) {
let t = e.resolveItems();
if (t.length <= 0) return null;
let r = e.resolveActiveIndex(), o = r ?? -1;
switch (n.focus) {
case 0: {
for (let i = 0; i < t.length; ++i) if (!e.resolveDisabled(t[i], i, t)) return i;
return r;
}
case 1: {
o === -1 && (o = t.length);
for (let i = o - 1; i >= 0; --i) if (!e.resolveDisabled(t[i], i, t)) return i;
return r;
}
case 2: {
for (let i = o + 1; i < t.length; ++i) if (!e.resolveDisabled(t[i], i, t)) return i;
return r;
}
case 3: {
for (let i = t.length - 1; i >= 0; --i) if (!e.resolveDisabled(t[i], i, t)) return i;
return r;
}
case 4: {
for (let i = 0; i < t.length; ++i) if (e.resolveId(t[i], i, t) === n.id) return i;
return r;
}
case 5:
return null;
default:
qS(n);
}
}
function kh(n = {}, e = null, t = []) {
for (let [r, o] of Object.entries(n)) Mh(t, Ch(e, r), o);
return t;
}
function Ch(n, e) {
return n ? n + "[" + e + "]" : e;
}
function Mh(n, e, t) {
if (Array.isArray(t)) for (let [r, o] of t.entries()) Mh(n, Ch(e, r.toString()), o);
else t instanceof Date ? n.push([e, t.toISOString()]) : typeof t == "boolean" ? n.push([e, t ? "1" : "0"]) : typeof t == "string" ? n.push([e, t]) : typeof t == "number" ? n.push([e, `${t}`]) : t == null ? n.push([e, ""]) : kh(t, e, n);
}
let yu = /([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;
function vu(n) {
var e, t;
let r = (e = n.innerText) != null ? e : "", o = n.cloneNode(!0);
if (!(o instanceof HTMLElement)) return r;
let i = !1;
for (let l of o.querySelectorAll('[hidden],[aria-hidden],[role="img"]')) l.remove(), i = !0;
let s = i ? (t = o.innerText) != null ? t : "" : r;
return yu.test(s) && (s = s.replace(yu, "")), s;
}
function GS(n) {
let e = n.getAttribute("aria-label");
if (typeof e == "string") return e.trim();
let t = n.getAttribute("aria-labelledby");
if (t) {
let r = t.split(" ").map((o) => {
let i = document.getElementById(o);
if (i) {
let s = i.getAttribute("aria-label");
return typeof s == "string" ? s.trim() : vu(i).trim();
}
return null;
}).filter(Boolean);
if (r.length > 0) return r.join(", ");
}
return vu(n).trim();
}
function JS(n) {
let e = M(""), t = M("");
return () => {
let r = ke(n);
if (!r) return "";
let o = r.innerText;
if (e.value === o) return t.value;
let i = GS(r).trim().toLowerCase();
return e.value = o, t.value = i, i;
};
}
function YS(n, e) {
return n === e;
}
var XS = ((n) => (n[n.Open = 0] = "Open", n[n.Closed = 1] = "Closed", n))(XS || {}), QS = ((n) => (n[n.Single = 0] = "Single", n[n.Multi = 1] = "Multi", n))(QS || {}), ZS = ((n) => (n[n.Pointer = 0] = "Pointer", n[n.Other = 1] = "Other", n))(ZS || {});
function ek(n) {
requestAnimationFrame(() => requestAnimationFrame(n));
}
let Eh = Symbol("ListboxContext");
function oi(n) {
let e = zn(Eh, null);
if (e === null) {
let t = new Error(`<${n} /> is missing a parent <Listbox /> component.`);
throw Error.captureStackTrace && Error.captureStackTrace(t, oi), t;
}
return e;
}
let ii = Qe({ name: "Listbox", emits: { "update:modelValue": (n) => !0 }, props: { as: { type: [Object, String], default: "template" }, disabled: { type: [Boolean], default: !1 }, by: { type: [String, Function], default: () => YS }, horizontal: { type: [Boolean], default: !1 }, modelValue: { type: [Object, String, Number, Boolean], default: void 0 }, defaultValue: { type: [Object, String, Number, Boolean], default: void 0 }, form: { type: String, optional: !0 }, name: { type: String, optional: !0 }, multiple: { type: [Boolean], default: !1 } }, inheritAttrs: !1, setup(n, { slots: e, attrs: t, emit: r }) {
let o = M(1), i = M(null), s = M(null), l = M(null), a = M([]), c = M(""), p = M(null), u = M(1);
function f(S = (g) => g) {
let g = p.value !== null ? a.value[p.value] : null, O = _S(S(a.value.slice()), (B) => ke(B.dataRef.domRef)), T = g ? O.indexOf(g) : null;
return T === -1 && (T = null), { options: O, activeOptionIndex: T };
}
let h = I(() => n.multiple ? 1 : 0), [b, m] = wS(I(() => n.modelValue), (S) => r("update:modelValue", S), I(() => n.defaultValue)), x = I(() => b.value === void 0 ? _t(h.value, { 1: [], 0: void 0 }) : b.value), v = { listboxState: o, value: x, mode: h, compare(S, g) {
if (typeof n.by == "string") {
let O = n.by;
return (S == null ? void 0 : S[O]) === (g == null ? void 0 : g[O]);
}
return n.by(S, g);
}, orientation: I(() => n.horizontal ? "horizontal" : "vertical"), labelRef: i, buttonRef: s, optionsRef: l, disabled: I(() => n.disabled), options: a, searchQuery: c, activeOptionIndex: p, activationTrigger: u, closeListbox() {
n.disabled || o.value !== 1 && (o.value = 1, p.value = null);
}, openListbox() {
n.disabled || o.value !== 0 && (o.value = 0);
}, goToOption(S, g, O) {
if (n.disabled || o.value === 1) return;
let T = f(), B = KS(S === Ge.Specific ? { focus: Ge.Specific, id: g } : { focus: S }, { resolveItems: () => T.options, resolveActiveIndex: () => T.activeOptionIndex, resolveId: (F) => F.id, resolveDisabled: (F) => F.dataRef.disabled });
c.value = "", p.value = B, u.value = O ?? 1, a.value = T.options;
}, search(S) {
if (n.disabled || o.value === 1) return;
let g = c.value !== "" ? 0 : 1;
c.value += S.toLowerCase();
let O = (p.value !== null ? a.value.slice(p.value + g).concat(a.value.slice(0, p.value + g)) : a.value).find((B) => B.dataRef.textValue.startsWith(c.value) && !B.dataRef.disabled), T = O ? a.value.indexOf(O) : -1;
T === -1 || T === p.value || (p.value = T, u.value = 1);
}, clearSearch() {
n.disabled || o.value !== 1 && c.value !== "" && (c.value = "");
}, registerOption(S, g) {
let O = f((T) => [...T, { id: S, dataRef: g }]);
a.value = O.options, p.value = O.activeOptionIndex;
}, unregisterOption(S) {
let g = f((O) => {
let T = O.findIndex((B) => B.id === S);
return T !== -1 && O.splice(T, 1), O;
});
a.value = g.options, p.value = g.activeOptionIndex, u.value = 1;
}, theirOnChange(S) {
n.disabled || m(S);
}, select(S) {
n.disabled || m(_t(h.value, { 0: () => S, 1: () => {
let g = Ve(v.value.value).slice(), O = Ve(S), T = g.findIndex((B) => v.compare(O, Ve(B)));
return T === -1 ? g.push(O) : g.splice(T, 1), g;
} }));
} };
$S([s, l], (S, g) => {
var O;
v.closeListbox(), xh(g, xc.Loose) || (S.preventDefault(), (O = ke(s)) == null || O.focus());
}, I(() => o.value === 0)), En(Eh, v), US(I(() => _t(o.value, { 0: Qo.Open, 1: Qo.Closed })));
let C = I(() => {
var S;
return (S = ke(s)) == null ? void 0 : S.closest("form");
});
return pn(() => {
ee([C], () => {
if (!C.value || n.defaultValue === void 0) return;
function S() {
v.theirOnChange(n.defaultValue);
}
return C.value.addEventListener("reset", S), () => {
var g;
(g = C.value) == null || g.removeEventListener("reset", S);
};
}, { immediate: !0 });
}), () => {
let { name: S, modelValue: g, disabled: O, form: T, ...B } = n, F = { open: o.value === 0, disabled: O, value: x.value };
return jn(Z, [...S != null && x.value != null ? kh({ [S]: x.value }).map(([W, L]) => jn(VS, jS({ features: wh.Hidden, key: W, as: "input", type: "hidden", hidden: !0, readOnly: !0, form: T, disabled: O, name: W, value: L }))) : [], lo({ ourProps: {}, theirProps: { ...t, ...vh(B, ["defaultValue", "onUpdate:modelValue", "horizontal", "multiple", "by"]) }, slot: F, slots: e, attrs: t, name: "Listbox" })]);
};
} });
Qe({ name: "ListboxLabel", props: { as: { type: [Object, String], default: "label" }, id: { type: String, default: null } }, setup(n, { attrs: e, slots: t }) {
var r;
let o = (r = n.id) != null ? r : `headlessui-listbox-label-${Js()}`, i = oi("ListboxLabel");
function s() {
var l;
(l = ke(i.buttonRef)) == null || l.focus({ preventScroll: !0 });
}
return () => {
let l = { open: i.listboxState.value === 0, disabled: i.disabled.value }, { ...a } = n, c = { id: o, ref: i.labelRef, onClick: s };
return lo({ ourProps: c, theirProps: a, slot: l, attrs: e, slots: t, name: "ListboxLabel" });
};
} });
let Tr = Qe({ name: "ListboxButton", props: { as: { type: [Object, String], default: "button" }, id: { type: String, default: null } }, setup(n, { attrs: e, slots: t, expose: r }) {
var o;
let i = (o = n.id) != null ? o : `headlessui-listbox-button-${Js()}`, s = oi("ListboxButton");
r({ el: s.buttonRef, $el: s.buttonRef });
function l(u) {
switch (u.key) {
case Be.Space:
case Be.Enter:
case Be.ArrowDown:
u.preventDefault(), s.openListbox(), ce(() => {
var f;
(f = ke(s.optionsRef)) == null || f.focus({ preventScroll: !0 }), s.value.value || s.goToOption(Ge.First);
});
break;
case Be.ArrowUp:
u.preventDefault(), s.openListbox(), ce(() => {
var f;
(f = ke(s.optionsRef)) == null || f.focus({ preventScroll: !0 }), s.value.value || s.goToOption(Ge.Last);
});
break;
}
}
function a(u) {
switch (u.key) {
case Be.Space:
u.preventDefault();
break;
}
}
function c(u) {
s.disabled.value || (s.listboxState.value === 0 ? (s.closeListbox(), ce(() => {
var f;
return (f = ke(s.buttonRef)) == null ? void 0 : f.focus({ preventScroll: !0 });
})) : (u.preventDefault(), s.openListbox(), ek(() => {
var f;
return (f = ke(s.optionsRef)) == null ? void 0 : f.focus({ preventScroll: !0 });
})));
}
let p = RS(I(() => ({ as: n.as, type: e.type })), s.buttonRef);
return () => {
var u, f;
let h = { open: s.listboxState.value === 0, disabled: s.disabled.value, value: s.value.value }, { ...b } = n, m = { ref: s.buttonRef, id: i, type: p.value, "aria-haspopup": "listbox", "aria-controls": (u = ke(s.optionsRef)) == null ? void 0 : u.id, "aria-expanded": s.listboxState.value === 0, "aria-labelledby": s.labelRef.value ? [(f = ke(s.labelRef)) == null ? void 0 : f.id, i].join(" ") : void 0, disabled: s.disabled.value === !0 ? !0 : void 0, onKeydown: l, onKeyup: a, onClick: c };
return lo({ ourProps: m, theirProps: b, slot: h, attrs: e, slots: t, name: "ListboxButton" });
};
} }), si = Qe({ name: "ListboxOptions", props: { as: { type: [Object, String], default: "ul" }, static: { type: Boolean, default: !1 }, unmount: { type: Boolean, default: !0 }, id: { type: String, default: null } }, setup(n, { attrs: e, slots: t, expose: r }) {
var o;
let i = (o = n.id) != null ? o : `headlessui-listbox-options-${Js()}`, s = oi("ListboxOptions"), l = M(null);
r({ el: s.optionsRef, $el: s.optionsRef });
function a(u) {
switch (l.value && clearTimeout(l.value), u.key) {
case Be.Space:
if (s.searchQuery.value !== "") return u.preventDefault(), u.stopPropagation(), s.search(u.key);
case Be.Enter:
if (u.preventDefault(), u.stopPropagation(), s.activeOptionIndex.value !== null) {
let f = s.options.value[s.activeOptionIndex.value];
s.select(f.dataRef.value);
}
s.mode.value === 0 && (s.closeListbox(), ce(() => {
var f;
return (f = ke(s.buttonRef)) == null ? void 0 : f.focus({ preventScroll: !0 });
}));
break;
case _t(s.orientation.value, { vertical: Be.ArrowDown, horizontal: Be.ArrowRight }):
return u.preventDefault(), u.stopPropagation(), s.goToOption(Ge.Next);
case _t(s.orientation.value, { vertical: Be.ArrowUp, horizontal: Be.ArrowLeft }):
return u.preventDefault(), u.stopPropagation(), s.goToOption(Ge.Previous);
case Be.Home:
case Be.PageUp:
return u.preventDefault(), u.stopPropagation(), s.goToOption(Ge.First);
case Be.End:
case Be.PageDown:
return u.preventDefault(), u.stopPropagation(), s.goToOption(Ge.Last);
case Be.Escape:
u.preventDefault(), u.stopPropagation(), s.closeListbox(), ce(() => {
var f;
return (f = ke(s.buttonRef)) == null ? void 0 : f.focus({ preventScroll: !0 });
});
break;
case Be.Tab:
u.preventDefault(), u.stopPropagation();
break;
default:
u.key.length === 1 && (s.search(u.key), l.value = setTimeout(() => s.clearSearch(), 350));
break;
}
}
let c = WS(), p = I(() => c !== null ? (c.value & Qo.Open) === Qo.Open : s.listboxState.value === 0);
return () => {
var u, f;
let h = { open: s.listboxState.value === 0 }, { ...b } = n, m = { "aria-activedescendant": s.activeOptionIndex.value === null || (u = s.options.value[s.activeOptionIndex.value]) == null ? void 0 : u.id, "aria-multiselectable": s.mode.value === 1 ? !0 : void 0, "aria-labelledby": (f = ke(s.buttonRef)) == null ? void 0 : f.id, "aria-orientation": s.orientation.value, id: i, onKeydown: a, role: "listbox", tabIndex: 0, ref: s.optionsRef };
return lo({ ourProps: m, theirProps: b, slot: h, attrs: e, slots: t, features: wa.RenderStrategy | wa.Static, visible: p.value, name: "ListboxOptions" });
};
} }), li = Qe({ name: "ListboxOption", props: { as: { type: [Object, String], default: "li" }, value: { type: [Object, String, Number, Boolean] }, disabled: { type: Boolean, default: !1 }, id: { type: String, default: null } }, setup(n, { slots: e, attrs: t, expose: r }) {
var o;
let i = (o = n.id) != null ? o : `headlessui-listbox-option-${Js()}`, s = oi("ListboxOption"), l = M(null);
r({ el: l, $el: l });
let a = I(() => s.activeOptionIndex.value !== null ? s.options.value[s.activeOptionIndex.value].id === i : !1), c = I(() => _t(s.mode.value, { 0: () => s.compare(Ve(s.value.value), Ve(n.value)), 1: () => Ve(s.value.value).some((S) => s.compare(Ve(S), Ve(n.value))) })), p = I(() => _t(s.mode.value, { 1: () => {
var S;
let g = Ve(s.value.value);
return ((S = s.options.value.find((O) => g.some((T) => s.compare(Ve(T), Ve(O.dataRef.value))))) == null ? void 0 : S.id) === i;
}, 0: () => c.value })), u = JS(l), f = I(() => ({ disabled: n.disabled, value: n.value, get textValue() {
return u();
}, domRef: l }));
pn(() => s.registerOption(i, f)), Vh(() => s.unregisterOption(i)), pn(() => {
ee([s.listboxState, c], () => {
s.listboxState.value === 0 && c.value && _t(s.mode.value, { 1: () => {
p.value && s.goToOption(Ge.Specific, i);
}, 0: () => {
s.goToOption(Ge.Specific, i);
} });
}, { immediate: !0 });
}), ro(() => {
s.listboxState.value === 0 && a.value && s.activationTrigger.value !== 0 && ce(() => {
var S, g;
return (g = (S = ke(l)) == null ? void 0 : S.scrollIntoView) == null ? void 0 : g.call(S, { block: "nearest" });
});
});
function h(S) {
if (n.disabled) return S.preventDefault();
s.select(n.value), s.mode.value === 0 && (s.closeListbox(), ce(() => {
var g;
return (g = ke(s.buttonRef)) == null ? void 0 : g.focus({ preventScroll: !0 });
}));
}
function b() {
if (n.disabled) return s.goToOption(Ge.Nothing);
s.goToOption(Ge.Specific, i);
}
let m = FS();
function x(S) {
m.update(S);
}
function v(S) {
m.wasMoved(S) && (n.disabled || a.value || s.goToOption(Ge.Specific, i, 0));
}
function C(S) {
m.wasMoved(S) && (n.disabled || a.value && s.goToOption(Ge.Nothing));
}
return () => {
let { disabled: S } = n, g = { active: a.value, selected: c.value, disabled: S }, { value: O, disabled: T, ...B } = n, F = { id: i, ref: l, role: "option", tabIndex: S === !0 ? void 0 : -1, "aria-disabled": S === !0 ? !0 : void 0, "aria-selected": c.value, disabled: void 0, onClick: h, onFocus: b, onPointerenter: x, onMouseenter: x, onPointermove: v, onMousemove: v, onPointerleave: C, onMouseleave: C };
return lo({ ourProps: F, theirProps: B, slot: g, attrs: t, slots: e, name: "ListboxOption" });
};
} });
const tk = { class: "pbx-relative" }, nk = { class: "pbx-flex pbx-justify-start pbx-items-center pbx-gap-2" }, rk = {
key: 0,
class: "material-symbols-outlined"
}, ok = { class: "pbx-flex pbx-flex-col" }, ik = { class: "pbx-flex pbx-gap-2 pbx-items-center" }, sk = {
key: 0,
class: "pbx-flex pbx-items-center"
}, lk = {
key: 1,
class: "pbx-flex pbx-items-center"
}, ak = { class: "pbx-ml-3" }, Th = {
__name: "TextColorEditor",
props: {
globalPageLayout: {
Type: Boolean
}
},
setup(n) {
const { translate: e } = Me(), t = Ce(), r = Se, o = M(null), i = I(() => r.getTextColor);
return ee(
i,
async (s) => {
o.value = s, await t.initializeElementStyles();
},
{ immediate: !0 }
), (s, l) => (w(), pe(y(ii), {
as: "div",
modelValue: o.value,
"onUpdate:modelValue": l[1] || (l[1] = (a) => o.value = a)
}, {
default: V(() => [
d("div", tk, [
d("div", {
class: X([
n.globalPageLayout ? "pbx-flex pbx-flex-col pbx-border-solid pbx-border pbx-border-gray-400" : "pbx-flex pbx-gap-2 pbx-items-center"
])
}, [
n.globalPageLayout ? (w(), pe(y(Tr), {
key: 0,
class: "pbx-flex pbx-flex-row pbx-justify-between pbx-items-center pbx-pl-3 pbx-pr-3 pbx-py-5 pbx-cursor-pointer pbx-duration-200 hover:pbx-bg-myPrimaryLightGrayColor pbx-bg-white hover:pbx-text-black pbx-text-black pbx-font-sans pbx-font-medium pbx-border-0"
}, {
default: V(() => {
var a;
return [
d("div", nk, [
d("div", {
class: X(["pbx-aspect-square pbx-w-6 pbx-h-6 pbx-border pbx-border-gray-600 pbx-rounded-sm pbx-bg-none pbx-border-solid", `pbx-bg-${(a = o.value) == null ? void 0 : a.replace("pbx-text-", "")}`])
}, null, 2),
d("div", null, [
d("div", null, k(y(e)("Text Color")), 1)
])
]),
n.globalPageLayout ? (w(), E("span", rk, " chevron_right ")) : A("", !0)
];
}),
_: 1
})) : A("", !0),
n.globalPageLayout ? A("", !0) : (w(), pe(y(Tr), {
key: 1,
class: "pbx-h-10 pbx-w-10 pbx-flex-end pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-200 pbx-aspect-square hover:pbx-bg-gray-100 hover:pbx-fill-white focus-visible:pbx-ring-0 pbx-text-myPrimaryDarkGrayColor"
}, {
default: V(() => {
var a;
return [
d("div", ok, [
d("div", ik, [
d("span", {
class: X(["material-symbols-outlined", `pbx-text-${(a = o.value) == null ? void 0 : a.replace("pbx-text-", "")}`]),
style: { "text-shadow": "rgb(0 0 0 / 10%) 1.5px 1.5px 0px" }
}, " format_color_text ", 2)
])
])
];
}),
_: 1
}))
], 2),
j(oo, {
"leave-active-class": "pbx-transition pbx-ease-in pbx-duration-100",
"leave-from-class": "pbx-opacity-100",
"leave-to-class": "pbx-opacity-0"
}, {
default: V(() => [
j(y(si), { class: "pbx-headless-dropdown pbx-absolute pbx-min-w-[12rem] pbx-z-40 pbx-mt-1 pbx-max-h-56 pbx-w-full pbx-overflow-auto pbx-rounded-md pbx-bg-gray-50 pbx-py-1 pbx-text-base pbx-shadow-lg pbx-ring-1 pbx-ring-black pbx-ring-opacity-5 focus:pbx-outline-none sm:pbx-text-sm" }, {
default: V(() => [
(w(!0), E(Z, null, fe(y(Fi).textColorVariables, (a) => (w(), pe(y(li), {
as: "template",
onClick: l[0] || (l[0] = (c) => y(t).handleTextColor(o.value)),
key: a,
value: a
}, {
default: V(({ active: c, textColor: p }) => [
d("li", {
class: X([
c ? "pbx-bg-myPrimaryLinkColor pbx-text-white" : "pbx-text-myPrimaryDarkGrayColor",
"pbx-relative pbx-cursor-default pbx-select-none pbx-py-2 pbx-pl-3 pbx-pr-9"
])
}, [
a === "none" ? (w(), E("div", sk, l[2] || (l[2] = [
d("span", { class: "material-symbols-outlined" }, " invert_colors ", -1),
d("span", { class: "pbx-ml-3" }, "Default black", -1)
]))) : A("", !0),
a !== "none" ? (w(), E("div", lk, [
d("div", {
class: X(["pbx-aspect-square pbx-w-6 pbx-h-6 pbx-border-solid pbx-border pbx-border-gray-100 pbx-rounded-sm", `pbx-bg-${a.replace("pbx-text-", "")}`])
}, null, 2),
d("span", ak, k(a), 1)
])) : A("", !0)
], 2)
]),
_: 2
}, 1032, ["value"]))), 128))
]),
_: 1
})
]),
_: 1
})
])
]),
_: 1
}, 8, ["modelValue"]));
}
}, ck = { class: "pbx-relative" }, pk = { class: "pbx-flex pbx-justify-start pbx-items-center pbx-gap-2" }, uk = {
key: 0,
class: "material-symbols-outlined"
}, dk = { class: "pbx-flex pbx-flex-col" }, fk = { class: "pbx-flex pbx-gap-2 pbx-items-center" }, hk = {
key: 0,
class: "pbx-flex pbx-items-center"
}, bk = { class: "pbx-ml-3" }, mk = {
key: 1,
class: "pbx-flex pbx-items-center"
}, xk = { class: "pbx-ml-3" }, Oh = {
__name: "BackgroundColorEditor",
props: {
globalPageLayout: {
Type: Boolean
}
},
setup(n) {
const { translate: e } = Me(), t = Ce(), r = Se, o = M(null), i = I(() => r.getBackgroundColor);
return ee(
i,
async (s) => {
o.value = s, await t.initializeElementStyles();
},
{ immediate: !0 }
), (s, l) => (w(), pe(y(ii), {
as: "div",
modelValue: o.value,
"onUpdate:modelValue": l[1] || (l[1] = (a) => o.value = a)
}, {
default: V(() => [
d("div", ck, [
d("div", {
class: X([
n.globalPageLayout ? "pbx-flex pbx-flex-col pbx-border-solid pbx-border pbx-border-gray-400" : "pbx-flex pbx-gap-2 pbx-items-center"
])
}, [
n.globalPageLayout ? (w(), pe(y(Tr), {
key: 0,
class: "pbx-flex pbx-flex-row pbx-justify-between pbx-items-center pbx-pl-3 pbx-pr-3 pbx-py-5 pbx-cursor-pointer pbx-duration-200 hover:pbx-bg-myPrimaryLightGrayColor pbx-bg-white hover:pbx-text-black pbx-text-black pbx-font-sans pbx-font-medium pbx-border-0"
}, {
default: V(() => {
var a;
return [
d("div", pk, [
d("div", {
class: X(["pbx-aspect-square pbx-w-6 pbx-h-6 pbx-border pbx-border-gray-600 pbx-rounded-sm pbx-bg-none pbx-border-solid", `pbx-bg-${(a = o.value) == null ? void 0 : a.replace("pbx-bg-", "")}`])
}, null, 2),
d("div", null, k(y(e)("Background Color")), 1)
]),
n.globalPageLayout ? (w(), E("span", uk, " chevron_right ")) : A("", !0)
];
}),
_: 1
})) : A("", !0),
n.globalPageLayout ? A("", !0) : (w(), pe(y(Tr), {
key: 1,
class: "pbx-h-10 pbx-w-10 pbx-flex-end pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-200 pbx-aspect-square hover:pbx-bg-gray-100 hover:pbx-fill-white focus-visible:pbx-ring-0 pbx-text-myPrimaryDarkGrayColor"
}, {
default: V(() => {
var a;
return [
d("div", dk, [
d("div", fk, [
d("span", {
class: X(["material-symbols-outlined", `pbx-text-${(a = o.value) == null ? void 0 : a.replace("pbx-bg-", "")}`]),
style: { "text-shadow": "rgb(0 0 0 / 10%) 1.5px 1.5px 0px" }
}, " format_color_fill ", 2)
])
])
];
}),
_: 1
}))
], 2),
j(oo, {
"leave-active-class": "pbx-transition pbx-ease-in pbx-duration-100",
"leave-from-class": "pbx-opacity-100",
"leave-to-class": "pbx-opacity-0"
}, {
default: V(() => [
j(y(si), { class: "pbx-headless-dropdown pbx-absolute pbx-min-w-[12rem] pbx-z-40 pbx-mt-1 pbx-max-h-56 pbx-w-full pbx-overflow-auto pbx-rounded-md pbx-bg-gray-50 pbx-py-1 pbx-text-base pbx-shadow-lg pbx-ring-1 pbx-ring-black pbx-ring-opacity-5 focus:pbx-outline-none sm:pbx-text-sm" }, {
default: V(() => [
(w(!0), E(Z, null, fe(y(Fi).backgroundColorVariables, (a) => (w(), pe(y(li), {
as: "template",
onClick: l[0] || (l[0] = (c) => y(t).handleBackgroundColor(o.value)),
key: a,
value: a
}, {
default: V(({ active: c, backgroundColor: p }) => [
d("li", {
class: X([
c ? "pbx-bg-myPrimaryLinkColor pbx-text-white" : "pbx-text-myPrimaryDarkGrayColor",
"pbx-relative pbx-cursor-default pbx-select-none pbx-py-2 pbx-pl-3 pbx-pr-9"
])
}, [
a === "none" ? (w(), E("div", hk, [
l[2] || (l[2] = d("span", { class: "material-symbols-outlined" }, " ev_shadow ", -1)),
d("span", bk, k(y(e)("Transparent")), 1)
])) : A("", !0),
a !== "none" ? (w(), E("div", mk, [
d("div", {
class: X(["pbx-aspect-square pbx-w-6 pbx-h-6 pbx-border-solid pbx-border pbx-border-gray-100 pbx-rounded-sm", `pbx-bg-${a.replace("pbx-bg-", "")}`])
}, null, 2),
d("span", xk, k(a), 1)
])) : A("", !0)
], 2)
]),
_: 2
}, 1032, ["value"]))), 128))
]),
_: 1
})
]),
_: 1
})
])
]),
_: 1
}, 8, ["modelValue"]));
}
}, gk = { class: "pbx-myInputGroup" }, yk = { class: "pbx-myPrimaryFormOrganizationHeaderDescriptionSection" }, vk = { class: "pbx-myPrimaryFormOrganizationHeader" }, wk = {
key: 0,
class: "pbx-min-h-[2.5rem] pbx-flex pbx-items-center pbx-justify-start"
}, Sk = { class: "pbx-myPrimaryInputError pbx-mt-2 pbx-mb-0 pbx-py-0 pbx-self-start" }, kk = { class: "pbx-overflow-y-auto" }, Ck = {
key: 0,
class: "pbx-flex pbx-items-center pbx-justify-start pbx-gap-2 pbx-w-max"
}, Mk = {
key: 2,
class: "pbx-flex pbx-items-center pbx-justify-start pbx-gap-2 pbx-w-max"
}, Ek = {
__name: "EditGetElement",
setup(n) {
const { translate: e } = Me(), t = Ce(), r = Se, o = zn("CustomMediaComponent"), i = I(() => r.getElement);
I(() => {
var ie;
return (ie = i.value) == null ? void 0 : ie.tagName;
});
const s = I(() => {
const ie = r.getShowModalTipTap;
return ie && C(), ie;
}), l = I(() => r.getComponent), a = M(""), c = M(1), p = M(""), u = M(""), f = M(""), h = M(null), b = M(null), m = M(null), x = M(null), v = M(null), C = function() {
t.toggleTipTapModal(!0), a.value = "success", c.value = 2, p.value = e("Manage Content"), u.value = null, f.value = null, h.value = null, b.value = "Save", m.value = function() {
t.toggleTipTapModal(!1);
}, v.value = function() {
t.toggleTipTapModal(!0);
};
}, S = I(() => r.getBasePrimaryImage), g = M(!1), O = M(""), T = M(""), B = M(""), F = M(null), W = M(null), L = M(null), N = function() {
g.value = !0, O.value = e("Media Library"), T.value = null, B.value = e("Close"), F.value = e(" Select image"), L.value = function() {
g.value = !1;
};
}, $ = M(null), K = M(""), ae = M(!1), he = function() {
$.value = null;
const ie = /^https?:\/\//, G = M(!0);
return G.value = ie.test(K.value), G.value === !1 ? ($.value = "The provided URL is invalid. Please ensure that it begins with 'https://' for proper formatting and security.", !0) : !1;
}, ue = function() {
var G;
$.value = null;
const ie = i.value && ((G = i.value.firstElementChild) == null ? void 0 : G.tagName) === "IFRAME" && i.value.firstElementChild.hasAttribute("src") && i.value.firstElementChild.getAttribute("src").trim() !== "" ? i.value.firstElementChild.src : "";
K.value = ie, ae.value = !0, a.value = "success", c.value = 2, p.value = "Add video url", u.value = null, f.value = e("Close"), h.value = "Save", b.value = null, m.value = function() {
ae.value = !1;
}, x.value = function() {
he() || (i.value && i.value.firstElementChild && i.value.firstElementChild.tagName === "IFRAME" && (K.value = K.value.replace("watch?v=", "embed/"), K.value = K.value.replace(/&ab_channel=[^&]*/, "").replace(/&list=[^&]*/, "").replace(/&start_radio=[^&]*/, "").replace(/&t=[^&]*/, ""), i.value.firstElementChild.src = K.value), ae.value = !1);
};
};
return (ie, G) => (w(), E("div", null, [
j(yr, {
showDynamicModalBuilder: ae.value,
maxWidth: "2xl",
type: a.value,
gridColumnAmount: c.value,
title: p.value,
description: u.value,
firstButtonText: f.value,
secondButtonText: h.value,
thirdButtonText: b.value,
onFirstModalButtonFunctionDynamicModalBuilder: m.value,
onSecondModalButtonFunctionDynamicModalBuilder: x.value,
onThirdModalButtonFunctionDynamicModalBuilder: v.value
}, {
default: V(() => [
G[4] || (G[4] = d("header", null, null, -1)),
d("main", null, [
d("div", gk, [
d("div", yk, [
d("div", vk, [
G[3] || (G[3] = d("label", {
for: "video",
class: "pbx-myPrimaryInputLabel"
}, "Video url:", -1)),
xe(d("input", {
"onUpdate:modelValue": G[0] || (G[0] = (re) => K.value = re),
type: "text",
class: "pbx-myPrimaryInput",
name: "video"
}, null, 512), [
[gr, K.value]
]),
$.value ? (w(), E("div", wk, [
d("p", Sk, k($.value), 1)
])) : A("", !0)
])
])
])
])
]),
_: 1,
__: [4]
}, 8, ["showDynamicModalBuilder", "type", "gridColumnAmount", "title", "description", "firstButtonText", "secondButtonText", "thirdButtonText", "onFirstModalButtonFunctionDynamicModalBuilder", "onSecondModalButtonFunctionDynamicModalBuilder", "onThirdModalButtonFunctionDynamicModalBuilder"]),
j(yr, {
simpleModal: !0,
showDynamicModalBuilder: s.value,
maxWidth: "6xl",
type: a.value,
gridColumnAmount: c.value,
title: p.value,
description: u.value,
firstButtonText: f.value,
secondButtonText: h.value,
thirdButtonText: b.value,
onFirstModalButtonFunctionDynamicModalBuilder: m.value,
onSecondModalButtonFunctionDynamicModalBuilder: x.value,
onThirdModalButtonFunctionDynamicModalBuilder: v.value
}, {
default: V(() => [
G[5] || (G[5] = d("header", null, null, -1)),
d("main", kk, [
j(hS)
])
]),
_: 1,
__: [5]
}, 8, ["showDynamicModalBuilder", "type", "gridColumnAmount", "title", "description", "firstButtonText", "secondButtonText", "thirdButtonText", "onFirstModalButtonFunctionDynamicModalBuilder", "onSecondModalButtonFunctionDynamicModalBuilder", "onThirdModalButtonFunctionDynamicModalBuilder"]),
j(mh, {
open: g.value,
title: O.value,
description: T.value,
firstButtonText: B.value,
secondButtonText: F.value,
thirdButtonText: W.value,
customMediaComponent: y(o),
onFirstMediaButtonFunction: L.value
}, null, 8, ["open", "title", "description", "firstButtonText", "secondButtonText", "thirdButtonText", "customMediaComponent", "onFirstMediaButtonFunction"]),
A("", !0),
d("div", {
class: X(["pbx-flex pbx-items-center pbx-justify-center pbx-gap-2", { "": i.value }])
}, [
y(t).ElOrFirstChildIsIframe() ? (w(), E("div", Ck, [
d("button", {
onClick: ue,
type: "button",
class: "pbx-h-10 pbx-w-10 pbx-flex-end pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-200 pbx-aspect-square hover:pbx-bg-gray-100 hover:pbx-fill-white focus-visible:pbx-ring-0 pbx-text-myPrimaryDarkGrayColor"
}, G[7] || (G[7] = [
d("span", { class: "material-symbols-outlined" }, " play_circle ", -1)
]))
])) : A("", !0),
y(t).isSelectedElementValidText() && !y(t).ElOrFirstChildIsIframe() ? (w(), E(Z, { key: 1 }, [
d("div", { class: "pbx-flex pbx-items-center pbx-justify-start pbx-gap-2 pbx-w-max" }, [
d("button", {
onClick: C,
type: "button",
class: "pbx-h-10 pbx-w-10 pbx-flex-end pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-200 pbx-aspect-square hover:pbx-bg-gray-100 hover:pbx-fill-white focus-visible:pbx-ring-0 pbx-text-myPrimaryDarkGrayColor"
}, G[8] || (G[8] = [
d("span", { class: "material-symbols-outlined" }, " edit ", -1)
]))
]),
j(Th)
], 64)) : A("", !0),
i.value && l.value && S.value && !y(t).ElOrFirstChildIsIframe() ? (w(), E("div", Mk, [
d("button", {
onClick: N,
type: "button",
class: "pbx-h-10 pbx-w-10 pbx-flex-end pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-200 pbx-aspect-square hover:pbx-bg-gray-100 hover:pbx-fill-white focus-visible:pbx-ring-0 pbx-text-myPrimaryDarkGrayColor"
}, G[9] || (G[9] = [
d("span", { class: "material-symbols-outlined" }, " add_photo_alternate ", -1)
]))
])) : A("", !0),
i.value && i.value.nodeType === 1 && !S.value && !y(t).ElOrFirstChildIsIframe() ? (w(), pe(Oh, { key: 3 })) : A("", !0),
i.value ? (w(), E("button", {
key: 4,
onClick: G[1] || (G[1] = (...re) => y(t).deleteElementFromDOM && y(t).deleteElementFromDOM(...re)),
type: "button",
class: "pbx-h-10 pbx-w-10 pbx-flex-end pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-200 pbx-aspect-square hover:pbx-bg-gray-100 hover:pbx-fill-white focus-visible:pbx-ring-0 pbx-text-myPrimaryDarkGrayColor"
}, G[10] || (G[10] = [
d("span", { class: "material-symbols-outlined" }, " delete ", -1)
]))) : A("", !0),
i.value && l.value ? (w(), E("div", {
key: 5,
class: "pbx-h-10 pbx-w-10 pbx-flex-end pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-200 pbx-aspect-square hover:pbx-bg-gray-100 hover:pbx-fill-white focus-visible:pbx-ring-0 pbx-text-myPrimaryDarkGrayColor",
onClick: G[2] || (G[2] = (re) => y(t).clearHtmlSelection())
}, G[11] || (G[11] = [
d("span", { class: "material-symbols-outlined" }, " close", -1)
]))) : A("", !0)
], 2)
]));
}
}, Tk = [
{
html_code: `
<section>
<div class="relative py-4">
<div class="mx-auto max-w-7xl lg:px-4 px-2">
<div>
<p>
Start customizing by editing this default text directly in the editor.
</p>
</div>
</div>
</div>
</section>`,
id: null,
title: "Text",
icon: `
<span class="material-symbols-outlined">
text_fields
</span>
`
},
{
html_code: '<section><div class="relative py-4"><div class="mx-auto max-w-7xl lg:px-4 px-2"><div class="break-words"><h2>Layouts and visual.</h2></div></div></div></section>',
id: null,
title: "Header H2",
icon: `
<span class="material-symbols-outlined">
format_h2
</span>
`
},
{
html_code: '<section><div class="relative py-4"><div class="mx-auto max-w-7xl lg:px-4 px-2"><div class="break-words"><h3>Layouts and visual.</h3></div></div></div></section>',
id: null,
title: "Header H3",
icon: `
<span class="material-symbols-outlined">
format_h3
</span>
`
},
{
html_code: `
<section>
<div class="py-4">
<div class="mx-auto max-w-7xl w-full pt-6 pb-6 bg-gray-100">
<div id="youtube-video" class="w-full aspect-video p-4">
<iframe
frameborder="0"
allowfullscreen
class="w-full aspect-video"
src=""
allow="accelerometer; autoplay; clipboard-write;" allowfullscreen>
</iframe>
</div>
</div>
</div>
</section>`,
id: null,
title: "YouTube Video",
icon: `
<span class="material-symbols-outlined">
play_circle
</span>
`
},
{
html_code: '<section><div class="relative py-8"><div class="absolute inset-0 flex items-center" aria-hidden="true"><div class="w-full border-4 border-gray-800 leading-none"></div></div><div class="relative flex justify-start"></div></div></section>',
id: null,
title: "Break Divider",
icon: `
<span class="material-symbols-outlined">
horizontal_rule
</span>
`
},
{
html_code: `<section>
<div class="w-full md:pt-2 md:pb-2 pt-4 pb-4 lg:px-4 px-2">
<div class="mx-auto max-w-7xl">
<div id="linktree"
class="flex items-centre justify-start font-medium text-black bg-gray-200">
<a target="_blank" rel="noopener noreferrer nofollow" href="https://www.google.com">Link to landing page</a>
</div>
</div>
</div>
</section>`,
id: null,
title: "Link",
icon: `
<span class="material-symbols-outlined">
link
</span>
`
}
], Ok = () => `data:image/svg+xml,${encodeURIComponent(`
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 150">
<defs>
<style>
.bg { fill: #384152; }
.fg { fill: #718096; }
</style>
</defs>
<rect class="bg" width="200" height="150"/>
<polygon class="fg" points="65 90.01 90 60.01 115 90.01"/>
<polygon class="fg" points="110 90.01 122.5 75.01 135 90.01"/>
<circle class="fg" cx="122.5" cy="64.15" r="4.16"/>
</svg>
`.trim())}`, Bk = (n) => {
const t = {
"Single Image": {
title: "Single Image",
svg: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 150">
<defs>
<style>
.bg { fill: #384152; }
.fg { fill: #718096; }
</style>
</defs>
<rect class="bg" width="200" height="150"/>
<polygon class="fg" points="65 90.01 90 60.01 115 90.01"/>
<polygon class="fg" points="110 90.01 122.5 75.01 135 90.01"/>
<circle class="fg" cx="122.5" cy="64.15" r="4.16"/>
</svg>
`
},
"Two Vertical Images": {
title: "Two Vertical Images",
svg: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 133.88 122.11">
<defs>
<style>
.cls-1 {
fill: #384152;
}
.cls-2 {
fill: #718096;
}
</style>
</defs>
<g>
<rect class="cls-1" width="63.93" height="122.11"/>
<g>
<polygon class="cls-2" points="8.68 71.04 25.31 51.08 41.94 71.04 8.68 71.04"/>
<polygon class="cls-2" points="38.62 71.04 46.93 61.06 55.24 71.04 38.62 71.04"/>
<circle class="cls-2" cx="46.93" cy="53.84" r="2.77"/>
</g>
</g>
<g>
<rect class="cls-1" x="69.95" width="63.93" height="122.11"/>
<g>
<polygon class="cls-2" points="78.64 71.04 95.27 51.08 111.89 71.04 78.64 71.04"/>
<polygon class="cls-2" points="108.57 71.04 116.88 61.06 125.2 71.04 108.57 71.04"/>
<circle class="cls-2" cx="116.88" cy="53.84" r="2.77"/>
</g>
</g>
</svg>
`
},
"Two Square Images": {
title: "Two Square Images",
svg: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120.18 57.68">
<defs>
<style>
.cls-1 {
fill: #384152;
}
.cls-2 {
fill: #718096;
}
</style>
</defs>
<g>
<rect class="cls-1" width="57.68" height="57.68"/>
<g>
<polygon class="cls-2" points="8.77 37.45 23.11 20.25 37.44 37.45 8.77 37.45"/>
<polygon class="cls-2" points="34.58 37.45 41.74 28.85 48.91 37.45 34.58 37.45"/>
<circle class="cls-2" cx="41.74" cy="22.62" r="2.39"/>
</g>
</g>
<g>
<rect class="cls-1" x="62.5" width="57.68" height="57.68"/>
<g>
<polygon class="cls-2" points="71.27 37.45 85.61 20.25 99.94 37.45 71.27 37.45"/>
<polygon class="cls-2" points="97.07 37.45 104.24 28.85 111.41 37.45 97.07 37.45"/>
<circle class="cls-2" cx="104.24" cy="22.62" r="2.39"/>
</g>
</g>
</svg>
`
},
"Three Square Images": {
title: "Three Square Images",
svg: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 177.28 53.92">
<defs>
<style>
.bg { fill: #384152; }
.fg { fill: #718096; }
</style>
</defs>
<rect class="bg" width="53.92" height="53.92"/>
<rect class="bg" x="62.15" width="53.92" height="53.92"/>
<rect class="bg" x="123.37" width="53.92" height="53.92"/>
<polygon class="fg" points="8.2 35 21.6 18.92 35 35"/>
<polygon class="fg" points="32.32 35 39.02 26.96 45.71 35"/>
<circle class="fg" cx="39.02" cy="21.15" r="2.23"/>
<polygon class="fg" points="70.36 35 83.75 18.92 97.15 35"/>
<polygon class="fg" points="94.47 35 101.17 26.96 107.87 35"/>
<circle class="fg" cx="101.17" cy="21.15" r="2.23"/>
<polygon class="fg" points="131.57 35 144.96 18.92 158.36 35"/>
<polygon class="fg" points="155.68 35 162.38 26.96 169.08 35"/>
<circle class="fg" cx="162.38" cy="21.15" r="2.23"/>
</svg>
`
},
"Four Square Images": {
title: "Four Square Images",
svg: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 190.34 42.55">
<defs>
<style>
.cls-1 {
fill: #394152;
}
.cls-2 {
fill: #718096;
}
</style>
</defs>
<rect class="cls-1" width="42.55" height="42.55"/>
<rect class="cls-1" x="49.05" width="42.55" height="42.55"/>
<rect class="cls-1" x="97.35" width="42.55" height="42.55"/>
<rect class="cls-1" x="147.79" width="42.55" height="42.55"/>
<polygon class="cls-2" points="6.47 27.62 17.04 14.93 27.62 27.62 6.47 27.62"/>
<polygon class="cls-2" points="25.5 27.62 30.79 21.28 36.07 27.62 25.5 27.62"/>
<circle class="cls-2" cx="30.79" cy="16.69" r="1.76"/>
<polygon class="cls-2" points="55.52 27.62 66.09 14.93 76.66 27.62 55.52 27.62"/>
<polygon class="cls-2" points="74.55 27.62 79.83 21.28 85.12 27.62 74.55 27.62"/>
<circle class="cls-2" cx="79.83" cy="16.69" r="1.76"/>
<polygon class="cls-2" points="103.82 27.62 114.39 14.93 124.97 27.62 103.82 27.62"/>
<polygon class="cls-2" points="122.85 27.62 128.14 21.28 133.42 27.62 122.85 27.62"/>
<circle class="cls-2" cx="128.14" cy="16.69" r="1.76"/>
<polygon class="cls-2" points="154.26 27.62 164.83 14.93 175.4 27.62 154.26 27.62"/>
<polygon class="cls-2" points="173.29 27.62 178.57 21.28 183.86 27.62 173.29 27.62"/>
<circle class="cls-2" cx="178.57" cy="16.69" r="1.76"/>
</svg>
`
},
"Six Square Images Grid": {
title: "Six Square Images Grid",
svg: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 177.28 120.27">
<defs>
<style>
.bg { fill: #384152; }
.fg { fill: #718096; }
</style>
</defs>
<rect class="bg" width="53.92" height="53.92"/>
<rect class="bg" x="62.15" width="53.92" height="53.92"/>
<rect class="bg" x="123.37" width="53.92" height="53.92"/>
<rect class="bg" y="66.35" width="53.92" height="53.92"/>
<rect class="bg" x="62.15" y="66.35" width="53.92" height="53.92"/>
<rect class="bg" x="123.37" y="66.35" width="53.92" height="53.92"/>
<polygon class="fg" points="8.2 35 21.6 18.92 35 35"/>
<polygon class="fg" points="32.32 35 39.02 26.96 45.71 35"/>
<circle class="fg" cx="39.02" cy="21.15" r="2.23"/>
<polygon class="fg" points="70.36 35 83.75 18.92 97.15 35"/>
<polygon class="fg" points="94.47 35 101.17 26.96 107.87 35"/>
<circle class="fg" cx="101.17" cy="21.15" r="2.23"/>
<polygon class="fg" points="131.57 35 144.96 18.92 158.36 35"/>
<polygon class="fg" points="155.68 35 162.38 26.96 169.08 35"/>
<circle class="fg" cx="162.38" cy="21.15" r="2.23"/>
<polygon class="fg" points="8.2 101.35 21.6 85.28 35 101.35"/>
<polygon class="fg" points="32.32 101.35 39.02 93.32 45.71 101.35"/>
<circle class="fg" cx="39.02" cy="87.5" r="2.23"/>
<polygon class="fg" points="70.36 101.35 83.75 85.28 97.15 101.35"/>
<polygon class="fg" points="94.47 101.35 101.17 93.32 107.87 101.35"/>
<circle class="fg" cx="101.17" cy="87.5" r="2.23"/>
<polygon class="fg" points="131.57 101.35 144.96 85.28 158.36 101.35"/>
<polygon class="fg" points="155.68 101.35 162.38 93.32 169.08 101.35"/>
<circle class="fg" cx="162.38" cy="87.5" r="2.23"/>
</svg>
`
},
"Two Square Images With Text": {
title: "Two Square Images With Text",
svg: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 179.99 53.92">
<defs>
<style>
.bg { fill: #384152; }
.fg { fill: #718096; }
</style>
</defs>
<rect class="bg" width="53.92" height="53.92"/>
<rect class="bg" x="62.15" width="53.92" height="53.92"/>
<polygon class="fg" points="8.2 35 21.6 18.92 35 35"/>
<polygon class="fg" points="32.32 35 39.02 26.96 45.71 35"/>
<circle class="fg" cx="39.02" cy="21.15" r="2.23"/>
<polygon class="fg" points="70.36 35 83.75 18.92 97.15 35"/>
<polygon class="fg" points="94.47 35 101.17 26.96 107.87 35"/>
<circle class="fg" cx="101.17" cy="21.15" r="2.23"/>
<rect class="bg" x="126.07" width="53.92" height="2.93"/>
<rect class="bg" x="126.07" y="4" width="53.92" height="2.93"/>
<rect class="bg" x="126.07" y="7.99" width="53.92" height="2.93"/>
<rect class="bg" x="126.07" y="11.99" width="53.92" height="2.93"/>
<rect class="bg" x="126.07" y="15.99" width="53.92" height="2.93"/>
</svg>
`
},
"Three Vertical Images": {
title: "Three Vertical Images",
svg: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 179.84 110.72">
<defs>
<style>
.bg { fill: #384152; }
.fg { fill: #718096; }
</style>
</defs>
<rect class="bg" width="54.28" height="110.72"/>
<rect class="bg" x="62.79" width="54.28" height="110.72"/>
<rect class="bg" x="125.56" width="54.28" height="110.72"/>
<polygon class="fg" points="7.37 63.83 21.49 46.89 35.61 63.83"/>
<polygon class="fg" points="32.79 63.83 39.85 55.36 46.91 63.83"/>
<circle class="fg" cx="39.85" cy="49.23" r="2.35"/>
<polygon class="fg" points="70.17 63.83 84.29 46.89 98.4 63.83"/>
<polygon class="fg" points="95.58 63.83 102.64 55.36 109.7 63.83"/>
<circle class="fg" cx="102.64" cy="49.23" r="2.35"/>
<polygon class="fg" points="132.94 63.83 147.06 46.89 161.18 63.83"/>
<polygon class="fg" points="158.35 63.83 165.41 55.36 172.47 63.83"/>
<circle class="fg" cx="165.41" cy="49.23" r="2.35"/>
</svg>
`
},
"Four Square Images With Text": {
title: "Four Square Images With Text",
svg: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 190.33 55.9">
<defs>
<style>
.bg { fill: #384152; }
.fg { fill: #718096; }
</style>
</defs>
<rect class="bg" width="42.55" height="42.55"/>
<rect class="bg" x="49.05" width="42.55" height="42.55"/>
<rect class="bg" x="97.35" width="42.55" height="42.55"/>
<rect class="bg" x="147.79" width="42.55" height="42.55"/>
<polygon class="fg" points="6.47 27.62 17.04 14.93 27.62 27.62"/>
<polygon class="fg" points="25.5 27.62 30.79 21.28 36.07 27.62"/>
<circle class="fg" cx="30.79" cy="16.69" r="1.76"/>
<polygon class="fg" points="55.52 27.62 66.09 14.93 76.66 27.62"/>
<polygon class="fg" points="74.55 27.62 79.83 21.28 85.12 27.62"/>
<circle class="fg" cx="79.83" cy="16.69" r="1.76"/>
<polygon class="fg" points="103.82 27.62 114.39 14.93 124.97 27.62"/>
<polygon class="fg" points="122.85 27.62 128.14 21.28 133.42 27.62"/>
<circle class="fg" cx="128.14" cy="16.69" r="1.76"/>
<polygon class="fg" points="154.26 27.62 164.83 14.93 175.4 27.62"/>
<polygon class="fg" points="173.29 27.62 178.57 21.28 183.86 27.62"/>
<circle class="fg" cx="178.57" cy="16.69" r="1.76"/>
<rect class="bg" y="47.28" width="42.55" height="2.31"/>
<rect class="bg" y="50.43" width="42.55" height="2.31"/>
<rect class="bg" y="53.59" width="42.55" height="2.31"/>
<rect class="bg" x="49.05" y="47.28" width="42.55" height="2.31"/>
<rect class="bg" x="49.05" y="50.43" width="42.55" height="2.31"/>
<rect class="bg" x="49.05" y="53.59" width="42.55" height="2.31"/>
<rect class="bg" x="97.35" y="47.28" width="42.55" height="2.31"/>
<rect class="bg" x="97.35" y="50.43" width="42.55" height="2.31"/>
<rect class="bg" x="97.35" y="53.59" width="42.55" height="2.31"/>
<rect class="bg" x="147.79" y="47.28" width="42.55" height="2.31"/>
<rect class="bg" x="147.79" y="50.43" width="42.55" height="2.31"/>
<rect class="bg" x="147.79" y="53.59" width="42.55" height="2.31"/>
</svg>
`
},
"Three Square Images With Text": {
title: "Three Square Images With Text",
svg: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 177.28 70.84">
<defs>
<style>
.bg { fill: #384152; }
.fg { fill: #718096; }
</style>
</defs>
<rect class="bg" width="53.92" height="53.92"/>
<rect class="bg" x="62.15" width="53.92" height="53.92"/>
<rect class="bg" x="123.37" width="53.92" height="53.92"/>
<polygon class="fg" points="8.2 35 21.6 18.92 35 35"/>
<polygon class="fg" points="32.32 35 39.02 26.96 45.71 35"/>
<circle class="fg" cx="39.02" cy="21.15" r="2.23"/>
<polygon class="fg" points="70.36 35 83.75 18.92 97.15 35"/>
<polygon class="fg" points="94.47 35 101.17 26.96 107.87 35"/>
<circle class="fg" cx="101.17" cy="21.15" r="2.23"/>
<polygon class="fg" points="131.57 35 144.96 18.92 158.36 35"/>
<polygon class="fg" points="155.68 35 162.38 26.96 169.08 35"/>
<circle class="fg" cx="162.38" cy="21.15" r="2.23"/>
<rect class="bg" y="59.92" width="53.92" height="2.93"/>
<rect class="bg" y="63.91" width="53.92" height="2.93"/>
<rect class="bg" y="67.91" width="53.92" height="2.93"/>
<rect class="bg" x="62.15" y="59.92" width="53.92" height="2.93"/>
<rect class="bg" x="62.15" y="63.91" width="53.92" height="2.93"/>
<rect class="bg" x="62.15" y="67.91" width="53.92" height="2.93"/>
<rect class="bg" x="123.37" y="59.92" width="53.92" height="2.93"/>
<rect class="bg" x="123.37" y="63.91" width="53.92" height="2.93"/>
<rect class="bg" x="123.37" y="67.91" width="53.92" height="2.93"/>
</svg>
`
}
}[n];
return t ? t.svg : `
<svg viewBox="0 0 200 150" xmlns="http://www.w3.org/2000/svg">
<rect fill="#384152" width="200" height="150"/>
<text x="100" y="75" text-anchor="middle" fill="#718096" font-family="Arial, sans-serif" font-size="14">Preview</text>
</svg>
`;
}, de = Ok(), _l = [
{
components: {
data: [
{
title: "Single Image",
html_code: `<section>
<div class="md:pt-12 md:pb-12 pt-4 pb-4 lg:px-4 px-2"><div class="mx-auto max-w-7xl"><div class="myPrimaryGap grid grid-cols-1 sm:grid-cols-1 lg:grid-cols-1"> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"></div></div></div></div>
</section>`,
cover_image: null,
category: "Image"
},
{
title: "Two Vertical Images",
html_code: `<section>
<div class="md:pt-12 md:pb-12 pt-4 pb-4 lg:px-4 px-2"><div class="mx-auto max-w-7xl"><div class="myPrimaryGap grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-2"> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-[9/16] " src="${de}" alt="provider"> </div> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-[9/16] " src="${de}" alt="provider"> </div> </div> </div> </div>
</section>`,
cover_image: null,
category: "Image"
},
{
title: "Two Square Images",
html_code: `<section>
<div class="md:pt-12 md:pb-12 pt-4 pb-4 lg:px-4 px-2"><div class="mx-auto max-w-7xl"><div class="myPrimaryGap grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-2"> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"> </div> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"></div></div> </div></div>
</section>`,
cover_image: null,
category: "Image"
},
{
title: "Three Square Images",
html_code: `<section>
<div class="md:pt-12 md:pb-12 pt-4 pb-4 lg:px-4 px-2"><div class="mx-auto max-w-7xl"><div class="myPrimaryGap grid grid-cols-1 sm:grid-cols-3 lg:grid-cols-3"> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"> </div> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"> </div> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"></div></div> </div></div>
</section>`,
cover_image: null,
category: "Image"
},
{
title: "Four Square Images",
html_code: `<section>
<div class="md:pt-12 md:pb-12 pt-4 pb-4 lg:px-4 px-2"> <div class="mx-auto max-w-7xl"> <div class="myPrimaryGap grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4"> <div><img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"></div> <div><img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"></div> <div><img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"></div> <div><img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"></div> </div> </div> </div>
</section>`,
cover_image: null,
category: "Image"
},
{
title: "Six Square Images Grid",
html_code: `<section>
<div class="md:pt-12 md:pb-12 pt-4 pb-4 lg:px-4 px-2">
<div class="mx-auto max-w-7xl">
<div class="grid grid-cols-2 md:grid-cols-3 myPrimaryGap">
<div>
<img class="object-cover w-full object-top aspect-square " src="${de}" alt="image">
</div>
<div>
<img class="object-cover w-full object-top aspect-square " src="${de}" alt="image">
</div>
<div>
<img class="object-cover w-full object-top aspect-square " src="${de}" alt="image">
</div>
<div>
<img class="object-cover w-full object-top aspect-square " src="${de}" alt="image">
</div>
<div>
<img class="object-cover w-full object-top aspect-square " src="${de}" alt="image">
</div>
<div>
<img class="object-cover w-full object-top aspect-square " src="${de}" alt="image">
</div>
</div>
</div>
</div>
</section>`,
cover_image: null,
category: "Image"
},
{
title: "Two Square Images With Text",
html_code: `<section>
<div class="md:pt-12 md:pb-12 pt-4 pb-4 lg:px-4 px-2"><div class="mx-auto max-w-7xl">
<div class="myPrimaryGap lg:flex lg:justify-center"><div class="flex-1 py-2">
<div class="grid myPrimaryGap grid-cols-1 lg:grid-cols-2"> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"> </div> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"> </div> </div> </div>
<div class="flex-1 py-2"> <div class="break-words py-2"><p>Start customizing by editing this default text directly in the editor.</p></div></div>
</div></div></div>
</section>`,
cover_image: null,
category: "Image & Text"
},
{
title: "Three Vertical Images",
html_code: `<section>
<div class="md:pt-12 md:pb-12 pt-4 pb-4 lg:px-4 px-2"><div class="mx-auto max-w-7xl"><div class="myPrimaryGap grid grid-cols-1 sm:grid-cols-3 lg:grid-cols-3"> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-[9/16] " src="${de}" alt="provider"> </div> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-[9/16] " src="${de}" alt="provider"> </div> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-[9/16] " src="${de}" alt="provider"></div></div> </div></div>
</section>`,
cover_image: null,
category: "Image"
},
{
title: "Four Square Images With Text",
html_code: `<section>
<div class="md:pt-12 md:pb-12 pt-4 pb-4 lg:px-4 px-2"><div class="mx-auto max-w-7xl"><div class="myPrimaryGap grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4"> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"> <div class="break-words py-2"><p>Layouts and visual.</p><p>Start customizing by editing this default text directly in the editor.</p></div> </div> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"> <div class="break-words py-2"><p>Layouts and visual.</p><p>Start customizing by editing this default text directly in the editor.</p></div> </div> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"> <div class="break-words py-2"><p>Layouts and visual.</p><p>Start customizing by editing this default text directly in the editor.</p></div> </div> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"><div class="break-words py-2"><p>Layouts and visual.</p><p>Start customizing by editing this default text directly in the editor.</p></div> </div> </div> </div> </div>
</section>`,
cover_image: null,
category: "Image & Text"
},
{
title: "Three Square Images With Text",
html_code: `<section>
<div class="md:pt-12 md:pb-12 pt-4 pb-4 lg:px-4 px-2"><div class="mx-auto max-w-7xl"><div class="myPrimaryGap grid grid-cols-1 sm:grid-cols-3 lg:grid-cols-3"> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"> <div class="break-words py-2"><p>Layouts and visual.</p><p>Start customizing by editing this default text directly in the editor.</p></div> </div> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"> <div class="break-words py-2"><p>Layouts and visual.</p><p>Start customizing by editing this default text directly in the editor.</p></div> </div> <div class="flex-1 py-2"> <img class="object-cover w-full object-top aspect-square " src="${de}" alt="provider"> <div class="break-words py-2"><p>Layouts and visual.</p><p>Start customizing by editing this default text directly in the editor.</p></div> </div> </div> </div> </div>
</section>`,
cover_image: null,
category: "Image & Text"
}
]
}
}
];
function Pk() {
const n = zn("closeAddComponentModal", null), e = zn("closeMediaLibraryModal", null);
return {
closeAddComponentModal: n || (() => {
console.warn(
"closeAddComponentModal function not available. Make sure you are using this within a PageBuilder context."
);
}),
closeMediaLibraryModal: e || (() => {
console.warn(
"closeMediaLibraryModal function not available. Make sure you are using this within a MediaLibraryModal context."
);
})
};
}
const Ak = {
key: 0,
class: "pbx-min-h-[90vh] pbx-h-[90vh]"
}, _k = { class: "pbx-flex pbx-items-center pbx-justify-center" }, Lk = { class: "pbx-inline-block pbx-h-8 pbx-w-8 pbx-animate-spin pbx-rounded-full pbx-border-4 pbx-border-solid pbx-border-current pbx-border-r-transparent pbx-align-[-0.125em] motion-reduce:pbx-animate-[spin_1.5s_linear_infinite]" }, Nk = { class: "!pbx-absolute !pbx-m-px !pbx-h-px !pbx-w-px !pbx-overflow-hidden !pbx-whitespace-nowrap !pbx-border-0 !pbx-p-0 !pbx-[clip:rect(0,0,0,0)]" }, Dk = { key: 1 }, Ik = { class: "pbx-mb-8" }, $k = { class: "pbx-myQuaternaryHeader pbx-mb-4" }, Rk = { class: "pbx-px-2 pbx-grid pbx-grid-cols-1 sm:pbx-grid-cols-2 md:pbx-grid-cols-3 lg:pbx-grid-cols-4 pbx-gap-4" }, Fk = ["onClick"], Hk = { class: "pbx-max-h-72 pbx-cursor-pointer pbx-object-contain pbx-bg-white pbx-mx-auto" }, jk = { class: "pbx-myPrimaryParagraph pbx-text-base pbx-font-medium" }, zk = { class: "pbx-myPrimaryParagraph pbx-text-xs pbx-font-normal pbx-pt-2" }, Vk = {
key: 0,
class: "pbx-px-2"
}, Wk = { class: "pbx-myQuaternaryHeader pbx-mb-4" }, Uk = { class: "pbx-mb-4 pbx-flex pbx-jusitify-left pbx-items-center pbx-gap-2" }, qk = ["onClick"], Kk = { class: "pbx-grid pbx-grid-cols-1 sm:pbx-grid-cols-2 md:pbx-grid-cols-3 pbx-gap-4 pbx-pb-4" }, Gk = ["onClick"], Jk = { class: "pbx-overflow-hidden pbx-whitespace-pre-line pbx-flex-1 pbx-h-auto pbx-border-0 pbx-border-solid pbx-border-b pbx-border-gray-200 lg:pbx-py-10 pbx-py-8 pbx-px-2" }, Yk = ["innerHTML"], Xk = { class: "pbx-p-3" }, Qk = { class: "pbx-myPrimaryParagraph pbx-text-sm pbx-font-normal" }, Zk = { class: "pbx-myPrimaryParagraph pbx-text-xs pbx-font-normal pbx-pt-2" }, eC = /* @__PURE__ */ Qe({
__name: "DefaultBuilderComponents",
props: {
customMediaComponent: {
type: Object,
default: null
}
},
setup(n) {
const { translate: e } = Me(), t = Ce(), r = M(!1), o = M("All"), i = I(() => {
const u = _l[0].components.data.map((f) => f.category);
return ["All", ...new Set(u)];
}), s = I(() => o.value === "All" ? _l[0].components.data : _l[0].components.data.filter((u) => u.category === o.value)), { closeAddComponentModal: l } = Pk(), a = async function(u) {
r.value = !0;
const f = u.html_code.replace(/Layouts and visual\./g, e("Layouts and visual.")).replace(
/Start customizing by editing this default text directly in the editor\./g,
e("Start customizing by editing this default text directly in the editor.")
), h = {
...u,
html_code: f,
title: u.title
};
await t.addComponent(h), l(), r.value = !1;
}, c = function(u) {
return {
id: null,
// Generate ID when needed in PageBuilderClass
html_code: u.html_code,
title: u.title
};
}, p = (u) => Bk(u);
return (u, f) => (w(), E("div", null, [
r.value ? (w(), E("div", Ak, [
d("div", _k, [
d("div", Lk, [
d("span", Nk, k(y(e)("Loading...")), 1)
])
])
])) : A("", !0),
r.value ? A("", !0) : (w(), E("div", Dk, [
d("div", Ik, [
d("h3", $k, k(y(e)("Helper Components")), 1),
d("div", Rk, [
(w(!0), E(Z, null, fe(y(Tk), (h) => (w(), E("div", {
key: h.title,
class: "pbx-border-solid pbx-border pbx-border-gray-400 pbx-overflow-hidden hover:pbx-border-myPrimaryLinkColor pbx-duration-100 pbx-cursor-pointer pbx-p-4",
onClick: (b) => a(h)
}, [
d("div", Hk, [
A("", !0),
d("h4", jk, k(y(e)(h.title)), 1)
]),
d("div", zk, k(y(e)("Click to add")) + " " + k(h.title.toLowerCase()) + " " + k(y(e)("component")), 1)
], 8, Fk))), 128))
])
]),
n.customMediaComponent ? (w(), E("div", Vk, [
d("h3", Wk, k(y(e)("Layout Components")), 1),
d("div", Uk, [
(w(!0), E(Z, null, fe(i.value, (h) => (w(), E("button", {
key: h,
onClick: (b) => o.value = h,
class: X(["pbx-mySecondaryButton pbx-text-xs pbx-px-4", { active: o.value === h }])
}, k(y(e)(h)), 11, qk))), 128))
]),
d("div", Kk, [
(w(!0), E(Z, null, fe(s.value, (h) => (w(), E("div", {
key: h.title,
class: "pbx-border-solid pbx-border pbx-border-gray-400 pbx-overflow-hidden hover:pbx-border-myPrimaryLinkColor pbx-duration-100 pbx-cursor-pointer",
onClick: (b) => a(c(h))
}, [
d("div", Jk, [
d("div", {
class: "pbx-max-h-72 pbx-cursor-pointer pbx-bg-white pbx-mx-auto pbx-flex pbx-items-center pbx-justify-center",
innerHTML: p(h.title)
}, null, 8, Yk)
]),
d("div", Xk, [
d("h4", Qk, k(y(e)(h.title)), 1),
d("div", Zk, k(y(e)("Click to add component")), 1)
])
], 8, Gk))), 128))
])
])) : A("", !0),
f[0] || (f[0] = d("div", null, [
d("button", { class: "pbx-sr-only" }, "Focusable fallback")
], -1))
]))
]));
}
}), tC = /* @__PURE__ */ Gs(eC, [["__scopeId", "data-v-2147a377"]]), nC = { class: "pbx-w-full pbx-inset-x-0 pbx-bg-white pbx-overflow-x-auto lg:pbx-pt-2 pbx-pt-2" }, rC = { key: 0 }, oC = { key: 1 }, iC = {
__name: "BuilderComponents",
props: {
firstButtonText: {
required: !0
},
title: {
required: !0
},
show: {
type: Boolean,
default: !1,
required: !0
},
CustomBuilderComponents: {
type: Object,
default: null
}
},
emits: ["firstModalButtonSearchComponentsFunction"],
setup(n, { emit: e }) {
const t = zn("CustomMediaComponent"), r = e, o = function() {
r("firstModalButtonSearchComponentsFunction");
};
return (i, s) => (w(), pe(Vt, {
title: n.title,
maxWidth: "6xl",
showModalBuilder: n.show,
onCloseMainModalBuilder: o,
minHeight: "",
maxHeight: ""
}, {
default: V(() => [
d("div", nC, [
d("div", null, [
n.CustomBuilderComponents ? (w(), E("div", rC, [
(w(), pe(Au(n.CustomBuilderComponents)))
])) : (w(), E("div", oC, [
j(tC, { customMediaComponent: y(t) }, null, 8, ["customMediaComponent"])
]))
])
])
]),
_: 1
}, 8, ["title", "showModalBuilder"]));
}
}, sC = {
setup() {
return {
expanded: M(!1)
};
}
}, lC = { class: "pbx-myPrimaryParagraph pbx-font-medium pbx-my-0 pbx-py-0" }, aC = {
key: 0,
class: "material-symbols-outlined"
}, cC = {
key: 1,
class: "material-symbols-outlined"
};
function pC(n, e, t, r, o, i) {
return w(), E("div", {
class: X(["pbx-flex pbx-flex-col pbx-border-solid pbx-border pbx-border-gray-400", { "": r.expanded }])
}, [
d("div", {
class: "pbx-flex pbx-flex-row pbx-justify-between pbx-items-center pbx-pl-3 pbx-pr-3 pbx-py-5 pbx-cursor-pointer pbx-duration-200 pbx-bg-white hover:pbx-bg-myPrimaryLightGrayColor",
onClick: e[0] || (e[0] = (s) => r.expanded = !r.expanded)
}, [
d("p", lC, [
ar(n.$slots, "title")
]),
r.expanded ? (w(), E("span", aC, " keyboard_arrow_down ")) : A("", !0),
r.expanded ? A("", !0) : (w(), E("span", cC, " chevron_right "))
]),
d("div", {
class: X([[
r.expanded ? "pbx-block pbx-bg-indigo-50 pbx-border-0 pbx-border-solid pbx-border-t pbx-border-red-50" : "pbx-hidden"
], "pbx-px-4 pbx-ease-linear pbx-duration-75 pbx-pb-8"])
}, [
ar(n.$slots, "content")
], 2)
], 2);
}
const Nt = /* @__PURE__ */ Gs(sC, [["render", pC]]), uC = { class: "pbx-myPrimaryInputLabel pbx-my-4" }, dC = { class: "pbx-flex pbx-flex-row pbx-flex-wrap pbx-gap-2 pbx-mt-2 pbx-mb-4" }, fC = ["onClick"], hC = { class: "pbx-flex pbx-items-center pbx-gap-1" }, bC = { class: "pbx-mr-1" }, mC = { class: "pbx-my-2 pbx-py-2" }, xC = {
for: "custom-css",
class: "pbx-myPrimaryInputLabel"
}, gC = { class: "pbx-flex pbx-gap-2 pbx-item-center" }, yC = ["placeholder"], vC = {
key: 0,
class: "pbx-myPrimaryInputError"
}, wu = {
__name: "ClassEditor",
setup(n) {
const { translate: e } = Me(), t = Ce(), r = Se, o = M(null), i = I(() => r.getCurrentClasses);
ee(
i,
(c) => {
o.value = c;
},
{ immediate: !0 }
);
const s = M(""), l = M(""), a = async () => {
var u;
const c = s.value.trim();
if (!c) {
l.value = "Please enter a class name.";
return;
}
const p = c.startsWith("pbx-") ? c : "pbx-" + c;
if ((u = o.value) != null && u.includes(p)) {
l.value = `Class "${p}" is already added.`;
return;
}
l.value = "", t.handleAddClasses(c), await t.initializeElementStyles(), s.value = "";
};
return (c, p) => (w(), pe(Nt, null, {
title: V(() => [
we(k(y(e)("Generated CSS")), 1)
]),
content: V(() => [
d("p", uC, k(y(e)(
"This is the CSS applied by the builder. Add your own CSS and press Enter to apply it to the selected element."
)), 1),
d("div", dC, [
(w(!0), E(Z, null, fe(o.value, (u) => (w(), E("div", {
key: u,
class: "pbx-myPrimaryTag pbx-cursor-pointer hover:pbx-bg-myPrimaryErrorColor hover:pbx-text-white pbx-text-xs pbx-py-2 pbx-font-medium",
onClick: async () => {
y(t).handleRemoveClasses(u), await y(t).initializeElementStyles();
}
}, [
d("div", hC, [
d("span", bC, k(u), 1)
])
], 8, fC))), 128))
]),
p[3] || (p[3] = d("hr", null, null, -1)),
d("div", mC, [
d("label", xC, [
we(k(y(e)("Add your CSS.")) + " ", 1),
p[2] || (p[2] = d("br", null, null, -1)),
we(" " + k(y(e)("The pbx- prefix is added automatically.")), 1)
]),
d("div", gC, [
xe(d("input", {
id: "custom-css",
"onUpdate:modelValue": p[0] || (p[0] = (u) => s.value = u),
type: "text",
placeholder: y(e)("Type class"),
onKeydown: p[1] || (p[1] = Nl((u) => a(), ["enter"])),
autocomplete: "off",
class: "pbx-myPrimaryInput"
}, null, 40, yC), [
[gr, s.value]
]),
d("button", {
onClick: a,
type: "button",
class: "pbx-myPrimaryButton"
}, k(y(e)("Add")), 1)
])
]),
l.value ? (w(), E("p", vC, k(l.value), 1)) : A("", !0)
]),
_: 1
}));
}
}, wC = { class: "pbx-myPrimaryInputLabel pbx-my-4" }, SC = { class: "pbx-flex pbx-flex-row pbx-flex-wrap pbx-gap-2 pbx-mt-2 pbx-mb-4" }, kC = ["onClick"], CC = { class: "pbx-flex pbx-items-center pbx-gap-1" }, MC = { class: "pbx-mr-1" }, EC = { class: "pbx-my-2 pbx-py-2" }, TC = {
for: "custom-style-property",
class: "pbx-myPrimaryInputLabel"
}, OC = { class: "pbx-flex pbx-gap-2 pbx-flex-col pbx-item-center" }, BC = ["placeholder", "onKeydown"], PC = ["placeholder"], AC = {
key: 0,
class: "pbx-myPrimaryInputError"
}, Su = {
__name: "StyleEditor",
setup(n) {
const { translate: e } = Me(), t = Ce(), r = Se, o = M(null), i = I(() => r.getCurrentStyles);
ee(
i,
(f) => {
o.value = f;
},
{ immediate: !0 }
);
const s = M(""), l = M(""), a = M(""), c = M(null), p = () => {
c.value && c.value.focus();
}, u = async () => {
const f = s.value.trim(), h = l.value.trim();
if (!f || !h) {
a.value = "Please enter a property and a value.";
return;
}
if (o.value && o.value[f]) {
a.value = `Property "${f}" already exists. Remove it first to add a new one.`;
return;
}
a.value = "", t.handleAddStyle(f, h), await t.initializeElementStyles(), s.value = "", l.value = "";
};
return (f, h) => (w(), pe(Nt, null, {
title: V(() => [
we(k(y(e)("Inline Styles")), 1)
]),
content: V(() => [
d("p", wC, k(y(e)(
"These are the inline styles applied by the builder. Add your own styles and press Enter to apply them to the selected element."
)), 1),
d("div", SC, [
(w(!0), E(Z, null, fe(o.value, (b, m) => (w(), E("div", {
key: m,
class: "pbx-myPrimaryTag pbx-cursor-pointer hover:pbx-bg-myPrimaryErrorColor hover:pbx-text-white pbx-text-xs pbx-py-2 pbx-font-medium",
onClick: async () => {
y(t).handleRemoveStyle(m), await y(t).initializeElementStyles();
}
}, [
d("div", CC, [
d("span", MC, k(m) + ": " + k(b) + "; ", 1)
])
], 8, kC))), 128))
]),
h[2] || (h[2] = d("hr", null, null, -1)),
d("div", EC, [
d("label", TC, k(y(e)("Add your own style.")), 1),
d("div", OC, [
xe(d("input", {
id: "custom-style-property",
"onUpdate:modelValue": h[0] || (h[0] = (b) => s.value = b),
type: "text",
placeholder: y(e)("property"),
onKeydown: Nl(bt(p, ["prevent"]), ["enter"]),
autocomplete: "off",
class: "pbx-myPrimaryInput"
}, null, 40, BC), [
[gr, s.value]
]),
xe(d("input", {
id: "custom-style-value",
ref_key: "valueInputRef",
ref: c,
"onUpdate:modelValue": h[1] || (h[1] = (b) => l.value = b),
type: "text",
placeholder: y(e)("value"),
onKeydown: Nl(u, ["enter"]),
autocomplete: "off",
class: "pbx-myPrimaryInput"
}, null, 40, PC), [
[gr, l.value]
]),
d("button", {
onClick: u,
type: "button",
class: "pbx-myPrimaryButton"
}, k(y(e)("Add")), 1)
])
]),
a.value ? (w(), E("p", AC, k(a.value), 1)) : A("", !0)
]),
_: 1
}));
}
};
function _C(n) {
return new Promise((e, t) => {
const r = new window.Image();
r.onload = e, r.onerror = t, r.src = n;
});
}
const LC = ["src"], NC = {
__name: "ImageEditor",
setup(n) {
const { translate: e } = Me(), t = Se, r = zn("CustomMediaComponent"), o = M(!1), i = M(!1), s = M(""), l = M(""), a = M(""), c = M(null), p = M(null), u = M(null), f = I(() => (t.getBasePrimaryImage && b(t.getBasePrimaryImage), t.getBasePrimaryImage)), h = function() {
i.value = !0, s.value = e("Media Library"), l.value = null, a.value = e("Close"), c.value = e(" Select image"), u.value = function() {
i.value = !1;
};
}, b = async function(m) {
o.value = !0, m && typeof m == "string" && m.length > 2 && (await _C(m), await Pe(200), o.value = !1);
};
return (m, x) => (w(), E("div", null, [
xe(d("div", null, x[0] || (x[0] = [
d("div", { class: "pbx-flex pbx-items-center pbx-justify-center pbx-mt-4 pbx-min-h-80" }, [
d("div", { class: "pbx-inline-block pbx-h-8 pbx-w-8 pbx-animate-spin pbx-rounded-full pbx-border-4 pbx-border-solid pbx-border-current pbx-border-r-transparent pbx-align-[-0.125em] motion-reduce:pbx-animate-[spin_1.5s_linear_infinite]" }, [
d("span", { class: "!pbx-absolute !pbx-m-px !pbx-h-px !pbx-w-px !pbx-overflow-hidden !pbx-whitespace-nowrap !pbx-border-0 !pbx-p-0 !pbx-[clip:rect(0,0,0,0)]" }, "Loading...")
])
], -1)
]), 512), [
[Dl, o.value]
]),
xe(d("div", null, [
d("img", {
class: "pbx-object-cover pbx-object-center pbx-w-full pbx-cursor-pointer",
src: f.value,
onClick: h,
alt: "image"
}, null, 8, LC)
], 512), [
[Dl, f.value && !o.value]
]),
j(mh, {
open: i.value,
title: s.value,
description: l.value,
firstButtonText: a.value,
secondButtonText: c.value,
thirdButtonText: p.value,
customMediaComponent: y(r),
onFirstMediaButtonFunction: u.value
}, null, 8, ["open", "title", "description", "firstButtonText", "secondButtonText", "thirdButtonText", "customMediaComponent", "onFirstMediaButtonFunction"])
]));
}
}, DC = { class: "pbx-my-2 pbx-py-2" }, IC = { class: "pbx-relative" }, $C = { class: "pbx-flex pbx-items-center pbx-gap-2" }, RC = { key: 0 }, FC = { class: "pbx-flex pbx-items-center" }, HC = { key: 0 }, jC = {
key: 2,
class: "pbx-ml-3"
}, zC = {
key: 3,
class: "pbx-ml-3"
}, VC = {
__name: "ManageBackgroundOpacity",
setup(n) {
const e = Ce(), t = Se, r = M(null), o = I(() => t.getBackgroundOpacity);
return ee(
o,
async (i) => {
r.value = i, await e.initializeElementStyles();
},
{ immediate: !0 }
), (i, s) => (w(), E("div", DC, [
s[3] || (s[3] = d("label", {
for: "bg-opacity",
class: "pbx-myPrimaryInputLabel"
}, " Background Opacity", -1)),
j(y(ii), {
as: "div",
modelValue: r.value,
"onUpdate:modelValue": s[0] || (s[0] = (l) => r.value = l)
}, {
default: V(() => [
d("div", IC, [
j(y(Tr), {
class: "pbx-myPrimarySelect",
id: "bg-opacity"
}, {
default: V(() => [
d("span", $C, [
r.value === "none" ? (w(), E("div", RC, s[1] || (s[1] = [
d("div", { class: "pbx-myPrimaryColorPreview pbx-border-none" }, [
d("span", { class: "material-symbols-outlined" }, " ev_shadow ")
], -1)
]))) : A("", !0),
r.value !== "none" ? (w(), E("div", {
key: 1,
class: X(["pbx-aspect-square pbx-w-6 pbx-h-6 pbx-bg-gray-950", `${r.value}`])
}, null, 2)) : A("", !0),
d("span", {
class: X(["pbx-block pbx-truncate", [(r.value !== "none", "")]])
}, k(r.value === "none" ? "Transparent" : r.value), 3)
])
]),
_: 1
}),
j(oo, {
"leave-active-class": "pbx-transition pbx-ease-in pbx-duration-100",
"leave-from-class": "pbx-opacity-100",
"leave-to-class": "pbx-opacity-0"
}, {
default: V(() => [
j(y(si), { class: "pbx-absolute pbx-z-10 pbx-mt-1 pbx-max-h-56 pbx-w-full pbx-overflow-auto pbx-rounded-md pbx-bg-white pbx-text-base pbx-shadow-lg pbx-ring-1 pbx-ring-black pbx-ring-opacity-5 focus:pbx-outline-none sm:pbx-text-sm pbx-list-none pbx-p-0 pbx-m-0" }, {
default: V(() => [
(w(!0), E(Z, null, fe(y(Hi).backgroundOpacities, (l) => (w(), pe(y(li), {
as: "template",
onClick: (a) => y(e).handleBackgroundOpacity(l),
key: l,
value: l
}, {
default: V(({ active: a }) => [
d("li", {
class: X([
a ? "pbx-bg-myPrimaryLinkColor text-white" : "pbx-text-myPrimaryDarkGrayColor",
"pbx-relative pbx-cursor-default pbx-select-none pbx-py-2 pbx-pl-3 pbx-pr-9"
])
}, [
d("div", FC, [
l === "none" ? (w(), E("div", HC, s[2] || (s[2] = [
d("div", { class: "pbx-myPrimaryColorPreview pbx-border-none" }, [
d("span", { class: "material-symbols-outlined" }, " ev_shadow ")
], -1)
]))) : A("", !0),
l !== "none" ? (w(), E("div", {
key: 1,
class: X(["pbx-aspect-square pbx-w-6 pbx-h-6 pbx-bg-gray-950", `${l}`])
}, null, 2)) : A("", !0),
l === "none" ? (w(), E("span", jC, "Transparent")) : A("", !0),
l !== "none" ? (w(), E("span", zC, k(l), 1)) : A("", !0)
])
], 2)
]),
_: 2
}, 1032, ["onClick", "value"]))), 128))
]),
_: 1
})
]),
_: 1
})
])
]),
_: 1
}, 8, ["modelValue"])
]));
}
}, WC = { class: "pbx-my-2 pbx-py-2" }, UC = { class: "pbx-relative" }, qC = { class: "pbx-flex pbx-items-center pbx-gap-2" }, KC = { key: 0 }, GC = { class: "pbx-flex pbx-items-center" }, JC = { key: 0 }, YC = {
key: 2,
class: "pbx-ml-3"
}, XC = {
key: 3,
class: "pbx-ml-3"
}, QC = {
__name: "ManageOpacity",
setup(n) {
const e = Ce(), t = Se, r = M(null), o = I(() => t.getOpacity);
return ee(
o,
async (i) => {
r.value = i, await e.initializeElementStyles();
},
{ immediate: !0 }
), (i, s) => (w(), E("div", WC, [
s[3] || (s[3] = d("label", {
for: "default-opacity",
class: "pbx-myPrimaryInputLabel"
}, " Opacity", -1)),
j(y(ii), {
as: "div",
modelValue: r.value,
"onUpdate:modelValue": s[0] || (s[0] = (l) => r.value = l)
}, {
default: V(() => [
d("div", UC, [
j(y(Tr), {
class: "pbx-myPrimarySelect",
id: "default-opacity"
}, {
default: V(() => [
d("span", qC, [
r.value === "none" ? (w(), E("div", KC, s[1] || (s[1] = [
d("div", { class: "pbx-myPrimaryColorPreview pbx-border-none" }, [
d("span", { class: "material-symbols-outlined" }, " ev_shadow ")
], -1)
]))) : A("", !0),
r.value !== "none" ? (w(), E("div", {
key: 1,
class: X(["pbx-aspect-square pbx-w-6 pbx-h-6 pbx-bg-gray-950", `${r.value}`])
}, null, 2)) : A("", !0),
d("span", {
class: X(["pbx-block pbx-truncate", [(r.value !== "none", "")]])
}, k(r.value === "none" ? "Transparent" : r.value), 3)
])
]),
_: 1
}),
j(oo, {
"leave-active-class": "pbx-transition pbx-ease-in pbx-duration-100",
"leave-from-class": "pbx-opacity-100",
"leave-to-class": "pbx-opacity-0"
}, {
default: V(() => [
j(y(si), { class: "pbx-absolute pbx-z-10 pbx-mt-1 pbx-max-h-56 pbx-w-full pbx-overflow-auto pbx-rounded-md pbx-bg-white pbx-text-base pbx-shadow-lg pbx-ring-1 pbx-ring-black pbx-ring-opacity-5 focus:pbx-outline-none sm:pbx-text-sm pbx-list-none pbx-p-0 pbx-m-0" }, {
default: V(() => [
(w(!0), E(Z, null, fe(y(Hi).opacities, (l) => (w(), pe(y(li), {
as: "template",
onClick: (a) => y(e).handleOpacity(l),
key: l,
value: l
}, {
default: V(({ active: a }) => [
d("li", {
class: X([
a ? "pbx-bg-myPrimaryLinkColor text-white" : "pbx-text-myPrimaryDarkGrayColor",
"pbx-relative pbx-cursor-default pbx-select-none pbx-py-2 pbx-pl-3 pbx-pr-9"
])
}, [
d("div", GC, [
l === "none" ? (w(), E("div", JC, s[2] || (s[2] = [
d("div", { class: "pbx-myPrimaryColorPreview pbx-border-none" }, [
d("span", { class: "material-symbols-outlined" }, " ev_shadow ")
], -1)
]))) : A("", !0),
l !== "none" ? (w(), E("div", {
key: 1,
class: X(["pbx-aspect-square pbx-w-6 pbx-h-6 pbx-bg-gray-950", `${l}`])
}, null, 2)) : A("", !0),
l === "none" ? (w(), E("span", YC, "Transparent")) : A("", !0),
l !== "none" ? (w(), E("span", XC, k(l), 1)) : A("", !0)
])
], 2)
]),
_: 2
}, 1032, ["onClick", "value"]))), 128))
]),
_: 1
})
]),
_: 1
})
])
]),
_: 1
}, 8, ["modelValue"])
]));
}
}, ZC = {
__name: "OpacityEditor",
setup(n) {
const { translate: e } = Me();
return (t, r) => (w(), pe(Nt, null, {
title: V(() => [
we(k(y(e)("Opacity & Transparency")), 1)
]),
content: V(() => [
j(QC),
r[0] || (r[0] = d("hr", null, null, -1)),
j(VC)
]),
_: 1
}));
}
}, e2 = { class: "pbx-myPrimaryParagraph pbx-font-medium pbx-py-0 pbx-my-4" }, t2 = { class: "pbx-my-2 pbx-py-2" }, n2 = {
for: "font-desktop",
class: "pbx-myPrimaryInputLabel"
}, r2 = {
disabled: "",
value: ""
}, o2 = { class: "pbx-my-2 pbx-py-2" }, i2 = {
for: "font-weight",
class: "pbx-myPrimaryInputLabel"
}, s2 = {
disabled: "",
value: ""
}, l2 = { class: "pbx-my-2 pbx-py-2" }, a2 = {
for: "font-family",
class: "pbx-myPrimaryInputLabel"
}, c2 = {
disabled: "",
value: ""
}, p2 = { class: "pbx-my-2 pbx-py-2" }, u2 = {
for: "font-style",
class: "pbx-myPrimaryInputLabel"
}, d2 = {
disabled: "",
value: ""
}, ku = {
__name: "Typography",
setup(n) {
const { translate: e } = Me(), t = Ce(), r = Se, o = M(null), i = M(null), s = M(null), l = M(null), a = M(null), c = M(null), p = M(null), u = I(() => r.getFontBase), f = I(() => r.getFontDesktop), h = I(() => r.getFontTablet), b = I(() => r.getFontMobile), m = I(() => r.getFontWeight), x = I(() => r.getFontFamily), v = I(() => r.getFontStyle);
return ee(
u,
async (C) => {
o.value = C, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
f,
async (C) => {
i.value = C, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
h,
async (C) => {
s.value = C, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
b,
async (C) => {
l.value = C, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
m,
async (C) => {
a.value = C, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
x,
async (C) => {
c.value = C, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
v,
async (C) => {
p.value = C, await t.initializeElementStyles();
},
{ immediate: !0 }
), (C, S) => (w(), pe(Nt, null, {
title: V(() => [
we(k(y(e)("Typographies")), 1)
]),
content: V(() => [
d("p", e2, k(y(e)("Font Appearance")), 1),
A("", !0),
d("div", t2, [
d("label", n2, k(y(e)("Font size")), 1),
xe(d("select", {
id: "font-desktop",
"onUpdate:modelValue": S[2] || (S[2] = (g) => i.value = g),
class: "pbx-myPrimarySelect",
onChange: S[3] || (S[3] = (g) => y(t).handleFontSizeDesktop(i.value))
}, [
d("option", r2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(ho).fontDesktop, (g) => (w(), E("option", { key: g }, k(g), 1))), 128))
], 544), [
[Ue, i.value]
])
]),
A("", !0),
S[14] || (S[14] = d("hr", null, null, -1)),
d("div", o2, [
d("label", i2, k(y(e)("Font weight")), 1),
xe(d("select", {
id: "font-weight",
"onUpdate:modelValue": S[8] || (S[8] = (g) => a.value = g),
class: "pbx-myPrimarySelect",
onChange: S[9] || (S[9] = (g) => y(t).handleFontWeight(a.value))
}, [
d("option", s2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(Vr).fontWeight, (g) => (w(), E("option", { key: g }, k(g), 1))), 128))
], 544), [
[Ue, a.value]
])
]),
S[15] || (S[15] = d("hr", null, null, -1)),
d("div", l2, [
d("label", a2, k(y(e)("Font family")), 1),
xe(d("select", {
id: "font-family",
"onUpdate:modelValue": S[10] || (S[10] = (g) => c.value = g),
class: "pbx-myPrimarySelect",
onChange: S[11] || (S[11] = (g) => y(t).handleFontFamily(c.value))
}, [
d("option", c2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(Vr).fontFamily, (g) => (w(), E("option", { key: g }, k(g), 1))), 128))
], 544), [
[Ue, c.value]
])
]),
S[16] || (S[16] = d("hr", null, null, -1)),
d("div", p2, [
d("label", u2, k(y(e)("Font Style")), 1),
xe(d("select", {
id: "font-style",
"onUpdate:modelValue": S[12] || (S[12] = (g) => p.value = g),
class: "pbx-myPrimarySelect",
onChange: S[13] || (S[13] = (g) => y(t).handleFontStyle(p.value))
}, [
d("option", d2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(Vr).fontStyle, (g) => (w(), E("option", { key: g }, k(g), 1))), 128))
], 544), [
[Ue, p.value]
])
])
]),
_: 1
}));
}
}, f2 = { class: "pbx-my-2 pbx-py-2" }, h2 = { class: "pbx-pt-4 pbx-pb-2 pbx-mb-4" }, b2 = { class: "pbx-myPrimaryInputLabel pbx-font-medium pbx-italic" }, m2 = {
for: "vertical-padding",
class: "pbx-myPrimaryInputLabel"
}, x2 = {
disabled: "",
value: ""
}, g2 = { class: "pbx-my-2 pbx-py-2" }, y2 = {
for: "horizontal-padding",
class: "pbx-myPrimaryInputLabel"
}, v2 = {
disabled: "",
value: ""
}, Cu = {
__name: "Padding",
setup(n) {
const { translate: e } = Me(), t = Ce(), r = Se, o = M(null), i = M(null), s = M(null), l = M(null), a = I(() => r.getFontVerticalPadding), c = I(() => r.getFontHorizontalPadding), p = I(() => r.getFontVerticalMargin), u = I(() => r.getFontHorizontalMargin);
return ee(
a,
async (f) => {
o.value = f, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
c,
async (f) => {
i.value = f, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
p,
async (f) => {
s.value = f, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
u,
async (f) => {
l.value = f, await t.initializeElementStyles();
},
{ immediate: !0 }
), (f, h) => (w(), pe(Nt, null, {
title: V(() => [
we(k(y(e)("Padding")), 1)
]),
content: V(() => [
d("div", f2, [
d("div", h2, [
d("p", b2, k(y(e)("Large Screens Only")), 1),
h[4] || (h[4] = d("hr", null, null, -1))
]),
d("label", m2, k(y(e)("Vertical Padding")), 1),
xe(d("select", {
id: "vertical-padding",
"onUpdate:modelValue": h[0] || (h[0] = (b) => o.value = b),
class: "pbx-myPrimarySelect",
onChange: h[1] || (h[1] = (b) => y(t).handleVerticalPadding(o.value))
}, [
d("option", x2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(An).verticalPadding, (b) => (w(), E("option", { key: b }, k(b), 1))), 128))
], 544), [
[Ue, o.value]
])
]),
h[5] || (h[5] = d("hr", null, null, -1)),
d("div", g2, [
d("label", y2, k(y(e)("Horizontal Padding")), 1),
xe(d("select", {
id: "horizontal-padding",
"onUpdate:modelValue": h[2] || (h[2] = (b) => i.value = b),
class: "pbx-myPrimarySelect",
onChange: h[3] || (h[3] = (b) => y(t).handleHorizontalPadding(i.value))
}, [
d("option", v2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(An).horizontalPadding, (b) => (w(), E("option", { key: b }, k(b), 1))), 128))
], 544), [
[Ue, i.value]
])
])
]),
_: 1
}));
}
}, w2 = { class: "pbx-my-2 pbx-py-2" }, S2 = { class: "pbx-pt-4 pbx-pb-2 pbx-mb-4" }, k2 = { class: "pbx-myPrimaryInputLabel pbx-font-medium pbx-italic" }, C2 = {
for: "vertical-margin",
class: "pbx-myPrimaryInputLabel"
}, M2 = {
disabled: "",
value: ""
}, E2 = { class: "pbx-my-2 pbx-py-2" }, T2 = {
for: "horizontal-margin",
class: "pbx-myPrimaryInputLabel"
}, O2 = {
disabled: "",
value: ""
}, Mu = {
__name: "Margin",
setup(n) {
const { translate: e } = Me(), t = Ce(), r = Se, o = M(null), i = M(null), s = M(null), l = M(null), a = I(() => r.getFontVerticalPadding), c = I(() => r.getFontHorizontalPadding), p = I(() => r.getFontVerticalMargin), u = I(() => r.getFontHorizontalMargin);
return ee(
a,
async (f) => {
o.value = f, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
c,
async (f) => {
i.value = f, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
p,
async (f) => {
s.value = f, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
u,
async (f) => {
l.value = f, await t.initializeElementStyles();
},
{ immediate: !0 }
), (f, h) => (w(), pe(Nt, null, {
title: V(() => [
we(k(y(e)("Margin")), 1)
]),
content: V(() => [
d("div", w2, [
d("div", S2, [
d("p", k2, k(y(e)("Large Screens Only")), 1),
h[4] || (h[4] = d("hr", null, null, -1))
]),
d("label", C2, k(y(e)("Vertical Margin")), 1),
xe(d("select", {
id: "vertical-margin",
"onUpdate:modelValue": h[0] || (h[0] = (b) => s.value = b),
class: "pbx-myPrimarySelect",
onChange: h[1] || (h[1] = (b) => y(t).handleVerticalMargin(s.value))
}, [
d("option", M2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(An).verticalMargin, (b) => (w(), E("option", { key: b }, k(b), 1))), 128))
], 544), [
[Ue, s.value]
])
]),
h[5] || (h[5] = d("hr", null, null, -1)),
d("div", E2, [
d("label", T2, k(y(e)("Horizontal Margin")), 1),
xe(d("select", {
id: "horizontal-margin",
"onUpdate:modelValue": h[2] || (h[2] = (b) => l.value = b),
class: "pbx-myPrimarySelect",
onChange: h[3] || (h[3] = (b) => y(t).handleHorizontalMargin(l.value))
}, [
d("option", O2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(An).horizontalMargin, (b) => (w(), E("option", { key: b }, k(b), 1))), 128))
], 544), [
[Ue, l.value]
])
])
]),
_: 1
}));
}
}, B2 = { class: "pbx-myPrimaryParagraph pbx-font-medium pbx-py-0 pbx-my-4" }, P2 = { class: "pbx-my-2 pbx-py-2" }, A2 = {
for: "global-border-radius",
class: "pbx-myPrimaryInputLabel"
}, _2 = {
disabled: "",
value: ""
}, L2 = { class: "pbx-myPrimaryParagraph pbx-font-medium pbx-py-0 pbx-my-4" }, N2 = { class: "pbx-my-2 pbx-py-2" }, D2 = {
for: "border-radius-top-left",
class: "pbx-myPrimaryInputLabel"
}, I2 = {
disabled: "",
value: ""
}, $2 = { class: "pbx-my-2 pbx-py-2" }, R2 = {
for: "border-radius-top-right",
class: "pbx-myPrimaryInputLabel"
}, F2 = {
disabled: "",
value: ""
}, H2 = { class: "pbx-my-2 pbx-py-2" }, j2 = {
for: "border-radius-bottom-left",
class: "pbx-myPrimaryInputLabel"
}, z2 = {
disabled: "",
value: ""
}, V2 = { class: "pbx-my-2 pbx-py-2" }, W2 = {
for: "border-radius-bottom-right",
class: "pbx-myPrimaryInputLabel"
}, U2 = {
disabled: "",
value: ""
}, Eu = {
__name: "BorderRadius",
setup(n) {
const { translate: e } = Me(), t = Ce(), r = Se, o = M(null), i = M(null), s = M(null), l = M(null), a = M(null), c = I(() => r.getBorderRadiusGlobal), p = I(() => r.getBorderRadiusTopLeft), u = I(() => r.getBorderRadiusTopRight), f = I(() => r.getBorderRadiusBottomleft), h = I(() => r.getBorderRadiusBottomRight);
return ee(
c,
async (b) => {
o.value = b, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
p,
async (b) => {
i.value = b, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
u,
async (b) => {
s.value = b, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
f,
async (b) => {
l.value = b, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
h,
async (b) => {
a.value = b, await t.initializeElementStyles();
},
{ immediate: !0 }
), (b, m) => (w(), pe(Nt, null, {
title: V(() => [
we(k(y(e)("Border Radius")), 1)
]),
content: V(() => [
d("p", B2, k(y(e)("Global")), 1),
d("div", P2, [
d("label", A2, k(y(e)("Border Radius")), 1),
xe(d("select", {
id: "global-border-radius",
"onUpdate:modelValue": m[0] || (m[0] = (x) => o.value = x),
class: "pbx-myPrimarySelect",
onChange: m[1] || (m[1] = (x) => y(t).handleBorderRadiusGlobal(o.value))
}, [
d("option", _2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(jt).roundedGlobal, (x) => (w(), E("option", { key: x }, k(x), 1))), 128))
], 544), [
[Ue, o.value]
])
]),
m[10] || (m[10] = d("hr", null, null, -1)),
d("p", L2, k(y(e)("Specific")), 1),
d("div", N2, [
d("label", D2, k(y(e)("Border Radius top left")), 1),
xe(d("select", {
id: "border-radius-top-left",
"onUpdate:modelValue": m[2] || (m[2] = (x) => i.value = x),
class: "pbx-myPrimarySelect",
onChange: m[3] || (m[3] = (x) => y(t).handleBorderRadiusTopLeft(i.value))
}, [
d("option", I2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(jt).roundedTopLeft, (x) => (w(), E("option", { key: x }, k(x), 1))), 128))
], 544), [
[Ue, i.value]
])
]),
m[11] || (m[11] = d("hr", null, null, -1)),
d("div", $2, [
d("label", R2, k(y(e)("Border Radius top right")), 1),
xe(d("select", {
id: "border-radius-top-right",
"onUpdate:modelValue": m[4] || (m[4] = (x) => s.value = x),
class: "pbx-myPrimarySelect",
onChange: m[5] || (m[5] = (x) => y(t).handleBorderRadiusTopRight(s.value))
}, [
d("option", F2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(jt).roundedTopRight, (x) => (w(), E("option", { key: x }, k(x), 1))), 128))
], 544), [
[Ue, s.value]
])
]),
m[12] || (m[12] = d("hr", null, null, -1)),
d("div", H2, [
d("label", j2, k(y(e)("Border Radius bottom left")), 1),
xe(d("select", {
id: "border-radius-bottom-left",
"onUpdate:modelValue": m[6] || (m[6] = (x) => l.value = x),
class: "pbx-myPrimarySelect",
onChange: m[7] || (m[7] = (x) => y(t).handleBorderRadiusBottomleft(l.value))
}, [
d("option", z2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(jt).roundedBottomLeft, (x) => (w(), E("option", { key: x }, k(x), 1))), 128))
], 544), [
[Ue, l.value]
])
]),
m[13] || (m[13] = d("hr", null, null, -1)),
d("div", V2, [
d("label", W2, k(y(e)("Border Radius bottom right")), 1),
xe(d("select", {
id: "border-radius-bottom-right",
"onUpdate:modelValue": m[8] || (m[8] = (x) => a.value = x),
class: "pbx-myPrimarySelect",
onChange: m[9] || (m[9] = (x) => y(t).handleBorderRadiusBottomRight(a.value))
}, [
d("option", U2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(jt).roundedBottomRight, (x) => (w(), E("option", { key: x }, k(x), 1))), 128))
], 544), [
[Ue, a.value]
])
])
]),
_: 1
}));
}
}, q2 = { class: "pbx-myPrimaryParagraph pbx-font-medium pbx-py-0 pbx-my-4" }, K2 = { class: "pbx-my-2 pbx-py-2" }, G2 = {
for: "border-style",
class: "pbx-myPrimaryInputLabel"
}, J2 = {
disabled: "",
value: ""
}, Y2 = { class: "pbx-my-2 pbx-py-2" }, X2 = {
for: "border-width",
class: "pbx-myPrimaryInputLabel"
}, Q2 = {
disabled: "",
value: ""
}, Z2 = { class: "pbx-my-2 pbx-py-2" }, eM = {
for: "border-color",
class: "pbx-myPrimaryInputLabel"
}, tM = { class: "pbx-relative pbx-mt-2" }, nM = { class: "pbx-flex pbx-items-center pbx-gap-2" }, rM = { key: 0 }, oM = { class: "pbx-block pbx-truncate" }, iM = { class: "pbx-flex pbx-items-center" }, sM = { key: 0 }, lM = {
key: 2,
class: "pbx-ml-3"
}, aM = {
key: 3,
class: "pbx-ml-3"
}, Tu = {
__name: "Borders",
setup(n) {
const { translate: e } = Me(), t = Ce(), r = Se, o = M(null), i = M(null), s = M(null), l = I(() => r.getBorderStyle), a = I(() => r.getBorderWidth), c = I(() => r.getBorderColor);
return ee(
l,
async (p) => {
o.value = p, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
a,
async (p) => {
i.value = p, await t.initializeElementStyles();
},
{ immediate: !0 }
), ee(
c,
async (p) => {
s.value = p, await t.initializeElementStyles();
},
{ immediate: !0 }
), (p, u) => (w(), pe(Nt, null, {
title: V(() => [
we(k(y(e)("Border Style, Width & Color")), 1)
]),
content: V(() => [
d("p", q2, k(y(e)("Border")), 1),
d("div", K2, [
d("label", G2, k(y(e)("Border Style")), 1),
xe(d("select", {
id: "border-style",
"onUpdate:modelValue": u[0] || (u[0] = (f) => o.value = f),
class: "pbx-myPrimarySelect",
onChange: u[1] || (u[1] = (f) => y(t).handleBorderStyle(o.value))
}, [
d("option", J2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(Wr).borderStyle, (f) => (w(), E("option", { key: f }, k(f), 1))), 128))
], 544), [
[Ue, o.value]
])
]),
u[8] || (u[8] = d("hr", null, null, -1)),
d("div", Y2, [
d("label", X2, k(y(e)("Border Width")), 1),
xe(d("select", {
id: "border-width",
"onUpdate:modelValue": u[2] || (u[2] = (f) => i.value = f),
class: "pbx-myPrimarySelect",
onChange: u[3] || (u[3] = (f) => y(t).handleBorderWidth(i.value))
}, [
d("option", Q2, k(y(e)("Select")), 1),
(w(!0), E(Z, null, fe(y(Wr).borderWidth, (f) => (w(), E("option", { key: f }, k(f), 1))), 128))
], 544), [
[Ue, i.value]
])
]),
u[9] || (u[9] = d("hr", null, null, -1)),
d("div", Z2, [
d("label", eM, k(y(e)("Border Color")), 1),
j(y(ii), {
as: "div",
modelValue: s.value,
"onUpdate:modelValue": u[5] || (u[5] = (f) => s.value = f)
}, {
default: V(() => [
d("div", tM, [
j(y(Tr), {
class: "pbx-myPrimarySelect",
id: "border-color"
}, {
default: V(() => {
var f;
return [
d("span", nM, [
c.value === "none" ? (w(), E("div", rM, u[6] || (u[6] = [
d("div", { class: "pbx-myPrimaryColorPreview pbx-border-none" }, [
d("span", { class: "material-symbols-outlined" }, " ev_shadow ")
], -1)
]))) : A("", !0),
s.value !== "none" ? (w(), E("div", {
key: 1,
class: X(["pbx-aspect-square pbx-w-6 pbx-h-6 pbx-border-solid pbx-border pbx-border-gray-100 pbx-rounded-sm", `pbx-bg-${(f = s.value) == null ? void 0 : f.replace("pbx-border-", "")}`])
}, null, 2)) : A("", !0),
d("span", oM, k(s.value), 1)
])
];
}),
_: 1
}),
j(oo, {
"leave-active-class": "pbx-transition pbx-ease-in pbx-duration-100",
"leave-from-class": "pbx-opacity-100",
"leave-to-class": "pbx-opacity-0"
}, {
default: V(() => [
j(y(si), { class: "pbx-absolute pbx-z-10 pbx-mt-1 pbx-max-h-56 pbx-w-full pbx-overflow-auto pbx-rounded-md pbx-bg-white pbx-text-base pbx-shadow-lg pbx-ring-1 pbx-ring-black pbx-ring-opacity-5 focus:pbx-outline-none sm:pbx-text-sm pbx-list-none pbx-p-0 pbx-m-0" }, {
default: V(() => [
(w(!0), E(Z, null, fe(y(Wr).borderColor, (f) => (w(), pe(y(li), {
as: "template",
onClick: u[4] || (u[4] = (h) => y(t).handleBorderColor(s.value)),
key: f,
value: f
}, {
default: V(({ active: h, borderColor: b }) => [
d("li", {
class: X([
h ? "pbx-bg-myPrimaryLinkColor pbx-text-white" : "pbx-text-myPrimaryDarkGrayColor",
"pbx-relative pbx-cursor-default pbx-select-none pbx-py-2 pbx-pl-3 pbx-pr-9"
])
}, [
d("div", iM, [
f === "none" ? (w(), E("div", sM, u[7] || (u[7] = [
d("div", { class: "pbx-myPrimaryColorPreview pbx-border-none" }, [
d("span", { class: "material-symbols-outlined" }, " ev_shadow ")
], -1)
]))) : A("", !0),
f !== "none" ? (w(), E("div", {
key: 1,
class: X(["pbx-aspect-square pbx-w-6 pbx-h-6 pbx-bg-gray-950", `pbx-bg-${f.replace("pbx-border-", "")}`])
}, null, 2)) : A("", !0),
f === "none" ? (w(), E("span", lM, k(y(e)("Transparent")), 1)) : A("", !0),
f !== "none" ? (w(), E("span", aM, k(f), 1)) : A("", !0)
])
], 2)
]),
_: 2
}, 1032, ["value"]))), 128))
]),
_: 1
})
]),
_: 1
})
])
]),
_: 1
}, 8, ["modelValue"])
])
]),
_: 1
}));
}
}, cM = {
key: 0,
class: "pbx-flex pbx-flex-col pbx-border-solid pbx-border pbx-border-gray-400"
}, pM = { class: "pbx-myPrimaryParagraph pbx-font-medium pbx-my-0 pbx-py-0" }, uM = /* @__PURE__ */ Qe({
__name: "TipTap",
setup(n) {
const { translate: e } = Me(), t = Ce();
return (r, o) => (w(), E("div", null, [
y(t).isSelectedElementValidText() ? (w(), E("div", cM, [
d("div", {
onClick: o[0] || (o[0] = (i) => y(t).toggleTipTapModal(!0)),
class: "pbx-flex pbx-flex-row pbx-justify-between pbx-items-center pbx-pl-3 pbx-pr-3 pbx-py-5 pbx-cursor-pointer pbx-duration-200 hover:pbx-bg-myPrimaryLightGrayColor pbx-bg-white"
}, [
d("p", pM, k(y(e)("Text")), 1),
o[1] || (o[1] = d("span", { class: "material-symbols-outlined" }, " chevron_right ", -1))
])
])) : A("", !0)
]));
}
}), dM = { class: "pbx-my-2 pbx-py-2" }, fM = {
for: "vertical-margin",
class: "pbx-myPrimaryInputLabel"
}, hM = { class: "pbx-flex pbx-justify-end pbx-min-h-6" }, bM = {
key: 0,
class: "pbx-myPrimaryParagraphError"
}, mM = { class: "pbx-border-0 pbx-border-solid pbx-border-t pbx-border-gray-200 pbx-flex pbx-items-center pbx-justify-end" }, xM = { class: "pbx-py-4 pbx-flex sm:pbx-justify-end pbx-justify-center" }, gM = { class: "sm:pbx-grid-cols-2 sm:pbx-items-end sm:pbx-justify-end pbx-flex sm:pbx-flex-row pbx-flex-col pbx-myPrimaryGap sm:pbx-w-5/6 pbx-w-full" }, yM = {
key: 1,
class: "pbx-flex pbx-items-center pbx-my-2 pbx-justify-end"
}, vM = { class: "pbx-flex pbx-justify-end pbx-min-h-6" }, wM = {
key: 0,
class: "pbx-myPrimaryParagraphError"
}, SM = { class: "pbx-border-0 pbx-border-solid pbx-border-t pbx-border-gray-200 pbx-flex pbx-items-center pbx-justify-end" }, kM = { class: "pbx-py-4 pbx-flex sm:pbx-justify-end pbx-justify-center" }, CM = { class: "sm:pbx-grid-cols-2 sm:pbx-items-end sm:pbx-justify-end pbx-flex sm:pbx-flex-row pbx-flex-col pbx-myPrimaryGap sm:pbx-w-5/6 pbx-w-full" }, MM = {
key: 1,
class: "pbx-flex pbx-items-center pbx-my-2 pbx-justify-end"
}, Ou = {
__name: "HTMLEditor",
props: {
globalPage: {
type: Boolean
}
},
setup(n) {
const e = Ce(), t = Se, { translate: r } = Me(), o = n, i = I(() => t.getElement), s = I(() => t.getComponents), l = I(() => !i.value || !(i.value instanceof HTMLElement) ? "" : i.value.outerHTML), a = M(!1), c = M(""), p = M(""), u = () => {
if (a.value = !0, o.globalPage || (c.value = l.value), o.globalPage) {
const v = Array.isArray(s.value) && s.value.map((C) => C.html_code.replace(/data-componentid="[^"]*"/g, "").replace(/\s{2,}/g, " ")).join(`
`);
p.value = v;
}
}, f = () => {
a.value = !1;
}, h = M(!1), b = M(null), m = async () => {
b.value = null, h.value = !0, await Pe(300);
const v = await e.applyModifiedHTML(c.value);
if (v) {
b.value = v, h.value = !1;
return;
}
a.value = !1, h.value = !1;
}, x = async () => {
b.value = null, h.value = !0, b.value = null, await Pe(300);
const v = await e.applyModifiedComponents(p.value);
if (v) {
b.value = v, h.value = !1;
return;
}
a.value = !1, h.value = !1;
};
return (v, C) => (w(), E(Z, null, [
j(Nt, null, {
title: V(() => [
we(k(y(r)("HTML Editor")), 1)
]),
content: V(() => [
d("div", dM, [
d("label", fM, k(y(r)("Gain full control over components by editing the raw HTML.")), 1),
C[2] || (C[2] = d("hr", null, null, -1))
]),
d("button", {
onClick: u,
type: "button",
class: "pbx-myPrimaryButton"
}, k(y(r)("HTML Editor")), 1)
]),
_: 1
}),
j(Vt, {
maxWidth: "7xl",
showModalBuilder: a.value,
title: y(r)("HTML Editor"),
onCloseMainModalBuilder: f
}, {
default: V(() => [
n.globalPage ? A("", !0) : (w(), E(Z, { key: 0 }, [
xe(d("textarea", {
id: "html-editor",
"onUpdate:modelValue": C[0] || (C[0] = (S) => c.value = S),
class: "pbx-h-full pbx-font-sans pbx-bg-gray-900 pbx-text-white pbx-w-full",
style: { overflow: "auto", "min-height": "400px" }
}, null, 512), [
[gr, c.value]
]),
d("div", hM, [
b.value ? (w(), E("p", bM, " Error: " + k(b.value), 1)) : A("", !0)
]),
d("div", mM, [
d("div", xM, [
d("div", gM, [
h.value ? A("", !0) : (w(), E(Z, { key: 0 }, [
d("button", {
onClick: f,
type: "button",
class: "pbx-mySecondaryButton"
}, k(y(r)("Close")), 1),
d("button", {
onClick: m,
type: "button",
class: "pbx-myPrimaryButton"
}, k(y(r)("Save")), 1)
], 64)),
h.value ? (w(), E("div", yM, C[3] || (C[3] = [
d("div", { class: "pbx-inline-block pbx-h-8 pbx-w-8 pbx-animate-spin pbx-rounded-full pbx-border-4 pbx-border-solid pbx-border-current pbx-border-r-transparent pbx-align-[-0.125em] motion-reduce:pbx-animate-[spin_1.5s_linear_infinite]" }, [
d("span", { class: "!pbx-absolute !pbx-m-px !pbx-h-px !pbx-w-px !pbx-overflow-hidden !pbx-whitespace-nowrap !pbx-border-0 !pbx-p-0 !pbx-[clip:rect(0,0,0,0)]" }, "Loading...")
], -1)
]))) : A("", !0)
])
])
])
], 64)),
n.globalPage ? (w(), E(Z, { key: 1 }, [
xe(d("textarea", {
id: "html-editor",
"onUpdate:modelValue": C[1] || (C[1] = (S) => p.value = S),
class: "pbx-h-full pbx-font-sans pbx-bg-gray-900 pbx-text-white pbx-w-full",
style: { overflow: "auto", "min-height": "400px" }
}, null, 512), [
[gr, p.value]
]),
d("div", vM, [
b.value ? (w(), E("p", wM, " Error: " + k(b.value), 1)) : A("", !0)
]),
d("div", SM, [
d("div", kM, [
d("div", CM, [
h.value ? A("", !0) : (w(), E(Z, { key: 0 }, [
d("button", {
onClick: f,
type: "button",
class: "pbx-mySecondaryButton"
}, k(y(r)("Close")), 1),
d("button", {
onClick: x,
type: "button",
class: "pbx-myPrimaryButton"
}, k(y(r)("Save")), 1)
], 64)),
h.value ? (w(), E("div", MM, C[4] || (C[4] = [
d("div", { class: "pbx-inline-block pbx-h-8 pbx-w-8 pbx-animate-spin pbx-rounded-full pbx-border-4 pbx-border-solid pbx-border-current pbx-border-r-transparent pbx-align-[-0.125em] motion-reduce:pbx-animate-[spin_1.5s_linear_infinite]" }, [
d("span", { class: "!pbx-absolute !pbx-m-px !pbx-h-px !pbx-w-px !pbx-overflow-hidden !pbx-whitespace-nowrap !pbx-border-0 !pbx-p-0 !pbx-[clip:rect(0,0,0,0)]" }, "Loading...")
], -1)
]))) : A("", !0)
])
])
])
], 64)) : A("", !0)
]),
_: 1
}, 8, ["showModalBuilder", "title"])
], 64));
}
}, EM = { class: "pbx-flex pbx-h-full pbx-flex-col" }, TM = { class: "pbx-flex pbx-flex-row pbx-justify-between pbx-pt-7 pbx-pr-4 pbx-pl-4 pbx-items-center pbx-mb-3" }, OM = { class: "pbx-font-medium pbx-text-sm" }, BM = { class: "pbx-lowercase" }, PM = { class: "pbx-mb-1" }, AM = { class: "pbx-mb-1" }, _M = { class: "pbx-my-1" }, LM = { class: "pbx-my-1" }, NM = { class: "pbx-my-1" }, DM = { class: "pbx-my-1" }, IM = { class: "pbx-my-1" }, $M = { class: "pbx-my-1" }, RM = { class: "pbx-my-1" }, FM = { class: "pbx-my-1" }, HM = { class: "pbx-my-1" }, jM = { class: "pbx-my-1" }, zM = { class: "pbx-myPrimaryInputLabel pbx-my-4" }, VM = { class: "pbx-my-2 pbx-py-2" }, WM = {
key: 0,
class: "pbx-my-1"
}, UM = { class: "pbx-myPrimaryInputLabel pbx-my-4" }, qM = { class: "pbx-my-2 pbx-py-2" }, KM = {
id: "pagebuilder-right-menu",
class: "pbx-flex pbx-flex-col pbx-gap-2 pbx-pt-4 pbx-pb-2"
}, GM = { key: 0 }, JM = { class: "pbx-flex pbx-items-center pbx-my-2 pbx-py-4 pbx-px-2 pbx-justify-center" }, YM = { class: "pbx-inline-block pbx-h-8 pbx-w-8 pbx-animate-spin pbx-rounded-full pbx-border-4 pbx-border-solid pbx-border-current pbx-border-r-transparent pbx-align-[-0.125em] motion-reduce:pbx-animate-[spin_1.5s_linear_infinite]" }, XM = { class: "!pbx-absolute !pbx-m-px !pbx-h-px !pbx-w-px !pbx-overflow-hidden !pbx-whitespace-nowrap !pbx-border-0 !pbx-p-0 !pbx-[clip:rect(0,0,0,0)]" }, QM = {
key: 1,
class: "pbx-pb-12"
}, ZM = { class: "pbx-myPrimaryParagraph" }, eE = { class: "pbx-my-1" }, tE = { class: "pbx-my-1" }, nE = { class: "pbx-my-1" }, rE = { class: "pbx-my-1" }, oE = { class: "pbx-my-1" }, iE = { class: "pbx-my-1" }, sE = { class: "pbx-my-1" }, lE = { class: "pbx-my-1" }, aE = { class: "pbx-my-1" }, cE = { class: "pbx-my-1" }, pE = {
__name: "RightSidebarEditor",
emits: ["closeEditor"],
setup(n) {
const { translate: e } = Me(), t = Ce(), r = Se, o = M(null), i = I(() => r.getComponents), s = I(() => r.getElement), l = I(() => {
var x;
return (x = s.value) == null ? void 0 : x.tagName;
});
I(() => s.value instanceof HTMLElement && s.value.innerText.trim() !== " " || s.value instanceof HTMLImageElement);
const a = M(null);
let c = 0;
ee(
// or the specific value that triggers re-render
() => r.getElement,
() => {
ce(() => {
a.value && (a.value.scrollTop = c);
});
}
);
function p() {
a.value && (c = a.value.scrollTop);
}
const u = function(x, v) {
const O = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Downloaded HTML</title>
${`${Array.from(document.querySelectorAll('style, link[rel="stylesheet"]')).map((B) => B.tagName === "STYLE" ? B.outerHTML : B.tagName === "LINK" ? `<link rel="stylesheet" href="${B.href}">` : "").join(`
`)}
<style>
#pagebuilder blockquote,
#pagebuilder dl,
#pagebuilder dd,
#pagebuilder pre,
#pagebuilder hr,
#pagebuilder figure,
#pagebuilder p,
#pagebuilder h1,
#pagebuilder h2,
#pagebuilder h3,
#pagebuilder h4,
#pagebuilder h5,
#pagebuilder h6,
#pagebuilder ul,
#pagebuilder ol,
#pagebuilder li {
margin: 0;
padding: 0; /* Often useful for ul/ol too */
}
</style>
`}
</head>
<body>
<div id="pagebuilder" class="pbx-font-sans pbx-text-black">
${v}
</div>
</body>
</html>
`, T = document.createElement("a");
T.setAttribute("href", "data:text/html;charset=utf-8," + encodeURIComponent(O)), T.setAttribute("download", x), T.style.display = "none", document.body.appendChild(T), T.click(), document.body.removeChild(T);
}, f = function() {
const x = document.getElementById("pagebuilder");
if (!x)
return;
let v = _u(x);
const C = document.createElement("div");
C.innerHTML = v, C.querySelectorAll("[hovered], [selected]").forEach((S) => {
S.removeAttribute("hovered"), S.removeAttribute("selected");
}), v = C.innerHTML, u("downloaded_html.html", v);
}, h = M(null), b = async function() {
h.value = !0, await t.globalPageStyles();
}, m = async function() {
o.value = !0, await t.handleManualSave();
const x = document.querySelector("#pagebuilder");
x && x.removeAttribute("data-global-selected"), h.value = !1, o.value = !1;
};
return (x, v) => (w(), E("div", EM, [
d("div", TM, [
d("button", {
type: "button",
onClick: v[0] || (v[0] = (C) => x.$emit("closeEditor")),
class: "pbx-h-10 pbx-w-10 pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-50 pbx-aspect-square hover:pbx-bg-myPrimaryLinkColor hover:pbx-text-white focus-visible:pbx-ring-0 pbx-text-black hover:pbx-text-white"
}, v[1] || (v[1] = [
d("span", { class: "material-symbols-outlined" }, " close ", -1)
])),
d("p", OM, [
we(k(y(e)("Editing")) + " ", 1),
d("span", BM, "<" + k(l.value) + ">", 1)
])
]),
h.value ? A("", !0) : (w(), E("div", {
key: 0,
ref_key: "scrollContainer",
ref: a,
onScroll: p,
class: "pbx-pl-3 pbx-pr-3 pbx-mb-4 pbx-overflow-y-scroll"
}, [
xe(d("div", null, [
d("article", PM, [
j(NC)
]),
d("article", AM, [
j(uM)
]),
d("article", _M, [
j(ku)
]),
d("article", LM, [
j(ZC)
]),
d("article", NM, [
j(Cu)
]),
d("article", DM, [
j(Mu)
]),
d("article", IM, [
j(Eu)
]),
d("article", $M, [
j(Tu)
]),
d("article", RM, [
j(wu)
]),
d("article", FM, [
j(Su)
]),
d("article", HM, [
j(Ou)
])
], 512), [
[Dl, s.value && y(t).isEditableElement(s.value)]
]),
d("article", jM, [
j(Nt, null, {
title: V(() => [
we(k(y(e)("Global Page Styles")), 1)
]),
content: V(() => [
d("p", zM, k(y(e)(
"Apply styles that affect the entire page. These settings include global font family, text color, background color, and other universal styles that apply to all sections."
)), 1),
v[2] || (v[2] = d("hr", null, null, -1)),
d("div", VM, [
d("button", {
onClick: b,
type: "button",
class: "pbx-myPrimaryButton"
}, k(y(e)("Update Page Styles")), 1)
])
]),
_: 1
})
]),
Array.isArray(i.value) && i.value.length >= 1 ? (w(), E("article", WM, [
j(Nt, null, {
title: V(() => [
we(k(y(e)("Download HTML")), 1)
]),
content: V(() => [
d("p", UM, k(y(e)(
"Export the entire page as a standalone HTML file. This includes all sections, content, and applied styles, making it ready for use or integration elsewhere."
)), 1),
v[3] || (v[3] = d("hr", null, null, -1)),
d("div", qM, [
d("button", {
onClick: f,
type: "button",
class: "pbx-myPrimaryButton"
}, k(y(e)("Download HTML file")), 1)
])
]),
_: 1
})
])) : A("", !0)
], 544)),
j(Vt, {
maxWidth: "md",
minHeight: "pbx-min-h-[65vh] pbx-max-h-[65vh]",
showModalBuilder: h.value,
title: y(e)("Global Page Styles"),
onCloseMainModalBuilder: m
}, {
default: V(() => [
d("div", KM, [
o.value ? (w(), E("div", GM, [
d("div", JM, [
d("div", YM, [
d("span", XM, k(y(e)("Loading...")), 1)
])
])
])) : A("", !0),
!o.value && h.value ? (w(), E("div", QM, [
d("div", null, [
d("p", ZM, k(y(e)(
"Apply styles that affect the entire page. These settings include global font family, text color, background color, and other universal styles that apply to all sections."
)), 1),
d("article", eE, [
j(ku)
]),
d("article", tE, [
j(Th, { globalPageLayout: !0 })
]),
d("article", nE, [
j(Oh, { globalPageLayout: !0 })
]),
d("article", rE, [
j(Cu)
]),
d("article", oE, [
j(Mu)
]),
d("article", iE, [
j(Eu)
]),
d("article", sE, [
j(Tu)
]),
d("article", lE, [
j(wu)
]),
d("article", aE, [
j(Su)
]),
d("article", cE, [
j(Ou, { globalPage: !0 })
])
])
])) : A("", !0)
])
]),
_: 1
}, 8, ["showModalBuilder", "title"])
]));
}
}, uE = { class: "pbx-w-full pbx-inset-x-0 pbx-h-[90vh] pbx-bg-white pbx-overflow-x-scroll lg:pbx-pt-2 pbx-pt-2" }, dE = { class: "pbx-mt-4 pbx-mb-4 pbx-py-8 pbx-px-2 pbx-border pbx-border-solid pbx-border-gray-600 pbx-rounded-xl" }, fE = { class: "pbx-px-2" }, hE = { class: "pbx-mt-8" }, bE = { class: "pbx-overflow-hidden pbx-shadow pbx-ring-1 pbx-ring-black pbx-ring-opacity-5 md:pbx-rounded-lg" }, mE = { class: "pbx-overflow-x-auto" }, xE = { class: "pbx-min-w-full" }, gE = { class: "pbx-bg-white pbx-divide-y pbx-divide-gray-200" }, yE = { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-text-gray-500" }, vE = { class: "pbx-min-w-[30rem] pbx-w-max" }, wE = { class: "pbx-inline-flex pbx-items-center pbx-px-2.5 pbx-py-0.5 pbx-rounded-full pbx-text-xs pbx-font-medium pbx-bg-blue-100 pbx-text-blue-800" }, SE = {
key: 0,
class: "pbx-mt-4"
}, kE = { class: "pbx-overflow-hidden pbx-shadow pbx-ring-1 pbx-ring-black pbx-ring-opacity-5 md:pbx-rounded-lg" }, CE = { class: "pbx-overflow-x-auto" }, ME = { class: "pbx-min-w-full" }, EE = { class: "pbx-bg-white pbx-divide-y pbx-divide-gray-200" }, TE = { key: 0 }, OE = { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-text-gray-500" }, BE = { class: "pbx-min-w-[30rem] pbx-w-max" }, PE = { key: 1 }, AE = { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-text-gray-500" }, _E = { class: "pbx-min-w-[30rem] pbx-w-max" }, LE = {
key: 1,
class: "pbx-mt-8"
}, NE = { class: "pbx-overflow-hidden pbx-shadow pbx-ring-1 pbx-ring-black pbx-ring-opacity-5 md:pbx-rounded-lg" }, DE = { class: "pbx-overflow-x-auto" }, IE = { class: "pbx-min-w-full" }, $E = { class: "pbx-bg-white pbx-divide-y pbx-divide-gray-200" }, RE = { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-text-gray-500" }, FE = { class: "pbx-min-w-[30rem] pbx-w-max" }, HE = {
key: 0,
class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-text-gray-500"
}, jE = { class: "pbx-min-w-[30rem] pbx-w-max" }, zE = { class: "pbx-flex pbx-items-center pbx-space-x-3" }, VE = ["src"], WE = {
key: 0,
class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-text-gray-500"
}, UE = { class: "pbx-min-w-[30rem] pbx-w-max" }, qE = {
key: 2,
class: "pbx-mt-8"
}, KE = { class: "pbx-overflow-hidden pbx-shadow pbx-ring-1 pbx-ring-black pbx-ring-opacity-5 md:pbx-rounded-lg" }, GE = { class: "pbx-overflow-x-auto" }, JE = { class: "pbx-min-w-full" }, YE = { class: "pbx-bg-white pbx-divide-y pbx-divide-gray-200" }, XE = { key: 0 }, QE = { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-text-gray-500" }, ZE = { class: "pbx-min-w-[30rem] pbx-w-max" }, eT = { key: 1 }, tT = { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-text-gray-500" }, nT = { class: "pbx-min-w-[30rem] pbx-w-max" }, rT = { key: 2 }, oT = { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-text-gray-500" }, iT = { class: "pbx-min-w-[30rem] pbx-w-max" }, sT = { key: 3 }, lT = { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-text-gray-500" }, aT = { class: "pbx-min-w-[30rem] pbx-w-max" }, cT = {
key: 3,
class: "pbx-mt-8"
}, pT = { class: "pbx-overflow-hidden pbx-shadow pbx-ring-1 pbx-ring-black pbx-ring-opacity-5 md:pbx-rounded-lg" }, uT = { class: "pbx-overflow-x-auto" }, dT = { class: "pbx-min-w-full" }, fT = { class: "pbx-bg-white pbx-divide-y pbx-divide-gray-200" }, hT = { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-text-gray-500" }, bT = { class: "pbx-min-w-[30rem] pbx-w-max" }, mT = { class: "pbx-flex pbx-items-center pbx-space-x-3" }, xT = ["src"], gT = { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-text-gray-500" }, yT = { class: "pbx-min-w-[30rem] pbx-w-max" }, vT = { class: "pbx-flex pbx-items-center pbx-space-x-3" }, wT = { class: "pbx-pr-6" }, ST = { class: "pbx-flex pbx-items-center pbx-space-x-3" }, kT = { class: "pbx-whitespace-nowrap" }, CT = {
key: 4,
class: "pbx-mt-8"
}, MT = { class: "pbx-overflow-hidden pbx-shadow pbx-ring-1 pbx-ring-black pbx-ring-opacity-5 md:pbx-rounded-lg" }, ET = { class: "pbx-overflow-x-auto" }, TT = { class: "pbx-w-max" }, OT = { class: "pbx-bg-white pbx-divide-y pbx-divide-gray-200" }, BT = { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-text-gray-500" }, PT = { class: "pbx-min-w-[30rem] pbx-w-max" }, AT = { key: 0 }, _T = { key: 1 }, LT = { key: 0 }, NT = { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-text-gray-500" }, DT = { class: "pbx-min-w-[30rem] pbx-w-max" }, IT = { class: "pbx-inline-flex pbx-items-center pbx-px-2.5 pbx-py-0.5 pbx-rounded-full pbx-text-xs pbx-font-medium" }, $T = { class: "pbx-mt-4 pbx-mb-4 pbx-py-8 pbx-px-2 pbx-border pbx-border-solid pbx-border-gray-600 pbx-rounded-xl" }, RT = { class: "pbx-mt-4 pbx-whitespace-pre-wrap pbx-text-white pbx-overflow-hidden pbx-bg-gray-900" }, FT = { class: "pbx-px-4 pbx-pb-8 pbx-pt-4 pbx-text-white pbx-text-xs pbx-break-all" }, HT = { class: "pbx-myPrimaryParagraph pbx-text-xs pbx-text-white" }, jT = {
__name: "PageBuilderSettings",
setup(n) {
const e = "3.4.9", t = Se, r = I(() => t.getPageBuilderConfig);
return (o, i) => {
var s, l, a, c, p, u, f, h, b, m, x, v, C, S, g, O;
return w(), E("div", uE, [
d("div", dE, [
d("div", null, [
i[26] || (i[26] = d("div", { class: "pbx-flex pbx-items-left pbx-flex-col pbx-gap-1" }, [
d("h3", { class: "pbx-myQuaternaryHeader" }, "Configuration Overview"),
d("p", { class: "pbx-myPrimaryParagraph pbx-text-xs" }, " A summary of current user preferences, application settings, and system metadata including UI theme, language, saved components, and logo configuration. ")
], -1)),
d("div", fE, [
d("div", hE, [
i[2] || (i[2] = d("h4", { class: "pbx-myQuaternaryHeader pbx-text-sm pbx-mb-2" }, "Version Information", -1)),
d("div", bE, [
d("div", mE, [
d("table", xE, [
i[1] || (i[1] = d("thead", { class: "pbx-bg-gray-50" }, [
d("tr", null, [
d("th", {
scope: "col",
class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-font-medium pbx-text-gray-500 pbx-uppercase pbx-tracking-wider"
}, " App "),
d("th", {
scope: "col",
class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-font-medium pbx-text-gray-500 pbx-uppercase pbx-tracking-wider"
}, " Version ")
])
], -1)),
d("tbody", gE, [
d("tr", null, [
i[0] || (i[0] = d("td", { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-font-medium pbx-text-gray-900" }, [
d("div", { class: "pbx-min-w-[30rem] pbx-w-max" }, "Page Builder")
], -1)),
d("td", yE, [
d("div", vE, [
d("span", wE, k(y(e)), 1)
])
])
])
])
])
])
])
]),
(s = r.value) != null && s.resourceData && !y(Tn)(r.value.resourceData) ? (w(), E("div", SE, [
i[6] || (i[6] = d("h4", { class: "pbx-myQuaternaryHeader pbx-text-sm pbx-mb-2" }, "Resource Data", -1)),
d("div", kE, [
d("div", CE, [
d("table", ME, [
i[5] || (i[5] = d("thead", { class: "pbx-bg-gray-50" }, [
d("tr", null, [
d("th", {
scope: "col",
class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-font-medium pbx-text-gray-500 pbx-uppercase pbx-tracking-wider"
}, " Property "),
d("th", {
scope: "col",
class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-font-medium pbx-text-gray-500 pbx-uppercase pbx-tracking-wider"
}, " Value ")
])
], -1)),
d("tbody", EE, [
(a = (l = r.value) == null ? void 0 : l.resourceData) != null && a.title ? (w(), E("tr", TE, [
i[3] || (i[3] = d("td", { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-font-medium pbx-text-gray-900" }, [
d("div", { class: "pbx-min-w-[30rem] pbx-w-max" }, "Title")
], -1)),
d("td", OE, [
d("div", BE, k(r.value.resourceData.title), 1)
])
])) : A("", !0),
(p = (c = r.value) == null ? void 0 : c.resourceData) != null && p.id ? (w(), E("tr", PE, [
i[4] || (i[4] = d("td", { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-font-medium pbx-text-gray-900" }, [
d("div", { class: "pbx-min-w-[30rem] pbx-w-max" }, "ID")
], -1)),
d("td", AE, [
d("div", _E, k(r.value.resourceData.id), 1)
])
])) : A("", !0)
])
])
])
])
])) : A("", !0),
(u = r.value) != null && u.userForPageBuilder && !y(Tn)(r.value.userForPageBuilder) ? (w(), E("div", LE, [
i[11] || (i[11] = d("h4", { class: "pbx-myQuaternaryHeader pbx-text-sm pbx-mb-2" }, "User Information", -1)),
d("div", NE, [
d("div", DE, [
d("table", IE, [
i[10] || (i[10] = d("thead", { class: "pbx-bg-gray-50" }, [
d("tr", null, [
d("th", {
scope: "col",
class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-font-medium pbx-text-gray-500 pbx-uppercase pbx-tracking-wider"
}, " Property "),
d("th", {
scope: "col",
class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-font-medium pbx-text-gray-500 pbx-uppercase pbx-tracking-wider"
}, " Value ")
])
], -1)),
d("tbody", $E, [
d("tr", null, [
i[7] || (i[7] = d("td", { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-font-medium pbx-text-gray-900" }, [
d("div", { class: "pbx-min-w-[30rem] pbx-w-max" }, "User Name")
], -1)),
d("td", RE, [
d("div", FE, k(r.value.userForPageBuilder.name), 1)
])
]),
d("tr", null, [
i[8] || (i[8] = d("td", { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-font-medium pbx-text-gray-900" }, [
d("div", { class: "pbx-min-w-[30rem] pbx-w-max" }, "Image")
], -1)),
r.value.userForPageBuilder.image && typeof r.value.userForPageBuilder.image == "string" && r.value.userForPageBuilder.image.length > 2 ? (w(), E("td", HE, [
d("div", jE, [
d("div", zE, [
d("img", {
class: "pbx-block pbx-inset-0 pbx-object-top pbx-h-10 pbx-min-h-10 pbx-max-h-10 pbx-w-10 pbx-min-w-10 pbx-max-w-10 pbx-object-cover pbx-rounded-full",
src: r.value.userForPageBuilder.image,
alt: "image"
}, null, 8, VE)
])
])
])) : A("", !0)
]),
d("tr", null, [
i[9] || (i[9] = d("td", { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-font-medium pbx-text-gray-900" }, [
d("div", { class: "pbx-min-w-[30rem] pbx-w-max" }, "Image URL")
], -1)),
r.value.userForPageBuilder.image && typeof r.value.userForPageBuilder.image == "string" && r.value.userForPageBuilder.image.length > 2 ? (w(), E("td", WE, [
d("div", UE, k(r.value.userForPageBuilder.image), 1)
])) : A("", !0)
])
])
])
])
])
])) : A("", !0),
(f = r.value) != null && f.userSettings && !y(Tn)(r.value.userSettings) ? (w(), E("div", qE, [
i[17] || (i[17] = d("h4", { class: "pbx-myQuaternaryHeader pbx-text-sm pbx-mb-2" }, "User Settings", -1)),
d("div", KE, [
d("div", GE, [
d("table", JE, [
i[16] || (i[16] = d("thead", { class: "pbx-bg-gray-50" }, [
d("tr", null, [
d("th", {
scope: "col",
class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-font-medium pbx-text-gray-500 pbx-uppercase pbx-tracking-wider"
}, " Setting "),
d("th", {
scope: "col",
class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-font-medium pbx-text-gray-500 pbx-uppercase pbx-tracking-wider"
}, " Value ")
])
], -1)),
d("tbody", YE, [
(b = (h = r.value) == null ? void 0 : h.userSettings) != null && b.theme ? (w(), E("tr", XE, [
i[12] || (i[12] = d("td", { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-font-medium pbx-text-gray-900" }, [
d("div", { class: "pbx-min-w-[30rem] pbx-w-max" }, "Theme")
], -1)),
d("td", QE, [
d("div", ZE, k(r.value.userSettings.theme), 1)
])
])) : A("", !0),
(x = (m = r.value) == null ? void 0 : m.userSettings) != null && x.language ? (w(), E("tr", eT, [
i[13] || (i[13] = d("td", { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-font-medium pbx-text-gray-900" }, [
d("div", { class: "pbx-min-w-[30rem] pbx-w-max" }, "Language")
], -1)),
d("td", tT, [
d("div", nT, k(r.value.userSettings.language), 1)
])
])) : A("", !0),
((C = (v = r.value) == null ? void 0 : v.userSettings) == null ? void 0 : C.autoSave) !== void 0 ? (w(), E("tr", rT, [
i[14] || (i[14] = d("td", { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-font-medium pbx-text-gray-900" }, [
d("div", { class: "pbx-min-w-[30rem] pbx-w-max" }, "Auto Save")
], -1)),
d("td", oT, [
d("div", iT, [
d("span", {
class: X([
"pbx-inline-flex pbx-items-center pbx-px-2.5 pbx-py-0.5 pbx-rounded-full pbx-text-xs pbx-font-medium",
r.value.userSettings.autoSave ? "bg-green-100 text-green-800" : "bg-red-100 text-red-800"
])
}, k(r.value.userSettings.autoSave ? "Enabled" : "Disabled"), 3)
])
])
])) : A("", !0),
((g = (S = r.value) == null ? void 0 : S.userSettings) == null ? void 0 : g.notifications) !== void 0 ? (w(), E("tr", sT, [
i[15] || (i[15] = d("td", { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-font-medium pbx-text-gray-900" }, [
d("div", { class: "pbx-min-w-[30rem] pbx-w-max" }, "Notifications")
], -1)),
d("td", lT, [
d("div", aT, [
d("span", {
class: X([
"pbx-inline-flex pbx-items-center pbx-px-2.5 pbx-py-0.5 pbx-rounded-full pbx-text-xs pbx-font-medium",
r.value.userSettings.notifications ? "bg-green-100 text-green-800" : "bg-red-100 text-red-800"
])
}, k(r.value.userSettings.notifications ? "Enabled" : "Disabled"), 3)
])
])
])) : A("", !0)
])
])
])
])
])) : A("", !0),
r.value && r.value.pageBuilderLogo && !y(Tn)(r.value.pageBuilderLogo) ? (w(), E("div", cT, [
i[21] || (i[21] = d("h4", { class: "pbx-myQuaternaryHeader pbx-text-sm pbx-mb-2" }, "Logo Configuration", -1)),
d("div", pT, [
d("div", uT, [
d("table", dT, [
i[20] || (i[20] = d("thead", { class: "pbx-bg-gray-50" }, [
d("tr", null, [
d("th", {
scope: "col",
class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-font-medium pbx-text-gray-500 pbx-uppercase pbx-tracking-wider"
}, " Property "),
d("th", {
scope: "col",
class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-font-medium pbx-text-gray-500 pbx-uppercase pbx-tracking-wider"
}, " Value ")
])
], -1)),
d("tbody", fT, [
d("tr", null, [
i[18] || (i[18] = d("td", { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-font-medium pbx-text-gray-900" }, [
d("div", { class: "pbx-min-w-[30rem] pbx-w-max" }, "Logo")
], -1)),
d("td", hT, [
d("div", bT, [
d("div", mT, [
d("img", {
class: "pbx-h-4",
src: r.value.pageBuilderLogo.src,
alt: "Logo"
}, null, 8, xT)
])
])
])
]),
d("tr", null, [
i[19] || (i[19] = d("td", { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-font-medium pbx-text-gray-900" }, [
d("div", { class: "pbx-min-w-[30rem] pbx-w-max" }, "Logo URL")
], -1)),
d("td", gT, [
d("div", yT, [
d("div", vT, [
d("div", wT, [
d("div", ST, [
d("span", kT, k(r.value.pageBuilderLogo.src), 1)
])
])
])
])
])
])
])
])
])
])
])) : A("", !0),
(O = r.value) != null && O.updateOrCreate && !y(Tn)(r.value.updateOrCreate) ? (w(), E("div", CT, [
i[25] || (i[25] = d("h4", { class: "pbx-myQuaternaryHeader pbx-text-sm pbx-mb-2" }, "Form Type", -1)),
d("div", MT, [
d("div", ET, [
d("table", TT, [
i[24] || (i[24] = d("thead", { class: "pbx-bg-gray-50" }, [
d("tr", null, [
d("th", {
scope: "col",
class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-font-medium pbx-text-gray-500 pbx-uppercase pbx-tracking-wider"
}, " Mode "),
d("th", {
scope: "col",
class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-font-medium pbx-text-gray-500 pbx-uppercase pbx-tracking-wider"
}, " Description ")
])
], -1)),
d("tbody", OT, [
d("tr", null, [
i[22] || (i[22] = d("td", { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-font-medium pbx-text-gray-900" }, [
d("div", { class: "pbx-min-w-[30rem] pbx-w-max" }, "Form Type")
], -1)),
d("td", BT, [
d("div", PT, [
d("span", {
class: X([
"pbx-inline-flex pbx-items-center pbx-px-2.5 pbx-py-0.5 pbx-rounded-full pbx-text-xs pbx-font-medium",
r.value.updateOrCreate === "create" ? "bg-green-100 text-green-800" : "bg-blue-100 text-blue-800"
])
}, [
r.value && r.value.updateOrCreate.formType === "create" ? (w(), E("span", AT, k(r.value.updateOrCreate.formType), 1)) : A("", !0),
r.value && r.value.updateOrCreate.formType === "update" ? (w(), E("span", _T, k(r.value.updateOrCreate.formType), 1)) : A("", !0)
], 2)
])
])
]),
r.value.updateOrCreate.formName && r.value.updateOrCreate.formName.length > 0 ? (w(), E("tr", LT, [
i[23] || (i[23] = d("td", { class: "pbx-px-6 pbx-py-4 pbx-whitespace-nowrap pbx-text-sm pbx-font-medium pbx-text-gray-900" }, [
d("div", { class: "pbx-min-w-[30rem] pbx-w-max" }, "Form Name")
], -1)),
d("td", NT, [
d("div", DT, [
d("span", IT, k(r.value.updateOrCreate.formName), 1)
])
])
])) : A("", !0)
])
])
])
])
])) : A("", !0)
])
])
]),
d("div", $T, [
i[28] || (i[28] = d("div", { class: "pbx-flex pbx-items-left pbx-flex-col pbx-gap-1" }, [
d("h3", { class: "pbx-myQuaternaryHeader" }, "Complete Configuration Overview"),
d("p", { class: "pbx-myPrimaryParagraph pbx-text-xs" }, " Complete configuration object currently used by the Page Builder. Includes user information, branding settings, and other context-specific data needed for rendering and managing the builder environment. ")
], -1)),
d("div", RT, [
i[27] || (i[27] = d("div", { class: "pbx-flex bg-gray-800/40 pbx-ring-1 ring-white/5" }, [
d("div", { class: "pbx-mb-px pbx-flex pbx-text-xs pbx-font-medium pbx-text-myPrimaryMediumGrayColor" }, [
d("div", { class: "pbx-px-4 pbx-py-4 pbx-text-white" }, "Configuration")
])
], -1)),
d("div", FT, [
d("p", HT, " config: " + k(JSON.stringify(r.value, null, 4)), 1)
])
])
])
]);
};
}
}, zT = { class: "pbx-w-full pbx-inset-x-0 pbx-h-[90vh] pbx-bg-white pbx-overflow-x-scroll lg:pbx-pt-2 pbx-pt-2" }, VT = { class: "pbx-flex pbx-items-left pbx-flex-col pbx-myPrimaryGap pbx-border-myPrimaryMediumGrayColor" }, WT = { class: "pbx-myPrimaryParagraph" }, UT = { class: "pbx-myPrimaryParagraph pbx-text-xs pbx-pb-2" }, qT = { class: "pbx-text-gray-100 pbx-overflow-hidden pbx-bg-gray-900" }, KT = { class: "pbx-flex pbx-bg-gray-900 pbx-ring-1 ring-white/5" }, GT = { class: "pbx-mb-px pbx-flex pbx-text-xs pbx-font-medium pbx-text-myPrimaryMediumGrayColor" }, JT = { class: "pbx-px-4 pbx-py-4 pbx-text-gray-100" }, YT = { class: "pbx-px-4 pbx-pb-8 pbx-pt-4 pbx-text-gray-100 pbx-text-xs" }, XT = { class: "pbx-text-xs pbx-pb-2" }, QT = { class: "pbx-text-xs pbx-pb-2" }, ZT = { class: "pbx-text-xs pbx-pb-2" }, eO = { class: "pbx-myPrimaryParagraph pbx-text-xs pbx-pb-2" }, tO = { class: "pbx-overflow-hidden pbx-bg-gray-900" }, nO = { class: "pbx-flex pbx-bg-gray-900 pbx-ring-1 ring-white/5" }, rO = { class: "pbx-mb-px pbx-flex pbx-text-xs pbx-font-medium pbx-text-myPrimaryMediumGrayColor" }, oO = { class: "pbx-px-4 pbx-pb-8 pbx-pt-4 pbx-text-gray-100 pbx-text-xs pbx-break-all" }, iO = { key: 0 }, sO = { key: 0 }, lO = { class: "pbx-pb-2 pbx-text-xs" }, aO = {
key: 1,
class: "pbx-overflow-hidden pbx-border-solid pbx-border pbx-border-gray-100 pbx-mb-6"
}, cO = { class: "pbx-border-0 pbx-bg-gray-900 pbx-pt-4 pbx-1 pbx-border-solid pbx-border-b pbx-border-gray-200" }, pO = { class: "pbx-overflow-x-auto" }, uO = { class: "pbx-min-w-full" }, dO = { class: "pbx-bg-gray-900" }, fO = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal" }, hO = { class: "pbx-bg-gray-900 pbx-divide-y pbx-divide-gray-200" }, bO = { class: "pbx-border-0 pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal pbx-border-solid pbx-border-b" }, mO = { class: "pbx-overflow-x-auto" }, xO = { class: "pbx-min-w-full" }, gO = { class: "pbx-bg-gray-900" }, yO = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal" }, vO = { class: "pbx-bg-gray-900 pbx-divide-y pbx-divide-gray-200" }, wO = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal pbx-whitespace-pre-line" }, SO = { class: "pbx-overflow-x-auto" }, kO = { class: "pbx-min-w-full" }, CO = { class: "pbx-bg-gray-900" }, MO = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal" }, EO = { class: "pbx-bg-gray-900 pbx-divide-y pbx-divide-gray-200" }, TO = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal" }, OO = { key: 1 }, BO = { key: 0 }, PO = { class: "pbx-pb-2 pbx-text-xs" }, AO = {
key: 1,
class: "pbx-overflow-hidden pbx-border-solid pbx-border pbx-border-gray-100 pbx-mb-6"
}, _O = { class: "pbx-border-0 pbx-bg-gray-900 pbx-pt-4 pbx-1 pbx-border-solid pbx-border-b pbx-border-gray-200" }, LO = { class: "pbx-overflow-x-auto" }, NO = { class: "pbx-min-w-full" }, DO = { class: "pbx-bg-gray-900" }, IO = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal" }, $O = { class: "pbx-bg-gray-900 pbx-divide-y pbx-divide-gray-200" }, RO = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal" }, FO = { class: "pbx-overflow-x-auto" }, HO = { class: "pbx-min-w-full" }, jO = { class: "pbx-bg-gray-900" }, zO = { class: "pbx-border-0 pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal pbx-border-solid pbx-border-t pbx-border-gray-200" }, VO = { class: "pbx-bg-gray-900 pbx-divide-y pbx-divide-gray-200" }, WO = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal pbx-whitespace-pre-line" }, UO = { class: "pbx-overflow-x-auto" }, qO = { class: "pbx-min-w-full" }, KO = { class: "pbx-bg-gray-900" }, GO = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal" }, JO = { class: "pbx-bg-gray-900 pbx-divide-y pbx-divide-gray-200" }, YO = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal" }, XO = { class: "pbx-text-xs pbx-text-gray-100 pbx-whitespace-pre-wrap pbx-font-sans pbx-flex pbx-items-start pbx-justify-left" }, QO = ["innerHTML"], ZO = { key: 2 }, eB = { key: 0 }, tB = { class: "pbx-pb-2 pbx-text-xs" }, nB = { key: 1 }, rB = { class: "pbx-border-0 pbx-bg-gray-900 pbx-pt-4 pbx-1 pbx-border-solid pbx-border-b pbx-border-gray-200" }, oB = { class: "pbx-overflow-x-auto" }, iB = { class: "pbx-min-w-full" }, sB = { class: "pbx-bg-gray-900" }, lB = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal" }, aB = { class: "pbx-bg-gray-900 pbx-divide-y pbx-divide-gray-200" }, cB = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal" }, pB = { class: "pbx-overflow-x-auto" }, uB = { class: "pbx-min-w-full" }, dB = { class: "pbx-bg-gray-900" }, fB = { class: "pbx-border-0 pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal pbx-border-solid pbx-border-t pbx-border-gray-200" }, hB = { class: "pbx-bg-gray-900 pbx-divide-y pbx-divide-gray-200" }, bB = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal pbx-whitespace-pre-line" }, mB = { class: "pbx-overflow-x-auto" }, xB = { class: "pbx-min-w-full" }, gB = { class: "pbx-bg-gray-900" }, yB = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal" }, vB = { class: "pbx-bg-gray-900 pbx-divide-y pbx-divide-gray-200" }, wB = { class: "pbx-px-6 pbx-py-3 pbx-text-left pbx-text-xs pbx-text-gray-100 pbx-font-normal" }, SB = { class: "pbx-text-xs pbx-text-gray-100 pbx-whitespace-pre-wrap pbx-font-sans pbx-flex pbx-items-start pbx-justify-left" }, kB = ["innerHTML"], CB = {
__name: "AdvancedPageBuilderSettings",
setup(n) {
const { translate: e } = Me(), t = Se, r = I(() => t.getElement), o = I(() => t.getComponent), i = I(() => t.getComponents), s = M("element"), l = function(c) {
s.value = c;
};
function a(c) {
if (!c) return "";
const p = " ";
let u = 0, f = "";
const b = c.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """).replace(/'/g, "'").split(/(<[^>]+>)/g), m = [
"<area",
"<base",
"<br",
"<col",
"<embed",
"<hr",
"<img",
"<input",
"<link",
"<meta",
"<param",
"<source",
"<track",
"<wbr"
];
return b.forEach((x) => {
const v = x.trim();
if (!v) return;
const C = v.startsWith("<") && v.endsWith(">"), S = C && v.startsWith("</");
S && (u = Math.max(0, u - 1));
let g = p.repeat(u) + v;
C && (g = g.replace(/(<\/?[[\w\s="/.':;#-\/\?]+>)/g, (O) => {
var F;
const T = (F = O.match(/<\/?([\w-]+)/)) == null ? void 0 : F[1];
let B = O.replace(
/(<\/?[\w-]+)/g,
`<span class="html-tag-symbol"><</span><span class="html-tag-name">${T}</span>`
);
return B = B.replace(
/([\w-]+)=("[^"]*")/g,
'<span class="html-attribute-name">$1</span><span class="html-operator">=</span><span class="html-attribute-value">$2</span>'
), B + '<span class="html-tag-symbol">></span>';
})), f += g + `
`, C && !S && (v.endsWith("/>") || m.some((T) => v.startsWith(T)) || u++);
}), f;
}
return (c, p) => {
var u, f, h, b, m, x, v, C, S, g;
return w(), E("div", zT, [
d("div", VT, [
d("p", WT, k(y(e)(
"Overview of Selected Element, Component, and Components. This section provides real-time updates based on your HTML selection."
)), 1),
d("div", null, [
d("h4", UT, k(y(e)("Types")), 1),
d("div", qT, [
d("div", KT, [
d("div", GT, [
d("div", JT, k(y(e)("Types")), 1)
])
]),
d("div", YT, [
d("p", XT, [
d("span", null, k(y(e)("Element type:")), 1),
d("span", null, k(typeof r.value), 1)
]),
d("p", QT, [
d("span", null, k(y(e)("Component type:")), 1),
we(" " + k(typeof o.value), 1)
]),
d("p", ZT, [
d("span", null, k(y(e)("Components:")), 1),
d("span", null, k(Array.isArray(i.value) === !0 ? y(e)("array") : typeof i.value), 1)
])
])
])
]),
d("div", null, [
d("h4", eO, k(y(e)("Content")), 1),
d("div", tO, [
d("div", nO, [
d("div", rO, [
d("div", {
onClick: p[0] || (p[0] = (O) => l("element")),
class: X(["pbx-px-4 pbx-py-4 pbx-cursor-pointer", [s.value === "element" ? "pbx-text-gray-100" : ""]])
}, k(y(e)("Element")), 3),
d("div", {
onClick: p[1] || (p[1] = (O) => l("component")),
class: X(["pbx-px-4 pbx-py-4 pbx-cursor-pointer", [s.value === "component" ? "pbx-text-gray-100" : ""]])
}, k(y(e)("Component")), 3),
d("div", {
onClick: p[2] || (p[2] = (O) => l("components")),
class: X(["pbx-px-4 pbx-py-4 pbx-cursor-pointer", [s.value === "components" ? "pbx-text-gray-100" : ""]])
}, k(y(e)("Components added")) + " " + k(Array.isArray(i.value) && i.value.length), 3)
])
]),
d("div", oO, [
s.value === "element" ? (w(), E("div", iO, [
o.value ? A("", !0) : (w(), E("div", sO, [
d("p", lO, k(o.value === null ? y(e)("No Element selected") : typeof o.value), 1)
])),
r.value ? (w(), E("div", aO, [
d("div", cO, [
d("div", pO, [
d("table", uO, [
d("thead", dO, [
d("tr", null, [
d("th", fO, k(y(e)("Selected HTML:")), 1)
])
]),
d("tbody", hO, [
d("tr", null, [
d("td", bO, k((u = r.value) == null ? void 0 : u.outerHTML), 1)
])
])
])
]),
d("div", mO, [
d("table", xO, [
d("thead", gO, [
d("tr", null, [
d("th", yO, k(y(e)("Element src:")), 1)
])
]),
d("tbody", vO, [
d("tr", null, [
d("td", wO, k((f = r.value) != null && f.src ? (h = r.value) == null ? void 0 : h.src : typeof ((b = r.value) == null ? void 0 : b.src)), 1)
])
])
])
])
]),
d("div", SO, [
d("table", kO, [
d("thead", CO, [
d("tr", null, [
d("th", MO, k(y(e)("Element classes:")), 1)
])
]),
d("tbody", EO, [
d("tr", null, [
d("td", TO, k((m = r.value) != null && m.classList ? (x = r.value) == null ? void 0 : x.classList : typeof ((v = r.value) == null ? void 0 : v.classList)), 1)
])
])
])
])
])) : A("", !0)
])) : A("", !0),
s.value === "component" ? (w(), E("div", OO, [
o.value ? A("", !0) : (w(), E("div", BO, [
d("p", PO, k(o.value === null ? y(e)("No Component selected") : typeof o.value), 1)
])),
o.value ? (w(), E("div", AO, [
d("div", _O, [
d("div", LO, [
d("table", NO, [
d("thead", DO, [
d("tr", null, [
d("th", IO, k(y(e)("ID:")), 1)
])
]),
d("tbody", $O, [
d("tr", null, [
d("td", RO, k((C = o.value) == null ? void 0 : C.id), 1)
])
])
])
]),
d("div", FO, [
d("table", HO, [
d("thead", jO, [
d("tr", null, [
d("th", zO, k(y(e)("Title:")), 1)
])
]),
d("tbody", VO, [
d("tr", null, [
d("td", WO, k((S = o.value) == null ? void 0 : S.title), 1)
])
])
])
])
]),
d("div", UO, [
d("table", qO, [
d("thead", KO, [
d("tr", null, [
d("th", GO, k(y(e)("HTML Code:")), 1)
])
]),
d("tbody", JO, [
d("tr", null, [
d("td", YO, [
d("pre", XO, [
p[3] || (p[3] = we(" ")),
d("code", {
class: "pbx-font-sans pbx-bg-gray-800 pbx-p-4 pbx-rounded-md pbx-block pbx-w-full",
innerHTML: a((g = o.value) == null ? void 0 : g.html_code)
}, null, 8, QO),
p[4] || (p[4] = we(`
`))
])
])
])
])
])
])
])) : A("", !0)
])) : A("", !0),
s.value === "components" ? (w(), E("div", ZO, [
Array.isArray(i.value) && i.value.length === 0 ? (w(), E("div", eB, [
d("p", tB, k(y(e)("No Components added yet")), 1)
])) : A("", !0),
i.value ? (w(), E("div", nB, [
(w(!0), E(Z, null, fe(i.value, (O) => (w(), E("div", {
key: O.id,
class: "pbx-overflow-hidden pbx-border-solid pbx-border pbx-border-gray-100 pbx-mb-6"
}, [
d("div", rB, [
d("div", oB, [
d("table", iB, [
d("thead", sB, [
d("tr", null, [
d("th", lB, k(y(e)("ID:")), 1)
])
]),
d("tbody", aB, [
d("tr", null, [
d("td", cB, k(O.id), 1)
])
])
])
]),
d("div", pB, [
d("table", uB, [
d("thead", dB, [
d("tr", null, [
d("th", fB, k(y(e)("Title:")), 1)
])
]),
d("tbody", hB, [
d("tr", null, [
d("td", bB, k(O.title), 1)
])
])
])
])
]),
d("div", mB, [
d("table", xB, [
d("thead", gB, [
d("tr", null, [
d("th", yB, k(y(e)("HTML Code:")), 1)
])
]),
d("tbody", vB, [
d("tr", null, [
d("td", wB, [
d("pre", SB, [
p[5] || (p[5] = we(" ")),
d("code", {
class: "pbx-font-sans pbx-w-full",
innerHTML: a(O.html_code)
}, null, 8, kB),
p[6] || (p[6] = we(`
`))
])
])
])
])
])
])
]))), 128))
])) : A("", !0)
])) : A("", !0)
])
])
])
])
]);
};
}
}, MB = { class: "pbx-flex pbx-items-center pbx-justify-center" }, EB = { class: "pbx-mr-2" }, TB = {
key: 0,
class: "pbx-flex pbx-items-center pbx-myPrimaryTag pbx-whitespace-nowrap pbx-py-0 pbx-gap-2"
}, OB = { class: "pbx-text-white pbx-rounded-full pbx-bg-myPrimaryBrandColor pbx-flex pbx-justify-center pbx-items-center pbx-text-xs pbx-d pbx-min-d pbx-max-d lg:pbx-w-8 lg:pbx-h-8 lg:pbx-min-w-8 lg:pbx-max-w-8 pbx-w-8 pbx-h-8 pbx-min-w-8 pbx-max-w-8 pbx-font-normal" }, BB = { class: "pbx-hidden pbx-text-xs pbx-d lg:pbx-flex pbx-items-center pbx-font-normal pbx-w-max pbx-break-keep" }, PB = {
key: 1,
class: "pbx-flex pbx-items-center lg:pbx-myPrimaryTag pbx-whitespace-nowrap pbx-py-0 pbx-gap-4 pbx-w-max pbx-h-12 pbx-ml-2"
}, AB = { class: "pbx-text-white pbx-flex-shrink-0 pbx-d pbx-w-10 pbx-h-10 pbx-rounded-full pbx-flex pbx-justify-center pbx-items-center pbx-text-xs pbx-rounded-l-full" }, _B = ["src"], LB = { class: "pbx-hidden pbx-text-xs pbx-d lg:pbx-flex pbx-items-center pbx-font-normal pbx-w-max pbx-break-keep" }, NB = { class: "pbx-hidden lg:pbx-block" }, DB = { class: "pbx-relative pbx-group" }, IB = {
type: "button",
class: "pbx-mySecondaryButton pbx-font-normal pbx-text-xs"
}, $B = { class: "pbx-absolute pbx-left-0 -pbx-ml-16 -pbx-mt-2 pbx-flex pbx-flex-col pbx-gap-3 pbx-shadow-lg pbx-bg-white pbx-w-max pbx-border-solid pbx-border pbx-border-gray-100 pbx-rounded-2xl pbx-transition-all pbx-duration-200 pbx-ease-out pbx-pt-4 pbx-pr-4 pbx-pb-4 pbx-pl-2 pbx-z-30 pbx-opacity-0 pbx-pointer-events-none pbx-translate-y-2 group-hover:pbx-opacity-100 group-hover:pbx-pointer-events-auto group-hover:pbx-translate-y-0" }, RB = {
__name: "ToolbarOption",
setup(n) {
const { translate: e } = Me(), t = Ce(), r = Se, o = I(() => r.getPageBuilderConfig), i = M(!1), s = M(!1), l = M(""), a = M(1), c = M(""), p = M(""), u = M(""), f = M(null), h = M(null), b = M(null), m = M(null), x = M(null), v = function() {
s.value = !0, l.value = "delete", a.value = 2, c.value = e("Remove all Components"), p.value = e("Are you sure you want to remove all Components?"), u.value = e("Close"), f.value = null, h.value = e("Delete"), b.value = function() {
s.value = !1;
}, x.value = async function() {
i.value = !0, await t.clearHtmlSelection(), await t.handleFormSubmission(), await Pe(500), s.value = !1, i.value = !1;
};
}, C = M(!1), S = function() {
C.value = !1;
}, g = function() {
C.value = !0;
}, O = M(!1), T = function() {
O.value = !1;
}, B = function() {
O.value = !0;
};
return (F, W) => {
var L;
return w(), E("div", null, [
d("div", MB, [
d("div", EB, [
o.value && o.value.userForPageBuilder && o.value.userForPageBuilder.name && (!o.value.userForPageBuilder.image || typeof o.value.userForPageBuilder.image == "string" && ((L = o.value.userForPageBuilder.image) == null ? void 0 : L.length) < 2) ? (w(), E("div", TB, [
d("div", OB, k(typeof o.value.userForPageBuilder.name == "string" && o.value.userForPageBuilder.name[0]), 1),
d("div", BB, k(o.value.userForPageBuilder.name), 1)
])) : A("", !0),
o.value && o.value.userForPageBuilder && o.value.userForPageBuilder.name && o.value.userForPageBuilder.image && typeof o.value.userForPageBuilder.image == "string" && o.value.userForPageBuilder.image.length > 2 ? (w(), E("div", PB, [
d("div", AB, [
d("img", {
alt: "Avatar",
src: `${o.value.userForPageBuilder.image}`,
class: "pbx-block pbx-inset-0 pbx-object-top pbx-d pbx-min-d pbx-max-d lg:pbx-w-8 lg:pbx-h-8 lg:pbx-min-w-8 lg:pbx-max-w-8 pbx-w-8 pbx-h-8 pbx-min-w-8 pbx-max-w-8 pbx-object-cover pbx-rounded-full"
}, null, 8, _B)
]),
d("div", LB, k(o.value.userForPageBuilder.name), 1)
])) : A("", !0)
]),
d("div", NB, [
d("div", DB, [
d("button", IB, [
d("span", null, k(y(e)("Options")), 1)
]),
d("div", $B, [
d("button", {
onClick: W[0] || (W[0] = async () => {
await y(t).clearHtmlSelection(), g();
}),
class: "pbx-mySecondaryButton pbx-text-xs pbx-font-normal",
type: "button"
}, k(y(e)("Config Overview")), 1),
d("button", {
onClick: B,
class: "pbx-mySecondaryButton pbx-text-xs pbx-font-normal",
type: "button"
}, k(y(e)("HTML Overview")), 1),
d("button", {
onClick: v,
class: "pbx-myPrimaryDeleteButton pbx-text-xs pbx-font-normal",
type: "button"
}, k(y(e)("Delete Layout")), 1)
])
])
])
]),
j(Vt, {
maxWidth: "5xl",
showModalBuilder: C.value,
title: "Main Settings",
onCloseMainModalBuilder: S,
minHeight: "",
maxHeight: ""
}, {
default: V(() => [
j(jT)
]),
_: 1
}, 8, ["showModalBuilder"]),
j(Vt, {
maxWidth: "5xl",
showModalBuilder: O.value,
title: y(e)("Selected HTML"),
onCloseMainModalBuilder: T,
minHeight: "",
maxHeight: ""
}, {
default: V(() => [
j(CB)
]),
_: 1
}, 8, ["showModalBuilder", "title"]),
j(yr, {
showDynamicModalBuilder: s.value,
type: l.value,
gridColumnAmount: a.value,
title: c.value,
description: p.value,
isLoading: i.value,
firstButtonText: u.value,
secondButtonText: f.value,
thirdButtonText: h.value,
onFirstModalButtonFunctionDynamicModalBuilder: b.value,
onSecondModalButtonFunctionDynamicModalBuilder: m.value,
onThirdModalButtonFunctionDynamicModalBuilder: x.value
}, {
default: V(() => W[1] || (W[1] = [
d("header", null, null, -1),
d("main", null, null, -1)
])),
_: 1,
__: [1]
}, 8, ["showDynamicModalBuilder", "type", "gridColumnAmount", "title", "description", "isLoading", "firstButtonText", "secondButtonText", "thirdButtonText", "onFirstModalButtonFunctionDynamicModalBuilder", "onSecondModalButtonFunctionDynamicModalBuilder", "onThirdModalButtonFunctionDynamicModalBuilder"])
]);
};
}
};
let Ll = null;
function FB() {
return (n, e = 300) => {
Ll && clearTimeout(Ll), Ll = setTimeout(n, e);
};
}
const HB = {}, jB = { class: "pbx-bg-white pbx-flex pbx-justify-center pbx-items-center min-pbx-h-screen pbx-h-screen pbx-w-screen pbx-fixed pbx-inset-0 pbx-z-[10000]" };
function zB(n, e) {
return w(), E("div", jB, e[0] || (e[0] = [
d("div", { class: "pbx-absolute pbx-top-1/3" }, [
d("div", { class: "pbx-flex pbx-items-center pbx-justify-center pbx-mt-4" }, [
d("div", { class: "pbx-inline-block pbx-h-8 pbx-w-8 pbx-animate-spin pbx-rounded-full pbx-border-4 pbx-border-solid pbx-border-current pbx-border-r-transparent pbx-align-[-0.125em] motion-reduce:pbx-animate-[spin_1.5s_linear_infinite]" }, [
d("span", { class: "!pbx-absolute !pbx-m-px !pbx-h-px !pbx-w-px !pbx-overflow-hidden !pbx-whitespace-nowrap !pbx-border-0 !pbx-p-0 !pbx-[clip:rect(0,0,0,0)]" }, "Loading...")
])
])
], -1)
]));
}
const Bh = /* @__PURE__ */ Gs(HB, [["render", zB]]), VB = { class: "pbx-text-xs pbx-text-gray-600 pbx-mx-2 pbx-py-3 pbx-px-2 pbx-border-solid pbx-border pbx-border-gray-200 pbx-rounded-full" }, WB = /* @__PURE__ */ Qe({
__name: "UndoRedo",
emits: ["toolbar-hide-request"],
setup(n, { emit: e }) {
const t = Ce(), r = e, o = Se, i = I(() => o.getIsLoadingGlobal), s = I(() => o.getHistoryIndex), l = I(() => o.getHistoryLength), a = I(() => s.value > 0), c = I(() => s.value < l.value - 1), p = async function() {
a.value && (r("toolbar-hide-request"), await t.undo(), await t.clearHtmlSelection());
}, u = async function() {
c.value && (r("toolbar-hide-request"), await t.redo(), await t.clearHtmlSelection());
};
return (f, h) => (w(), E(Z, null, [
i.value ? (w(), pe(Bh, { key: 0 })) : A("", !0),
d("div", {
onClick: h[0] || (h[0] = async () => {
await y(t).clearHtmlSelection();
}),
class: "pbx-flex-1 pbx-flex pbx-justify-center pbx-items-center pbx-py-2 pbx-w-full gap-1"
}, [
d("div", {
onClick: p,
type: "button",
class: X(["pbx-h-10 pbx-w-10 pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-50 pbx-aspect-square pbx-text-black hover:pbx-text-white", [
a.value ? "pbx-cursor-pointer hover:pbx-bg-myPrimaryLinkColor focus-visible:pbx-ring-0" : "pbx-cursor-not-allowed pbx-bg-opacity-20 hover:pbx-bg-gray-200"
]])
}, h[1] || (h[1] = [
d("span", { class: "material-symbols-outlined" }, " undo ", -1)
]), 2),
d("div", VB, k(s.value + 1) + "/" + k(l.value), 1),
d("div", {
onClick: u,
class: X(["pbx-h-10 pbx-w-10 pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-50 pbx-aspect-square pbx-text-black hover:pbx-text-white", [
c.value ? "pbx-cursor-pointer hover:pbx-bg-myPrimaryLinkColor focus-visible:pbx-ring-0" : "pbx-cursor-not-allowed pbx-bg-opacity-20 hover:pbx-bg-gray-200"
]])
}, h[2] || (h[2] = [
d("span", { class: "material-symbols-outlined" }, " redo ", -1)
]), 2)
])
], 64));
}
}), UB = { class: "lg:pbx-min-w-full lg:pbx-max-w-full lg:pbx-w-full pbx-mx-auto pbx-flex pbx-flex-col pbx-font-sans pbx-text-black pbx-border-solid pbx-border pbx-border-gray-400 pbx-inset-x-0 pbx-z-10 pbx-bg-white pbx-overflow-x-auto pbx-h-full" }, qB = {
id: "pagebuilder-navbar",
class: "lg:pbx-min-w-full lg:pbx-max-w-full lg:pbx-w-full pbx-min-w-[64rem] pbx-max-w-[64rem] pbx-w-[64rem] pbx-flex-1 pbx-bg-myPrimaryLightGrayColor pbx-flex pbx-items-center pbx-justify-between pbx-border-0 pbx-border-solid pbx-border-b pbx-border-gray-200 pbx-mb-2 pbx-font-sans pbx-min-h-20"
}, KB = ["src"], GB = { class: "pbx-flex pbx-items-center pbx-justify-center" }, JB = ["disabled"], YB = {
key: 0,
class: "pbx-h-10 pbx-w-4 pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-justify-center"
}, XB = {
key: 1,
class: "pbx-h-10 pbx-w-4 pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-justify-center"
}, QB = ["disabled"], ZB = {
key: 0,
class: "pbx-h-10 pbx-w-4 pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-justify-center"
}, eP = {
key: 1,
class: "pbx-h-10 pbx-w-4 pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-justify-center"
}, tP = { class: "lg:pbx-block pbx-hidden" }, nP = { class: "lg:pbx-hidden pbx-block" }, rP = { class: "pbx-flex pbx-items-center pbx-justify-center pbx-gap-2 pbx-border-gray-200" }, oP = { class: "lg:pbx-block pbx-hidden" }, iP = { class: "pbx-whitespace-nowrap pbx-cursor-pointer" }, sP = { class: "pbx-flex pbx-items-center pbx-justify-center pbx-mr-2" }, lP = { class: "lg:pbx-flex pbx-hidden pbx-items-center pbx-justify-center" }, aP = { class: "pbx-flex-1 pbx-flex gap-2 pbx-items-center pbx-justify-end" }, cP = {
key: 0,
class: "pbx-flex-1 pbx-ml-2"
}, pP = {
key: 0,
class: "pbx-flex-1 pbx-flex pbx-justify-end pbx-items-center pbx-ml-2 lg:pbx-mr-4 pbx-mr-2"
}, uP = ["value"], dP = ["value"], fP = {
key: 2,
class: "pbx-flex-1 pbx-ml-2 pbx-mr-2"
}, hP = {
id: "pagebuilder-main",
class: "lg:pbx-min-w-full lg:pbx-max-w-full lg:pbx-w-full pbx-min-w-[64rem] pbx-max-w-[64rem] pbx-w-[64rem] pbx-flex-1 pbx-relative pbx-h-full pbx-flex pbx-pb-2 pbx-gap-2"
}, bP = { class: "pbx-mx-2 pbx-flex pbx-flex-col pbx-myPrimaryGap pbx-items-stretch" }, mP = { class: "pbx-flex pbx-gap-2 pbx-items-center pbx-justify-center" }, xP = {
id: "pbxEditToolbar",
class: "pbx-z-30 lg:pbx-mx-20 pbx-flex pbx-gap-2 pbx-justify-center pbx-items-center pbx-rounded pbx-px-4 pbx-bg-red-200 pbx-h-0"
}, gP = {
id: "pagebuilder",
class: "pbx-text-black pbx-font-sans"
}, yP = ["innerHTML", "onMouseup"], vP = {
id: "pagebuilder-footer",
class: "lg:pbx-min-w-full lg:pbx-max-w-full lg:pbx-w-full pbx-min-w-[64rem] pbx-max-w-[64rem] pbx-w-[64rem] pbx-flex-1 pbx-flex pbx-items-center pbx-justify-center pbx-border-0 pbx-border-t pbx-border-t-gray-200 pbx-border-solid pbx-bg-myPrimaryLightGrayColor pbx-py-4"
}, wP = { class: "lg:pbx-block pbx-hidden" }, SP = { class: "pbx-whitespace-nowrap" }, TP = {
__name: "PageBuilder",
props: {
CustomMediaLibraryComponent: {
type: Object,
default: null
},
CustomBuilderComponents: {
type: Object,
default: null
},
showCloseButton: {
type: Boolean,
default: !1
},
showPublishButton: {
type: Boolean,
default: !1
}
},
emits: ["handleClosePageBuilder", "handlePublishPageBuilder"],
setup(n, { emit: e }) {
const t = Ce(), r = n, { translate: o, loadTranslations: i } = Me(), s = bh, l = Se;
En("pageBuilderStateStore", l), En("internalPinia", s), En("CustomMediaComponent", r.CustomMediaLibraryComponent), En("CustomBuilderComponents", r.CustomBuilderComponents);
const a = e, c = function() {
a("handleClosePageBuilder");
}, p = async function() {
l.setIsLoadingGlobal(!0), await t.handleManualSave(), l.setIsLoadingGlobal(!1), a("handlePublishPageBuilder");
};
En("closeAddComponentModal", () => {
ae.value = !1;
});
const f = M("en");
let h = !0;
const b = M(!1);
ee(f, async (H) => {
if (H && !h) {
b.value = !0, await Pe(200), await i(H), t.changeLanguage(H);
const _ = JSON.parse(localStorage.getItem("userSettingsPageBuilder")) || {};
_.lang = H, localStorage.setItem("userSettingsPageBuilder", JSON.stringify(_)), b.value = !1;
}
});
const m = I(() => l.getBuilderStarted), x = I(() => l.getPageBuilderConfig), v = I(() => l.getMenuRight), C = M(!1), S = M(""), g = M(""), O = function() {
t.previewCurrentDesign();
}, T = function() {
S.value = o("Preview"), O(), C.value = !0;
}, B = M(!1), F = function() {
t.previewCurrentDesign();
}, W = function() {
g.value = o("Mobile"), F(), B.value = !0;
}, L = M(!1), N = function() {
L.value = !1;
}, $ = function() {
C.value = !1;
}, K = function() {
B.value = !1;
}, ae = M(!1), he = M(""), ue = M(""), ie = M(null), G = async function() {
await t.clearHtmlSelection(), he.value = o("Add Components to Page"), ue.value = o("Close"), ae.value = !0, ie.value = function() {
ae.value = !1;
};
}, re = I(() => l.getElement), ut = I(() => l.getComponents), Jt = I(() => l.getHasLocalDraftForUpdate);
ee(Jt, (H) => {
H && Ot();
});
const dt = I(() => !re.value || !(re.value instanceof HTMLElement) ? "" : {
src: re.value.getAttribute("src"),
href: re.value.getAttribute("href"),
style: re.value.getAttribute("style"),
class: re.value.getAttribute("class"),
dataImage: re.value.getAttribute("data-image")
}), Yt = FB();
ee(dt, async (H, _) => {
((H == null ? void 0 : H.src) !== (_ == null ? void 0 : _.src) || (H == null ? void 0 : H.href) !== (_ == null ? void 0 : _.href) || (H == null ? void 0 : H.style) !== (_ == null ? void 0 : _.style) || (H == null ? void 0 : H.class) !== (_ == null ? void 0 : _.class) || (H == null ? void 0 : H.dataImage) !== (_ == null ? void 0 : _.dataImage)) && Yt(async () => {
await t.initializeElementStyles();
}, 200);
});
const Mt = function(H) {
l.setComponent(H);
}, it = I(() => l.getIsLoadingGlobal), st = I(() => l.getIsSaving), fn = I(() => l.getIsLoadingResumeEditing), et = I(() => l.getIsRestoring), hn = M(1), Et = M(""), Tt = M(!1), Gn = M(""), bn = M(""), Jn = M(""), Yn = M(null), mn = M(null), xn = M(null), Xn = M(null), Qn = M(null), Ot = async function() {
Et.value = "warning", Tt.value = !0, Gn.value = o("Continue Your Work?"), bn.value = o(
"We noticed you have some changes that weren’t saved last time. Would you like to pick up where you left off, or use the version that’s currently loaded from the database?"
), Jn.value = o("Use Saved Version"), Yn.value = null, mn.value = o("Continue Where I Left Off"), xn.value = async function() {
l.setHasLocalDraftForUpdate(!1), Tt.value = !1;
}, Xn.value = function() {
}, Qn.value = async function() {
await t.resumeEditingFromDraft(), l.setHasLocalDraftForUpdate(!1), Tt.value = !1;
};
}, It = M(1), gn = M(""), ft = M(!1), yn = M(""), Zn = M(""), er = M(""), tr = M(null), nr = M(null), ai = M(null), ci = M(null), pi = M(null), Ys = async function() {
await t.clearHtmlSelection(), gn.value = "success", ft.value = !0, yn.value = o("Do you want to reset this page?"), Zn.value = o(
"Are you sure you want to reset this page? This will overwrite your current changes."
), er.value = o("Close"), tr.value = null, nr.value = o("Reset changes"), ai.value = function() {
ft.value = !1;
}, ci.value = async function() {
}, pi.value = async function() {
await t.restoreOriginalContent(), ft.value = !1;
};
}, ao = function() {
m.value || (L.value = !0);
}, P = M(null), q = function() {
const H = document.querySelector("#pbxEditToolbar");
H && (H.classList.remove("is-visible"), H.removeAttribute("style"));
};
function Y() {
const H = P.value, _ = H && H.querySelector("#pbxEditToolbar");
if (!H || !_) return;
const le = H.querySelector("[selected]");
if (le && typeof le.getBoundingClientRect == "function") {
const Bt = le.getBoundingClientRect(), co = H.getBoundingClientRect(), Xt = Bt.left - co.left + Bt.width / 2 - _.offsetWidth / 2, Br = Bt.top - co.top + H.scrollTop - _.offsetHeight - 20, vn = Math.max(0, Br);
_.style.position = "absolute", _.style.left = `${Xt}px`, _.style.top = `${vn}px`, _.classList.add("is-visible");
} else
_.classList.remove("is-visible"), _.removeAttribute("style");
}
const se = JSON.parse(localStorage.getItem("userSettingsPageBuilder"));
return pn(async () => {
await t.completeBuilderInitialization(void 0, !0), se && se.lang && (f.value = se.lang), x.value && x.value.userSettings && x.value.userSettings.language && x.value.userSettings.language.default && (!se || !se.lang) && (f.value = x.value.userSettings.language.default), await i(f.value), h = !1, Y();
const H = P.value;
if (!H) return;
new MutationObserver(Y).observe(H, {
childList: !0,
subtree: !0,
attributes: !0,
attributeFilter: ["selected"]
}), window.addEventListener("scroll", Y), window.addEventListener("resize", Y), await Pe(1e4), ao(), await Pe(1e4), ao(), await Pe(1e4), ao();
}), (H, _) => (w(), E("div", UB, [
it.value && !L.value || b.value ? (w(), pe(Bh, { key: 0 })) : A("", !0),
j(Vt, {
title: "The builder hasn’t started yet",
showModalBuilder: L.value,
onCloseMainModalBuilder: N,
type: "delete",
maxWidth: "2xl",
noBackgroundOpacity: !0
}, {
default: V(() => _[21] || (_[21] = [
we(" The builder hasn’t started yet. If this screen doesn’t go away soon, it may just need a little setup in the background. You can safely contact support and ask them to initialize the builder by running the startBuilder method for this resource. ")
])),
_: 1,
__: [21]
}, 8, ["showModalBuilder"]),
ae.value ? (w(), pe(iC, {
key: 1,
show: ae.value,
firstButtonText: ue.value,
title: he.value,
CustomBuilderComponents: r.CustomBuilderComponents,
onFirstModalButtonSearchComponentsFunction: ie.value
}, null, 8, ["show", "firstButtonText", "title", "CustomBuilderComponents", "onFirstModalButtonSearchComponentsFunction"])) : A("", !0),
j(Vt, {
title: S.value,
showModalBuilder: C.value,
onCloseMainModalBuilder: $,
maxWidth: "screen"
}, {
default: V(() => [
j(vc)
]),
_: 1
}, 8, ["title", "showModalBuilder"]),
j(Vt, {
title: g.value,
showModalBuilder: B.value,
onCloseMainModalBuilder: K,
maxWidth: "lg"
}, {
default: V(() => [
j(vc, { mobile: !0 })
]),
_: 1
}, 8, ["title", "showModalBuilder"]),
j(yr, {
showDynamicModalBuilder: Tt.value,
isLoading: fn.value,
type: Et.value,
gridColumnAmount: hn.value,
title: Gn.value,
description: bn.value,
firstButtonText: Jn.value,
secondButtonText: Yn.value,
thirdButtonText: mn.value,
onFirstModalButtonFunctionDynamicModalBuilder: xn.value,
onSecondModalButtonFunctionDynamicModalBuilder: Xn.value,
onThirdModalButtonFunctionDynamicModalBuilder: Qn.value
}, {
default: V(() => _[22] || (_[22] = [
d("header", null, null, -1),
d("main", null, null, -1)
])),
_: 1,
__: [22]
}, 8, ["showDynamicModalBuilder", "isLoading", "type", "gridColumnAmount", "title", "description", "firstButtonText", "secondButtonText", "thirdButtonText", "onFirstModalButtonFunctionDynamicModalBuilder", "onSecondModalButtonFunctionDynamicModalBuilder", "onThirdModalButtonFunctionDynamicModalBuilder"]),
j(yr, {
showDynamicModalBuilder: ft.value,
isLoading: et.value,
type: gn.value,
gridColumnAmount: It.value,
title: yn.value,
description: Zn.value,
firstButtonText: er.value,
secondButtonText: tr.value,
thirdButtonText: nr.value,
onFirstModalButtonFunctionDynamicModalBuilder: ai.value,
onSecondModalButtonFunctionDynamicModalBuilder: ci.value,
onThirdModalButtonFunctionDynamicModalBuilder: pi.value
}, {
default: V(() => _[23] || (_[23] = [
d("header", null, null, -1),
d("main", null, null, -1)
])),
_: 1,
__: [23]
}, 8, ["showDynamicModalBuilder", "isLoading", "type", "gridColumnAmount", "title", "description", "firstButtonText", "secondButtonText", "thirdButtonText", "onFirstModalButtonFunctionDynamicModalBuilder", "onSecondModalButtonFunctionDynamicModalBuilder", "onThirdModalButtonFunctionDynamicModalBuilder"]),
d("div", qB, [
x.value && x.value.pageBuilderLogo && x.value.pageBuilderLogo.src ? (w(), E("div", {
key: 0,
onClick: _[0] || (_[0] = bt(
async () => {
await y(t).clearHtmlSelection();
},
["self"]
)),
class: "pbx-flex pbx-justify-start pbx-py-2 lg:pbx-ml-4 pbx-ml-2"
}, [
d("img", {
class: "pbx-h-6",
src: x.value.pageBuilderLogo.src,
alt: "Logo"
}, null, 8, KB)
])) : A("", !0),
j(WB, { onToolbarHideRequest: q }),
d("div", {
onClick: _[3] || (_[3] = bt(
async () => {
await y(t).clearHtmlSelection();
},
["self"]
)),
class: "pbx-flex-1 pbx-flex pbx-justify-center pbx-items-center pbx-py-2 pbx-w-full"
}, [
d("div", GB, [
d("button", {
class: "pbx-mySecondaryButton pbx-h-6 pbx-flex pbx-gap-2 pbx-mr-2",
onClick: _[1] || (_[1] = bt(
async () => {
await y(t).clearHtmlSelection(), await y(t).handleManualSave();
},
["stop"]
)),
type: "button",
disabled: st.value
}, [
st.value ? A("", !0) : (w(), E("div", YB, _[24] || (_[24] = [
d("span", { class: "material-symbols-outlined" }, "save", -1)
]))),
st.value ? (w(), E("div", XB, _[25] || (_[25] = [
d("span", { class: "pbx-relative pbx-flex pbx-size-3" }, [
d("span", { class: "pbx-absolute pbx-inline-flex pbx-h-full pbx-w-full pbx-animate-ping pbx-rounded-full pbx-bg-gray-400 pbx-opacity-75" }),
d("span", { class: "pbx-relative pbx-inline-flex pbx-size-3 pbx-rounded-full pbx-bg-green-200" })
], -1)
]))) : A("", !0),
d("div", null, k(y(o)("Save")), 1)
], 8, JB),
x.value && x.value.updateOrCreate && x.value.updateOrCreate.formType === "update" ? (w(), E("button", {
key: 0,
class: "pbx-mySecondaryButton pbx-h-6 pbx-flex pbx-gap-2 lg:pbx-mr-2 pbx-mr-2",
onClick: _[2] || (_[2] = bt(
async () => {
await y(t).clearHtmlSelection(), await Ys();
},
["stop"]
)),
type: "button",
disabled: et.value
}, [
et.value ? A("", !0) : (w(), E("div", ZB, _[26] || (_[26] = [
d("span", { class: "material-symbols-outlined" }, " settings_backup_restore ", -1)
]))),
et.value ? (w(), E("div", eP, _[27] || (_[27] = [
d("span", { class: "pbx-relative pbx-flex pbx-size-3" }, [
d("span", { class: "pbx-absolute pbx-inline-flex pbx-h-full pbx-w-full pbx-animate-ping pbx-rounded-full pbx-bg-gray-400 pbx-opacity-75" }),
d("span", { class: "pbx-relative pbx-inline-flex pbx-size-3 pbx-rounded-full pbx-bg-green-200" })
], -1)
]))) : A("", !0),
d("div", tP, [
d("span", null, k(y(o)("Reset Page")), 1)
]),
d("div", nP, [
d("span", null, k(y(o)("Reset")), 1)
])
], 8, QB)) : A("", !0)
])
]),
d("div", {
onClick: _[8] || (_[8] = bt(
async () => {
await y(t).clearHtmlSelection();
},
["self"]
)),
class: "pbx-flex-1 pbx-flex pbx-justify-center pbx-items-center pbx-py-2 pbx-w-full"
}, [
d("div", {
onClick: _[7] || (_[7] = bt(
async () => {
await y(t).clearHtmlSelection();
},
["self"]
)),
class: "pbx-flex pbx-items-center pbx-justify-center"
}, [
d("div", {
class: "pbx-mr-2",
onClick: _[4] || (_[4] = () => {
y(l).setComponentArrayAddMethod("unshift"), G();
})
}, [
d("div", rP, [
d("span", oP, [
d("div", iP, k(y(o)("Add new Components")), 1)
]),
_[28] || (_[28] = d("span", { class: "pbx-h-10 pbx-w-10 pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-50 pbx-aspect-square hover:pbx-bg-myPrimaryLinkColor focus-visible:pbx-ring-0 pbx-text-black hover:pbx-text-white" }, [
d("span", { class: "pbx-myMediumIcon material-symbols-outlined" }, " interests ")
], -1))
])
]),
d("div", sP, [
d("div", {
onClick: _[5] || (_[5] = async () => {
y(l).setMenuRight(!1), y(l).setElement(null), await y(t).clearHtmlSelection(), T();
})
}, _[29] || (_[29] = [
d("div", { class: "pbx-flex pbx-items-center pbx-justify-center pbx-gap-2" }, [
d("span", { class: "pbx-h-10 pbx-w-10 pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-50 pbx-aspect-square hover:pbx-bg-myPrimaryLinkColor focus-visible:pbx-ring-0 pbx-text-black hover:pbx-text-white" }, [
d("span", { class: "pbx-myMediumIcon material-symbols-outlined" }, " visibility ")
])
], -1)
]))
]),
d("div", lP, [
d("div", {
onClick: _[6] || (_[6] = async () => {
y(l).setMenuRight(!1), y(l).setElement(null), await y(t).clearHtmlSelection(), W();
})
}, _[30] || (_[30] = [
d("div", { class: "pbx-flex pbx-items-center pbx-justify-center pbx-gap-2" }, [
d("span", { class: "pbx-h-10 pbx-w-10 pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-50 pbx-aspect-square hover:pbx-bg-myPrimaryLinkColor focus-visible:pbx-ring-0 pbx-text-black hover:pbx-text-white" }, [
d("span", { class: "material-symbols-outlined" }, " phone_iphone ")
])
], -1)
]))
])
])
]),
d("div", aP, [
d("div", {
onClick: _[9] || (_[9] = bt(
async () => {
await y(t).clearHtmlSelection();
},
["self"]
)),
class: X(["pbx-flex pbx-items-center pbx-py-2 pbx-w-full", [n.showCloseButton ? "pbx-justify-between" : "pbx-justify-end"]])
}, [
j(RB)
], 2),
n.showPublishButton ? (w(), E("div", cP, [
d("button", {
class: "pbx-myPrimaryButton",
onClick: _[10] || (_[10] = async () => {
p();
})
}, k(y(o)("Publish")), 1)
])) : A("", !0),
x.value && x.value.userSettings && x.value.userSettings.language && !x.value.userSettings.language.disableLanguageDropDown ? (w(), E(Z, { key: 1 }, [
x.value && x.value.userSettings && x.value.userSettings.language ? (w(), E("div", pP, [
xe(d("select", {
id: "pbx-lang",
class: "pbx-myPrimarySelect pbx-min-w-20",
"onUpdate:modelValue": _[11] || (_[11] = (le) => f.value = le)
}, [
Array.isArray(x.value.userSettings.language.enable) && x.value.userSettings.language.enable.length >= 1 ? (w(!0), E(Z, { key: 0 }, fe(y(t).availableLanguage().filter((le) => x.value.userSettings.language.enable.includes(le)), (le) => (w(), E("option", {
key: le,
value: le
}, k(le), 9, uP))), 128)) : A("", !0),
!x.value.userSettings.language.enable || Array.isArray(x.value.userSettings.language.enable) && x.value.userSettings.language.enable.length === 0 ? (w(!0), E(Z, { key: 1 }, fe(y(t).availableLanguage(), (le) => (w(), E("option", {
key: le,
value: le
}, k(le), 9, dP))), 128)) : A("", !0)
], 512), [
[Ue, f.value]
])
])) : A("", !0)
], 64)) : A("", !0),
n.showCloseButton ? (w(), E("div", fP, [
d("button", {
class: "pbx-h-10 pbx-w-10 pbx-flex-end pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-50 pbx-aspect-square hover:pbx-bg-myPrimaryLinkColor hover:pbx-text-white hover:pbx-fill-white focus-visible:pbx-ring-0",
onClick: _[12] || (_[12] = async () => {
c(), await y(t).clearHtmlSelection();
})
}, _[31] || (_[31] = [
d("span", { class: "material-symbols-outlined" }, " close ", -1)
]))
])) : A("", !0)
])
]),
d("div", hP, [
d("div", {
onClick: _[15] || (_[15] = bt(
async () => {
await y(t).clearHtmlSelection();
},
["self"]
)),
id: "pagebuilder-left-menu",
class: "pbx-w-16 pbx-pt-7 pbx-pb-2 pbx-bg-myPrimaryLightGrayColor pbx-rounded-r-2xl pbx-shadow-sm"
}, [
d("div", bP, [
d("div", mP, [
d("button", {
type: "button",
onClick: _[13] || (_[13] = () => {
y(l).setComponentArrayAddMethod("unshift"), G();
}),
class: "pbx-h-10 pbx-w-10 pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-50 pbx-aspect-square hover:pbx-bg-myPrimaryLinkColor focus-visible:pbx-ring-0 pbx-text-black hover:pbx-text-white"
}, _[32] || (_[32] = [
d("span", { class: "pbx-myMediumIcon material-symbols-outlined" }, " interests ", -1)
]))
]),
d("div", {
onClick: _[14] || (_[14] = bt(
async () => {
await y(t).clearHtmlSelection();
},
["self"]
))
}, [
re.value ? (w(), pe(bb, { key: 0 })) : A("", !0)
])
])
]),
d("main", {
ref_key: "pbxBuilderWrapper",
ref: P,
id: "page-builder-wrapper",
class: X(["pbx-transition-all pbx-duration-300 pbx-font-sans pbx-p-1 pbx-flex pbx-flex-col pbx-grow pbx-rounded-tr-2xl pbx-rounded-tl-2xl pbx-border-solid pbx-border pbx-border-gray-200 pbx-items-stretch pbx-text-black pbx-h-[100vh] pbx-overflow-y-scroll pbx-relative pbx-pt-16", [(v.value, "pbx-w-full")]])
}, [
d("div", xP, [
re.value ? (w(), pe(Ek, { key: 0 })) : A("", !0)
]),
d("div", gP, [
(w(!0), E(Z, null, fe(ut.value, (le) => (w(), E(Z, {
key: le.id
}, [
le.html_code ? (w(), E("div", {
key: 0,
innerHTML: le.html_code,
onMouseup: (Bt) => Mt(le)
}, null, 40, yP)) : A("", !0)
], 64))), 128))
])
], 2),
j(oo, {
name: "slide-right",
appear: "",
mode: "out-in"
}, {
default: V(() => [
v.value ? (w(), E("aside", {
key: 0,
"aria-label": "menu",
id: "pagebuilder-right-menu",
class: X(["pbx-z-20 pbx-flex-shrink-0 pbx-overflow-hidden pbx-border-0 pbx-border-solid pbx-border-l-0 pbx-border-l-gray-600 pbx-rounded-l-2xl pbx-h-[100vh] pbx-pl-2", [
v.value ? "pbx-w-80 pbx-bg-myPrimaryLightGrayColor pbx-items-stretch" : "bpx-w-0 pbx-mr-0"
]])
}, [
j(pE, {
onCloseEditor: _[16] || (_[16] = (le) => y(l).setMenuRight(!1))
})
], 2)) : (w(), E("div", {
key: 1,
onClick: _[19] || (_[19] = bt(
async () => {
await y(t).clearHtmlSelection();
},
["self"]
)),
class: "pbx-w-18 pbx-bg-myPrimaryLightGrayColor pbx-pt-5 pbx-z-20 pbx-flex-shrink-0 pbx-overflow-hidden pbx-border-0 pbx-border-solid pbx-border-l-0 pbx-border-l-gray-600 pbx-rounded-l-2xl pbx-h-[100vh] pbx-pl-2 pbx-pr-2"
}, [
d("div", {
onClick: _[18] || (_[18] = bt(
async () => {
await y(t).clearHtmlSelection();
},
["self"]
)),
class: "pbx-flex pbx-flex-col pbx-items-center pbx-justify-center pbx-gap-2"
}, [
v.value ? A("", !0) : (w(), E("button", {
key: 0,
onClick: _[17] || (_[17] = (le) => y(l).setMenuRight(!0)),
type: "button",
class: "pbx-mySecondaryButton pbx-px-2 pbx-text-xs"
}, [
d("span", null, k(y(o)("Styles")), 1)
]))
])
]))
]),
_: 1
})
]),
d("div", vP, [
d("div", {
onClick: _[20] || (_[20] = () => {
y(l).setComponentArrayAddMethod("push"), G();
}),
class: "pbx-flex pbx-items-center pbx-justify-center pbx-gap-2 pbx-cursor-pointer"
}, [
d("span", wP, [
d("div", SP, k(y(o)("Add to the bottom")), 1)
]),
_[33] || (_[33] = d("div", { class: "pbx-flex pbx-gap-2 pbx-items-center pbx-justify-center" }, [
d("button", {
type: "button",
class: "pbx-h-10 pbx-w-10 pbx-cursor-pointer pbx-rounded-full pbx-flex pbx-items-center pbx-border-none pbx-justify-center pbx-bg-gray-50 pbx-aspect-square hover:pbx-bg-myPrimaryLinkColor focus-visible:pbx-ring-0 pbx-text-black hover:pbx-text-white"
}, [
d("span", { class: "pbx-myMediumIcon material-symbols-outlined" }, " interests ")
])
], -1))
])
])
]));
}
}, OP = {
install: (n) => {
if (!n.config.globalProperties.$pageBuilder) {
const e = Se, t = new ab(e);
cb(t), n.config.globalProperties.$pageBuilder = t;
}
}
};
export {
TP as PageBuilder,
vc as Preview,
qw as createPinia,
Ce as getPageBuilder,
OP as pageBuilder,
bh as sharedPageBuilderPinia,
Se as sharedPageBuilderStore,
Pk as usePageBuilderModal,
Xw as usePageBuilderStateStore
};