/*
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 { StraightNumericAxisBase } from "./StraightNumericAxisBase";
import { IScaler_$type } from "./IScaler";
import { markType, TypeRegistrar } from "igniteui-react-core/ES2015/type";
import { HorizontalAxisLabelPanel } from "./HorizontalAxisLabelPanel";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-react-core/ES2015/Rect";
import { RangeInfo } from "./RangeInfo";
import { HorizontalLogarithmicScaler } from "./HorizontalLogarithmicScaler";
import { FastHorizontalLinearScaler } from "./FastHorizontalLinearScaler";
import { isNaN_ } from "igniteui-react-core/ES2015/number";
import { StraightNumericAxisBaseView } from "./StraightNumericAxisBaseView";
export class NumericXAxis extends StraightNumericAxisBase {
    constructor() {
        super();
        this.ab = NumericXAxis.$;
        this.i7 = this.i5();
    }
    a1() {
        return new NumericXAxisView(this);
    }
    gl(a) {
        super.gl(a);
        this.ln = a;
    }
    as() {
        if (this.co) {
            return (TypeRegistrar.create('HorizontalSmartAxisLabelPanel'));
        }
        else {
            return new HorizontalAxisLabelPanel();
        }
    }
    i5() {
        let a = super.i5();
        a.b.c = (b) => {
            if ((this.aw == null || this.aw.visibility == 0) && this.ag != null) {
                this.at.a8 = b;
                if (this.aw != null && (this.aw.location == 4 || this.aw.location == 5)) {
                    this.bf.hp();
                }
            }
        };
        a.k = (b, c, d) => this.g8(c, d, b.z, b.b, false);
        a.l = (b, c, d, e) => this.g9(c, d, e, b.z);
        a.m = (b, c) => {
            let d = b.y;
            let e = new ScalerParams(0, b.aa, b.z, this.b9, d);
            return this.dt(c, e);
        };
        a.q = (b, c) => true;
        a.j = (b) => this.gj(b.t, b.n, b.z, b.a, true);
        a.e = (b) => {
            b.n = b.z.bottom;
            if (this.ag != null && this.ag.bf != null) {
                let c = b.n;
                let d = b.r;
                let e = this.g3(c, d, b.aa, b.z, b.y, b.z.top, b.z.bottom);
                c = e.p0;
                d = e.p1;
                b.n = c;
                b.r = d;
            }
        };
        a.p = (b, c, d) => {
            let e = Math.round(c);
            return e >= Math.floor(b.z.left) && e <= Math.ceil(b.z.right);
        };
        return a;
    }
    dt(a, b) {
        if (this.k6 != null) {
            return this.k6.p(a, b);
        }
        return this.k5.p(a, b);
    }
    dw(a, b) {
        if (this.k6 != null) {
            return this.k6.q(a, b);
        }
        return this.k5.q(a, b);
    }
    gg(a, b, c, d) {
        if (this.k6 != null) {
            this.k6.v(a, b, c, d);
            return;
        }
        this.k5.v(a, b, c, d);
    }
    gf(a, b, c, d, e) {
        if (this.k6 != null) {
            this.k6.u(a, b, c, d, e);
            return;
        }
        this.k5.u(a, b, c, d, e);
    }
    gh(a, b, c, d) {
        if (this.k6 != null) {
            this.k6.j(a, b, c, d);
            return;
        }
        this.k5.j(a, b, c, d);
    }
    lo(a, b) {
        if (this.bf == null || a == NaN || b == NaN) {
            return;
        }
        let c = this.lb(a, this);
        let d = this.lb(b, this);
        if (c == NaN || d == NaN) {
            return;
        }
        this.bf.my = new Rect(0, c, this.bf.my.y, d - c, this.bf.my.height);
    }
    i8(a, b, c, d) {
        let e = d;
        let f = super.i8(a, b, c, d);
        let g = new ScalerParams(0, b, a, this.b8, c);
        let h = NaN;
        let i = NaN;
        if (!this.b8 && b.right == 1) {
            i = this.jv;
        }
        else if (this.b8 && b.left == 0) {
            h = this.jv;
        }
        if (isNaN_(h)) {
            h = this.dw(e.left, g);
        }
        if (isNaN_(i)) {
            i = this.dw(e.right, g);
        }
        let j = Math.min(h, i);
        let k = Math.max(h, i);
        this.jz = j;
        this.jy = k;
        f.k.add(((() => {
            let $ret = new RangeInfo();
            $ret.d = j;
            $ret.c = k;
            $ret.b = e.width;
            return $ret;
        })()));
        return f;
    }
    g0(a) {
        super.g0(a);
        let b = this.bf != null ? this.bf.mk : Rect.empty;
        let c = !b.isEmpty ? this.it : Rect.empty;
        let d = this.io();
        let e = this.im();
        let f = this.i7.c(a, c, b, d, e);
        if (f != null) {
            this.ju = f.f.m;
            this.jx = f.f.l;
        }
    }
    ha(a, b) {
        super.ha(a, b);
        if (b.height != a.height) {
            this.ck();
        }
    }
    get_az() {
        return 0;
    }
    get az() {
        return this.get_az();
    }
    ja() {
        if (this.jl) {
            return new HorizontalLogarithmicScaler();
        }
        switch (this.k4) {
            case 0: return new FastHorizontalLinearScaler();
            case 1: return new HorizontalLogarithmicScaler();
        }
        return null;
    }
    j$c(a, b) {
        return this.dw.apply(this, arguments);
    }
    j$b(a, b) {
        return this.dt.apply(this, arguments);
    }
    j$d(a, b, c, d, e) {
        this.gf.apply(this, arguments);
    }
    j$e(a, b, c, d) {
        this.gg.apply(this, arguments);
    }
    j$f(a, b, c, d) {
        this.gh.apply(this, arguments);
    }
    get j$a() {
        return this.b8;
    }
}
NumericXAxis.$t = markType(NumericXAxis, 'NumericXAxis', StraightNumericAxisBase.$, [IScaler_$type]);
export class NumericXAxisView extends StraightNumericAxisBaseView {
    constructor(a) {
        super(a);
        this.bh = null;
        this.bh = a;
    }
}
NumericXAxisView.$t = markType(NumericXAxisView, 'NumericXAxisView', StraightNumericAxisBaseView.$);
