/*
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 { __extends } from "tslib";
import { ScatterBase } from "./ScatterBase";
import { DependencyProperty } from "igniteui-angular-core";
import { Point_$type, typeCast, runOn, markType, markDep } from "igniteui-angular-core";
import { ScatterFrame } from "./ScatterFrame";
import { ScatterSplineSeriesView } from "./ScatterSplineSeriesView";
import { Defaults } from "./Defaults";
import { Clipper } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { OwnedPoint } from "./OwnedPoint";
import { PathGeometry } from "igniteui-angular-core";
import { Numeric } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
var ScatterSplineSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ScatterSplineSeries, _super);
    function ScatterSplineSeries() {
        var _this = _super.call(this) || this;
        _this.ab = ScatterSplineSeries.$;
        _this.sb = new ScatterFrame();
        _this.sd = new ScatterFrame();
        _this.r9 = new ScatterFrame();
        return _this;
    }
    ScatterSplineSeries.prototype.get_ej = function () {
        return true;
    };
    ScatterSplineSeries.prototype.by = function () {
        return new ScatterSplineSeriesView(this);
    };
    ScatterSplineSeries.prototype.gz = function () {
        if (!isNaN_(this.gy)) {
            return _super.prototype.gz.call(this);
        }
        return Defaults.x;
    };
    ScatterSplineSeries.prototype.l9 = function (a, b, c, d) {
        _super.prototype.l9.call(this, a, b, c, d);
        switch (b) {
            case ScatterSplineSeries.$$p[0]:
                this.mn(false);
                this.lu();
                break;
        }
    };
    ScatterSplineSeries.prototype.bq = function () {
        if (this.br == 0) {
            return 2;
        }
        else {
            return _super.prototype.bq.call(this);
        }
    };
    ScatterSplineSeries.prototype.ua = function (a, b) {
        var _this = this;
        _super.prototype.ua.call(this, a, b);
        a.m.clear();
        a.u.clear();
        var c = b.bv;
        var d = b.bu;
        var e = this.getEffectiveViewport1(b);
        var f = this.fx * this.fx;
        var g = Math.min(this.sl != null ? this.sl.count : 0, this.sm != null ? this.sm.count : 0);
        var h = new ScalerParams(0, c, d, this.r5.d, e);
        var i = ((function () {
            var $ret = new ScalerParams(0, c, d, _this.r5.e, e);
            $ret.b = _this.gg();
            return $ret;
        })());
        var j = function (k) { return _this.r5.a.ei(_this.sl.item(k), h); };
        var k = function (l) { return _this.r5.b.ei(_this.sm.item(l), i); };
        var l = ((function () {
            var $ret = new Clipper(0, d, false);
            $ret.i = a.m;
            return $ret;
        })());
        for (var m = 0; m < g;) {
            var n = m;
            ++m;
            while (m < g && this.vg(j, k, n, m) < f) {
                ++m;
            }
            if (g > this.tb) {
                l.j(this.vk(j, k, n, m - 1));
            }
            else {
                var o = new OwnedPoint();
                o.c = { $type: Point_$type, x: j(n), y: k(n) };
                o.a = this.cl.item(n);
                if (!a.u.containsKey(o.a)) {
                    a.u.addItem(o.a, o);
                }
            }
        }
        if (g > this.tb) {
            l.i = null;
        }
    };
    ScatterSplineSeries.prototype.vk = function (a, b, c, d) {
        if (c == d) {
            return { $type: Point_$type, x: a(c), y: b(c) };
        }
        var e = 0;
        var f = 0;
        var g = (d - c + 1);
        for (var h = c; h <= d; ++h) {
            e += a(h);
            f += b(h);
        }
        return { $type: Point_$type, x: e / g, y: f / g };
    };
    ScatterSplineSeries.prototype.vg = function (a, b, c, d) {
        var e = a(d) - a(c);
        var f = b(d) - b(c);
        return e * e + f * f;
    };
    ScatterSplineSeries.prototype.get_su = function () {
        return true;
    };
    ScatterSplineSeries.prototype.k2 = function (a, b) {
        _super.prototype.k2.call(this, a, b);
        var c = typeCast(ScatterSplineSeriesView.$, b);
        c.c4(false);
    };
    ScatterSplineSeries.prototype.ul = function (a, b) {
        this.k2(false, b);
        _super.prototype.ul.call(this, a, b);
        this.ud(a);
        var c = typeCast(ScatterSplineSeriesView.$, b);
        var d = c.dg;
        this.si.az(this, this.sz(), runOn(this, this.rt));
        var e = false;
        var f = this.si.b;
        if (f != null) {
            e = true;
        }
        if (e) {
            this.t6(-1, this.sl.count, b.q);
        }
        this.si.ad(d, true, false, true, false);
        c.dg.an = new PathGeometry();
        c.dg.an.c = Numeric.h(a.m.count, function (g) { return a.m._inner[g].x; }, function (g) { return a.m._inner[g].y; }, this.vh);
    };
    ScatterSplineSeries.$t = markType(ScatterSplineSeries, 'ScatterSplineSeries', ScatterBase.$);
    ScatterSplineSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterSplineSeries, 'raisePropertyChanged', ['Stiffness:vh:vj', [1, 0.5]]);
    return ScatterSplineSeries;
}(ScatterBase));
export { ScatterSplineSeries };
