"use strict";

Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.FormulaThrottle = void 0;

class FormulaThrottle {
    constructor() {
        this.recalcTimer = null, this.pendingRecalc = !1, this.throttleDelay = 150;
    }
    static getInstance() {
        return FormulaThrottle.instance || (FormulaThrottle.instance = new FormulaThrottle), 
        FormulaThrottle.instance;
    }
    throttledRebuildAndRecalculate(formulaManager) {
        if (formulaManager) if (null === this.recalcTimer) {
            if (!this.pendingRecalc) try {
                formulaManager.rebuildAndRecalculate();
            } catch (e) {}
            this.pendingRecalc = !1, this.recalcTimer = window.setTimeout((() => {
                if (this.recalcTimer = null, this.pendingRecalc) try {
                    formulaManager.rebuildAndRecalculate(), this.pendingRecalc = !1;
                } catch (e) {}
            }), this.throttleDelay);
        } else this.pendingRecalc = !0;
    }
    immediateRebuildAndRecalculate(formulaManager) {
        if (formulaManager) {
            null !== this.recalcTimer && (window.clearTimeout(this.recalcTimer), this.recalcTimer = null), 
            this.pendingRecalc = !1;
            try {
                formulaManager.rebuildAndRecalculate();
            } catch (e) {}
        }
    }
}

exports.FormulaThrottle = FormulaThrottle;
//# sourceMappingURL=formula-throttle.js.map