1import{Q as e,K as t,M as a,P as s,a5 as r,a8 as n,an as i,Z as l,J as d,L as o,u as c,R as m,d as u,U as p,a4 as g,V as x,F as y,X as f,Y as v,a6 as h,W as b}from"./index-BsLsMjlV.js";import{_ as w}from"./AdminLayout-9ounIWk_.js";import{S as k}from"./sortable.esm-Dhe0be67.js";import{r as C}from"./FolderIcon-4G4Y-paQ.js";import{r as j}from"./PlusIcon-DGKfC-wA.js";import{r as _}from"./PencilIcon-Dson-okt.js";import{r as I}from"./TrashIcon-By2yjW2Q.js";import"./Banner-B3VNYRSc.js";import"./ResponsiveNavLink-BKe24OV6.js";function A(s,r){return t(),e("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor","aria-hidden":"true","data-slot":"icon"},[a("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3 7.5 7.5 3m0 0L12 7.5M7.5 3v13.5m13.5 0L16.5 21m0 0L12 16.5m4.5 4.5V7.5"})])}const E={class:"flex items-center justify-between gap-4"},L={class:"bg-white overflow-hidden shadow-xl sm:rounded-lg"},N={class:"border-b border-gray-200"},S={class:"flex -mb-px"},M={class:"p-6"},O={key:0},P={key:0,class:"text-center py-12"},B={class:"mt-6"},D={key:1,class:"overflow-x-auto"},F={class:"min-w-full bg-white"},R={class:"divide-y divide-gray-200"},T={class:"py-4 px-4 whitespace-nowrap"},V={class:"text-sm font-medium text-gray-900"},z={key:0,class:"text-sm text-gray-500"},J={class:"py-4 px-4 whitespace-nowrap"},K={key:0,class:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800"},Q={key:1,class:"text-xs text-gray-400"},U={class:"py-4 px-4 whitespace-nowrap text-center text-sm text-gray-600"},W={class:"py-4 px-4 whitespace-nowrap"},X={key:0,class:"px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800"},Y={key:1,class:"px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800"},Z={class:"py-4 px-4 whitespace-nowrap text-sm font-medium"},$={class:"flex items-center justify-end gap-2"},q=["onClick"],G={key:1},H={key:0,class:"text-center py-8"},ee=["data-id"],te={class:"flex items-center justify-between gap-3"},ae={class:"flex items-center min-w-0"},se={class:"cursor-move mr-2 text-gray-400"},re={class:"min-w-0"},ne={class:"font-medium text-gray-900 truncate"},ie={key:0,class:"ml-2 inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-700"},le=["data-id"],de={class:"flex items-center min-w-0"},oe={class:"cursor-move mr-2 text-gray-400"},ce={class:"min-w-0"},me={class:"font-medium text-gray-900 truncate"},ue={key:0,class:"ml-2 inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-700"},pe={__name:"Index",props:{categories:Array},setup(pe){const ge=pe,xe=s("list"),ye=s(ge.categories),fe=s(null),ve=s({}),he=r(()=>{const e=[],t=(a,s=null)=>{a.forEach(a=>{e.push({id:a.id,name:a.name,slug:a.slug,is_active:a.is_active,parentName:s,childrenCount:a.children?a.children.length:0}),a.children&&a.children.length&&t(a.children,a.name)})};return t(ge.categories||[]),e}),be=()=>{fe.value&&new k(fe.value,{animation:200,ghostClass:"ghost",onEnd:we}),Object.keys(ve.value).forEach(e=>{ve.value[e]&&new k(ve.value[e],{animation:200,ghostClass:"ghost",group:"nested",onEnd:we})})};n(()=>{"ordering"===xe.value&&i(be)}),l(xe,e=>{"ordering"===e&&i(()=>setTimeout(be,50))});const we=()=>{const e=Array.from(fe.value.children).map((e,t)=>({id:parseInt(e.dataset.id),order:t,parent_id:null}));Object.keys(ve.value).forEach(t=>{if(ve.value[t]){const a=Array.from(ve.value[t].children).map((e,a)=>({id:parseInt(e.dataset.id),order:a,parent_id:parseInt(t)}));e.push(...a)}}),b.post(route("admin.categories.order"),{categories:e},{preserveScroll:!0})};return(s,r)=>(t(),d(w,{title:"Categories"},{header:o(()=>[a("div",E,[r[3]||(r[3]=a("div",null,[a("h2",{class:"font-semibold text-xl text-gray-800 leading-tight"},"Categories"),a("p",{class:"text-sm text-gray-500 mt-0.5"},"Organize content into a hierarchy")],-1)),u(p(g),{href:s.route("admin.categories.create"),class:"admin-btn admin-btn-add"},{default:o(()=>[u(p(j)),r[2]||(r[2]=x(" Add Category "))]),_:1},8,["href"])])]),default:o(()=>[a("div",L,[a("div",N,[a("nav",S,[a("button",{type:"button",onClick:r[0]||(r[0]=e=>xe.value="list"),class:c(["px-6 py-3 text-sm font-medium border-b-2 transition-colors","list"===xe.value?"border-gray-800 text-gray-800":"border-transparent text-gray-500 hover:text-gray-700"])}," Category List ",2),a("button",{type:"button",onClick:r[1]||(r[1]=e=>xe.value="ordering"),class:c(["px-6 py-3 text-sm font-medium border-b-2 transition-colors","ordering"===xe.value?"border-gray-800 text-gray-800":"border-transparent text-gray-500 hover:text-gray-700"])}," Manage Ordering ",2)])]),a("div",M,["list"===xe.value?(t(),e("div",O,[0===he.value.length?(t(),e("div",P,[u(p(C),{class:"mx-auto h-12 w-12 text-gray-400"}),r[5]||(r[5]=a("h3",{class:"mt-2 text-sm font-medium text-gray-900"},"No categories yet",-1)),r[6]||(r[6]=a("p",{class:"mt-1 text-sm text-gray-500"},"Create your first category to get started.",-1)),a("div",B,[u(p(g),{href:s.route("admin.categories.create"),class:"admin-btn admin-btn-add"},{default:o(()=>[u(p(j)),r[4]||(r[4]=x(" Add Category "))]),_:1},8,["href"])])])):(t(),e("div",D,[a("table",F,[r[9]||(r[9]=a("thead",{class:"bg-gray-100"},[a("tr",null,[a("th",{class:"py-3 px-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"}," Name "),a("th",{class:"py-3 px-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"}," Parent "),a("th",{class:"py-3 px-4 text-center text-xs font-medium text-gray-500 uppercase tracking-wider"}," Sub-categories "),a("th",{class:"py-3 px-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"}," Status "),a("th",{class:"py-3 px-4 text-right text-xs font-medium text-gray-500 uppercase tracking-wider"}," Actions ")])],-1)),a("tbody",R,[(t(!0),e(y,null,f(he.value,n=>(t(),e("tr",{key:n.id},[a("td",T,[a("div",V,v(n.name),1),n.slug?(t(),e("div",z,v(n.slug),1)):m("",!0)]),a("td",J,[n.parentName?(t(),e("span",K,v(n.parentName),1)):(t(),e("span",Q,"â"))]),a("td",U,v(n.childrenCount),1),a("td",W,[n.is_active?(t(),e("span",X," Active ")):(t(),e("span",Y," Inactive "))]),a("td",Z,[a("div",$,[u(p(g),{href:s.route("admin.categories.edit",n.id),class:"admin-btn admin-btn-edit admin-btn-sm"},{default:o(()=>[u(p(_)),r[7]||(r[7]=x(" Edit "))]),_:2},1032,["href"]),a("button",{type:"button",onClick:h(e=>(e=>{confirm(`Are you sure you want to delete "${e.name}"?`)&&b.delete(route("admin.categories.destroy",e.id),{preserveScroll:!0})})(n),["prevent"]),class:"admin-btn admin-btn-delete admin-btn-sm"}
1,[u(p(I)),r[8]||(r[8]=x(" Delete "))],8,q)])])]))),128))])])]))])):m("",!0),"ordering"===xe.value?(t(),e("div",G,[r[11]||(r[11]=a("div",{class:"mb-4 flex justify-between items-center"},[a("div",null,[a("h3",{class:"text-lg font-medium text-gray-900"},"Manage Category Ordering"),a("p",{class:"mt-1 text-sm text-gray-500"},"Drag and drop categories to change their order")])],-1)),0===ye.value.length?(t(),e("div",H,r[10]||(r[10]=[a("p",{class:"text-gray-500"},"No categories to order.",-1)]))):(t(),e("div",{key:1,ref_key:"mainContainer",ref:fe,class:"space-y-2"},[(t(!0),e(y,null,f(ye.value,s=>(t(),e("div",{key:s.id,"data-id":s.id,class:"bg-gray-50 p-4 rounded-lg border border-gray-200"},[a("div",te,[a("div",ae,[a("span",se,[u(p(A),{class:"w-5 h-5"})]),a("div",re,[a("span",ne,v(s.name),1),s.is_active?m("",!0):(t(),e("span",ie," Inactive "))])])]),s.children&&s.children.length?(t(),e("div",{key:0,class:"ml-8 mt-3 space-y-2",ref_for:!0,ref:e=>{e&&(ve.value[s.id]=e)}},[(t(!0),e(y,null,f(s.children,s=>(t(),e("div",{key:s.id,"data-id":s.id,class:"bg-white p-3 rounded-lg border border-gray-200 flex items-center justify-between gap-3"},[a("div",de,[a("span",oe,[u(p(A),{class:"w-5 h-5"})]),a("div",ce,[a("span",me,v(s.name),1),s.is_active?m("",!0):(t(),e("span",ue," Inactive "))])])],8,le))),128))],512)):m("",!0)],8,ee))),128))],512))])):m("",!0)])])]),_:1}))}};export{pe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.