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