/*
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 { Base, runOn, delegateCombine, markType, INotifyPropertyChanged_$type, PropertyChangedEventArgs, enumGetBox, Point_$type } from "./type";
import { CanvasGestureDOMEventProxy } from "./CanvasGestureDOMEventProxy";
import { Brush } from "./Brush";
import { DOMExecutionContext } from "./DOMExecutionContext";
import { DoubleAnimator } from "./DoubleAnimator";
import { Rect } from "./Rect";
import { ScrollbarStyle_$type } from "./ScrollbarStyle";
import { truncate, isNaN_ } from "./number";
import { EasingFunctions } from "./EasingFunctions";
import { ScrollerScrollingEventArgs } from "./ScrollerScrollingEventArgs";
/**
 * @hidden
 */
var ScrollerView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(ScrollerView, _super);
    function ScrollerView(a) {
        var _this = _super.call(this) || this;
        _this.c = null;
        _this.ad = null;
        _this.ah = null;
        _this.b = null;
        _this.ac = null;
        _this.a = null;
        _this.ag = null;
        _this.ae = null;
        _this.af = null;
        _this.ai = null;
        _this.e = false;
        _this.d = null;
        _this.i = false;
        _this.h = false;
        _this.w = 0;
        _this.t = 0;
        _this.x = -1;
        _this.u = -1;
        _this.g = false;
        _this.f = false;
        _this.v = 0;
        _this.s = 0;
        _this.c = a;
        return _this;
    }
    ScrollerView.prototype.a8 = function () {
        return ((function () {
            var $ret = new Brush();
            $ret.fill = "#666666";
            return $ret;
        })());
    };
    ScrollerView.prototype.a0 = function (a) {
        var _this = this;
        if (a == null) {
            if (this.ad != null) {
                this.ad = null;
            }
            if (this.a != null) {
                this.a.ak = null;
                this.a.aq();
            }
            return;
        }
        this.ad = a;
        this.c.executionContext = new DOMExecutionContext(this.ad);
        var b = Math.round(this.ad.rootWrapper.width());
        var c = Math.round(this.ad.rootWrapper.height());
        this.ag = this.ad.rootWrapper;
        this.ag.setStyleProperty("position", "relative");
        this.ah = this.ad.createElement("div");
        this.ah.setStyleProperty("position", "relative");
        this.ah.setStyleProperty("width", "100%");
        this.ah.setStyleProperty("height", "100%");
        this.ah.setStyleProperty("overflow", "hidden");
        this.ag.append(this.ah);
        this.af = this.ad.createElement("div");
        this.af.setStyleProperty("position", "absolute");
        this.af.setStyleProperty("height", this.c.scrollbarSpan + "px");
        this.af.setStyleProperty("width", this.c.minScrollbarSize + "px");
        this.af.setStyleProperty("background-color", this.c.scrollbarBrush._fill);
        this.af.setStyleProperty("display", "none");
        this.af.setStyleProperty("border-radius", "5px");
        this.af.setStyleProperty("z-index", "10000");
        this.af.setStyleProperty("bottom", "0px");
        this.ag.append(this.af);
        this.ai = this.ad.createElement("div");
        this.ai.setStyleProperty("position", "absolute");
        this.ai.setStyleProperty("width", this.c.scrollbarSpan + "px");
        this.ai.setStyleProperty("height", this.c.minScrollbarSize + "px");
        this.ai.setStyleProperty("background-color", this.c.scrollbarBrush._fill);
        this.ai.setStyleProperty("display", "none");
        this.ai.setStyleProperty("border-radius", "5px");
        this.ai.setStyleProperty("z-index", "10000");
        this.ai.setStyleProperty("right", "0px");
        this.ag.append(this.ai);
        this.a4(false);
        this.ac = this.ah.getNativeElement();
        this.a = new CanvasGestureDOMEventProxy(this.ad.rootWrapper, this.ad, true);
        this.ad.rootWrapper.setProperty("tabIndex", 1000);
        this.ad.rootWrapper.setRawStyleProperty("outline", "none");
        this.a.c2 = true;
        this.a.bp = true;
        var d = this.a;
        d.onMouseWheel = delegateCombine(d.onMouseWheel, runOn(this, this.l));
        var e = this.a;
        e.onMouseWheelHorizontal = delegateCombine(e.onMouseWheelHorizontal, runOn(this, this.m));
        var f = this.a;
        f.onMouseLeave = delegateCombine(f.onMouseLeave, runOn(this, this.aq));
        var g = this.a;
        g.onDragStarted = delegateCombine(g.onDragStarted, runOn(this, this.ap));
        var h = this.a;
        h.onDragDelta = delegateCombine(h.onDragDelta, runOn(this, this.ao));
        var i = this.a;
        i.onDragCompleted = delegateCombine(i.onDragCompleted, runOn(this, this.an));
        var j = this.a;
        j.onFlingStarted = delegateCombine(j.onFlingStarted, runOn(this, this.j));
        var k = this.a;
        k.onContactStarted = delegateCombine(k.onContactStarted, runOn(this, this.am));
        var l = this.a;
        l.onContactMoved = delegateCombine(l.onContactMoved, runOn(this, this.al));
        var m = this.a;
        m.onContactCompleted = delegateCombine(m.onContactCompleted, runOn(this, this.ak));
        this.a.aa = true;
        this.a.am = runOn(this, this.r);
        var n = this.a;
        n.onKeyDown = delegateCombine(n.onKeyDown, runOn(this, this.k));
        this.a.an = function (o) {
            var e_ = o.originalEvent;
            var p = (e_.type);
            if (p == "pointerdown" && !_this.a.bl(o)) {
                return false;
            }
            return true;
        };
        this.c.da(b, c);
        this.c.horizontalAnimation.u(this.ad);
        this.c.verticalAnimation.u(this.ad);
    };
    ScrollerView.prototype.k = function (a) {
        return this.c.ai(a, (this.a.bc & 4) != 0, (this.a.bc & 2) != 0);
    };
    ScrollerView.prototype.r = function (a, b, c) {
        if (this.f || this.g) {
            return true;
        }
        if (c || b) {
            return true;
        }
        if (this.n(a, b)) {
            this.c.cv();
            if (this.p(a, b)) {
                return true;
            }
        }
        else if (this.c.isHorizontalActive) {
            this.c.cz();
        }
        if (this.o(a, b)) {
            this.c.cw();
            if (this.q(a, b)) {
                return true;
            }
        }
        else if (this.c.isVerticalActive) {
            this.c.c0();
        }
        return false;
    };
    ScrollerView.prototype.ak = function (a, b) {
        this.f = false;
        this.g = false;
        this.c.isDraggingVBar = false;
        this.c.isDraggingHBar = false;
    };
    ScrollerView.prototype.al = function (a, b) {
        if (this.g) {
            var c = a.y - this.v;
            this.v = a.y;
            this.c.c9(c);
        }
        else if (this.f) {
            var d = a.x - this.s;
            this.s = a.x;
            this.c.c7(d);
        }
    };
    ScrollerView.prototype.am = function (a, b) {
        this.e = false;
        this.aj();
        var c = this.q(a, b);
        var d = this.p(a, b);
        if (c) {
            this.c.isDraggingVBar = true;
            this.g = true;
            this.v = a.y;
            this.ar();
        }
        else if (d) {
            this.c.isDraggingHBar = true;
            this.f = true;
            this.s = a.x;
            this.ar();
        }
    };
    ScrollerView.prototype.p = function (a, b) {
        if (!this.h) {
            return false;
        }
        if (a.y >= this.c.viewportHeight - this.c.scrollbarSpan && a.y <= this.c.viewportHeight && a.x >= this.u - this.t / 2 && a.x <= this.u + this.t / 2) {
            return true;
        }
        return false;
    };
    ScrollerView.prototype.q = function (a, b) {
        if (!this.i) {
            return false;
        }
        if (a.x >= this.c.viewportWidth - this.c.scrollbarSpan && a.x <= this.c.viewportWidth && a.y >= this.x - this.w / 2 && a.y <= this.x + this.w / 2) {
            return true;
        }
        return false;
    };
    ScrollerView.prototype.n = function (a, b) {
        if (!this.h) {
            return false;
        }
        return a.y >= this.c.viewportHeight - this.c.scrollbarSpan - 40 && a.y <= this.c.viewportHeight;
    };
    ScrollerView.prototype.o = function (a, b) {
        if (!this.i) {
            return false;
        }
        return a.x >= this.c.viewportWidth - this.c.scrollbarSpan - 40 && a.x <= this.c.viewportWidth;
    };
    ScrollerView.prototype.j = function (a, b, c) {
        this.e = true;
        return true;
    };
    ScrollerView.prototype.ay = function (a) {
        this.a.bf = new Rect(0, 0, 0, this.c.viewportWidth, this.c.viewportHeight);
    };
    ScrollerView.prototype.az = function (a) {
        this.a.bf = new Rect(0, 0, 0, this.c.viewportWidth, this.c.viewportHeight);
    };
    ScrollerView.prototype.av = function (a) {
        if (this.ae != null) {
            this.ae.setStyleProperty("height", a + "px");
        }
    };
    ScrollerView.prototype.aw = function (a) {
        if (this.ae != null) {
            this.ae.setStyleProperty("width", a + "px");
        }
    };
    ScrollerView.prototype.aj = function () {
    };
    ScrollerView.prototype.an = function (a) {
        if (this.f || this.g) {
            return;
        }
        this.e = false;
        this.c.c4(a);
    };
    ScrollerView.prototype.ao = function (a) {
        if (this.f || this.g) {
            return;
        }
        this.c.c5(a);
    };
    ScrollerView.prototype.a6 = function (a) {
        this.ac.scrollTop = truncate(a);
    };
    ScrollerView.prototype.ap = function (a) {
        if (this.f || this.g) {
            return;
        }
        this.e = false;
        this.c.c6(a);
    };
    ScrollerView.prototype.z = function () {
        return this.ac.scrollLeft;
    };
    ScrollerView.prototype.aa = function () {
        return this.ac.scrollTop;
    };
    ScrollerView.prototype.l = function (a, b) {
        this.e = false;
        this.aj();
        return this.c.ak(a, 0, b);
    };
    ScrollerView.prototype.m = function (a, b) {
        this.e = false;
        this.aj();
        return this.c.ak(a, b, 0);
    };
    ScrollerView.prototype.aq = function (a) {
        if (this.c.horizontalScrollbarStatus > 0) {
            this.c.cz();
        }
        if (this.c.verticalScrollbarStatus > 0) {
            this.c.c0();
        }
    };
    ScrollerView.prototype.a5 = function (a) {
        this.ac.scrollLeft = truncate(a);
    };
    ScrollerView.prototype.a1 = function (a) {
        this.ae = a;
        this.ah.append(this.ae);
    };
    ScrollerView.prototype.a2 = function (a) {
        if (this.ad == null) {
            return;
        }
        if (this.d == null) {
            this.d = this.ad.getRequestAnimationFrame();
        }
        if (this.e) {
            a();
        }
        else {
            this.d(function () { return a(); });
        }
    };
    ScrollerView.prototype.at = function () {
        if (this.i) {
            this.i = false;
            this.ai.setStyleProperty("display", "none");
        }
    };
    ScrollerView.prototype.as = function () {
        if (this.h) {
            this.h = false;
            this.af.setStyleProperty("display", "none");
        }
    };
    ScrollerView.prototype.a7 = function (a, b) {
        var c = false;
        if (!this.i) {
            c = true;
            this.i = true;
            this.ai.setStyleProperty("display", "block");
        }
        if (a != this.x || c) {
            this.x = a;
            if (this.i) {
                this.ai.setRawYPosition(a - b / 2);
            }
        }
        if (b != this.w || c) {
            this.w = b;
            if (this.i) {
                this.ai.setRawSize(this.ab(), b);
            }
        }
    };
    ScrollerView.prototype.a3 = function (a, b) {
        var c = false;
        if (!this.h) {
            c = true;
            this.h = true;
            this.af.setStyleProperty("display", "block");
        }
        if (a != this.u || c) {
            this.u = a;
            if (this.h) {
                this.af.setRawXPosition(a - b / 2);
            }
        }
        if (b != this.t || c) {
            this.t = b;
            if (this.h) {
                this.af.setRawSize(b, this.y());
            }
        }
    };
    ScrollerView.prototype.a4 = function (a) {
        if (this.af != null && this.ai != null) {
            switch (this.c.scrollbarStyle) {
                case 0:
                    if (a) {
                        this.af.setStyleProperty("opacity", "1");
                        this.ai.setStyleProperty("opacity", "1");
                        this.af.setRawSize(this.t, this.y());
                        this.ai.setRawSize(this.ab(), this.w);
                    }
                    break;
                case 1:
                    if (a) {
                        this.af.setRawSize(this.t, this.y());
                        this.ai.setRawSize(this.ab(), this.w);
                    }
                    this.af.setStyleProperty("opacity", this.c.horizontalScrollbarStatus.toString());
                    this.ai.setStyleProperty("opacity", this.c.verticalScrollbarStatus.toString());
                    break;
                case 2:
                    if (a) {
                        this.af.setStyleProperty("opacity", "1");
                        this.ai.setStyleProperty("opacity", "1");
                    }
                    this.af.setRawSize(this.t, this.y());
                    this.ai.setRawSize(this.ab(), this.w);
                    break;
            }
        }
    };
    ScrollerView.prototype.y = function () {
        if (this.c.scrollbarStyle == 2) {
            return this.c.horizontalScrollbarStatus * (this.c.scrollbarSpan - 2) + 2;
        }
        return this.c.scrollbarSpan;
    };
    ScrollerView.prototype.ab = function () {
        if (this.c.scrollbarStyle == 2) {
            return this.c.verticalScrollbarStatus * (this.c.scrollbarSpan - 2) + 2;
        }
        return this.c.scrollbarSpan;
    };
    ScrollerView.prototype.ar = function () {
        this.ad.rootWrapper.focus(false);
    };
    ScrollerView.prototype.ax = function () {
        if (this.a != null) {
            this.a.bb(this.ad.rootWrapper, "");
        }
    };
    ScrollerView.prototype.au = function () {
        if (this.a != null) {
            this.a.ap(this.ad.rootWrapper, "");
        }
    };
    ScrollerView.$t = markType(ScrollerView, 'ScrollerView');
    return ScrollerView;
}(Base));
export { ScrollerView };
/**
 * @hidden
 */
