/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import * as tslib_1 from "tslib";
import { EventProxy } from "./EventProxy";
import { Point_$type, runOn, markType, PointUtil, String_$type, Delegate_$type } from "./type";
import { Rect } from "./Rect";
import { MouseEventArgs } from "./MouseEventArgs";
import { Dictionary$2 } from "./Dictionary$2";
import { List$1 } from "./List$1";
/**
 * @hidden
 */
var BaseDOMEventProxy = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(BaseDOMEventProxy, _super);
    function BaseDOMEventProxy() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.bz = null;
        _this.bq = false;
        _this.bs = false;
        _this.by = null;
        _this.bj = false;
        _this.bw = 0;
        _this.bx = 0;
        _this.bu = 0;
        _this.bv = 0;
        _this.b0 = 0;
        _this.cy = null;
        _this.cx = null;
        _this.bi = false;
        _this.b1 = -1;
        _this.bn = false;
        _this.bk = false;
        _this.bh = false;
        return _this;
    }
    BaseDOMEventProxy.prototype.d = function () {
        var a = new DOMEventProxy(this.bz, this.by, this.bs);
        a.aa = this.aa;
        a.am = this.am;
        return a;
    };
    Object.defineProperty(BaseDOMEventProxy, "bt", {
        get: function () {
            return (BaseDOMEventProxy.bo || BaseDOMEventProxy.bp);
        },
        enumerable: true,
        configurable: true
    });
    BaseDOMEventProxy.prototype.bf = function (a) {
        return DOMEventProxy.cz(a);
    };
    BaseDOMEventProxy.prototype.bm = function (e_) {
        var pointerEvent_ = e_.originalEvent;
        var a = false;
        if (BaseDOMEventProxy.bp) {
            a = (pointerEvent_.pointerType == 'touch');
        }
        else {
            a = (pointerEvent_.pointerType == pointerEvent_.MSPOINTER_TYPE_TOUCH);
        }
        return a;
    };
    BaseDOMEventProxy.prototype.cp = function (a) {
        if (!this.ac) {
            if (this.bl(a)) {
                if (this.ao == null || this.ao(a)) {
                    a.preventDefault();
                }
            }
        }
    };
    BaseDOMEventProxy.prototype.bl = function (e_) {
        return (e_.originalEvent.cancelable || e_.originalEvent.cancelable == undefined);
    };
    BaseDOMEventProxy.prototype.cl = function () {
        var source_ = this.bz.getNativeElement();
        BaseDOMEventProxy.co(source_);
    };
    BaseDOMEventProxy.co = function (source_) {
        if (BaseDOMEventProxy.bp) {
            source_.style.touchAction = 'none';
        }
        else {
            source_.style.msTouchAction = 'none';
        }
        source_.style.msUserSelect = 'none';
        source_.style.webkitTouchCallout = 'none';
        source_.style.webkitUserSelect = 'none';
        source_.style.khtmlUserSelect = 'none';
        source_.style.mozUserSelect = 'none';
        source_.style.userSelect = 'none';
    };
    BaseDOMEventProxy.ci = function (source_) {
        if (BaseDOMEventProxy.bp) {
            source_.style.touchAction = 'auto';
        }
        else {
            source_.style.msTouchAction = 'auto';
        }
        source_.style.msUserSelect = 'auto';
        source_.style.webkitTouchCallout = 'none';
        source_.style.webkitUserSelect = 'auto';
        source_.style.khtmlUserSelect = 'auto';
        source_.style.mozUserSelect = 'auto';
        source_.style.userSelect = 'auto';
    };
    BaseDOMEventProxy.prototype.cj = function () {
        var source_ = this.bz.getNativeElement();
        BaseDOMEventProxy.ci(source_);
    };
    BaseDOMEventProxy.prototype.as = function () {
        _super.prototype.as.call(this);
        if (!this.ac) {
            this.cl();
        }
        else {
            this.cj();
        }
    };
    BaseDOMEventProxy.prototype.b6 = function () {
        var ver_ = -1;
        var matchIE_ = /Trident\/([\d.]+)/;
        if ((matchIE_.exec(navigator.userAgent) != null)) {
            ver_ = (parseFloat(RegExp.$1));
        }
        return ver_;
    };
    BaseDOMEventProxy.prototype.b5 = function () {
        var ver_ = -1;
        var matchIE_ = /Edge\/([\d.]+)/;
        if ((matchIE_.exec(navigator.userAgent) != null)) {
            ver_ = (parseFloat(RegExp.$1));
        }
        return ver_;
    };
    BaseDOMEventProxy.cn = function (e_) {
        var a = BaseDOMEventProxy.b7 >= 6;
        var oe_ = e_.originalEvent;
        if ((((typeof e_.pageX == 'undefined')) || a) && oe_.clientX != null) {
            var od_ = void 0;
            if ((e_.target !== undefined)) {
                od_ = e_.target.ownerDocument;
            }
            else {
                od_ = e_.originalEvent.target.ownerDocument;
            }
            var ed_ = od_ ? od_ : document;
            var doc_ = ed_.documentElement;
            var body_ = ed_.body;
            var clientX_ = oe_.clientX;
            var clientY_ = oe_.clientY;
            var scrollLeft_ = doc_ && doc_.scrollLeft || body_ && body_.scrollLeft || 0;
            var scrollTop_ = doc_ && doc_.scrollTop || body_ && body_.scrollTop || 0;
            var clientLeft_ = doc_ && doc_.clientLeft || body_ && body_.clientLeft || 0;
            var clientTop_ = doc_ && doc_.clientTop || body_ && body_.clientTop || 0;
            e_.pageX = clientX_ + (scrollLeft_ - clientLeft_);
            e_.pageY = clientY_ + (scrollTop_ - clientTop_);
        }
        if ((!e_.pageX)) {
            e_.pageX = e_.originalEvent.pageX;
        }
        if ((!e_.pageY)) {
            e_.pageY = e_.originalEvent.pageY;
        }
        if (((typeof e_.button == 'undefined')) && ((typeof oe_.button != 'undefined'))) {
            e_.button = oe_.button;
        }
    };
    BaseDOMEventProxy.cz = function (a) {
        var b = BaseDOMEventProxy.b7 >= 6;
        var source_ = a.getNativeElement();
        var d_ = source_.ownerDocument;
        var doc_ = d_ ? d_.documentElement : null;
        var z_ = doc_ ? doc_.msContentZoomFactor : null;
        var body_ = doc_.body;
        if ((z_ && z_ > 1) || b) {
            var rect_ = source_.getBoundingClientRect();
            var x_ = (rect_.left);
            var y_ = (rect_.top);
            var scrollLeft_ = (doc_ && doc_.scrollLeft || body_ && body_.scrollLeft || 0);
            var scrollTop_ = (doc_ && doc_.scrollTop || body_ && body_.scrollTop || 0);
            var clientLeft_ = (doc_ && doc_.clientLeft || body_ && body_.clientLeft || 0);
            var clientTop_ = (doc_ && doc_.clientTop || body_ && body_.clientTop || 0);
            var c = x_ + scrollLeft_ - clientLeft_;
            var d = y_ + scrollTop_ - clientTop_;
            return new Rect(0, c, d, 0, 0);
        }
        else {
            var e = a.getOffset();
            return new Rect(0, e.left, e.top, 0, 0);
        }
    };
    Object.defineProperty(BaseDOMEventProxy.prototype, "b3", {
        get: function () {
            return this.b0;
        },
        set: function (a) {
            this.b0 = a;
        },
        enumerable: true,
        configurable: true
    });
    BaseDOMEventProxy.prototype.cs = function (a) {
        this.ap = a;
        BaseDOMEventProxy.cn(a);
        var b = BaseDOMEventProxy.cz(this.bz);
        var c = 0;
        var d = 0;
        if (Rect.l_op_Inequality(this.bg, null)) {
            c = this.bg.left;
            d = this.bg.top;
        }
        this.bw = a.pageX - b.left;
        this.bx = a.pageY - b.top;
        this.bu = this.bw - c;
        this.bv = this.bx - d;
        this.cy = { $type: Point_$type, x: this.bw, y: this.bx };
        this.cx = { $type: Point_$type, x: this.bu, y: this.bv };
    };
    BaseDOMEventProxy.prototype.ct = function (e_) {
        this.ap = e_;
        BaseDOMEventProxy.cn(e_);
        if (BaseDOMEventProxy.bt) {
            var a = e_.pageX;
            var b = e_.pageY;
            var c = BaseDOMEventProxy.cz(this.bz);
            this.bw = a - c.left;
            this.bx = b - c.top;
        }
        else {
            this.b0 = 0;
            if (!e_.originalEvent.targetTouches || e_.originalEvent.targetTouches.length < 1) {
                return;
            }
            ;
            this.b0 = (e_.originalEvent.targetTouches.length);
            var d = (e_.originalEvent.targetTouches[0].pageX);
            var e = (e_.originalEvent.targetTouches[0].pageY);
            var f = BaseDOMEventProxy.cz(this.bz);
            this.bw = d - f.left;
            this.bx = e - f.top;
        }
        var g = 0;
        var h = 0;
        if (Rect.l_op_Inequality(this.bg, null)) {
            g = this.bg.left;
            h = this.bg.top;
        }
        this.bu = this.bw - g;
        this.bv = this.bx - h;
        this.cy = { $type: Point_$type, x: this.bw, y: this.bx };
        this.cx = { $type: Point_$type, x: this.bu, y: this.bv };
    };
    BaseDOMEventProxy.prototype.ch = function (e_) {
        this.cr(e_);
        if (this.ab(this.cy, false, true)) {
            var deltaY_ = 0;
            var ev_ = e_;
            deltaY_ = (ev_.originalEvent ? ev_.originalEvent.deltaY : ev_.deltaY);
            var deltaX_ = 0;
            deltaX_ = (ev_.originalEvent ? ev_.originalEvent.deltaX : ev_.deltaX);
            var a = (ev_.originalEvent ? (ev_.originalEvent.deltaMode == 1) : (ev_.deltaMode == 1));
            if (a) {
                deltaY_ = deltaY_ * 40;
                deltaX_ = deltaX_ * 40;
            }
            var b = this.ag(this.cx, deltaY_);
            var c = this.ah(this.cx, deltaX_);
            if (b || c) {
                this.cp(e_);
            }
        }
    };
    BaseDOMEventProxy.prototype.cf = function (e_) {
        this.cr(e_);
        this.cs(e_);
        if (this.ab(this.cy, false, true)) {
            var ev_ = e_;
            var delta_ = 0;
            if (ev_.wheelDelta) {
                delta_ = ev_.wheelDelta / 120;
            }
            ;
            if (ev_.originalEvent && ev_.originalEvent.wheelDelta) {
                delta_ = ev_.originalEvent.wheelDelta / 120;
            }
            ;
            if (ev_.detail) {
                delta_ = -ev_.detail / 3;
            }
            ;
            if (ev_.originalEvent && ev_.originalEvent.detail) {
                delta_ = -ev_.originalEvent.detail / 3;
            }
            ;
            delta_ = delta_ / 10;
            var a = this.ag(this.cx, delta_);
            if (a) {
                this.cp(e_);
            }
        }
    };
    BaseDOMEventProxy.prototype.cm = function () {
        if (this.bi) {
            if (this.b1 == -1) {
                this.b1 = this.by.setTimeout(runOn(this, this.ck), 500);
            }
            else {
                window.clearTimeout(this.b1);
                this.b1 = -1;
                this.b1 = this.by.setTimeout(runOn(this, this.ck), 500);
            }
        }
    };
    BaseDOMEventProxy.prototype.b8 = function () {
        this.bi = true;
        if (this.b1 != -1) {
            window.clearTimeout(this.b1);
            this.b1 = -1;
        }
    };
    BaseDOMEventProxy.prototype.ck = function () {
        this.bi = false;
    };
    Object.defineProperty(BaseDOMEventProxy.prototype, "br", {
        get: function () {
            return this.bk;
        },
        set: function (a) {
            this.bk = a;
        },
        enumerable: true,
        configurable: true
    });
    BaseDOMEventProxy.prototype.cd = function (a) {
        if (this.bk || this.bi) {
            return;
        }
        this.cs(a);
        if (this.bn) {
            this.bn = false;
            this.a4(this.cx);
        }
    };
    BaseDOMEventProxy.prototype.ce = function (a) {
        if (this.bk || this.bi) {
            return;
        }
        this.cs(a);
        this.cr(a);
        var b = new MouseEventArgs();
        b.position = this.cy;
        if (this.ab(this.cy, false, false)) {
            if (!this.bn) {
                this.bn = true;
                this.a3(this.cy);
            }
            this.a5(this.cy, true, false);
            this.au(this.cx, false);
        }
        else if (this.bn) {
            this.cd(a);
        }
    };
    BaseDOMEventProxy.prototype.cq = function (a) {
        this.bz.focus(this.bq);
    };
    BaseDOMEventProxy.prototype.cc = function (a) {
        if (this.bk || this.bi) {
            return;
        }
        this.cq(a);
        this.cs(a);
        this.cr(a);
        if (this.ab(this.cy, false, false)) {
            this.bh = true;
            this.a2(this.cy);
            this.av(this.cx, false);
            this.cp(a);
        }
    };
    BaseDOMEventProxy.prototype.cu = function (a) {
        if (this.bk || this.bi) {
            return;
        }
        if (this.bh) {
            this.cg(a);
        }
    };
    BaseDOMEventProxy.prototype.cg = function (a) {
        if (this.bk || this.bi) {
            return;
        }
        this.cr(a);
        if (PointUtil.equals(this.cy, null) || PointUtil.equals(this.cx, null)) {
            this.cs(a);
        }
        var b = this.ab(this.cy, false, false) || this.bh || this.bn;
        this.bh = false;
        this.a6(this.cy);
        this.at(this.cx, false, false);
        if (b) {
            this.cp(a);
        }
    };
    BaseDOMEventProxy.prototype.b9 = function (a) {
        this.ca(a, true);
    };
    BaseDOMEventProxy.prototype.cb = function (a) {
        this.ca(a, false);
    };
    BaseDOMEventProxy.prototype.cw = function (a) {
        return BaseDOMEventProxy.cv(a);
    };
    BaseDOMEventProxy.cv = function (a) {
        var b;
        switch (a.which) {
            case 33:
                b = 10;
                break;
            case 34:
                b = 11;
                break;
            case 36:
                b = 13;
                break;
            case 37:
                b = 14;
                break;
            case 38:
                b = 15;
                break;
            case 39:
                b = 16;
                break;
            case 40:
                b = 17;
                break;
            case 9:
                b = 2;
                break;
            case 32:
                b = 9;
                break;
            case 13:
                b = 3;
                break;
            case 27:
                b = 8;
                break;
            case 16:
                b = 4;
                break;
            case 17:
                b = 5;
                break;
            case 18:
                b = 6;
                break;
            case 8:
                b = 1;
                break;
            case 35:
                b = 12;
                break;
            case 45:
                b = 18;
                break;
            case 46:
                b = 19;
                break;
            case 106:
                b = 78;
                break;
            case 107:
                b = 79;
                break;
            case 109:
                b = 80;
                break;
            case 110:
                b = 81;
                break;
            case 111:
                b = 82;
                break;
            case 220:
                b = 85;
                break;
            case 192:
                b = 86;
                break;
            case 191:
                b = 84;
                break;
            case 186:
                b = 83;
                break;
            case 189:
                b = 88;
                break;
            case 187:
                b = 87;
                break;
            default:
                if (112 <= a.which && a.which <= 123) {
                    b = (56 + a.which - 112);
                }
                else if (65 <= a.which && a.which <= 90) {
                    b = (30 + a.which - 65);
                }
                else if (48 <= a.which && a.which <= 57) {
                    b = (20 + a.which - 48);
                }
                else if (96 <= a.which && a.which <= 105) {
                    b = (68 + a.which - 96);
                }
                else {
                    b = 0;
                }
                break;
        }
        return b;
    };
    BaseDOMEventProxy.prototype.ca = function (a, b) {
        var c = this.cw(a);
        var d = c != 0;
        this.cr(a);
        if (d) {
            var e = false;
            if (b) {
                e = this.ae(c);
            }
            else {
                e = this.af(c);
            }
            if (e) {
                this.cp(a);
            }
        }
    };
    BaseDOMEventProxy.prototype.cr = function (a) {
        this.ap = a;
        this.bd = 0;
        if (a.shiftKey) {
            this.bd = this.bd | 4;
        }
        if (a.altKey) {
            this.bd = this.bd | 1;
        }
        if (a.ctrlKey) {
            this.bd = this.bd | 2;
        }
        this.ai = a.button == 2;
    };
    BaseDOMEventProxy.prototype.be = function () {
        var a = BaseDOMEventProxy.cz(this.bz);
        var b = a.left;
        var c = a.top;
        return { $type: Point_$type, x: b, y: c };
    };
    BaseDOMEventProxy.$t = markType(BaseDOMEventProxy, 'BaseDOMEventProxy', EventProxy.$);
    BaseDOMEventProxy.bo = false;
    BaseDOMEventProxy.bp = false;
    BaseDOMEventProxy.b7 = 0;
    BaseDOMEventProxy.b4 = 0;
    return BaseDOMEventProxy;
}(EventProxy));
export { BaseDOMEventProxy };
/**
 * @hidden
 */
