"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),q=require("@aplus-frontend/antdv");require("../../config-provider/index.js");require("./components/MultipleFile.vue.js");require("./components/Picture.vue.js");require("./components/SingleFile.vue.js");const h=require("./hooks/useOss.js"),F=require("./style/index.js"),w=require("./utils/accept.js"),M=require("../../config-provider/hooks/use-locale.js"),x=require("../../config-provider/hooks/use-namespace.js"),N=require("./components/Picture.vue2.js"),E=require("./components/MultipleFile.vue2.js"),O=require("./components/SingleFile.vue2.js"),U=require("../../config-provider/hooks/use-global-config.js"),j=["id"],k=e.defineComponent({name:"AplusFileUpload",__name:"apUpload",props:{dirName:{type:String,default:void 0},type:{type:String,default:"singleFile"},value:{type:[String,Object,Array],default:void 0},needName:{type:[Boolean,Object],default:void 0},accept:{type:String,default:void 0},maxSize:{type:Number,default:void 0},title:{type:String,default:""},subTitle:{type:[String,Object,null],default:""},maxCount:{type:Number,default:void 0},beforeUpload:{type:Function,default:void 0},customRequest:{type:Function,default:void 0},getOssAccess:{type:Function,default:void 0},onChange:{type:Function,default:void 0},maxSizeErrorMsg:{type:String,default:void 0},maxCountErrorMsg:{type:String,default:void 0},acceptErrorMsg:{type:String,default:void 0},onRemove:{type:Function,default:void 0},showUploadErrorMsg:{type:Boolean,default:!0},baseDirName:{type:String,default:"Frontend-Upload"},bucket:{type:String,default:void 0},showDownload:{type:[Boolean,Object],default:!0},showPreview:{type:[Boolean,Object],default:!0}},emits:["update:value"],setup(d,{expose:p,emit:c}){const{t:a,lang:v}=M.useLocale();w.injectLocaleToAccept(a),h.injectLocaleToOss(a,v);const{b:m}=x.useNamespace("ap-upload"),f=F.default("ap-upload"),u=e.ref(null),t=d,g=c,y={singleFile:O.default,multipleFile:E.default,picture:N.default},i=q.Form.useInjectFormItemContext(),_=e.computed({get(){return t.value},set(o){g("update:value",o),i?.onFieldChange(),t.onChange?.(o)}}),r=U.useGlobalConfig("apUpload");e.provide("value",_),e.provide("dirName",t.dirName??r.value?.dirName),e.provide("needName",t.needName??r.value?.needName??!1),e.provide("accept",t.accept??r.value?.accept??""),e.provide("maxSize",t.maxSize),e.provide("title",t.title),e.provide("subTitle",t.subTitle),e.provide("maxCount",t.maxCount),e.provide("beforeUpload",t.beforeUpload),e.provide("customRequest",t.customRequest),e.provide("baseDirName",t.baseDirName??"Frontend-Upload"),e.provide("getOssAccess",t.getOssAccess??r.value?.getOssAccess),e.provide("maxSizeErrorMsg",t.maxSizeErrorMsg),e.provide("maxCountErrorMsg",t.maxCountErrorMsg),e.provide("acceptErrorMsg",t.acceptErrorMsg),e.provide("onRemove",t.onRemove),e.provide("showUploadErrorMsg",t.showUploadErrorMsg),e.provide("bucket",t.bucket),e.provide("showDownload",t.showDownload),e.provide("showPreview",t.showPreview);const b=e.computed(()=>n.value===0),n=e.ref(0);e.provide("uploadingCount",n);function S(){s(void 0)}function s(o){u?.value?.setValue?.(o)}return p({done:b,clear:S,setValue:s}),(o,R)=>(e.openBlock(),e.createElementBlock("div",{id:e.unref(i)?.id.value,class:e.normalizeClass([e.unref(m)(),e.unref(f)])},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(y[t.type]),e.mergeProps(o.$attrs,{ref_key:"uploadRef",ref:u}),e.createSlots({_:2},[e.renderList(Object.keys(o.$slots),l=>({name:l,fn:e.withCtx(C=>[e.renderSlot(o.$slots,l,e.normalizeProps(e.guardReactiveProps(C||{})))])}))]),1040))],10,j))}});exports.default=k;
