export function noteDeferredFormulaInstance(records, prepared, formula) {
    if (!records || !formula) {
        return;
    }
    records.push({
        cellIndex: prepared.cellIndex,
        sheetName: prepared.ownerSheetName,
        row: prepared.row,
        col: prepared.col,
        source: formula.source,
        ...(formula.templateId !== undefined ? { templateId: formula.templateId } : {}),
    });
}
export function writeDeferredFormulaInstance(records, index, prepared, formula) {
    if (!records || !formula) {
        return index;
    }
    records[index] = {
        cellIndex: prepared.cellIndex,
        sheetName: prepared.ownerSheetName,
        row: prepared.row,
        col: prepared.col,
        source: formula.source,
        ...(formula.templateId !== undefined ? { templateId: formula.templateId } : {}),
    };
    return index + 1;
}
export function materializeDeferredFormulaInstances(records, count) {
    return count === records.length ? records : records.slice(0, count);
}
export function readAlignedFreshFormulaInstancesFromRefs(refs) {
    if (!hasFreshFormulaInstances(refs)) {
        return undefined;
    }
    const records = refs.freshFormulaInstances;
    return records !== undefined && records.length === refs.length ? records : undefined;
}
function hasFreshFormulaInstances(value) {
    return typeof value === 'object' && value !== null && 'freshFormulaInstances' in value;
}
//# sourceMappingURL=formula-initialization-fresh-instances.js.map