import { K as e, M as t, T as n, ct as r, d as i, g as a, h as o, it as s, m as c, ot as l, p as u, st as d, u as f, v as p, x as m, y as h } from "./draggable-P6QWzy4g.js";
import { Ft as g, Y as _, a as v, en as y, tn as b, vt as x } from "./features-CgTy87Ni.js";
import { U as S, V as C, Z as w, x as T } from "./icons-DxJ--AJb.js";
import { n as E, t as D } from "./RichTextEditorContent-CFL-Lrv5.js";
//#region src/components/blocks/TitleEditor.vue?vue&type=script&setup=true&lang.ts
var ee = { class: "tpl-text-editor-wrapper tpl:relative" }, O = ["data-tpl-theme", "aria-label"], k = ["aria-label", "title"], A = ["aria-label", "title"], j = ["aria-label", "title"], M = {
	key: 0,
	class: "tpl:mx-1.5 tpl:h-6 tpl:w-px tpl:bg-[var(--tpl-border)]"
}, N = ["aria-label", "title"], P = {
	key: 1,
	class: "tpl:flex tpl:items-center tpl:gap-2 tpl:px-2 tpl:text-xs tpl:text-[var(--tpl-text-dim)]"
}, F = /* @__PURE__ */ m({
	__name: "TitleEditor",
	props: {
		block: {},
		toolbarPosition: {}
	},
	emits: ["done"],
	setup(m, { emit: F }) {
		let I = m, L = F, R = n(y, null), z = n(b, null), B = v(), { t: V } = g(), { editor: H, EditorContent: U, isLoading: W, initError: G, retry: K, showLinkDialog: q, linkUrl: J, linkDialogRef: Y, canRequestMergeTag: X, openLinkDialog: Z, insertLink: Q, removeLink: te, closeLinkDialog: ne, handleLinkKeydown: re, handleAddMergeTag: $ } = _({
			blockId: () => I.block.id,
			blockContent: () => I.block.content,
			onDone: () => L("done"),
			editorName: "TitleEditor",
			async loadExtensions({ mergeTags: e, syntax: t, triggerChar: n, autocompleteEnabled: r, suggestionEmptyText: i }) {
				let [{ Editor: a, EditorContent: o }, { default: s }, { default: c }, { MergeTagNode: l, MergeTagSuggestion: u, LogicMergeTagNode: d }] = await Promise.all([
					import("./tiptap-BwTCLVWl.js").then((e) => e.i),
					import("./tiptap-BwTCLVWl.js").then((e) => e.a),
					import("./tiptap-BwTCLVWl.js").then((e) => e.u),
					import("./extensions-DgvvgeJU.js")
				]);
				return {
					TiptapEditor: a,
					EC: o,
					extensions: [
						s.configure({
							heading: !1,
							codeBlock: !1,
							blockquote: !1,
							horizontalRule: !1,
							bulletList: !1,
							orderedList: !1,
							listItem: !1,
							strike: !1
						}),
						c.configure({
							openOnClick: !1,
							HTMLAttributes: {
								target: "_blank",
								rel: "noopener noreferrer"
							}
						}),
						l.configure({
							mergeTags: e,
							syntax: t
						}),
						d.configure({ syntax: t }),
						...r && n && e.length > 0 ? [u.configure({
							mergeTags: e,
							char: n,
							emptyText: i,
							popoverRoot: B
						})] : []
					]
				};
			}
		});
		return (n, g) => (t(), a("div", ee, [
			s(B) ? (t(), c(i, {
				key: 0,
				to: s(B)
			}, [u("div", {
				"data-tpl-theme": s(z),
				role: "toolbar",
				"aria-label": s(V).titleEditor.toolbar,
				class: "tpl tpl-text-toolbar tpl:fixed tpl:z-popover tpl:flex tpl:items-center tpl:gap-1 tpl:rounded-lg tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:px-3 tpl:py-2 tpl:shadow-lg",
				style: d({
					...s(R),
					top: `${m.toolbarPosition.top}px`,
					left: `${m.toolbarPosition.left}px`,
					transform: "translateY(-100%)"
				})
			}, [!s(W) && s(H) ? (t(), a(f, { key: 0 }, [
				u("button", {
					type: "button",
					class: l(["tpl-text-toolbar-btn", { "tpl-text-toolbar-btn--active": s(H)?.isActive("bold") }]),
					"aria-label": s(V).titleEditor.bold,
					title: s(V).titleEditor.bold,
					onClick: g[0] ||= (e) => s(H)?.chain().focus().toggleBold().run()
				}, [h(s(w), {
					size: 16,
					"stroke-width": 2.5
				})], 10, k),
				u("button", {
					type: "button",
					class: l(["tpl-text-toolbar-btn", { "tpl-text-toolbar-btn--active": s(H)?.isActive("italic") }]),
					"aria-label": s(V).titleEditor.italic,
					title: s(V).titleEditor.italic,
					onClick: g[1] ||= (e) => s(H)?.chain().focus().toggleItalic().run()
				}, [h(s(S), {
					size: 16,
					"stroke-width": 2
				})], 10, A),
				g[6] ||= u("span", {
					class: "tpl:mx-1.5 tpl:h-6 tpl:w-px tpl:bg-[var(--tpl-border)]",
					"aria-hidden": "true"
				}, null, -1),
				u("button", {
					type: "button",
					class: l(["tpl-text-toolbar-btn", { "tpl-text-toolbar-btn--active": s(H)?.isActive("link") }]),
					"aria-label": s(V).titleEditor.addLink,
					title: s(V).titleEditor.addLink,
					onClick: g[2] ||= (...e) => s(Z) && s(Z)(...e)
				}, [h(s(C), {
					size: 16,
					"stroke-width": 2
				})], 10, j),
				s(X) ? (t(), a("span", M)) : o("", !0),
				s(X) ? (t(), a("button", {
					key: 1,
					type: "button",
					class: "tpl:flex tpl:h-8 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:gap-1.5 tpl:rounded tpl:border-none tpl:bg-transparent tpl:px-2.5 tpl:text-xs tpl:font-medium tpl:text-[var(--tpl-text)] tpl:transition-all tpl:duration-150 tpl:hover:bg-[var(--tpl-bg-active)]",
					"aria-label": s(V).mergeTag.add,
					title: s(V).mergeTag.add,
					onClick: g[3] ||= (...e) => s($) && s($)(...e)
				}, [h(s(T), {
					size: 16,
					"stroke-width": 2
				}), p(" " + r(s(V).mergeTag.add), 1)], 8, N)) : o("", !0)
			], 64)) : (t(), a("div", P, [h(s(x), {
				class: "tpl-spinner",
				size: 14,
				"stroke-width": 2
			}), p(" " + r(s(V).errors.editorLoading), 1)]))], 12, O)], 8, ["to"])) : o("", !0),
			h(D, {
				editor: s(H),
				"editor-content": s(U),
				"is-loading": s(W),
				"init-error": s(G),
				onRetry: s(K)
			}, null, 8, [
				"editor",
				"editor-content",
				"is-loading",
				"init-error",
				"onRetry"
			]),
			h(E, {
				visible: s(q),
				"is-editing-link": s(H)?.isActive("link") ?? !1,
				"dialog-ref": s(Y),
				"onUpdate:dialogRef": g[4] ||= (t) => e(Y) ? Y.value = t : null,
				"link-url": s(J),
				"onUpdate:linkUrl": g[5] ||= (t) => e(J) ? J.value = t : null,
				onClose: s(ne),
				onInsert: s(Q),
				onRemove: s(te),
				onKeydown: s(re)
			}, null, 8, [
				"visible",
				"is-editing-link",
				"dialog-ref",
				"link-url",
				"onClose",
				"onInsert",
				"onRemove",
				"onKeydown"
			])
		]));
	}
});
//#endregion
export { F as default };

//# sourceMappingURL=TitleEditor-CSDdss38.js.map