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