import { A as e, G as t, _ as n, at as r, b as i, f as a, h as o, l as s, m as c, ot as l, p as u, rt as d, st as f, u as p, v as m, w as h } from "./vue.runtime.esm-bundler-Bxqkjqhc.js";
import { b as g } from "./useEditorCore-uCU9Ny0M.js";
import { D as _, k as v } from "./keys-B5SJtPWf.js";
import { t as y } from "./useI18n-PEB8ioi_.js";
import { a as b, i as x, n as S, r as C, t as w } from "./RichTextEditorContent-C3QSg7gd.js";
import { t as T } from "./loader-circle-_9bP23op.js";
import { t as E } from "./scan-line-DUEg6DoT.js";
import { t as ee } from "./usePopoverRoot-BxJrqnMD.js";
//#region src/components/blocks/TitleEditor.vue?vue&type=script&setup=true&lang.ts
var D = { 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__ */ i({
	__name: "TitleEditor",
	props: {
		block: {},
		toolbarPosition: {}
	},
	emits: ["done"],
	setup(i, { emit: F }) {
		let I = i, L = F, R = h(_, null), z = h(v, null), B = ee(), { t: V } = y(), { 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: $ } = g({
			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("./dist-Pk4MhWMP.js").then((e) => e.r),
					import("./dist-D90y8dvT.js"),
					import("./dist-DDJIWTRY.js"),
					import("./extensions-D-J02CiP.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 (h, g) => (e(), o("div", D, [
			d(B) ? (e(), u(p, {
				key: 0,
				to: d(B)
			}, [a("div", {
				"data-tpl-theme": d(z),
				role: "toolbar",
				"aria-label": d(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: l({
					...d(R),
					top: `${i.toolbarPosition.top}px`,
					left: `${i.toolbarPosition.left}px`,
					transform: "translateY(-100%)"
				})
			}, [!d(W) && d(H) ? (e(), o(s, { key: 0 }, [
				a("button", {
					type: "button",
					class: r(["tpl-text-toolbar-btn", { "tpl-text-toolbar-btn--active": d(H)?.isActive("bold") }]),
					"aria-label": d(V).titleEditor.bold,
					title: d(V).titleEditor.bold,
					onClick: g[0] ||= (e) => d(H)?.chain().focus().toggleBold().run()
				}, [m(d(b), {
					size: 16,
					"stroke-width": 2.5
				})], 10, k),
				a("button", {
					type: "button",
					class: r(["tpl-text-toolbar-btn", { "tpl-text-toolbar-btn--active": d(H)?.isActive("italic") }]),
					"aria-label": d(V).titleEditor.italic,
					title: d(V).titleEditor.italic,
					onClick: g[1] ||= (e) => d(H)?.chain().focus().toggleItalic().run()
				}, [m(d(x), {
					size: 16,
					"stroke-width": 2
				})], 10, A),
				g[6] ||= a("span", {
					class: "tpl:mx-1.5 tpl:h-6 tpl:w-px tpl:bg-[var(--tpl-border)]",
					"aria-hidden": "true"
				}, null, -1),
				a("button", {
					type: "button",
					class: r(["tpl-text-toolbar-btn", { "tpl-text-toolbar-btn--active": d(H)?.isActive("link") }]),
					"aria-label": d(V).titleEditor.addLink,
					title: d(V).titleEditor.addLink,
					onClick: g[2] ||= (...e) => d(Z) && d(Z)(...e)
				}, [m(d(C), {
					size: 16,
					"stroke-width": 2
				})], 10, j),
				d(X) ? (e(), o("span", M)) : c("", !0),
				d(X) ? (e(), o("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": d(V).mergeTag.add,
					title: d(V).mergeTag.add,
					onClick: g[3] ||= (...e) => d($) && d($)(...e)
				}, [m(d(E), {
					size: 16,
					"stroke-width": 2
				}), n(" " + f(d(V).mergeTag.add), 1)], 8, N)) : c("", !0)
			], 64)) : (e(), o("div", P, [m(d(T), {
				class: "tpl-spinner",
				size: 14,
				"stroke-width": 2
			}), n(" " + f(d(V).errors.editorLoading), 1)]))], 12, O)], 8, ["to"])) : c("", !0),
			m(w, {
				editor: d(H),
				"editor-content": d(U),
				"is-loading": d(W),
				"init-error": d(G),
				onRetry: d(K)
			}, null, 8, [
				"editor",
				"editor-content",
				"is-loading",
				"init-error",
				"onRetry"
			]),
			m(S, {
				visible: d(q),
				"is-editing-link": d(H)?.isActive("link") ?? !1,
				"dialog-ref": d(Y),
				"onUpdate:dialogRef": g[4] ||= (e) => t(Y) ? Y.value = e : null,
				"link-url": d(J),
				"onUpdate:linkUrl": g[5] ||= (e) => t(J) ? J.value = e : null,
				onClose: d(ne),
				onInsert: d(Q),
				onRemove: d(te),
				onKeydown: d(re)
			}, null, 8, [
				"visible",
				"is-editing-link",
				"dialog-ref",
				"link-url",
				"onClose",
				"onInsert",
				"onRemove",
				"onKeydown"
			])
		]));
	}
});
//#endregion
export { F as default };
