import{_ as g,x as v,$ as y,Z as h,r,b as k,e as p,o,f as d,w as $,g as f,j as m,t as D,aF as F,aG as q}from"./app-DGDivIsO.js";const w=v({props:{formData:null,folder:String,imageField:{default:"image",type:String},url:{default:"upload-file",type:String}},components:{LoadingOutlined:y,PlusOutlined:h},setup(e,{emit:s}){const n=r([]),t=r(!1),{t:u}=k();return{fileList:n,loading:t,customRequest:i=>{const a=new FormData;a.append("image",i.file),a.append("folder",e.folder),t.value=!0,axiosAdmin.post(e.url,a,{headers:{"Content-Type":"multipart/form-data"}}).then(l=>{n.value=[],t.value=!1,s("onFileUploaded",{file:l.data.file,file_url:l.data.file_url})}).catch(()=>{t.value=!1,F.error(u("messages.uploading_failed"))})}}}}),L={key:0},R=["src"],B={key:1},C={class:"ant-upload-text"};function S(e,s,n,t,u,c){const i=p("loading-outlined"),a=p("plus-outlined"),l=q;return o(),d(l,{accept:"image/*","file-list":e.fileList,"onUpdate:fileList":s[0]||(s[0]=_=>e.fileList=_),name:"image","list-type":"picture-card",class:"avatar-uploader","show-upload-list":!1,customRequest:e.customRequest},{default:$(()=>[e.formData[e.imageField]!=null?(o(),f("div",L,[m("img",{style:{width:"128px"},src:e.formData[`${e.imageField}_url`],alt:"avatar"},null,8,R)])):(o(),f("div",B,[e.loading?(o(),d(i,{key:0})):(o(),d(a,{key:1})),m("div",C,D(e.$t("common.upload")),1)]))]),_:1},8,["file-list","customRequest"])}const O=g(w,[["render",S]]);export{O as U};
