import { addEngineCounter } from '../../perf/engine-counters.js';
export function scanFormulaInitializationCycleMembers(state) {
    addEngineCounter(state.counters, 'cycleFormulaScans');
    let found = false;
    state.formulas.forEach((_formula, cellIndex) => {
        if (((state.workbook.cellStore.flags[cellIndex] ?? 0) & 8 /* CellFlags.InCycle */) !== 0) {
            found = true;
        }
    });
    return found;
}
export function createFormulaInitializationSheetNameResolver(state) {
    const sheetNameById = new Map();
    return (sheetId) => {
        const sheet = state.workbook.getSheetById(sheetId);
        if (!sheet) {
            throw new Error(`Unknown sheet id: ${sheetId}`);
        }
        const cached = sheetNameById.get(sheetId);
        if (cached === sheet.name) {
            return cached;
        }
        sheetNameById.set(sheetId, sheet.name);
        return sheet.name;
    };
}
//# sourceMappingURL=formula-initialization-service-helpers.js.map