import { t as AdminLayout_default } from "./AdminLayout-CFTJa237.js";
import { Head, Link, router } from "@inertiajs/vue3";
import { Fragment, createBlock, createCommentVNode, createTextVNode, createVNode, defineComponent, openBlock, ref, renderList, toDisplayString, unref, useSSRContext, vModelSelect, withCtx, withDirectives } from "vue";
import { ssrIncludeBooleanAttr, ssrInterpolate, ssrLooseContain, ssrLooseEqual, ssrRenderAttr, ssrRenderClass, ssrRenderComponent, ssrRenderList } from "vue/server-renderer";
import { Calendar, ClipboardList, Eye, Plus, Store, Trash2, User } from "lucide-vue-next";
//#region resources/js/Pages/CafePOS/Opnames/Index.vue?vue&type=script&setup=true&lang.ts
var Index_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
	__name: "Index",
	__ssrInlineRender: true,
	props: {
		opnames: {},
		outlets: {},
		filters: {}
	},
	setup(__props) {
		const props = __props;
		const selectedOutletId = ref(props.filters.outlet_id || (props.outlets[0] ? String(props.outlets[0].id) : ""));
		const handleFilter = () => {
			router.get(route("opnames.index"), { outlet_id: selectedOutletId.value }, {
				preserveState: true,
				replace: true
			});
		};
		const createOpname = () => {
			if (!selectedOutletId.value) return;
			router.post(route("opnames.store"), { outlet_id: Number(selectedOutletId.value) }, { onSuccess: () => {} });
		};
		const deleteOpname = (opname) => {
			if (confirm("Apakah Anda yakin ingin menghapus draf opname ini?")) router.delete(route("opnames.destroy", opname.id));
		};
		const getStatusBadge = (status) => {
			switch (status) {
				case "draft": return "bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20";
				case "completed": return "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20";
				default: return "bg-slate-500/10 text-slate-600 dark:text-slate-400 border-slate-500/20";
			}
		};
		return (_ctx, _push, _parent, _attrs) => {
			_push(`<!--[-->`);
			_push(ssrRenderComponent(unref(Head), { title: "Stock Opname (Audit Stok)" }, null, _parent));
			_push(ssrRenderComponent(AdminLayout_default, null, {
				default: withCtx((_, _push, _parent, _scopeId) => {
					if (_push) {
						_push(`<div class="space-y-6"${_scopeId}><div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4"${_scopeId}><div${_scopeId}><h1 class="text-2xl font-extrabold text-slate-900 dark:text-slate-55 tracking-tight"${_scopeId}> Stock Opname </h1><p class="text-sm text-slate-500 dark:text-slate-400 mt-1"${_scopeId}> Audit stok bahan baku dan produk retail secara berkala untuk menyesuaikan stok sistem dengan fisik. </p></div><button class="flex items-center justify-center gap-2 px-4 py-2 bg-[#8c5a3c] hover:bg-[#734a31] text-white text-sm font-bold rounded-xl transition-all cursor-pointer shadow-lg shadow-[#8c5a3c]/10"${_scopeId}>`);
						_push(ssrRenderComponent(unref(Plus), { class: "h-4 w-4" }, null, _parent, _scopeId));
						_push(` Mulai Audit Baru (Draf) </button></div><div class="flex flex-wrap items-center justify-between gap-4 bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-2xl px-5 py-4 shadow-sm"${_scopeId}><div class="flex items-center gap-3"${_scopeId}>`);
						_push(ssrRenderComponent(unref(Store), { class: "h-5 w-5 text-slate-400" }, null, _parent, _scopeId));
						_push(`<span class="text-xs font-bold text-slate-500 uppercase tracking-wide"${_scopeId}>Cabang Outlet:</span><select class="h-9 px-3 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 cursor-pointer"${_scopeId}><!--[-->`);
						ssrRenderList(__props.outlets, (ot) => {
							_push(`<option${ssrRenderAttr("value", String(ot.id))}${ssrIncludeBooleanAttr(Array.isArray(selectedOutletId.value) ? ssrLooseContain(selectedOutletId.value, String(ot.id)) : ssrLooseEqual(selectedOutletId.value, String(ot.id))) ? " selected" : ""}${_scopeId}>${ssrInterpolate(ot.name)}</option>`);
						});
						_push(`<!--]--></select></div></div>`);
						if (__props.opnames.data.length > 0) {
							_push(`<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}>ID Audit</th><th class="px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider"${_scopeId}>Outlet</th><th class="px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider"${_scopeId}>Petugas Audit</th><th class="px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider"${_scopeId}>Tanggal Audit</th><th class="px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider"${_scopeId}>Status</th><th class="px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider text-right"${_scopeId}>Aksi</th></tr></thead><tbody class="divide-y divide-slate-100 dark:divide-slate-800"${_scopeId}><!--[-->`);
							ssrRenderList(__props.opnames.data, (op) => {
								_push(`<tr class="hover:bg-slate-50/30 dark:hover:bg-slate-800/10"${_scopeId}><td class="px-6 py-4 text-xs font-bold text-[#8c5a3c]"${_scopeId}> #OPN-${ssrInterpolate(String(op.id).padStart(4, "0"))}</td><td class="px-6 py-4 text-xs font-bold text-slate-700 dark:text-slate-350"${_scopeId}>${ssrInterpolate(op.outlet?.name)}</td><td class="px-6 py-4 text-xs text-slate-600 dark:text-slate-400"${_scopeId}><div class="flex items-center gap-1.5"${_scopeId}>`);
								_push(ssrRenderComponent(unref(User), { class: "h-3.5 w-3.5 text-slate-400" }, null, _parent, _scopeId));
								_push(`<span${_scopeId}>${ssrInterpolate(op.user?.name)}</span></div></td><td class="px-6 py-4 text-[11px] text-slate-400"${_scopeId}><div class="flex items-center gap-1.5"${_scopeId}>`);
								_push(ssrRenderComponent(unref(Calendar), { class: "h-3.5 w-3.5 text-slate-450" }, null, _parent, _scopeId));
								_push(`<span${_scopeId}>${ssrInterpolate(new Date(op.created_at).toLocaleString("id-ID", {
									dateStyle: "medium",
									timeStyle: "short"
								}))}</span></div></td><td class="px-6 py-4"${_scopeId}><span class="${ssrRenderClass(["px-2.5 py-0.5 border rounded-full text-[9px] font-extrabold uppercase tracking-wider", getStatusBadge(op.status)])}"${_scopeId}>${ssrInterpolate(op.status)}</span></td><td class="px-6 py-4 text-right"${_scopeId}><div class="flex items-center justify-end gap-2"${_scopeId}>`);
								_push(ssrRenderComponent(unref(Link), {
									href: _ctx.route("opnames.show", op.id),
									class: "p-1.5 hover:bg-slate-100 dark:hover:bg-slate-800 text-[#8c5a3c] rounded-lg cursor-pointer flex items-center gap-1 text-xs font-bold"
								}, {
									default: withCtx((_, _push, _parent, _scopeId) => {
										if (_push) {
											_push(ssrRenderComponent(unref(Eye), { class: "h-4 w-4" }, null, _parent, _scopeId));
											_push(`<span${_scopeId}>${ssrInterpolate(op.status === "draft" ? "Lakukan Input" : "Lihat")}</span>`);
										} else return [createVNode(unref(Eye), { class: "h-4 w-4" }), createVNode("span", null, toDisplayString(op.status === "draft" ? "Lakukan Input" : "Lihat"), 1)];
									}),
									_: 2
								}, _parent, _scopeId));
								if (op.status === "draft") {
									_push(`<button class="p-1.5 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-500 hover:text-rose-600 rounded-lg cursor-pointer"${_scopeId}>`);
									_push(ssrRenderComponent(unref(Trash2), { class: "h-3.5 w-3.5" }, null, _parent, _scopeId));
									_push(`</button>`);
								} else _push(`<!---->`);
								_push(`</div></td></tr>`);
							});
							_push(`<!--]--></tbody></table></div>`);
							if (__props.opnames.last_page > 1) {
								_push(`<div class="px-6 py-4 border-t border-slate-100 dark:border-slate-800 flex items-center justify-between gap-4"${_scopeId}><span class="text-xs text-slate-500"${_scopeId}>Total ${ssrInterpolate(__props.opnames.total)} audit opname</span><div class="flex items-center gap-2"${_scopeId}><!--[-->`);
								ssrRenderList(__props.opnames.links, (link) => {
									_push(ssrRenderComponent(unref(Link), {
										key: link.label,
										href: link.url || "#",
										class: [
											"px-3 py-1.5 border rounded-lg text-xs font-semibold cursor-pointer",
											link.active ? "bg-[#8c5a3c] text-white border-[#8c5a3c]" : "border-slate-200 dark:border-slate-800 hover:bg-slate-50 dark:hover:bg-slate-800 text-slate-700 dark:text-slate-350",
											!link.url ? "opacity-50 pointer-events-none" : ""
										]
									}, null, _parent, _scopeId));
								});
								_push(`<!--]--></div></div>`);
							} else _push(`<!---->`);
							_push(`</div>`);
						} else {
							_push(`<div class="text-center py-16 bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-2xl shadow-sm"${_scopeId}>`);
							_push(ssrRenderComponent(unref(ClipboardList), { class: "h-10 w-10 text-slate-350 dark:text-slate-655 mx-auto mb-3" }, null, _parent, _scopeId));
							_push(`<h3 class="text-sm font-bold text-slate-800 dark:text-slate-200"${_scopeId}>Belum ada audit stock opname</h3><p class="text-xs text-slate-400 mt-1"${_scopeId}>Gunakan tombol di atas untuk membuat draf stock opname baru di cabang outlet yang dipilih.</p></div>`);
						}
						_push(`</div>`);
					} else return [createVNode("div", { class: "space-y-6" }, [
						createVNode("div", { class: "flex flex-col sm:flex-row sm:items-center justify-between gap-4" }, [createVNode("div", null, [createVNode("h1", { class: "text-2xl font-extrabold text-slate-900 dark:text-slate-55 tracking-tight" }, " Stock Opname "), createVNode("p", { class: "text-sm text-slate-500 dark:text-slate-400 mt-1" }, " Audit stok bahan baku dan produk retail secara berkala untuk menyesuaikan stok sistem dengan fisik. ")]), createVNode("button", {
							onClick: createOpname,
							class: "flex items-center justify-center gap-2 px-4 py-2 bg-[#8c5a3c] hover:bg-[#734a31] text-white text-sm font-bold rounded-xl transition-all cursor-pointer shadow-lg shadow-[#8c5a3c]/10"
						}, [createVNode(unref(Plus), { class: "h-4 w-4" }), createTextVNode(" Mulai Audit Baru (Draf) ")])]),
						createVNode("div", { class: "flex flex-wrap items-center justify-between gap-4 bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-2xl px-5 py-4 shadow-sm" }, [createVNode("div", { class: "flex items-center gap-3" }, [
							createVNode(unref(Store), { class: "h-5 w-5 text-slate-400" }),
							createVNode("span", { class: "text-xs font-bold text-slate-500 uppercase tracking-wide" }, "Cabang Outlet:"),
							withDirectives(createVNode("select", {
								"onUpdate:modelValue": ($event) => selectedOutletId.value = $event,
								onChange: handleFilter,
								class: "h-9 px-3 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 cursor-pointer"
							}, [(openBlock(true), createBlock(Fragment, null, renderList(__props.outlets, (ot) => {
								return openBlock(), createBlock("option", {
									key: ot.id,
									value: String(ot.id)
								}, toDisplayString(ot.name), 9, ["value"]);
							}), 128))], 40, ["onUpdate:modelValue"]), [[vModelSelect, selectedOutletId.value]])
						])]),
						__props.opnames.data.length > 0 ? (openBlock(), createBlock("div", {
							key: 0,
							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" }, "ID Audit"),
							createVNode("th", { class: "px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider" }, "Outlet"),
							createVNode("th", { class: "px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider" }, "Petugas Audit"),
							createVNode("th", { class: "px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider" }, "Tanggal Audit"),
							createVNode("th", { class: "px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider" }, "Status"),
							createVNode("th", { class: "px-6 py-3.5 text-[11px] font-bold text-slate-400 uppercase tracking-wider text-right" }, "Aksi")
						])]), createVNode("tbody", { class: "divide-y divide-slate-100 dark:divide-slate-800" }, [(openBlock(true), createBlock(Fragment, null, renderList(__props.opnames.data, (op) => {
							return openBlock(), createBlock("tr", {
								key: op.id,
								class: "hover:bg-slate-50/30 dark:hover:bg-slate-800/10"
							}, [
								createVNode("td", { class: "px-6 py-4 text-xs font-bold text-[#8c5a3c]" }, " #OPN-" + toDisplayString(String(op.id).padStart(4, "0")), 1),
								createVNode("td", { class: "px-6 py-4 text-xs font-bold text-slate-700 dark:text-slate-350" }, toDisplayString(op.outlet?.name), 1),
								createVNode("td", { class: "px-6 py-4 text-xs text-slate-600 dark:text-slate-400" }, [createVNode("div", { class: "flex items-center gap-1.5" }, [createVNode(unref(User), { class: "h-3.5 w-3.5 text-slate-400" }), createVNode("span", null, toDisplayString(op.user?.name), 1)])]),
								createVNode("td", { class: "px-6 py-4 text-[11px] text-slate-400" }, [createVNode("div", { class: "flex items-center gap-1.5" }, [createVNode(unref(Calendar), { class: "h-3.5 w-3.5 text-slate-450" }), createVNode("span", null, toDisplayString(new Date(op.created_at).toLocaleString("id-ID", {
									dateStyle: "medium",
									timeStyle: "short"
								})), 1)])]),
								createVNode("td", { class: "px-6 py-4" }, [createVNode("span", { class: ["px-2.5 py-0.5 border rounded-full text-[9px] font-extrabold uppercase tracking-wider", getStatusBadge(op.status)] }, toDisplayString(op.status), 3)]),
								createVNode("td", { class: "px-6 py-4 text-right" }, [createVNode("div", { class: "flex items-center justify-end gap-2" }, [createVNode(unref(Link), {
									href: _ctx.route("opnames.show", op.id),
									class: "p-1.5 hover:bg-slate-100 dark:hover:bg-slate-800 text-[#8c5a3c] rounded-lg cursor-pointer flex items-center gap-1 text-xs font-bold"
								}, {
									default: withCtx(() => [createVNode(unref(Eye), { class: "h-4 w-4" }), createVNode("span", null, toDisplayString(op.status === "draft" ? "Lakukan Input" : "Lihat"), 1)]),
									_: 2
								}, 1032, ["href"]), op.status === "draft" ? (openBlock(), createBlock("button", {
									key: 0,
									onClick: ($event) => deleteOpname(op),
									class: "p-1.5 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-500 hover:text-rose-600 rounded-lg cursor-pointer"
								}, [createVNode(unref(Trash2), { class: "h-3.5 w-3.5" })], 8, ["onClick"])) : createCommentVNode("", true)])])
							]);
						}), 128))])])]), __props.opnames.last_page > 1 ? (openBlock(), createBlock("div", {
							key: 0,
							class: "px-6 py-4 border-t border-slate-100 dark:border-slate-800 flex items-center justify-between gap-4"
						}, [createVNode("span", { class: "text-xs text-slate-500" }, "Total " + toDisplayString(__props.opnames.total) + " audit opname", 1), createVNode("div", { class: "flex items-center gap-2" }, [(openBlock(true), createBlock(Fragment, null, renderList(__props.opnames.links, (link) => {
							return openBlock(), createBlock(unref(Link), {
								key: link.label,
								href: link.url || "#",
								class: [
									"px-3 py-1.5 border rounded-lg text-xs font-semibold cursor-pointer",
									link.active ? "bg-[#8c5a3c] text-white border-[#8c5a3c]" : "border-slate-200 dark:border-slate-800 hover:bg-slate-50 dark:hover:bg-slate-800 text-slate-700 dark:text-slate-350",
									!link.url ? "opacity-50 pointer-events-none" : ""
								],
								innerHTML: link.label
							}, null, 8, [
								"href",
								"class",
								"innerHTML"
							]);
						}), 128))])])) : createCommentVNode("", true)])) : (openBlock(), createBlock("div", {
							key: 1,
							class: "text-center py-16 bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-2xl shadow-sm"
						}, [
							createVNode(unref(ClipboardList), { class: "h-10 w-10 text-slate-350 dark:text-slate-655 mx-auto mb-3" }),
							createVNode("h3", { class: "text-sm font-bold text-slate-800 dark:text-slate-200" }, "Belum ada audit stock opname"),
							createVNode("p", { class: "text-xs text-slate-400 mt-1" }, "Gunakan tombol di atas untuk membuat draf stock opname baru di cabang outlet yang dipilih.")
						]))
					])];
				}),
				_: 1
			}, _parent));
			_push(`<!--]-->`);
		};
	}
});
//#endregion
//#region resources/js/Pages/CafePOS/Opnames/Index.vue
var _sfc_setup = Index_vue_vue_type_script_setup_true_lang_default.setup;
Index_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/Index.vue");
	return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
var Index_default = Index_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { Index_default as default };
