import{A as B}from"./AmaTRG5a.js";import{_ as E}from"./CNIrc0EA.js";import{_ as j}from"./DuhDFJjj.js";import{z as N,j as n,c as b,b as e,f as o,t as a,m as i,e as H,D as S,w as U,o as x,J as q}from"./Bgmy51Qv.js";import{u as z}from"./7pZkuj9N.js";import{u as A}from"./LR-3m_fG.js";const F={class:"mx-w-600x mlr-auto"},M={class:"mb-20 card p-20"},R={class:"info-msg mtb-15"},J={class:"info-msg mtb-15"},O={class:"info-msg mb-15"},T={key:0,class:"error mb-15"},G={class:"mb-20 card p-20"},K={class:"dply-felx gap-15 sided"},L={class:"info-msg mtb-15"},et={__name:"index",setup(P){const{downloadRequest:y,setRequest:h}=z(),{setErrors:p}=N();n(null);const u=n(null),r=n(null),f=n(null),d=n(!1),g=n(!1),_=n(!1),{isValidImage:k,isValidExcel:$}=A(),C=async()=>{_.value=!0,await y({params:{},api:"bulkExport"}),_.value=!1},w=async t=>{p();const s=t.target.files;let l=[];const c=new FormData;Object.values(s).forEach(m=>{const v=k(m);if(v)return l.push(v),!1;c.append("images[]",m)}),l.length?p({multiple_image:l}):u.value=c},D=t=>{const s=t.target.files[0];s&&(r.value=$(s),r.value||(s.value=s))},I=async()=>{u.value&&(p(),d.value=!0,await h({params:u.value,api:"imgUpload"}),u.value=null,d.value=!1)},V=async()=>{if(f.value){p();const t=new FormData;t.append("file",f.value),g.value=!0,await h({params:t,api:"bulkImport"}),f.value=null,g.value=!1}};return(t,s)=>{const l=B,c=E,m=j;return x(),b("div",F,[e("div",M,[e("h4",null,a(t.$t("title.epd")),1),e("p",R,a(t.$t("title.csvDn")),1),o(l,{class:"primary-btn",type:"button",text:t.$t("title.ex"),"loading-text":"","fetching-data":i(_),onClicked:C},null,8,["text","fetching-data"])]),o(c),e("div",{class:S(["mb-20 card p-20 file-wrap",{"has-error":i(r)}])},[e("h4",null,a(t.$t("title.fti")),1),e("p",J,a(t.$t("title.csvUp")),1),e("p",O,a(t.$t("title.upHelp"))+" "+a(t.$t("title.lngHelp")),1),e("input",{class:"mb-15 file-input",type:"file",accept:".xlsx, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ref:"fileInput",onChange:D},null,544),i(r)?(x(),b("span",T,a(i(r)),1)):H("",!0),o(l,{class:"primary-btn",type:"button",text:t.$t("title.im"),"loading-text":"","fetching-data":i(g),onClicked:V},null,8,["text","fetching-data"])],2),e("div",G,[e("div",K,[e("h4",null,a(t.$t("title.bulkImg")),1),o(m,{to:"/images",target:"_blank",class:"link"},{default:U(()=>[q(a(t.$t("title.vi")),1)]),_:1})]),e("p",L,a(t.$t("title.imgMsg")),1),o(c,{type:"multiple_image"}),e("input",{class:"mb-15 file-input",type:"file",accept:"image/*",ref:"fileInput",multiple:"",onChange:w},null,544),o(l,{class:"primary-btn",type:"button",text:t.$t("title.bulkImgBtn"),"loading-text":"","fetching-data":i(d),onClicked:I},null,8,["text","fetching-data"])])])}}};export{et as default};
