"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),X=require("@ant-design/icons-vue/DeleteOutlined"),Y=require("@ant-design/icons-vue/DownloadOutlined"),Z=require("@ant-design/icons-vue/EyeOutlined"),ee=require("../../_util/transition.js"),t=require("../../_util/type.js"),oe=require("../../config-provider/hooks/useConfigInject.js"),ne=require("../../progress/index.js"),te=require("../../tooltip/index.js"),D=()=>({prefixCls:String,locale:t.objectType(void 0),file:t.objectType(),items:t.arrayType(),listType:t.stringType(),isImgUrl:t.functionType(),showRemoveIcon:t.booleanType(),showDownloadIcon:t.booleanType(),showPreviewIcon:t.booleanType(),removeIcon:t.functionType(),downloadIcon:t.functionType(),previewIcon:t.functionType(),iconRender:t.functionType(),actionIconRender:t.functionType(),itemRender:t.functionType(),onPreview:t.functionType(),onClose:t.functionType(),onDownload:t.functionType(),progress:t.objectType()}),re=o.defineComponent({compatConfig:{MODE:3},name:"ListItem",inheritAttrs:!1,props:D(),setup(a,{slots:i,attrs:q}){const f=o.shallowRef(!1),v=o.shallowRef();o.onMounted(()=>{v.value=setTimeout(()=>{f.value=!0},300)}),o.onBeforeUnmount(()=>{clearTimeout(v.value)});const l=o.shallowRef(a.file?.status);o.watch(()=>a.file?.status,n=>{n!=="removed"&&(l.value=n)});const{rootPrefixCls:U}=oe.default("upload",a),O=o.computed(()=>ee.getTransitionProps(`${U.value}-fade`));return()=>{const{prefixCls:n,locale:u,listType:s,file:e,items:x,progress:S,iconRender:j=i.iconRender,actionIconRender:w=i.actionIconRender,itemRender:g=i.itemRender,isImgUrl:d,showPreviewIcon:_,showRemoveIcon:E,showDownloadIcon:M,previewIcon:y=i.previewIcon,removeIcon:I=i.removeIcon,downloadIcon:N=i.downloadIcon,onPreview:c,onDownload:T,onClose:h}=a,{class:b,style:F}=q,p=j({file:e});let m=o.createVNode("div",{class:`${n}-text-icon`},[p]);if(s==="picture"||s==="picture-card")if(l.value==="uploading"||!e.thumbUrl&&!e.url){const r={[`${n}-list-item-thumbnail`]:!0,[`${n}-list-item-file`]:l.value!=="uploading"};m=o.createVNode("div",{class:r},[p])}else{const r=d?.(e)?o.createVNode("img",{src:e.thumbUrl||e.url,alt:e.name,class:`${n}-list-item-image`,crossorigin:e.crossOrigin},null):p,Q={[`${n}-list-item-thumbnail`]:!0,[`${n}-list-item-file`]:d&&!d(e)};m=o.createVNode("a",{class:Q,onClick:W=>c(e,W),href:e.url||e.thumbUrl,target:"_blank",rel:"noopener noreferrer"},[r])}const L={[`${n}-list-item`]:!0,[`${n}-list-item-${l.value}`]:!0},A=typeof e.linkProps=="string"?JSON.parse(e.linkProps):e.linkProps,C=E?w({customIcon:I?I({file:e}):o.createVNode(X,null,null),callback:()=>h(e),prefixCls:n,title:u.removeFile}):null,P=M&&l.value==="done"?w({customIcon:N?N({file:e}):o.createVNode(Y,null,null),callback:()=>T(e),prefixCls:n,title:u.downloadFile}):null,V=s!=="picture-card"&&o.createVNode("span",{key:"download-delete",class:[`${n}-list-item-actions`,{picture:s==="picture"}]},[P,C]),R=`${n}-list-item-name`,B=e.url?[o.createVNode("a",{key:"view",target:"_blank",rel:"noopener noreferrer",class:R,title:e.name,...A,href:e.url,onClick:r=>c(e,r)},[e.name]),V]:[o.createVNode("span",{key:"view",class:R,onClick:r=>c(e,r),title:e.name},[e.name]),V],J={pointerEvents:"none",opacity:.5},z=_?o.createVNode("a",{href:e.url||e.thumbUrl,target:"_blank",rel:"noopener noreferrer",style:e.url||e.thumbUrl?void 0:J,onClick:r=>c(e,r),title:u.previewFile},[y?y({file:e}):o.createVNode(Z,null,null)]):null,G=s==="picture-card"&&l.value!=="uploading"&&o.createVNode("span",{class:`${n}-list-item-actions`},[z,l.value==="done"&&P,C]),$=o.createVNode("div",{class:L},[m,B,G,f.value&&o.createVNode(o.Transition,O.value,{default:()=>[o.withDirectives(o.createVNode("div",{class:`${n}-list-item-progress`},["percent"in e?o.createVNode(ne.default,{...S,type:"line",percent:e.percent},null):null]),[[o.vShow,l.value==="uploading"]])]})]),H={[`${n}-list-item-container`]:!0,[`${b}`]:!!b},K=e.response&&typeof e.response=="string"?e.response:e.error?.statusText||e.error?.message||u.uploadError,k=l.value==="error"?o.createVNode(te.default,{title:K,getPopupContainer:r=>r.parentNode},{default:()=>[$]}):$;return o.createVNode("div",{class:H,style:F},[g?g({originNode:k,file:e,fileList:x,actions:{download:T.bind(null,e),preview:c.bind(null,e),remove:h.bind(null,e)}}):k])}}});exports.default=re;exports.listItemProps=D;
