import { n as head_default, o as vue_exports, r as link_default, s as router } from "../ssr.js";
import { n as server_renderer_exports, t } from "./i18n-CXLOYfyq.js";
import { t as toast } from "./toast-DMXj7c3P.js";
import { t as AdminLayout_default } from "./AdminLayout-DJaJT5Cr.js";
//#region resources/js/Pages/Admin/ExtensionSettings.vue?vue&type=script&setup=true&lang.ts
var ExtensionSettings_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ (0, vue_exports.defineComponent)({
	__name: "ExtensionSettings",
	__ssrInlineRender: true,
	props: { ext: {} },
	setup(__props) {
		const props = __props;
		const formValues = (0, vue_exports.ref)({ ...props.ext.values });
		const status = (0, vue_exports.ref)("idle");
		let timer = null;
		function save() {
			status.value = "saving";
			router.post("/admin/marketplace/settings", {
				id: props.ext.id,
				values: formValues.value
			}, {
				preserveScroll: true,
				preserveState: true,
				only: [],
				onSuccess: () => {
					status.value = "saved";
					toast(t("Settings saved"));
					setTimeout(() => {
						if (status.value === "saved") status.value = "idle";
					}, 2e3);
				},
				onError: () => {
					status.value = "error";
					toast(t("Couldn't save — will retry"), "error");
				}
			});
		}
		(0, vue_exports.watch)(formValues, () => {
			if (timer) clearTimeout(timer);
			status.value = "saving";
			timer = setTimeout(save, 700);
		}, { deep: true });
		const frame = (0, vue_exports.ref)(null);
		let ro = null;
		function onFrameLoad() {
			const f = frame.value;
			if (!f) return;
			try {
				const doc = f.contentDocument;
				if (!doc) return;
				const cs = getComputedStyle(document.documentElement);
				const tok = (n) => cs.getPropertyValue(n).trim();
				const isDark = (document.documentElement.dataset.theme || document.body.dataset.theme) === "dark";
				const style = doc.createElement("style");
				style.textContent = `
      :root{
        --c-bg:${tok("--c-bg")};--c-surface:${tok("--c-surface")};--c-surface-2:${tok("--c-surface-2")};
        --c-border:${tok("--c-border")};--c-text:${tok("--c-text")};--c-text-2:${tok("--c-text-2")};
        --c-muted:${tok("--c-muted")};--c-primary:${tok("--c-primary")};
        color-scheme:${isDark ? "dark" : "light"};
      }
      .top{display:none!important}
      a[href="/admin/marketplace"]{display:none!important}
      .wrap,.container{max-width:none!important;margin:0!important;padding:18px 20px!important}
      html,body{background:transparent!important;color:rgb(var(--c-text))!important;min-height:0!important}
      h1,h2,h3,h4{color:rgb(var(--c-text))!important}
      .card,.panel,.box,.stat,.tile,.well{background:rgb(var(--c-surface))!important;border-color:rgb(var(--c-border))!important;color:rgb(var(--c-text))!important}
      .sub,.hint,.muted,.meta,.note{color:rgb(var(--c-muted))!important}
      label,.f,.chk,.lbl,legend,th{color:rgb(var(--c-text-2))!important}
      input:not([type=checkbox]):not([type=radio]),textarea,select{background:rgb(var(--c-surface-2))!important;border-color:rgb(var(--c-border))!important;color:rgb(var(--c-text))!important}
      .toggle,.switch,.option-row,.field-row,.input-row{background:rgb(var(--c-surface-2))!important;border-color:rgb(var(--c-border))!important;color:rgb(var(--c-text))!important}
      a:not(.btn){color:rgb(var(--c-primary))!important}
      .btn.ghost{border-color:rgb(var(--c-border))!important;color:rgb(var(--c-text-2))!important}
      table,th,td,hr,.row,.item,.divider{border-color:rgb(var(--c-border))!important}
      ::-webkit-scrollbar{width:0;height:0}
    `;
				doc.head.appendChild(style);
				const isCustomPage = !!doc.querySelector(".top, .wrap, .container");
				const resize = () => {
					try {
						f.style.height = (doc.documentElement.scrollHeight || doc.body.scrollHeight) + "px";
					} catch {}
				};
				if (isCustomPage) {
					f.style.minHeight = "0";
					resize();
					if (doc.body) {
						ro = new ResizeObserver(resize);
						ro.observe(doc.body);
					}
				} else f.style.minHeight = "78vh";
			} catch {
				f.style.minHeight = "78vh";
			}
		}
		(0, vue_exports.onBeforeUnmount)(() => {
			ro?.disconnect();
			ro = null;
		});
		return (_ctx, _push, _parent, _attrs) => {
			_push((0, server_renderer_exports.ssrRenderComponent)(AdminLayout_default, _attrs, {
				title: (0, vue_exports.withCtx)((_, _push, _parent, _scopeId) => {
					if (_push) _push(`${(0, server_renderer_exports.ssrInterpolate)(__props.ext.name)}`);
					else return [(0, vue_exports.createTextVNode)((0, vue_exports.toDisplayString)(__props.ext.name), 1)];
				}),
				subtitle: (0, vue_exports.withCtx)((_, _push, _parent, _scopeId) => {
					if (_push) {
						_push(`${(0, server_renderer_exports.ssrInterpolate)(__props.ext.type === "theme" ? (0, vue_exports.unref)(t)("Theme") : (0, vue_exports.unref)(t)("Extension"))} · v${(0, server_renderer_exports.ssrInterpolate)(__props.ext.version)}`);
						if (__props.ext.author) _push(`<span${_scopeId}> · ${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("by {author}", { author: __props.ext.author }))}</span>`);
						else _push(`<!---->`);
					} else return [(0, vue_exports.createTextVNode)((0, vue_exports.toDisplayString)(__props.ext.type === "theme" ? (0, vue_exports.unref)(t)("Theme") : (0, vue_exports.unref)(t)("Extension")) + " · v" + (0, vue_exports.toDisplayString)(__props.ext.version), 1), __props.ext.author ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", { key: 0 }, " · " + (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("by {author}", { author: __props.ext.author })), 1)) : (0, vue_exports.createCommentVNode)("", true)];
				}),
				default: (0, vue_exports.withCtx)((_, _push, _parent, _scopeId) => {
					if (_push) {
						_push((0, server_renderer_exports.ssrRenderComponent)((0, vue_exports.unref)(head_default), { title: `${__props.ext.name}` }, null, _parent, _scopeId));
						_push(`<div class="mb-4"${_scopeId}>`);
						_push((0, server_renderer_exports.ssrRenderComponent)((0, vue_exports.unref)(link_default), {
							href: "/admin/marketplace",
							class: "inline-flex items-center gap-1.5 text-sm font-semibold text-ink-2 hover:text-ink"
						}, {
							default: (0, vue_exports.withCtx)((_, _push, _parent, _scopeId) => {
								if (_push) _push(`<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"${_scopeId}><path d="M19 12H5M12 19l-7-7 7-7"${_scopeId}></path></svg> ${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Marketplace"))}`);
								else return [((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("svg", {
									width: "15",
									height: "15",
									viewBox: "0 0 24 24",
									fill: "none",
									stroke: "currentColor",
									"stroke-width": "2",
									"stroke-linecap": "round",
									"stroke-linejoin": "round"
								}, [(0, vue_exports.createVNode)("path", { d: "M19 12H5M12 19l-7-7 7-7" })])), (0, vue_exports.createTextVNode)(" " + (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Marketplace")), 1)];
							}),
							_: 1
						}, _parent, _scopeId));
						_push(`</div>`);
						if (__props.ext.adminUrl) _push(`<div class="overflow-hidden rounded-2xl border border-line bg-appbg"${_scopeId}><iframe${(0, server_renderer_exports.ssrRenderAttr)("src", __props.ext.adminUrl + (__props.ext.adminUrl.includes("?") ? "&" : "?") + "embed=1")}${(0, server_renderer_exports.ssrRenderAttr)("title", (0, vue_exports.unref)(t)("Extension settings"))} class="block w-full border-0" style="${(0, server_renderer_exports.ssrRenderStyle)({ "min-height": "60vh" })}"${_scopeId}></iframe></div>`);
						else {
							_push(`<div class="max-w-2xl space-y-5"${_scopeId}><div class="rounded-2xl border border-line bg-surface p-5"${_scopeId}><div class="flex items-start gap-3"${_scopeId}><div class="${(0, server_renderer_exports.ssrRenderClass)([__props.ext.type === "theme" ? "bg-fuchsia-500/15 text-fuchsia-300" : "bg-indigo-500/15 text-indigo-300", "grid h-11 w-11 shrink-0 place-items-center rounded-xl text-lg"])}"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(__props.ext.type === "theme" ? "🎨" : "🧩")}</div><div class="min-w-0 flex-1"${_scopeId}><p class="text-sm text-ink-2"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(__props.ext.description)}</p><div class="mt-2 flex items-center gap-2"${_scopeId}><span class="${(0, server_renderer_exports.ssrRenderClass)([__props.ext.enabled ? "bg-emerald-500/15 text-emerald-300" : "bg-surface-2 text-ink-2", "rounded px-1.5 py-0.5 text-[11px] font-semibold"])}"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(__props.ext.enabled ? (0, vue_exports.unref)(t)("Enabled") : (0, vue_exports.unref)(t)("Disabled"))}</span><span class="text-[11px] text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(__props.ext.id)}</span></div></div></div></div>`);
							if (__props.ext.settings.length) {
								_push(`<form class="rounded-2xl border border-line bg-surface p-5 space-y-4"${_scopeId}><!--[-->`);
								(0, server_renderer_exports.ssrRenderList)(__props.ext.settings, (field) => {
									_push(`<div${_scopeId}>`);
									if (field.type === "boolean") _push(`<label class="flex items-center gap-3"${_scopeId}><input type="checkbox"${(0, server_renderer_exports.ssrIncludeBooleanAttr)(Array.isArray(formValues.value[field.key]) ? (0, server_renderer_exports.ssrLooseContain)(formValues.value[field.key], null) : formValues.value[field.key]) ? " checked" : ""} class="rounded border-line bg-appbg text-indigo-500 focus:ring-indigo-500"${_scopeId}><span class="text-sm font-medium text-ink"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(field.label)}</span></label>`);
									else {
										_push(`<!--[--><label class="block text-sm font-medium text-ink-2"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(field.label)}</label>`);
										if (field.type === "textarea") _push(`<textarea rows="3" class="mt-1.5 w-full rounded-lg border-line bg-appbg text-sm text-ink focus:border-indigo-500 focus:ring-indigo-500"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(formValues.value[field.key])}</textarea>`);
										else if (field.type === "select") {
											_push(`<select class="mt-1.5 w-full rounded-lg border-line bg-appbg text-sm text-ink focus:border-indigo-500 focus:ring-indigo-500"${_scopeId}><!--[-->`);
											(0, server_renderer_exports.ssrRenderList)(field.options || [], (o) => {
												_push(`<option${(0, server_renderer_exports.ssrRenderAttr)("value", o.value)}${(0, server_renderer_exports.ssrIncludeBooleanAttr)(Array.isArray(formValues.value[field.key]) ? (0, server_renderer_exports.ssrLooseContain)(formValues.value[field.key], o.value) : (0, server_renderer_exports.ssrLooseEqual)(formValues.value[field.key], o.value)) ? " selected" : ""}${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(o.label)}</option>`);
											});
											_push(`<!--]--></select>`);
										} else _push(`<input${(0, server_renderer_exports.ssrRenderAttr)("type", field.type === "number" ? "number" : field.type === "color" ? "color" : "text")}${(0, server_renderer_exports.ssrRenderDynamicModel)(field.type === "number" ? "number" : field.type === "color" ? "color" : "text", formValues.value[field.key], null)} class="mt-1.5 w-full rounded-lg border-line bg-appbg text-sm text-ink focus:border-indigo-500 focus:ring-indigo-500"${_scopeId}>`);
										_push(`<!--]-->`);
									}
									if (field.help) _push(`<p class="mt-1 text-xs text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)(field.help)}</p>`);
									else _push(`<!---->`);
									_push(`</div>`);
								});
								_push(`<!--]--><div class="flex items-center gap-2 pt-1 text-sm"${_scopeId}>`);
								if (status.value === "saving") _push(`<span class="text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Saving…"))}</span>`);
								else if (status.value === "saved") _push(`<span class="font-semibold text-emerald-500"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("✓ All changes saved"))}</span>`);
								else if (status.value === "error") _push(`<span class="text-red-500"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Couldn't save — will retry on next change"))}</span>`);
								else _push(`<span class="text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("Changes save automatically"))}</span>`);
								_push(`</div></form>`);
							} else _push(`<p class="rounded-2xl border border-dashed border-line p-8 text-center text-sm text-ink-muted"${_scopeId}>${(0, server_renderer_exports.ssrInterpolate)((0, vue_exports.unref)(t)("This {type} has no configurable settings.", { type: __props.ext.type }))}</p>`);
							_push(`</div>`);
						}
					} else return [
						(0, vue_exports.createVNode)((0, vue_exports.unref)(head_default), { title: `${__props.ext.name}` }, null, 8, ["title"]),
						(0, vue_exports.createVNode)("div", { class: "mb-4" }, [(0, vue_exports.createVNode)((0, vue_exports.unref)(link_default), {
							href: "/admin/marketplace",
							class: "inline-flex items-center gap-1.5 text-sm font-semibold text-ink-2 hover:text-ink"
						}, {
							default: (0, vue_exports.withCtx)(() => [((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("svg", {
								width: "15",
								height: "15",
								viewBox: "0 0 24 24",
								fill: "none",
								stroke: "currentColor",
								"stroke-width": "2",
								"stroke-linecap": "round",
								"stroke-linejoin": "round"
							}, [(0, vue_exports.createVNode)("path", { d: "M19 12H5M12 19l-7-7 7-7" })])), (0, vue_exports.createTextVNode)(" " + (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Marketplace")), 1)]),
							_: 1
						})]),
						__props.ext.adminUrl ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("div", {
							key: 0,
							class: "overflow-hidden rounded-2xl border border-line bg-appbg"
						}, [(0, vue_exports.createVNode)("iframe", {
							ref_key: "frame",
							ref: frame,
							src: __props.ext.adminUrl + (__props.ext.adminUrl.includes("?") ? "&" : "?") + "embed=1",
							title: (0, vue_exports.unref)(t)("Extension settings"),
							class: "block w-full border-0",
							style: { "min-height": "60vh" },
							onLoad: onFrameLoad
						}, null, 40, ["src", "title"])])) : ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("div", {
							key: 1,
							class: "max-w-2xl space-y-5"
						}, [(0, vue_exports.createVNode)("div", { class: "rounded-2xl border border-line bg-surface p-5" }, [(0, vue_exports.createVNode)("div", { class: "flex items-start gap-3" }, [(0, vue_exports.createVNode)("div", { class: ["grid h-11 w-11 shrink-0 place-items-center rounded-xl text-lg", __props.ext.type === "theme" ? "bg-fuchsia-500/15 text-fuchsia-300" : "bg-indigo-500/15 text-indigo-300"] }, (0, vue_exports.toDisplayString)(__props.ext.type === "theme" ? "🎨" : "🧩"), 3), (0, vue_exports.createVNode)("div", { class: "min-w-0 flex-1" }, [(0, vue_exports.createVNode)("p", { class: "text-sm text-ink-2" }, (0, vue_exports.toDisplayString)(__props.ext.description), 1), (0, vue_exports.createVNode)("div", { class: "mt-2 flex items-center gap-2" }, [(0, vue_exports.createVNode)("span", { class: ["rounded px-1.5 py-0.5 text-[11px] font-semibold", __props.ext.enabled ? "bg-emerald-500/15 text-emerald-300" : "bg-surface-2 text-ink-2"] }, (0, vue_exports.toDisplayString)(__props.ext.enabled ? (0, vue_exports.unref)(t)("Enabled") : (0, vue_exports.unref)(t)("Disabled")), 3), (0, vue_exports.createVNode)("span", { class: "text-[11px] text-ink-muted" }, (0, vue_exports.toDisplayString)(__props.ext.id), 1)])])])]), __props.ext.settings.length ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("form", {
							key: 0,
							class: "rounded-2xl border border-line bg-surface p-5 space-y-4",
							onSubmit: (0, vue_exports.withModifiers)(save, ["prevent"])
						}, [((0, vue_exports.openBlock)(true), (0, vue_exports.createBlock)(vue_exports.Fragment, null, (0, vue_exports.renderList)(__props.ext.settings, (field) => {
							return (0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("div", { key: field.key }, [field.type === "boolean" ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("label", {
								key: 0,
								class: "flex items-center gap-3"
							}, [(0, vue_exports.withDirectives)((0, vue_exports.createVNode)("input", {
								type: "checkbox",
								"onUpdate:modelValue": ($event) => formValues.value[field.key] = $event,
								class: "rounded border-line bg-appbg text-indigo-500 focus:ring-indigo-500"
							}, null, 8, ["onUpdate:modelValue"]), [[vue_exports.vModelCheckbox, formValues.value[field.key]]]), (0, vue_exports.createVNode)("span", { class: "text-sm font-medium text-ink" }, (0, vue_exports.toDisplayString)(field.label), 1)])) : ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)(vue_exports.Fragment, { key: 1 }, [(0, vue_exports.createVNode)("label", { class: "block text-sm font-medium text-ink-2" }, (0, vue_exports.toDisplayString)(field.label), 1), field.type === "textarea" ? (0, vue_exports.withDirectives)(((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("textarea", {
								key: 0,
								"onUpdate:modelValue": ($event) => formValues.value[field.key] = $event,
								rows: "3",
								class: "mt-1.5 w-full rounded-lg border-line bg-appbg text-sm text-ink focus:border-indigo-500 focus:ring-indigo-500"
							}, null, 8, ["onUpdate:modelValue"])), [[vue_exports.vModelText, formValues.value[field.key]]]) : field.type === "select" ? (0, vue_exports.withDirectives)(((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("select", {
								key: 1,
								"onUpdate:modelValue": ($event) => formValues.value[field.key] = $event,
								class: "mt-1.5 w-full rounded-lg border-line bg-appbg text-sm text-ink focus:border-indigo-500 focus:ring-indigo-500"
							}, [((0, vue_exports.openBlock)(true), (0, vue_exports.createBlock)(vue_exports.Fragment, null, (0, vue_exports.renderList)(field.options || [], (o) => {
								return (0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("option", {
									key: o.value,
									value: o.value
								}, (0, vue_exports.toDisplayString)(o.label), 9, ["value"]);
							}), 128))], 8, ["onUpdate:modelValue"])), [[vue_exports.vModelSelect, formValues.value[field.key]]]) : (0, vue_exports.withDirectives)(((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("input", {
								key: 2,
								type: field.type === "number" ? "number" : field.type === "color" ? "color" : "text",
								"onUpdate:modelValue": ($event) => formValues.value[field.key] = $event,
								class: "mt-1.5 w-full rounded-lg border-line bg-appbg text-sm text-ink focus:border-indigo-500 focus:ring-indigo-500"
							}, null, 8, ["type", "onUpdate:modelValue"])), [[vue_exports.vModelDynamic, formValues.value[field.key]]])], 64)), field.help ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("p", {
								key: 2,
								class: "mt-1 text-xs text-ink-muted"
							}, (0, vue_exports.toDisplayString)(field.help), 1)) : (0, vue_exports.createCommentVNode)("", true)]);
						}), 128)), (0, vue_exports.createVNode)("div", { class: "flex items-center gap-2 pt-1 text-sm" }, [status.value === "saving" ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", {
							key: 0,
							class: "text-ink-muted"
						}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Saving…")), 1)) : status.value === "saved" ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", {
							key: 1,
							class: "font-semibold text-emerald-500"
						}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("✓ All changes saved")), 1)) : status.value === "error" ? ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", {
							key: 2,
							class: "text-red-500"
						}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Couldn't save — will retry on next change")), 1)) : ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("span", {
							key: 3,
							class: "text-ink-muted"
						}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("Changes save automatically")), 1))])], 32)) : ((0, vue_exports.openBlock)(), (0, vue_exports.createBlock)("p", {
							key: 1,
							class: "rounded-2xl border border-dashed border-line p-8 text-center text-sm text-ink-muted"
						}, (0, vue_exports.toDisplayString)((0, vue_exports.unref)(t)("This {type} has no configurable settings.", { type: __props.ext.type })), 1))]))
					];
				}),
				_: 1
			}, _parent));
		};
	}
});
//#endregion
//#region resources/js/Pages/Admin/ExtensionSettings.vue
var _sfc_setup = ExtensionSettings_vue_vue_type_script_setup_true_lang_default.setup;
ExtensionSettings_vue_vue_type_script_setup_true_lang_default.setup = (props, ctx) => {
	const ssrContext = (0, vue_exports.useSSRContext)();
	(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("resources/js/Pages/Admin/ExtensionSettings.vue");
	return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
var ExtensionSettings_default = ExtensionSettings_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { ExtensionSettings_default as default };
