/*
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 { ScalerParams } from "./ScalerParams";
import { OwnedPoint } from "./OwnedPoint";
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 {
        get_fd() {
            return true;
        }
        constructor() {
            super();
            this.ab = ScatterSplineSeries.$;
            this.v0 = new ScatterFrame();
            this.v2 = new ScatterFrame();
            this.vy = new ScatterFrame();
        }
        cg() {
            return new ScatterSplineSeriesView(this);
        }
        wp() {
            return true;
        }
        ip() {
            if (!isNaN_(this.io)) {
                return super.ip();
            }
            return Defaults.x;
        }
        o8(a, b, c, d) {
            super.o8(a, b, c, d);
            switch (b) {
                case ScatterSplineSeries.$$p[0]:
                    this.pp(false);
                    this.ol();
                    break;
            }
        }
        bx() {
            if (this.by == 0) {
                return 2;
            }
            else {
                return super.bx();
            }
        }
        x6(a, b) {
            super.x6(a, b);
            a.m.clear();
            a.u.clear();
            let c = b.by;
            let d = b.bx;
            let e = this.getEffectiveViewport1(b);
            let f = this.hj * this.hj;
            let g = Math.min(this.wa != null ? this.wa.count : 0, this.wb != null ? this.wb.count : 0);
            let h = new ScalerParams(0, c, d, this.vu.d, e);
            let i = ((() => {
                let $ret = new ScalerParams(0, c, d, this.vu.e, e);
                $ret.b = this.h2();
                return $ret;
            })());
            let j = (k) => this.vu.a.ej(this.wa.item(k), h);
            let k = (l) => this.vu.b.ej(this.wb.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.ze(j, k, n, m) < f) {
                    ++m;
                }
                if (g > this.w1) {
                    l.j(this.zi(j, k, n, m - 1));
                }
                else {
                    let o = new OwnedPoint();
                    o.c = { $type: Point_$type, x: j(n), y: k(n) };
                    o.a = this.c6.item(n);
                    if (!a.u.containsKey(o.a)) {
                        a.u.addItem(o.a, o);
                    }
                }
            }
            if (g > this.w1) {
                l.i = null;
            }
        }
        zi(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 };
        }
        ze(a, b, c, d) {
            let e = a(d) - a(c);
            let f = b(d) - b(c);
            return e * e + f * f;
        }
        get_wj() {
            return true;
        }
        nj(a, b) {
            super.nj(a, b);
            let c = typeCast(ScatterSplineSeriesView.$, b);
            c.c7(false);
        }
        yh(a, b) {
            this.nj(false, b);
            super.yh(a, b);
            this.x9(a);
            let c = typeCast(ScatterSplineSeriesView.$, b);
            let d = c.dj;
            this.v7.az(this, this.wo(), runOn(this, this.vi));
            let e = false;
            let f = this.v7.b;
            if (f != null) {
                e = true;
            }
            if (e) {
                this.x2(-1, this.wa.count, b.q);
            }
            this.v7.ad(d, true, false, true, false);
            c.dj.an = new PathGeometry();
            c.dj.an.c = Numeric.h(a.m.count, (g) => a.m._inner[g].x, (g) => a.m._inner[g].y, this.zf);
        }
    }
    ScatterSplineSeries.$t = /*@__PURE__*/ markType(ScatterSplineSeries, 'ScatterSplineSeries', ScatterBase.$);
    ScatterSplineSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ScatterSplineSeries, 'raisePropertyChanged', ['Stiffness:zf:zh', [1, 0.5]]);
    return ScatterSplineSeries;
})();
