import { t as AdminLayout_default } from "./AdminLayout-DcKfAlG1.js";
import { Head, Link, useForm } from "@inertiajs/vue3";
import { Fragment, createBlock, createCommentVNode, createTextVNode, createVNode, defineComponent, onMounted, openBlock, renderList, toDisplayString, unref, useSSRContext, vModelText, withCtx, withDirectives } from "vue";
import { ssrIncludeBooleanAttr, ssrInterpolate, ssrRenderAttr, ssrRenderClass, ssrRenderComponent, ssrRenderList, ssrRenderStyle } from "vue/server-renderer";
import { ArrowLeft, Save } from "lucide-vue-next";
//#region resources/js/Pages/CafePOS/Opnames/Show.vue?vue&type=script&setup=true&lang.ts
var Show_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
	__name: "Show",
	__ssrInlineRender: true,
	props: {
		opname: {},
		items: {}
	},
	setup(__props) {
		const props = __props;
		const form = useForm({ items: [] });
		onMounted(() => {
			form.items = props.items.map((item) => ({
				id: item.id,
				actual_qty: item.actual_qty
			}));
		});
		const getDifference = (item, index) => {
			const actual = form.items[index]?.actual_qty ?? 0;
			return Number(actual) - Number(item.system_qty);
		};
		const submitOpname = () => {
			if (confirm("Apakah Anda yakin ingin menyelesaikan opname ini? Stok sistem akan diperbarui secara permanen.")) form.post(route("opnames.complete", props.opname.id));
		};
		return (_ctx, _push, _parent, _attrs) => {
			_push(`<!--[-->`);
			_push(ssrRenderComponent(unref(Head), { title: "Audit Stock Opname Detail" }, null, _parent));
			_push(ssrRenderComponent(AdminLayout_default, null, {
				default: withCtx((_, _push, _parent, _scopeId) => {
					if (_push) {
						_push(`<div class="space-y-6"${_scopeId}><div class="flex items-center justify-between gap-4"${_scopeId}><div class="flex items-center gap-3"${_scopeId}>`);
						_push(ssrRenderComponent(unref(Link), {
							href: _ctx.route("opnames.index"),
							class: "p-2 border border-slate-205 dark:border-slate-800 rounded-xl hover:bg-slate-50 dark:hover:bg-slate-800 text-slate-500 hover:text-slate-800 transition-colors"
						}, {
							default: withCtx((_, _push, _parent, _scopeId) => {
								if (_push) _push(ssrRenderComponent(unref(ArrowLeft), { class: "h-4 w-4" }, null, _parent, _scopeId));
								else return [createVNode(unref(ArrowLeft), { class: "h-4 w-4" })];
							}),
							_: 1
						}, _parent, _scopeId));
						_push(`<div${_scopeId}><h1 class="text-xl font-extrabold text-slate-900 dark:text-slate-50 flex items-center gap-2"${_scopeId}><span${_scopeId}>Audit #OPN-${ssrInterpolate(String(__props.opname.id).padStart(4, "0"))}</span><span class="${ssrRenderClass(["px-2 py-0.5 border rounded-full text-[9px] font-extrabold uppercase tracking-wider", __props.opname.status === "draft" ? "bg-amber-500/10 text-amber-600 border-amber-500/20" : "bg-emerald-500/10 text-emerald-600 border-emerald-500/20"])}"${_scopeId}>${ssrInterpolate(__props.opname.status)}</span></h1><p class="text-xs text-slate-400 mt-1"${_scopeId}> Outlet: <span class="font-bold text-slate-600 dark:text-slate-300"${_scopeId}>${ssrInterpolate(__props.opname.outlet?.name)}</span> | Oleh: <span class="font-bold text-slate-600 dark:text-slate-300"${_scopeId}>${ssrInterpolate(__props.opname.user?.name)}</span></p></div></div>`);
						if (__props.opname.status === "draft") {
							_push(`<button${ssrIncludeBooleanAttr(unref(form).processing) ? " disabled" : ""} class="flex items-center justify-center gap-2 px-4 py-2 bg-emerald-600 hover:bg-emerald-500 text-white text-xs font-bold rounded-xl transition-all cursor-pointer shadow-lg shadow-emerald-900/10 disabled:opacity-50"${_scopeId}>`);
							_push(ssrRenderComponent(unref(Save), { class: "h-4 w-4" }, null, _parent, _scopeId));
							_push(` Selesaikan &amp; Rekonsiliasi </button>`);
						} else _push(`<!---->`);
						_push(`</div><div class="bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-2xl shadow-sm overflow-hidden"${_scopeId}><div class="overflow-x-auto"${_scopeId}><table class="w-full text-left border-collapse"${_scopeId}><thead${_scopeId}><tr class="border-b border-slate-100 dark:border-slate-800 bg-slate-50/50 dark:bg-slate-900/50"${_scopeId}><th class="px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider"${_scopeId}>Tipe</th><th class="px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider"${_scopeId}>Nama Item</th><th class="px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider text-right"${_scopeId}>Stok Sistem</th><th class="px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider text-center" style="${ssrRenderStyle({ "width": "160px" })}"${_scopeId}>Stok Fisik Aktif</th><th class="px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider text-right"${_scopeId}>Selisih</th></tr></thead><tbody class="divide-y divide-slate-100 dark:divide-slate-800"${_scopeId}><!--[-->`);
						ssrRenderList(__props.items, (item, index) => {
							_push(`<tr class="hover:bg-slate-50/30 dark:hover:bg-slate-800/10"${_scopeId}><td class="px-6 py-4"${_scopeId}>`);
							if (item.item_type === "Ingredient") _push(`<span class="px-2 py-0.5 border border-[#8c5a3c]/20 bg-[#8c5a3c]/10 text-[#8c5a3c] rounded text-[9px] font-extrabold uppercase"${_scopeId}> Bahan Baku </span>`);
							else _push(`<span class="px-2 py-0.5 border border-indigo-500/20 bg-indigo-500/10 text-indigo-500 rounded text-[9px] font-extrabold uppercase"${_scopeId}> Retail </span>`);
							_push(`</td><td class="px-6 py-4"${_scopeId}><span class="font-extrabold text-xs text-slate-800 dark:text-slate-100"${_scopeId}>${ssrInterpolate(item.name)}</span></td><td class="px-6 py-4 text-xs font-bold text-slate-700 dark:text-slate-300 text-right"${_scopeId}>${ssrInterpolate(item.system_qty)} <span class="text-[10px] text-slate-400 dark:text-slate-500 font-semibold ml-0.5"${_scopeId}>${ssrInterpolate(item.unit)}</span></td><td class="px-6 py-4 text-center"${_scopeId}><div class="flex items-center justify-center gap-1.5"${_scopeId}>`);
							if (__props.opname.status === "draft" && unref(form).items[index]) _push(`<input type="number" step="0.0001"${ssrRenderAttr("value", unref(form).items[index].actual_qty)} class="w-24 text-center h-8 border border-slate-200 dark:border-slate-700 rounded-lg bg-slate-50 dark:bg-slate-800 text-xs font-semibold focus:outline-none focus:ring-2 focus:ring-[#8c5a3c]/20 text-slate-900 dark:text-slate-100"${_scopeId}>`);
							else _push(`<span class="text-xs font-bold text-slate-755 dark:text-slate-200"${_scopeId}>${ssrInterpolate(item.actual_qty)}</span>`);
							_push(`<span class="text-[10px] text-slate-400 dark:text-slate-500 font-semibold"${_scopeId}>${ssrInterpolate(item.unit)}</span></div></td><td class="px-6 py-4 text-right"${_scopeId}><span class="${ssrRenderClass([[getDifference(item, index) > 0 ? "text-emerald-500" : "", getDifference(item, index) < 0 ? "text-rose-500" : "text-slate-400"], "text-xs font-bold animate-in"])}"${_scopeId}>${ssrInterpolate(getDifference(item, index) > 0 ? "+" : "")}${ssrInterpolate(getDifference(item, index).toFixed(2))} <span class="text-[10px] text-slate-400 dark:text-slate-500 font-semibold ml-0.5"${_scopeId}>${ssrInterpolate(item.unit)}</span></span></td></tr>`);
						});
						_push(`<!--]--></tbody></table></div></div></div>`);
					} else return [createVNode("div", { class: "space-y-6" }, [createVNode("div", { class: "flex items-center justify-between gap-4" }, [createVNode("div", { class: "flex items-center gap-3" }, [createVNode(unref(Link), {
						href: _ctx.route("opnames.index"),
						class: "p-2 border border-slate-205 dark:border-slate-800 rounded-xl hover:bg-slate-50 dark:hover:bg-slate-800 text-slate-500 hover:text-slate-800 transition-colors"
					}, {
						default: withCtx(() => [createVNode(unref(ArrowLeft), { class: "h-4 w-4" })]),
						_: 1
					}, 8, ["href"]), createVNode("div", null, [createVNode("h1", { class: "text-xl font-extrabold text-slate-900 dark:text-slate-50 flex items-center gap-2" }, [createVNode("span", null, "Audit #OPN-" + toDisplayString(String(__props.opname.id).padStart(4, "0")), 1), createVNode("span", { class: ["px-2 py-0.5 border rounded-full text-[9px] font-extrabold uppercase tracking-wider", __props.opname.status === "draft" ? "bg-amber-500/10 text-amber-600 border-amber-500/20" : "bg-emerald-500/10 text-emerald-600 border-emerald-500/20"] }, toDisplayString(__props.opname.status), 3)]), createVNode("p", { class: "text-xs text-slate-400 mt-1" }, [
						createTextVNode(" Outlet: "),
						createVNode("span", { class: "font-bold text-slate-600 dark:text-slate-300" }, toDisplayString(__props.opname.outlet?.name), 1),
						createTextVNode(" | Oleh: "),
						createVNode("span", { class: "font-bold text-slate-600 dark:text-slate-300" }, toDisplayString(__props.opname.user?.name), 1)
					])])]), __props.opname.status === "draft" ? (openBlock(), createBlock("button", {
						key: 0,
						onClick: submitOpname,
						disabled: unref(form).processing,
						class: "flex items-center justify-center gap-2 px-4 py-2 bg-emerald-600 hover:bg-emerald-500 text-white text-xs font-bold rounded-xl transition-all cursor-pointer shadow-lg shadow-emerald-900/10 disabled:opacity-50"
					}, [createVNode(unref(Save), { class: "h-4 w-4" }), createTextVNode(" Selesaikan & Rekonsiliasi ")], 8, ["disabled"])) : createCommentVNode("", true)]), createVNode("div", { class: "bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-2xl shadow-sm overflow-hidden" }, [createVNode("div", { class: "overflow-x-auto" }, [createVNode("table", { class: "w-full text-left border-collapse" }, [createVNode("thead", null, [createVNode("tr", { class: "border-b border-slate-100 dark:border-slate-800 bg-slate-50/50 dark:bg-slate-900/50" }, [
						createVNode("th", { class: "px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider" }, "Tipe"),
						createVNode("th", { class: "px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider" }, "Nama Item"),
						createVNode("th", { class: "px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider text-right" }, "Stok Sistem"),
						createVNode("th", {
							class: "px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider text-center",
							style: { "width": "160px" }
						}, "Stok Fisik Aktif"),
						createVNode("th", { class: "px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider text-right" }, "Selisih")
					])]), createVNode("tbody", { class: "divide-y divide-slate-100 dark:divide-slate-800" }, [(openBlock(true), createBlock(Fragment, null, renderList(__props.items, (item, index) => {
						return openBlock(), createBlock("tr", {
							key: item.id,
							class: "hover:bg-slate-50/30 dark:hover:bg-slate-800/10"
						}, [
							createVNode("td", { class: "px-6 py-4" }, [item.item_type === "Ingredient" ? (openBlock(), createBlock("span", {
								key: 0,
								class: "px-2 py-0.5 border border-[#8c5a3c]/20 bg-[#8c5a3c]/10 text-[#8c5a3c] rounded text-[9px] font-extrabold uppercase"
							}, " Bahan Baku ")) : (openBlock(), createBlock("span", {
								key: 1,
								class: "px-2 py-0.5 border border-indigo-500/20 bg-indigo-500/10 text-indigo-500 rounded text-[9px] font-extrabold uppercase"
							}, " Retail "))]),
							createVNode("td", { class: "px-6 py-4" }, [createVNode("span", { class: "font-extrabold text-xs text-slate-800 dark:text-slate-100" }, toDisplayString(item.name), 1)]),
							createVNode("td", { class: "px-6 py-4 text-xs font-bold text-slate-700 dark:text-slate-300 text-right" }, [createTextVNode(toDisplayString(item.system_qty) + " ", 1), createVNode("span", { class: "text-[10px] text-slate-400 dark:text-slate-500 font-semibold ml-0.5" }, toDisplayString(item.unit), 1)]),
							createVNode("td", { class: "px-6 py-4 text-center" }, [createVNode("div", { class: "flex items-center justify-center gap-1.5" }, [__props.opname.status === "draft" && unref(form).items[index] ? withDirectives((openBlock(), createBlock("input", {
								key: 0,
								type: "number",
								step: "0.0001",
								"onUpdate:modelValue": ($event) => unref(form).items[index].actual_qty = $event,
								class: "w-24 text-center h-8 border border-slate-200 dark:border-slate-700 rounded-lg bg-slate-50 dark:bg-slate-800 text-xs font-semibold focus:outline-none focus:ring-2 focus:ring-[#8c5a3c]/20 text-slate-900 dark:text-slate-100"
							}, null, 8, ["onUpdate:modelValue"])), [[vModelText, unref(form).items[index].actual_qty]]) : (openBlock(), createBlock("span", {
								key: 1,
								class: "text-xs font-bold text-slate-755 dark:text-slate-200"
							}, toDisplayString(item.actual_qty), 1)), createVNode("span", { class: "text-[10px] text-slate-400 dark:text-slate-500 font-semibold" }, toDisplayString(item.unit), 1)])]),
							createVNode("td", { class: "px-6 py-4 text-right" }, [createVNode("span", { class: ["text-xs font-bold animate-in", [getDifference(item, index) > 0 ? "text-emerald-500" : "", getDifference(item, index) < 0 ? "text-rose-500" : "text-slate-400"]] }, [createTextVNode(toDisplayString(getDifference(item, index) > 0 ? "+" : "") + toDisplayString(getDifference(item, index).toFixed(2)) + " ", 1), createVNode("span", { class: "text-[10px] text-slate-400 dark:text-slate-500 font-semibold ml-0.5" }, toDisplayString(item.unit), 1)], 2)])
						]);
					}), 128))])])])])])];
				}),
				_: 1
			}, _parent));
			_push(`<!--]-->`);
		};
	}
});
//#endregion
//#region resources/js/Pages/CafePOS/Opnames/Show.vue
var _sfc_setup = Show_vue_vue_type_script_setup_true_lang_default.setup;
Show_vue_vue_type_script_setup_true_lang_default.setup = (props, ctx) => {
	const ssrContext = useSSRContext();
	(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("resources/js/Pages/CafePOS/Opnames/Show.vue");
	return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
var Show_default = Show_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { Show_default as default };
