import { A as e, B as t, L as n, M as r, O as i, Q as a, X as o, _ as s, at as c, b as l, c as u, d, f, g as p, h as m, j as h, k as g, l as _, m as v, o as y, ot as b, p as x, q as S, rt as C, st as w, t as T, v as E, y as D, z as O } from "./vue.runtime.esm-bundler-Bxqkjqhc.js";
import { t as k } from "./timeouts-BSGxjuUF.js";
import { E as A, i as j } from "./dist-DJmnUmW9.js";
import { P as M, S as ee, t as N } from "./useEditorCore-uCU9Ny0M.js";
import { s as P, t as F } from "./dist-BzRLLpfq.js";
import { E as te, S as ne, T as I, c as L, i as R, l as z, n as B, u as V } from "./keys-B5SJtPWf.js";
import { t as H } from "./useI18n-PEB8ioi_.js";
import { t as U } from "./createLucideIcon-Di4mqmGn.js";
import { t as W } from "./check-Bg5yrRmX.js";
import { t as G } from "./circle-alert-C0L9pUQ4.js";
import { a as K, c as re, i as q, l as ie, n as J, o as ae, r as oe, s as se, t as ce } from "./styles-D_fEz49o.js";
import { t as Y } from "./clock-CDlEdqiP.js";
import { t as X } from "./loader-circle-_9bP23op.js";
import { t as Z } from "./message-circle-gzy2ZGJ3.js";
import { t as le } from "./send-BatIZC9a.js";
import { t as ue } from "./sparkles-D1IGi_cC.js";
import { t as de } from "./triangle-alert-DWQySIE2.js";
import { t as fe } from "./_plugin-vue_export-helper-B0hnzhyu.js";
import { n as Q } from "./useCloudI18n-ByEMykjO.js";
import { d as $ } from "./styleConstants-fWzlIIwN.js";
import { _ as pe, a as me, c as he, d as ge, f as _e, g as ve, h as ye, l as be, m as xe, n as Se, o as Ce, p as we, r as Te, s as Ee, t as De, v as Oe, y as ke } from "./cloud-a3VovHva.js";
var Ae = U("save", [
	["path", {
		d: "M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",
		key: "1c8476"
	}],
	["path", {
		d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",
		key: "1ydtos"
	}],
	["path", {
		d: "M7 3v4a1 1 0 0 0 1 1h7",
		key: "t51u73"
	}]
]);
//#endregion
//#region src/cloud/composables/useSnapshotPreview.ts
function je(e) {
	let { authManager: t, editor: n, history: r, conditionPreview: i, autoSave: s, onError: c } = e, l = a(null), u = o(null), f = o(null), p = !1;
	S(() => {
		p = !0;
	});
	let m = d(() => u.value !== null), h = d(() => l.value?.snapshots.value ?? []), g = d(() => l.value?.isLoading.value ?? !1), _ = d(() => l.value?.isRestoring.value ?? !1);
	function v() {
		n.state.template?.id && !l.value && (l.value = ve({
			authManager: t,
			templateId: n.state.template.id,
			onRestore: y,
			onError: c
		}), l.value.loadSnapshots());
	}
	function y(e) {
		n.setContent(e.content, !1), r.clear(), i.reset();
	}
	async function b(e) {
		if (!p) {
			if (u.value) {
				u.value = e, n.setContent(e.content, !1);
				return;
			}
			n.state.isDirty && n.hasTemplate() && (await n.createSnapshot(), p) || (f.value = structuredClone(n.content.value), s?.pause(), u.value = e, n.setContent(e.content, !1));
		}
	}
	async function x() {
		if (!(!u.value || !l.value)) try {
			if (await l.value.restoreSnapshot(u.value.id), p || (await l.value.loadSnapshots(), p)) return;
		} finally {
			p || (u.value = null, f.value = null, s?.resume());
		}
	}
	function C() {
		!u.value || !f.value || (n.setContent(f.value, !1), u.value = null, f.value = null, s?.resume());
	}
	async function w() {
		p || l.value && await l.value.loadSnapshots();
	}
	return {
		snapshotHistoryInstance: l,
		previewingSnapshot: u,
		contentBeforePreview: f,
		isPreviewingSnapshot: m,
		snapshotHistorySnapshots: h,
		snapshotHistoryIsLoading: g,
		snapshotHistoryIsRestoring: _,
		initSnapshotHistory: v,
		handleRestore: y,
		handleSnapshotNavigate: b,
		confirmRestoreSnapshot: x,
		cancelPreview: C,
		loadSnapshotHistory: w
	};
}
//#endregion
//#region src/cloud/composables/useCloudPanelState.ts
function Me() {
	let e = o(null), t = d({
		get: () => e.value === "ai-chat",
		set: (t) => e.value = t ? "ai-chat" : null
	}), n = d({
		get: () => e.value === "scoring",
		set: (t) => e.value = t ? "scoring" : null
	}), r = d({
		get: () => e.value === "design-reference",
		set: (t) => e.value = t ? "design-reference" : null
	}), i = d({
		get: () => e.value === "comments",
		set: (t) => e.value = t ? "comments" : null
	}), a = o(!1), s = o(!1), c = o(void 0), l = o(!1), u = o(null), f = d(() => e.value !== null), p = d(() => {
		let t = e.value;
		return t === "ai-chat" || t === "design-reference" || t === "scoring" ? t : null;
	}), m = d(() => l.value || e.value === "ai-chat" || e.value === "design-reference" || e.value === "scoring");
	function h() {
		l.value = !l.value;
	}
	function g(t) {
		l.value = !1, e.value = e.value === t ? null : t;
	}
	return F(u, () => {
		l.value = !1;
	}), {
		activePanel: e,
		aiChatOpen: t,
		scoringPanelOpen: n,
		designReferenceOpen: r,
		commentsOpen: i,
		testEmailModalOpen: a,
		mediaLibraryOpen: s,
		mediaLibraryAccept: c,
		aiMenuOpen: l,
		aiMenuRef: u,
		rightPanelOpen: f,
		activeAiFeature: p,
		aiButtonActive: m,
		toggleAiMenu: h,
		handleAiFeatureSelect: g
	};
}
//#endregion
//#region src/cloud/composables/useCollabUndoWarning.ts
function Ne(e) {
	let { isCollaborationEnabled: t, getCollaboratorCount: n, canUndo: r } = e, i = o(!1), a = o(!1), { start: s } = P(() => {
		a.value = !1;
	}, k, { immediate: !1 });
	function c() {
		i.value || !t.value || n() === 0 || !r.value || (i.value = !0, a.value = !0, s());
	}
	return {
		collabUndoWarningVisible: a,
		showCollabUndoWarning: c
	};
}
//#endregion
//#region src/cloud/composables/useCloudFeatureFlags.ts
function Pe(e) {
	let { planConfigInstance: t, aiConfig: n, editor: r } = e, i = d(() => t.hasFeature("ai_generation") && n.hasAnyMenuFeature.value), a = d(() => t.hasFeature("test_email")), s = d(() => !!r.state.template?.id), c = d(() => t.hasFeature("white_label")), l = d(() => t.config.value?.limits.max_templates ?? null), u = d(() => t.config.value?.template_count ?? 0), f = o(!1), p = o("idle"), m = o(""), { start: h } = P(() => {
		p.value = "idle";
	}, 3e3, { immediate: !1 });
	return {
		canUseAiGeneration: i,
		canSendTestEmail: a,
		hasTemplateSaved: s,
		isWhiteLabeled: c,
		templateLimit: l,
		templateCount: u,
		isSaveExporting: f,
		saveStatus: p,
		saveErrorMessage: m,
		startSaveStatusClear: h
	};
}
//#endregion
//#region src/cloud/composables/useCloudMediaLibrary.ts
function Fe(e) {
	let { onRequestMedia: t, mediaLibraryOpen: n, mediaLibraryAccept: r } = e, i = null;
	async function a() {
		if (t) {
			let e = await t({ accept: ["images"] });
			return e ? {
				url: e.url,
				alt: e.alt_text || void 0
			} : null;
		}
		return i &&= (i(null), null), r.value = ["images"], n.value = !0, new Promise((e) => {
			i = (t) => {
				e(t);
			};
		});
	}
	function o(e) {
		n.value = !1, i?.({
			url: e.url,
			alt: e.alt_text || void 0
		}), i = null;
	}
	function s() {
		n.value = !1, i?.(null), i = null;
	}
	return S(() => {
		i &&= (i(null), null);
	}), {
		handleRequestMedia: a,
		handleMediaSelect: o,
		handleMediaLibraryClose: s
	};
}
//#endregion
//#region src/cloud/composables/useCloudInitialization.ts
function Ie(e) {
	let { config: t, translations: r, fontsManager: i, emit: a, getCommentsSidebar: s } = e, c = o(!0), l = o(!1), u = o(null), f = !1, p = { value: null }, m = null, g = null, _ = new De({
		...t.auth,
		onError: t.onError
	}), v = xe({
		authManager: _,
		onError: t.onError
	}), y = o(/* @__PURE__ */ new Map()), b = ge({
		authManager: _,
		defaultFontFamily: t.fonts?.defaultFont,
		templateDefaults: t.templateDefaults,
		onError: t.onError,
		lockedBlocks: y
	}), x = ke({
		authManager: _,
		onError: t.onError
	});
	t.mcp?.enabled && we({
		editor: b,
		channel: x.channel,
		onOperation: t.mcp.onOperation
	});
	let S = null;
	t.collaboration?.enabled && (S = Ce({
		authManager: _,
		editor: b,
		channel: x.channel,
		onError: t.onError,
		onCollaboratorJoined: t.collaboration.onCollaboratorJoined,
		onCollaboratorLeft: t.collaboration.onCollaboratorLeft,
		onBlockLocked: t.collaboration.onBlockLocked,
		onBlockUnlocked: t.collaboration.onBlockUnlocked
	}), n(() => S.lockedBlocks.value, (e) => {
		y.value = e;
	}, { immediate: !0 }), Ee(b, S));
	let C = d(() => !!t.collaboration?.enabled && v.hasFeature("collaboration")), w = N({
		editor: b,
		config: {
			uiTheme: t.uiTheme,
			theme: void 0,
			blockDefaults: t.blockDefaults,
			customBlocks: [],
			mergeTags: t.mergeTags,
			displayConditions: t.displayConditions,
			onRequestMedia: null,
			accessibility: re(t),
			onSave: () => {
				p.value?.().catch((e) => {
					t.onError?.(e);
				});
			}
		},
		translations: r,
		fontsManager: i,
		historyOptions: S ? { isRemoteOperation: () => S._isProcessingRemoteOperation() } : void 0,
		autoSaveOptions: {
			onChange: async () => {
				b.hasTemplate() && (await b.createSnapshot(), m?.snapshotHistoryInstance.value?.loadSnapshots());
			},
			debounce: t.autoSaveDebounce ?? 5e3,
			enabled: () => t.autoSave !== !1 && v.hasFeature("auto_save")
		},
		themeExtraStyles: () => ({ "--tpl-drop-text": `"${r.canvas.dropHere}"` }),
		keyboardOptions: { onBeforeUndo: () => g?.showCollabUndoWarning() },
		editorRoot: e.editorRoot
	}), T = Ne({
		isCollaborationEnabled: C,
		getCollaboratorCount: () => S?.collaborators.value.length ?? 0,
		canUndo: w.history.canUndo
	});
	g = T;
	let E = je({
		authManager: _,
		editor: b,
		history: w.history,
		conditionPreview: w.conditionPreview,
		autoSave: w.autoSave,
		onError: t.onError
	});
	m = E;
	let D = Me(), O = me(t.ai), k = Pe({
		planConfigInstance: v,
		aiConfig: O,
		editor: b
	}), A = Fe({
		onRequestMedia: t.onRequestMedia,
		mediaLibraryOpen: D.mediaLibraryOpen,
		mediaLibraryAccept: D.mediaLibraryAccept
	});
	ee({
		onBlockMove: b.moveBlock,
		onBlockAdd: b.addBlock
	});
	let j = _e({
		authManager: _,
		getFontsConfig: () => t.fonts,
		canUseCustomFonts: () => v.hasFeature("custom_fonts")
	}), P = Oe({
		authManager: _,
		getTemplateId: () => b.state.template?.id ?? null,
		save: () => b.save(),
		exportHtml: (e) => j.exportHtml(e),
		onError: t.onError,
		isAuthReady: l,
		onBeforeTestEmail: t.onBeforeTestEmail
	}), F = be({
		authManager: _,
		getTemplateId: () => b.state.template?.id ?? null,
		getSocketId: () => x.getSocketId(),
		onComment: t.onComment,
		onError: t.onError,
		isAuthReady: l,
		hasCommentingFeature: () => t.commenting !== !1 && v.hasFeature("commenting")
	});
	he({
		comments: F,
		channel: x.channel
	});
	let z = ye({
		authManager: _,
		onError: t.onError
	}), H = o(!1), U = o(null), W = o(!1), G = pe({
		authManager: _,
		getTemplateId: () => b.state.template?.id ?? null
	});
	function K(e) {
		D.commentsOpen.value = !0, queueMicrotask(() => {
			s()?.filterByBlock(e);
		});
	}
	h(ne, A.handleRequestMedia), h(R, _), h(B, O), h(V, F), h(I, z), h(te, G), h(L, {
		plan: v,
		ai: O,
		comments: {
			getBlockCount: (e) => F.commentCountByBlock.value.get(e) ?? 0,
			openForBlock: K
		},
		savedModules: {
			openSaveDialog: (e) => {
				U.value = e ?? null, H.value = !0;
			},
			openBrowser: () => {
				W.value = !0;
			},
			moduleCount: d(() => z.modules.value.length)
		}
	});
	function q(e) {
		v.hasFeature("theme_customization") && (w.themeOverrides.value = e);
	}
	function ie(e) {
		b.setUiTheme(e);
	}
	async function J() {
		c.value = !0, u.value = null;
		try {
			if (await _.initialize(), f) return;
			l.value = !0;
			let e = await Se({ authManager: _ });
			if (f) return;
			if (!e.api.ok) throw Error("Health check failed: API is not reachable");
			if (!e.auth.ok) throw Error(`Health check failed: authentication error${e.auth.error ? ` - ${e.auth.error}` : ""}`);
			if (e.websocket.ok || M.warn("WebSocket health check failed:", e.websocket.error ?? "unknown error", "-- real-time features will be disabled."), await v.fetchConfig(), f) return;
			i.setCustomFontsEnabled(v.hasFeature("custom_fonts")), t.customBlocks?.length && v.hasFeature("custom_blocks") && w.registerCustomBlocks(t.customBlocks), t.theme && v.hasFeature("theme_customization") && (w.themeOverrides.value = t.theme), t.modules !== !1 && v.hasFeature("saved_modules") && z.loadModules(), a("ready");
		} catch (e) {
			if (f) return;
			let n = e instanceof Error ? e : Error("Initialization failed", { cause: e });
			u.value = n, t.onError?.(n);
		} finally {
			f || (c.value = !1);
		}
	}
	function ae() {
		f = !0, i.cleanupFontLinks(), x.disconnect(), w.destroy(), t.onUnmount?.();
	}
	return {
		isInitializing: c,
		isAuthReady: l,
		initError: u,
		isDestroyed: () => f,
		authManager: _,
		planConfigInstance: v,
		websocket: x,
		collaboration: S,
		isCollaborationEnabled: C,
		editor: b,
		core: w,
		aiConfig: O,
		featureFlags: k,
		mediaLib: A,
		exporter: j,
		testEmail: P,
		commentsInstance: F,
		savedModulesHeadless: z,
		scoringInstance: G,
		panelState: D,
		snapshotPreview: E,
		collabWarning: T,
		showSaveModuleDialog: H,
		showModuleBrowserModal: W,
		saveModulePreSelectedBlockId: U,
		onSaveHook: p,
		initialize: J,
		destroy: ae,
		setThemeOverrides: q,
		setUiTheme: ie,
		openCommentsForBlock: K
	};
}
//#endregion
//#region src/utils/preRenderCustomBlocks.ts
async function Le(e, t) {
	let n = async (e) => {
		if (A(e)) {
			let n = e;
			try {
				n.renderedHtml = await t.renderCustomBlock(n);
			} catch {
				n.renderedHtml = `<!-- Custom block render error: ${n.customType} -->`;
			}
		}
		if (e.type === "section" && "children" in e) {
			let t = e;
			for (let e of t.children) for (let t of e) await n(t);
		}
	};
	for (let t of e.blocks) await n(t);
}
//#endregion
//#region src/cloud/composables/useCloudLifecycle.ts
function Re(e) {
	let { config: t, editor: n, websocket: r, planConfigInstance: i, snapshotPreview: a, core: o, exporter: s, featureFlags: c, isDestroyed: l } = e;
	function u() {
		return Te(i.config.value.websocket);
	}
	async function d(e) {
		let i = await n.create(e);
		return l() ? i : (t.onCreate?.(i), a.initSnapshotHistory(), r.connect(i.id, u()), i);
	}
	async function f(e) {
		let i = await n.load(e);
		return l() ? i : (t.onLoad?.(i), a.initSnapshotHistory(), r.connect(i.id, u()), i);
	}
	async function p() {
		c.isSaveExporting.value = !0, c.saveStatus.value = "idle";
		try {
			if (await Le(n.content.value, o.registry), l()) throw Error("Component unmounted during save");
			let e = await n.save();
			if (l()) throw Error("Component unmounted during save");
			a.initSnapshotHistory(), a.snapshotHistoryInstance.value?.loadSnapshots();
			let r = await s.exportHtml(e.id);
			if (l()) throw Error("Component unmounted during save");
			let i = {
				templateId: e.id,
				html: r.html,
				mjml: r.mjml,
				content: e.content
			};
			return t.onSave?.(i), c.saveStatus.value = "saved", c.startSaveStatusClear(), i;
		} catch (e) {
			throw l() || (c.saveStatus.value = "error", c.saveErrorMessage.value = e instanceof Error ? e.message : "Save failed"), e;
		} finally {
			l() || (c.isSaveExporting.value = !1);
		}
	}
	return {
		createTemplate: d,
		loadTemplate: f,
		saveTemplate: p
	};
}
//#endregion
//#region src/cloud/composables/useCloudSaveGate.ts
function ze(e) {
	let t = o(!1), n = null, r = d(() => e.planConfig.value?.accessibility?.blockOnError === !0), i = d(() => r.value ? e.issues.value.filter((e) => e.severity === "error") : []), a = d(() => i.value.length > 0);
	async function s(e) {
		return a.value ? (n = e, t.value = !0, !1) : (await e(), !0);
	}
	async function c() {
		let e = n;
		n = null, t.value = !1, e && await e();
	}
	function l() {
		n = null, t.value = !1;
	}
	return {
		shouldBlock: a,
		blockingIssues: i,
		modalOpen: t,
		tryRunSave: s,
		confirmAndSave: c,
		cancel: l
	};
}
//#endregion
//#region src/cloud/components/CloudSaveGateModal.vue?vue&type=script&setup=true&lang.ts
var Be = ["aria-label"], Ve = { class: "tpl:flex tpl:max-h-[80vh] tpl:w-full tpl:max-w-md tpl:flex-col tpl:gap-4 tpl:rounded-lg tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg-elevated)] tpl:p-5 tpl:shadow-[var(--tpl-shadow-md)]" }, He = { class: "tpl:flex tpl:items-center tpl:gap-2" }, Ue = { class: "tpl:m-0 tpl:text-base tpl:font-semibold tpl:text-[var(--tpl-text)]" }, We = { class: "tpl:m-0 tpl:text-sm tpl:text-[var(--tpl-text-muted)]" }, Ge = { class: "tpl:m-0 tpl:flex tpl:max-h-64 tpl:list-none tpl:flex-col tpl:gap-1.5 tpl:overflow-y-auto tpl:rounded-md tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:p-2" }, Ke = { class: "tpl:text-xs tpl:text-[var(--tpl-text)]" }, qe = { class: "tpl:font-mono tpl:text-[10px] tpl:text-[var(--tpl-text-dim)]" }, Je = { class: "tpl:flex tpl:justify-end tpl:gap-2" }, Ye = /* @__PURE__ */ l({
	__name: "CloudSaveGateModal",
	props: {
		open: { type: Boolean },
		issues: {}
	},
	emits: ["cancel", "confirm"],
	setup(t, { emit: n }) {
		let i = n, { t: a } = Q();
		return (n, o) => (e(), x(T, {
			"enter-active-class": "tpl:transition-opacity tpl:duration-150",
			"leave-active-class": "tpl:transition-opacity tpl:duration-150",
			"enter-from-class": "tpl:opacity-0",
			"leave-to-class": "tpl:opacity-0"
		}, {
			default: O(() => [t.open ? (e(), m("div", {
				key: 0,
				role: "dialog",
				"aria-modal": "true",
				"aria-label": C(a).saveGate.title,
				class: "tpl:fixed tpl:inset-0 tpl:z-50 tpl:flex tpl:items-center tpl:justify-center tpl:bg-black/40 tpl:p-6",
				onClick: o[2] ||= u((e) => i("cancel"), ["self"])
			}, [f("div", Ve, [
				f("header", He, [E(C(de), {
					size: 18,
					"stroke-width": 2,
					class: "tpl:text-[var(--tpl-warning)]"
				}), f("h2", Ue, w(C(a).saveGate.title), 1)]),
				f("p", We, w(C(a).saveGate.body), 1),
				f("ul", Ge, [(e(!0), m(_, null, r(t.issues, (t) => (e(), m("li", {
					key: `${t.ruleId}-${t.blockId ?? "template"}`,
					class: "tpl:flex tpl:flex-col tpl:gap-0.5 tpl:rounded tpl:px-2 tpl:py-1.5"
				}, [f("span", Ke, w(t.message), 1), f("span", qe, w(t.ruleId), 1)]))), 128))]),
				f("footer", Je, [f("button", {
					type: "button",
					class: "tpl:rounded-md tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)] tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:text-[var(--tpl-text)]",
					onClick: o[0] ||= (e) => i("cancel")
				}, w(C(a).saveGate.cancel), 1), f("button", {
					type: "button",
					class: "tpl:rounded-md tpl:bg-[var(--tpl-danger)] tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:text-white",
					onClick: o[1] ||= (e) => i("confirm")
				}, w(C(a).saveGate.confirm), 1)])
			])], 8, Be)) : v("", !0)]),
			_: 1
		}));
	}
}), Xe = {
	class: "tpl-header tpl:absolute tpl:top-0 tpl:right-0 tpl:left-0 tpl:z-50 tpl:grid tpl:h-14 tpl:grid-cols-[1fr_auto_1fr] tpl:items-center tpl:px-4",
	style: {
		"background-color": "color-mix(in srgb, var(--tpl-bg) 80%, transparent)",
		"backdrop-filter": "blur(12px)",
		"-webkit-backdrop-filter": "blur(12px)",
		"box-shadow": "var(--tpl-shadow-md)",
		"border-bottom": "1px solid var(--tpl-border)"
	}
}, Ze = { class: "tpl-header-left tpl:flex tpl:min-w-[200px] tpl:items-center tpl:gap-3" }, Qe = {
	key: 0,
	class: "tpl:text-xs tpl:opacity-60 tpl:text-[var(--tpl-text-muted)]"
}, $e = { class: "tpl-header-center tpl:flex tpl:items-center tpl:justify-center tpl:gap-10" }, et = { class: "tpl-header-right tpl:flex tpl:min-w-[200px] tpl:items-center tpl:justify-end tpl:gap-3" }, tt = ["data-tooltip"], nt = {
	key: 1,
	"aria-live": "polite",
	class: "tpl-status tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-xs tpl:text-[var(--tpl-success)]"
}, rt = {
	key: 2,
	"aria-live": "polite",
	class: "tpl-status tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-xs tpl:text-[var(--tpl-text-muted)]"
}, it = ["aria-label", "aria-expanded"], at = {
	key: 0,
	class: "tpl:inline-flex tpl:size-4.5 tpl:items-center tpl:justify-center tpl:rounded-full tpl:text-[10px] tpl:font-semibold tpl:bg-[var(--tpl-primary)] tpl:text-[var(--tpl-bg)]"
}, ot = ["aria-expanded"], st = {
	key: 0,
	class: "tpl:absolute tpl:right-0 tpl:top-full tpl:z-50 tpl:mt-1 tpl:origin-top-right"
}, ct = ["disabled"], lt = ["disabled"], ut = /* @__PURE__ */ l({
	__name: "CloudHeader",
	props: {
		editor: {},
		core: {},
		featureFlags: {},
		panelState: {},
		snapshotPreview: {},
		commentsInstance: {},
		testEmail: {},
		websocket: {},
		collaboration: {},
		isCollaborationEnabled: { type: Boolean },
		isSaveDisabled: { type: Boolean },
		isSaving: { type: Boolean }
	},
	emits: ["save"],
	setup(t) {
		let n = D(() => import("./CollaboratorBar-VZKOv_Zn.js")), r = D(() => import("./SnapshotHistory-C97Iw6xw.js")), i = D(() => import("./AiFeatureMenu-CVHKharv.js")), { t: a, format: o } = Q();
		return (l, d) => (e(), m("header", Xe, [
			f("div", Ze, [t.featureFlags.templateLimit.value === null ? v("", !0) : (e(), m("span", Qe, w(C(o)(C(a).header.templatesUsed, {
				used: t.featureFlags.templateCount.value,
				max: t.featureFlags.templateLimit.value
			})), 1))]),
			f("div", $e, [
				E(q, {
					viewport: t.editor.state.viewport,
					onChange: t.editor.setViewport
				}, null, 8, ["viewport", "onChange"]),
				E(J, {
					"dark-mode": t.editor.state.darkMode,
					onChange: t.editor.setDarkMode
				}, null, 8, ["dark-mode", "onChange"]),
				E(oe, {
					"preview-mode": t.editor.state.previewMode,
					onChange: t.editor.setPreviewMode
				}, null, 8, ["preview-mode", "onChange"]),
				t.collaboration && t.isCollaborationEnabled ? (e(), x(C(n), {
					key: 0,
					collaborators: t.collaboration.collaborators.value,
					"is-connected": t.websocket.isConnected.value
				}, null, 8, ["collaborators", "is-connected"])) : v("", !0),
				t.snapshotPreview.snapshotHistoryInstance.value ? (e(), x(C(r), {
					key: 1,
					snapshots: t.snapshotPreview.snapshotHistorySnapshots.value,
					"is-loading": t.snapshotPreview.snapshotHistoryIsLoading.value,
					"is-restoring": t.snapshotPreview.snapshotHistoryIsRestoring.value,
					onLoad: t.snapshotPreview.loadSnapshotHistory,
					onNavigate: t.snapshotPreview.handleSnapshotNavigate
				}, null, 8, [
					"snapshots",
					"is-loading",
					"is-restoring",
					"onLoad",
					"onNavigate"
				])) : v("", !0)
			]),
			f("div", et, [
				t.featureFlags.saveStatus.value === "error" ? (e(), m("div", {
					key: 0,
					"aria-live": "assertive",
					class: "tpl-tooltip tpl-status tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-xs tpl:text-[var(--tpl-danger)]",
					"data-tooltip": t.featureFlags.saveErrorMessage.value
				}, [E(C(G), {
					size: 12,
					"stroke-width": 2.5
				}), s(" " + w(C(a).header.saveFailed), 1)], 8, tt)) : t.featureFlags.saveStatus.value === "saved" ? (e(), m("div", nt, [E(C(W), {
					size: 12,
					"stroke-width": 2.5
				}), s(" " + w(C(a).header.saved), 1)])) : t.editor.state.isDirty ? (e(), m("div", rt, [d[4] ||= f("span", { class: "tpl-pulse tpl:size-1.5 tpl:rounded-full tpl:bg-[var(--tpl-primary)]" }, null, -1), s(" " + w(C(a).header.unsaved), 1)])) : v("", !0),
				t.commentsInstance.isEnabled.value && t.featureFlags.hasTemplateSaved.value ? (e(), m("button", {
					key: 3,
					"aria-label": t.commentsInstance.unresolvedCount.value > 0 ? `${C(a).comments.button} (${t.commentsInstance.unresolvedCount.value})` : C(a).comments.button,
					"aria-expanded": t.panelState.commentsOpen.value,
					class: c(C($)),
					style: b({
						backgroundColor: t.panelState.commentsOpen.value ? "var(--tpl-primary)" : "transparent",
						color: t.panelState.commentsOpen.value ? "var(--tpl-bg)" : "var(--tpl-primary)",
						borderColor: "var(--tpl-primary)"
					}),
					onClick: d[0] ||= (e) => t.panelState.commentsOpen.value = !t.panelState.commentsOpen.value
				}, [
					E(C(Z), {
						size: 16,
						"stroke-width": 2
					}),
					s(" " + w(C(a).comments.button) + " ", 1),
					t.commentsInstance.unresolvedCount.value > 0 && !t.panelState.commentsOpen.value ? (e(), m("span", at, w(t.commentsInstance.unresolvedCount.value), 1)) : v("", !0)
				], 14, it)) : v("", !0),
				t.featureFlags.canUseAiGeneration.value && t.featureFlags.hasTemplateSaved.value ? (e(), m("div", {
					key: 4,
					ref: (e) => t.panelState.aiMenuRef.value = e,
					class: "tpl:relative"
				}, [f("button", {
					"aria-expanded": t.panelState.aiMenuOpen.value,
					class: c(["tpl-ai-btn tpl:inline-flex tpl:items-center tpl:gap-1.5 tpl:rounded-[var(--tpl-radius-sm)] tpl:border-none tpl:px-4 tpl:py-2 tpl:text-sm tpl:font-semibold tpl:whitespace-nowrap tpl:transition-all tpl:duration-200", t.panelState.aiButtonActive.value ? "tpl-ai-btn--active" : "tpl-ai-btn--idle"]),
					onClick: d[1] ||= u((...e) => t.panelState.toggleAiMenu && t.panelState.toggleAiMenu(...e), ["stop"])
				}, [E(C(ue), {
					size: 16,
					"stroke-width": 2,
					class: "tpl-ai-btn-icon"
				}), s(" " + w(C(a).aiChat.button), 1)], 10, ot), E(T, {
					"enter-active-class": "tpl:transition-all tpl:duration-150 tpl:ease-out",
					"enter-from-class": "tpl:scale-95 tpl:opacity-0",
					"enter-to-class": "tpl:scale-100 tpl:opacity-100",
					"leave-active-class": "tpl:transition-all tpl:duration-100 tpl:ease-in",
					"leave-from-class": "tpl:scale-100 tpl:opacity-100",
					"leave-to-class": "tpl:scale-95 tpl:opacity-0"
				}, {
					default: O(() => [t.panelState.aiMenuOpen.value ? (e(), m("div", st, [E(C(i), {
						"active-feature": t.panelState.activeAiFeature.value,
						onSelect: t.panelState.handleAiFeatureSelect
					}, null, 8, ["active-feature", "onSelect"])])) : v("", !0)]),
					_: 1
				})], 512)) : v("", !0),
				t.testEmail.isEnabled.value && t.featureFlags.canSendTestEmail.value ? (e(), m("button", {
					key: 5,
					class: c(C($)),
					style: {
						"background-color": "transparent",
						color: "var(--tpl-primary)",
						"border-color": "var(--tpl-primary)"
					},
					disabled: t.testEmail.isSending.value || !t.featureFlags.hasTemplateSaved.value,
					onClick: d[2] ||= (e) => t.panelState.testEmailModalOpen.value = !0
				}, [t.testEmail.isSending.value ? (e(), x(C(X), {
					key: 1,
					class: "tpl-spinner",
					size: 16,
					"stroke-width": 2
				})) : (e(), x(C(le), {
					key: 0,
					size: 16,
					"stroke-width": 2
				})), s(" " + w(C(a).testEmail.button), 1)], 10, ct)) : v("", !0),
				f("button", {
					class: c(C($)),
					style: {
						"background-color": "transparent",
						color: "var(--tpl-primary)",
						"border-color": "var(--tpl-primary)"
					},
					disabled: t.isSaveDisabled,
					onClick: d[3] ||= (e) => l.$emit("save")
				}, [t.isSaving ? (e(), x(C(X), {
					key: 1,
					class: "tpl-spinner",
					size: 16,
					"stroke-width": 2
				})) : (e(), x(C(Ae), {
					key: 0,
					size: 16,
					"stroke-width": 2
				})), s(" " + w(t.isSaving ? C(a).header.saving : C(a).header.save), 1)], 10, lt)
			])
		]));
	}
}), dt = /* @__PURE__ */ l({
	__name: "CloudPanels",
	props: {
		config: {},
		editor: {},
		core: {},
		panelState: {},
		planConfigInstance: {},
		testEmail: {},
		mediaLib: {},
		savedModulesHeadless: {},
		showSaveModuleDialog: { type: Boolean },
		saveModulePreSelectedBlockId: {},
		showModuleBrowserModal: { type: Boolean }
	},
	emits: [
		"update:showSaveModuleDialog",
		"update:saveModulePreSelectedBlockId",
		"update:showModuleBrowserModal",
		"send-test-email",
		"module-insert"
	],
	setup(t, { expose: n, emit: r }) {
		let i = D(() => import("./AiChatSidebar-BwLECwsO.js")), a = D(() => import("./CommentsSidebar-BiRtaXYD.js")), s = D(() => import("./DesignReferenceSidebar-Ci9HIGbf.js")), c = D(() => import("./TemplateScoringPanel-V79yrEPC.js")), l = D(() => import("./TestEmailModal-B7S8H-VG.js")), u = D(() => import("./SaveModuleDialog-DGGGNZfm.js")), d = D(() => import("./ModuleBrowserModal-D7IYx1Nh.js")), f = D(async () => {
			try {
				return (await import("@templatical/media-library")).MediaLibraryModal;
			} catch {
				throw Error("[Templatical] Cloud media library requires the optional peer dependency '@templatical/media-library'. Please install it.");
			}
		}), p = r;
		function h(e, t, n) {
			t.history.record(), n.setContent(e), t.conditionPreview.reset();
		}
		function g(e, t) {
			p("module-insert", e, t);
		}
		let y = o(null);
		function b(e) {
			y.value?.filterByBlock(e);
		}
		return n({ filterCommentsByBlock: b }), (n, r) => (e(), m(_, null, [
			E(C(i), {
				visible: t.panelState.aiChatOpen.value,
				"on-apply": (e) => h(e, t.core, t.editor),
				onClose: r[0] ||= (e) => t.panelState.aiChatOpen.value = !1
			}, null, 8, ["visible", "on-apply"]),
			E(C(c), {
				visible: t.panelState.scoringPanelOpen.value,
				onClose: r[1] ||= (e) => t.panelState.scoringPanelOpen.value = !1
			}, null, 8, ["visible"]),
			E(C(s), {
				visible: t.panelState.designReferenceOpen.value,
				"has-existing-blocks": t.editor.content.value.blocks.length > 0,
				onClose: r[2] ||= (e) => t.panelState.designReferenceOpen.value = !1,
				onApply: r[3] ||= (e) => h(e, t.core, t.editor)
			}, null, 8, ["visible", "has-existing-blocks"]),
			E(C(a), {
				ref_key: "commentsSidebar",
				ref: y,
				visible: t.panelState.commentsOpen.value,
				onClose: r[4] ||= (e) => t.panelState.commentsOpen.value = !1
			}, null, 8, ["visible"]),
			E(C(l), {
				visible: t.panelState.testEmailModalOpen.value,
				"allowed-emails": t.testEmail.allowedEmails.value,
				"is-sending": t.testEmail.isSending.value,
				error: t.testEmail.error.value,
				onSend: r[5] ||= (e) => p("send-test-email", e),
				onClose: r[6] ||= (e) => t.panelState.testEmailModalOpen.value = !1
			}, null, 8, [
				"visible",
				"allowed-emails",
				"is-sending",
				"error"
			]),
			t.planConfigInstance.hasFeature("saved_modules") && t.config.modules !== !1 ? (e(), x(C(u), {
				key: 0,
				visible: t.showSaveModuleDialog,
				"pre-selected-block-id": t.saveModulePreSelectedBlockId,
				onClose: r[7] ||= (e) => {
					p("update:showSaveModuleDialog", !1), p("update:saveModulePreSelectedBlockId", null);
				},
				onSaved: r[8] ||= (e) => t.savedModulesHeadless.loadModules()
			}, null, 8, ["visible", "pre-selected-block-id"])) : v("", !0),
			t.planConfigInstance.hasFeature("saved_modules") && t.config.modules !== !1 ? (e(), x(C(d), {
				key: 1,
				visible: t.showModuleBrowserModal,
				onClose: r[9] ||= (e) => p("update:showModuleBrowserModal", !1),
				onInsert: g
			}, null, 8, ["visible"])) : v("", !0),
			E(C(f), {
				visible: t.panelState.mediaLibraryOpen.value,
				accept: t.panelState.mediaLibraryAccept.value,
				"popover-target": t.core.popoverRoot.value,
				onSelect: t.mediaLib.handleMediaSelect,
				onClose: t.mediaLib.handleMediaLibraryClose
			}, null, 8, [
				"visible",
				"accept",
				"popover-target",
				"onSelect",
				"onClose"
			])
		], 64));
	}
}), ft = {
	key: 0,
	class: "tpl-loading tpl:absolute tpl:inset-0 tpl:z-overlay tpl:flex tpl:flex-col tpl:bg-[var(--tpl-bg)]"
}, pt = { class: "tpl:flex tpl:flex-1 tpl:overflow-hidden" }, mt = { class: "tpl:flex tpl:w-12 tpl:shrink-0 tpl:flex-col tpl:items-center tpl:gap-4 tpl:py-5 tpl:border-r tpl:border-[var(--tpl-border)]" }, ht = /* @__PURE__ */ l({
	__name: "CloudLoadingOverlay",
	props: { visible: { type: Boolean } },
	setup(t) {
		return (n, i) => t.visible ? (e(), m("div", ft, [i[1] ||= p("<div class=\"tpl:flex tpl:h-14 tpl:shrink-0 tpl:items-center tpl:justify-between tpl:px-4 tpl:border-b tpl:border-[var(--tpl-border)]\"><div class=\"tpl-shimmer tpl:h-5 tpl:w-28 tpl:rounded-[var(--tpl-radius-sm)]\"></div><div class=\"tpl:flex tpl:gap-3\"><div class=\"tpl-shimmer tpl:h-8 tpl:w-20 tpl:rounded-[var(--tpl-radius-sm)]\"></div><div class=\"tpl-shimmer tpl:h-8 tpl:w-20 tpl:rounded-[var(--tpl-radius-sm)]\"></div></div></div>", 1), f("div", pt, [f("div", mt, [(e(), m(_, null, r(5, (e) => f("div", {
			key: e,
			class: "tpl-shimmer tpl:size-7 tpl:rounded-[var(--tpl-radius-sm)]"
		})), 64))]), i[0] ||= p("<div class=\"tpl:flex tpl:flex-1 tpl:items-start tpl:justify-center tpl:overflow-auto tpl:p-8 tpl:bg-[var(--tpl-canvas-bg)]\"><div class=\"tpl:w-full tpl:max-w-[600px] tpl:rounded-[var(--tpl-radius)] tpl:p-6 tpl:bg-[var(--tpl-bg)] tpl:shadow-[var(--tpl-shadow-sm)]\"><div class=\"tpl:space-y-2 tpl:py-4\"><div class=\"tpl-shimmer tpl:h-3 tpl:w-3/4 tpl:rounded\"></div><div class=\"tpl-shimmer tpl:h-3 tpl:w-full tpl:rounded\"></div><div class=\"tpl-shimmer tpl:h-3 tpl:w-5/6 tpl:rounded\"></div></div><div class=\"tpl:py-4\"><div class=\"tpl-shimmer tpl:h-44 tpl:w-full tpl:rounded-[var(--tpl-radius-sm)]\"></div></div><div class=\"tpl:space-y-2 tpl:py-4\"><div class=\"tpl-shimmer tpl:h-3 tpl:w-full tpl:rounded\"></div><div class=\"tpl-shimmer tpl:h-3 tpl:w-2/3 tpl:rounded\"></div></div><div class=\"tpl:flex tpl:justify-center tpl:py-4\"><div class=\"tpl-shimmer tpl:h-10 tpl:w-36 tpl:rounded-[var(--tpl-radius-sm)]\"></div></div><div class=\"tpl:space-y-2 tpl:py-4\"><div class=\"tpl-shimmer tpl:mx-auto tpl:h-2.5 tpl:w-1/2 tpl:rounded\"></div><div class=\"tpl-shimmer tpl:mx-auto tpl:h-2.5 tpl:w-1/3 tpl:rounded\"></div></div></div></div><div class=\"tpl:flex tpl:w-[320px] tpl:shrink-0 tpl:flex-col tpl:gap-4 tpl:p-4 tpl:border-l tpl:border-[var(--tpl-border)]\"><div class=\"tpl-shimmer tpl:h-8 tpl:rounded-[var(--tpl-radius-sm)]\"></div><div class=\"tpl-shimmer tpl:h-32 tpl:rounded-[var(--tpl-radius)]\"></div><div class=\"tpl-shimmer tpl:h-32 tpl:rounded-[var(--tpl-radius)]\"></div></div>", 2)])])) : v("", !0);
	}
}), gt = {
	key: 0,
	role: "alert",
	class: "tpl-error tpl:absolute tpl:inset-0 tpl:z-overlay tpl:flex tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-6 tpl:px-8 tpl:bg-[var(--tpl-bg)]"
}, _t = { class: "tpl:flex tpl:size-16 tpl:items-center tpl:justify-center tpl:rounded-full tpl:bg-[var(--tpl-danger-light)]" }, vt = { class: "tpl:flex tpl:flex-col tpl:items-center tpl:gap-2 tpl:text-center" }, yt = { class: "tpl:text-lg tpl:font-semibold tpl:text-[var(--tpl-text)]" }, bt = { class: "tpl:max-w-md tpl:text-sm tpl:text-[var(--tpl-text-muted)]" }, xt = /* @__PURE__ */ l({
	__name: "CloudErrorOverlay",
	props: {
		error: {},
		visible: { type: Boolean }
	},
	emits: ["retry"],
	setup(t, { emit: n }) {
		let r = n, { t: i } = Q();
		function a(e) {
			return "isUnauthorized" in e && e.isUnauthorized ? i.error.authFailed : "isNotFound" in e && e.isNotFound ? i.error.templateNotFound : i.error.defaultMessage;
		}
		function o(e) {
			return "isNotFound" in e && !!e.isNotFound;
		}
		return (n, s) => t.visible && t.error ? (e(), m("div", gt, [
			f("div", _t, [E(C(G), {
				size: 32,
				"stroke-width": 1.5,
				class: "tpl:text-[var(--tpl-danger)]"
			})]),
			f("div", vt, [f("h2", yt, w(C(i).error.title), 1), f("p", bt, w(a(t.error)), 1)]),
			o(t.error) ? v("", !0) : (e(), m("button", {
				key: 0,
				class: "tpl-btn tpl-btn-primary tpl:inline-flex tpl:items-center tpl:gap-2 tpl:rounded-md tpl:px-4 tpl:py-2.5 tpl:text-sm tpl:font-medium tpl:shadow-xs tpl:transition-all tpl:duration-150 tpl:hover:opacity-90 tpl:bg-[var(--tpl-primary)] tpl:text-[var(--tpl-bg)]",
				onClick: s[0] ||= (e) => r("retry")
			}, w(C(i).error.retry), 1))
		])) : v("", !0);
	}
}), St = {
	key: 0,
	class: "tpl-preview-banner tpl:absolute tpl:top-14 tpl:right-0 tpl:left-0 tpl:z-40 tpl:flex tpl:items-center tpl:justify-center tpl:gap-4 tpl:px-4 tpl:py-3 tpl:bg-[var(--tpl-primary-light)] tpl:border-b tpl:border-[var(--tpl-primary)]"
}, Ct = { class: "tpl:flex tpl:items-center tpl:gap-2 tpl:text-sm tpl:text-[var(--tpl-text)]" }, wt = { class: "tpl:flex tpl:items-center tpl:gap-2" }, Tt = /* @__PURE__ */ l({
	__name: "SnapshotPreviewBanner",
	props: { visible: { type: Boolean } },
	emits: ["cancel", "confirm"],
	setup(t, { emit: n }) {
		let r = n, { t: i } = Q();
		return (n, a) => t.visible ? (e(), m("div", St, [f("div", Ct, [E(C(Y), {
			size: 18,
			"stroke-width": 2,
			class: "tpl:text-[var(--tpl-primary)]"
		}), f("span", null, w(C(i).snapshotPreview.message), 1)]), f("div", wt, [f("button", {
			class: "tpl:rounded-md tpl:px-3 tpl:py-1.5 tpl:text-sm tpl:font-medium tpl:transition-all tpl:duration-150 tpl:text-[var(--tpl-text-muted)] tpl:border tpl:border-[var(--tpl-border)]",
			style: { "background-color": "transparent" },
			onClick: a[0] ||= (e) => r("cancel")
		}, w(C(i).snapshotPreview.cancel), 1), f("button", {
			class: "tpl:rounded-md tpl:px-3 tpl:py-1.5 tpl:text-sm tpl:font-medium tpl:transition-all tpl:duration-150 tpl:hover:opacity-90 tpl:bg-[var(--tpl-primary)] tpl:text-[var(--tpl-bg)]",
			onClick: a[1] ||= (e) => r("confirm")
		}, w(C(i).snapshotPreview.restore), 1)])])) : v("", !0);
	}
}), Et = {
	key: 0,
	role: "status",
	"aria-live": "polite",
	class: "tpl:absolute tpl:top-16 tpl:left-1/2 tpl:z-toast tpl:-translate-x-1/2 tpl:rounded-[var(--tpl-radius)] tpl:px-4 tpl:py-2.5 tpl:text-sm tpl:shadow-lg",
	style: {
		"background-color": "var(--tpl-warning-light)",
		color: "var(--tpl-text)",
		border: "1px solid var(--tpl-warning)"
	}
}, Dt = /* @__PURE__ */ l({
	__name: "CollabUndoToast",
	props: { visible: { type: Boolean } },
	setup(t) {
		let { t: n } = H();
		return (r, i) => t.visible ? (e(), m("div", Et, w(C(n).history.collabWarning), 1)) : v("", !0);
	}
}), Ot = ["data-tpl-theme"], kt = { class: "tpl:sticky tpl:top-0 tpl:z-40 tpl:h-0" }, At = { class: "tpl-main tpl:flex tpl:justify-center tpl:p-8" }, jt = ["aria-label"], Mt = /* @__PURE__ */ fe(/* @__PURE__ */ l({
	__name: "CloudEditor",
	props: {
		config: {},
		translations: {},
		cloudTranslations: {},
		fontsManager: {},
		shadowRoot: {}
	},
	emits: ["ready"],
	setup(n, { expose: r, emit: a }) {
		let l = n;
		h(z, l.cloudTranslations);
		let u = a, d = o(null), p = Ie({
			config: l.config,
			translations: l.translations,
			fontsManager: l.fontsManager,
			emit: u,
			getCommentsSidebar: () => d.value ? { filterByBlock: d.value.filterCommentsByBlock } : null,
			editorRoot: l.shadowRoot
		}), { isInitializing: _, isAuthReady: S, initError: D, planConfigInstance: k, websocket: A, collaboration: M, isCollaborationEnabled: ee, editor: N, core: P, featureFlags: F, mediaLib: te, exporter: ne, testEmail: I, commentsInstance: L, savedModulesHeadless: R, panelState: B, snapshotPreview: V, collabWarning: H, showSaveModuleDialog: U, showModuleBrowserModal: W, saveModulePreSelectedBlockId: G, setThemeOverrides: re, setUiTheme: q } = p;
		async function J(e) {
			try {
				await I.sendTestEmail(e), B.testEmailModalOpen.value = !1;
			} catch {}
		}
		function oe(e, t) {
			for (let n = 0; n < e.content.length; n++) {
				let r = j(e.content[n]), i = t === void 0 ? void 0 : t + n;
				N.addBlock(r, void 0, void 0, i);
			}
			W.value = !1;
		}
		let Y = Re({
			config: l.config,
			editor: N,
			websocket: A,
			planConfigInstance: k,
			snapshotPreview: V,
			core: P,
			exporter: ne,
			featureFlags: F,
			isDestroyed: p.isDestroyed
		}), X = ze({
			issues: P.accessibilityLint ? P.accessibilityLint.issues : o([]),
			planConfig: k.config
		});
		async function Z() {
			await X.tryRunSave(() => Y.saveTemplate().catch((e) => l.config.onError?.(e)));
		}
		return p.onSaveHook.value = Z, i(() => {
			p.initialize();
		}), g(() => {
			p.destroy();
		}), r({
			getContent: () => N.content.value,
			setContent: (e) => N.setContent(e),
			setTheme: q,
			setThemeOverrides: re,
			create: Y.createTemplate,
			load: Y.loadTemplate,
			save: Y.saveTemplate,
			sendTestEmail: I.sendTestEmail
		}), (r, i) => (e(), m("div", {
			class: c(["tpl tpl:relative tpl:h-full tpl:overflow-hidden", { "tpl:dark": C(N).state.darkMode }]),
			"data-tpl-theme": C(P).resolvedTheme.value,
			style: b(C(P).themeStyles.value)
		}, [
			E(T, {
				"enter-active-class": "tpl:transition-opacity tpl:duration-200",
				"enter-from-class": "tpl:opacity-100",
				"enter-to-class": "tpl:opacity-100",
				"leave-active-class": "tpl:transition-opacity tpl:duration-300",
				"leave-from-class": "tpl:opacity-100",
				"leave-to-class": "tpl:opacity-0"
			}, {
				default: O(() => [E(ht, { visible: C(_) || C(N).state.isLoading }, null, 8, ["visible"])]),
				_: 1
			}),
			E(T, {
				"enter-active-class": "tpl:transition-opacity tpl:duration-200",
				"enter-from-class": "tpl:opacity-0",
				"enter-to-class": "tpl:opacity-100",
				"leave-active-class": "tpl:transition-opacity tpl:duration-300",
				"leave-from-class": "tpl:opacity-100",
				"leave-to-class": "tpl:opacity-0"
			}, {
				default: O(() => [E(xt, {
					error: C(D),
					visible: !!C(D) && !C(_),
					onRetry: C(p).initialize
				}, null, 8, [
					"error",
					"visible",
					"onRetry"
				])]),
				_: 1
			}),
			E(ut, {
				editor: C(N),
				core: C(P),
				"feature-flags": C(F),
				"panel-state": C(B),
				"snapshot-preview": C(V),
				"comments-instance": C(L),
				"test-email": C(I),
				websocket: C(A),
				collaboration: C(M),
				"is-collaboration-enabled": C(ee),
				"is-saving": C(N).state.isSaving || C(F).isSaveExporting.value,
				"is-save-disabled": C(N).state.isSaving || C(F).isSaveExporting.value || !C(N).state.isDirty,
				onSave: Z
			}, null, 8, [
				"editor",
				"core",
				"feature-flags",
				"panel-state",
				"snapshot-preview",
				"comments-instance",
				"test-email",
				"websocket",
				"collaboration",
				"is-collaboration-enabled",
				"is-saving",
				"is-save-disabled"
			]),
			E(Ye, {
				open: C(X).modalOpen.value,
				issues: C(X).blockingIssues.value,
				onCancel: C(X).cancel,
				onConfirm: C(X).confirmAndSave
			}, null, 8, [
				"open",
				"issues",
				"onCancel",
				"onConfirm"
			]),
			E(Tt, {
				visible: C(V).isPreviewingSnapshot.value,
				onCancel: C(V).cancelPreview,
				onConfirm: C(V).confirmRestoreSnapshot
			}, null, 8, [
				"visible",
				"onCancel",
				"onConfirm"
			]),
			E(T, {
				"enter-active-class": "tpl:transition-all tpl:duration-200 tpl:ease-out",
				"enter-from-class": "tpl:translate-y-[-8px] tpl:opacity-0",
				"enter-to-class": "tpl:translate-y-0 tpl:opacity-100",
				"leave-active-class": "tpl:transition-all tpl:duration-300 tpl:ease-in",
				"leave-from-class": "tpl:translate-y-0 tpl:opacity-100",
				"leave-to-class": "tpl:translate-y-[-8px] tpl:opacity-0"
			}, {
				default: O(() => [E(Dt, { visible: C(H).collabUndoWarningVisible.value }, null, 8, ["visible"])]),
				_: 1
			}),
			t(E(ae, null, null, 512), [[y, !C(N).state.previewMode]]),
			f("div", {
				class: c(["tpl-body tpl:absolute tpl:bottom-0 tpl:overflow-auto", [C(N).state.previewMode ? "tpl:left-0 tpl:right-0" : C(B).rightPanelOpen.value ? "tpl:left-12 tpl:right-[680px]" : "tpl:left-12 tpl:right-[320px]", C(V).isPreviewingSnapshot.value ? "tpl:top-[104px]" : "tpl:top-14"]]),
				style: {
					transition: "all 300ms cubic-bezier(0.34, 1.56, 0.64, 1)",
					"background-color": "var(--tpl-canvas-bg)"
				}
			}, [f("div", kt, [E(T, { name: "tpl-restore-btn" }, {
				default: O(() => [C(P).conditionPreview.hasHiddenBlocks.value ? (e(), m("button", {
					key: 0,
					class: "tpl:absolute tpl:left-1/2 tpl:top-2 tpl:-translate-x-1/2 tpl:inline-flex tpl:items-center tpl:gap-1.5 tpl:rounded-full tpl:border tpl:px-3.5 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:whitespace-nowrap tpl:shadow-md tpl:hover:opacity-80",
					style: {
						"background-color": "var(--tpl-warning-light)",
						color: "var(--tpl-warning)",
						"border-color": "var(--tpl-warning)",
						"backdrop-filter": "blur(8px)"
					},
					onClick: i[0] ||= (e) => C(P).conditionPreview.reset()
				}, [E(C(ie), {
					size: 13,
					"stroke-width": 2
				}), s(" " + w(C(P).t.blockSettings.restoreHiddenBlocks), 1)])) : v("", !0)]),
				_: 1
			})]), f("main", At, [E(se, {
				viewport: C(N).state.viewport,
				content: C(N).content.value,
				"selected-block-id": C(N).state.selectedBlockId,
				"dark-mode": C(N).state.darkMode,
				"preview-mode": C(N).state.previewMode,
				"locked-blocks": C(M)?.lockedBlocks.value ?? void 0,
				onSelectBlock: C(N).selectBlock,
				onOpenAiChat: i[1] ||= (e) => C(B).aiChatOpen.value = !0,
				onOpenDesignReference: i[2] ||= (e) => C(B).designReferenceOpen.value = !0
			}, null, 8, [
				"viewport",
				"content",
				"selected-block-id",
				"dark-mode",
				"preview-mode",
				"locked-blocks",
				"onSelectBlock"
			])])], 2),
			n.config.branding !== !1 && !C(F).isWhiteLabeled.value ? (e(), x(ce, {
				key: 0,
				"position-class": [C(N).state.previewMode ? "tpl:left-0 tpl:right-0" : C(B).rightPanelOpen.value ? "tpl:left-12 tpl:right-[680px]" : "tpl:left-12 tpl:right-[320px]"]
			}, null, 8, ["position-class"])) : v("", !0),
			f("div", {
				class: "tpl-sr-only",
				role: "status",
				"aria-live": "polite",
				"aria-atomic": "true",
				"aria-label": C(P).t.landmarks.reorderAnnouncements
			}, w(C(P).keyboardReorder.announcement.value), 9, jt),
			t(E(K, {
				"selected-block": C(N).selectedBlock.value,
				settings: C(N).content.value.settings,
				"shifted-left": C(B).rightPanelOpen.value,
				onUpdateBlock: i[3] ||= (e) => C(N).updateBlock(C(N).selectedBlock.value.id, e),
				onDeleteBlock: i[4] ||= (e) => C(P).blockActions.deleteBlock(C(N).selectedBlock.value.id),
				onDuplicateBlock: i[5] ||= (e) => C(P).blockActions.duplicateBlock(C(N).selectedBlock.value),
				onUpdateSettings: C(N).updateSettings
			}, null, 8, [
				"selected-block",
				"settings",
				"shifted-left",
				"onUpdateSettings"
			]), [[y, !C(N).state.previewMode]]),
			!C(_) && C(S) ? (e(), x(dt, {
				key: 1,
				ref_key: "cloudPanelsRef",
				ref: d,
				config: l.config,
				editor: C(N),
				core: C(P),
				"panel-state": C(B),
				"plan-config-instance": C(k),
				"test-email": C(I),
				"media-lib": C(te),
				"saved-modules-headless": C(R),
				"show-save-module-dialog": C(U),
				"save-module-pre-selected-block-id": C(G),
				"show-module-browser-modal": C(W),
				"onUpdate:showSaveModuleDialog": i[6] ||= (e) => U.value = e,
				"onUpdate:saveModulePreSelectedBlockId": i[7] ||= (e) => G.value = e,
				"onUpdate:showModuleBrowserModal": i[8] ||= (e) => W.value = e,
				onSendTestEmail: J,
				onModuleInsert: oe
			}, null, 8, [
				"config",
				"editor",
				"core",
				"panel-state",
				"plan-config-instance",
				"test-email",
				"media-lib",
				"saved-modules-headless",
				"show-save-module-dialog",
				"save-module-pre-selected-block-id",
				"show-module-browser-modal"
			])) : v("", !0),
			f("div", {
				ref: (e) => C(P).popoverRoot.value = e,
				class: "tpl-popover-root"
			}, null, 512)
		], 14, Ot));
	}
}), [["__scopeId", "data-v-c00ce9ab"]]);
//#endregion
export { Mt as default };
