import * as tslib_1 from "tslib";
import ADialog from './ADialog';
import { updateFilterState } from './utils';
import { cssClass } from '../../styles';
/** @internal */
var BooleanFilterDialog = /** @class */ (function (_super) {
    tslib_1.__extends(BooleanFilterDialog, _super);
    function BooleanFilterDialog(column, dialog) {
        var _this = _super.call(this, dialog, {
            fullDialog: true
        }) || this;
        _this.column = column;
        _this.before = _this.column.getFilter();
        return _this;
    }
    BooleanFilterDialog.prototype.build = function (node) {
        node.insertAdjacentHTML('beforeend', "\n     <label class=\"" + cssClass('checkbox') + "\"><input type=\"radio\" name=\"boolean_check\" value=\"null\" " + (this.before == null ? 'checked="checked"' : '') + "><span>No Filter</span></label>\n     <label class=\"" + cssClass('checkbox') + "\"><input type=\"radio\" name=\"boolean_check\" value=\"true\" " + (this.before === true ? 'checked="checked"' : '') + "><span>True</span></label>\n     <label class=\"" + cssClass('checkbox') + "\"><input type=\"radio\" name=\"boolean_check\" value=\"false\" " + (this.before === false ? 'checked="checked"' : '') + "><span>False</span></label>\n    ");
    };
    BooleanFilterDialog.prototype.updateFilter = function (filter) {
        updateFilterState(this.attachment, this.column, filter != null);
        this.column.setFilter(filter);
    };
    BooleanFilterDialog.prototype.reset = function () {
        var v = 'null';
        this.forEach('input[type="radio"]', function (d) { return d.checked = d.value === v; });
        this.updateFilter(null);
    };
    BooleanFilterDialog.prototype.submit = function () {
        var isTrue = this.findInput('input[type="radio"][value="true"]').checked;
        var isFalse = this.findInput('input[type="radio"][value="false"]').checked;
        this.updateFilter(isTrue ? true : (isFalse ? false : null));
        return true;
    };
    return BooleanFilterDialog;
}(ADialog));
export default BooleanFilterDialog;
//# sourceMappingURL=BooleanFilterDialog.js.map