/*
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 { 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
 */
export let ScrollerView = /*@__PURE__*/ (() => {
    class ScrollerView extends Base {
        constructor(a) {
            super();
            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;
        }
        a8() {
            return ((() => {
                let $ret = new Brush();
                $ret.fill = "#666666";
                return $ret;
            })());
        }
        a0(a) {
            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);
            let b = Math.round(this.ad.rootWrapper.width());
            let 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;
            let d = this.a;
            d.onMouseWheel = delegateCombine(d.onMouseWheel, runOn(this, this.l));
            let e = this.a;
            e.onMouseWheelHorizontal = delegateCombine(e.onMouseWheelHorizontal, runOn(this, this.m));
            let f = this.a;
            f.onMouseLeave = delegateCombine(f.onMouseLeave, runOn(this, this.aq));
            let g = this.a;
            g.onDragStarted = delegateCombine(g.onDragStarted, runOn(this, this.ap));
            let h = this.a;
            h.onDragDelta = delegateCombine(h.onDragDelta, runOn(this, this.ao));
            let i = this.a;
            i.onDragCompleted = delegateCombine(i.onDragCompleted, runOn(this, this.an));
            let j = this.a;
            j.onFlingStarted = delegateCombine(j.onFlingStarted, runOn(this, this.j));
            let k = this.a;
            k.onContactStarted = delegateCombine(k.onContactStarted, runOn(this, this.am));
            let l = this.a;
            l.onContactMoved = delegateCombine(l.onContactMoved, runOn(this, this.al));
            let m = this.a;
            m.onContactCompleted = delegateCombine(m.onContactCompleted, runOn(this, this.ak));
            this.a.aa = true;
            this.a.am = runOn(this, this.r);
            let n = this.a;
            n.onKeyDown = delegateCombine(n.onKeyDown, runOn(this, this.k));
            this.a.an = (o) => {
                let e_ = o.originalEvent;
                let 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);
        }
        k(a) {
            return this.c.ai(a, (this.a.bc & 4) != 0, (this.a.bc & 2) != 0);
        }
        r(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;
        }
        ak(a, b) {
            this.f = false;
            this.g = false;
            this.c.isDraggingVBar = false;
            this.c.isDraggingHBar = false;
        }
        al(a, b) {
            if (this.g) {
                let c = a.y - this.v;
                this.v = a.y;
                this.c.c9(c);
            }
            else if (this.f) {
                let d = a.x - this.s;
                this.s = a.x;
                this.c.c7(d);
            }
        }
        am(a, b) {
            this.e = false;
            this.aj();
            let c = this.q(a, b);
            let 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();
            }
        }
        p(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;
        }
        q(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;
        }
        n(a, b) {
            if (!this.h) {
                return false;
            }
            return a.y >= this.c.viewportHeight - this.c.scrollbarSpan - 40 && a.y <= this.c.viewportHeight;
        }
        o(a, b) {
            if (!this.i) {
                return false;
            }
            return a.x >= this.c.viewportWidth - this.c.scrollbarSpan - 40 && a.x <= this.c.viewportWidth;
        }
        j(a, b, c) {
            this.e = true;
            return true;
        }
        ay(a) {
            this.a.bf = new Rect(0, 0, 0, this.c.viewportWidth, this.c.viewportHeight);
        }
        az(a) {
            this.a.bf = new Rect(0, 0, 0, this.c.viewportWidth, this.c.viewportHeight);
        }
        av(a) {
            if (this.ae != null) {
                this.ae.setStyleProperty("height", a + "px");
            }
        }
        aw(a) {
            if (this.ae != null) {
                this.ae.setStyleProperty("width", a + "px");
            }
        }
        aj() {
        }
        an(a) {
            if (this.f || this.g) {
                return;
            }
            this.e = false;
            this.c.c4(a);
        }
        ao(a) {
            if (this.f || this.g) {
                return;
            }
            this.c.c5(a);
        }
        a6(a) {
            this.ac.scrollTop = truncate(a);
        }
        ap(a) {
            if (this.f || this.g) {
                return;
            }
            this.e = false;
            this.c.c6(a);
        }
        z() {
            return this.ac.scrollLeft;
        }
        aa() {
            return this.ac.scrollTop;
        }
        l(a, b) {
            this.e = false;
            this.aj();
            return this.c.ak(a, 0, b);
        }
        m(a, b) {
            this.e = false;
            this.aj();
            return this.c.ak(a, b, 0);
        }
        aq(a) {
            if (this.c.horizontalScrollbarStatus > 0) {
                this.c.cz();
            }
            if (this.c.verticalScrollbarStatus > 0) {
                this.c.c0();
            }
        }
        a5(a) {
            this.ac.scrollLeft = truncate(a);
        }
        a1(a) {
            this.ae = a;
            this.ah.append(this.ae);
        }
        a2(a) {
            if (this.ad == null) {
                return;
            }
            if (this.d == null) {
                this.d = this.ad.getRequestAnimationFrame();
            }
            if (this.e) {
                a();
            }
            else {
                this.d(() => a());
            }
        }
        at() {
            if (this.i) {
                this.i = false;
                this.ai.setStyleProperty("display", "none");
            }
        }
        as() {
            if (this.h) {
                this.h = false;
                this.af.setStyleProperty("display", "none");
            }
        }
        a7(a, b) {
            let 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);
                }
            }
        }
        a3(a, b) {
            let 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());
                }
            }
        }
        a4(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;
                }
            }
        }
        y() {
            if (this.c.scrollbarStyle == 2) {
                return this.c.horizontalScrollbarStatus * (this.c.scrollbarSpan - 2) + 2;
            }
            return this.c.scrollbarSpan;
        }
        ab() {
            if (this.c.scrollbarStyle == 2) {
                return this.c.verticalScrollbarStatus * (this.c.scrollbarSpan - 2) + 2;
            }
            return this.c.scrollbarSpan;
        }
        ar() {
            this.ad.rootWrapper.focus(false);
        }
        ax() {
            if (this.a != null) {
                this.a.bb(this.ad.rootWrapper, "");
            }
        }
        au() {
            if (this.a != null) {
                this.a.ap(this.ad.rootWrapper, "");
            }
        }
    }
    ScrollerView.$t = /*@__PURE__*/ markType(ScrollerView, 'ScrollerView');
    return ScrollerView;
})();
/**
 * @hidden
 */
