{"version":3,"file":"SnapGuides.js","names":[],"sources":["esm/react-flow/SnapGuides.js"],"sourcesContent":["import { ViewportPortal } from \"./xy\";\nimport { jsx } from \"react/jsx-runtime\";\nconst snapGuidesClassName = \"mp-graph-guides\";\nconst snapGuideClassName = \"mp-graph-guide\";\nconst snapGuidePadding = 2;\nfunction snapGuidesBounds(guides) {\n  if (guides.length === 0) return null;\n  let minX = Number.POSITIVE_INFINITY;\n  let minY = Number.POSITIVE_INFINITY;\n  let maxX = Number.NEGATIVE_INFINITY;\n  let maxY = Number.NEGATIVE_INFINITY;\n  for (const guide of guides) {\n    const [x1, y1, x2, y2] = guide.axis === \"x\" ? [guide.position, guide.start, guide.position, guide.end] : [guide.start, guide.position, guide.end, guide.position];\n    minX = Math.min(minX, x1, x2);\n    maxX = Math.max(maxX, x1, x2);\n    minY = Math.min(minY, y1, y2);\n    maxY = Math.max(maxY, y1, y2);\n  }\n  return {\n    x: minX - snapGuidePadding,\n    y: minY - snapGuidePadding,\n    width: maxX - minX + snapGuidePadding * 2,\n    height: maxY - minY + snapGuidePadding * 2\n  };\n}\nfunction SnapGuides({ guides, animated = true }) {\n  const box = snapGuidesBounds(guides);\n  if (!box) return null;\n  return /* @__PURE__ */ jsx(ViewportPortal, { children: /* @__PURE__ */ jsx(\n    \"svg\",\n    {\n      className: snapGuidesClassName,\n      \"data-animated\": animated ? \"true\" : \"false\",\n      width: box.width,\n      height: box.height,\n      style: {\n        position: \"absolute\",\n        left: 0,\n        top: 0,\n        // The same mechanism React Flow moves its own nodes with, so the\n        // guide and the node it points at cannot round differently.\n        transform: `translate(${box.x}px, ${box.y}px)`,\n        overflow: \"visible\",\n        pointerEvents: \"none\"\n      },\n      children: guides.map((guide) => /* @__PURE__ */ jsx(\n        \"line\",\n        {\n          className: snapGuideClassName,\n          \"data-axis\": guide.axis,\n          x1: (guide.axis === \"x\" ? guide.position : guide.start) - box.x,\n          x2: (guide.axis === \"x\" ? guide.position : guide.end) - box.x,\n          y1: (guide.axis === \"x\" ? guide.start : guide.position) - box.y,\n          y2: (guide.axis === \"x\" ? guide.end : guide.position) - box.y\n        },\n        guide.axis\n      ))\n    }\n  ) });\n}\nexport {\n  SnapGuides,\n  snapGuideClassName,\n  snapGuidePadding,\n  snapGuidesBounds,\n  snapGuidesClassName\n};\n//# sourceMappingURL=SnapGuides.js.map\n"],"mappings":";;;;AAEA,MAAM,sBAAsB;AAC5B,MAAM,qBAAqB;AAC3B,MAAM,mBAAmB;AACzB,SAAS,iBAAiB,QAAQ;CAChC,IAAI,OAAO,WAAW,GAAG,OAAO;CAChC,IAAI,OAAO,OAAO;CAClB,IAAI,OAAO,OAAO;CAClB,IAAI,OAAO,OAAO;CAClB,IAAI,OAAO,OAAO;CAClB,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,CAAC,IAAI,IAAI,IAAI,MAAM,MAAM,SAAS,MAAM;GAAC,MAAM;GAAU,MAAM;GAAO,MAAM;GAAU,MAAM;EAAG,IAAI;GAAC,MAAM;GAAO,MAAM;GAAU,MAAM;GAAK,MAAM;EAAQ;EAChK,OAAO,KAAK,IAAI,MAAM,IAAI,EAAE;EAC5B,OAAO,KAAK,IAAI,MAAM,IAAI,EAAE;EAC5B,OAAO,KAAK,IAAI,MAAM,IAAI,EAAE;EAC5B,OAAO,KAAK,IAAI,MAAM,IAAI,EAAE;CAC9B;CACA,OAAO;EACL,GAAG;EACH,GAAG;EACH,OAAO,OAAO,WAA0B;EACxC,QAAQ,OAAO,WAA0B;CAC3C;AACF;AACA,SAAS,WAAW,EAAE,QAAQ,WAAW,QAAQ;CAC/C,MAAM,MAAM,iBAAiB,MAAM;CACnC,IAAI,CAAC,KAAK,OAAO;CACjB,OAAuB,oBAAI,gBAAgB,EAAE,UAA0B,oBACrE,OACA;EACE,WAAW;EACX,iBAAiB,WAAW,SAAS;EACrC,OAAO,IAAI;EACX,QAAQ,IAAI;EACZ,OAAO;GACL,UAAU;GACV,MAAM;GACN,KAAK;GAGL,WAAW,aAAa,IA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