import * as React from 'react';
import { delegateCombine, delegateRemove } from "igniteui-react-core/ES2015/type";
import { PropertyUpdatedEventArgs } from "igniteui-react-core/ES2015/igr-property-updated-event-args";
import { BrushScale } from "./BrushScale";
import { getModifiedProps, isValidProp, toBrushCollection, fromBrushCollection, brushToString } from "igniteui-react-core/ES2015/componentUtil";
/**
 * Represents a base class for brush scales.
*/
export class IgrBrushScale extends React.Component {
    constructor(props) {
        super(props);
        this._hasUserValues = new Set();
        this._propertyUpdated = null;
        this._propertyUpdated_wrapped = null;
        this._implementation = this.createImplementation();
        this._implementation.externalObject = this;
        this.onImplementationCreated();
    }
    createImplementation() {
        return new BrushScale();
    }
    get i() {
        return this._implementation;
    }
    onImplementationCreated() {
    }
    get hasUserValues() {
        return this._hasUserValues;
    }
    componentDidMount() {
        for (const p of Object.keys(this.props)) {
            if (isValidProp(this, p)) {
                this._hasUserValues.add(p);
                this[p] = this.props[p];
            }
        }
    }
    shouldComponentUpdate(nextProps, nextState) {
        const mod = getModifiedProps(this.props, nextProps);
        for (const p of Object.keys(mod)) {
            if (isValidProp(this, p)) {
                this._hasUserValues.add(p);
                this[p] = mod[p];
            }
        }
        return true;
    }
    render() {
        return null;
    }
    /**
     * Gets the brushes collection used by this scale.
    */
    get brushes() {
        return fromBrushCollection(this.i.brushes);
    }
    set brushes(v) {
        this.i.brushes = toBrushCollection(v);
    }
    /**
     * Gets the status of the scale
    */
    get isReady() {
        return this.i.isReady;
    }
    /**
     * Checks if this item is a BrushScale
    */
    get isBrushScale() {
        return this.i.isBrushScale;
    }
    /**
     * Registers a series with the scale. Under normal circumstances you should not need to call this manually.
    
    * @param series  * The series to register with the scale.
    */
    registerSeries(series) {
        this.i.registerSeries((series == null ? null : series.i));
    }
    /**
     * Unregisters a series with the scale. Under normal circumstances you should not need to call this manually.
    
    * @param series  * The series to unregister from the scale.
    */
    unregisterSeries(series) {
        this.i.unregisterSeries((series == null ? null : series.i));
    }
    /**
     * Gets a brush from the brushes collection by index.
    
    */
    getBrush(index) {
        let iv = this.i.getBrush(index);
        return brushToString(iv);
    }
    /**
     * Event raised when a property (including "effective" and non-dependency property) value changes.
    */
    get propertyUpdated() {
        return this._propertyUpdated;
    }
    set propertyUpdated(ev) {
        if (this._propertyUpdated_wrapped !== null) {
            this.i.propertyUpdated = delegateRemove(this.i.propertyUpdated, this._propertyUpdated_wrapped);
            this._propertyUpdated_wrapped = null;
            this._propertyUpdated = null;
        }
        this._propertyUpdated = ev;
        this._propertyUpdated_wrapped = (o, e) => {
            let outerArgs = new PropertyUpdatedEventArgs();
            outerArgs._provideImplementation(e);
            if (this.beforePropertyUpdated) {
                this.beforePropertyUpdated(this, outerArgs);
            }
            if (this._propertyUpdated) {
                this._propertyUpdated(this, outerArgs);
            }
        };
        this.i.propertyUpdated = delegateCombine(this.i.propertyUpdated, this._propertyUpdated_wrapped);
    }
}
