var U=Object.defineProperty;var h=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable;var f=(o,n,a)=>n in o?U(o,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[n]=a,x=(o,n)=>{for(var a in n||(n={}))O.call(n,a)&&f(o,a,n[a]);if(h)for(var a of h(n))W.call(n,a)&&f(o,a,n[a]);return o};import{d as $,i as w,D as F,q as J,H as C,E as I,J as v,n as g,W as q,o as r,j as c,k as y,c as m,b,v as H,w as k,m as M,x as R,a as z,F as A,f as j,t as G,e as K,at as P,au as Q,av as X}from"./index.29cf2edd.js";/* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              */const Y={class:"flex",style:{"padding-bottom":"10px"}},Z={key:0},ee={key:1,class:"editable-row-operations"},ae={key:0},te=j("Save"),ne=y("a",null,"Cancel",-1),se={key:1},oe=["onClick"],me=$({__name:"Translate",setup(o){const n=[{title:"ID",dataIndex:"id",key:"id"},{title:"Word",dataIndex:"word",key:"word"},{title:"Laos",dataIndex:"la",key:"la"},{title:"English US",dataIndex:"us",key:"us"},{title:"Chinese",dataIndex:"cn",key:"cn"},{title:"Vietnamese",dataIndex:"vn",key:"vn"},{title:"Japanese",dataIndex:"jp",key:"jp"},{title:"Operation",dataIndex:"operation"}];let a=w(),p=w();const t=F({});J(()=>{S()});const S=()=>{C(),I.getTranslate().then(e=>{v();const l=e.data;p.value=l.translate.map(s=>{const u=x({la:"",us:"",cn:"",vn:"",jp:""},s.translate);return x({id:s.id,word:s.word},u)})}).catch(e=>{v(),g.error(e.message)})},T=q(()=>a.value?p.value.filter(e=>e.word.toLowerCase().indexOf(a.value.toLowerCase())!==-1):p.value),D=e=>{t[e]=P(p.value.filter(l=>e===l.id)[0])},L=async e=>{const l={id:e,word:t[e].word,translate:{la:t[e].la,us:t[e].us,cn:t[e].cn,vn:t[e].vn,jp:t[e].jp}};C(),await I.saveTranslate(l).then(s=>{v(),g.success("Saved"),Object.assign(p.value.filter(u=>e===u.id)[0],t[e]),delete t[e]}).catch(s=>{v(),g.error(s.message)})},V=e=>{delete t[e]};return(e,l)=>{const s=M,u=Q,B=X,E=R;return r(),c("div",null,[y("div",Y,[m(s,{value:b(a),"onUpdate:value":l[0]||(l[0]=d=>H(a)?a.value=d:a=d),placeholder:"Word...",style:{"max-width":"265px","margin-right":"12px"}},null,8,["value"])]),m(E,{columns:n,"data-source":b(T),bordered:""},{bodyCell:k(({column:d,text:N,record:i})=>[["la","us","cn","vn","jp"].includes(d.dataIndex)?(r(),c("div",Z,[t[i.id]?(r(),z(s,{key:0,value:t[i.id][d.dataIndex],"onUpdate:value":_=>t[i.id][d.dataIndex]=_,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):(r(),c(A,{key:1},[j(G(N),1)],64))])):d.dataIndex==="operation"?(r(),c("div",ee,[t[i.id]?(r(),c("span",ae,[m(u,{onClick:_=>L(i.id),style:{"padding-right":"5px"}},{default:k(()=>[te]),_:2},1032,["onClick"]),m(B,{title:"Sure to cancel?",onConfirm:_=>V(i.id)},{default:k(()=>[ne]),_:2},1032,["onConfirm"])])):(r(),c("span",se,[y("a",{onClick:_=>D(i.id)},"Edit",8,oe)]))])):K("",!0)]),_:1},8,["data-source"])])}}});export{me as default};
