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