{
  "version": 3,
  "sources": ["../../../src/core/engine-snapshot.ts"],
  "sourcesContent": [
    "import type { ContextDependency } from \"../evaluator/evaluation-context.cjs\";\nimport type { DependencyNode } from \"./managers/dependency-node.cjs\";\nimport type {\n  CellAddress,\n  CellInRangeResult,\n  CellValue,\n  ConditionalStyle,\n  DirectCellStyle,\n  FormulaError,\n  NamedExpression,\n  RangeAddress,\n  RelativeRange,\n  SpreadsheetRange,\n  TableDefinition,\n  TrackedReference,\n  Workbook,\n} from \"./types.cjs\";\n\nexport const ENGINE_SNAPSHOT_VERSION = 4 as const;\n\nexport type NodeSnapshotId = string;\n\nexport type NamedExpressionManagerSnapshot = {\n  sheetExpressions: Map<string, Map<string, Map<string, NamedExpression>>>;\n  workbookExpressions: Map<string, Map<string, NamedExpression>>;\n  globalExpressions: Map<string, NamedExpression>;\n};\n\nexport type WorkbookManagerSnapshot = Map<string, Workbook>;\n\nexport type TableManagerSnapshot = Map<string, Map<string, TableDefinition>>;\n\nexport type StyleManagerSnapshot = {\n  conditionalStyles: ConditionalStyle[];\n  cellStyles: DirectCellStyle[];\n};\n\nexport type ReferenceManagerSnapshot = Map<string, TrackedReference>;\n\nexport type SerializedValueEvaluationResultSnapshot = {\n  type: \"value\";\n  result: CellValue;\n  sourceCell?: CellAddress;\n};\n\nexport type SerializedErrorEvaluationResultSnapshot = {\n  type: \"error\";\n  err: FormulaError;\n  message: string;\n  errAddressId: NodeSnapshotId;\n  sourceCell?: CellAddress;\n};\n\nexport type SerializedSingleEvaluationResultSnapshot =\n  | SerializedValueEvaluationResultSnapshot\n  | SerializedErrorEvaluationResultSnapshot;\n\nexport type SerializedCellInRangeResultSnapshot = {\n  relativePos: CellInRangeResult[\"relativePos\"];\n  result: SerializedSingleEvaluationResultSnapshot;\n};\n\nexport type SerializedEvaluateAllCellsResultSnapshot =\n  | SerializedErrorEvaluationResultSnapshot\n  | {\n      type: \"values\";\n      values: SerializedCellInRangeResultSnapshot[];\n    };\n\nexport type SerializedMaterializedSpillSnapshot = {\n  kind: \"materialized\";\n  relativeSpillArea: RelativeRange;\n  source: string;\n  sourceCell?: CellAddress;\n  sourceRange?: RangeAddress;\n  values: SerializedCellInRangeResultSnapshot[];\n};\n\nexport type SerializedSourceRangeSpillSnapshot = {\n  kind: \"source-range\";\n  relativeSpillArea: RelativeRange;\n  source: string;\n  sourceCell?: CellAddress;\n  sourceRange: RangeAddress;\n};\n\nexport type SerializedSpillResultSnapshot =\n  | SerializedMaterializedSpillSnapshot\n  | SerializedSourceRangeSpillSnapshot;\n\nexport type SerializedSpilledValuesEvaluationResultSnapshot = {\n  type: \"spilled-values\";\n  spill: SerializedSpillResultSnapshot;\n};\n\nexport type SerializedFunctionEvaluationResultSnapshot =\n  | SerializedSingleEvaluationResultSnapshot\n  | SerializedSpilledValuesEvaluationResultSnapshot;\n\nexport type SerializedSpillMetaEvaluationResultSnapshot =\n  | SerializedErrorEvaluationResultSnapshot\n  | SerializedSpilledValuesEvaluationResultSnapshot\n  | {\n      type: \"does-not-spill\";\n    };\n\ntype SerializedBaseNodeSnapshot = {\n  snapshotId: NodeSnapshotId;\n  key: string;\n  dependencies: NodeSnapshotId[];\n};\n\nexport type SerializedCellValueNodeSnapshot = SerializedBaseNodeSnapshot & {\n  kind: \"cell-value\";\n  evaluationResult: SerializedSingleEvaluationResultSnapshot;\n  spillMetaSnapshotId?: NodeSnapshotId;\n};\n\nexport type SerializedSpillMetaNodeSnapshot = SerializedBaseNodeSnapshot & {\n  kind: \"spill-meta\";\n  evaluationResult: SerializedSpillMetaEvaluationResultSnapshot;\n};\n\nexport type SerializedEmptyCellNodeSnapshot = SerializedBaseNodeSnapshot & {\n  kind: \"empty\";\n  evaluationResult: SerializedSingleEvaluationResultSnapshot;\n};\n\nexport type SerializedRangeNodeSnapshot = SerializedBaseNodeSnapshot & {\n  kind: \"range\";\n  result: SerializedEvaluateAllCellsResultSnapshot;\n};\n\nexport type SerializedAstNodeSnapshot = SerializedBaseNodeSnapshot & {\n  kind: \"ast\";\n  contextDependency: ContextDependency;\n  evaluationResult: SerializedFunctionEvaluationResultSnapshot;\n};\n\nexport type SerializedResourceNodeSnapshot = SerializedBaseNodeSnapshot & {\n  kind: \"resource\";\n};\n\nexport type SerializedDependencyNodeSnapshot =\n  | SerializedCellValueNodeSnapshot\n  | SerializedSpillMetaNodeSnapshot\n  | SerializedEmptyCellNodeSnapshot\n  | SerializedRangeNodeSnapshot\n  | SerializedAstNodeSnapshot\n  | SerializedResourceNodeSnapshot;\n\nexport type DependencyManagerSnapshot = {\n  nodes: SerializedDependencyNodeSnapshot[];\n  spilledValues: Array<[string, { origin: CellAddress; spillOnto: SpreadsheetRange }]>;\n};\n\nexport type SerializedSCCSnapshot = {\n  id: number;\n  nodes: NodeSnapshotId[];\n  evaluationOrder: NodeSnapshotId[];\n  resolved: boolean;\n  hardEdgeSCCs: NodeSnapshotId[][];\n};\n\nexport type SerializedEvaluationOrderSnapshot = {\n  nodeKey: string;\n  evaluationOrder: NodeSnapshotId[];\n  hasCycle: boolean;\n  cycleNodes?: NodeSnapshotId[];\n  hash: string;\n};\n\nexport type CacheManagerSnapshot = {\n  evaluationOrders: SerializedEvaluationOrderSnapshot[];\n  sccs: Array<{\n    hash: string;\n    scc: SerializedSCCSnapshot;\n  }>;\n};\n\ntype EngineSnapshotManagers = {\n  workbook: WorkbookManagerSnapshot;\n  namedExpression: NamedExpressionManagerSnapshot;\n  table: TableManagerSnapshot;\n  style: StyleManagerSnapshot;\n  reference: ReferenceManagerSnapshot;\n  dependency: DependencyManagerSnapshot;\n  cache: CacheManagerSnapshot;\n};\n\nexport type EngineSnapshot = {\n  version: typeof ENGINE_SNAPSHOT_VERSION;\n  managers: EngineSnapshotManagers;\n};\n\nexport function getAstNodeSnapshotId(\n  node: DependencyNode & { getContextDependency(): ContextDependency }\n): NodeSnapshotId {\n  return `${node.key}::${JSON.stringify(node.getContextDependency())}`;\n}\n"
  ],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,IAAM,0BAA0B;AAiLhC,SAAS,oBAAoB,CAClC,MACgB;AAAA,EAChB,OAAO,GAAG,KAAK,QAAQ,KAAK,UAAU,KAAK,qBAAqB,CAAC;AAAA;",
  "debugId": "B0DBBBA2B6EB8C4A64756E2164756E21",
  "names": []
}