import { A as e, B as t, D as n, L as r, X as i, _ as a, a as ee, at as te, b as o, d as ne, f as s, h as c, m as l, ot as u, p as re, rt as d, st as f, t as ie, v as p, z as ae } from "./vue.runtime.esm-bundler-Bxqkjqhc.js";
import "./timeouts-BSGxjuUF.js";
import { A as m, i as oe, m as h } from "./keys-B5SJtPWf.js";
import { t as g } from "./createLucideIcon-Di4mqmGn.js";
import { t as se } from "./circle-alert-C0L9pUQ4.js";
import { t as _ } from "./image-up-1D_3XDdO.js";
import { t as v } from "./x-Dlaenqta.js";
import { t as ce } from "./LoadingTrack-CFkDkjBb.js";
import { t as y } from "./_plugin-vue_export-helper-B0hnzhyu.js";
import { n as le } from "./useCloudI18n-ByEMykjO.js";
import { u as ue } from "./cloud-a3VovHva.js";
var de = g("file-image", [
	["path", {
		d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
		key: "1oefj6"
	}],
	["path", {
		d: "M14 2v5a1 1 0 0 0 1 1h5",
		key: "wfsgrz"
	}],
	["circle", {
		cx: "10",
		cy: "12",
		r: "2",
		key: "737tya"
	}],
	["path", {
		d: "m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",
		key: "wt3hpn"
	}]
]), b = g("file-text", [
	["path", {
		d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
		key: "1oefj6"
	}],
	["path", {
		d: "M14 2v5a1 1 0 0 0 1 1h5",
		key: "wfsgrz"
	}],
	["path", {
		d: "M10 9H8",
		key: "b1mrlr"
	}],
	["path", {
		d: "M16 13H8",
		key: "t4e002"
	}],
	["path", {
		d: "M16 17H8",
		key: "z1uh3a"
	}]
]), fe = g("upload", [
	["path", {
		d: "M12 3v12",
		key: "1x0j5s"
	}],
	["path", {
		d: "m17 8-5-5-5 5",
		key: "7q97r8"
	}],
	["path", {
		d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",
		key: "ih7n3h"
	}]
]), pe = {
	key: 0,
	class: "tpl-design-sidebar tpl:absolute tpl:top-14 tpl:right-0 tpl:bottom-0 tpl:z-panel tpl:flex tpl:w-[360px] tpl:flex-col tpl:border-l tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg-elevated)]"
}, me = { class: "tpl:flex tpl:items-center tpl:justify-between tpl:border-b tpl:border-[var(--tpl-border)] tpl:px-4 tpl:py-3" }, he = { class: "tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-sm tpl:font-medium tpl:text-[var(--tpl-primary)]" }, x = { class: "tpl:flex-1 tpl:overflow-y-auto tpl:p-4" }, S = {
	key: 0,
	class: "tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center"
}, C = { class: "tpl:flex tpl:w-full tpl:flex-col tpl:items-center tpl:gap-3" }, w = { class: "tpl:text-sm tpl:text-[var(--tpl-text-muted)]" }, T = {
	key: 1,
	class: "tpl:flex tpl:flex-col tpl:gap-4"
}, E = { class: "tpl:flex tpl:gap-1 tpl:rounded-[var(--tpl-radius-sm)] tpl:p-1 tpl:bg-[var(--tpl-bg-hover)]" }, D = {
	key: 0,
	class: "tpl:flex tpl:flex-col tpl:gap-2"
}, O = { class: "tpl:relative tpl:overflow-hidden tpl:rounded-[var(--tpl-radius)] tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)]" }, k = ["src", "alt"], A = {
	key: 1,
	class: "tpl:flex tpl:h-32 tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-2"
}, j = { class: "tpl:text-xs tpl:text-[var(--tpl-text-muted)]" }, M = { class: "tpl:text-center tpl:text-xs tpl:text-[var(--tpl-text-muted)]" }, N = { class: "tpl:text-center tpl:text-[11px] tpl:text-[var(--tpl-text-dim)]" }, P = ["accept"], F = { class: "tpl:flex tpl:flex-col tpl:gap-1.5" }, I = { class: "tpl:text-xs tpl:font-medium tpl:text-[var(--tpl-text-muted)]" }, L = ["placeholder"], R = {
	key: 0,
	class: "tpl:flex tpl:flex-col tpl:gap-2 tpl:rounded-[var(--tpl-radius)] tpl:px-3 tpl:py-3 tpl:bg-[var(--tpl-warning-light)] tpl:border tpl:border-[var(--tpl-warning)]"
}, ge = { class: "tpl:text-xs tpl:leading-snug tpl:text-[var(--tpl-text)]" }, _e = { class: "tpl:flex tpl:gap-2" }, ve = {
	key: 1,
	class: "tpl:flex tpl:items-start tpl:gap-2 tpl:rounded-lg tpl:px-3 tpl:py-2 tpl:text-xs tpl:bg-[var(--tpl-danger-light)] tpl:text-[var(--tpl-danger)]"
}, ye = ["disabled"], be = { class: "tpl:m-0 tpl:pt-1 tpl:text-center tpl:text-[11px] tpl:text-[var(--tpl-text-dim)]" }, z = /* @__PURE__ */ y(/* @__PURE__ */ o({
	__name: "DesignReferenceSidebar",
	props: {
		visible: { type: Boolean },
		hasExistingBlocks: { type: Boolean }
	},
	emits: ["close", "apply"],
	setup(o, { emit: g }) {
		let y = o, z = g, { t: B } = le(), xe = m(h, "DesignReferenceSidebar"), V = ue({
			authManager: m(oe, "DesignReferenceSidebar"),
			getTemplateId: () => xe.state.template?.id ?? null,
			onApply: (e) => z("apply", e)
		}), H = i(null), U = i("image"), W = i(null), G = i(""), K = i(null), q = i(!1), J = i(!1), Y = ne(() => V.isGenerating.value ? !1 : W.value !== null);
		function X(e) {
			U.value = e, Q();
		}
		function Se(e) {
			let t = e.target, n = t.files?.[0];
			n && Z(n), t.value = "";
		}
		function Z(e) {
			if (e.size > 10485760) {
				V.error.value = B.designReference.fileTooLarge;
				return;
			}
			if (U.value === "image") {
				if (![
					"image/png",
					"image/jpeg",
					"image/jpg",
					"image/webp"
				].includes(e.type)) {
					V.error.value = B.designReference.invalidFileType;
					return;
				}
			} else if (U.value === "pdf" && e.type !== "application/pdf") {
				V.error.value = B.designReference.invalidFileType;
				return;
			}
			W.value = e, V.error.value = null, K.value && URL.revokeObjectURL(K.value), e.type.startsWith("image/") ? K.value = URL.createObjectURL(e) : K.value = null;
		}
		function Q() {
			K.value &&= (URL.revokeObjectURL(K.value), null), W.value = null;
		}
		function Ce(e) {
			e.preventDefault(), J.value = !0;
		}
		function we() {
			J.value = !1;
		}
		function Te(e) {
			e.preventDefault(), J.value = !1;
			let t = e.dataTransfer?.files?.[0];
			t && Z(t);
		}
		function $() {
			if (!Y.value) return;
			if (y.hasExistingBlocks && !q.value) {
				q.value = !0;
				return;
			}
			q.value = !1;
			let e = {};
			G.value.trim() && (e.prompt = G.value.trim()), U.value === "image" && W.value ? e.imageUpload = W.value : U.value === "pdf" && W.value && (e.pdfUpload = W.value), V.generate(e);
		}
		function Ee() {
			q.value = !1;
		}
		return r(() => y.visible, (e) => {
			e || (q.value = !1);
		}), n(() => {
			K.value &&= (URL.revokeObjectURL(K.value), null);
		}), (n, r) => (e(), re(ie, {
			"enter-active-class": "tpl-design-slide-enter-active",
			"enter-from-class": "tpl:translate-x-full",
			"enter-to-class": "tpl:translate-x-0",
			"leave-active-class": "tpl-design-slide-leave-active",
			"leave-from-class": "tpl:translate-x-0",
			"leave-to-class": "tpl:translate-x-full"
		}, {
			default: ae(() => [o.visible ? (e(), c("div", pe, [s("div", me, [s("div", he, [p(d(_), {
				size: 13,
				"stroke-width": 2
			}), s("span", null, f(d(B).designReference.title), 1)]), s("button", {
				class: "tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:duration-150 tpl:text-[var(--tpl-text-muted)]",
				onClick: r[0] ||= (e) => z("close")
			}, [p(d(v), {
				size: 14,
				"stroke-width": 2
			})])]), s("div", x, [d(V).isGenerating.value ? (e(), c("div", S, [s("div", C, [p(ce), s("p", w, f(d(B).designReference.generating), 1)])])) : (e(), c("div", T, [
				s("div", E, [s("button", {
					class: "tpl:flex tpl:flex-1 tpl:items-center tpl:justify-center tpl:gap-1.5 tpl:rounded-[var(--tpl-radius-sm)] tpl:px-2 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150",
					style: u({
						backgroundColor: U.value === "image" ? "var(--tpl-bg)" : "transparent",
						color: U.value === "image" ? "var(--tpl-primary)" : "var(--tpl-text-muted)",
						boxShadow: U.value === "image" ? "var(--tpl-shadow)" : "none"
					}),
					onClick: r[1] ||= (e) => X("image")
				}, [p(d(de), {
					size: 12,
					"stroke-width": 2
				}), a(" " + f(d(B).designReference.uploadImage), 1)], 4), s("button", {
					class: "tpl:flex tpl:flex-1 tpl:items-center tpl:justify-center tpl:gap-1.5 tpl:rounded-[var(--tpl-radius-sm)] tpl:px-2 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150",
					style: u({
						backgroundColor: U.value === "pdf" ? "var(--tpl-bg)" : "transparent",
						color: U.value === "pdf" ? "var(--tpl-primary)" : "var(--tpl-text-muted)",
						boxShadow: U.value === "pdf" ? "var(--tpl-shadow)" : "none"
					}),
					onClick: r[2] ||= (e) => X("pdf")
				}, [p(d(b), {
					size: 12,
					"stroke-width": 2
				}), a(" " + f(d(B).designReference.uploadPdf), 1)], 4)]),
				s("div", null, [W.value ? (e(), c("div", D, [s("div", O, [K.value ? (e(), c("img", {
					key: 0,
					src: K.value,
					alt: W.value.name,
					class: "tpl:h-auto tpl:max-h-48 tpl:w-full tpl:object-contain"
				}, null, 8, k)) : (e(), c("div", A, [p(d(b), {
					size: 32,
					"stroke-width": 1.5,
					class: "tpl:text-[var(--tpl-text-dim)]"
				}), s("span", j, f(W.value.name), 1)])), s("button", {
					class: "tpl:absolute tpl:top-2 tpl:right-2 tpl:rounded-full tpl:p-1 tpl:transition-colors tpl:duration-150 tpl:bg-[var(--tpl-bg)] tpl:text-[var(--tpl-text-muted)] tpl:shadow-[var(--tpl-shadow)]",
					onClick: Q
				}, [p(d(v), {
					size: 12,
					"stroke-width": 2
				})])])])) : (e(), c("div", {
					key: 1,
					class: "tpl-design-dropzone tpl:flex tpl:cursor-pointer tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-2 tpl:rounded-[var(--tpl-radius)] tpl:border-2 tpl:border-dashed tpl:px-4 tpl:py-8 tpl:transition-colors tpl:duration-150",
					style: u({
						borderColor: J.value ? "var(--tpl-primary)" : "var(--tpl-border-light)",
						backgroundColor: J.value ? "var(--tpl-primary-light)" : "var(--tpl-bg)"
					}),
					onClick: r[3] ||= (e) => H.value?.click(),
					onDragover: Ce,
					onDragleave: we,
					onDrop: Te
				}, [
					p(d(fe), {
						size: 24,
						"stroke-width": 1.5,
						class: "tpl:text-[var(--tpl-text-dim)]"
					}),
					s("span", M, f(d(B).designReference.dropHint), 1),
					s("span", N, f(U.value === "image" ? d(B).designReference.acceptedImages : d(B).designReference.acceptedPdf), 1)
				], 36)), s("input", {
					ref_key: "fileInput",
					ref: H,
					type: "file",
					class: "tpl:hidden",
					accept: U.value === "image" ? "image/png,image/jpeg,image/webp" : "application/pdf",
					onChange: Se
				}, null, 40, P)]),
				s("div", F, [s("label", I, f(d(B).designReference.promptLabel), 1), t(s("textarea", {
					"onUpdate:modelValue": r[4] ||= (e) => G.value = e,
					class: te(["tpl:min-h-[72px] tpl:w-full tpl:resize-none tpl:rounded-[var(--tpl-radius-sm)] tpl:border tpl:px-3 tpl:py-2 tpl:font-sans tpl:text-sm tpl:outline-none tpl:transition-colors tpl:duration-150 tpl:border-[var(--tpl-border)] tpl:text-[var(--tpl-text)] tpl:bg-[var(--tpl-bg)]", ["tpl-design-prompt-input"]]),
					placeholder: d(B).designReference.promptPlaceholder,
					rows: "3"
				}, null, 8, L), [[ee, G.value]])]),
				q.value ? (e(), c("div", R, [s("p", ge, f(d(B).designReference.replaceWarning), 1), s("div", _e, [s("button", {
					class: "tpl:flex-1 tpl:rounded-[var(--tpl-radius-sm)] tpl:px-3 tpl:py-1.5 tpl:text-xs 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: Ee
				}, f(d(B).designReference.replaceCancel), 1), s("button", {
					class: "tpl:flex-1 tpl:rounded-[var(--tpl-radius-sm)] tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150 tpl:hover:opacity-90 tpl:bg-[var(--tpl-primary)] tpl:text-[var(--tpl-bg)]",
					onClick: $
				}, f(d(B).designReference.replaceConfirm), 1)])])) : l("", !0),
				d(V).error.value ? (e(), c("div", ve, [p(d(se), {
					size: 14,
					"stroke-width": 2,
					class: "tpl:mt-0.5 tpl:shrink-0"
				}), s("span", null, f(d(B).designReference.error), 1)])) : l("", !0),
				q.value ? l("", !0) : (e(), c("button", {
					key: 2,
					class: "tpl:flex tpl:w-full tpl:items-center tpl:justify-center tpl:gap-2 tpl:rounded-[var(--tpl-radius-sm)] tpl:px-4 tpl:py-2.5 tpl:text-sm tpl:font-medium tpl:transition-all tpl:duration-150 tpl:hover:opacity-90 tpl:disabled:cursor-not-allowed tpl:disabled:opacity-50 tpl:bg-[var(--tpl-primary)] tpl:text-[var(--tpl-bg)]",
					disabled: !Y.value,
					onClick: $
				}, [p(d(_), {
					size: 16,
					"stroke-width": 2
				}), a(" " + f(d(B).designReference.generate), 1)], 8, ye)),
				s("p", be, f(d(B).aiMenu.disclaimer), 1)
			]))])])) : l("", !0)]),
			_: 1
		}));
	}
}), [["__scopeId", "data-v-bdbf8d0d"]]);
//#endregion
export { z as default };
