import { delegateCombine, delegateRemove } from "igniteui-react-core";
import { IgrPropertyUpdatedEventArgs } from "igniteui-react-core";
import { IgrSeriesLayerPropertyOverlayValueResolvingEventArgs } from "./igr-series-layer-property-overlay-value-resolving-event-args";
import { SeriesLayerPropertyOverlay as SeriesLayerPropertyOverlay_internal } from "./SeriesLayerPropertyOverlay";
import { ensureBool } from "igniteui-react-core";
/**
 * Represents an axis annotation
*/
export class IgrSeriesLayerPropertyOverlay {
    createImplementation() {
        return new SeriesLayerPropertyOverlay_internal();
    }
    /**
     * @hidden
     */
    get i() {
        return this._implementation;
    }
    onImplementationCreated() {
    }
    constructor() {
        this.mounted = false;
        this._propertyUpdated = null;
        this._propertyUpdated_wrapped = null;
        this._valueResolving = null;
        this._valueResolving_wrapped = null;
        this._implementation = this.createImplementation();
        this._implementation.externalObject = this;
        this.onImplementationCreated();
        if (this._initializeAdapters) {
            this._initializeAdapters();
        }
    }
    _provideImplementation(i) {
        this._implementation = i;
        this._implementation.externalObject = this;
        this.onImplementationCreated();
        if (this._initializeAdapters) {
            this._initializeAdapters();
        }
    }
    /**
     * Gets or sets whether this property overlay targets the source series instead of the current layer while the layer is present.
    */
    get isSourceOverlay() {
        return this.i.r;
    }
    set isSourceOverlay(v) {
        this.i.r = ensureBool(v);
    }
    /**
     * Gets or sets whether this property overlay should be applied to the source or target even if the source property wasn't mutated.
    */
    get isAlwaysApplied() {
        return this.i.p;
    }
    set isAlwaysApplied(v) {
        this.i.p = ensureBool(v);
    }
    get internalPropertyName() {
        return this.i.aa;
    }
    /**
     * Gets or sets the property to overlay on the series or series layer.
    */
    get propertyName() {
        return this.i.ad;
    }
    set propertyName(v) {
        this.i.ad = v;
    }
    /**
     * Gets or sets the property from which to get the current value, if different from property name.
    */
    get currentValuePropertyName() {
        return this.i.y;
    }
    set currentValuePropertyName(v) {
        this.i.y = v;
    }
    /**
     * Gets or sets the value to overlay on the series or series layer.
    */
    get value() {
        return this.i.x;
    }
    set value(v) {
        this.i.x = v;
    }
    findByName(name) {
        if (this.findEphemera) {
            if (name && name.indexOf("@@e:") == 0) {
                return this.findEphemera(name);
            }
        }
        return null;
    }
    /**
     * Event raised when a property value is changed.
    */
    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 IgrPropertyUpdatedEventArgs();
            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);
        ;
    }
    get valueResolving() {
        return this._valueResolving;
    }
    set valueResolving(ev) {
        if (this._valueResolving_wrapped !== null) {
            this.i.valueResolving = delegateRemove(this.i.valueResolving, this._valueResolving_wrapped);
            this._valueResolving_wrapped = null;
            this._valueResolving = null;
        }
        this._valueResolving = ev;
        this._valueResolving_wrapped = (o, e) => {
            let outerArgs = new IgrSeriesLayerPropertyOverlayValueResolvingEventArgs();
            outerArgs._provideImplementation(e);
            if (this.beforeValueResolving) {
                this.beforeValueResolving(this, outerArgs);
            }
            if (this._valueResolving) {
                this._valueResolving(this, outerArgs);
            }
        };
        this.i.valueResolving = delegateCombine(this.i.valueResolving, this._valueResolving_wrapped);
        ;
    }
}
