import{_ as j,x as V,Q as M,b as P,e as b,o as p,f as I,w as l,c as a,i as D,t as E,bd as U,B as R,am as q,ar as z,a as G,r as x,u as J,d as Q,ad as L,E as H,c9 as W,g as k,V as X,F as O,h as N,n as Y,a3 as Z,v as K,aw as ee,J as te,a2 as ne,a0 as ae}from"./app-DNXD_-wA.js";import{a as se}from"./apiAdmin-CAbwMQYP.js";import{L as oe}from"./AddButton-DEr95q6y.js";const le=V({emits:["fetchTranslationsSuccesss"],components:{SyncOutlined:M},setup(m,{emit:r}){const{addEditRequestAdmin:g,loading:t}=se(),{t:s}=P();return{loading:t,refetchTranslations:()=>{g({url:U("translations/refetch"),data:{},successMessage:s("translations.fetched_successfully"),success:_=>{r("fetchTranslationsSuccesss")}})}}}});function ce(m,r,g,t,s,T){const _=b("SyncOutlined"),C=R;return p(),I(C,{onClick:m.refetchTranslations,loading:m.loading,style:{width:"100%"}},{icon:l(()=>[a(_)]),default:l(()=>[D(" "+E(m.$t("translations.fetch_new_translations")),1)]),_:1},8,["onClick","loading"])}const ue=j(le,[["render",ce]]),de={components:{FetchNewTranslation:ue,LangAddButton:oe,EditOutlined:q,CheckOutlined:z},setup(){const{permsArray:m}=G(),r=x([]),g=x([]),t=x([]),s=x(void 0),T=x([]),_=J(),C=Q(()=>_.state.auth.lang),w=L({data:[]}),h=L({}),S=x(0),$=(e,f)=>{h[e[`${f}_id`]]={id:e[`${f}_id`],value:e[f]}},A=e=>{axiosAdmin.post(U(`translations/${e}`),{value:h[e].value,_method:"PUT"}).then(()=>{y(),delete h[e]})};var o={};const B=()=>{const e=[{title:"Group",key:"group",dataIndex:"group",fixed:"left"}],f=[];r.value.map(n=>{e.push({title:n.name,key:n.key,dataIndex:n.key}),f.push({key:n.key})}),t.value=f,g.value=e;const u=[];r.value.map(n=>{o[n.key]={},n.translations.map(c=>{o[n.key][c.group]==null&&(o[n.key][c.group]={},n.key=="en"&&u.push(c.group)),o[n.key][c.group][c.key]={id:c.xid,value:c.value}})}),s.value===void 0&&(s.value=u[0]);const d=o.en[s.value],v=[];Object.keys(d).forEach(n=>{const c={};e.map(i=>{i.key=="group"?c[i.key]=n:(c[i.key]=o[i.key][s.value][n]&&o[i.key][s.value][n].value?o[i.key][s.value][n].value:"",c[`${i.key}_id`]=o[i.key][s.value][n]&&o[i.key][s.value][n].id?o[i.key][s.value][n].id:"")}),v.push(c)}),T.value=u,w.data=v};H(()=>{y()});const y=()=>{axiosAdmin.get("lang-trans").then(e=>{r.value=e.data.data,W(e,i18n,C.value),B()})};return{columns:g,table:w,editableData:h,activeTab:S,langKeys:t,group:s,groupKeys:T,getData:y,edit:$,save:A,permsArray:m,langAdded:()=>{y()}}}},ie={key:0,class:"editable-cell"},re={key:0,class:"editable-cell-input-wrapper"},_e={key:1,class:"editable-cell-text-wrapper"};function pe(m,r,g,t,s,T){const _=Y,C=ne,w=Z,h=b("FetchNewTranslation"),S=K,$=b("admin-page-filters"),A=ae,o=b("check-outlined"),B=b("edit-outlined"),y=ee,F=b("admin-page-table-content");return p(),k(O,null,[a($,null,{default:l(()=>[a(S,{gutter:[16,16]},{default:l(()=>[a(_,{xs:24,sm:24,md:12,lg:10,xl:12},{default:l(()=>[X(m.$slots,"actionButtons")]),_:3}),a(_,{xs:24,sm:24,md:12,lg:14,xl:12},{default:l(()=>[a(S,{gutter:[16,16],justify:"end"},{default:l(()=>[a(_,{xs:24,sm:24,md:12,lg:12,xl:8},{default:l(()=>[a(w,{value:t.group,"onUpdate:value":r[0]||(r[0]=e=>t.group=e),"show-search":"",placeholder:"Select group...",style:{width:"100%"},onChange:t.getData},{default:l(()=>[(p(!0),k(O,null,N(t.groupKeys,e=>(p(),I(C,{key:e,value:e},{default:l(()=>[D(E(e),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value","onChange"])]),_:1}),a(_,{xs:24,sm:24,md:12,lg:12,xl:8},{default:l(()=>[a(h,{onFetchTranslationsSuccesss:t.getData},null,8,["onFetchTranslationsSuccesss"])]),_:1})]),_:1})]),_:1})]),_:3})]),_:3}),a(F,null,{default:l(()=>[a(y,{columns:t.columns,"row-key":e=>e.group,"data-source":t.table.data,pagination:!1,bordered:"",size:"middle"},{bodyCell:l(({column:e,text:f,record:u})=>[(p(!0),k(O,null,N(t.langKeys,d=>(p(),k(O,{key:d},[e.dataIndex===d.key?(p(),k("div",ie,[t.editableData[u[`${d.key}_id`]]?(p(),k("div",re,[a(A,{value:t.editableData[u[`${d.key}_id`]].value,"onUpdate:value":v=>t.editableData[u[`${d.key}_id`]].value=v,onPressEnter:v=>t.save(u[`${d.key}_id`])},null,8,["value","onUpdate:value","onPressEnter"]),a(o,{class:"editable-cell-icon-check",onClick:v=>t.save(u[`${d.key}_id`])},null,8,["onClick"])])):(p(),k("div",_e,[D(E(f||" ")+" ",1),a(B,{class:"editable-cell-icon",onClick:v=>t.edit(u,d.key)},null,8,["onClick"])]))])):te("",!0)],64))),128))]),_:1},8,["columns","row-key","data-source"])]),_:1})],64)}const ke=j(de,[["render",pe]]);export{ke as T};
