/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Hooks
 */
import { useEffect, useState } from "react";
import { IModelApp } from "@itwin/core-frontend";
/** React hook that maintains the active viewport.
 * @public
 */
export function useActiveViewport() {
    const [activeViewport, setActiveViewport] = useState(IModelApp.viewManager.selectedView);
    useEffect(() => {
        return IModelApp.viewManager.onSelectedViewportChanged.addListener((args) => {
            setActiveViewport(args.current);
        });
    }, []);
    return activeViewport;
}
//# sourceMappingURL=useActiveViewport.js.map