import { useState } from 'react'; import { IoAdd } from 'react-icons/io5'; import { CustomFields, EntryId, isOntimeEvent, isPlayableEvent, OntimeEvent, ProjectData, Settings, } from 'ontime-types'; import Button from '../../common/components/buttons/Button'; import Empty from '../../common/components/state/Empty'; import ViewLogo from '../../common/components/view-logo/ViewLogo'; import ViewParamsEditor from '../../common/components/view-params-editor/ViewParamsEditor'; import { useWindowTitle } from '../../common/hooks/useWindowTitle'; import { ViewExtendedTimer } from '../../common/models/TimeManager.type'; import { formatTime, getDefaultFormat } from '../../common/utils/time'; import SuperscriptTime from '../../features/viewers/common/superscript-time/SuperscriptTime'; import { useTranslation } from '../../translation/TranslationProvider'; import { getCountdownOptions, useCountdownOptions } from './countdown.options'; import CountdownSelect from './CountdownSelect'; import CountdownSubscriptions from './CountdownSubscriptions'; import './Countdown.scss'; interface CountdownProps { backstageEvents: OntimeEvent[]; customFields: CustomFields; general: ProjectData; time: ViewExtendedTimer; isMirrored: boolean; selectedId: EntryId | null; settings: Settings | undefined; } export default function Countdown(props: CountdownProps) { const { backstageEvents, customFields, general, time, isMirrored, selectedId, settings } = props; const { getLocalizedString } = useTranslation(); const { subscriptions } = useCountdownOptions(); const [editMode, setEditMode] = useState(false); useWindowTitle('Countdown'); // gather rundown data const playableEvents = backstageEvents.filter((event) => isOntimeEvent(event) && isPlayableEvent(event)); // gather timer data const clock = formatTime(time.clock); // gather presentation data const hasEvents = playableEvents.length > 0; // gather option data const defaultFormat = getDefaultFormat(settings?.timeFormat); const countdownOptions = getCountdownOptions(defaultFormat, customFields); return (