/*
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-angular-core";
import { HorizontalAxisLabelPanel } from "./HorizontalAxisLabelPanel";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-angular-core";
import { RangeInfo } from "./RangeInfo";
import { HorizontalLogarithmicScaler } from "./HorizontalLogarithmicScaler";
import { FastHorizontalLinearScaler } from "./FastHorizontalLinearScaler";
import { isNaN_ } from "igniteui-angular-core";
import { StraightNumericAxisBaseView } from "./StraightNumericAxisBaseView";
import { AxisDefaults } from "./AxisDefaults";
/**
 * @hidden
 */
export let NumericXAxis = /*@__PURE__*/ (() => {
    class NumericXAxis extends StraightNumericAxisBase {
        constructor() {
            super();
            this.ab = NumericXAxis.$;
            this.k4 = this.k2();
        }
        a4() {
            return new NumericXAxisView(this);
        }
        hv(a) {
            super.hv(a);
            this.oj = a;
        }
        av() {
            if (this.c6) {
                return (TypeRegistrar.create('HorizontalSmartAxisLabelPanel'));
            }
            else {
                return new HorizontalAxisLabelPanel();
            }
        }
        k2() {
            let a = super.k2();
            a.b.c = (b) => {
                if ((this.az == null || this.az.visibility == 0) && this.aj != null) {
                    this.aw.bg = b;
                    if (this.az != null && (this.az.location == 4 || this.az.location == 5)) {
                        this.bi.n3();
                    }
                }
            };
            a.k = (b, c, d) => this.iq(c, d, b.aa, b.b, false);
            a.l = (b, c, d, e) => this.ir(c, d, e, b.aa);
            a.m = (b, c) => {
                let d = b.z;
                let e = new ScalerParams(0, b.ab, b.aa, this.ci, d);
                return this.el(c, e);
            };
            a.q = (b, c) => true;
            a.j = (b) => this.ht(b.u, b.n, b.aa, b.a, true);
            a.e = (b) => {
                b.n = b.aa.bottom;
                if (this.aj != null && this.aj.bi != null) {
                    let c = b.n;
                    let d = b.r;
                    let e = this.ii(c, d, b.ab, b.aa, b.z, b.aa.top, b.aa.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.aa.left) && e <= Math.ceil(b.aa.right);
            };
            return a;
        }
        el(a, b) {
            if (this.n2 != null) {
                return this.n2.p(a, b);
            }
            return this.n1.p(a, b);
        }
        eo(a, b) {
            if (this.n2 != null) {
                return this.n2.q(a, b);
            }
            return this.n1.q(a, b);
        }
        hq(a, b, c, d) {
            if (this.n2 != null) {
                this.n2.v(a, b, c, d);
                return;
            }
            this.n1.v(a, b, c, d);
        }
        hp(a, b, c, d, e) {
            if (this.n2 != null) {
                this.n2.u(a, b, c, d, e);
                return;
            }
            this.n1.u(a, b, c, d, e);
        }
        hr(a, b, c, d) {
            if (this.n2 != null) {
                this.n2.j(a, b, c, d);
                return;
            }
            this.n1.j(a, b, c, d);
        }
        ok(a, b) {
            if (this.bi == null || isNaN_(a) || isNaN_(b)) {
                return;
            }
            let c = this.n7(a, this);
            let d = this.n7(b, this);
            if (isNaN_(c) || isNaN_(d)) {
                return;
            }
            this.bi.wk = new Rect(0, c, this.bi.wk.y, d - c, this.bi.wk.height);
        }
        k5(a, b, c, d) {
            let e = d;
            let f = super.k5(a, b, c, d);
            let g = new ScalerParams(0, b, a, this.ch, c);
            let h = NaN;
            let i = NaN;
            if (!this.ch && b.right == 1) {
                i = this.l3;
            }
            else if (this.ch && b.left == 0) {
                h = this.l3;
            }
            if (isNaN_(h)) {
                h = this.eo(e.left, g);
            }
            if (isNaN_(i)) {
                i = this.eo(e.right, g);
            }
            let j = Math.min(h, i);
            let k = Math.max(h, i);
            this.l7 = j;
            this.l6 = k;
            f.k.add(((() => {
                let $ret = new RangeInfo();
                $ret.d = j;
                $ret.c = k;
                $ret.b = e.width;
                return $ret;
            })()));
            return f;
        }
        ic(a) {
            super.ic(a);
            let b = this.bi != null ? this.bi.v4 : Rect.empty;
            let c = !b.isEmpty ? this.kh : Rect.empty;
            let d = this.kc();
            let e = this.kb();
            let f = this.k4.c(a, c, b, d, e);
            if (f != null) {
                this.l2 = f.f.m;
                this.l5 = f.f.l;
            }
        }
        is(a, b) {
            super.is(a, b);
            if (b.height != a.height) {
                this.c1();
            }
        }
        get_a2() {
            return 0;
        }
        get a2() {
            return this.get_a2();
        }
        k7() {
            if (this.lo) {
                return new HorizontalLogarithmicScaler();
            }
            switch (this.n0) {
                case 0: return new FastHorizontalLinearScaler();
                case 1: return new HorizontalLogarithmicScaler();
            }
            return null;
        }
        j$d(a, b) {
            return this.eo.apply(this, arguments);
        }
        j$c(a, b) {
            return this.el.apply(this, arguments);
        }
        j$e(a, b, c, d, e) {
            this.hp.apply(this, arguments);
        }
        j$f(a, b, c, d) {
            this.hq.apply(this, arguments);
        }
        j$g(a, b, c, d) {
            this.hr.apply(this, arguments);
        }
        get j$b() {
            return this.ch;
        }
        j$a() {
            return this.ag.apply(this, arguments);
        }
    }
    NumericXAxis.$t = markType(NumericXAxis, 'NumericXAxis', StraightNumericAxisBase.$, [IScaler_$type]);
    return NumericXAxis;
})();
/**
 * @hidden
 */
export let NumericXAxisView = /*@__PURE__*/ (() => {
    class NumericXAxisView extends StraightNumericAxisBaseView {
        constructor(a) {
            super(a);
            this.bo = null;
            this.bo = a;
        }
        al() {
            super.al();
            this.a.jz = AxisDefaults.h;
        }
    }
    NumericXAxisView.$t = markType(NumericXAxisView, 'NumericXAxisView', StraightNumericAxisBaseView.$);
    return NumericXAxisView;
})();
