import { Dt as e, E as t, L as n, M as r, Mt as i, Ot as a, P as o, Q as s, S as c, V as ee, _ as l, b as u, d, g as f, h as p, it as m, m as h, t as te, y as g, z as ne } from "./vue.runtime.esm-bundler-DpvJL-nX.js";
import { C as re, D as _, _ as ie, p as v } from "./keys-BeW4IrXP.js";
import { n as y, t as b } from "./_plugin-vue_export-helper-GRmvIR5A.js";
import { t as x } from "./chevron-down-SG7QNtDl.js";
import { t as S } from "./circle-alert-De74azaX.js";
import { n as C, r as ae, t as w } from "./refresh-cw-CpmOfpPK.js";
import { t as T } from "./loader-circle-IS16T05j.js";
import { t as E } from "./shield-check-DtXk7JKN.js";
import { t as D } from "./sparkles-CD7TiNiC.js";
import { t as oe } from "./triangle-alert-8CkexIzx.js";
import { t as se } from "./x-BNc1bVzp.js";
import { t as ce } from "./LoadingTrack-DhxulLPM.js";
import { n as le } from "./useCloudI18n-D0Fi0hBU.js";
var O = y("shield-x", [
	["path", {
		d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
		key: "oel41y"
	}],
	["path", {
		d: "m14.5 9.5-5 5",
		key: "17q4r4"
	}],
	["path", {
		d: "m9.5 9.5 5 5",
		key: "18nt4w"
	}]
]), k = y("zap", [["path", {
	d: "M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",
	key: "1xq2db"
}]]);
//#endregion
//#region src/cloud/utils/scoringStyles.ts
function A(e) {
	return e >= 80 ? "var(--tpl-success)" : e >= 60 ? "var(--tpl-warning)" : "var(--tpl-danger)";
}
function j(e) {
	return e >= 80 ? "var(--tpl-success-light)" : e >= 60 ? "var(--tpl-warning-light)" : "var(--tpl-danger-light)";
}
function M(e) {
	return e === "high" ? "var(--tpl-danger)" : e === "medium" ? "var(--tpl-warning)" : "var(--tpl-text-muted)";
}
function N(e) {
	return e === "high" ? "var(--tpl-danger-light)" : e === "medium" ? "var(--tpl-warning-light)" : "var(--tpl-bg-hover)";
}
//#endregion
//#region src/cloud/components/TemplateScoringPanel.vue?vue&type=script&setup=true&lang.ts
var P = {
	key: 0,
	class: "tpl-scoring-panel 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)]"
}, F = { class: "tpl:flex tpl:items-center tpl:justify-between tpl:border-b tpl:border-[var(--tpl-border)] tpl:px-4 tpl:py-3" }, I = { class: "tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-sm tpl:font-medium tpl:text-[var(--tpl-primary)]" }, L = { class: "tpl:flex tpl:items-center tpl:gap-1" }, R = ["title"], z = { class: "tpl:flex-1 tpl:overflow-y-auto tpl:p-4" }, B = {
	key: 0,
	class: "tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center"
}, V = { class: "tpl:text-sm tpl:text-[var(--tpl-text-muted)]" }, H = {
	key: 1,
	class: "tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center"
}, U = { class: "tpl:max-w-[240px] tpl:text-sm tpl:text-[var(--tpl-text-muted)]" }, W = {
	key: 2,
	class: "tpl:flex tpl:flex-col tpl:gap-4"
}, ue = { class: "tpl:text-xs tpl:font-medium tpl:uppercase tpl:tracking-wider tpl:text-[var(--tpl-text-muted)]" }, de = {
	key: 0,
	class: "tpl:text-xs tpl:text-[var(--tpl-text-dim)]"
}, fe = {
	key: 0,
	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)]"
}, pe = ["onClick"], me = { class: "tpl:flex-1 tpl:text-xs tpl:font-medium tpl:text-[var(--tpl-text)]" }, he = {
	key: 0,
	class: "tpl:text-[10px] tpl:text-[var(--tpl-text-dim)]"
}, ge = {
	key: 0,
	class: "tpl:border-t tpl:border-[var(--tpl-border)]"
}, _e = {
	key: 0,
	class: "tpl:px-3 tpl:py-3 tpl:text-center tpl:text-xs tpl:text-[var(--tpl-text-dim)]"
}, ve = { class: "tpl:flex tpl:items-start tpl:gap-2" }, ye = { class: "tpl:flex-1 tpl:min-w-0" }, be = { class: "tpl:flex tpl:items-start tpl:gap-1.5" }, xe = { class: "tpl:text-xs tpl:leading-snug tpl:text-[var(--tpl-text)]" }, Se = {
	key: 0,
	class: "tpl:mt-1 tpl:text-[11px] tpl:leading-snug tpl:text-[var(--tpl-text-dim)]"
}, Ce = {
	key: 1,
	class: "tpl:mt-2 tpl:flex tpl:justify-center"
}, we = ["disabled", "onClick"], Te = {
	key: 0,
	class: "tpl:mt-1.5 tpl:text-[11px] tpl:text-[var(--tpl-danger)]"
}, Ee = {
	key: 3,
	class: "tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center"
}, De = { class: "tpl:max-w-[240px] tpl:text-sm tpl:text-[var(--tpl-text-muted)]" }, Oe = { class: "tpl:m-0 tpl:px-4 tpl:pb-2 tpl:pt-2 tpl:text-center tpl:text-[11px] tpl:text-[var(--tpl-text-dim)]" }, G = /* @__PURE__ */ b(/* @__PURE__ */ c({
	__name: "TemplateScoringPanel",
	props: { visible: { type: Boolean } },
	emits: ["close"],
	setup(c, { emit: y }) {
		let b = c, G = y, { t: K } = le(), q = _(v, "TemplateScoringPanel"), J = _(re, "TemplateScoringPanel"), Y = t(ie, []), X = s({
			spam: !0,
			readability: !0,
			accessibility: !0,
			bestPractices: !0
		});
		function ke(e) {
			X.value[e] = !X.value[e];
		}
		let Z = [
			"spam",
			"readability",
			"accessibility",
			"bestPractices"
		], Ae = {
			spam: O,
			readability: ae,
			accessibility: D,
			bestPractices: k
		};
		function Q() {
			J.score(q.content.value, Y);
		}
		ne(() => b.visible, (e) => {
			e && !J.scoringResult.value && !J.isScoring.value && Q();
		});
		async function je(e) {
			if (!e.blockId) return;
			let t = q.content.value.blocks.find((t) => t.id === e.blockId);
			if (!t) return;
			let n = t.content;
			if (!n) return;
			let r = await J.fixFinding(n, e, Y);
			r && (q.updateBlock(e.blockId, { content: r }), J.removeFinding(e.category, e.id));
		}
		function $() {
			return J.scoringResult.value ? Z.reduce((e, t) => e + (J.scoringResult.value?.categories[t]?.findings.length ?? 0), 0) : 0;
		}
		return (t, s) => (r(), p(te, {
			"enter-active-class": "tpl-scoring-slide-enter-active",
			"enter-from-class": "tpl:translate-x-full",
			"enter-to-class": "tpl:translate-x-0",
			"leave-active-class": "tpl-scoring-slide-leave-active",
			"leave-from-class": "tpl:translate-x-0",
			"leave-to-class": "tpl:translate-x-full"
		}, {
			default: ee(() => [c.visible ? (r(), l("div", P, [h("div", F, [h("div", I, [u(m(E), {
				size: 13,
				"stroke-width": 2
			}), h("span", null, i(m(K).scoring.title), 1)]), h("div", L, [m(J).scoringResult.value && !m(J).isScoring.value ? (r(), l("button", {
				key: 0,
				class: "tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:duration-150 tpl:text-[var(--tpl-text-muted)]",
				title: m(K).scoring.rescore,
				onClick: s[0] ||= (e) => Q()
			}, [u(m(w), {
				size: 14,
				"stroke-width": 2
			})], 8, R)) : f("", !0), h("button", {
				class: "tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:duration-150 tpl:text-[var(--tpl-text-muted)]",
				onClick: s[1] ||= (e) => G("close")
			}, [u(m(se), {
				size: 14,
				"stroke-width": 2
			})])])]), h("div", z, [m(J).isScoring.value ? (r(), l("div", B, [h("p", V, i(m(K).scoring.scoring), 1), u(ce, { class: "tpl:w-3/4" })])) : m(J).error.value && !m(J).scoringResult.value ? (r(), l("div", H, [
				u(m(S), {
					size: 32,
					"stroke-width": 1.5,
					class: "tpl:text-[var(--tpl-danger)]"
				}),
				h("p", U, i(m(K).scoring.error), 1),
				h("button", {
					class: "tpl:mt-2 tpl:inline-flex tpl:items-center tpl:gap-1.5 tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150 tpl:border-[var(--tpl-border)] tpl:text-[var(--tpl-text-muted)]",
					onClick: s[2] ||= (e) => Q()
				}, [u(m(w), {
					size: 12,
					"stroke-width": 2
				}), g(" " + i(m(K).scoring.rescore), 1)])
			])) : m(J).scoringResult.value ? (r(), l("div", W, [
				h("div", {
					class: "tpl:flex tpl:flex-col tpl:items-center tpl:gap-2 tpl:rounded-[var(--tpl-radius)] tpl:p-5",
					style: a({ backgroundColor: m(j)(m(J).scoringResult.value.score) })
				}, [
					h("span", {
						class: "tpl:text-4xl tpl:font-bold tpl:tabular-nums",
						style: a({ color: m(A)(m(J).scoringResult.value.score) })
					}, i(m(J).scoringResult.value.score), 5),
					h("span", ue, i(m(K).scoring.overallScore), 1),
					$() > 0 ? (r(), l("span", de, i($()) + " " + i(m(K).scoring.findings), 1)) : f("", !0)
				], 4),
				m(J).fixError.value ? (r(), l("div", fe, [u(m(S), {
					size: 14,
					"stroke-width": 2,
					class: "tpl:mt-0.5 tpl:shrink-0"
				}), h("span", null, i(m(K).scoring.fixError), 1)])) : f("", !0),
				(r(), l(d, null, o(Z, (t) => h("div", {
					key: t,
					class: "tpl:overflow-hidden tpl:rounded-[var(--tpl-radius)] tpl:border tpl:border-[var(--tpl-border)]"
				}, [h("button", {
					class: "tpl:flex tpl:w-full tpl:cursor-pointer tpl:items-center tpl:gap-2.5 tpl:px-3 tpl:py-2.5 tpl:text-left tpl:transition-colors tpl:duration-100 tpl:bg-[var(--tpl-bg)]",
					onClick: (e) => ke(t)
				}, [
					(r(), p(n(Ae[t]), {
						size: 14,
						"stroke-width": 2,
						style: a({ color: m(A)(m(J).scoringResult.value.categories[t].score) })
					}, null, 8, ["style"])),
					h("span", me, i(m(K).scoring.categories[t]), 1),
					h("span", {
						class: "tpl:rounded-full tpl:px-2 tpl:py-0.5 tpl:text-xs tpl:font-semibold tpl:tabular-nums",
						style: a({
							color: m(A)(m(J).scoringResult.value.categories[t].score),
							backgroundColor: m(j)(m(J).scoringResult.value.categories[t].score)
						})
					}, i(m(J).scoringResult.value.categories[t].score), 5),
					m(J).scoringResult.value.categories[t].findings.length > 0 ? (r(), l("span", he, i(m(J).scoringResult.value.categories[t].findings.length), 1)) : f("", !0),
					u(m(x), {
						size: 12,
						"stroke-width": 2,
						class: e(["tpl:transition-transform tpl:duration-200 tpl:text-[var(--tpl-text-dim)]", X.value[t] ? "tpl:rotate-0" : "tpl:-rotate-90"])
					}, null, 8, ["class"])
				], 8, pe), X.value[t] ? (r(), l("div", ge, [m(J).scoringResult.value.categories[t].findings.length === 0 ? (r(), l("div", _e, i(m(K).scoring.noFindings), 1)) : f("", !0), (r(!0), l(d, null, o(m(J).scoringResult.value.categories[t].findings, (e) => (r(), l("div", {
					key: e.id,
					class: "tpl:border-t tpl:px-3 tpl:py-2.5 first:tpl:border-t-0 tpl:border-[var(--tpl-border-light)]"
				}, [h("div", ve, [(r(), p(n(e.severity === "high" ? m(S) : e.severity === "medium" ? m(oe) : m(C)), {
					size: 13,
					"stroke-width": 2,
					class: "tpl:mt-0.5 tpl:shrink-0",
					style: a({ color: m(M)(e.severity) })
				}, null, 8, ["style"])), h("div", ye, [
					h("div", be, [h("span", {
						class: "tpl:mt-0.5 tpl:shrink-0 tpl:rounded tpl:px-1 tpl:py-px tpl:text-[10px] tpl:font-medium tpl:leading-tight",
						style: a({
							color: m(M)(e.severity),
							backgroundColor: m(N)(e.severity)
						})
					}, i(m(K).scoring.severity[e.severity]), 5), h("span", xe, i(e.message), 1)]),
					e.suggestion ? (r(), l("p", Se, i(e.suggestion), 1)) : f("", !0),
					e.blockId ? (r(), l("div", Ce, [h("button", {
						class: "tpl-scoring-fix-btn tpl:inline-flex tpl:items-center tpl:gap-1.5 tpl:rounded tpl:border tpl:px-3 tpl:py-1.5 tpl:text-[11px] tpl:font-medium tpl:transition-all tpl:duration-150 tpl:disabled:opacity-50 tpl:border-[var(--tpl-border)] tpl:text-[var(--tpl-primary)]",
						style: { "background-color": "transparent" },
						disabled: m(J).fixingFindingId.value !== null,
						onClick: (t) => je(e)
					}, [m(J).fixingFindingId.value === e.id ? (r(), p(m(T), {
						key: 0,
						class: "tpl-spinner",
						size: 11,
						"stroke-width": 2
					})) : (r(), p(m(D), {
						key: 1,
						size: 11,
						"stroke-width": 2
					})), g(" " + i(m(J).fixingFindingId.value === e.id ? m(K).scoring.fixing : m(K).scoring.fix), 1)], 8, we), m(J).fixError.value ? (r(), l("p", Te, i(m(J).fixError.value), 1)) : f("", !0)])) : f("", !0)
				])])]))), 128))])) : f("", !0)])), 64))
			])) : (r(), l("div", Ee, [u(m(E), {
				size: 32,
				"stroke-width": 1.5,
				class: "tpl:text-[var(--tpl-text-dim)]"
			}), h("p", De, i(m(K).scoring.emptyState), 1)])), h("p", Oe, i(m(K).aiMenu.disclaimer), 1)])])) : f("", !0)]),
			_: 1
		}));
	}
}), [["__scopeId", "data-v-3a059e8d"]]);
//#endregion
export { G as default };
