{"version":3,"file":"GeolocationPreview.mjs","names":[],"sources":["../../../../../src/components/MessageComposer/AttachmentPreviewList/GeolocationPreview.tsx"],"sourcesContent":["import type { LiveLocationPreview, StaticLocationPreview } from 'stream-chat';\nimport type { ComponentType } from 'react';\nimport React from 'react';\nimport { useTranslationContext } from '../../../context';\nimport { useComponentContextIcons } from '../../../context';\nimport { RemoveAttachmentPreviewButton } from '../RemoveAttachmentPreviewButton';\n\ntype GeolocationPreviewImageProps = {\n  location: StaticLocationPreview | LiveLocationPreview;\n};\n\nconst GeolocationPreviewImage = () => {\n  const { IconLocation } = useComponentContextIcons();\n\n  return (\n    <div className='str-chat__location-preview-image'>\n      <IconLocation />\n    </div>\n  );\n};\n\nexport type GeolocationPreviewProps = {\n  location: StaticLocationPreview | LiveLocationPreview;\n  PreviewImage?: ComponentType<GeolocationPreviewImageProps>;\n  remove?: () => void;\n};\n\nexport const GeolocationPreview = ({\n  location,\n  PreviewImage = GeolocationPreviewImage,\n  remove,\n}: GeolocationPreviewProps) => {\n  const { t } = useTranslationContext();\n  const shareDuration = (location as LiveLocationPreview).durationMs;\n  const title = shareDuration\n    ? t('common.liveLocation.text', 'Live location')\n    : t('common.currentLocation.text', 'Current location');\n\n  return (\n    <div className='str-chat__location-preview' data-testid='location-preview'>\n      <PreviewImage location={location} />\n      <div className='str-chat__location-preview__data'>\n        <div\n          className='str-chat__location-preview__data__title'\n          title={t(\n            'messageComposer.geolocationPreview.sharedLocation.title',\n            'Shared location',\n          )}\n        >\n          {title}\n        </div>\n        <div className='str-chat__location-preview__data__subtitle'>\n          {t(\n            'messageComposer.geolocationPreview.location.text',\n            'Location: {{ coordinates }}',\n            {\n              coordinates: `${location.latitude}, ${location.longitude}`,\n            },\n          )}\n        </div>\n        {shareDuration && (\n          <div className='str-chat__location-preview__data__sharing-duration'>\n            {t('messageComposer.geolocationPreview.live.text', 'Live for {{duration}}', {\n              duration: t('duration.shareLocation', {\n                milliseconds: shareDuration,\n              }),\n            })}\n          </div>\n        )}\n      </div>\n      {remove && (\n        <RemoveAttachmentPreviewButton\n          aria-label={t(\n            'messageComposer.geolocationPreview.removeLocationAttachment.ariaLabel',\n            'Remove location attachment',\n          )}\n          className='str-chat__attachment-preview__remove-button'\n          data-testid='location-preview-item-delete-button'\n          onClick={remove}\n        />\n      )}\n    </div>\n  );\n};\n"],"mappings":";;;;;;AAWA,IAAM,gCAAgC;CACpC,MAAM,EAAE,iBAAiB,yBAAyB;CAElD,OACE,oBAAC,OAAD;EAAK,WAAU;YACb,oBAAC,cAAD,CAAe,CAAA;CACZ,CAAA;AAET;AAQA,IAAa,sBAAsB,EACjC,UACA,eAAe,yBACf,aAC6B;CAC7B,MAAM,EAAE,MAAM,sBAAsB;CACpC,MAAM,gBAAiB,SAAiC;CACxD,MAAM,QAAQ,gBACV,EAAE,4BAA4B,eAAe,IAC7C,EAAE,+BAA+B,kBAAkB;CAEvD,OACE,qBAAC,OAAD;EAAK,WAAU;EAA6B,eAAY;YAAxD;GACE,oBAAC,cAAD,EAAwB,SAAW,CAAA;GACnC,qBAAC,OAAD;IAAK,WAAU;cAAf;KACE,oBAAC,OAAD;MACE,WAAU;MACV,OAAO,EACL,2DACA,iBACF;gBAEC;KACE,CAAA;KACL,oBAAC,OAAD;MAAK,WAAU;gBACZ,EACC,oDACA,+BACA,EACE,aAAa,GAAG,SAAS,SAAS,IAAI,SAAS,YACjD,CACF;KACG,CAAA;KACJ,iBACC,oBAAC,OAAD;MAAK,WAAU;gBACZ,EAAE,gDAAgD,yBAAyB,EAC1E,UAAU,EAAE,0BAA0B,EACpC,cAAc,cAChB,CAAC,EACH,CAAC;KACE,CAAA;IAEJ;;GACJ,UACC,oBAAC,+BAAD;IACE,cAAY,EACV,yEACA,4BACF;IACA,WAAU;IACV,eAAY;IACZ,SAAS;GACV,CAAA;EAEA;;AAET"}