var DOMEventProxy = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(DOMEventProxy, _super);
    function DOMEventProxy(a, b, c) {
        var _this = _super.call(this) || this;
        _this.c9 = 0;
        _this.db = "";
        _this.c1 = false;
        _this.da = null;
        _this.c3 = new Dictionary$2(String_$type, List$1.$.specialize(Delegate_$type), 0);
        _this.dy = null;
        _this.c7 = -1;
        _this.dz = null;
        _this.c5 = 0;
        _this.c6 = 0;
        _this.c4 = 5;
        _this.c0 = false;
        _this.dx = null;
        _this.bs = c;
        _this.by = b;
        _this.am = function (d) { return true; };
        _this.aa = false;
        DOMEventProxy.c8++;
        _this.c9 = DOMEventProxy.c8;
        _this.db = ".DOMProxy" + _this.c9.toString();
        _this.bd = 0;
        _this.bz = a;
        BaseDOMEventProxy.bo = false;
        try {
            BaseDOMEventProxy.bo = (window.navigator.msPointerEnabled && window.MSGesture !== undefined);
        }
        catch (d) {
        }
        BaseDOMEventProxy.bp = false;
        try {
            BaseDOMEventProxy.bp = (window.PointerEvent !== undefined);
        }
        catch (e) {
        }
        BaseDOMEventProxy.b7 = _this.b6();
        BaseDOMEventProxy.b4 = _this.b5();
        _this.aq(_this.bz, "");
        _this.al = function (f) { return true; };
        return _this;
    }
    DOMEventProxy.prototype.dc = function (a, b, c) {
    };
    DOMEventProxy.prototype.aq = function (a, b) {
        var c = a;
        var d = this.db + b;
        if (!this.by.supportsDOMEvents()) {
            return;
        }
        var e = new List$1(Delegate_$type, 0);
        this.c3.addItem(d, e);
        this.dc(a, b, e);
        if (!BaseDOMEventProxy.bt) {
            e.add(c.listen("mousemove", runOn(this, this.ce)));
            e.add(c.listen("mouseleave", runOn(this, this.cd)));
            e.add(c.listen("mousedown", runOn(this, this.cc)));
            e.add(c.listen("mouseup", runOn(this, this.cg)));
            e.add(this.by.globalListen("window", "mouseup", runOn(this, this.cu)));
        }
        e.add(c.listen("keydown", runOn(this, this.b9)));
        e.add(c.listen("keyup", runOn(this, this.cb)));
        var source_ = this.bz.getNativeElement();
        if (!this.ac) {
            BaseDOMEventProxy.co(source_);
        }
        if (BaseDOMEventProxy.bt) {
            var f = this.bz.getNativeElement();
            if ((window.MSGesture !== undefined)) {
                var gesture_ = new window.MSGesture();
                var container_ = f;
                gesture_.target = container_;
                this.da = gesture_;
                e.add(c.listen("MSGestureStart", runOn(this, this.df)));
                e.add(c.listen("MSGestureChange", runOn(this, this.dd)));
                e.add(c.listen("MSGestureEnd", runOn(this, this.de)));
            }
            if (BaseDOMEventProxy.bp) {
                e.add(c.listen("pointerdown", runOn(this, this.di)));
                e.add(c.listen("pointerup", runOn(this, this.dl)));
                e.add(c.listen("pointercancel", runOn(this, this.dh)));
                e.add(c.listen("pointermove", runOn(this, this.dj)));
                e.add(c.listen("pointerout", runOn(this, this.dk)));
                e.add(c.listen("lostpointercapture", runOn(this, this.dg)));
            }
            else {
                e.add(c.listen("MSPointerDown", runOn(this, this.di)));
                e.add(c.listen("MSPointerUp", runOn(this, this.dl)));
                e.add(c.listen("MSPointerCancel", runOn(this, this.dh)));
                e.add(c.listen("MSPointerMove", runOn(this, this.dj)));
                e.add(c.listen("MSPointerOut", runOn(this, this.dk)));
                e.add(c.listen("MSLostPointerCapture", runOn(this, this.dg)));
            }
        }
        else {
            e.add(c.listen("gesturestart", runOn(this, this.df)));
            e.add(c.listen("gesturechange", runOn(this, this.dd)));
            e.add(c.listen("gestureend", runOn(this, this.de)));
            e.add(c.listen("touchstart", runOn(this, this.dp)));
            e.add(c.listen("touchmove", runOn(this, this.dn)));
            e.add(c.listen("touchend", runOn(this, this.dm)));
        }
        if (this.bs) {
            e.add(c.listen("wheel", runOn(this, this.ch)));
        }
        else {
            e.add(c.listen("DOMMouseScroll", runOn(this, this.cf)));
            e.add(c.listen("mousewheel", runOn(this, this.cf)));
        }
    };
    DOMEventProxy.prototype.dl = function (e_) {
        var a = this.bm(e_);
        if (a) {
            this.b3 = this.b3 - 1;
            if (this.b3 < 0) {
                this.b3 = 0;
            }
        }
        if (this.b3 < 2 && this.c1 && a) {
            this.c1 = false;
            var b = (e_.originalEvent.scale);
            this.a0(this.cx, b);
        }
        else {
            if (a) {
                this.dm(e_);
            }
            else {
                this.cg(e_);
            }
        }
    };
    DOMEventProxy.prototype.dg = function (e_) {
        var a = this.bm(e_);
        if (a) {
            this.b3--;
            if (this.b3 < 0) {
                this.b3 = 0;
            }
        }
        if (this.b3 < 2 && this.c1 && a) {
            this.c1 = false;
            var b = (e_.originalEvent.scale);
            this.a0(this.cx, b);
        }
    };
    DOMEventProxy.prototype.dh = function (e_) {
        var a = this.bm(e_);
        if (a) {
            this.b3--;
            if (this.b3 < 0) {
                this.b3 = 0;
            }
        }
        if (this.b3 < 2 && this.c1 && a) {
            this.c1 = false;
            var b = (e_.originalEvent.scale);
            this.a0(this.cx, b);
        }
    };
    DOMEventProxy.prototype.di = function (e_) {
        var a = this.bm(e_);
        if (this.da != null && a) {
            this.b3++;
            var mGesture_ = this.da;
            mGesture_.addPointer(e_.originalEvent.pointerId);
        }
        var eventSource_ = this.bz.getNativeElement();
        if (BaseDOMEventProxy.bp) {
            eventSource_.setPointerCapture(e_.originalEvent.pointerId);
        }
        else {
            eventSource_.msSetPointerCapture(e_.originalEvent.pointerId);
        }
        if (this.b3 > 1 && !this.c1 && a) {
            this.c1 = true;
            this.ct(e_);
            var b = (e_.originalEvent.scale);
            this.a8(this.cx, b);
        }
        else {
            if (a) {
                this.dp(e_);
            }
            else {
                this.cc(e_);
            }
        }
    };
    DOMEventProxy.prototype.dj = function (e_) {
        var a = this.bm(e_);
        if (this.c1) {
            return;
        }
        if (a) {
            this.dn(e_);
        }
        else {
            this.ce(e_);
        }
    };
    DOMEventProxy.prototype.dk = function (e_) {
        var a = this.bm(e_);
        if (this.c1) {
            return;
        }
        if (a) {
        }
        else {
            this.cd(e_);
        }
    };
    DOMEventProxy.prototype.df = function (e_) {
        this.bn = true;
        this.cr(e_);
        this.ct(e_);
        this.dr();
        if (this.ab(this.cy, true, false)) {
            this.cp(e_);
            if (BaseDOMEventProxy.bt && this.b3 < 2) {
                return;
            }
            var a = (e_.originalEvent.scale);
            this.a8(this.cx, a);
        }
    };
    DOMEventProxy.prototype.dd = function (e_) {
        this.bn = true;
        this.cr(e_);
        this.ct(e_);
        if (this.ab(this.cy, true, false)) {
            this.cp(e_);
            if (BaseDOMEventProxy.bt && this.b3 < 2) {
                return;
            }
            var a = (e_.originalEvent.scale);
            this.a7(this.cx, a);
        }
    };
    DOMEventProxy.prototype.de = function (e_) {
        this.cp(e_);
        var a = (e_.originalEvent.scale);
        this.bn = false;
        this.cr(e_);
        this.ct(e_);
        if (!BaseDOMEventProxy.bt || this.c1) {
            this.a0(this.cx, a);
        }
    };
    DOMEventProxy.prototype.dp = function (e_) {
        this.bn = true;
        this.cr(e_);
        this.ct(e_);
        this.dy = this.cx;
        if (this.ab(this.cy, true, false)) {
            if (!this.aa) {
                this.cp(e_);
            }
            else {
                this.br = true;
            }
            this.a5(this.cy, false, true);
            this.a2(this.cy);
            this.av(this.cx, true);
            this.du();
        }
    };
    DOMEventProxy.prototype.du = function () {
        if (this.c7 == -1) {
            this.c5 = this.cy.x;
            this.c6 = this.cy.y;
            this.c7 = this.by.setTimeout(runOn(this, this.ds), 1500);
        }
    };
    DOMEventProxy.prototype.dr = function () {
        if (Math.abs(this.c5 - this.cy.x) > this.c4 || Math.abs(this.c6 - this.cy.y) > this.c4) {
            this.dv();
        }
    };
    DOMEventProxy.prototype.dv = function () {
        if (this.c7 != -1) {
            window.clearTimeout(this.c7);
            this.c7 = -1;
        }
    };
    DOMEventProxy.prototype.ds = function () {
        this.c7 = -1;
        if (this.br) {
            this.br = false;
            this.b8();
        }
        this.a1(this.cx);
    };
    DOMEventProxy.prototype.dn = function (a) {
        this.bn = true;
        this.cr(a);
        this.ct(a);
        if (this.br) {
            if (this.ab(this.cy, true, false) && this.c2()) {
                this.br = false;
                this.b8();
            }
        }
        this.dr();
        this.dw();
        if (this.ab(this.cy, true, false) && this.b3 == 1 && !this.br) {
            this.cp(a);
            if (!this.c0) {
                this.c0 = true;
                this.dx = this.cx;
                this.az(this.dx);
            }
            else {
                this.a5(this.cy, true, true);
                this.au(this.cx, true);
                this.ay(this.cx);
            }
        }
    };
    DOMEventProxy.prototype.c2 = function () {
        var a = { $type: Point_$type, x: this.dy.x - this.cx.x, y: this.dy.y - this.cx.y };
        if (Math.abs(a.x) < 2 && Math.abs(a.y) < 2) {
            return false;
        }
        if (Math.abs(a.x) > Math.abs(a.y)) {
            a.y = 0;
        }
        if (Math.abs(a.y) > Math.abs(a.x)) {
            a.x = 0;
        }
        return this.am(a);
    };
    DOMEventProxy.prototype.dm = function (a) {
        this.bn = false;
        this.cr(a);
        this.ct(a);
        this.dv();
        if (this.br) {
            this.br = false;
            this.b8();
        }
        this.cp(a);
        this.a5(this.cy, false, true);
        this.a6(this.cy);
        if (this.b3 == 0) {
            this.dt(this.cy);
            this.cm();
        }
        if (this.c0 && this.b3 == 0) {
            this.c0 = false;
            this.dx = null;
            this.ax(this.cx);
            this.cm();
        }
        this.at(this.cx, true, this.b3 > 0);
    };
    DOMEventProxy.prototype.dt = function (a) {
        if (Rect.l_op_Equality(this.dz, null)) {
            this.dz = new Rect(0, a.x - 50, a.y - 50, 100, 100);
            this.by.setTimeout(runOn(this, this.dw), 500);
        }
        else {
            if (a.x >= this.dz.x && a.x <= this.dz.right && a.y >= this.dz.y && a.y <= this.dz.bottom) {
                this.dw();
                this.aw(a);
            }
        }
    };
    DOMEventProxy.prototype.dw = function () {
        this.dz = null;
    };
    DOMEventProxy.prototype.dq = function (a) {
        if (this.c3.containsKey(a)) {
            var b = this.c3.item(a);
            this.c3.removeItem(a);
            for (var c = 0; c < b.count; c++) {
                b._inner[c]();
            }
            b.clear();
        }
    };
    DOMEventProxy.prototype.bc = function (a, b) {
        var c = a;
        var d = this.db + b;
        this.dq(d);
    };
    DOMEventProxy.prototype.ar = function () {
        if (this.bz == null) {
            return;
        }
        this.dq(this.db);
        this.bz = null;
    };
    DOMEventProxy.$t = markType(DOMEventProxy, 'DOMEventProxy', BaseDOMEventProxy.$);
    DOMEventProxy.c8 = 0;
    return DOMEventProxy;
}(BaseDOMEventProxy));
export { DOMEventProxy };
//# sourceMappingURL=BaseDOMEventProxy_combined.js.map
