import { FUniver as s, debounce as u, LifecycleService as m, ILogService as h, IConfigService as F, LifecycleStages as S } from "@univerjs/core"; import { SetFormulaCalculationStartMutation as d } from "@univerjs/engine-formula"; import { IRegisterFunctionService as i, RegisterFunctionService as l, PLUGIN_CONFIG_KEY_BASE as _ } from "@univerjs/sheets-formula"; import { FFormula as f } from "@univerjs/engine-formula/facade"; class C extends s { /** * Initialize the FUniver instance. * @private */ _initialize() { this._debouncedFormulaCalculation = u(() => { this._commandService.executeCommand( d.id, { commands: [], forceCalculation: !0 }, { onlyLocal: !0 } ); }, 10); } registerFunction(n) { let c = this._injector.get(i); c || (this._injector.add([i, { useClass: l }]), c = this._injector.get(i)); const e = c.registerFunctions(n); return this._debouncedFormulaCalculation(), e; } } s.extend(C); class v extends f { /** * Initialize the FUniver instance. * @private */ _initialize() { this._debouncedFormulaCalculation = u(() => { this._commandService.executeCommand( d.id, { commands: [], forceCalculation: !0 }, { onlyLocal: !0 } ); }, 10); } setInitialFormulaComputing(n) { const e = this._injector.get(m).stage, t = this._injector.get(h), o = this._injector.get(F); e > S.Starting && t.warn("[FFormula]", "CalculationMode is called after the Starting lifecycle and will take effect the next time the Univer Sheet is constructed. If you want it to take effect when the Univer Sheet is initialized this time, consider calling it before the Ready lifecycle or using configuration."); const r = o.getConfig(_); r && (r.initialFormulaComputing = n); } registerFunction(n, c, e) { var a; let t = this._injector.get(i); t || (this._injector.add([i, { useClass: l }]), t = this._injector.get(i)); const o = { name: n, func: c, description: typeof e == "string" ? e : (a = e == null ? void 0 : e.description) != null ? a : "", locales: typeof e == "object" ? e.locales : void 0 }, r = t.registerFunction(o); return this._debouncedFormulaCalculation(), r; } registerAsyncFunction(n, c, e) { var a; let t = this._injector.get(i); t || (this._injector.add([i, { useClass: l }]), t = this._injector.get(i)); const o = { name: n, func: c, description: typeof e == "string" ? e : (a = e == null ? void 0 : e.description) != null ? a : "", locales: typeof e == "object" ? e.locales : void 0 }, r = t.registerAsyncFunction(o); return this._debouncedFormulaCalculation(), r; } } f.extend(v);