/*---------------------------------------------------------------------------------------------
 * 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 { IModelApp } from "@itwin/core-frontend";
import { useSyncExternalStore } from "use-sync-external-store/shim";
const subscribe = (onStoreChange) => {
    return IModelApp.viewManager.onSelectedViewportChanged.addListener(onStoreChange);
};
const getSnapshot = () => {
    return IModelApp.viewManager.selectedView;
};
/** React hook that maintains the active viewport.
 * @public
 */
export function useActiveViewport() {
    const activeViewport = useSyncExternalStore(subscribe, getSnapshot);
    return activeViewport;
}
//# sourceMappingURL=useActiveViewport.js.map