export let Scroller = /*@__PURE__*/ (() => {
    class Scroller extends Base {
        constructor() {
            super();
            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;
            let a = this.h;
            a.propertyChanged = delegateCombine(a.propertyChanged, runOn(this, this.ct));
            let b = this.i;
            b.propertyChanged = delegateCombine(b.propertyChanged, runOn(this, this.cu));
        }
        get smallVerticalChange() {
            return this.a9;
        }
        set smallVerticalChange(a) {
            let b = this.a9;
            this.a9 = a;
            if (b != this.a9) {
                this.c8("SmallVerticalChange", b, this.a9);
            }
        }
        get keyboardListener() {
            return this._keyboardListener;
        }
        set keyboardListener(a) {
            this._keyboardListener = a;
        }
        get largeVerticalChange() {
            return this.a1;
        }
        set largeVerticalChange(a) {
            let b = this.a1;
            this.a1 = a;
            if (b != this.a1) {
                this.c8("LargeVerticalChange", b, this.a1);
            }
        }
        get bi() {
            return this.av;
        }
        set bi(a) {
            let b = this.av;
            this.av = a;
            if (b != this.av) {
                this.c8("ActualSmallVerticalChange", b, this.av);
            }
        }
        get bg() {
            return this.at;
        }
        set bg(a) {
            let b = this.at;
            this.at = a;
            if (b != this.at) {
                this.c8("ActualLargeVerticalChange", b, this.at);
            }
        }
        get smallHorizontalChange() {
            return this.a8;
        }
        set smallHorizontalChange(a) {
            let b = this.a8;
            this.a8 = a;
            if (b != this.a8) {
                this.c8("SmallHorizontalChange", b, this.a8);
            }
        }
        get largeHorizontalChange() {
            return this.a0;
        }
        set largeHorizontalChange(a) {
            let b = this.a0;
            this.a0 = a;
            if (b != this.a0) {
                this.c8("LargeHorizontalChange", b, this.a0);
            }
        }
        get bh() {
            return this.au;
        }
        set bh(a) {
            let b = this.au;
            this.au = a;
            if (b != this.au) {
                this.c8("ActualSmallHorizontalChange", b, this.au);
            }
        }
        get bf() {
            return this.as;
        }
        set bf(a) {
            let b = this.as;
            this.as = a;
            if (b != this.as) {
                this.c8("ActualLargeHorizontalChange", b, this.as);
            }
        }
        get contentWidth() {
            return this.ay;
        }
        set contentWidth(a) {
            let b = this.ay;
            this.ay = a;
            if (b != this.ay) {
                this.c8("ContentWidth", b, this.ay);
            }
        }
        get minScrollbarSize() {
            return this.a2;
        }
        set minScrollbarSize(a) {
            let b = this.a2;
            this.a2 = a;
            if (b != this.a2) {
                this.c8("MinScrollbarSize", b, this.a2);
            }
        }
        get scrollbarSpan() {
            return this.a5;
        }
        set scrollbarSpan(a) {
            let b = this.a5;
            this.a5 = a;
            if (b != this.a5) {
                this.c8("ScrollbarSpan", b, this.a5);
            }
        }
        ai(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;
        }
        ao(a, b) {
            if (this.keyboardListener != null) {
                if (this.keyboardListener.onTab(a, b)) {
                    return true;
                }
            }
            return false;
        }
        af(a, b) {
            if (this.keyboardListener != null) {
                if (this.keyboardListener.onEnd(a, b)) {
                    return true;
                }
            }
            return false;
        }
        ah(a, b) {
            if (this.keyboardListener != null) {
                if (this.keyboardListener.onHome(a, b)) {
                    return true;
                }
            }
            return false;
        }
        an(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;
        }
        aj(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;
        }
        ap(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;
        }
        ae(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;
        }
        am(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;
        }
        al(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;
        }
        ag(a, b) {
            if (this.keyboardListener != null) {
                if (this.keyboardListener.onEnter(a, b)) {
                    return true;
                }
            }
            return false;
        }
        get verticalTrackStartInset() {
            return this.bb;
        }
        set verticalTrackStartInset(a) {
            let b = this.bb;
            this.bb = a;
            if (b != this.bb) {
                this.c8("VerticalTrackStartInset", b, this.bb);
            }
        }
        get scrollbarBrush() {
            return this.dp;
        }
        set scrollbarBrush(a) {
            let b = this.dp;
            this.dp = a;
            if (b != this.dp) {
                this.c8("ScrollbarBrush", b, this.dp);
            }
        }
        c8(a, b, c) {
            if (this.propertyChanged != null) {
                this.propertyChanged(this, new PropertyChangedEventArgs(a));
            }
            this.db(a, b, c);
        }
        get aq() {
            return this.v;
        }
        set aq(a) {
            this.v = a;
            if (!this.v) {
                this.view.a6(this.scrollTop);
                this.view.a5(this.scrollLeft);
            }
        }
        db(a, b, c) {
            switch (a) {
                case "ContentWidth":
                    this.view.aw(this.contentWidth);
                    let d = c;
                    let 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);
                    let f = c;
                    let 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;
            }
        }
        get contentHeight() {
            return this.ax;
        }
        set contentHeight(a) {
            let b = this.ax;
            this.ax = a;
            if (b != this.ax) {
                this.c8("ContentHeight", b, this.ax);
            }
        }
        c9(a) {
            let b = Math.max(this.minScrollbarSize, this.actualVerticalScrollbarHeight);
            let c = this.verticalTrackStartInset + (b / 2);
            let d = this.viewportHeight - (b / 2);
            let e = a / (d - c);
            let f = e * (this.contentHeight - this.viewportHeight);
            this.df(0, f);
        }
        c7(a) {
            let b = Math.max(this.minScrollbarSize, this.actualHorizontalScrollbarWidth);
            let c = 0 + (b / 2);
            let d = this.viewportWidth - (b / 2);
            let e = a / (d - c);
            let f = e * (this.contentWidth - this.viewportWidth);
            this.df(f, 0);
        }
        da(a, b, c = false) {
            let d = this.bd;
            let 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);
            }
        }
        get viewportWidth() {
            return this.bd;
        }
        set viewportWidth(a) {
            let b = this.bd;
            this.bd = a;
            if (b != this.bd) {
                this.c8("ViewportWidth", b, this.bd);
            }
        }
        get viewportHeight() {
            return this.bc;
        }
        set viewportHeight(a) {
            let b = this.bc;
            this.bc = a;
            if (b != this.bc) {
                this.c8("ViewportHeight", b, this.bc);
            }
        }
        get scrollTop() {
            return this.a7;
        }
        set scrollTop(a) {
            let b = this.a7;
            this.a7 = a;
            if (b != this.a7) {
                this.c8("ScrollTop", b, this.a7);
            }
        }
        get scrollLeft() {
            return this.a6;
        }
        set scrollLeft(a) {
            let b = this.a6;
            this.a6 = a;
            if (b != this.a6) {
                this.c8("ScrollLeft", b, this.a6);
            }
        }
        get view() {
            if (this.f == null) {
                this.f = new ScrollerView(this);
            }
            return this.f;
        }
        provideContainer(a) {
            this.view.a0(a);
            this.a7 = this.view.aa();
            this.a6 = this.view.z();
            this.dl();
            this.dn();
        }
        onDetachedFromUI() {
            this.view.ax();
        }
        onAttachedToUI() {
            this.view.au();
        }
        provideContent(a) {
            this.view.a1(a);
        }
        ak(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;
        }
        get lockScrollDirection() {
            return this.t;
        }
        set lockScrollDirection(a) {
            this.t = true;
        }
        get actualVerticalScrollbarHeight() {
            return this.aw;
        }
        set actualVerticalScrollbarHeight(a) {
            let b = this.aw;
            this.aw = a;
            if (b != this.aw) {
                this.c8("ActualVerticalScrollbarHeight", b, this.aw);
            }
        }
        get actualHorizontalScrollbarWidth() {
            return this.ar;
        }
        set actualHorizontalScrollbarWidth(a) {
            let b = this.ar;
            this.ar = a;
            if (b != this.ar) {
                this.c8("ActualHorizontalScrollbarWidth", b, this.ar);
            }
        }
        get scrollbarStyle() {
            return this.c;
        }
        set scrollbarStyle(a) {
            let b = this.c;
            this.c = a;
            if (b != this.c) {
                this.c8("ScrollbarStyle", enumGetBox(ScrollbarStyle_$type, b), enumGetBox(ScrollbarStyle_$type, this.c));
            }
        }
        get horizontalScrollbarStatus() {
            return this.az;
        }
        set horizontalScrollbarStatus(a) {
            let b = this.az;
            this.az = a;
            if (b != this.az) {
                this.c8("HorizontalScrollbarStatus", b, this.az);
            }
        }
        get verticalScrollbarStatus() {
            return this.ba;
        }
        set verticalScrollbarStatus(a) {
            let b = this.ba;
            this.ba = a;
            if (b != this.ba) {
                this.c8("VerticalOpacity", b, this.ba);
            }
        }
        get horizontalAnimation() {
            return this.h;
        }
        get verticalAnimation() {
            return this.i;
        }
        get executionContext() {
            return this._executionContext;
        }
        set executionContext(a) {
            this._executionContext = a;
        }
        get isVerticalActive() {
            return this.w;
        }
        get isHorizontalActive() {
            return this.l;
        }
        get isDraggingVBar() {
            return this._isDraggingVBar;
        }
        set isDraggingVBar(a) {
            this._isDraggingVBar = a;
        }
        get isDraggingHBar() {
            return this._isDraggingHBar;
        }
        set isDraggingHBar(a) {
            this._isDraggingHBar = a;
        }
        focus() {
            this.view.ar();
        }
        c6(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 };
        }
        c5(a) {
            if (this.n) {
                let b = a.y - this.dr.y;
                let 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);
            }
        }
        scrollTo(a, b) {
            this.a3 = a - this.scrollLeft;
            this.a4 = b - this.scrollTop;
            this.de();
        }
        df(a, b) {
            this.a3 += a;
            this.a4 += b;
            this.de();
        }
        dg(a, b) {
            this.a3 += a;
            this.a4 += b;
            this.dk();
        }
        de() {
            if (this.u) {
                return;
            }
            this.u = true;
            this.view.a2(runOn(this, this.dk));
        }
        dk() {
            this.u = false;
            let a = this.a3;
            let 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;
            }
            let c = Math.round(this.scrollTop + b);
            let 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, ((() => {
                            let $ret = new ScrollerScrollingEventArgs();
                            $ret.deltaX = a;
                            $ret.deltaY = b;
                            return $ret;
                        })()));
                    }
                }
                finally {
                    this.aq = false;
                }
            }
        }
        dn() {
            this.dm(this.contentHeight, this.viewportHeight, this.scrollTop, true);
        }
        dl() {
            this.dm(this.contentWidth, this.viewportWidth, this.scrollLeft, false);
        }
        dm(a, b, c, d) {
            let e = Math.round((b / a) * b);
            let 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;
            }
            let g = f + (e / 2);
            let h = b - (e / 2);
            let i = c / (a - b);
            let 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);
            }
        }
        c4(a) {
            this.p = false;
            this.o = false;
            this.q = false;
            this.n = false;
        }
        ct(a, b) {
            this.horizontalScrollbarStatus = this.bm + this.h.o * (this.bx - this.bm);
        }
        cu(a, b) {
            this.verticalScrollbarStatus = this.bn + this.i.o * (this.by - this.bn);
        }
        cv() {
            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;
        }
        cw() {
            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;
        }
        cz() {
            if (!this.l || this.isDraggingHBar) {
                return;
            }
            if (this.scrollbarStyle == 1 || this.scrollbarStyle == 2) {
                this.di();
            }
            this.l = false;
        }
        c0() {
            if (!this.w || this.isDraggingVBar) {
                return;
            }
            if (this.scrollbarStyle == 1 || this.scrollbarStyle == 2) {
                this.dj();
            }
            this.w = false;
        }
        di() {
            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();
            }
        }
        dj() {
            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();
            }
        }
        cx() {
            if (!this.m) {
                return;
            }
            let 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)));
            }
        }
        cy() {
            if (!this.x) {
                return;
            }
            let 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 = /*@__PURE__*/ markType(Scroller, 'Scroller', Base.$, [INotifyPropertyChanged_$type]);
    return Scroller;
})();
//# sourceMappingURL=ScrollerView_combined.js.map
