/*
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 * as React from 'react';
import { Visibility_$type } from "igniteui-react-core/ES2015/Visibility";
import { TransitionInSpeedType_$type } from './TransitionInSpeedType';
import { SeriesHitTestMode_$type } from './SeriesHitTestMode';
import { brushToString, stringToBrush, toPoint, fromPoint, fromRect, stringToColor, colorToString, ensureEnum, ensureBool, isValidProp, getModifiedProps } from "igniteui-react-core/ES2015/componentUtil";
import { RenderRequestedEventArgs } from './RenderRequestedEventArgs';
import { delegateCombine, delegateRemove, TypeRegistrar } from "igniteui-react-core/ES2015/type";
/**
 * Represents the base class for all IgxDataChartComponent series.
*/
export class IgrSeries extends React.Component {
    constructor(props) {
        super(props);
        this._chartLevelData = null;
        this._dataSource = null;
        this._tooltipTemplate = null;
        this._tooltipContent = null;
        this._tooltipContainerTemplate = null;
        this._renderer = null;
        this._renderRequested = null;
        this._renderRequested_wrapped = null;
        this._implementation = this.createImplementation();
        this._implementation.externalObject = this;
        this.onImplementationCreated();
    }
    get i() {
        return this._implementation;
    }
    onImplementationCreated() {
    }
    createImplementation() {
        return null;
    }
    initializeProperties() {
        for (const p of Object.keys(this.props)) {
            if (isValidProp(this, p)) {
                this[p] = this.props[p];
            }
        }
    }
    componentDidMount() {
        this.initializeProperties();
    }
    get seriesInternal() {
        return this.i;
    }
    shouldComponentUpdate(nextProps, nextState) {
        const mod = getModifiedProps(this.props, nextProps);
        for (const p of Object.keys(mod)) {
            if (isValidProp(this, p)) {
                this[p] = mod[p];
            }
        }
        return true;
    }
    render() {
        return null;
    }
    set name(value) {
        this.i.name = value;
    }
    get name() {
        return this.i.name;
    }
    provideData(data) {
        this._chartLevelData = data;
        this.updateDataSource();
    }
    updateDataSource() {
        if (this._dataSource == null) {
            this.i.itemsSource = this._chartLevelData;
        }
        else {
            this.i.itemsSource = this._dataSource;
        }
    }
    set dataSource(value) {
        this._dataSource = value;
        this.updateDataSource();
        //console.log("setting axis data source: " + value)
    }
    get dataSource() {
        if (this._dataSource != null) {
            return this._dataSource;
        }
        return this.i.itemsSource;
    }
    bindAxes(axes) {
    }
    set tooltipTemplate(value) {
        this._tooltipTemplate = value;
        if (value == null) {
            if (this._tooltipContent !== null) {
                //this._tooltipContent.destroy();
                this._tooltipContent = null;
            }
        }
        if (this._tooltipContent != null) {
            this._tooltipContent.instance.template = this._tooltipTemplate;
        }
        else {
            if (this.owner != null) {
                this.owner._ensureTooltipCreated(this);
            }
        }
    }
    get tooltipTemplate() {
        return this._tooltipTemplate;
    }
    set tooltipContainerTemplate(value) {
        this._tooltipContainerTemplate = value;
        if (this._tooltipContent != null) {
            this._tooltipContent.instance.containerTemplate = this._tooltipContainerTemplate;
        }
    }
    get tooltipContainerTemplate() {
        return this._tooltipContainerTemplate;
    }
    _ensureTooltipCreated(createTooltip, createWrapper) {
        if (this._tooltipTemplate == null) {
            this.i.toolTip = null;
        }
        if (this._tooltipContent == null && this._tooltipTemplate != null) {
            let tooltip = createTooltip();
            if (tooltip == null) {
                return;
            }
            this._tooltipContent = tooltip;
            tooltip.tooltipTemplate = this._tooltipTemplate;
            this.i.toolTip = createWrapper(tooltip);
        }
    }
    _ensureTooltipDestroyed() {
        if (this._tooltipContent !== null) {
            //this._tooltipContent.destroy();
            this._tooltipContent = null;
        }
    }
    _provideRenderer(renderer) {
        this._renderer = renderer;
    }
    static _createFromInternal(internal) {
        if (!internal) {
            return null;
        }
        if (!internal.$type) {
            return null;
        }
        let name = internal.$type.name;
        let externalName = "Igr" + name;
        if (!TypeRegistrar.isRegistered(externalName)) {
            return null;
        }
        return TypeRegistrar.create(externalName);
    }
    /**
 * Gets whether the series is an annotation layer.
*/
    get isAnnotationLayer() {
        return this.i.ci;
    }
    /**
     * Gets whether the current series is oriented vertically.
    */
    get isVertical() {
        return this.i.isVertical;
    }
    /**
     * Gets whether the current series is a stack fragment.
    */
    get isFragment() {
        return this.i.cr;
    }
    /**
     * Gets whether the current series shows an area or line shape.
    */
    get isAreaOrLine() {
        return this.i.cj;
    }
    /**
     * Gets whether the current series is a polar type series.
    */
    get isPolar() {
        return this.i.cz;
    }
    /**
     * Gets whether the current series is a scatter type series.
    */
    get isScatter() {
        return this.i.c3;
    }
    /**
     * Gets whether the current series is a radial type series.
    */
    get isRadial() {
        return this.i.c1;
    }
    /**
     * Gets whether the current series is a stacked type series.
    */
    get isStacked() {
        return this.i.isStacked;
    }
    /**
     * Gets whether the current series is a financial type series.
    */
    get isFinancial() {
        return this.i.cq;
    }
    /**
     * Gets whether the current series is a range type series.
    */
    get isRange() {
        return this.i.c2;
    }
    /**
     * Gets whether the current series is a category type series.
    */
    get isCategory() {
        return this.i.ck;
    }
    /**
     * Gets whether the current seires is a geogrpahic series.
    */
    get isGeographic() {
        return this.i.cs;
    }
    /**
     * Gets whether the default crosshair behavior should be disabled if this series is present.
    */
    get isDefaultCrosshairBehaviorDisabled() {
        return this.i.cl;
    }
    /**
     * Gets whether the default tooltip behavior should be disabled if this series is present.
    */
    get isDefaultTooltipBehaviorDisabled() {
        return this.i.cm;
    }
    /**
     * Returns whether the current series supports visual markers.
    */
    get hasMarkers() {
        return this.i.hasMarkers;
    }
    /**
     * Gets if the series uses an index, which can be used to auto-assign it a color.
    */
    get isIndexed() {
        return this.i.cv;
    }
    /**
     * Gets if the series should appear in any legends.
    */
    get isUsableInLegend() {
        return this.i.isUsableInLegend;
    }
    /**
     * Gets or sets the legend item visibility for the current series object.
    */
    get legendItemVisibility() {
        return this.i.ln;
    }
    set legendItemVisibility(v) {
        this.i.ln = ensureEnum(Visibility_$type, v);
    }
    /**
     * Gets or sets the LegendItemBadgeTemplate property.
     * The legend item badge is created according to the LegendItemBadgeTemplate on-demand by
     * the series object itself.
    */
    get legendItemBadgeTemplate() {
        return this.i.legendItemBadgeTemplate;
    }
    set legendItemBadgeTemplate(v) {
        this.i.legendItemBadgeTemplate = v;
    }
    /**
     * Gets or sets the LegendItemTemplate property.
     * The legend item control content is created according to the LegendItemTemplate on-demand by
     * the series object itself.
    */
    get legendItemTemplate() {
        return this.i.legendItemTemplate;
    }
    set legendItemTemplate(v) {
        this.i.legendItemTemplate = v;
    }
    /**
     * Gets or sets the DiscreteLegendItemTemplate property.
     * The legend item control content is created according to the DiscreteLegendItemTemplate on-demand by
     * the series object itself.
    */
    get discreteLegendItemTemplate() {
        return this.i.jm;
    }
    set discreteLegendItemTemplate(v) {
        this.i.jm = v;
    }
    /**
     * Gets or sets the easing function used to morph the current series.
    */
    get transitionEasingFunction() {
        return this.i.bu;
    }
    set transitionEasingFunction(v) {
        this.i.bu = v;
    }
    /**
     * Gets or sets the EasingFunction used to morph the current series during the initial transition.
    */
    get transitionInEasingFunction() {
        return this.i.bv;
    }
    set transitionInEasingFunction(v) {
        this.i.bv = v;
    }
    /**
     * Gets or sets the duration of the current series's morph.
    */
    get transitionDuration() {
        return this.i.fc;
    }
    set transitionDuration(v) {
        this.i.fc = +v;
    }
    /**
     * Gets or sets the current series object's rendering resolution.
    */
    get resolution() {
        return this.i.eo;
    }
    set resolution(v) {
        this.i.eo = +v;
    }
    /**
     * Gets or sets the Title property.
     * The legend item control is created according to the Title on-demand by
     * the series object itself.
    */
    get title() {
        return this.i.fo;
    }
    set title(v) {
        this.i.fo = v;
    }
    /**
     * Gets or sets the brush to use for the series.
    */
    get brush() {
        return brushToString(this.i.kt);
    }
    set brush(v) {
        this.i.kt = stringToBrush(v);
    }
    /**
     * Gets the effective brush for the current series object.
    */
    get actualBrush() {
        return brushToString(this.i.kr);
    }
    /**
     * Gets or sets the brush to use for the outline of the series.
     * Some series types, such as LineSeries, do not display outlines.  Therefore, this property does not affect some charts.
    */
    get outline() {
        return brushToString(this.i.kw);
    }
    set outline(v) {
        this.i.kw = stringToBrush(v);
    }
    /**
     * Gets the effective outline for the current series object.
    */
    get actualOutline() {
        return brushToString(this.i.ks);
    }
    /**
     * Gets or sets the width of the current series object's line thickness.
    */
    get thickness() {
        return this.i.es;
    }
    set thickness(v) {
        this.i.es = +v;
    }
    /**
     * Gets or sets whether highlighting should be enabled for this series, if this type of series supports highlighting.
    */
    get isHighlightingEnabled() {
        return this.i.ct;
    }
    set isHighlightingEnabled(v) {
        this.i.ct = ensureBool(v);
    }
    /**
     * Gets or sets whether drop shadow should be enabled for this series.
    */
    get isDropShadowEnabled() {
        return this.i.co;
    }
    set isDropShadowEnabled(v) {
        this.i.co = ensureBool(v);
    }
    /**
     * Gets or sets the shadow blur.
     * This property is ignored when Series.UseSingleShadow is set to true.
    */
    get shadowBlur() {
        return this.i.ep;
    }
    set shadowBlur(v) {
        this.i.ep = +v;
    }
    /**
     * Gets or sets the drop shadow color.
    */
    get shadowColor() {
        return colorToString(this.i.ky);
    }
    set shadowColor(v) {
        this.i.ky = stringToColor(v);
    }
    /**
     * Gets or sets whether drop shadow is applied to the whole series visual or to each of the individual shapes forming the series.
     * When this property is set to true, no Series.ShadowBlur is applied.
    */
    get useSingleShadow() {
        return this.i.dr;
    }
    set useSingleShadow(v) {
        this.i.dr = ensureBool(v);
    }
    /**
     * Gets or sets the drop shadow x-offset.
    */
    get shadowOffsetX() {
        return this.i.eq;
    }
    set shadowOffsetX(v) {
        this.i.eq = +v;
    }
    /**
     * Gets or sets the drop shadow y-offset.
    */
    get shadowOffsetY() {
        return this.i.er;
    }
    set shadowOffsetY(v) {
        this.i.er = +v;
    }
    /**
     * Gets or sets the opacity applied to the area fill visual.
     * This property only applies to series that have area visual.
    */
    get areaFillOpacity() {
        return this.i.d2;
    }
    set areaFillOpacity(v) {
        this.i.d2 = +v;
    }
    /**
     * Gets the actual opacity applied to the area fill visual.
    */
    get actualAreaFillOpacity() {
        return this.i.d1;
    }
    /**
     * Gets if the default tooltip has been selected for display.
    */
    get isDefaultToolTipSelected() {
        return this.i.cn;
    }
    set isDefaultToolTipSelected(v) {
        this.i.cn = ensureBool(v);
    }
    /**
     * Gets or sets whether default tooltip will be shown.
    */
    get showDefaultTooltip() {
        return this.i.da;
    }
    set showDefaultTooltip(v) {
        this.i.da = ensureBool(v);
    }
    /**
     * Gets or sets the duration of the current series's transition in morph.
    */
    get transitionInDuration() {
        return this.i.fd;
    }
    set transitionInDuration(v) {
        this.i.fd = +v;
    }
    /**
     * Gets or sets the duration of the current series's transition in morph.
    */
    get transitionInSpeedType() {
        return this.i.bp;
    }
    set transitionInSpeedType(v) {
        this.i.bp = ensureEnum(TransitionInSpeedType_$type, v);
    }
    /**
     * Gets or sets the whether the chart reacts to mouse move events.
    */
    get mouseOverEnabled() {
        return this.i.c4;
    }
    set mouseOverEnabled(v) {
        this.i.c4 = ensureBool(v);
    }
    /**
     * Gets or gets the coercion methods to use when loading data from data sources.
     * Should be specified before setting any member paths, if being used. Setting it later
     * will not cause data to be reimported into the chart.
    */
    get coercionMethods() {
        return this.i.coercionMethods;
    }
    set coercionMethods(v) {
        this.i.coercionMethods = v;
    }
    /**
     * Gets or sets whether the series should expect that properties in its items source may be functions that need to be
     * evaluated to yield their value. This defaults to false, as there will be a subtle performance impact to using this feature.
     * This value must be set before assigning an item's source to take effect.
    */
    get expectFunctions() {
        return this.i.expectFunctions;
    }
    set expectFunctions(v) {
        this.i.expectFunctions = ensureBool(v);
    }
    /**
     * Method of hit testing to use when pointing to items in this series.
    */
    get hitTestMode() {
        return this.i.be;
    }
    set hitTestMode(v) {
        this.i.be = ensureEnum(SeriesHitTestMode_$type, v);
    }
    /**
     * Resolved method of hit testing to use when pointing to items in the chart.
    */
    get actualHitTestMode() {
        return this.i.bc;
    }
    get isNegativeColorSupported() {
        return this.i.cy;
    }
    get isMarkerlessDisplayPreferred() {
        return this.i.cx;
    }
    get finalValue() {
        return this.i.d3;
    }
    get percentChange() {
        return this.i.en;
    }
    resolveTooltipBrush() {
        let iv = this.i.gl();
        return (iv);
    }
    /**
     * Gets the precise item index, if possible, based on the closeness to the previous or next whole integer. If the series cannot provide this information, GetExactItemIndex will return the same integer value as GetItemIndex.
    
    * @param world  * The world position for which to return the index.
    */
    getExactItemIndex(world) {
        let iv = this.i.d6(toPoint(world));
        return (iv);
    }
    /**
     * Gets the item item index associated with the specified world position
    
    */
    getItemIndex(world) {
        let iv = this.i.e2(toPoint(world));
        return (iv);
    }
    /**
     * Gets the item that is the best match for the specified world coordinates.
    
    * @param world  * The world coordinates to use.
    */
    getItem(world) {
        let iv = this.i.fj(toPoint(world));
        return (iv);
    }
    getPreviousOrExactIndex(world, skipUnknowns) {
        let iv = this.i.e8(toPoint(world), skipUnknowns);
        return (iv);
    }
    getNextOrExactIndex(world, skipUnknowns) {
        let iv = this.i.e6(toPoint(world), skipUnknowns);
        return (iv);
    }
    getSeriesValue(world, useInterpolation, skipUnknowns) {
        let iv = this.i.eh(toPoint(world), useInterpolation, skipUnknowns);
        return (iv);
    }
    getSeriesValuePosition(world, useInterpolation, skipUnknowns) {
        let iv = this.i.k9(toPoint(world), useInterpolation, skipUnknowns);
        return fromPoint(iv);
    }
    /**
     * If possible, will return the best available value bounding box within the series that has the best value match for the world position provided.
    
    * @param world  * The world coordinate for which to get a value bounding box for
    */
    getSeriesValueBoundingBox(world) {
        let iv = this.i.li(toPoint(world));
        return fromRect(iv);
    }
    /**
     * If possible, will return the best available value marker bounding box within the series that has the best value match for the world position provided.
    
    * @param world  * The world coordinates for which to get a value marker bounding box for
    */
    getSeriesValueMarkerBoundingBox(world) {
        let iv = this.i.lk(toPoint(world));
        return fromRect(iv);
    }
    getSeriesHighValue(world, useInterpolation, skipUnknowns) {
        let iv = this.i.ed(toPoint(world), useInterpolation, skipUnknowns);
        return (iv);
    }
    getSeriesHighValuePosition(world, useInterpolation, skipUnknowns) {
        let iv = this.i.k5(toPoint(world), useInterpolation, skipUnknowns);
        return fromPoint(iv);
    }
    getSeriesLowValue(world, useInterpolation, skipUnknowns) {
        let iv = this.i.ef(toPoint(world), useInterpolation, skipUnknowns);
        return (iv);
    }
    getSeriesLowValuePosition(world, useInterpolation, skipUnknowns) {
        let iv = this.i.k7(toPoint(world), useInterpolation, skipUnknowns);
        return fromPoint(iv);
    }
    getSeriesValuePositionFromSeriesPixel(mouse, useInterpolation, skipUnknowns) {
        let iv = this.i.la(toPoint(mouse), useInterpolation, skipUnknowns);
        return fromPoint(iv);
    }
    getSeriesValueFromSeriesPixel(mouse, useInterpolation, skipUnknowns) {
        let iv = this.i.ei(toPoint(mouse), useInterpolation, skipUnknowns);
        return (iv);
    }
    /**
     * For a category plotted series, returns the current width of the items within the categories. This only returns a value if the items have some form of width (e.g. columns, bars, etc.) otherwise 0 is returned.
    
    */
    getItemSpan() {
        let iv = this.i.eb();
        return (iv);
    }
    /**
     * Converts a point from coordinates within the series plot area to a world position within axis space.
    
    * @param seriesPoint  * The pixel location within the plot area of the series.
    */
    toWorldPosition(seriesPoint) {
        let iv = this.i.lc(toPoint(seriesPoint));
        return fromPoint(iv);
    }
    /**
     * Converts a point from world coordinates to coordinates within the viewport of the series.
    
    * @param world  * The world position from which to convert.
    */
    fromWorldPosition(world) {
        let iv = this.i.k4(toPoint(world));
        return fromPoint(iv);
    }
    /**
     * Requests that the provided item should be brought into view if possible.
    
    * @param item  * The item to attempt to bring into view.
    */
    scrollIntoView(item) {
        let iv = this.i.c6(item);
        return (iv);
    }
    /**
     * Renders the series.
    
    * @param animate  * True if the change should be animated.
    */
    renderSeries(animate) {
        this.i.i1(animate);
    }
    /**
     * Gets the effective viewport, adjusted to account for margins and other factors.
    
    */
    getEffectiveViewport() {
        let iv = this.i.getEffectiveViewport();
        return fromRect(iv);
    }
    removeAllAlternateViews() {
        this.i.iw();
    }
    removeAlternateView(viewIdentifier) {
        this.i.iy(viewIdentifier);
    }
    /**
     * Replays the assigned transition in animation, if any.
    
    */
    replayTransitionIn() {
        this.i.i4();
    }
    /**
     * Simulates a pointer hover over the series surface.
    
    * @param point  * The pointer position relative to the series viewport over which to hover.
    */
    simulateHover(point) {
        this.i.i8(toPoint(point));
    }
    styleUpdated() {
        this.i.ja();
    }
    setNegativeColors(negativeBrush, negativeOutline) {
        this.i.i6(stringToBrush(negativeBrush), stringToBrush(negativeOutline));
    }
    /**
     * Moves the cursor point to the provided world position. Some series may react to the current cursor position.
    
    * @param point  * The cursor point, in world coordinates.
    */
    moveCursorPoint(point) {
        this.i.h1(toPoint(point));
    }
    /**
     * This event is raised every time a render has been requested from a series.
    */
    get renderRequested() {
        return this._renderRequested;
    }
    set renderRequested(ev) {
        if (this._renderRequested !== null) {
            this.i.renderRequested = delegateRemove(this.i.renderRequested, this._renderRequested_wrapped);
            this._renderRequested_wrapped = null;
            this._renderRequested = null;
        }
        this._renderRequested = ev;
        this._renderRequested_wrapped = (o, e) => {
            let outerArgs = new RenderRequestedEventArgs();
            outerArgs._provideImplementation(e);
            this._renderRequested(this, outerArgs);
        };
        this.i.renderRequested = delegateCombine(this.i.renderRequested, this._renderRequested_wrapped);
    }
}
