{"version":3,"file":"GalleryContext.mjs","names":[],"sources":["../../../../src/components/Gallery/GalleryContext.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { LocalMessage, UserResponse } from 'stream-chat';\n\nimport { requireContext } from '../../context/requireContext';\nimport { toBaseImageDescriptors } from '../BaseImage';\nimport type { BaseImageProps } from '../BaseImage';\nimport type { Dimensions } from '../../types/types';\n\nexport type GalleryItem = Omit<BaseImageProps, 'src'> & {\n  /** When the media was shared; drives the gallery header timestamp. */\n  createdAt?: string | Date;\n  dimensions?: Dimensions;\n  imageUrl?: string;\n  /** Message the media was shared in; passed to a `ComponentContext.MessageTimestamp` override. */\n  message?: LocalMessage;\n  /** User who shared the media; drives the gallery header title. */\n  user?: UserResponse;\n  videoThumbnailUrl?: string;\n  videoUrl?: string;\n};\n\n/**\n * Maps an attachment or link preview to gallery item fields. Takes the same arguments as\n * {@link toBaseImageDescriptors}.\n */\nexport const toGalleryItemDescriptors = (\n  ...args: Parameters<typeof toBaseImageDescriptors>\n):\n  | Pick<\n      GalleryItem,\n      'alt' | 'dimensions' | 'imageUrl' | 'title' | 'videoThumbnailUrl' | 'videoUrl'\n    >\n  | undefined => toBaseImageDescriptors(...args);\n\nexport type GalleryContextValue = {\n  /** Whether clicking the empty gallery background requests close. */\n  closeOnBackgroundClick: boolean;\n  currentIndex: number;\n  currentItem: GalleryItem;\n  /** Ignores indexes outside the item range. */\n  goToIndex: (index: number) => void;\n  /** Does nothing at the last item. */\n  goToNext: () => void;\n  /** Does nothing at the first item. */\n  goToPrevious: () => void;\n  hasNext: boolean;\n  hasPrevious: boolean;\n  itemCount: number;\n  items: GalleryItem[];\n  /** The default `GalleryUI` prefers the enclosing modal's `close` over this handler. */\n  onRequestClose?: () => void;\n};\n\nexport const GalleryContext = createContext<GalleryContextValue | undefined>(undefined);\n\nexport const useGalleryContext = () =>\n  requireContext(useContext(GalleryContext), 'useGalleryContext', 'Gallery');\n"],"mappings":";;;;;;;;AAyBA,IAAa,4BACX,GAAG,SAMY,uBAAuB,GAAG,IAAI;AAqB/C,IAAa,iBAAiB,cAA+C,KAAA,CAAS;AAEtF,IAAa,0BACX,eAAe,WAAW,cAAc,GAAG,qBAAqB,SAAS"}