var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
define(["require", "exports", "jquery", "./context-menu"], function (require, exports, jquery_1, context_menu_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    jquery_1 = __importDefault(jquery_1);
    /**
     * A menu for displaying replacement values.
     */
    class ReplacementMenu extends context_menu_1.ContextMenu {
        /**
         * @param editor The editor for which to create this menu.
         *
         * @param document The DOM document for which to make this context menu.
         *
         * @param x Position of the menu. The context menu may ignore this position if
         * the menu would appear off-screen.
         *
         * @param y Position of the menu.
         *
         * @param items An array of possible replacement values.
         *
         * @param dismissCallback Function to call when the menu is dismissed.
         */
        constructor(editor, document, x, y, items, dismissCallback) {
            super(document, x, y, [], () => {
                dismissCallback(this.selected);
            }, false);
            this.replacementItems = items;
            this.editor = editor;
            this.dropdown.classList.add("wed-replacement-menu");
            this.display([]);
        }
        render() {
            const items = [];
            const doc = this.editor.doc;
            for (const item of this.replacementItems) {
                const li = doc.createElement("li");
                // tslint:disable-next-line:no-inner-html
                li.innerHTML = "<a href='#'></a>";
                li.lastChild.textContent = item;
                items.push(li);
                jquery_1.default(li).click(item, () => {
                    this.selected = item;
                    this.dismiss();
                });
            }
            super.render(items);
        }
        dismiss() {
            if (this.dismissed) {
                return;
            }
            super.dismiss();
        }
    }
    exports.ReplacementMenu = ReplacementMenu;
});
//  LocalWords:  MPL li href
//# sourceMappingURL=replacement-menu.js.map