"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isEnter = void 0;
exports.getAlertGptInfo = getAlertGptInfo;
exports.getDisableReplaceButtonText = getDisableReplaceButtonText;
exports.getInputPlaceHolder = getInputPlaceHolder;
exports.focusWithoutScroll = focusWithoutScroll;
exports.isEmptyGptPrompts = isEmptyGptPrompts;
const dialog_1 = require("../../../i18n/gpt/dialog/index.js");
function getAlertGptInfo(gptAlert) {
    return {
        alertMessage: gptAlert?.message || (0, dialog_1.i18n)('alert-gpt-presets-info'),
        alertTheme: gptAlert?.theme || 'info',
        alertClassName: gptAlert?.className,
    };
}
function getDisableReplaceButtonText(disablePromptPresets) {
    return disablePromptPresets ? (0, dialog_1.i18n)(`replace-disabled`) : (0, dialog_1.i18n)(`replace`);
}
function getInputPlaceHolder(disablePromptPresets, disabledPromptPlaceholder, customPromptPlaceholder) {
    return disablePromptPresets ? disabledPromptPlaceholder : customPromptPlaceholder;
}
const isEnter = (event) => event.code === 'Enter' || event.code === 'NumpadEnter';
exports.isEnter = isEnter;
function focusWithoutScroll(element) {
    const x = window.scrollX;
    const y = window.scrollY;
    element?.focus({
        preventScroll: true,
    });
    window.scrollTo(x, y);
}
function isEmptyGptPrompts(gptWidgetOptions, disablePromptPresets) {
    if (disablePromptPresets && !gptWidgetOptions.onCustomPromptApply)
        return true;
    if (!disablePromptPresets &&
        !gptWidgetOptions.promptPresets?.length &&
        !gptWidgetOptions.onCustomPromptApply)
        return true;
    return false;
}
//# sourceMappingURL=utils.js.map
