/*
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 { LinearScaler } from "./LinearScaler";
import { NumericScaler } from "./NumericScaler";
import { markType } from "igniteui-react-core/ES2015/type";
import { ArrayAccessHelper } from "igniteui-react-core/ES2015/ArrayAccessHelper";
/**
 * @hidden
 */
export class HorizontalLinearScaler extends LinearScaler {
    q(a, b) {
        if (!b.c.isEmpty) {
            let c = b.e.left + b.e.width * (a - b.d.left) / b.d.width;
            c = (c * b.d.width) + b.d.left;
            c = this.ae(c, NumericScaler.ac, b.c, b.a);
            return c;
        }
        return this.ae(a, b.e, b.d, b.a);
    }
    p(a, b) {
        if (!b.c.isEmpty) {
            let c = this.ad(a, NumericScaler.ac, b.c, b.a);
            c = (c - b.d.left) / b.d.width;
            c = b.d.left + b.d.width * (c - b.e.left) / b.e.width;
            return c;
        }
        return this.ad(a, b.e, b.d, b.a);
    }
    v(a, b, c, d) {
        let e;
        let f = d.e;
        let g = d.d;
        let h = d.c;
        let i = d.a;
        let j = !h.isEmpty;
        let k = this.m;
        let l = this.o;
        let m = h.left;
        let n = h.width;
        let o = f.left;
        let p = f.width;
        let q = g.left;
        let r = g.width;
        let s = 0;
        let t = 1;
        let u = ArrayAccessHelper.b(a);
        let v = false;
        if (u != null) {
            v = true;
        }
        for (let w = b; w < c; w++) {
            if (v) {
                e = u[w];
            }
            else {
                e = a.item(w);
            }
            if (j) {
                let x = (e - l) / (k);
                if (i) {
                    x = 1 - x;
                }
                x = m + n * (x - s) / t;
                let y = (x - (o * r)) / p;
                if (v) {
                    u[w] = y;
                }
                else {
                    a.item(w, y);
                }
            }
            else {
                let z = (e - l) / (k);
                if (i) {
                    z = 1 - z;
                }
                z = q + r * (z - o) / p;
                if (v) {
                    u[w] = z;
                }
                else {
                    a.item(w, z);
                }
            }
        }
    }
    ae(a, b, c, d) {
        let e = b.left + b.width * (a - c.left) / c.width;
        if (d) {
            e = 1 - e;
        }
        return this.o + e * (this.m);
    }
    ad(a, b, c, d) {
        let e = (a - this.o) / (this.m);
        if (d) {
            e = 1 - e;
        }
        return c.left + c.width * (e - b.left) / b.width;
    }
}
HorizontalLinearScaler.$t = markType(HorizontalLinearScaler, 'HorizontalLinearScaler', LinearScaler.$);
