import{I as w}from"./moment-BywspGD9.js";import{S as k,t as v,p as V}from"./SearchInput-C5NjNnwl.js";import{L as C}from"./Layout-DIVdUaBZ.js";import{m as I}from"./mapValues-BykAXOI1.js";import{P as N}from"./Pagination-MejnxKj7.js";import{i as L,Z as y,r as n,c,a as r,b as t,w as l,F as S,j,h as B,o as f,t as d,e as p}from"./app-CK3cEAAe.js";import{_ as H}from"./FlashMessages-ByEdcHWZ.js";const P={metaInfo:{title:"Categories"},components:{SearchInput:k,Icon:w,Pagination:N,Link:L,Head:y},layout:C,props:{title:String,filters:Object,categories:Object},data(){return{form:{search:this.filters.search}}},watch:{form:{deep:!0,handler:v(function(){this.$inertia.get(this.route("categories"),V(this.form),{preserveState:!0})},150)}},methods:{getCategories(){let a=this.categories.data.filter(e=>!e.parent);for(let e=0;e<this.categories.data.length;e++)if(this.categories.data[e].parent){const o=a.findIndex(m=>m.id===this.categories.data[e].parent.id);o>-1&&a.splice(o+1,0,this.categories.data[e])}return a},reset(){this.form=I(this.form,()=>null)}}},D={class:"mb-6 flex justify-between items-center"},F={class:"bg-white rounded-md shadow overflow-x-auto"},O={class:"w-full whitespace-nowrap"},R={class:"border-t px-6 py-4"},E={class:"border-t px-6 py-4"},T={class:"border-t px-6 py-4"},U={class:"border-t w-px px-4"},Z={key:0};function q(a,e,o,m,h,u){const g=n("Head"),_=n("search-input"),i=n("Link"),b=n("icon"),x=n("pagination");return f(),c("div",null,[r(g,{title:a.$t(o.title)},null,8,["title"]),t("div",D,[r(_,{modelValue:h.form.search,"onUpdate:modelValue":e[0]||(e[0]=s=>h.form.search=s),class:"w-full max-w-md mr-4",onReset:u.reset},null,8,["modelValue","onReset"]),r(i,{class:"btn-indigo",href:a.route("categories.create")},{default:l(()=>[t("span",null,d(a.$t("Create New")),1)]),_:1},8,["href"])]),t("div",F,[t("table",O,[t("tbody",null,[e[2]||(e[2]=t("tr",{class:"text-left font-bold"},[t("th",{class:"px-6 pt-6 pb-4"},"Name"),t("th",{class:"px-6 pt-6 pb-4"},"Department"),t("th",{class:"px-6 pt-6 pb-4"},"Parent")],-1)),(f(!0),c(S,null,j(u.getCategories(),s=>(f(),c("tr",{key:s.id,class:"hover:bg-gray-100 focus-within:bg-gray-100"},[t("td",R,[r(i,{class:"flex items-center focus:text-indigo-500",href:a.route("categories.edit",s.id)},{default:l(()=>[p(d(s.parent?"   — ":"")+" "+d(s.name),1)]),_:2},1032,["href"])]),t("td",E,[r(i,{class:"flex items-center focus:text-indigo-500",href:a.route("categories.edit",s.id)},{default:l(()=>[p(d(s.department?s.department.name:"-"),1)]),_:2},1032,["href"])]),t("td",T,[r(i,{class:"flex items-center focus:text-indigo-500",href:a.route("categories.edit",s.id)},{default:l(()=>[p(d(s.parent?s.parent.name:"-"),1)]),_:2},1032,["href"])]),t("td",U,[r(i,{class:"flex items-center",href:a.route("categories.edit",s.id),tabindex:"-1"},{default:l(()=>[r(b,{name:"cheveron-right",class:"block w-6 h-6 fill-gray-400"})]),_:2},1032,["href"])])]))),128)),o.categories.data.length===0?(f(),c("tr",Z,e[1]||(e[1]=[t("td",{class:"border-t px-6 py-4",colspan:"4"},"No categories found.",-1)]))):B("",!0)])])]),r(x,{class:"mt-6",links:o.categories.links},null,8,["links"])])}const W=H(P,[["render",q]]);export{W as default};
