"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "handleItemError", {
    enumerable: true,
    get: function() {
        return handleItemError;
    }
});
var _CodeInputtokens = require("../CodeInput.tokens");
var _constants = require("../../../utils/constants");
var handleItemError = function handleItemError(param) {
    var currentSymbol = param.currentSymbol, itemErrorBehavior = param.itemErrorBehavior, index = param.index, newCode = param.newCode, inputRefs = param.inputRefs, inputContainerRef = param.inputContainerRef, codeSetter = param.codeSetter;
    var _inputContainerRef_current;
    if (!inputRefs.current[index] || currentSymbol === ' ') {
        return;
    }
    var circleElement = (_inputContainerRef_current = inputContainerRef.current) === null || _inputContainerRef_current === void 0 ? void 0 : _inputContainerRef_current.querySelector(".".concat(_CodeInputtokens.classes.itemCircle, "-").concat(index));
    switch(itemErrorBehavior){
        case 'forbid-enter':
            newCode[index] = '';
            codeSetter(newCode);
            break;
        case 'remove-symbol':
        default:
            newCode[index] = '';
            codeSetter(newCode);
            if (circleElement) {
                circleElement.classList.add(_CodeInputtokens.classes.itemCircleError, _CodeInputtokens.classes.itemCircleErrorAnimation);
            }
            setTimeout(function() {
                if (circleElement) {
                    circleElement.classList.remove(_CodeInputtokens.classes.itemCircleError, _CodeInputtokens.classes.itemCircleErrorAnimation);
                }
            }, _constants.ANIMATION_TIMEOUT);
    }
};
