/*
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 { ScatterBase } from "./ScatterBase";
import { DependencyProperty } from "igniteui-react-core";
import { Point_$type, typeCast, runOn, markType, markDep } from "igniteui-react-core";
import { ScatterFrame } from "./ScatterFrame";
import { ScatterSplineSeriesView } from "./ScatterSplineSeriesView";
import { Defaults } from "./Defaults";
import { Clipper } from "igniteui-react-core";
import { OwnedPoint } from "./OwnedPoint";
import { ScalerParams } from "./ScalerParams";
import { PathGeometry } from "igniteui-react-core";
import { Numeric } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
/**
 * @hidden
 */
export let ScatterSplineSeries = /*@__PURE__*/ (() => {
    class ScatterSplineSeries extends ScatterBase {
        bi() {
            return new ScatterSplineSeries();
        }
        get_fy() {
            return true;
        }
        constructor() {
            super();
            this.ab = ScatterSplineSeries.$;
            this.yt = new ScatterFrame();
            this.yv = new ScatterFrame();
            this.yr = new ScatterFrame();
        }
        cq() {
            return new ScatterSplineSeriesView(this);
        }
        zn() {
            return true;
        }
        ji() {
            if (!isNaN_(this.jh)) {
                return super.ji();
            }
            return Defaults.x;
        }
        q4(a, b, c, d) {
            super.q4(a, b, c, d);
            switch (b) {
                case ScatterSplineSeries.$$p[0]:
                    this.rm(false);
                    this.qg();
                    break;
            }
        }
        b0() {
            if (this.b1 == 0) {
                return 2;
            }
            else {
                return super.b0();
            }
        }
        aa5(a, b) {
            super.aa5(a, b);
            a.m.clear();
            a.u.clear();
            let c = b.by;
            let d = b.bx;
            let e = this.getEffectiveViewport1(b);
            let f = this.ib * this.ib;
            let g = Math.min(this.y8 != null ? this.y8.count : 0, this.y9 != null ? this.y9.count : 0);
            let h = new ScalerParams(0, c, d, this.yn.d, e);
            let i = ((() => {
                let $ret = new ScalerParams(0, c, d, this.yn.e, e);
                $ret.b = this.iw();
                return $ret;
            })());
            let j = (k) => this.yn.a.ek(this.y8.item(k), h);
            let k = (l) => this.yn.b.ek(this.y9.item(l), i);
            let l = ((() => {
                let $ret = new Clipper(0, d, false);
                $ret.i = a.m;
                return $ret;
            })());
            for (let m = 0; m < g;) {
                let n = m;
                ++m;
                while (m < g && this.acd(j, k, n, m) < f) {
                    ++m;
                }
                if (g > this.z0) {
                    l.j(this.ach(j, k, n, m - 1));
                }
                else {
                    let o = new OwnedPoint();
                    o.c = { $type: Point_$type, x: j(n), y: k(n) };
                    o.a = this.dl.item(n);
                    if (!a.u.containsKey(o.a)) {
                        a.u.addItem(o.a, o);
                    }
                }
            }
            if (g > this.z0) {
                l.i = null;
            }
        }
        ach(a, b, c, d) {
            if (c == d) {
                return { $type: Point_$type, x: a(c), y: b(c) };
            }
            let e = 0;
            let f = 0;
            let g = (d - c + 1);
            for (let h = c; h <= d; ++h) {
                e += a(h);
                f += b(h);
            }
            return { $type: Point_$type, x: e / g, y: f / g };
        }
        acd(a, b, c, d) {
            let e = a(d) - a(c);
            let f = b(d) - b(c);
            return e * e + f * f;
        }
        get_zh() {
            return true;
        }
        o2(a, b) {
            super.o2(a, b);
            let c = typeCast(ScatterSplineSeriesView.$, b);
            c.c9(false);
        }
        abg(a, b) {
            this.o2(false, b);
            super.abg(a, b);
            this.aa8(a);
            let c = typeCast(ScatterSplineSeriesView.$, b);
            let d = c.dl;
            this.y0.az(this, this.zm(), runOn(this, this.yg));
            let e = false;
            let f = this.y0.b;
            if (f != null) {
                e = true;
            }
            if (e) {
                this.aa1(-1, this.y8.count, b.q);
            }
            this.y0.ad(d, true, false, true, false);
            c.dl.an = new PathGeometry();
            c.dl.an.c = Numeric.h(a.m.count, (g) => a.m._inner[g].x, (g) => a.m._inner[g].y, this.ace);
        }
    }
    ScatterSplineSeries.$t = /*@__PURE__*/ markType(ScatterSplineSeries, 'ScatterSplineSeries', ScatterBase.$);
    ScatterSplineSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ScatterSplineSeries, 'raisePropertyChanged', ['Stiffness:ace:acg', [1, 0.5]]);
    return ScatterSplineSeries;
})();
