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