/*---------------------------------------------------------------------------------------------
* 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 * as React from "react";
import { useSelector } from "react-redux";
import { UiFramework } from "../UiFramework";
/**
 * @deprecated in 3.5. Used to toggle between UI1.0 and UI2.0.
 * @public
 */
export function useFrameworkVersion() {
    return React.useContext(FrameworkVersionContext); // eslint-disable-line deprecation/deprecation
}
/**
 * @deprecated in 3.5. Used to toggle between UI1.0 and UI2.0.
 * @public
 */
export const FrameworkVersionContext = React.createContext("2"); // eslint-disable-line @typescript-eslint/naming-convention, deprecation/deprecation
/** The FrameworkVersion component provides uiVersion context to react component. The
 * component uses the property frameworkState.configurableUiState.frameworkVersion from the redux store
 * to determine the ui version. This version will default to "2" and should only be set to "1" for older
 * iModelApp applications.
 * @deprecated in 3.5. Used to toggle between UI1.0 and UI2.0.
 * @public
 */
export function FrameworkVersion(props) {
    const uiVersion = useSelector((state) => {
        const frameworkState = state[UiFramework.frameworkStateKey];
        return frameworkState ? frameworkState.configurableUiState.frameworkVersion : "2"; // eslint-disable-line deprecation/deprecation
    });
    return React.createElement(FrameworkVersionContext.Provider // eslint-disable-line deprecation/deprecation
    , { children: props.children, value: uiVersion });
}
/** @internal */
export function FrameworkVersionSwitch(props) {
    const version = useFrameworkVersion(); // eslint-disable-line deprecation/deprecation
    switch (version) {
        case "1": {
            return React.createElement(React.Fragment, null, props.v1);
        }
        case "2":
        default: {
            return React.createElement(React.Fragment, null, props.v2);
        }
    }
}
//# sourceMappingURL=useFrameworkVersion.js.map