"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmojiSuggest = void 0;
const Autocomplete_1 = require("../../../behavior/Autocomplete/index.js");
const EmojiHandler_1 = require("./EmojiHandler.js");
const const_1 = require("./const.js");
const emojiSuggestActionName = 'openEmojiSuggest';
const EmojiSuggest = (builder, { defs, shortcuts }) => {
    if (!defs)
        return;
    if (!builder.context.has('autocomplete')) {
        builder.use(Autocomplete_1.Autocomplete);
    }
    const item = {
        trigger: {
            name: 'emoji',
            trigger: /(?:^|\s)(:)$/,
            allArrowKeys: false,
            cancelOnFirstSpace: true,
            decorationAttrs: { class: const_1.DecoClassName },
        },
        handler: new EmojiHandler_1.EmojiHandler({ defs, shortcuts }),
    };
    builder.context.get('autocomplete').add(item);
    builder.addAction(emojiSuggestActionName, () => {
        return {
            isEnable: (state) => {
                return state.selection.empty;
            },
            run: (_s, _d, view, attrs) => {
                return (0, Autocomplete_1.openAutocomplete)(view, ':', attrs?.text);
            },
        };
    });
};
exports.EmojiSuggest = EmojiSuggest;
//# sourceMappingURL=EmojiSuggest.js.map
