import { __extends } from "tslib";
import { REMOVE_USER_SELECT_NAME } from '../directive-names';
import { MDOMPlugin, MElementDomPlugin } from '../domPlugin';
var MRemoveUserSelect = /** @class */ (function (_super) {
    __extends(MRemoveUserSelect, _super);
    function MRemoveUserSelect() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MRemoveUserSelect.prototype.attach = function (mount) {
        var _this = this;
        if (this.options === undefined) {
            this._options = true;
        }
        if (this.options) {
            mount(function () {
                _this.addEventListener('onmouseover', function (event) { event.preventDefault(); });
                _this.element.style['webkitUserSelect'] = 'none';
                _this.element.style['msUserSelect'] = 'none';
                _this.element.style.userSelect = 'none';
                _this.element.style['-moz-user-select'] = 'none';
                // mobile ios will display a gray box over element on touch start.  We don't want that.
                _this.element.style['webkitTapHighlightColor'] = 'rgba(0,0,0,0)';
            });
        }
    };
    MRemoveUserSelect.prototype.update = function (options, refresh) {
        if (options === undefined) {
            options = true;
        }
        this._options = options;
        if (this.options) {
            refresh(function () { });
        }
    };
    MRemoveUserSelect.prototype.detach = function () {
        this.removeAllEvents();
        this.element.style['webkitTapHighlightColor'] = '';
        this.element.style.userSelect = '';
        this.element.style['msUserSelect'] = '';
        this.element.style['webkitUserSelect'] = '';
        this.element.style['-moz-user-select'] = '';
    };
    MRemoveUserSelect.defaultMountPoint = '__mremoveuserselect__';
    return MRemoveUserSelect;
}(MElementDomPlugin));
export { MRemoveUserSelect };
var Directive = {
    bind: function (element, binding, node) {
        MDOMPlugin.attach(MRemoveUserSelect, element, binding.value);
    },
    update: function (element, binding, node) {
        MDOMPlugin.attach(MRemoveUserSelect, element, binding.value);
    },
    unbind: function (element, binding) {
        MDOMPlugin.detach(MRemoveUserSelect, element);
    }
};
var RemoveUserSelectPlugin = {
    install: function (v, options) {
        v.directive(REMOVE_USER_SELECT_NAME, Directive);
    }
};
export default RemoveUserSelectPlugin;
//# sourceMappingURL=remove-user-select.js.map