import * as tslib_1 from "tslib";
import ADialog from './ADialog';
import { cssClass } from '../../styles';
/** @internal */
var SearchDialog = /** @class */ (function (_super) {
    tslib_1.__extends(SearchDialog, _super);
    function SearchDialog(column, dialog, provider) {
        var _this = _super.call(this, dialog) || this;
        _this.column = column;
        _this.provider = provider;
        return _this;
    }
    SearchDialog.prototype.build = function (node) {
        var _this = this;
        node.insertAdjacentHTML('beforeend', "<input type=\"text\" size=\"20\" value=\"\" required autofocus placeholder=\"search... (>= 3 chars)\"><label class=\"" + cssClass('checkbox') + "\"><input type=\"checkbox\"><span>Use regular expressions</span></label>");
        var input = node.querySelector('input[type="text"]');
        var checkbox = node.querySelector('input[type="checkbox"]');
        var update = function () {
            var search = input.value;
            if (search.length < 3) {
                input.setCustomValidity('at least 3 characters');
                return;
            }
            input.setCustomValidity('');
            var isRegex = checkbox.checked;
            if (isRegex) {
                search = new RegExp(search);
            }
            _this.provider.searchAndJump(search, _this.column);
        };
        input.addEventListener('input', update, {
            passive: true
        });
        checkbox.addEventListener('change', update, {
            passive: true
        });
    };
    return SearchDialog;
}(ADialog));
export default SearchDialog;
//# sourceMappingURL=SearchDialog.js.map