"use strict";
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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var Emoji_1 = require("../commons/Emoji");
var commons_1 = require("@universal-login/commons");
var getStyleForTopLevelComponent_1 = require("../../core/utils/getStyleForTopLevelComponent");
require("../styles/emoji.sass");
require("../styles/emojiDefaults.sass");
var lodash_range_1 = __importDefault(require("lodash.range"));
exports.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_1.default.createElement("li", { className: "emoji-item", key: i },
            react_1.default.createElement("button", { onClick: function () { return onEmojiClick && onEmojiClick(i); }, className: "emoji-keyboard-button" },
                react_1.default.createElement(Emoji_1.Emoji, { code: code })))); });
    };
    var renderPlaceholderPanel = function () {
        var emojis = renderEmojis();
        var placeholders = lodash_range_1.default(emojis.length, commons_1.SECURITY_CODE_LENGTH)
            .map(function (index) { return react_1.default.createElement("li", { className: "emoji-item emoji-item-empty", key: index }); });
        return __spread(emojis, placeholders);
    };
    return (react_1.default.createElement("div", { className: "universal-login-emojis" },
        react_1.default.createElement("div", { className: getStyleForTopLevelComponent_1.getStyleForTopLevelComponent(className) },
            react_1.default.createElement("div", { className: "emoji-placeholders-container" },
                react_1.default.createElement("ul", { className: "emojis-placeholders-list" }, renderPlaceholderPanel()),
                commons_1.isCodeSufficientButInvalid(enteredCode, publicKey) && react_1.default.createElement("p", { className: "emoji-input-chosen-invalid" }, "Invalid emoji chosen")))));
};
//# sourceMappingURL=EmojiPlaceholders.js.map