"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Settings
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnitSystemSelector = void 0;
const React = require("react");
const UiFramework_1 = require("../../UiFramework");
const itwinui_react_1 = require("@itwin/itwinui-react");
/** Select control to set the "active" Presentation Unit System. This setting determine what units are display for quantity values (i.e. foot vs meter).
 * @alpha
 */
function UnitSystemSelector(props) {
    const label = React.useRef(UiFramework_1.UiFramework.translate("presentationUnitSystem.selector-label"));
    const { selectedUnitSystemKey, onUnitSystemSelected, availableUnitSystems } = props;
    const handleUnitSystemSelected = React.useCallback((newValue) => {
        onUnitSystemSelected && onUnitSystemSelected(newValue);
    }, [onUnitSystemSelected]);
    const displayUnitSystems = [...availableUnitSystems.values()].map((sys) => {
        switch (sys) {
            case "imperial":
                return {
                    value: "imperial",
                    label: UiFramework_1.UiFramework.translate("presentationUnitSystem.BritishImperial"),
                };
            case "usCustomary":
                return {
                    value: "usCustomary",
                    label: UiFramework_1.UiFramework.translate("presentationUnitSystem.USCustomary"),
                };
            case "usSurvey":
                return {
                    value: "usSurvey",
                    label: UiFramework_1.UiFramework.translate("presentationUnitSystem.USSurvey"),
                };
            case "metric":
            default:
                return {
                    value: "metric",
                    label: UiFramework_1.UiFramework.translate("presentationUnitSystem.Metric"),
                };
        }
    });
    const unitSystemKey = availableUnitSystems.has(selectedUnitSystemKey) ? selectedUnitSystemKey : displayUnitSystems[0].value;
    return (React.createElement("div", { className: "quantity-unit-system-selector-container" },
        React.createElement("span", { className: "uicore-label" }, label.current),
        React.createElement(itwinui_react_1.Select, { "data-testid": "unitSystemSelector", value: unitSystemKey, options: displayUnitSystems, onChange: handleUnitSystemSelected, size: "small" })));
}
exports.UnitSystemSelector = UnitSystemSelector;
//# sourceMappingURL=UnitSystemSelector.js.map