/*
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-react-core/ES2015/type";
import { NumericYAxis } from "./NumericYAxis";
import { NumericScaler } from "./NumericScaler";
import { AxisRange } from "./AxisRange";
import { PercentChangeAxisRenderer } from "./PercentChangeAxisRenderer";
import { isNaN_ } from "igniteui-react-core/ES2015/number";
import { AutoRangeCalculator } from "./AutoRangeCalculator";
/**
 * @hidden
 */
export class PercentChangeYAxis extends NumericYAxis {
    jb() {
        return new VerticalPercentChangeScaler(this);
    }
    i4() {
        let a = 1.7976931348623157E+308;
        let b = -1.7976931348623157E+308;
        for (let c of fromEnum(this.cr())) {
            let d = c.an(this);
            if (d == null) {
                continue;
            }
            let e = c.ee();
            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);
    }
    i7(a) {
        return new PercentChangeAxisRenderer(a);
    }
    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.gg.apply(this, arguments);
    }
    j$e(a, b, c, d) {
        this.gh.apply(this, arguments);
    }
    j$f(a, b, c, d) {
        this.gi.apply(this, arguments);
    }
    get j$a() {
        return this.b8;
    }
}
PercentChangeYAxis.$t = markType(PercentChangeYAxis, 'PercentChangeYAxis', NumericYAxis.$);
/**
 * @hidden
 */
export 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) {
        let c;
        if (isNaN_(b.b)) {
            c = a;
        }
        else {
            let d = (a - b.b) / Math.abs(b.b) * 100;
            c = d;
        }
        let e = (c - this.o) / this.m;
        if (!b.a) {
            e = 1 - e;
        }
        return b.d.top + b.d.height * (e - b.e.top) / b.e.height;
    }
    q(a, b) {
        let c = b.e.top + b.e.height * (a - b.d.top) / b.d.height;
        if (!b.a) {
            c = 1 - c;
        }
        return this.o + c * (this.m);
    }
}
VerticalPercentChangeScaler.$t = markType(VerticalPercentChangeScaler, 'VerticalPercentChangeScaler', NumericScaler.$);
