import { A as e, B as t, F as n, I as r, T as i, _ as a, a as o, b as s, c, f as l, h as u, m as d, ot as f, p, rt as m, st as h, u as g, v as _, w as v } from "./vue.runtime.esm-bundler-BDSGA5hA.js";
import { D as y, k as b } from "./keys-B8K7Z7Ef.js";
import { t as x } from "./useI18n-CBbStVlD.js";
import { t as S } from "./createLucideIcon-XgXOJ05E.js";
import { t as C } from "./x-rcnxRG8Y.js";
import { t as w } from "./usePopoverRoot-62PlZQQ3.js";
var T = S("bold", [["path", {
	d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",
	key: "mg9rjx"
}]]), E = S("italic", [
	["line", {
		x1: "19",
		x2: "10",
		y1: "4",
		y2: "4",
		key: "15jd3p"
	}],
	["line", {
		x1: "14",
		x2: "5",
		y1: "20",
		y2: "20",
		key: "bu0au3"
	}],
	["line", {
		x1: "15",
		x2: "9",
		y1: "4",
		y2: "20",
		key: "uljnxc"
	}]
]), D = S("link", [["path", {
	d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",
	key: "1cjeqo"
}], ["path", {
	d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",
	key: "19qd67"
}]]), O = ["data-tpl-theme"], k = { class: "tpl:flex tpl:items-center tpl:justify-between tpl:border-b tpl:border-[var(--tpl-border)] tpl:px-5 tpl:py-4" }, A = {
	id: "tpl-link-dialog-title",
	class: "tpl:m-0 tpl:text-sm tpl:font-semibold tpl:text-[var(--tpl-text)]"
}, j = ["aria-label"], M = { class: "tpl:p-5" }, N = { class: "tpl:mb-4 tpl:last:mb-0" }, P = {
	for: "tpl-link-dialog-url",
	class: "tpl:mb-1.5 tpl:block tpl:text-xs tpl:font-medium tpl:tracking-wide tpl:text-[var(--tpl-text-muted)] tpl:uppercase"
}, F = ["placeholder"], I = { class: "tpl:flex tpl:items-center tpl:justify-between tpl:border-t tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg-elevated)] tpl:px-5 tpl:py-4" }, L = { class: "tpl:ml-auto tpl:flex tpl:gap-2" }, R = /* @__PURE__ */ s({
	__name: "RichTextLinkDialog",
	props: /* @__PURE__ */ i({
		visible: { type: Boolean },
		isEditingLink: { type: Boolean }
	}, {
		linkUrl: { required: !0 },
		linkUrlModifiers: {},
		dialogRef: { required: !0 },
		dialogRefModifiers: {}
	}),
	emits: /* @__PURE__ */ i([
		"close",
		"insert",
		"remove",
		"keydown"
	], ["update:linkUrl", "update:dialogRef"]),
	setup(n, { emit: i }) {
		let a = r(n, "linkUrl"), s = r(n, "dialogRef"), S = i, T = v(y, null), E = v(b, null), D = w(), { t: R } = x();
		return (r, i) => m(D) ? (e(), p(g, {
			key: 0,
			to: m(D)
		}, [n.visible ? (e(), u("div", {
			key: 0,
			"data-tpl-theme": m(E),
			class: "tpl tpl-link-dialog tpl:fixed tpl:inset-0 tpl:z-modal tpl:flex tpl:items-center tpl:justify-center",
			style: f(m(T)),
			onClick: i[6] ||= c((e) => S("close"), ["self"])
		}, [l("div", {
			ref: (e) => s.value = e,
			role: "dialog",
			"aria-modal": "true",
			"aria-labelledby": "tpl-link-dialog-title",
			class: "tpl:w-[400px] tpl:overflow-hidden tpl:rounded-lg tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:shadow-lg"
		}, [
			l("div", k, [l("h4", A, h(n.isEditingLink ? m(R).linkDialog.editLink : m(R).linkDialog.insertLink), 1), l("button", {
				type: "button",
				"aria-label": m(R).linkDialog.cancel,
				class: "tpl:flex tpl:size-7 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:rounded tpl:border-none tpl:bg-transparent tpl:p-0 tpl:text-[var(--tpl-text-muted)] tpl:hover:bg-[var(--tpl-bg-hover)] tpl:hover:text-[var(--tpl-text)]",
				onClick: i[0] ||= (e) => S("close")
			}, [_(m(C), {
				size: 16,
				"stroke-width": 2
			})], 8, j)]),
			l("div", M, [l("div", N, [l("label", P, h(m(R).linkDialog.urlLabel), 1), t(l("input", {
				id: "tpl-link-dialog-url",
				"onUpdate:modelValue": i[1] ||= (e) => a.value = e,
				type: "url",
				class: "tpl:w-full tpl:rounded-md tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:px-3 tpl:py-2.5 tpl:text-sm tpl:text-[var(--tpl-text)] tpl:transition-all tpl:duration-150 tpl:outline-none tpl:placeholder:text-[var(--tpl-text-dim)] tpl:focus:border-[var(--tpl-primary)] tpl:focus:shadow-[0_0_0_3px_var(--tpl-primary-light)]",
				placeholder: m(R).linkDialog.urlPlaceholder,
				autofocus: "",
				onKeydown: i[2] ||= (e) => S("keydown", e)
			}, null, 40, F), [[o, a.value]])])]),
			l("div", I, [n.isEditingLink ? (e(), u("button", {
				key: 0,
				type: "button",
				class: "tpl:inline-flex tpl:cursor-pointer tpl:items-center tpl:rounded-md tpl:border tpl:border-[var(--tpl-danger)] tpl:bg-transparent tpl:px-4 tpl:py-2 tpl:text-[13px] tpl:font-medium tpl:text-[var(--tpl-danger)] tpl:transition-all tpl:duration-150 tpl:hover:bg-[var(--tpl-danger-light)]",
				onClick: i[3] ||= (e) => S("remove")
			}, h(m(R).linkDialog.removeLink), 1)) : d("", !0), l("div", L, [l("button", {
				type: "button",
				class: "tpl:inline-flex tpl:cursor-pointer tpl:items-center tpl:rounded-md tpl:border tpl:border-[var(--tpl-border)] tpl:bg-transparent tpl:px-4 tpl:py-2 tpl:text-[13px] tpl:font-medium tpl:text-[var(--tpl-text-muted)] tpl:transition-all tpl:duration-150 tpl:hover:bg-[var(--tpl-bg-hover)] tpl:hover:text-[var(--tpl-text)]",
				onClick: i[4] ||= (e) => S("close")
			}, h(m(R).linkDialog.cancel), 1), l("button", {
				type: "button",
				class: "tpl:inline-flex tpl:cursor-pointer tpl:items-center tpl:rounded-md tpl:border-none tpl:bg-[var(--tpl-primary)] tpl:px-4 tpl:py-2 tpl:text-[13px] tpl:font-medium tpl:transition-all tpl:duration-150 tpl:hover:bg-[var(--tpl-primary-hover)] tpl:text-[var(--tpl-bg)]",
				onClick: i[5] ||= (e) => S("insert")
			}, h(n.isEditingLink ? m(R).linkDialog.updateLink : m(R).linkDialog.insertLink), 1)])])
		], 512)], 12, O)) : d("", !0)], 8, ["to"])) : d("", !0);
	}
}), z = {
	key: 0,
	class: "tpl-text-editable tpl:min-h-[1.5em] tpl:rounded tpl:border tpl:border-dashed tpl:border-[var(--tpl-primary)] tpl:p-2"
}, B = { class: "tpl:animate-pulse tpl:text-[var(--tpl-text-dim)]" }, V = {
	key: 1,
	class: "tpl-text-editable tpl:min-h-[1.5em] tpl:rounded tpl:border tpl:border-dashed tpl:p-2 tpl:text-center tpl:text-xs tpl:border-[var(--tpl-danger)] tpl:text-[var(--tpl-text-muted)]"
}, H = /* @__PURE__ */ s({
	__name: "RichTextEditorContent",
	props: {
		editor: {},
		editorContent: {},
		isLoading: { type: Boolean },
		initError: {}
	},
	emits: ["retry"],
	setup(t, { emit: r }) {
		let i = r, { t: o } = x();
		return (r, s) => t.isLoading ? (e(), u("div", z, [l("div", B, h(m(o).errors.editorLoading), 1)])) : t.initError ? (e(), u("div", V, [a(h(m(o).errors.editorLoadFailed) + " ", 1), l("button", {
			class: "tpl:ml-1 tpl:cursor-pointer tpl:border-none tpl:bg-transparent tpl:p-0 tpl:underline tpl:text-[var(--tpl-primary)]",
			onClick: s[0] ||= (e) => i("retry")
		}, h(m(o).errors.retry), 1)])) : t.editorContent && t.editor ? (e(), p(n(t.editorContent), {
			key: 2,
			editor: t.editor,
			class: "tpl-text-editable tpl:min-h-[1.5em] tpl:rounded tpl:border tpl:border-dashed tpl:border-[var(--tpl-primary)] tpl:p-2"
		}, null, 8, ["editor"])) : d("", !0);
	}
});
//#endregion
export { T as a, E as i, R as n, D as r, H as t };
