import { delegateCombine, delegateRemove } from "igniteui-react-core";
import { DataSourceSummaryOperand_$type } from "igniteui-react-core";
import { IgrProvideCalculatorEventArgs } from "igniteui-react-core";
import { ChartSummaryDescription as ChartSummaryDescription_internal } from "./ChartSummaryDescription";
import { ensureEnum } from "igniteui-react-core";
/**
 * Represents a summary that is applied to a datasource. Changes to this object are not observed or expected after it is initially assigned to a collection.
*/
export class IgrChartSummaryDescription {
    createImplementation() {
        return new ChartSummaryDescription_internal(0);
    }
    /**
     * @hidden
     */
    get i() {
        return this._implementation;
    }
    onImplementationCreated() {
    }
    constructor() {
        this.mounted = false;
        this._provideCalculator = null;
        this._provideCalculator_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();
        }
    }
    get field() {
        return this.i.p;
    }
    set field(v) {
        this.i.p = v;
    }
    get operand() {
        return this.i.c;
    }
    set operand(v) {
        this.i.c = ensureEnum(DataSourceSummaryOperand_$type, v);
    }
    /**
     * Gets or sets an alias for the summary. Currently only used in aggregated data situations.
    */
    get alias() {
        return this.i.n;
    }
    set alias(v) {
        this.i.n = v;
    }
    /**
     * Gets or sets the name to use when displaying the calculator name.
    */
    get calculatorDisplayName() {
        return this.i.o;
    }
    set calculatorDisplayName(v) {
        this.i.o = v;
    }
    findByName(name) {
        if (this.findEphemera) {
            if (name && name.indexOf("@@e:") == 0) {
                return this.findEphemera(name);
            }
        }
        return null;
    }
    equals(other) {
        let iv = this.i.equals(other);
        return (iv);
    }
    /**
     * Called when the summary calculator is required.
    */
    get provideCalculator() {
        return this._provideCalculator;
    }
    set provideCalculator(ev) {
        if (this._provideCalculator_wrapped !== null) {
            this.i.provideCalculator = delegateRemove(this.i.provideCalculator, this._provideCalculator_wrapped);
            this._provideCalculator_wrapped = null;
            this._provideCalculator = null;
        }
        this._provideCalculator = ev;
        this._provideCalculator_wrapped = (o, e) => {
            let outerArgs = new IgrProvideCalculatorEventArgs();
            outerArgs._provideImplementation(e);
            if (this.beforeProvideCalculator) {
                this.beforeProvideCalculator(this, outerArgs);
            }
            if (this._provideCalculator) {
                this._provideCalculator(this, outerArgs);
            }
        };
        this.i.provideCalculator = delegateCombine(this.i.provideCalculator, this._provideCalculator_wrapped);
        ;
    }
}
