import{d as I,p as _,u as E,r as A,X as p,a as d,c as m,I as k,h as x,w as L,k as N,t as T,i as n,a2 as $,a3 as z,e as C,g as F,a7 as M,a5 as e,E as V,a6 as D,_ as H}from"./index-6c60ffba.js";import{f as O,e as f,g as J,v as R,i as X}from"./config-d89d22f7.js";import"./BaseUpload.vue_vue_type_style_index_0_scoped_5165bd65_lang-d72bc660.js";const j=I({__name:"BaseUpload",props:{type:{type:String,default:"file",validator:a=>["image","video","audio","library","doc","file"].includes(a)},button:{type:String},uploadAction:{type:String},fileAccept:{type:String},fileMaxSize:{type:Number},multiple:{type:Boolean},disabled:{type:Boolean,default:!1},onSuccess:Function},setup(a){const g=a,{type:t,uploadAction:o,fileAccept:s,fileMaxSize:l}=_(g),{t:v}=E(),u=A({}),y=p(()=>{if((o==null?void 0:o.value)!=null)return o.value;switch(t.value){case"image":return X;case"video":return R;case"audio":return J;case"library":return f;case"doc":return f;case"file":return O;default:throw new Error(`Type not support: ${t.value}`)}}),b=p(()=>{if((s==null?void 0:s.value)!=null)return s.value;switch(t.value){case"image":return e.imageInputAccept;case"video":return e.videoInputAccept;case"audio":return e.audioInputAccept;case"library":return e.libraryInputAccept;case"doc":return e.docInputAccept;case"file":return e.fileInputAccept;default:throw new Error(`Type not support: ${t.value}`)}}),c=p(()=>{if((l==null?void 0:l.value)!=null)return l.value;switch(t.value){case"image":return e.imageLimitByte;case"video":return e.videoLimitByte;case"audio":return e.audioLimitByte;case"library":return e.libraryLimitByte;case"doc":return e.docLimitByte;case"file":return e.fileLimitByte;default:throw new Error(`Type not support: ${t.value}`)}}),B=r=>c.value>0&&r.size>c.value?(V.error(v("error.fileMaxSize",{size:`${c.value/1024/1024} MB`})),!1):!0,h=r=>{D(JSON.parse(r.message))};return(r,q)=>{const U=d("el-upload"),w=d("el-progress");return m(),k(M,null,[x(U,{action:n(y),headers:{...n($)(),...n(z)()},accept:n(b),"before-upload":B,"on-success":a.onSuccess,"on-progress":(i,S)=>u.value=S,"on-error":h,"show-file-list":!1,disabled:a.disabled,multiple:a.multiple,drag:""},{default:L(()=>{var i;return[N(T((i=a.button)!=null?i:r.$t("clickOrDragToUpload")),1)]}),_:1},8,["action","headers","accept","on-success","on-progress","disabled","multiple"]),u.value.status==="uploading"?(m(),C(w,{key:0,percentage:parseInt(u.value.percentage,10)},null,8,["percentage"])):F("",!0)],64)}}}),Q=H(j,[["__scopeId","data-v-5165bd65"]]);export{Q as B};
