{"version":3,"file":"FileAttachment.mjs","names":[],"sources":["../../../../src/components/Attachment/FileAttachment.tsx"],"sourcesContent":["import React from 'react';\nimport { useComponentContext } from '../../context/ComponentContext';\nimport { FileIcon } from '../FileIcon';\nimport type { Attachment } from 'stream-chat';\n\nimport {\n  AttachmentUploadProgressIndicator as DefaultAttachmentUploadProgressIndicator,\n  FileSizeIndicator as DefaultFileSizeIndicator,\n  DownloadButton,\n} from './components';\nimport { useAttachmentUploadState } from './hooks/useAttachmentUploadState';\n\nexport type FileAttachmentProps = {\n  attachment: Attachment;\n};\n\nexport const FileAttachment = ({ attachment }: FileAttachmentProps) => {\n  const {\n    AttachmentFileIcon,\n    AttachmentUploadProgressIndicator = DefaultAttachmentUploadProgressIndicator,\n    FileSizeIndicator = DefaultFileSizeIndicator,\n  } = useComponentContext();\n  const { isUploading } = useAttachmentUploadState(attachment);\n  const FileIconComponent = AttachmentFileIcon ?? FileIcon;\n  return (\n    <div\n      className='str-chat__message-attachment-file--item'\n      data-testid='attachment-file'\n    >\n      <FileIconComponent\n        className='str-chat__file-icon'\n        fileName={attachment.title}\n        mimeType={attachment.custom?.mime_type}\n      />\n      <div className='str-chat__message-attachment-file--item__info'>\n        <div className='str-chat__message-attachment-file--item__first-row'>\n          <div\n            className='str-chat__message-attachment-file--item__name'\n            data-testid='file-title'\n          >\n            {attachment.title}\n          </div>\n        </div>\n        <div className='str-chat__message-attachment-file--item__data'>\n          {/* While uploading, the upload progress takes the place of the file size. */}\n          {isUploading ? (\n            <AttachmentUploadProgressIndicator attachment={attachment} />\n          ) : (\n            <FileSizeIndicator fileSize={attachment.custom?.file_size} />\n          )}\n        </div>\n      </div>\n      <DownloadButton\n        assetUrl={attachment.asset_url}\n        suggestedFileName={attachment.title}\n      />\n    </div>\n  );\n};\n"],"mappings":";;;;;;;;;AAgBA,IAAa,kBAAkB,EAAE,iBAAsC;CACrE,MAAM,EACJ,oBACA,mCAAA,sCAAoC,mCACpC,mBAAA,sBAAoB,sBAClB,oBAAoB;CACxB,MAAM,EAAE,gBAAgB,yBAAyB,UAAU;CAE3D,OACE,qBAAC,OAAD;EACE,WAAU;EACV,eAAY;YAFd;GAIE,oBANsB,sBAAsB,UAM5C;IACE,WAAU;IACV,UAAU,WAAW;IACrB,UAAU,WAAW,QAAQ;GAC9B,CAAA;GACD,qBAAC,OAAD;IAAK,WAAU;cAAf,CACE,oBAAC,OAAD;KAAK,WAAU;eACb,oBAAC,OAAD;MACE,WAAU;MACV,eAAY;gBAEX,WAAW;KACT,CAAA;IACF,CAAA,GACL,oBAAC,OAAD;KAAK,WAAU;eAEZ,cACC,oBAAC,qCAAD,EAA+C,WAAa,CAAA,IAE5D,oBAAC,qBAAD,EAAmB,UAAU,WAAW,QAAQ,UAAY,CAAA;IAE3D,CAAA,CACF;;GACL,oBAAC,gBAAD;IACE,UAAU,WAAW;IACrB,mBAAmB,WAAW;GAC/B,CAAA;EACE;;AAET"}