import{a as L,aA as M,r as v,I as V,ao as N,b,a7 as T,c as f,e as g,F as $,i as j,m as u,Z as _,$ as k,f as h,u as c,h as H,aB as O,an as y,al as P,_ as S}from"./index.4d061c66.js";import{h as X}from"./image.e35d846c.js";import{u as Y}from"./useAsync.df7387ce.js";import{u as Z}from"./hooks.9f8f44e2.js";/* empty css                                                              */const q={class:"image-upload-list"},G=["src"],J={class:"absolute top-[-3px] right-[5px]"},K={class:"img-input"},Q=["accept","disabled"],W=L({__name:"image",props:{descs:null,types:null,size:{default:1},urls:null,disabled:{type:Boolean}},emits:["change","update:urls"],setup(t,{emit:B}){const o=t,{VITE_PROXY_DOMAIN_REAL:C}=P(),E=`${C}storage/`,I=M(),d=v(null),r=v(!1),w=V(()=>{const{types:a}=o;return a.map(e=>"image/"+e)}),l=N(o,"urls"),F=Y(),x=({type:a,size:e})=>w.value.includes(a)?e/1024/1024>o.size?(y.warning("\u56FE\u7247\u5927\u5C0F\u8D85\u8FC7"+o.size+"M"),!1):!0:(y.warning(`\u8BF7\u4E0A\u4F20${o.types.join(".")}\u7C7B\u578B\u7684\u56FE\u7247`),!1);function D(a){const e=l.value.findIndex(s=>s===a);e>=0&&l.value.splice(e,1)}const R=async()=>{if(r.value)return;const a=d.value.files,e=a.length;if(e!==0){r.value=!0;for(let s=0;s<=e;s++)if(s===e)r.value=!1,d.value=null;else{const n=await U(a,s);n==="break"||n==="error"||(l.value.push(n),B("change",c(l)))}}},U=(a,e)=>new Promise(s=>{x(a[e])||s("break");const n=new FormData;n.append("image",a[e]),n.append("token",I),X(n).then(p=>{const{message:i,code:m,data:z}=p;F({message:i,code:m,handler:()=>{const A=E+z[0].url;s(A)}})})});return(a,e)=>{const s=b("ElButton"),n=b("el-icon"),p=T("loading");return f(),g("ul",q,[(f(!0),g($,null,j(c(l),(i,m)=>(f(),g("li",{class:"img-show relative",key:m+i},[u("img",{src:i,alt:""},null,8,G),_(u("div",J,[h(s,{link:"",size:"large",type:"primary",icon:c(Z)("close-bold"),onClick:()=>D(i)},null,8,["icon","onClick"])],512),[[k,!t.disabled]])]))),128)),_(u("li",K,[_(u("input",{ref_key:"inputer",ref:d,accept:t.types.join("."),multiple:!0,type:"file",name:"file",disabled:t.disabled,onChange:R},null,40,Q),[[p,r.value]]),h(n,{class:"avatar-uploader-icon"},{default:H(()=>[h(c(O))]),_:1})],512),[[k,!t.disabled]])])}}}),oe=S(W,[["__scopeId","data-v-af76fb00"]]);export{oe as I};
