/*
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 { fromEnum, markType } from "igniteui-angular-core";
import { NumericYAxis } from "./NumericYAxis";
import { NumericScaler } from "./NumericScaler";
import { AxisRange } from "./AxisRange";
import { PercentChangeAxisRenderer } from "./PercentChangeAxisRenderer";
import { isNaN_ } from "igniteui-angular-core";
import { AutoRangeCalculator } from "./AutoRangeCalculator";
/**
 * @hidden
 */
export let PercentChangeYAxis = /*@__PURE__*/ (() => {
    class PercentChangeYAxis extends NumericYAxis {
        ak() {
            return new PercentChangeYAxis();
        }
        ot() {
            return new VerticalPercentChangeScaler(this);
        }
        oh() {
            let a = 1.7976931348623157E+308;
            let b = -1.7976931348623157E+308;
            for (let c of fromEnum(this.ed())) {
                let d = c.ay(this);
                if (d == null) {
                    continue;
                }
                let e = c.i0();
                if (isNaN_(e) || e == 0) {
                    continue;
                }
                let f = d.b - e;
                let g = e - d.c;
                let h = Math.abs(f / e * 100);
                let i = Math.abs(g / e * 100);
                a = Math.min(a, -i);
                b = Math.max(b, h);
            }
            return new AxisRange(a, b);
        }
        op(a) {
            return new PercentChangeAxisRenderer(a);
        }
        e3(a, b) {
            let c = ((a - b.b) / b.b) * 100;
            if (c < this.pr) {
                let d = ((this.pr / 100) * b.b) + b.b;
                return d;
            }
            if (c > this.pq) {
                let e = ((this.pq / 100) * b.b) + b.b;
                return e;
            }
            return a;
        }
        j$d(a, b) {
            return this.fw.apply(this, arguments);
        }
        j$c(a, b) {
            return this.ft.apply(this, arguments);
        }
        j$e(a, b, c, d, e) {
            this.j5.apply(this, arguments);
        }
        j$f(a, b, c, d) {
            this.j6.apply(this, arguments);
        }
        j$g(a, b, c, d) {
            this.j7.apply(this, arguments);
        }
        get j$b() {
            return this.df;
        }
        j$a() {
            return this.ag.apply(this, arguments);
        }
    }
    PercentChangeYAxis.$t = markType(PercentChangeYAxis, 'PercentChangeYAxis', NumericYAxis.$);
    return PercentChangeYAxis;
})();
/**
 * @hidden
 */
export let VerticalPercentChangeScaler = /*@__PURE__*/ (() => {
    class VerticalPercentChangeScaler extends NumericScaler {
        constructor(a) {
            super();
            this.ad = null;
            this.ad = a;
        }
        t(a, b, c, d, e) {
            let f = AutoRangeCalculator.a(this.ad, b, c, false, -1, d, e);
            d = f.p5;
            e = f.p6;
            return {
                p3: d,
                p4: e
            };
        }
        p(a, b) {
            if (!b.c.isEmpty) {
                let c = this.ae(a, NumericScaler.ac, b.c, b.b, b.a);
                c = (c - b.d.top) / b.d.height;
                c = b.d.top + b.d.height * (c - b.e.top) / b.e.height;
                return c;
            }
            return this.ae(a, b.e, b.d, b.b, b.a);
        }
        ae(a, b, c, d, e) {
            let f;
            if (isNaN_(d)) {
                f = a;
            }
            else {
                let g = (a - d) / Math.abs(d) * 100;
                f = g;
            }
            let h = (f - this.o) / this.m;
            if (!e) {
                h = 1 - h;
            }
            return c.top + c.height * (h - b.top) / b.height;
        }
        q(a, b) {
            let c = b.b;
            let d = b.e.top + b.e.height * (a - b.d.top) / b.d.height;
            if (!b.a) {
                d = 1 - d;
            }
            let e = this.o + d * (this.m);
            let f;
            if (isNaN_(c)) {
                f = e;
            }
            else {
                let g = ((e) * Math.abs(c) / 100) + c;
                f = g;
            }
            return f;
        }
    }
    VerticalPercentChangeScaler.$t = markType(VerticalPercentChangeScaler, 'VerticalPercentChangeScaler', NumericScaler.$);
    return VerticalPercentChangeScaler;
})();
