import{r as p,w as g,a as y,q as L,c as f,b as v,d as S,u as h,h as T,e,t as a,f as b,v as V,g as j,o as l,i as n,F as _,j as k,n as c,l as E,k as N,m as $}from"./app-Dtb5XozN.js";import{_ as A}from"./AdminLayout--JZAX24q.js";const B={class:"flex flex-col sm:flex-row sm:items-center sm:justify-between mb-6 gap-4"},M={class:"text-sm text-gray-500"},R={class:"flex gap-3"},D={class:"bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden"},U={class:"overflow-x-auto"},z={class:"w-full"},H={class:"divide-y divide-gray-100"},O={class:"px-6 py-4 font-mono text-sm text-gray-900"},q={class:"px-6 py-4 text-sm text-gray-600"},I={class:"px-6 py-4"},K={class:"px-6 py-4 text-sm text-gray-500"},G={class:"px-6 py-4 space-x-3"},J=["onClick"],P=["onClick"],Q={key:0,class:"px-6 py-4 border-t border-gray-100 flex items-center justify-between"},W={class:"text-sm text-gray-500"},X={class:"flex gap-2"},ee={__name:"Licenses",props:{licenses:Object,filters:Object,total_licenses:Number},setup(r){const u=r,i=p(u.filters.search||""),d=p(u.filters.status||"");let x;g(i,o=>{clearTimeout(x),x=setTimeout(()=>{y.get("/storesight/admin/licenses",{search:o,status:d.value},{preserveState:!0,replace:!0})},300)}),g(d,o=>{y.get("/storesight/admin/licenses",{search:i.value,status:o},{preserveState:!0,replace:!0})});const m=L({}),w=o=>{confirm("Revoke this license?")&&m.post(`/storesight/admin/licenses/${o}/revoke`)},C=o=>{m.post(`/storesight/admin/licenses/${o}/reinstate`)};return(o,s)=>(l(),f(A,null,{title:v(()=>[...s[2]||(s[2]=[$("Licenses",-1)])]),default:v(()=>[S(h(T),{title:"Licenses - Admin"}),e("div",B,[e("div",null,[s[3]||(s[3]=e("h2",{class:"text-xl font-bold text-gray-900"},"Licenses",-1)),e("p",M,a(r.total_licenses)+" total licenses",1)]),e("div",R,[b(e("input",{"onUpdate:modelValue":s[0]||(s[0]=t=>i.value=t),type:"text",placeholder:"Search license or user...",class:"px-4 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-[#4F46E5] focus:border-[#4F46E5] outline-none w-64"},null,512),[[V,i.value]]),b(e("select",{"onUpdate:modelValue":s[1]||(s[1]=t=>d.value=t),class:"px-4 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-[#4F46E5] outline-none"},[...s[4]||(s[4]=[e("option",{value:""},"All Statuses",-1),e("option",{value:"active"},"Active",-1),e("option",{value:"inactive"},"Inactive",-1),e("option",{value:"revoked"},"Revoked",-1)])],512),[[j,d.value]])])]),e("div",D,[e("div",U,[e("table",z,[s[5]||(s[5]=e("thead",{class:"bg-gray-50"},[e("tr",null,[e("th",{class:"text-left text-xs font-medium text-gray-500 uppercase px-6 py-3"},"License Key"),e("th",{class:"text-left text-xs font-medium text-gray-500 uppercase px-6 py-3"},"User"),e("th",{class:"text-left text-xs font-medium text-gray-500 uppercase px-6 py-3"},"Domain"),e("th",{class:"text-left text-xs font-medium text-gray-500 uppercase px-6 py-3"},"Status"),e("th",{class:"text-left text-xs font-medium text-gray-500 uppercase px-6 py-3"},"Created"),e("th",{class:"text-left text-xs font-medium text-gray-500 uppercase px-6 py-3"},"Actions")])],-1)),e("tbody",H,[(l(!0),n(_,null,k(r.licenses.data,t=>(l(),n("tr",{key:t.id},[e("td",O,a(t.license_key),1),e("td",q,a(t.user_name),1),e("td",{class:c(["px-6 py-4 text-sm",t.domain?"text-gray-600":"text-gray-400"])},a(t.domain||"—"),3),e("td",I,[e("span",{class:c([{"bg-green-100 text-green-800":t.status==="active","bg-gray-100 text-gray-600":t.status==="inactive","bg-red-100 text-red-800":t.status==="revoked"},"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium capitalize"])},a(t.status),3)]),e("td",K,a(t.created_at),1),e("td",G,[t.status!=="revoked"?(l(),n("button",{key:0,onClick:F=>w(t.id),class:"text-sm text-red-500 hover:underline"},"Revoke",8,J)):(l(),n("button",{key:1,onClick:F=>C(t.id),class:"text-sm text-green-600 hover:underline"},"Reinstate",8,P))])]))),128))])])]),r.licenses.last_page>1?(l(),n("div",Q,[e("p",W,"Showing "+a(r.licenses.from)+"-"+a(r.licenses.to)+" of "+a(r.licenses.total),1),e("div",X,[(l(!0),n(_,null,k(r.licenses.links,t=>(l(),f(h(E),{key:t.label,href:t.url||"#",class:c([t.active?"bg-[#4F46E5] text-white":t.url?"bg-white text-gray-700 hover:bg-gray-50":"bg-gray-100 text-gray-400 cursor-not-allowed","px-3 py-1 border border-gray-200 rounded text-sm"]),innerHTML:t.label},null,8,["href","class","innerHTML"]))),128))])])):N("",!0)])]),_:1}))}};export{ee as default};
