"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 Tools
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.getKeyinsFromToolList = exports.KeyinFieldLocalization = void 0;
/**
 * Controls whether localized and/or non-localized key-in strings appear in a KeyinField's auto-completion list.
 * @public
 */
var KeyinFieldLocalization;
(function (KeyinFieldLocalization) {
    /** Include only non-localized key-in strings. */
    KeyinFieldLocalization[KeyinFieldLocalization["NonLocalized"] = 0] = "NonLocalized";
    /** Include only localized key-in strings. */
    KeyinFieldLocalization[KeyinFieldLocalization["Localized"] = 1] = "Localized";
    /** Include localized and non-localized strings for each key-in. */
    KeyinFieldLocalization[KeyinFieldLocalization["Both"] = 2] = "Both";
})(KeyinFieldLocalization || (exports.KeyinFieldLocalization = KeyinFieldLocalization = {}));
/**
 * Parses a given ToolList for its tools keyins, filtering based on a KeyinFieldLocalization value.
 * @internal
 */
function getKeyinsFromToolList(toolList, localizedKeyinPreference = KeyinFieldLocalization.NonLocalized) {
    const toolKeyins = [];
    for (const tool of toolList) {
        switch (localizedKeyinPreference) {
            case KeyinFieldLocalization.Localized:
                toolKeyins.push({ value: tool.keyin });
                break;
            case KeyinFieldLocalization.Both:
                toolKeyins.push({ value: tool.keyin });
                if (tool.keyin === tool.englishKeyin)
                    break;
            default: // eslint-disable-line no-fallthrough
            case KeyinFieldLocalization.NonLocalized:
                if (KeyinFieldLocalization.NonLocalized === localizedKeyinPreference ||
                    (KeyinFieldLocalization.Both === localizedKeyinPreference &&
                        tool.englishKeyin !== tool.keyin))
                    toolKeyins.push({ value: tool.englishKeyin });
                break;
        }
    }
    return toolKeyins;
}
exports.getKeyinsFromToolList = getKeyinsFromToolList;
//# sourceMappingURL=Keyins.js.map