/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module ContentView
 */
import "./DefaultViewOverlay.scss";
import * as React from "react";
import { SolarTimeline, TimelineComponent, } from "@itwin/imodel-components-react";
import { useScheduleAnimationDataProvider } from "../hooks/useScheduleAnimationDataProvider";
import { useActiveViewport } from "../hooks/useActiveViewport";
import { useSolarDataProvider } from "../hooks/useSolarDataProvider";
import { useAnalysisAnimationDataProvider } from "../hooks/useAnalysisAnimationDataProvider";
/**
 * Default viewport overlay that examines ViewState of the active view for a schedule script, analysis data, or solar data. If one of these is detected, the corresponding
 * data provider is attached to the TimelineComponent and the overlay is made visible.
 * @public
 */
// istanbul ignore next
export function DefaultViewOverlay({ viewport, onPlayPause, featureOptions, }) {
    var _a, _b, _c;
    const solarDataTimelineProvider = useSolarDataProvider(viewport);
    const analysisAnimationTimelineDataProvider = useAnalysisAnimationDataProvider(viewport);
    const scheduleTimelineDataProvider = useScheduleAnimationDataProvider(viewport);
    const currentViewport = useActiveViewport();
    if (!currentViewport)
        return null;
    // Solar gets first shot
    if (solarDataTimelineProvider &&
        !!((_a = featureOptions === null || featureOptions === void 0 ? void 0 : featureOptions.defaultViewOverlay) === null || _a === void 0 ? void 0 : _a.enableSolarTimelineViewOverlay)) {
        return (React.createElement("div", { className: "uifw-view-overlay" },
            React.createElement("div", { className: "uifw-animation-overlay" },
                React.createElement(SolarTimeline, { dataProvider: solarDataTimelineProvider }))));
    }
    if (analysisAnimationTimelineDataProvider &&
        !!((_b = featureOptions === null || featureOptions === void 0 ? void 0 : featureOptions.defaultViewOverlay) === null || _b === void 0 ? void 0 : _b.enableAnalysisTimelineViewOverlay)) {
        return (React.createElement("div", { className: "uifw-view-overlay" },
            React.createElement("div", { className: "uifw-animation-overlay" },
                React.createElement(TimelineComponent, { startDate: analysisAnimationTimelineDataProvider.start, endDate: analysisAnimationTimelineDataProvider.end, initialDuration: analysisAnimationTimelineDataProvider.initialDuration, totalDuration: analysisAnimationTimelineDataProvider.duration, minimized: true, onChange: analysisAnimationTimelineDataProvider.onAnimationFractionChanged, onPlayPause: onPlayPause }))));
    }
    if (scheduleTimelineDataProvider &&
        !!((_c = featureOptions === null || featureOptions === void 0 ? void 0 : featureOptions.defaultViewOverlay) === null || _c === void 0 ? void 0 : _c.enableScheduleAnimationViewOverlay)) {
        return (React.createElement("div", { className: "uifw-view-overlay" },
            React.createElement("div", { className: "uifw-animation-overlay" },
                React.createElement(TimelineComponent, { startDate: scheduleTimelineDataProvider.start, endDate: scheduleTimelineDataProvider.end, initialDuration: scheduleTimelineDataProvider.initialDuration, totalDuration: scheduleTimelineDataProvider.duration, minimized: true, onChange: scheduleTimelineDataProvider.onAnimationFractionChanged, onPlayPause: onPlayPause }))));
    }
    return null;
}
//# sourceMappingURL=DefaultViewOverlay.js.map