/*
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 { 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
 */
export let BaseDOMEventProxy = /*@__PURE__*/ (() => {
    class BaseDOMEventProxy extends EventProxy {
        constructor() {
            super(...arguments);
            this.b4 = null;
            this.bv = false;
            this.bx = false;
            this.b3 = null;
            this.bo = false;
            this.b1 = 0;
            this.b2 = 0;
            this.bz = 0;
            this.b0 = 0;
            this.b5 = 0;
            this.c3 = null;
            this.c2 = null;
            this.bn = false;
            this.b6 = -1;
            this.bs = false;
            this.bp = false;
            this.bm = false;
        }
        d() {
            let a = new DOMEventProxy(this.b4, this.b3, this.bx);
            a.ab = this.ab;
            a.ap = this.ap;
            return a;
        }
        static get by() {
            return (BaseDOMEventProxy.bt || BaseDOMEventProxy.bu);
        }
        bk(a) {
            return DOMEventProxy.c4(a);
        }
        br(e_) {
            let pointerEvent_ = e_.originalEvent;
            let a = false;
            if (BaseDOMEventProxy.bu) {
                a = (pointerEvent_.pointerType == 'touch');
            }
            else {
                a = (pointerEvent_.pointerType == pointerEvent_.MSPOINTER_TYPE_TOUCH);
            }
            return a;
        }
        cu(a) {
            if (!this.ae) {
                if (this.bq(a)) {
                    if (this.ar == null || this.ar(a)) {
                        a.preventDefault();
                    }
                }
            }
        }
        bq(e_) {
            return (e_.originalEvent.cancelable || e_.originalEvent.cancelable == undefined);
        }
        cq() {
            let source_ = this.b4.getNativeElement();
            BaseDOMEventProxy.ct(source_);
        }
        static ct(source_) {
            if (BaseDOMEventProxy.bu) {
                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';
        }
        static cn(source_) {
            if (BaseDOMEventProxy.bu) {
                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';
        }
        co() {
            let source_ = this.b4.getNativeElement();
            BaseDOMEventProxy.cn(source_);
        }
        aw() {
            super.aw();
            if (!this.ae) {
                this.cq();
            }
            else {
                this.co();
            }
        }
        cb() {
            let ver_ = -1;
            let matchIE_ = /Trident\/([\d.]+)/;
            if ((matchIE_.exec(navigator.userAgent) != null)) {
                ver_ = (parseFloat(RegExp.$1));
            }
            return ver_;
        }
        ca() {
            let ver_ = -1;
            let matchIE_ = /Edge\/([\d.]+)/;
            if ((matchIE_.exec(navigator.userAgent) != null)) {
                ver_ = (parseFloat(RegExp.$1));
            }
            return ver_;
        }
        static cs(e_) {
            let a = BaseDOMEventProxy.cc >= 6;
            let oe_ = e_.originalEvent;
            if ((((typeof e_.pageX == 'undefined')) || a) && oe_.clientX != null) {
                let od_;
                if ((e_.target !== undefined)) {
                    od_ = e_.target.ownerDocument;
                }
                else {
                    od_ = e_.originalEvent.target.ownerDocument;
                }
                let ed_ = od_ ? od_ : document;
                let doc_ = ed_.documentElement;
                let body_ = ed_.body;
                let clientX_ = oe_.clientX;
                let clientY_ = oe_.clientY;
                let scrollLeft_ = doc_ && doc_.scrollLeft || body_ && body_.scrollLeft || 0;
                let scrollTop_ = doc_ && doc_.scrollTop || body_ && body_.scrollTop || 0;
                let clientLeft_ = doc_ && doc_.clientLeft || body_ && body_.clientLeft || 0;
                let 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;
            }
        }
        static c4(a) {
            let b = BaseDOMEventProxy.cc >= 6;
            let source_ = a.getNativeElement();
            let d_ = source_.ownerDocument;
            let doc_ = d_ ? d_.documentElement : null;
            let z_ = doc_ ? doc_.msContentZoomFactor : null;
            let body_ = doc_.body;
            if ((z_ && z_ > 1) || b) {
                let rect_ = source_.getBoundingClientRect();
                let x_ = (rect_.left);
                let y_ = (rect_.top);
                let scrollLeft_ = (doc_ && doc_.scrollLeft || body_ && body_.scrollLeft || 0);
                let scrollTop_ = (doc_ && doc_.scrollTop || body_ && body_.scrollTop || 0);
                let clientLeft_ = (doc_ && doc_.clientLeft || body_ && body_.clientLeft || 0);
                let clientTop_ = (doc_ && doc_.clientTop || body_ && body_.clientTop || 0);
                let c = x_ + scrollLeft_ - clientLeft_;
                let d = y_ + scrollTop_ - clientTop_;
                return new Rect(0, c, d, 0, 0);
            }
            else {
                let e = a.getOffset();
                return new Rect(0, e.left, e.top, 0, 0);
            }
        }
        get b8() {
            return this.b5;
        }
        set b8(a) {
            this.b5 = a;
        }
        cx(a) {
            this.as = a;
            BaseDOMEventProxy.cs(a);
            let b = BaseDOMEventProxy.c4(this.b4);
            let c = 0;
            let d = 0;
            if (Rect.l_op_Inequality(this.bl, null)) {
                c = this.bl.left;
                d = this.bl.top;
            }
            this.b1 = a.pageX - b.left;
            this.b2 = a.pageY - b.top;
            this.bz = this.b1 - c;
            this.b0 = this.b2 - d;
            this.c3 = { $type: Point_$type, x: this.b1, y: this.b2 };
            this.c2 = { $type: Point_$type, x: this.bz, y: this.b0 };
        }
        cy(e_) {
            this.as = e_;
            BaseDOMEventProxy.cs(e_);
            if (BaseDOMEventProxy.by) {
                let a = e_.pageX;
                let b = e_.pageY;
                let c = BaseDOMEventProxy.c4(this.b4);
                this.b1 = a - c.left;
                this.b2 = b - c.top;
            }
            else {
                this.b5 = 0;
                if (!e_.originalEvent.targetTouches || e_.originalEvent.targetTouches.length < 1) {
                    return;
                }
                ;
                this.b5 = (e_.originalEvent.targetTouches.length);
                let d = (e_.originalEvent.targetTouches[0].pageX);
                let e = (e_.originalEvent.targetTouches[0].pageY);
                let f = BaseDOMEventProxy.c4(this.b4);
                this.b1 = d - f.left;
                this.b2 = e - f.top;
            }
            let g = 0;
            let h = 0;
            if (Rect.l_op_Inequality(this.bl, null)) {
                g = this.bl.left;
                h = this.bl.top;
            }
            this.bz = this.b1 - g;
            this.b0 = this.b2 - h;
            this.c3 = { $type: Point_$type, x: this.b1, y: this.b2 };
            this.c2 = { $type: Point_$type, x: this.bz, y: this.b0 };
        }
        cm(e_) {
            this.cw(e_);
            if (this.ad(this.c3, false, true)) {
                let deltaY_ = 0;
                let ev_ = e_;
                deltaY_ = (ev_.originalEvent ? ev_.originalEvent.deltaY : ev_.deltaY);
                let deltaX_ = 0;
                deltaX_ = (ev_.originalEvent ? ev_.originalEvent.deltaX : ev_.deltaX);
                let a = (ev_.originalEvent ? (ev_.originalEvent.deltaMode == 1) : (ev_.deltaMode == 1));
                if (a) {
                    deltaY_ = deltaY_ * 40;
                    deltaX_ = deltaX_ * 40;
                }
                let b = this.aj(this.c2, deltaY_);
                let c = this.ak(this.c2, deltaX_);
                if (b || c) {
                    this.cu(e_);
                }
            }
        }
        ck(e_) {
            this.cw(e_);
            this.cx(e_);
            if (this.ad(this.c3, false, true)) {
                let ev_ = e_;
                let 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;
                let a = this.aj(this.c2, delta_);
                if (a) {
                    this.cu(e_);
                }
            }
        }
        cr() {
            if (this.bn) {
                if (this.b6 == -1) {
                    this.b6 = this.b3.setTimeout(runOn(this, this.cp), 500);
                }
                else {
                    window.clearTimeout(this.b6);
                    this.b6 = -1;
                    this.b6 = this.b3.setTimeout(runOn(this, this.cp), 500);
                }
            }
        }
        cd() {
            this.bn = true;
            if (this.b6 != -1) {
                window.clearTimeout(this.b6);
                this.b6 = -1;
            }
        }
        cp() {
            this.bn = false;
        }
        get bw() {
            return this.bp;
        }
        set bw(a) {
            this.bp = a;
        }
        ci(a) {
            if (this.bp || this.bn) {
                return;
            }
            this.cx(a);
            if (this.bs) {
                this.bs = false;
                this.a9(this.c2);
            }
        }
        cj(a) {
            if (this.bp || this.bn) {
                return;
            }
            this.cx(a);
            this.cw(a);
            let b = new MouseEventArgs();
            b.position = this.c3;
            if (this.ad(this.c3, false, false)) {
                if (!this.bs) {
                    this.bs = true;
                    this.a8(this.c3);
                }
                this.ba(this.c3, true, false);
                this.ay(this.c2, false);
            }
            else if (this.bs) {
                this.ci(a);
            }
        }
        cv(a) {
            this.b4.focus(this.bv);
        }
        ch(a) {
            if (this.bp || this.bn) {
                return;
            }
            this.cv(a);
            this.cx(a);
            this.cw(a);
            if (this.ad(this.c3, false, false)) {
                this.bm = true;
                this.a7(this.c3);
                this.az(this.c2, false);
                this.cu(a);
            }
        }
        cz(a) {
            if (this.bp || this.bn) {
                return;
            }
            if (this.bm) {
                this.cl(a);
            }
        }
        cl(a) {
            if (this.bp || this.bn) {
                return;
            }
            this.cw(a);
            if (PointUtil.equals(this.c3, null) || PointUtil.equals(this.c2, null)) {
                this.cx(a);
            }
            let b = this.ad(this.c3, false, false) || this.bm || this.bs;
            this.bm = false;
            this.bb(this.c3);
            this.ax(this.c2, false, false);
            if (b) {
                this.cu(a);
            }
        }
        ce(a) {
            this.cf(a, true);
        }
        cg(a) {
            this.cf(a, false);
        }
        c1(a) {
            return BaseDOMEventProxy.c0(a);
        }
        static c0(a) {
            let 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;
        }
        cf(a, b) {
            let c = this.c1(a);
            let d = c != 0;
            this.cw(a);
            if (d) {
                let e = false;
                if (b) {
                    e = this.ah(c);
                }
                else {
                    e = this.ai(c);
                }
                if (e) {
                    this.cu(a);
                }
            }
        }
        cw(a) {
            this.as = a;
            this.bi = 0;
            if (a.shiftKey) {
                this.bi = this.bi | 4;
            }
            if (a.altKey) {
                this.bi = this.bi | 1;
            }
            if (a.ctrlKey) {
                this.bi = this.bi | 2;
            }
            this.al = a.button == 2;
        }
        bj() {
            let a = BaseDOMEventProxy.c4(this.b4);
            let b = a.left;
            let c = a.top;
            return { $type: Point_$type, x: b, y: c };
        }
    }
    BaseDOMEventProxy.$t = markType(BaseDOMEventProxy, 'BaseDOMEventProxy', EventProxy.$);
    BaseDOMEventProxy.bt = false;
    BaseDOMEventProxy.bu = false;
    BaseDOMEventProxy.cc = 0;
    BaseDOMEventProxy.b9 = 0;
    return BaseDOMEventProxy;
})();
/**
 * @hidden
 */
export let DOMEventProxy = /*@__PURE__*/ (() => {
    class DOMEventProxy extends BaseDOMEventProxy {
        constructor(a, b, c) {
            super();
            this.de = 0;
            this.dg = "";
            this.c6 = false;
            this.df = null;
            this.c8 = new Dictionary$2(String_$type, List$1.$.specialize(Delegate_$type), 0);
            this.d3 = null;
            this.dc = -1;
            this.d4 = null;
            this.da = 0;
            this.db = 0;
            this.c9 = 5;
            this.c5 = false;
            this.d2 = null;
            this.bx = c;
            this.b3 = b;
            this.ap = (d) => true;
            this.ab = false;
            DOMEventProxy.dd++;
            this.de = DOMEventProxy.dd;
            this.dg = ".DOMProxy" + this.de.toString();
            this.bi = 0;
            this.b4 = a;
            BaseDOMEventProxy.bt = false;
            try {
                BaseDOMEventProxy.bt = (window.navigator.msPointerEnabled && window.MSGesture !== undefined);
            }
            catch (d) {
            }
            BaseDOMEventProxy.bu = false;
            try {
                BaseDOMEventProxy.bu = (window.PointerEvent !== undefined);
            }
            catch (e) {
            }
            BaseDOMEventProxy.cc = this.cb();
            BaseDOMEventProxy.b9 = this.ca();
            this.at(this.b4, "");
            this.ao = (f) => true;
        }
        dh(a, b, c) {
        }
        at(a, b) {
            let c = a;
            let d = this.dg + b;
            if (!this.b3.supportsDOMEvents()) {
                return;
            }
            let e = new List$1(Delegate_$type, 0);
            this.c8.addItem(d, e);
            this.dh(a, b, e);
            if (!BaseDOMEventProxy.by) {
                e.add(c.listen("mousemove", runOn(this, this.cj)));
                e.add(c.listen("mouseleave", runOn(this, this.ci)));
                e.add(c.listen("mousedown", runOn(this, this.ch)));
                e.add(c.listen("mouseup", runOn(this, this.cl)));
                e.add(this.b3.globalListen("window", "mouseup", runOn(this, this.cz)));
            }
            e.add(c.listen("keydown", runOn(this, this.ce)));
            e.add(c.listen("keyup", runOn(this, this.cg)));
            let source_ = this.b4.getNativeElement();
            if (!this.ae) {
                BaseDOMEventProxy.ct(source_);
            }
            if (BaseDOMEventProxy.by) {
                let f = this.b4.getNativeElement();
                if ((window.MSGesture !== undefined)) {
                    let gesture_ = new window.MSGesture();
                    let container_ = f;
                    gesture_.target = container_;
                    this.df = gesture_;
                    e.add(c.listen("MSGestureStart", runOn(this, this.dk)));
                    e.add(c.listen("MSGestureChange", runOn(this, this.di)));
                    e.add(c.listen("MSGestureEnd", runOn(this, this.dj)));
                }
                if (BaseDOMEventProxy.bu) {
                    e.add(c.listen("pointerdown", runOn(this, this.dn)));
                    e.add(c.listen("pointerup", runOn(this, this.dr)));
                    e.add(c.listen("pointercancel", runOn(this, this.dm)));
                    e.add(c.listen("pointermove", runOn(this, this.dp)));
                    e.add(c.listen("pointerout", runOn(this, this.dq)));
                    e.add(c.listen("lostpointercapture", runOn(this, this.dl)));
                }
                else {
                    e.add(c.listen("MSPointerDown", runOn(this, this.dn)));
                    e.add(c.listen("MSPointerUp", runOn(this, this.dr)));
                    e.add(c.listen("MSPointerCancel", runOn(this, this.dm)));
                    e.add(c.listen("MSPointerMove", runOn(this, this.dp)));
                    e.add(c.listen("MSPointerOut", runOn(this, this.dq)));
                    e.add(c.listen("MSLostPointerCapture", runOn(this, this.dl)));
                }
            }
            else {
                e.add(c.listen("gesturestart", runOn(this, this.dk)));
                e.add(c.listen("gesturechange", runOn(this, this.di)));
                e.add(c.listen("gestureend", runOn(this, this.dj)));
                e.add(c.listen("touchstart", runOn(this, this.du)));
                e.add(c.listen("touchmove", runOn(this, this.dt)));
                e.add(c.listen("touchend", runOn(this, this.ds)));
            }
            if (this.bx) {
                e.add(c.listen("wheel", runOn(this, this.cm)));
            }
            else {
                e.add(c.listen("DOMMouseScroll", runOn(this, this.ck)));
                e.add(c.listen("mousewheel", runOn(this, this.ck)));
            }
        }
        dr(e_) {
            let a = this.br(e_);
            if (a) {
                this.b8 = this.b8 - 1;
                if (this.b8 < 0) {
                    this.b8 = 0;
                }
            }
            if (this.b8 < 2 && this.c6 && a) {
                this.c6 = false;
                let b = (e_.originalEvent.scale);
                this.a4(this.c2, b);
            }
            else {
                if (a) {
                    this.ds(e_);
                }
                else {
                    this.cl(e_);
                }
            }
        }
        dl(e_) {
            let a = this.br(e_);
            if (a) {
                this.b8--;
                if (this.b8 < 0) {
                    this.b8 = 0;
                }
            }
            if (this.b8 < 2 && this.c6 && a) {
                this.c6 = false;
                let b = (e_.originalEvent.scale);
                this.a4(this.c2, b);
            }
        }
        dm(e_) {
            let a = this.br(e_);
            if (a) {
                this.b8--;
                if (this.b8 < 0) {
                    this.b8 = 0;
                }
            }
            if (this.b8 < 2 && this.c6 && a) {
                this.c6 = false;
                let b = (e_.originalEvent.scale);
                this.a4(this.c2, b);
            }
        }
        dn(e_) {
            let a = this.br(e_);
            if (this.df != null && a) {
                this.b8++;
                let mGesture_ = this.df;
                mGesture_.addPointer(e_.originalEvent.pointerId);
            }
            let eventSource_ = this.b4.getNativeElement();
            if (BaseDOMEventProxy.bu) {
                eventSource_.setPointerCapture(e_.originalEvent.pointerId);
            }
            else {
                eventSource_.msSetPointerCapture(e_.originalEvent.pointerId);
            }
            if (this.b8 > 1 && !this.c6 && a) {
                this.c6 = true;
                this.cy(e_);
                let b = (e_.originalEvent.scale);
                this.bd(this.c2, b);
            }
            else {
                if (a) {
                    this.du(e_);
                }
                else {
                    this.ch(e_);
                }
            }
        }
        dp(e_) {
            let a = this.br(e_);
            if (this.c6) {
                return;
            }
            if (a) {
                this.dt(e_);
            }
            else {
                this.cj(e_);
            }
        }
        dq(e_) {
            let a = this.br(e_);
            if (this.c6) {
                return;
            }
            if (a) {
            }
            else {
                this.ci(e_);
            }
        }
        dk(e_) {
            this.bs = true;
            this.cw(e_);
            this.cy(e_);
            this.dw();
            if (this.ad(this.c3, true, false)) {
                this.cu(e_);
                if (BaseDOMEventProxy.by && this.b8 < 2) {
                    return;
                }
                let a = (e_.originalEvent.scale);
                this.bd(this.c2, a);
            }
        }
        di(e_) {
            this.bs = true;
            this.cw(e_);
            this.cy(e_);
            if (this.ad(this.c3, true, false)) {
                this.cu(e_);
                if (BaseDOMEventProxy.by && this.b8 < 2) {
                    return;
                }
                let a = (e_.originalEvent.scale);
                this.bc(this.c2, a);
            }
        }
        dj(e_) {
            this.cu(e_);
            let a = (e_.originalEvent.scale);
            this.bs = false;
            this.cw(e_);
            this.cy(e_);
            if (!BaseDOMEventProxy.by || this.c6) {
                this.a4(this.c2, a);
            }
        }
        du(e_) {
            this.bs = true;
            this.cw(e_);
            this.cy(e_);
            this.d3 = this.c2;
            if (this.ad(this.c3, true, false)) {
                if (!this.ab) {
                    this.cu(e_);
                }
                else {
                    this.bw = true;
                }
                this.ba(this.c3, false, true);
                this.a7(this.c3);
                this.az(this.c2, true);
                this.dz();
            }
        }
        dz() {
            if (this.dc == -1) {
                this.da = this.c3.x;
                this.db = this.c3.y;
                this.dc = this.b3.setTimeout(runOn(this, this.dx), 1500);
            }
        }
        dw() {
            if (Math.abs(this.da - this.c3.x) > this.c9 || Math.abs(this.db - this.c3.y) > this.c9) {
                this.d0();
            }
        }
        d0() {
            if (this.dc != -1) {
                window.clearTimeout(this.dc);
                this.dc = -1;
            }
        }
        dx() {
            this.dc = -1;
            if (this.bw) {
                this.bw = false;
                this.cd();
            }
            this.a5(this.c2);
        }
        dt(a) {
            this.bs = true;
            this.cw(a);
            this.cy(a);
            if (this.bw) {
                if (this.ad(this.c3, true, false) && this.c7()) {
                    this.bw = false;
                    this.cd();
                }
            }
            this.dw();
            this.d1();
            if (this.ad(this.c3, true, false) && this.b8 == 1 && !this.bw) {
                this.cu(a);
                if (!this.c5) {
                    this.c5 = true;
                    this.d2 = this.c2;
                    this.a3(this.d2);
                }
                else {
                    this.ba(this.c3, true, true);
                    this.ay(this.c2, true);
                    this.a2(this.c2);
                }
            }
        }
        c7() {
            let a = { $type: Point_$type, x: this.d3.x - this.c2.x, y: this.d3.y - this.c2.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.ap(a);
        }
        ds(a) {
            this.bs = false;
            this.cw(a);
            this.cy(a);
            this.d0();
            if (this.bw) {
                this.bw = false;
                this.cd();
            }
            this.cu(a);
            this.ba(this.c3, false, true);
            this.bb(this.c3);
            if (this.b8 == 0) {
                this.dy(this.c3);
                this.cr();
            }
            if (this.c5 && this.b8 == 0) {
                this.c5 = false;
                this.d2 = null;
                this.a1(this.c2);
                this.cr();
            }
            this.ax(this.c2, true, this.b8 > 0);
        }
        dy(a) {
            if (Rect.l_op_Equality(this.d4, null)) {
                this.d4 = new Rect(0, a.x - 50, a.y - 50, 100, 100);
                this.b3.setTimeout(runOn(this, this.d1), 500);
            }
            else {
                if (a.x >= this.d4.x && a.x <= this.d4.right && a.y >= this.d4.y && a.y <= this.d4.bottom) {
                    this.d1();
                    this.a0(a);
                }
            }
        }
        d1() {
            this.d4 = null;
        }
        dv(a) {
            if (this.c8.containsKey(a)) {
                let b = this.c8.item(a);
                this.c8.removeItem(a);
                for (let c = 0; c < b.count; c++) {
                    b._inner[c]();
                }
                b.clear();
            }
        }
        bh(a, b) {
            if (a == null) {
                return;
            }
            let c = a;
            let d = this.dg + b;
            this.dv(d);
        }
        av() {
            if (this.b4 == null) {
                return;
            }
            this.dv(this.dg);
            this.b4 = null;
        }
    }
    DOMEventProxy.$t = markType(DOMEventProxy, 'DOMEventProxy', BaseDOMEventProxy.$);
    DOMEventProxy.dd = 0;
    return DOMEventProxy;
})();
