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 React from 'react';
import { Emoji } from '../commons/Emoji';
import { SECURITY_CODE_LENGTH, isCodeSufficientButInvalid } from '@universal-login/commons';
import { getStyleForTopLevelComponent } from '../../core/utils/getStyleForTopLevelComponent';
import '../styles/emoji.sass';
import '../styles/emojiDefaults.sass';
import range from 'lodash.range';
export var EmojiPlaceholders = function (_a) {
    var enteredCode = _a.enteredCode, publicKey = _a.publicKey, onEmojiClick = _a.onEmojiClick, className = _a.className;
    var renderEmojis = function () {
        return enteredCode.map(function (code, i) { return (React.createElement("li", { className: "emoji-item", key: i },
            React.createElement("button", { onClick: function () { return onEmojiClick && onEmojiClick(i); }, className: "emoji-keyboard-button" },
                React.createElement(Emoji, { code: code })))); });
    };
    var renderPlaceholderPanel = function () {
        var emojis = renderEmojis();
        var placeholders = range(emojis.length, SECURITY_CODE_LENGTH)
            .map(function (index) { return React.createElement("li", { className: "emoji-item emoji-item-empty", key: index }); });
        return __spread(emojis, placeholders);
    };
    return (React.createElement("div", { className: "universal-login-emojis" },
        React.createElement("div", { className: getStyleForTopLevelComponent(className) },
            React.createElement("div", { className: "emoji-placeholders-container" },
                React.createElement("ul", { className: "emojis-placeholders-list" }, renderPlaceholderPanel()),
                isCodeSufficientButInvalid(enteredCode, publicKey) && React.createElement("p", { className: "emoji-input-chosen-invalid" }, "Invalid emoji chosen")))));
};
//# sourceMappingURL=EmojiPlaceholders.js.map