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