import{e as m,Z as A,_ as F,d as _,G as D,f as H,b as t,o as s,a as l,r as g,i as d,h as V,B,F as b,j as f,n as k,g as p,t as x,m as K,u as z}from"./vendor-1-1-37.js";const I={key:0},U={class:"flex flex-col justify-center items-center bg-white rounded-md space-y-8 lg:px-48 px-4 lg:py-10 py-5"},q={class:"w-full bg-white divide-y divide-gray-200 dark:divide-neutral-700"},E={key:0,class:"text-xs text-gray-700 text-left bg-gray-50 dark:bg-gray-700 dark:text-gray-400"},G={key:0,class:"px-4 py-3",scope:"col"},O=["src","alt"],Z={key:1},J=["colspan"],P={class:"flex flex-col rounded items-center justify-center p-4"},Q=["onMouseover","onMouseleave"],R={key:0,class:"px-4 py-3",scope:"col"},W=["value"],X=["onClick"],Y={key:2,class:"text-xs text-gray-700 bg-white dark:bg-gray-700 dark:text-gray-400"},ee=["colspan"],ae={__name:"MdrTable",props:{headers:{type:Array,required:!0},items:{type:[Array,Object],default:()=>[]},selectable:{type:Boolean,default:!1},selectableKey:{type:String,default:"id"},noDataText:{type:String,default:"Veri bulunamadı."},showHeader:{type:Boolean,default:!0}},emits:["selected","tr-clicked","tr-mouseover","tr-mouseleave"],setup(a,{emit:M}){const y=M,i=a,w=e=>e===i.headers.length-1,T=e=>e===i.items.length-1,$=m(()=>i.selectable?i.headers.length+1:i.headers.length),C=m(()=>{var e,n;return!!((n=(e=A())==null?void 0:e.vnode.props)!=null&&n.onTrClicked)}),h=F(),u=_([]),v=_(!1),N=m(()=>!!h.footer),S=m(()=>!!h.noData);return D(v,e=>{e?u.value=i.items.map(n=>n[i.selectableKey]):u.value=[]}),D(u,e=>{y("selected",e)}),(e,n)=>{const j=H("magnifying-glass-icon");return a.items.length===0&&S.value?(s(),t("div",I,[l("div",U,[g(e.$slots,"noData")])])):(s(),t("div",{key:1,class:k(`border rounded-lg overflow-auto ${a.items.length===0?"p-1":"p-0"} dark:border-neutral-700`)},[g(e.$slots,"top"),l("table",q,[a.showHeader&&a.items.length>0?(s(),t("thead",E,[a.selectable?(s(),t("th",G,[V(l("input",{"onUpdate:modelValue":n[0]||(n[0]=o=>v.value=o),type:"checkbox",class:"w-4 h-4 text-primary-800 bg-gray-100 border-gray-300 rounded focus:ring-primary-500 dark:focus:ring-primary-800 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"},null,512),[[B,v.value]])])):d("",!0),(s(!0),t(b,null,f(a.headers,(o,c)=>(s(),t("th",{key:c,scope:"col",class:k(`px-4 py-3 w-auto ${w(c)?"text-right":""} ${o.class?o.class:""} `)},[p(x(o.title)+" ",1),o.img?(s(),t("img",{key:0,src:o.img,alt:o.title,class:"size-8 rounded inline-block"},null,8,O)):d("",!0)],2))),128))])):d("",!0),a.items.length===0?(s(),t("tbody",Z,[l("tr",null,[l("td",{colspan:$.value},[l("div",P,[K(j,{class:"w-8 h-8"}),p(" "+x(a.noDataText),1)])],8,J)])])):d("",!0),l("tbody",null,[(s(!0),t(b,null,f(a.items,(o,c)=>(s(),t("tr",{key:c,class:k(`${C.value?"cursor-pointer":""} bg-white dark:bg-gray-800 ${T(c)?"":"border-b"} text-sm dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600`),onMouseover:r=>y("tr-mouseover",c),onMouseleave:r=>y("tr-mouseleave",c)},[a.selectable?(s(),t("td",R,[V(l("input",{"onUpdate:modelValue":n[1]||(n[1]=r=>u.value=r),type:"checkbox",class:"w-4 h-4 text-primary-800 bg-gray-100 border-gray-300 rounded focus:ring-primary-500 dark:focus:ring-primary-800 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600",value:o[a.selectableKey]},null,8,W),[[B,u.value]])])):d("",!0),(s(!0),t(b,null,f(a.headers,(r,L)=>(s(),t("td",{key:r.key,class:k(`px-4 py-3 w-auto ${w(L)?"text-right":""} ${r.class?r.class:""} `),scope:"col",onClick:te=>C.value?y("tr-clicked",o,r):!1},[z(h)[r.key]?g(e.$slots,r.key,{key:0,item:o,index:c}):(s(),t(b,{key:1},[p(x(o[r.key]),1)],64))],10,X))),128))],42,Q))),128))]),N.value?(s(),t("tfoot",Y,[l("tr",null,[l("td",{class:"px-4 py-4",colspan:$.value},[g(e.$slots,"footer")],8,ee)])])):d("",!0)]),g(e.$slots,"bottom")],2))}}};export{ae as _};
