"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),L=require("@ant-design/icons-vue/FileTwoTone"),y=require("@ant-design/icons-vue/LoadingOutlined"),O=require("@ant-design/icons-vue/PaperClipOutlined"),$=require("@ant-design/icons-vue/PictureTwoTone"),E=require("../../_util/collapseMotion.js"),P=require("../../_util/props-util/index.js"),j=require("../../_util/transition.js");require("../../button/index.js");const M=require("../../config-provider/hooks/useConfigInject.js"),S=require("../interface.js"),T=require("../utils.js"),G=require("./ListItem.js"),z=require("../../_util/props-util/initDefaultProps.js"),b=require("../../button/button.js"),B=(e,{slots:c})=>P.filterEmpty(c.default?.())[0],H=n.defineComponent({compatConfig:{MODE:3},name:"AUploadList",props:z.default(S.uploadListProps(),{listType:"text",progress:{strokeWidth:2,showInfo:!1},showRemoveIcon:!0,showDownloadIcon:!1,showPreviewIcon:!0,previewFile:T.previewImage,isImageUrl:T.isImageUrl,items:[],appendActionVisible:!0}),setup(e,{slots:c,expose:R}){const f=n.shallowRef(!1);n.onMounted(()=>{f.value==!0});const s=n.shallowRef([]);n.watch(()=>e.items,(t=[])=>{s.value=t.slice()},{immediate:!0,deep:!0}),n.watchEffect(()=>{if(e.listType!=="picture"&&e.listType!=="picture-card")return;let t=!1;(e.items||[]).forEach((o,l)=>{typeof document>"u"||typeof window>"u"||!window.FileReader||!window.File||!(o.originFileObj instanceof File||o.originFileObj instanceof Blob)||o.thumbUrl!==void 0||(o.thumbUrl="",e.previewFile&&e.previewFile(o.originFileObj).then(r=>{const i=r||"";i!==o.thumbUrl&&(s.value[l].thumbUrl=i,t=!0)}))}),t&&n.triggerRef(s)});const w=(t,o)=>{if(e.onPreview)return o?.preventDefault(),e.onPreview(t)},m=t=>{typeof e.onDownload=="function"?e.onDownload(t):t.url&&window.open(t.url)},q=t=>{e.onRemove?.(t)},D=({file:t})=>{const o=e.iconRender||c.iconRender;if(o)return o({file:t,listType:e.listType});const l=t.status==="uploading",r=e.isImageUrl&&e.isImageUrl(t)?n.createVNode($,null,null):n.createVNode(L,null,null);let i=l?n.createVNode(y,null,null):n.createVNode(O,null,null);return e.listType==="picture"?i=l?n.createVNode(y,null,null):r:e.listType==="picture-card"&&(i=l?e.locale.uploading:r),i},U=t=>{const{customIcon:o,callback:l,prefixCls:r,title:i}=t,a={type:"text",size:"small",title:i,onClick:d=>{l();try{d?.currentTarget?.blur?.()}catch{}},class:`${r}-list-item-action`};return i===e.locale?.downloadFile&&(a.disabled=!1),P.isValidElement(o)?n.createVNode(b.default,a,{icon:()=>o}):n.createVNode(b.default,a,{default:()=>[n.createVNode("span",null,[o])]})};R({handlePreview:w,handleDownload:m});const{prefixCls:u,rootPrefixCls:V}=M.default("upload",e),C=n.computed(()=>({[`${u.value}-list`]:!0,[`${u.value}-list-${e.listType}`]:!0})),N=n.computed(()=>{const t={...E.default(`${V.value}-motion-collapse`)};delete t.onAfterAppear,delete t.onAfterEnter,delete t.onAfterLeave;const o={...j.getTransitionGroupProps(`${u.value}-${e.listType==="picture-card"?"animate-inline":"animate"}`),class:C.value,appear:f.value};return e.listType!=="picture-card"?{...t,...o}:o});return()=>{const{listType:t,locale:o,isImageUrl:l,showPreviewIcon:r,showRemoveIcon:i,showDownloadIcon:a,removeIcon:v,previewIcon:d,downloadIcon:p,progress:A,appendAction:I,itemRender:F,appendActionVisible:_}=e,k=I?.(),g=s.value;return n.createVNode(n.TransitionGroup,{...N.value,tag:"div"},{default:()=>[g.map(h=>{const{uid:x}=h;return n.createVNode(G.default,{key:x,locale:o,prefixCls:u.value,file:h,items:g,progress:A,listType:t,isImgUrl:l,showPreviewIcon:r,showRemoveIcon:i,showDownloadIcon:a,onPreview:w,onDownload:m,onClose:q,removeIcon:v,previewIcon:d,downloadIcon:p,itemRender:F},{...c,iconRender:D,actionIconRender:U})}),I?n.withDirectives(n.createVNode(B,{key:"__ant_upload_appendAction"},{default:()=>k}),[[n.vShow,!!_]]):null]})}}});exports.default=H;
