'use client'; import { clsx } from 'clsx/lite'; import { Photo, PhotoDateRange, dateRangeForPhotos, titleForPhoto, } from '.'; import { PhotoSetCategory } from '../category'; import ShareButton from '@/share/ShareButton'; import AnimateItems from '@/components/AnimateItems'; import { ReactNode } from 'react'; import DivDebugBaselineGrid from '@/components/DivDebugBaselineGrid'; import PhotoPrevNextActions from './PhotoPrevNextActions'; import PhotoLink from './PhotoLink'; import ResponsiveText from '@/components/primitives/ResponsiveText'; import { useAppState } from '@/state/AppState'; import { GRID_GAP_CLASSNAME } from '@/components'; import { APP_TEXT } from '@/app/config'; export default function PhotoHeader({ photos, selectedPhoto, entity, entityVerb = APP_TEXT.photo.photo.toLocaleUpperCase(), entityDescription, indexNumber, count, dateRange, hasAiTextGeneration, includeShareButton, ...categories }: { photos: Photo[] selectedPhoto?: Photo entity?: ReactNode entityVerb?: string entityDescription?: string indexNumber?: number count?: number dateRange?: PhotoDateRange hasAiTextGeneration: boolean includeShareButton?: boolean } & PhotoSetCategory) { const { isGridHighDensity } = useAppState(); const { start, end } = dateRangeForPhotos(photos, dateRange); const selectedPhotoIndex = selectedPhoto ? photos.findIndex(photo => photo.id === selectedPhoto.id) : undefined; const paginationIndex = indexNumber || (selectedPhotoIndex ?? 0 + 1); const paginationCount = count ?? photos.length; const headerType = selectedPhotoIndex === undefined ? 'photo-set' : entity ? 'photo-detail-with-entity' : 'photo-detail'; const renderPrevNext = ; const renderDateRange = {start === end ? start : <>{end}
– {start}}
; const renderContentA = entity ?? ( selectedPhoto !== undefined && {titleForPhoto(selectedPhoto, true)} ); return ( {/* Content A: Filter Set or Photo Title */}
{headerType === 'photo-detail-with-entity' ? renderContentA // Necessary for title truncation :

{renderContentA}

}
{/* Content B: Filter Set Meta or Photo Pagination */}
{entity && <> {headerType === 'photo-set' ? <> {entityDescription} {includeShareButton && } : {APP_TEXT.utility.paginate( paginationIndex, paginationCount, entityVerb)} } }
{/* Content C: Nav */}
{selectedPhoto ? renderPrevNext : renderDateRange}
, ]} /> ); }