import{ak as x,al as E,a as R,ao as U,aA as V,I as A,b as m,c as s,j as D,h as N,m as i,u as p,e as n,f as M,i as _,p as f,F as g,x as h,l as T,an as y,_ as O}from"./index.4d061c66.js";import{u as j}from"./hooks.9f8f44e2.js";import{u as q}from"./useAsync.df7387ce.js";/* empty css */const{VITE_PROXY_DOMAIN_REAL:z}=E();async function L(a){return x.request("post",`${z}admin/upload`,{data:a})}const $={class:"flex justify-between"},H=["src"],P={key:1},X={class:"ml-2 text-[#8c939d]"},Y={key:0},S=R({__name:"image",props:{descs:null,types:null,size:{default:1},url:null,disabled:{type:Boolean}},emits:["change","update:url"],setup(a,{emit:k}){const l=a,{VITE_PROXY_DOMAIN_REAL:v}=E(),r=U(l,"url"),B=`${v}storage/`,F=V(),I=A(()=>{const{types:o}=l;return o.map(e=>"image/"+e)}),b=q(),C=({type:o,size:e})=>{if(!I.value.includes(o))return y.warning(`\u8BF7\u4E0A\u4F20${l.types.join(".")}\u7C7B\u578B\u7684\u56FE\u7247`),!1;if(e/1024/1024>l.size)return y.warning("\u56FE\u7247\u5927\u5C0F\u8D85\u8FC7"+l.size+"M"),!1},w=async({file:o})=>{const e=new FormData;e.append("image",o),e.append("token",F);const{message:c,code:d,data:u}=await L(e),t=B+u[0].url;b({message:c,code:d,handler:()=>{r.value=t,k("change",t)}})};return(o,e)=>{const c=m("ElButton"),d=m("ElUpload");return s(),D(d,{class:"avatar-uploader","http-request":w,"before-upload":C,"show-file-list":!1,disabled:a.disabled},{default:N(()=>[i("div",$,[p(r)?(s(),n("img",{key:0,class:"avatar",src:p(r)},null,8,H)):(s(),n("div",P,[M(c,{class:"avatar-uploader-icon",icon:p(j)("plus")},null,8,["icon"])])),i("div",X,[(s(!0),n(g,null,_(a.descs,(u,t)=>(s(),n("p",{key:t},f(u),1))),128)),i("p",null,[h(" \u683C\u5F0F : "),(s(!0),n(g,null,_(a.types,(u,t)=>(s(),n("span",{key:t},[h(f(u)+" ",1),t!==a.types.length-1?(s(),n("i",Y,",")):T("",!0)]))),128))])])])]),_:1},8,["disabled"])}}}),W=O(S,[["__scopeId","data-v-527467f2"]]);export{W as I,L as h};