var Scroller = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(Scroller, _super);
    function Scroller() {
        var _this = _super.call(this) || this;
        _this.a9 = 49;
        _this._keyboardListener = null;
        _this.a1 = NaN;
        _this.av = 49;
        _this.at = NaN;
        _this.a8 = 48;
        _this.a0 = NaN;
        _this.au = 48;
        _this.as = NaN;
        _this.ay = 0;
        _this.a2 = 20;
        _this.a5 = 8;
        _this.bb = 0;
        _this.dp = null;
        _this.v = false;
        _this.ax = 0;
        _this.bd = 0;
        _this.bc = 0;
        _this.a7 = 0;
        _this.a6 = 0;
        _this.f = null;
        _this.t = true;
        _this.y = false;
        _this.aw = 0;
        _this.ar = 0;
        _this.c = 0;
        _this.az = 0;
        _this.ba = 0;
        _this.h = null;
        _this.i = null;
        _this.bm = 0;
        _this.bx = 0;
        _this.bn = 0;
        _this.by = 0;
        _this._executionContext = null;
        _this._isDraggingVBar = false;
        _this._isDraggingHBar = false;
        _this.q = false;
        _this.o = false;
        _this.p = false;
        _this.dr = null;
        _this.n = false;
        _this.propertyChanged = null;
        _this.onScrolling = null;
        _this.a3 = 0;
        _this.a4 = 0;
        _this.u = false;
        _this.b3 = 500;
        _this.b4 = 0;
        _this.b5 = 0;
        _this.m = false;
        _this.x = false;
        _this.l = false;
        _this.w = false;
        _this.r = true;
        _this.s = true;
        _this.dp = _this.view.a8();
        _this.h = new DoubleAnimator(0, 1, 400);
        _this.i = new DoubleAnimator(0, 1, 400);
        _this.h.b = EasingFunctions.cubicEase;
        _this.i.b = EasingFunctions.cubicEase;
        var a = _this.h;
        a.propertyChanged = delegateCombine(a.propertyChanged, runOn(_this, _this.ct));
        var b = _this.i;
        b.propertyChanged = delegateCombine(b.propertyChanged, runOn(_this, _this.cu));
        return _this;
    }
    Object.defineProperty(Scroller.prototype, "smallVerticalChange", {
        get: function () {
            return this.a9;
        },
        set: function (a) {
            var b = this.a9;
            this.a9 = a;
            if (b != this.a9) {
                this.c8("SmallVerticalChange", b, this.a9);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "keyboardListener", {
        get: function () {
            return this._keyboardListener;
        },
        set: function (a) {
            this._keyboardListener = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "largeVerticalChange", {
        get: function () {
            return this.a1;
        },
        set: function (a) {
            var b = this.a1;
            this.a1 = a;
            if (b != this.a1) {
                this.c8("LargeVerticalChange", b, this.a1);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "bi", {
        get: function () {
            return this.av;
        },
        set: function (a) {
            var b = this.av;
            this.av = a;
            if (b != this.av) {
                this.c8("ActualSmallVerticalChange", b, this.av);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "bg", {
        get: function () {
            return this.at;
        },
        set: function (a) {
            var b = this.at;
            this.at = a;
            if (b != this.at) {
                this.c8("ActualLargeVerticalChange", b, this.at);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "smallHorizontalChange", {
        get: function () {
            return this.a8;
        },
        set: function (a) {
            var b = this.a8;
            this.a8 = a;
            if (b != this.a8) {
                this.c8("SmallHorizontalChange", b, this.a8);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "largeHorizontalChange", {
        get: function () {
            return this.a0;
        },
        set: function (a) {
            var b = this.a0;
            this.a0 = a;
            if (b != this.a0) {
                this.c8("LargeHorizontalChange", b, this.a0);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "bh", {
        get: function () {
            return this.au;
        },
        set: function (a) {
            var b = this.au;
            this.au = a;
            if (b != this.au) {
                this.c8("ActualSmallHorizontalChange", b, this.au);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "bf", {
        get: function () {
            return this.as;
        },
        set: function (a) {
            var b = this.as;
            this.as = a;
            if (b != this.as) {
                this.c8("ActualLargeHorizontalChange", b, this.as);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "contentWidth", {
        get: function () {
            return this.ay;
        },
        set: function (a) {
            var b = this.ay;
            this.ay = a;
            if (b != this.ay) {
                this.c8("ContentWidth", b, this.ay);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "minScrollbarSize", {
        get: function () {
            return this.a2;
        },
        set: function (a) {
            var b = this.a2;
            this.a2 = a;
            if (b != this.a2) {
                this.c8("MinScrollbarSize", b, this.a2);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "scrollbarSpan", {
        get: function () {
            return this.a5;
        },
        set: function (a) {
            var b = this.a5;
            this.a5 = a;
            if (b != this.a5) {
                this.c8("ScrollbarSpan", b, this.a5);
            }
        },
        enumerable: true,
        configurable: true
    });
    Scroller.prototype.ai = function (a, b, c) {
        switch (a) {
            case 11: return this.al(b, c);
            case 10: return this.am(b, c);
            case 17: return this.ae(b, c);
            case 15: return this.ap(b, c);
            case 14: return this.aj(b, c);
            case 16: return this.an(b, c);
            case 13: return this.ah(b, c);
            case 12: return this.af(b, c);
            case 2: return this.ao(b, c);
            case 3: return this.ag(b, c);
        }
        return false;
    };
    Scroller.prototype.ao = function (a, b) {
        if (this.keyboardListener != null) {
            if (this.keyboardListener.onTab(a, b)) {
                return true;
            }
        }
        return false;
    };
    Scroller.prototype.af = function (a, b) {
        if (this.keyboardListener != null) {
            if (this.keyboardListener.onEnd(a, b)) {
                return true;
            }
        }
        return false;
    };
    Scroller.prototype.ah = function (a, b) {
        if (this.keyboardListener != null) {
            if (this.keyboardListener.onHome(a, b)) {
                return true;
            }
        }
        return false;
    };
    Scroller.prototype.an = function (a, b) {
        if (this.keyboardListener != null) {
            if (this.keyboardListener.onRightArrow(a, b)) {
                return true;
            }
        }
        if (this.scrollLeft + this.viewportWidth >= this.contentWidth) {
            return false;
        }
        this.df(this.bh, 0);
        return true;
    };
    Scroller.prototype.aj = function (a, b) {
        if (this.keyboardListener != null) {
            if (this.keyboardListener.onLeftArrow(a, b)) {
                return true;
            }
        }
        if (this.scrollLeft <= 0) {
            return false;
        }
        this.df(this.bh * -1, 0);
        return true;
    };
    Scroller.prototype.ap = function (a, b) {
        if (this.keyboardListener != null) {
            if (this.keyboardListener.onUpArrow(a, b)) {
                return true;
            }
        }
        if (this.scrollTop <= 0) {
            return false;
        }
        this.df(0, this.bi * -1);
        return true;
    };
    Scroller.prototype.ae = function (a, b) {
        if (this.keyboardListener != null) {
            if (this.keyboardListener.onDownArrow(a, b)) {
                return true;
            }
        }
        if (this.scrollTop + this.viewportHeight >= this.contentHeight) {
            return false;
        }
        this.df(0, this.bi);
        return true;
    };
    Scroller.prototype.am = function (a, b) {
        if (this.keyboardListener != null) {
            if (this.keyboardListener.onPageUp(a, b)) {
                return true;
            }
        }
        if (this.scrollTop < 0) {
            return false;
        }
        this.df(0, this.bg * -1);
        return true;
    };
    Scroller.prototype.al = function (a, b) {
        if (this.keyboardListener != null) {
            if (this.keyboardListener.onPageDown(a, b)) {
                return true;
            }
        }
        if (this.scrollTop + this.viewportHeight >= this.contentHeight) {
            return false;
        }
        this.df(0, this.bg);
        return true;
    };
    Scroller.prototype.ag = function (a, b) {
        if (this.keyboardListener != null) {
            if (this.keyboardListener.onEnter(a, b)) {
                return true;
            }
        }
        return false;
    };
    Object.defineProperty(Scroller.prototype, "verticalTrackStartInset", {
        get: function () {
            return this.bb;
        },
        set: function (a) {
            var b = this.bb;
            this.bb = a;
            if (b != this.bb) {
                this.c8("VerticalTrackStartInset", b, this.bb);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "scrollbarBrush", {
        get: function () {
            return this.dp;
        },
        set: function (a) {
            var b = this.dp;
            this.dp = a;
            if (b != this.dp) {
                this.c8("ScrollbarBrush", b, this.dp);
            }
        },
        enumerable: true,
        configurable: true
    });
    Scroller.prototype.c8 = function (a, b, c) {
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
        this.db(a, b, c);
    };
    Object.defineProperty(Scroller.prototype, "aq", {
        get: function () {
            return this.v;
        },
        set: function (a) {
            this.v = a;
            if (!this.v) {
                this.view.a6(this.scrollTop);
                this.view.a5(this.scrollLeft);
            }
        },
        enumerable: true,
        configurable: true
    });
    Scroller.prototype.db = function (a, b, c) {
        switch (a) {
            case "ContentWidth":
                this.view.aw(this.contentWidth);
                var d = c;
                var e = b;
                if (d < e && this.scrollLeft + this.viewportWidth >= d) {
                    this.dg(d - (this.scrollLeft + this.viewportWidth), 0);
                }
                this.dl();
                break;
            case "ContentHeight":
                this.view.av(this.contentHeight);
                var f = c;
                var g = b;
                if (f < g && this.scrollTop + this.viewportHeight >= f) {
                    this.dg(0, f - (this.scrollTop + this.viewportHeight));
                }
                this.dn();
                break;
            case "ScrollTop":
                if (!this.aq) {
                    this.view.a6(this.scrollTop);
                }
                break;
            case "ScrollLeft":
                if (!this.aq) {
                    this.view.a5(this.scrollLeft);
                }
                break;
            case "ViewportWidth":
                this.view.az(this.viewportWidth);
                if (isNaN_(this.largeVerticalChange)) {
                    this.bf = this.viewportWidth;
                }
                this.dl();
                break;
            case "ViewportHeight":
                this.view.ay(this.viewportHeight);
                if (isNaN_(this.largeVerticalChange)) {
                    this.bg = this.viewportHeight;
                }
                this.dn();
                break;
            case "ScrollbarBrush":
            case "ScrollbarSpan":
            case "MinScrollbarSize":
            case "VerticalTrackStartInset":
                this.dn();
                this.dl();
                break;
            case "HorizontalScrollbarStatus":
            case "VerticalOpacity":
                this.view.a4(false);
                break;
            case "ScrollbarStyle":
                this.view.a4(true);
                break;
        }
    };
    Object.defineProperty(Scroller.prototype, "contentHeight", {
        get: function () {
            return this.ax;
        },
        set: function (a) {
            var b = this.ax;
            this.ax = a;
            if (b != this.ax) {
                this.c8("ContentHeight", b, this.ax);
            }
        },
        enumerable: true,
        configurable: true
    });
    Scroller.prototype.c9 = function (a) {
        var b = Math.max(this.minScrollbarSize, this.actualVerticalScrollbarHeight);
        var c = this.verticalTrackStartInset + (b / 2);
        var d = this.viewportHeight - (b / 2);
        var e = a / (d - c);
        var f = e * (this.contentHeight - this.viewportHeight);
        this.df(0, f);
    };
    Scroller.prototype.c7 = function (a) {
        var b = Math.max(this.minScrollbarSize, this.actualHorizontalScrollbarWidth);
        var c = 0 + (b / 2);
        var d = this.viewportWidth - (b / 2);
        var e = a / (d - c);
        var f = e * (this.contentWidth - this.viewportWidth);
        this.df(f, 0);
    };
    Scroller.prototype.da = function (a, b, c) {
        if (c === void 0) {
            c = false;
        }
        var d = this.bd;
        var e = this.bc;
        this.bd = a;
        this.bc = b;
        if (c && (d != a || e != b)) {
            this.c8("ViewportWidth", d, a);
            this.c8("ViewportHeight", e, b);
        }
    };
    Object.defineProperty(Scroller.prototype, "viewportWidth", {
        get: function () {
            return this.bd;
        },
        set: function (a) {
            var b = this.bd;
            this.bd = a;
            if (b != this.bd) {
                this.c8("ViewportWidth", b, this.bd);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "viewportHeight", {
        get: function () {
            return this.bc;
        },
        set: function (a) {
            var b = this.bc;
            this.bc = a;
            if (b != this.bc) {
                this.c8("ViewportHeight", b, this.bc);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "scrollTop", {
        get: function () {
            return this.a7;
        },
        set: function (a) {
            var b = this.a7;
            this.a7 = a;
            if (b != this.a7) {
                this.c8("ScrollTop", b, this.a7);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "scrollLeft", {
        get: function () {
            return this.a6;
        },
        set: function (a) {
            var b = this.a6;
            this.a6 = a;
            if (b != this.a6) {
                this.c8("ScrollLeft", b, this.a6);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "view", {
        get: function () {
            if (this.f == null) {
                this.f = new ScrollerView(this);
            }
            return this.f;
        },
        enumerable: true,
        configurable: true
    });
    Scroller.prototype.provideContainer = function (a) {
        this.view.a0(a);
        this.a7 = this.view.aa();
        this.a6 = this.view.z();
        this.dl();
        this.dn();
    };
    Scroller.prototype.onDetachedFromUI = function () {
        this.view.ax();
    };
    Scroller.prototype.onAttachedToUI = function () {
        this.view.au();
    };
    Scroller.prototype.provideContent = function (a) {
        this.view.a1(a);
    };
    Scroller.prototype.ak = function (a, b, c) {
        this.p = false;
        this.o = false;
        this.q = false;
        this.view.aj();
        if (this.keyboardListener != null) {
            this.keyboardListener.onWheel();
        }
        this.df(b, c);
        return true;
    };
    Object.defineProperty(Scroller.prototype, "lockScrollDirection", {
        get: function () {
            return this.t;
        },
        set: function (a) {
            this.t = true;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "actualVerticalScrollbarHeight", {
        get: function () {
            return this.aw;
        },
        set: function (a) {
            var b = this.aw;
            this.aw = a;
            if (b != this.aw) {
                this.c8("ActualVerticalScrollbarHeight", b, this.aw);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "actualHorizontalScrollbarWidth", {
        get: function () {
            return this.ar;
        },
        set: function (a) {
            var b = this.ar;
            this.ar = a;
            if (b != this.ar) {
                this.c8("ActualHorizontalScrollbarWidth", b, this.ar);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "scrollbarStyle", {
        get: function () {
            return this.c;
        },
        set: function (a) {
            var b = this.c;
            this.c = a;
            if (b != this.c) {
                this.c8("ScrollbarStyle", enumGetBox(ScrollbarStyle_$type, b), enumGetBox(ScrollbarStyle_$type, this.c));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "horizontalScrollbarStatus", {
        get: function () {
            return this.az;
        },
        set: function (a) {
            var b = this.az;
            this.az = a;
            if (b != this.az) {
                this.c8("HorizontalScrollbarStatus", b, this.az);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "verticalScrollbarStatus", {
        get: function () {
            return this.ba;
        },
        set: function (a) {
            var b = this.ba;
            this.ba = a;
            if (b != this.ba) {
                this.c8("VerticalOpacity", b, this.ba);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "horizontalAnimation", {
        get: function () {
            return this.h;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "verticalAnimation", {
        get: function () {
            return this.i;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "executionContext", {
        get: function () {
            return this._executionContext;
        },
        set: function (a) {
            this._executionContext = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "isVerticalActive", {
        get: function () {
            return this.w;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "isHorizontalActive", {
        get: function () {
            return this.l;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "isDraggingVBar", {
        get: function () {
            return this._isDraggingVBar;
        },
        set: function (a) {
            this._isDraggingVBar = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Scroller.prototype, "isDraggingHBar", {
        get: function () {
            return this._isDraggingHBar;
        },
        set: function (a) {
            this._isDraggingHBar = a;
        },
        enumerable: true,
        configurable: true
    });
    Scroller.prototype.focus = function () {
        this.view.ar();
    };
    Scroller.prototype.c6 = function (a) {
        this.view.ar();
        this.q = false;
        this.o = false;
        this.p = false;
        this.n = true;
        this.dr = { $type: Point_$type, x: a.x, y: a.y };
    };
    Scroller.prototype.c5 = function (a) {
        if (this.n) {
            var b = a.y - this.dr.y;
            var c = a.x - this.dr.x;
            if (this.lockScrollDirection && !this.p) {
                this.p = true;
                if (b > 0 || c > 0) {
                    if (b > c) {
                        this.q = true;
                    }
                    else {
                        this.q = true;
                    }
                }
            }
            this.dr = { $type: Point_$type, x: a.x, y: a.y };
            this.df(-c, -b);
        }
    };
    Scroller.prototype.scrollTo = function (a, b) {
        this.a3 = a - this.scrollLeft;
        this.a4 = b - this.scrollTop;
        this.de();
    };
    Scroller.prototype.df = function (a, b) {
        this.a3 += a;
        this.a4 += b;
        this.de();
    };
    Scroller.prototype.dg = function (a, b) {
        this.a3 += a;
        this.a4 += b;
        this.dk();
    };
    Scroller.prototype.de = function () {
        if (this.u) {
            return;
        }
        this.u = true;
        this.view.a2(runOn(this, this.dk));
    };
    Scroller.prototype.dk = function () {
        this.u = false;
        var a = this.a3;
        var b = this.a4;
        this.a3 = 0;
        this.a4 = 0;
        if (this.p) {
            if (this.q) {
                a = 0;
            }
            if (this.o) {
                b = 0;
            }
        }
        if (a != 0) {
            this.r = false;
            this.cv();
            this.cz();
            this.r = true;
        }
        if (b != 0) {
            this.s = false;
            this.cw();
            this.c0();
            this.s = true;
        }
        var c = Math.round(this.scrollTop + b);
        var d = Math.round(this.scrollLeft + a);
        if (c < 0) {
            c = 0;
            this.view.aj();
        }
        if (d < 0) {
            d = 0;
            this.view.aj();
        }
        if (c + this.viewportHeight > this.contentHeight) {
            c = this.contentHeight - this.viewportHeight;
            if (c < 0) {
                c = 0;
            }
            this.view.aj();
        }
        if (d + this.viewportWidth > this.contentWidth) {
            d = this.contentWidth - this.viewportWidth;
            if (d < 0) {
                d = 0;
            }
            this.view.aj();
        }
        b = c - this.scrollTop;
        a = d - this.scrollLeft;
        if (b != 0 || a != 0) {
            try {
                this.aq = true;
                this.y = true;
                this.scrollTop = c;
                this.scrollLeft = d;
                this.dn();
                this.dl();
                this.y = false;
                if (this.onScrolling != null) {
                    this.onScrolling(this, ((function () {
                        var $ret = new ScrollerScrollingEventArgs();
                        $ret.deltaX = a;
                        $ret.deltaY = b;
                        return $ret;
                    })()));
                }
            }
            finally {
                this.aq = false;
            }
        }
    };
    Scroller.prototype.dn = function () {
        this.dm(this.contentHeight, this.viewportHeight, this.scrollTop, true);
    };
    Scroller.prototype.dl = function () {
        this.dm(this.contentWidth, this.viewportWidth, this.scrollLeft, false);
    };
    Scroller.prototype.dm = function (a, b, c, d) {
        var e = Math.round((b / a) * b);
        var f = d ? this.verticalTrackStartInset : 0;
        e = e - f;
        if (e < this.minScrollbarSize) {
            e = this.minScrollbarSize;
        }
        if (e >= (b - f)) {
            if (d) {
                this.view.at();
            }
            else {
                this.view.as();
            }
            return;
        }
        var g = f + (e / 2);
        var h = b - (e / 2);
        var i = c / (a - b);
        var j = Math.round(g + (h - g) * i);
        if (d) {
            this.actualVerticalScrollbarHeight = e;
            this.view.a7(j, e);
        }
        else {
            this.actualHorizontalScrollbarWidth = e;
            this.view.a3(j, e);
        }
    };
    Scroller.prototype.c4 = function (a) {
        this.p = false;
        this.o = false;
        this.q = false;
        this.n = false;
    };
    Scroller.prototype.ct = function (a, b) {
        this.horizontalScrollbarStatus = this.bm + this.h.o * (this.bx - this.bm);
    };
    Scroller.prototype.cu = function (a, b) {
        this.verticalScrollbarStatus = this.bn + this.i.o * (this.by - this.bn);
    };
    Scroller.prototype.cv = function () {
        if (this.l) {
            return;
        }
        if (this.scrollbarStyle == 1 || this.scrollbarStyle == 2) {
            if (this.h.f()) {
                this.h.w();
            }
            this.horizontalScrollbarStatus = 1;
            if (this.m && this.r) {
                this.m = false;
            }
        }
        this.l = true;
    };
    Scroller.prototype.cw = function () {
        if (this.w) {
            return;
        }
        if (this.scrollbarStyle == 1 || this.scrollbarStyle == 2) {
            if (this.i.f()) {
                this.i.w();
            }
            this.verticalScrollbarStatus = 1;
            if (this.x && this.s) {
                this.x = false;
            }
        }
        this.w = true;
    };
    Scroller.prototype.cz = function () {
        if (!this.l || this.isDraggingHBar) {
            return;
        }
        if (this.scrollbarStyle == 1 || this.scrollbarStyle == 2) {
            this.di();
        }
        this.l = false;
    };
    Scroller.prototype.c0 = function () {
        if (!this.w || this.isDraggingVBar) {
            return;
        }
        if (this.scrollbarStyle == 1 || this.scrollbarStyle == 2) {
            this.dj();
        }
        this.w = false;
    };
    Scroller.prototype.di = function () {
        if (!this.m) {
            this.m = true;
            this.b4 = this.executionContext.getCurrentRelativeTime();
            this.executionContext.executeDelayed(runOn(this, this.cx), this.b3);
        }
        else {
            this.b4 = this.executionContext.getCurrentRelativeTime();
        }
    };
    Scroller.prototype.dj = function () {
        if (!this.x) {
            this.x = true;
            this.b5 = this.executionContext.getCurrentRelativeTime();
            this.executionContext.executeDelayed(runOn(this, this.cy), this.b3);
        }
        else {
            this.b5 = this.executionContext.getCurrentRelativeTime();
        }
    };
    Scroller.prototype.cx = function () {
        if (!this.m) {
            return;
        }
        var a = this.executionContext.getCurrentRelativeTime();
        if (a - this.b4 >= this.b3) {
            if (!this.h.f() && this.horizontalScrollbarStatus != 0) {
                this.bm = this.horizontalScrollbarStatus;
                this.bx = 0;
                this.h.v();
            }
            this.m = false;
        }
        else {
            this.executionContext.executeDelayed(runOn(this, this.cx), (this.b3 - (a - this.b4)));
        }
    };
    Scroller.prototype.cy = function () {
        if (!this.x) {
            return;
        }
        var a = this.executionContext.getCurrentRelativeTime();
        if (a - this.b5 >= this.b3) {
            if (!this.i.f() && this.verticalScrollbarStatus != 0) {
                this.bn = this.verticalScrollbarStatus;
                this.by = 0;
                this.i.v();
            }
            this.x = false;
        }
        else {
            this.executionContext.executeDelayed(runOn(this, this.cy), (this.b3 - (a - this.b5)));
        }
    };
    Scroller.$t = markType(Scroller, 'Scroller', Base.$, [INotifyPropertyChanged_$type]);
    return Scroller;
}(Base));
export { Scroller };
//# sourceMappingURL=ScrollerView_combined.js.map
