{"version":3,"file":"layout.js","names":[],"sources":["jsx/layout/layout.js"],"sourcesContent":["import { nodeKindSpec, resolvePorts } from \"../model/index\";\nimport { FINE_PORT_PITCH, graphNodeMeasure, portSpacing } from \"../nodes/nodeMeasure\";\nimport { getLayoutRunner } from \"./runner\";\nfunction buildLayoutRequest(document, schema, options = {}) {\n  const { size = \"medium\", coarsePointer = false, measured } = options;\n  const portSpacingPx = coarsePointer ? portSpacing({ coarsePointer }) : FINE_PORT_PITCH;\n  return {\n    nodes: document.nodes.map((node) => {\n      const measure = graphNodeMeasure({\n        size,\n        ports: resolvePorts(schema, node),\n        portSpacingPx,\n        measure: nodeKindSpec(schema, node.kind)?.measure\n      });\n      const painted = measured?.[node.id];\n      return {\n        id: node.id,\n        width: node.size?.width ?? painted?.width ?? measure.width,\n        height: node.size?.height ?? painted?.height ?? measure.minHeight,\n        position: node.position\n      };\n    }),\n    edges: document.edges.map((edge) => ({\n      id: edge.id,\n      source: edge.source.node,\n      target: edge.target.node\n    })),\n    options: {\n      direction: options.direction,\n      nodeSpacing: options.nodeSpacing,\n      rankSpacing: options.rankSpacing,\n      edgeSpacing: options.edgeSpacing,\n      subset: options.subset\n    }\n  };\n}\nfunction reconcilePositions(result, touched) {\n  if (touched.size === 0) return result.positions;\n  const positions = {};\n  for (const [id, point] of Object.entries(result.positions)) {\n    if (touched.has(id)) continue;\n    positions[id] = point;\n  }\n  return positions;\n}\nasync function layout(document, schema, options = {}) {\n  const runner = await getLayoutRunner(options.runner);\n  return runner.run(buildLayoutRequest(document, schema, options));\n}\nexport {\n  buildLayoutRequest,\n  layout,\n  reconcilePositions\n};\n//# sourceMappingURL=layout.js.map\n"],"mappings":";;;;;AAGA,SAAS,mBAAmB,UAAU,QAAQ,UAAU,CAAC,GAAG;CAC1D,MAAM,EAAE,OAAO,UAAU,gBAAgB,OAAO,aAAa;CAC7D,MAAM,gBAAgB,gBAAgB,YAAY,EAAE,cAAc,CAAC,IAAI;CACvE,OAAO;EACL,OAAO,S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