/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Timeline
 */
import { BaseTimelineDataProvider } from "@itwin/imodel-components-react";
/**  Analysis Timeline Data Provider - Allows a TimelineComponent to animate the AnalysisStyle information stored in a ViewState.
 * @public
 */
export class AnalysisAnimationTimelineDataProvider extends BaseTimelineDataProvider {
    constructor(viewState, viewport) {
        super(viewport);
        this.onAnimationFractionChanged = (animationFraction) => {
            this.animationFraction = animationFraction;
            // istanbul ignore next
            if (this._viewport)
                this._viewport.analysisFraction = animationFraction;
        };
        // istanbul ignore next
        this.onPlaybackSettingChanged = (settings) => {
            this.updateSettings(settings);
        };
        this._viewState = viewState;
        // istanbul ignore else
        if (viewState && viewState.analysisStyle) {
            this.supportsTimelineAnimation = true;
        }
    }
    async loadTimelineData() {
        // if animationFraction is set pointer should match
        // istanbul ignore else
        if (this._viewport)
            this.animationFraction = this._viewport.analysisFraction;
        // istanbul ignore else
        if (this.supportsTimelineAnimation && this._viewState.analysisStyle) {
            // for now just initial settings
            this.updateSettings({
                duration: 10 * 1000,
                loop: true,
            });
            return true;
        }
        // istanbul ignore next
        return false;
    }
}
//# sourceMappingURL=AnalysisAnimationProvider.js.map