import{d as j,q as A,E as K,H as P,P as $,r as f,o as q,F as y,f as G,h as n,i as d,C as i,G as I,x as m,R as x,c as r,X as H,y as _,v,Q as S,a5 as O,S as E,a0 as R,V as z,b as Q}from"./index-C5GbdPxY.js";import{V as D}from"./VTextField-DxEUpn3-.js";import{V as X,a as J}from"./VAvatar-RkAR0u0e.js";import{V as W}from"./VSpacer-79sITyKz.js";import{V as Y}from"./VDataTable-BFiF8jPV.js";import{_ as Z}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./index-XcTykuv2.js";import"./VImg-BlqLjeEy.js";import"./forwardRefs-CB8NoG9r.js";import"./VSelect-vtfYszIh.js";import"./VList-C3dIUnee.js";import"./VMenu-CT0Fri-T.js";import"./VOverlay-DlJb3QlW.js";import"./getScrollParent-DE35ecf2.js";import"./VVirtualScroll-BUlcGoHW.js";import"./VChip-CsS_5IS6.js";import"./VTable-M43pjJD_.js";import"./filter-DERJvhSS.js";const ee={key:0},ae=["colspan"],te={class:"d-flex flex-column align-center justify-center"},oe={class:"text-caption text-medium-emphasis"},se={key:1,class:"text-caption text-medium-emphasis"},le={class:"font-weight-medium"},ne={key:0},re=["onClick"],ie=j({__name:"Index",setup(de){const b=A(),{update:F,loadData:M}=K(),{t:c}=P(),{can:N}=$(),k=f([]),u=f(!0),l=f(null),p=f("");q(async()=>{k.value=await M()||[],u.value=!1});const g=y(()=>[{title:c("translation::translations.table.key"),value:"key"},...b.supportedLanguages.map(t=>({title:t.name,value:t.id}))]),C=y(()=>k.value.map(t=>({key:t.key,...t.translations}))),h=(t,o)=>{const e=k.value.find(a=>a.key===t);return y({get:()=>(e==null?void 0:e.translations[o])??"",set:a=>{e&&(e.translations[o]=a)}})},w=()=>{var t,o,e,a;if(l.value!=null){const s=h((t=l.value)==null?void 0:t.key,(o=l.value)==null?void 0:o.lang).value;l.value.oldValue!=s&&F((e=l.value)==null?void 0:e.key,(a=l.value)==null?void 0:a.lang,s)}l.value=null},T=y(()=>{if(!p.value)return C.value;const t=p.value.toLowerCase();return C.value.filter(o=>Object.values(o).some(e=>typeof e=="string"&&(e==null?void 0:e.toLowerCase().includes(t))))}),U=(t,o)=>{N("admin.translations.edit")&&(l.value={key:t.key,lang:o.id,oldValue:t[o.id]})};return(t,o)=>(n(),G(Y,{headers:g.value,"hide-default-footer":u.value,"item-value":"key",items:T.value,loading:u.value},{top:d(()=>[r(X,{class:"pa-4 pb-0"},{default:d(()=>[r(W),r(J,{cols:"12",md:"3"},{default:d(()=>[r(D,{modelValue:p.value,"onUpdate:modelValue":o[0]||(o[0]=e=>p.value=e),clearable:"",disabled:u.value,placeholder:v(c)("admin::admin.table.search_placeholder"),"prepend-inner-icon":"tabler-search"},null,8,["modelValue","disabled","placeholder"])]),_:1})]),_:1})]),body:d(({items:e})=>[u.value||e.length===0?(n(),i("tr",ee,[m("td",{class:"text-center pa-6",colspan:g.value.length},[m("div",te,[u.value?(n(),i(x,{key:0},[r(H,{class:"mb-2",color:"primary",indeterminate:""}),m("div",oe,_(v(c)("admin::admin.table.loading")),1)],64)):e.length===0&&p.value?(n(),i("div",se,_(v(c)("admin::admin.table.no_matching_records_found")),1)):I("",!0)])],8,ae)])):I("",!0),(n(!0),i(x,null,S(e,a=>(n(),i("tr",{key:a.key},[m("td",le,_(a.key),1),(n(!0),i(x,null,S(v(b).supportedLanguages,s=>{var L,B;return n(),i("td",{key:s.id,class:"translation-cell"},[((L=l.value)==null?void 0:L.key)===a.key&&((B=l.value)==null?void 0:B.lang)===s.id?(n(),i("div",ne,[r(D,{modelValue:h(a.key,s.id).value,"onUpdate:modelValue":V=>h(a.key,s.id).value=V,autofocus:"",density:"compact","hide-details":"",onKeyup:O(w,["enter"])},{append:d(()=>[r(E,{color:"default",icon:"",size:"small",variant:"text",onClick:o[1]||(o[1]=R(V=>l.value=null,["stop"]))},{default:d(()=>[r(z,{icon:"tabler-x"})]),_:1}),r(E,{color:"primary",icon:"",size:"small",variant:"text",onClick:R(w,["stop"])},{default:d(()=>[r(z,{icon:"tabler-check"})]),_:1})]),_:2},1032,["modelValue","onUpdate:modelValue"])])):(n(),i("div",{key:1,style:{cursor:"pointer"},onClick:V=>U(a,s)},[m("span",{class:Q(["text-translation",{"translation-cell--empty":!a[s.id],"text-error":!a[s.id],"text-blue":a[s.id]}])},_(a[s.id]||v(c)("translation::translations.table.empty")),3)],8,re))])}),128))]))),128))]),_:1},8,["headers","hide-default-footer","items","loading"]))}}),Ie=Z(ie,[["__scopeId","data-v-05d02f22"]]);export{Ie as default};
