import{jsxs as r,jsx as e}from"react/jsx-runtime";import{B as F}from"./button-BvFBRYHq.js";import{C as L,b as H,c as M,a as _}from"./card-Zg0WOx-j.js";import{T as j,a as w,b as A,c as o}from"./table-BrXe3s2z.js";import{A as B}from"./layout-CssQHtfO.js";import{Head as P,router as f}from"@inertiajs/react";import{Plus as E}from"lucide-react";import{useState as i,useEffect as G,useCallback as R}from"react";import{CreateShopItemDialog as q}from"./CreateShopItemDialog-CIcAUHIh.js";import{DeleteShopItemDialog as z}from"./DeleteShopItemDialog-BoBbaosy.js";import{ShopItemsTable as J}from"./ShopItemsTable-B_0EyWr8.js";import{u as K,a as Q}from"./useItemNameLookup-i1Z88vba.js";import"@radix-ui/react-slot";import"class-variance-authority";import"./utils-CMbmcP35.js";import"clsx";import"tailwind-merge";import"./app-sidebar-header-BX2s-HO_.js";import"@radix-ui/react-collapsible";import"./dropdown-menu-BP80qPHw.js";import"@radix-ui/react-dropdown-menu";import"./app-logo-icon-beRg1XGs.js";import"./fonts-CqawFh47.js";import"@radix-ui/react-dialog";import"@radix-ui/react-tooltip";import"@radix-ui/react-avatar";import"../app.js";/* empty css     */import"axios";import"sonner";import"react-dom/client";import"./toaster-DuLpwsc2.js";import"./dialog-BfGkTFdF.js";import"./input-qMvM9qch.js";import"./label-DMnntKPk.js";import"@radix-ui/react-label";import"./select-DfhewM4T.js";import"@radix-ui/react-select";import"./TemplateSelect-DfGd1_U3.js";import"./alert-dialog-xorwy8s8.js";import"@radix-ui/react-alert-dialog";import"./badge-CFi7bqqA.js";import"./shop-helpers-CW6YR2iv.js";const U=[{title:"Dashboard",href:"/admin"},{title:"Shop Management",href:"/admin/shop"}];function Re({items:n,masks:d}){const[g,S]=i(n),[C,m]=i(!1),[I,a]=i(!1),[s,c]=i(null),{formData:D,errors:h,isLoading:u,setFormData:l,handleCreate:b,resetForm:N}=K(),{itemName:T,isLoadingItemName:x,fetchItemName:p,resetItemName:O}=Q();G(()=>{S(n)},[n]);const k=()=>{N(),O(),m(!0)},y=R(t=>{t&&(l(v=>({...v,item_id:String(t.item_id),count:String(t.count),octet:t.octet||"",mask:String(t.mask),proctype:String(t.proctype)})),p(String(t.item_id)))},[l,p]);return r(B,{breadcrumbs:U,children:[e(P,{title:"Shop Management"}),r("div",{className:"space-y-6",children:[r("div",{className:"flex items-center justify-between",children:[e("h1",{className:"text-2xl font-bold",children:"Shop Management"}),r(F,{onClick:k,children:[e(E,{className:"h-4 w-4"}),e("span",{className:"ml-2 hidden md:inline",children:"Create Item"})]})]}),r(L,{children:[e(H,{children:e(M,{children:"Shop Items"})}),e(_,{children:e("div",{className:"rounded-md border",children:r(j,{children:[e(w,{children:r(A,{children:[e(o,{children:"ID"}),e(o,{children:"Item Name"}),e(o,{children:"Description"}),e(o,{children:"Count"}),e(o,{children:"Price (Gold)"}),e(o,{children:"Mask"}),e(o,{children:"Status"}),e(o,{className:"text-right",children:"Actions"})]})}),e(J,{items:g,masks:d,onToggle:t=>{f.post(route("admin.shop.toggle",t.id),{},{preserveScroll:!0})},onDelete:t=>{c(t),a(!0)}})]})})})]})]}),e(q,{isOpen:C,onOpenChange:m,formData:D,onFormDataChange:l,masks:d,itemName:T,isLoadingItemName:x,errors:h,isLoading:u,onSubmit:()=>{b(),h.item_id||m(!1)},onTemplateSelect:y,onItemNameLookup:p}),e(z,{isOpen:I,onOpenChange:a,selectedItem:s,isLoading:u,onConfirm:()=>{s&&f.delete(route("admin.shop.destroy",s.id),{preserveScroll:!0,onSuccess:()=>{a(!1),c(null)},onFinish:()=>{}})}})]})}export{Re as default};
