var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __spread = (this && this.__spread) || function () {
    for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
    return ar;
};
import { EmojiPlaceholders } from './EmojiPlaceholders';
import React from 'react';
import { EmojiKeyboard } from './EmojiKeyboard';
import { EmojiPanelWithFakes } from './EmojiPanelWithFakes';
import { SECURITY_CODE_LENGTH } from '@universal-login/commons';
export var EmojiInput = function (_a) {
    var value = _a.value, onChange = _a.onChange, publicKey = _a.publicKey, className = _a.className;
    var onEmojiAdd = function (code) {
        if (value.length < SECURITY_CODE_LENGTH) {
            onChange(__spread(value, [code]));
        }
    };
    var onEmojiRemove = function (index) {
        if (value.length >= 0) {
            onChange(removeAtIndex(value, index));
        }
    };
    return (React.createElement(React.Fragment, null,
        React.createElement(EmojiPlaceholders, { enteredCode: value, publicKey: publicKey, onEmojiClick: onEmojiRemove, className: className }),
        publicKey
            ? (React.createElement(EmojiPanelWithFakes, { publicKey: publicKey, onEmojiClick: onEmojiAdd, className: className }))
            : React.createElement(EmojiKeyboard, { onEmojiClick: onEmojiAdd, className: className })));
};
function removeAtIndex(array, index) {
    return __spread(array.slice(0, index), array.slice(index + 1));
}
//# sourceMappingURL=EmojiInput.js.map