import{_ as N}from"./F47YBxX3.js";import{u as z}from"./B_NqmWCc.js";import{u as M,V as S,a as I,D as P}from"./CThvs1cs.js";import{V as R,D as j}from"./DfcAXvPm.js";import{d as $,r as u,j as k,o as O,t as r,v as p,z as e,Z as a,aU as W,N as v,A as t,O as C,B as V,y as _,x as X,U as w,W as D,X as Y,V as Z,R as b,S as q,P as G,Y as H}from"./D8zG9Ut8.js";import"./DlAUqK2U.js";import"./CcWp78UG.js";import"./Dbpq9kDR.js";const J=$({__name:"ScannersList",setup(h){const i=z(),d=M(),y=u(!0),o=u(!1),c=u(!1),n=u(null),B=[{title:"Name",value:"name",align:"left",width:"10%"},{title:"Endpoint",value:"endpoint",align:"left"},{title:"Actions",value:"actions",align:"center",width:"5%"}],x=[{title:"Edit",action:l=>A(l),icon:"mdi-pencil-outline",color:"primary",divider:!0},{title:"Delete",action:l=>T(l),icon:"mdi-delete",color:"red"}],F=k(()=>i.scanners),L=k(()=>n.value===null?"Are you sure you would like to delete this scanner?":`Are you sure you would like to delete the '${n.value.name}' scanner?`),A=l=>{n.value=l,c.value=!0},E=()=>{c.value=!1,n.value=null},T=l=>{n.value=l,o.value=!0},U=()=>{if(n.value!==null)try{i.deleteScanner(n.value.endpoint),d.reportSuccess("Scanner deleted successfully.")}catch{d.reportError("Failed to delete scanner. Please try again.")}finally{n.value=null}};return O(()=>{y.value=!1}),(l,m)=>(r(),p("div",null,[e(a(j),{"model-value":a(o),"onUpdate:modelValue":m[0]||(m[0]=s=>W(o)?o.value=s:null),title:a(L),"cancel-button-text":"Cancel","confirm-button-text":"Delete","cancel-icon":"mdi-close","confirm-icon":"mdi-check","confirm-button-color":"secondary","card-icon":"mdi-trash-can-outline",onConfirm:U,onCancel:m[1]||(m[1]=s=>n.value=null)},null,8,["model-value","title"]),a(c)===!0?(r(),v(S,{key:0,variant:"outlined",class:"pa-4 mb-4"},{default:t(()=>[e(N,{scanner:a(n),"is-edit-mode":!0,onCloseForm:E},null,8,["scanner"])]),_:1})):C("",!0),e(S,{variant:"outlined"},{default:t(()=>[e(R,{loading:a(y),headers:B,items:a(F),"items-per-page":-1,"hide-default-footer":"","loading-text":"Loading scanners...","no-data-text":"No scanners added",density:"compact"},{"item.name":t(({item:s})=>[V(_(s.name),1)]),"item.endpoint":t(({item:s})=>[X("code",null,_(s.endpoint),1)]),"item.actions":t(({item:s})=>[e(w,{variant:"text",size:"small",icon:!0},{default:t(()=>[e(D,{icon:"mdi-dots-vertical"}),e(Y,{activator:"parent",location:"bottom"},{default:t(()=>[e(Z,{density:"compact",class:"py-0"},{default:t(()=>[(r(),p(b,null,q(x,(f,g)=>(r(),p(b,{key:`item-${f.title}-${g}`},[e(G,{onClick:K=>f.action(s)},{default:t(()=>[e(D,{start:"",size:"small",icon:f.icon},null,8,["icon"]),V(" "+_(f.title),1)]),_:2},1032,["onClick"]),g!==x.length-1?(r(),v(H,{key:0})):C("",!0)],64))),64))]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:2},1032,["loading","items"])]),_:1})]))}}),re=$({__name:"index",setup(h){const i=u(!1),d=[{text:"Scanners",disabled:!0,to:"/scanners",exact:!0}];return(y,o)=>(r(),p("div",null,[e(a(P),{breadcrumbs:d,class:"mb-5"}),e(S,{variant:"outlined",class:"my-4"},{default:t(()=>[e(I,null,{default:t(()=>[a(i)===!1?(r(),v(w,{key:0,color:"accent","prepend-icon":"mdi-plus",onClick:o[0]||(o[0]=c=>i.value=!a(i))},{default:t(()=>[V(" New ")]),_:1})):(r(),v(N,{key:1,onCloseForm:o[1]||(o[1]=c=>i.value=!1)}))]),_:1})]),_:1}),e(J)]))}});export{re as default};
