@next-bricks/diagram 0.48.0 → 0.48.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/bricks.json +1 -1
  2. package/dist/chunks/{4192.5903f562.js → 1124.b5167ef0.js} +2 -2
  3. package/dist/chunks/{4192.5903f562.js.map → 1124.b5167ef0.js.map} +1 -1
  4. package/dist/chunks/{3171.7b3bd3db.js → 3171.05e8c8e3.js} +2 -2
  5. package/dist/chunks/{5552.05f2ffc3.js.map → 3171.05e8c8e3.js.map} +1 -1
  6. package/dist/chunks/{3233.7d668e53.js → 3233.19da547d.js} +3 -3
  7. package/dist/chunks/{3233.7d668e53.js.map → 3233.19da547d.js.map} +1 -1
  8. package/dist/chunks/{3933.0ff81187.js → 3933.88eac208.js} +2 -2
  9. package/dist/chunks/{3933.0ff81187.js.map → 3933.88eac208.js.map} +1 -1
  10. package/dist/chunks/4766.f59e3f71.js +3 -0
  11. package/dist/chunks/4766.f59e3f71.js.map +1 -0
  12. package/dist/chunks/{4837.3e1f88e9.js → 4837.70d6aed1.js} +2 -2
  13. package/dist/chunks/{7218.5fe22f37.js.map → 4837.70d6aed1.js.map} +1 -1
  14. package/dist/chunks/{5552.05f2ffc3.js → 5552.2e16bd1b.js} +2 -2
  15. package/dist/chunks/{3171.7b3bd3db.js.map → 5552.2e16bd1b.js.map} +1 -1
  16. package/dist/chunks/{6314.24686b76.js → 6314.bb9b530c.js} +2 -2
  17. package/dist/chunks/{6314.24686b76.js.map → 6314.bb9b530c.js.map} +1 -1
  18. package/dist/chunks/{7218.5fe22f37.js → 7218.46d7a966.js} +2 -2
  19. package/dist/chunks/{4837.3e1f88e9.js.map → 7218.46d7a966.js.map} +1 -1
  20. package/dist/chunks/{9711.58afee04.js → 9711.db99cd7a.js} +2 -2
  21. package/dist/chunks/{9711.58afee04.js.map → 9711.db99cd7a.js.map} +1 -1
  22. package/dist/chunks/{9961.813fbbe3.js → 9961.ae4c5cd7.js} +2 -2
  23. package/dist/chunks/9961.ae4c5cd7.js.map +1 -0
  24. package/dist/chunks/{eo-display-canvas.31ead79a.js → eo-display-canvas.6413b302.js} +2 -2
  25. package/dist/chunks/{eo-display-canvas.31ead79a.js.map → eo-display-canvas.6413b302.js.map} +1 -1
  26. package/dist/chunks/{eo-draw-canvas.a5b81b45.js → eo-draw-canvas.75290631.js} +2 -2
  27. package/dist/chunks/{eo-draw-canvas.a5b81b45.js.map → eo-draw-canvas.75290631.js.map} +1 -1
  28. package/dist/chunks/main.8f8d2a68.js +2 -0
  29. package/dist/chunks/{main.463fee46.js.map → main.8f8d2a68.js.map} +1 -1
  30. package/dist/index.fd8cc53f.js +2 -0
  31. package/dist/{index.a3714a79.js.map → index.fd8cc53f.js.map} +1 -1
  32. package/package.json +3 -3
  33. package/dist/chunks/799.ccb70fb8.js +0 -3
  34. package/dist/chunks/799.ccb70fb8.js.map +0 -1
  35. package/dist/chunks/9961.813fbbe3.js.map +0 -1
  36. package/dist/chunks/main.463fee46.js +0 -2
  37. package/dist/index.a3714a79.js +0 -2
  38. /package/dist/chunks/{3233.7d668e53.js.LICENSE.txt → 3233.19da547d.js.LICENSE.txt} +0 -0
  39. /package/dist/chunks/{799.ccb70fb8.js.LICENSE.txt → 4766.f59e3f71.js.LICENSE.txt} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunks/9961.ae4c5cd7.js","mappings":"yOAGO,SAASA,EACdC,EACAC,GAEA,OAAOD,EAAME,MACVC,IAASC,EAAAA,EAAAA,IAA0BD,IAASA,EAAKF,KAAOA,GAE7D,C,wBCSO,SAASI,EAAaC,GAKc,IAAAC,EAAAC,EAAA,IALb,KAC5BC,EAAI,MACJT,EAAK,YACLU,EAAW,OACXC,GACmBL,EACnB,MAAM,sBAAEM,IAA0BC,EAAAA,EAAAA,KAC5BC,GAAUC,EAAAA,EAAAA,QAAuB,MACjCC,GAAaC,EAAAA,EAAAA,UACjB,IAAMlB,EAAwBC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AK,CAEpE,IACC,CAAC+a,KAGJpsB,EAAAA,EAAAA,YAAU,KACR,MAAMgqB,EAAOrV,EAAQ/S,QACrB,IAAKooB,EACH,OAGF,MAAM4C,GAAgB3C,EAAAA,EAAAA,GAAOD,GAEvB6C,EAAYA,KAChBD,EACGD,GAAG,QAAS,MACZA,GAAG,eAAgB,MACnBA,GAAG,QAAS,KAAK,EAGtB,GAAMpD,GAAY0C,GAAcC,EA+ChC,OA1CI3C,GAAY0C,IAGdW,EAAcD,GACZ,qBACCtkB,IAEMA,EAAEmS,UAELnS,EAAEykB,2BACEb,IACF5jB,EAAEoE,iBACF+c,EAAOuD,YACLH,EACAvkB,EAAE2kB,YAAc,EAChB3kB,EAAE4kB,YAAc,IAGtB,IAMNL,EACG9qB,KAAK0nB,GACLmD,GAAG,SAAUtkB,IACZA,EAAEoE,gBAAgB,IAEnBkgB,GAAG,gBAAiB,OAEjBR,GAAcC,IAAmBF,GACrCU,EAAcD,GAAG,iBAAkB,MAGhCT,GACHU,EACGD,GAAG,kBAAmB,MACtBA,GAAG,iBAAkB,MACrBA,GAAG,gBAAiB,MAGlBE,EA9CLA,GA8Cc,GACf,CACDT,EACAD,EACAD,EACAvX,EACAsX,EACA1C,EACAC,IAGK,CAAE8C,WAAU/gB,YAAWie,SAAQ7M,aACxC,C,kEC9KIuQ,E,MAA0B,GAA4B,KAE1DA,EAAwB/mB,KAAK,CAACgnB,EAAOxvB,GAAI,86CAK2E,KAEpH,QAAeuvB,EAAwBE,U,kECTnCF,E,MAA0B,GAA4B,KAE1DA,EAAwB/mB,KAAK,CAACgnB,EAAOxvB,GAAI,6pGAYmkB,KAE5mB,QAAeuvB,EAAwBE,U","sources":["webpack:///./src/draw-canvas/processors/findNodeOrAreaDecorator.ts","webpack:///./src/draw-canvas/EdgeComponent.tsx","webpack:///./src/draw-canvas/NodeComponent.tsx","webpack:///./src/draw-canvas/processors/handleMouseDown.ts","webpack:///./src/draw-canvas/processors/normalizeSnapOptions.ts","webpack:///./src/draw-canvas/decorators/DecoratorArea.tsx","webpack:///./src/draw-canvas/decorators/DecoratorText.tsx","webpack:///./src/draw-canvas/decorators/DecoratorContainer.tsx","webpack:///./src/draw-canvas/decorators/index.tsx","webpack:///./src/draw-canvas/processors/computeContainerRect.ts","webpack:///./src/draw-canvas/CellComponent.tsx","webpack:///./src/draw-canvas/ConnectLineComponent.tsx","webpack:///./src/shared/canvas/processors/getEditingLinePoints.ts","webpack:///./src/draw-canvas/EditingLineComponent.tsx","webpack:///./src/draw-canvas/HoverStateContext.ts","webpack:///./src/draw-canvas/LineConnectorComponent.tsx","webpack:///./src/draw-canvas/LineEditorComponent.tsx","webpack:///./src/draw-canvas/SmartConnectLineComponent.tsx","webpack:///./src/shared/canvas/processors/getConnectLinePoints.ts","webpack:///./src/draw-canvas/constants.ts","webpack:///./src/draw-canvas/processors/asserts.ts","webpack:///./src/draw-canvas/processors/cellToTarget.ts","webpack:///./src/draw-canvas/processors/getUnrelatedCells.ts","webpack:///./src/draw-canvas/processors/handleKeyboard.ts","webpack:///./src/draw-canvas/processors/handleLasso.ts","webpack:///./src/draw-canvas/processors/handleNodeContainedChange.ts","webpack:///./src/draw-canvas/processors/initializeCells.ts","webpack:///./src/draw-canvas/processors/sameTarget.ts","webpack:///./src/draw-canvas/processors/targetIsActive.ts","webpack:///./src/draw-canvas/processors/transformToCenter.ts","webpack:///./src/draw-canvas/processors/updateCells.ts","webpack:///./src/draw-canvas/reducers/cells.ts","webpack:///./src/draw-canvas/reducers/index.ts","webpack:///./src/draw-canvas/reducers/layoutKey.ts","webpack:///./src/shared/canvas/icons/center.svg","webpack:///./src/shared/canvas/icons/zoom-in.svg","webpack:///./src/shared/canvas/icons/zoom-out.svg","webpack:///./src/shared/canvas/ZoomBarComponent.tsx","webpack:///./src/shared/canvas/dagreLayout.ts","webpack:///./src/shared/canvas/forceLayout.ts","webpack:///./src/shared/canvas/processors/nodeViewToNodeRect.ts","webpack:///./src/shared/canvas/processors/getSmartLinePoints.ts","webpack:///./src/shared/canvas/shapes/Rectangle.ts","webpack:///./src/shared/canvas/useActiveTarget.ts","webpack:///./src/draw-canvas/processors/normalizeAlignOrigin.ts","webpack:///./src/shared/canvas/useLayout.ts","webpack:///./src/shared/canvas/useAutoCenter.ts","webpack:///./src/shared/canvas/useLineMarkers.ts","webpack:///./src/shared/canvas/useReady.ts","webpack:///./src/shared/canvas/useZoom.ts","webpack:///./src/shared/canvas/ZoomBarComponent.shadow.css","webpack:///./src/shared/canvas/styles.shadow.css"],"sourcesContent":["import type { Cell, NodeCell, DecoratorCell, NodeId } from \"../interfaces\";\nimport { isNodeOrAreaDecoratorCell } from \"./asserts\";\n\nexport function findNodeOrAreaDecorator(\n cells: Cell[],\n id: NodeId\n): NodeCell | DecoratorCell | undefined {\n return cells.find(\n (cell) => isNodeOrAreaDecoratorCell(cell) && cell.id === id\n ) as NodeCell | DecoratorCell | undefined;\n}\n","import React, { useEffect, useMemo, useRef } from \"react\";\nimport classNames from \"classnames\";\nimport type { Cell, ComputedEdgeLineConf, EdgeCell } from \"./interfaces\";\nimport { isEdgeCell, isStraightType } from \"./processors/asserts\";\nimport { DEFAULT_LINE_INTERACT_ANIMATE_DURATION } from \"./constants\";\nimport { curveLine } from \"../diagram/lines/curveLine\";\nimport { getSmartLinePoints } from \"../shared/canvas/processors/getSmartLinePoints\";\nimport { findNodeOrAreaDecorator } from \"./processors/findNodeOrAreaDecorator\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport { getMarkers } from \"../shared/canvas/useLineMarkers\";\nimport { LineMarkerConf } from \"../diagram/interfaces\";\n\nexport interface EdgeComponentProps {\n edge: EdgeCell;\n cells: Cell[];\n lineConfMap: WeakMap<EdgeCell, ComputedEdgeLineConf>;\n active?: boolean;\n}\n\nexport function EdgeComponent({\n edge,\n cells,\n lineConfMap,\n active,\n}: EdgeComponentProps): JSX.Element | null {\n const { setActiveEditableLine } = useHoverStateContext();\n const pathRef = useRef<SVGPathElement>(null);\n const sourceNode = useMemo(\n () => findNodeOrAreaDecorator(cells, edge.source),\n [cells, edge.source]\n );\n const targetNode = useMemo(\n () => findNodeOrAreaDecorator(cells, edge.target),\n [cells, edge.target]\n );\n const lineConf = useMemo(() => lineConfMap.get(edge)!, [edge, lineConfMap]);\n\n const parallelGap = useMemo(() => {\n const hasOppositeEdge =\n isStraightType(edge.view?.type) &&\n cells.some(\n (cell) =>\n isEdgeCell(cell) &&\n cell.source === edge.target &&\n cell.target === edge.source &&\n isStraightType(cell.view?.type)\n );\n return hasOppositeEdge ? lineConf.parallelGap : 0;\n }, [cells, edge.source, edge.target, edge.view, lineConf.parallelGap]);\n\n const linePoints = useMemo(() => {\n const points =\n sourceNode &&\n targetNode &&\n sourceNode.view.x != null &&\n targetNode.view.x != null\n ? getSmartLinePoints(\n sourceNode.view,\n targetNode.view,\n edge.view,\n parallelGap\n )\n : null;\n return points;\n }, [edge.view, parallelGap, sourceNode, targetNode]);\n\n const line = useMemo(() => {\n const fixedLineType = lineConf.type;\n return curveLine(\n linePoints,\n fixedLineType === \"curve\" ? lineConf.curveType : \"curveLinear\",\n 0,\n 1\n );\n }, [lineConf, linePoints]);\n\n useEffect(() => {\n setActiveEditableLine((prev) =>\n active\n ? linePoints && sourceNode && targetNode\n ? {\n edge,\n source: sourceNode,\n target: targetNode,\n linePoints,\n lineType: lineConf.type,\n lineCurveType: lineConf.curveType,\n parallelGap,\n }\n : null\n : prev?.edge &&\n prev.edge.source === edge.source &&\n prev.edge.target === edge.target\n ? null\n : prev\n );\n }, [\n active,\n edge,\n lineConf.curveType,\n lineConf.type,\n linePoints,\n setActiveEditableLine,\n sourceNode,\n targetNode,\n parallelGap,\n ]);\n\n if (!line || !linePoints) {\n // This happens when source or target is not found,\n // or when source or target has not been positioned yet.\n return null;\n }\n\n let markerStart: string | undefined;\n let markerEnd: string | undefined;\n const lineMarkers: LineMarkerConf[] = getMarkers(lineConf);\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart = lineConf.$markerStartUrl;\n } else {\n markerEnd = lineConf.$markerEndUrl;\n }\n }\n\n return (\n <>\n <path\n // This `path` is made for expanding interaction area of graph lines.\n d={line}\n fill=\"none\"\n stroke=\"transparent\"\n strokeWidth={lineConf.interactStrokeWidth}\n />\n <path\n ref={pathRef}\n className={classNames(\"line\", {\n dashed: lineConf.dashed,\n dotted: lineConf.dotted,\n [`${lineConf.dashed ? \"dashed\" : lineConf.dotted ? \"dotted\" : \"solid\"}-animation`]:\n lineConf.animate.useAnimate,\n })}\n style={\n {\n \"--time\": `${lineConf.animate.duration ?? DEFAULT_LINE_INTERACT_ANIMATE_DURATION}s`,\n \"--solid-length\": pathRef.current?.getTotalLength?.(),\n } as React.CSSProperties\n }\n d={line}\n fill=\"none\"\n stroke={lineConf.strokeColor}\n strokeWidth={lineConf.strokeWidth}\n markerStart={markerStart}\n markerEnd={markerEnd}\n />\n <path className=\"line-active-bg\" d={line} fill=\"none\" />\n </>\n );\n}\n","import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { ReactUseBrick } from \"@next-core/react-runtime\";\nimport { __secret_internals, checkIfByTransform } from \"@next-core/runtime\";\nimport { isEqual } from \"lodash\";\nimport ResizeObserver from \"resize-observer-polyfill\";\nimport type { NodeBrickCell, NodeBrickConf, NodeCell } from \"./interfaces\";\nimport type { SizeTuple } from \"../diagram/interfaces\";\n\nexport interface NodeComponentProps {\n node: NodeCell;\n degraded: boolean;\n degradedNodeLabel?: string;\n defaultNodeBricks?: NodeBrickConf[];\n onResize(id: string, size: SizeTuple | null): void;\n}\n\nexport function NodeComponent({\n node,\n degraded,\n degradedNodeLabel,\n defaultNodeBricks,\n onResize,\n}: NodeComponentProps): JSX.Element | null {\n const memoizedData = useDeepMemo({ node: { id: node.id, data: node.data } });\n const specifiedUseBrick = (node as NodeBrickCell).useBrick;\n const observerRef = useRef<ResizeObserver | null>(null);\n\n const useBrick = useMemo(() => {\n return degraded\n ? null\n : specifiedUseBrick ??\n defaultNodeBricks?.find((item) =>\n checkIfByTransform(item, memoizedData)\n )?.useBrick;\n }, [degraded, specifiedUseBrick, defaultNodeBricks, memoizedData]);\n\n const label = useMemo<string>(\n () =>\n degraded\n ? String(\n __secret_internals.legacyDoTransform(\n memoizedData,\n degradedNodeLabel ?? \"<% DATA.node.id %>\"\n )\n )\n : \"\",\n [degraded, degradedNodeLabel, memoizedData]\n );\n\n const refCallback = useCallback(\n (element: HTMLElement | null) => {\n const prevObserver = observerRef.current;\n if (prevObserver) {\n prevObserver.disconnect();\n observerRef.current = null;\n }\n if (element) {\n // Todo: correctly wait for `useBrick` in v3 to be rendered (after layout)\n // Wait a macro task to let `useBrick` to be rendered.\n setTimeout(() => {\n const observer = new ResizeObserver(() => {\n onResize(node.id, [element.offsetWidth, element.offsetHeight]);\n });\n observer.observe(element);\n observerRef.current = observer;\n });\n } else {\n onResize(node.id, null);\n }\n },\n [node.id, onResize]\n );\n\n const degradedRefCallBack = useCallback(\n (g: SVGGElement | null) => {\n if (g) {\n // istanbul ignore next\n const size =\n process.env.NODE_ENV === \"test\"\n ? { width: 60, height: 60 }\n : g.getBBox();\n onResize(node.id, [size.width, size.height]);\n } else {\n onResize(node.id, null);\n }\n },\n [node.id, onResize]\n );\n\n return useBrick ? (\n <foreignObject\n // Make a large size to avoid the brick inside to be clipped by the foreignObject.\n width={9999}\n height={9999}\n className=\"node\"\n >\n {useBrick && (\n <ReactUseBrick\n useBrick={useBrick}\n data={memoizedData}\n refCallback={refCallback}\n />\n )}\n </foreignObject>\n ) : degraded ? (\n <g className=\"degraded\" ref={degradedRefCallBack}>\n <circle cx={8} cy={8} r={8} />\n <text x={8} y={32}>\n {label}\n </text>\n </g>\n ) : null;\n}\n\nfunction useDeepMemo<T>(value: T): T {\n const [memoizedValue, setMemoizedValue] = useState(value);\n\n useEffect(() => {\n setMemoizedValue((prev) => (isEqual(prev, value) ? prev : value));\n }, [value]);\n\n return memoizedValue;\n}\n","import type { PositionTuple } from \"../../diagram/interfaces\";\nimport type {\n ActiveTarget,\n Cell,\n LayoutOptions,\n DecoratorCell,\n LayoutType,\n NodeCell,\n NodeView,\n} from \"../interfaces\";\nimport type {\n MoveCellPayload,\n ResizeCellPayload,\n} from \"../reducers/interfaces\";\nimport {\n isContainerDecoratorCell,\n isDecoratorCell,\n isEdgeCell,\n isNodeCell,\n} from \"./asserts\";\nimport { cellToTarget } from \"./cellToTarget\";\nimport { normalizeSnapOptions } from \"./normalizeSnapOptions\";\nimport { targetIsActive } from \"./targetIsActive\";\n\nexport function handleMouseDown(\n event: MouseEvent,\n {\n action,\n cell,\n scale,\n layout,\n layoutOptions,\n activeTarget,\n cells,\n onCellsMoving,\n onCellsMoved,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n }: {\n action: \"move\" | \"resize\";\n cell: Cell;\n scale: number;\n layout?: LayoutType;\n layoutOptions?: LayoutOptions;\n activeTarget: ActiveTarget | null | undefined;\n cells: Cell[];\n onCellsMoving?(info: MoveCellPayload[]): void;\n onCellsMoved?(info: MoveCellPayload[]): void;\n onCellResizing?(info: ResizeCellPayload): void;\n onCellResized?(info: ResizeCellPayload): void;\n onSwitchActiveTarget?(activeTarget: ActiveTarget | null): void;\n }\n) {\n event.stopPropagation();\n // Drag node\n if (action === \"resize\" || !targetIsActive(cell, activeTarget)) {\n onSwitchActiveTarget?.(cellToTarget(cell));\n }\n if (isEdgeCell(cell)) {\n return;\n }\n const activeCells: Cell[] = [];\n const actives =\n activeTarget?.type === \"multi\" && action === \"move\"\n ? cells.filter((c) => targetIsActive(c, activeTarget))\n : [cell];\n actives.forEach((a) => {\n activeCells.push(a);\n if (action === \"move\" && isContainerDecoratorCell(a)) {\n activeCells.push(\n ...cells.filter(\n (c) => isNodeCell(c) && c.containerId === a.id && !actives.includes(c)\n )\n );\n }\n });\n const isAutoLayout = layout === \"force\" || layout === \"dagre\";\n const movableActiveCells = activeCells.filter(\n (c) => (isNodeCell(c) && !isAutoLayout) || isDecoratorCell(c)\n ) as (NodeCell | DecoratorCell)[];\n\n if (movableActiveCells.length === 0) {\n return;\n }\n\n const snap = normalizeSnapOptions(layoutOptions?.snap);\n\n const from: PositionTuple = [event.clientX, event.clientY];\n const originals = movableActiveCells.map<{\n cell: NodeCell | DecoratorCell;\n position: PositionTuple;\n center: PositionTuple | null;\n }>((c) => ({\n cell: c,\n position:\n action === \"move\" ? [c.view.x, c.view.y] : [c.view.width, c.view.height],\n center:\n action === \"move\" && !isEdgeCell(c) ? getCenterPosition(c.view) : null,\n }));\n const firstOriginalPosition = originals[0].position;\n let previousPositions = originals.map(({ position }) => position);\n\n // Get the positions of the objects (cells that are not active) to snap to\n let snapToObjectTargets: {\n cell: NodeCell | DecoratorCell;\n center: PositionTuple;\n }[] = [];\n if (action === \"move\" && snap.object) {\n const objectCells = cells.filter(\n (c) => !isEdgeCell(c) && !activeCells.includes(c)\n ) as (NodeCell | DecoratorCell)[];\n snapToObjectTargets = objectCells.map((c) => ({\n cell: c,\n center: getCenterPosition(c.view),\n }));\n }\n\n function getMovement(e: MouseEvent): PositionTuple {\n return [(e.clientX - from[0]) / scale, (e.clientY - from[1]) / scale];\n }\n let moved = false;\n\n const handleMove = (e: MouseEvent, finished?: boolean) => {\n // Respect the scale\n const movement = getMovement(e);\n let newPositions: PositionTuple[];\n let xAlign: [PositionTuple, PositionTuple] | undefined;\n let yAlign: [PositionTuple, PositionTuple] | undefined;\n let xAlignCell: Cell | undefined;\n let yAlignCell: Cell | undefined;\n\n // Use alt key (or option key ⌥ on Mac) to disable snap\n if ((!snap.grid && !snap.object) || e.altKey) {\n // No snap\n newPositions = originals.map(({ position }) => [\n position[0] + movement[0],\n position[1] + movement[1],\n ]);\n if (!moved) {\n moved = movement[0] ** 2 + movement[1] ** 2 >= 9;\n }\n } else {\n // Snap\n let diffX = Infinity;\n let diffY = Infinity;\n const snapMovement: PositionTuple = [...movement];\n\n if (snap.object) {\n const snapToObjectDistance = snap.object.distance;\n let xAlignFrom: PositionTuple | undefined;\n let yAlignFrom: PositionTuple | undefined;\n let xAlignTarget: NodeCell | DecoratorCell | undefined;\n let yAlignTarget: NodeCell | DecoratorCell | undefined;\n let xAlignToY = 0;\n let yAlignToX = 0;\n for (const {\n cell: target,\n center: [x, y],\n } of snapToObjectTargets) {\n for (const { cell: c, center } of originals) {\n const [cx, cy] = center!;\n const dX = Math.abs(cx + movement[0] - x);\n const dY = Math.abs(cy + movement[1] - y);\n const xSnapped = dX < snapToObjectDistance && dX < diffX;\n const ySnapped = dY < snapToObjectDistance && dY < diffY;\n if (xSnapped) {\n diffX = dX;\n snapMovement[0] = x - cx;\n xAlignCell = c;\n xAlignTarget = target;\n xAlignFrom = [x, y];\n xAlignToY = cy;\n }\n if (ySnapped) {\n diffY = dY;\n snapMovement[1] = y - cy;\n yAlignCell = c;\n yAlignTarget = target;\n yAlignFrom = [x, y];\n yAlignToX = cx;\n }\n }\n }\n\n if (xAlignTarget && xAlignTarget === yAlignTarget) {\n // Handle special case when both x and y are snapped to the same target.\n const halfHeight = xAlignTarget.view.height / 2;\n const halfWidth = xAlignTarget.view.width / 2;\n xAlign = [\n [xAlignFrom![0], xAlignFrom![1] - halfHeight],\n [xAlignFrom![0], xAlignFrom![1] + halfHeight],\n ];\n yAlign = [\n [yAlignFrom![0] - halfWidth, yAlignFrom![1]],\n [yAlignFrom![0] + halfWidth, yAlignFrom![1]],\n ];\n } else {\n if (xAlignFrom) {\n xAlign = [xAlignFrom, [xAlignFrom[0], xAlignToY + snapMovement[1]]];\n }\n if (yAlignFrom) {\n yAlign = [yAlignFrom, [yAlignToX + snapMovement[0], yAlignFrom[1]]];\n }\n }\n }\n\n if (snap.grid) {\n const snapToGridSize = snap.grid.size;\n // Use the first cell to decide the snap to grid position\n const firstNewPosition: PositionTuple = [\n Math.round(\n (firstOriginalPosition[0] + movement[0]) / snapToGridSize\n ) * snapToGridSize,\n Math.round(\n (firstOriginalPosition[1] + movement[1]) / snapToGridSize\n ) * snapToGridSize,\n ];\n const snapToGridMovement: PositionTuple = [\n firstNewPosition[0] - firstOriginalPosition[0],\n firstNewPosition[1] - firstOriginalPosition[1],\n ];\n const snapToGridDiffX = Math.abs(snapToGridMovement[0] - movement[0]);\n const snapToGridDiffY = Math.abs(snapToGridMovement[1] - movement[1]);\n if (snapToGridDiffX < diffX) {\n diffX = snapToGridDiffX;\n snapMovement[0] = snapToGridMovement[0];\n xAlign = undefined;\n xAlignCell = undefined;\n }\n if (snapToGridDiffY < diffY) {\n diffY = snapToGridDiffY;\n snapMovement[1] = snapToGridMovement[1];\n yAlign = undefined;\n yAlignCell = undefined;\n }\n }\n\n newPositions = originals.map(({ position }) => [\n Math.round(position[0] + snapMovement[0]),\n Math.round(position[1] + snapMovement[1]),\n ]);\n const changed =\n newPositions[0][0] !== previousPositions[0][0] ||\n newPositions[0][1] !== previousPositions[0][1];\n if (changed) {\n previousPositions = newPositions;\n moved = true;\n }\n }\n\n if (moved) {\n if (action === \"move\") {\n const payloads = originals.map(({ cell: c }, index) => ({\n type: c.type,\n id: c.id,\n x: newPositions[index][0],\n y: newPositions[index][1],\n width: c.view.width,\n height: c.view.height,\n decorator: isDecoratorCell(c) ? c.decorator : undefined,\n guideLines: finished\n ? undefined\n : [\n ...(xAlignCell === c ? [xAlign!] : []),\n ...(yAlignCell === c ? [yAlign!] : []),\n ],\n }));\n (finished ? onCellsMoved : onCellsMoving)?.(payloads);\n } else {\n (finished ? onCellResized : onCellResizing)?.({\n type: cell.type,\n id: cell.id,\n width: newPositions[0][0],\n height: newPositions[0][1],\n });\n }\n }\n };\n\n const onMouseMove = (e: MouseEvent) => {\n handleMove(e);\n };\n const onMouseUp = (e: MouseEvent) => {\n handleMove(e, true);\n moved = false;\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n };\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n}\n\nfunction getCenterPosition(view: NodeView): PositionTuple {\n return [view.x + view.width / 2, view.y + view.height / 2];\n}\n","import {\n DEFAULT_SNAP_GRID_SIZE,\n DEFAULT_SNAP_OBJECT_DISTANCE,\n} from \"../constants\";\nimport type {\n SnapOptions,\n SnapToGridOptions,\n SnapToObjectOptions,\n} from \"../interfaces\";\n\nexport interface NormalizedSnapOptions {\n grid: Required<SnapToGridOptions> | null;\n object: Required<SnapToObjectOptions> | null;\n}\n\nexport function normalizeSnapOptions(\n snap: boolean | SnapOptions | undefined\n): NormalizedSnapOptions {\n const intermediateSnap = snap\n ? snap === true\n ? { grid: true, object: true }\n : snap\n : null;\n const snapToGrid = intermediateSnap?.grid\n ? intermediateSnap.grid === true\n ? {}\n : intermediateSnap.grid\n : null;\n const snapToObject = intermediateSnap?.object\n ? intermediateSnap.object === true\n ? {}\n : intermediateSnap.object\n : null;\n return {\n grid: snapToGrid\n ? { size: snapToGrid.size ?? DEFAULT_SNAP_GRID_SIZE }\n : null,\n object: snapToObject\n ? { distance: snapToObject.distance ?? DEFAULT_SNAP_OBJECT_DISTANCE }\n : null,\n };\n}\n","import React, { useEffect } from \"react\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport { handleMouseDown } from \"../processors/handleMouseDown\";\n\nexport function DecoratorArea({\n cell,\n transform,\n readOnly,\n layoutOptions,\n activeTarget,\n cells,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n}: BasicDecoratorProps): JSX.Element {\n const resizeHandleRef = React.useRef<SVGGElement>(null);\n\n useEffect(() => {\n const resizeHandle = resizeHandleRef.current;\n if (!resizeHandle || readOnly) {\n return;\n }\n const onMouseDown = (event: MouseEvent) => {\n handleMouseDown(event, {\n action: \"resize\",\n cell,\n scale: transform.k,\n layoutOptions,\n activeTarget,\n cells,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n });\n };\n resizeHandle.addEventListener(\"mousedown\", onMouseDown);\n return () => {\n resizeHandle.removeEventListener(\"mousedown\", onMouseDown);\n };\n }, [\n activeTarget,\n cell,\n cells,\n layoutOptions,\n onCellResized,\n onCellResizing,\n onSwitchActiveTarget,\n readOnly,\n transform.k,\n ]);\n\n return (\n <g className=\"decorator-area\">\n <rect\n width={cell.view.width}\n height={cell.view.height}\n className=\"area\"\n />\n {!readOnly && (\n <g\n ref={resizeHandleRef}\n className=\"resize-handle\"\n transform={`translate(${cell.view.width - 20} ${cell.view.height - 20})`}\n >\n <rect width={20} height={20} />\n <path d=\"M10 18L18 10 M15 18L18 15\" />\n </g>\n )}\n </g>\n );\n}\n","import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport classNames from \"classnames\";\n\nexport type DecoratorTextProps = Pick<\n BasicDecoratorProps,\n \"cell\" | \"readOnly\" | \"onDecoratorTextEditing\" | \"onDecoratorTextChange\"\n>;\n\nexport function DecoratorText({\n cell,\n readOnly,\n onDecoratorTextEditing,\n onDecoratorTextChange,\n}: DecoratorTextProps): JSX.Element {\n const label = cell.view.text ?? \"\";\n const [currentLabel, setCurrentLabel] = useState<string>(label);\n const [editingLabel, setEditingLabel] = useState(false);\n const editingLabelInitialized = useRef(false);\n const [shouldEmitLabelChange, setShouldEmitLabelChange] = useState(false);\n const ref = useRef<HTMLDivElement>(null);\n\n const handleEnableEdit = useCallback(\n (e: React.MouseEvent) => {\n if (readOnly) {\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n setEditingLabel(true);\n },\n [readOnly]\n );\n\n useEffect(() => {\n const element = ref.current;\n if (element && element.textContent !== currentLabel) {\n element.textContent = currentLabel;\n }\n }, [currentLabel]);\n useEffect(() => {\n const parentElement = ref.current?.parentElement;\n if (parentElement) {\n cell.view.width = parentElement.clientWidth;\n cell.view.height = parentElement.clientHeight;\n }\n }, [currentLabel, cell.id]);\n\n useEffect(() => {\n if (editingLabel && ref.current) {\n ref.current.focus();\n selectAllText(ref.current);\n }\n onDecoratorTextEditing?.({ id: cell.id, editing: editingLabel });\n }, [cell.id, editingLabel, onDecoratorTextEditing]);\n\n useEffect(() => {\n if (editingLabelInitialized.current) {\n onDecoratorTextEditing?.({ id: cell.id, editing: editingLabel });\n } else {\n editingLabelInitialized.current = true;\n }\n }, [cell.id, editingLabel, onDecoratorTextEditing]);\n\n const handleInput = useCallback(\n (event: React.FormEvent<HTMLDivElement>) => {\n if (readOnly) {\n return;\n }\n setCurrentLabel((event.target as HTMLDivElement).textContent!);\n },\n [readOnly]\n );\n\n const handleBlur = useCallback(() => {\n if (readOnly) {\n return;\n }\n setEditingLabel(false);\n setShouldEmitLabelChange(true);\n }, [readOnly]);\n\n useEffect(() => {\n if (shouldEmitLabelChange) {\n onDecoratorTextChange?.({\n id: cell.id,\n view: { ...cell.view, text: currentLabel },\n });\n setShouldEmitLabelChange(false);\n }\n }, [cell, currentLabel, onDecoratorTextChange, shouldEmitLabelChange]);\n\n return (\n <foreignObject className=\"decorator-text\">\n <div\n className={classNames(\"text-container\", { editing: editingLabel })}\n onDoubleClick={handleEnableEdit}\n >\n <div\n className=\"text\"\n contentEditable={editingLabel}\n ref={ref}\n onInput={handleInput}\n onBlur={handleBlur}\n />\n </div>\n </foreignObject>\n );\n}\n\nexport function selectAllText(element: HTMLElement) {\n const range = document.createRange();\n range.selectNodeContents(element);\n const selection = window.getSelection()!;\n selection.removeAllRanges();\n selection.addRange(range);\n}\n","import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport { handleMouseDown } from \"../processors/handleMouseDown\";\nimport classNames from \"classnames\";\nimport { get } from \"lodash\";\nimport { selectAllText } from \"./DecoratorText\";\nimport { isNoManualLayout } from \"../processors/asserts\";\nimport { uuidV4 } from \"..\";\n\nexport function DecoratorContainer({\n cell,\n transform,\n readOnly,\n layout,\n view,\n activeTarget,\n cells,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n onDecoratorTextEditing,\n onDecoratorTextChange,\n}: BasicDecoratorProps): JSX.Element {\n const label = get(cell.view, \"text\", \"\");\n const direction = get(cell.view, \"direction\", \"top\");\n const textRef = useRef<HTMLDivElement>(null);\n const resizeHandleRef = React.useRef<SVGGElement>(null);\n const [editingLabel, setEditingLabel] = useState(false);\n const [currentLabel, setCurrentLabel] = useState<string>(label);\n const [shouldEmitLabelChange, setShouldEmitLabelChange] = useState(false);\n const [recomputation, setRecomputation] = useState<string>();\n const [titleForeignRect, setTitleForeignRect] = useState({\n x: 0,\n y: 0,\n width: cell.view.width,\n height: cell.view.height,\n });\n const handleEnableEdit = useCallback(\n (e: React.MouseEvent) => {\n if (readOnly) {\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n setEditingLabel(true);\n },\n [readOnly]\n );\n const handleInput = useCallback(\n (event: React.FormEvent<HTMLDivElement>) => {\n if (readOnly) {\n return;\n }\n setCurrentLabel((event.target as HTMLDivElement).textContent!);\n },\n [readOnly]\n );\n\n const handleBlur = useCallback(() => {\n if (readOnly) {\n return;\n }\n setEditingLabel(false);\n setShouldEmitLabelChange(true);\n setRecomputation(uuidV4());\n }, [readOnly]);\n\n useEffect(() => {\n setCurrentLabel(label);\n }, [label]);\n useEffect(() => {\n const element = textRef.current;\n if (element && element.textContent !== currentLabel) {\n element.textContent = currentLabel;\n }\n }, [currentLabel]);\n\n useEffect(() => {\n const textParentEle = textRef.current?.parentElement;\n if (textParentEle) {\n const { clientWidth, clientHeight } = textParentEle;\n if ([\"left\", \"right\"].includes(direction)) {\n const rect = {\n width: clientWidth,\n height: view.height,\n x: direction === \"left\" ? -clientWidth : view.width,\n y: 0,\n };\n setTitleForeignRect(rect);\n } else {\n const rect = {\n width: view.width,\n height: clientHeight,\n x: 0,\n y: direction === \"top\" ? -clientHeight : view.height,\n };\n setTitleForeignRect(rect);\n }\n }\n }, [view, currentLabel, direction, recomputation]);\n\n useEffect(() => {\n if (editingLabel && textRef.current) {\n textRef.current.focus();\n selectAllText(textRef.current);\n }\n onDecoratorTextEditing?.({ id: cell.id, editing: editingLabel });\n }, [cell.id, editingLabel, onDecoratorTextEditing]);\n\n useEffect(() => {\n if (shouldEmitLabelChange) {\n onDecoratorTextChange?.({\n id: cell.id,\n view: { ...view, text: currentLabel },\n });\n setShouldEmitLabelChange(false);\n }\n }, [cell, view, currentLabel, onDecoratorTextChange, shouldEmitLabelChange]);\n\n useEffect(() => {\n const resizeHandle = resizeHandleRef.current;\n if (!resizeHandle || readOnly) {\n return;\n }\n const onMouseDown = (event: MouseEvent) => {\n handleMouseDown(event, {\n action: \"resize\",\n cell,\n scale: transform.k,\n activeTarget,\n cells,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n });\n };\n resizeHandle.addEventListener(\"mousedown\", onMouseDown);\n return () => {\n resizeHandle.removeEventListener(\"mousedown\", onMouseDown);\n };\n }, [\n activeTarget,\n cell,\n cells,\n onCellResized,\n onCellResizing,\n onSwitchActiveTarget,\n readOnly,\n transform.k,\n ]);\n\n return (\n <g className=\"decorator-container\">\n <foreignObject {...titleForeignRect}>\n <div\n className={classNames(\"text-container\", {\n editing: editingLabel,\n [[\"left\", \"right\"].includes(direction) ? \"vertical\" : \"horizontal\"]:\n true,\n })}\n onDoubleClick={handleEnableEdit}\n >\n <div\n className=\"text\"\n contentEditable={editingLabel}\n ref={textRef}\n onInput={handleInput}\n onBlur={handleBlur}\n />\n </div>\n </foreignObject>\n <rect width={view.width} height={view.height} className=\"container\" />\n {!readOnly && !isNoManualLayout(layout) && (\n <g\n ref={resizeHandleRef}\n className=\"resize-handle\"\n transform={`translate(${view.width - 20} ${view.height - 20})`}\n >\n <rect width={20} height={20} />\n <path d=\"M10 18L18 10 M15 18L18 15\" />\n </g>\n )}\n </g>\n );\n}\n","import React from \"react\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport { DecoratorArea } from \"./DecoratorArea\";\nimport { DecoratorText } from \"./DecoratorText\";\nimport { DecoratorContainer } from \"./DecoratorContainer\";\n\nexport function DecoratorComponent({\n cell,\n view,\n transform,\n readOnly,\n layout,\n layoutOptions,\n activeTarget,\n cells,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n onDecoratorTextEditing,\n onDecoratorTextChange,\n}: BasicDecoratorProps): JSX.Element | null {\n let SpecifiedComponent: (props: BasicDecoratorProps) => JSX.Element | null;\n\n switch (cell.decorator) {\n case \"container\":\n SpecifiedComponent = DecoratorContainer;\n break;\n case \"area\":\n SpecifiedComponent = DecoratorArea;\n break;\n case \"text\":\n SpecifiedComponent = DecoratorText;\n break;\n // istanbul ignore next\n default:\n // eslint-disable-next-line no-console\n console.error(`Unknown decorator: ${cell.decorator}`);\n return null;\n }\n\n return (\n <SpecifiedComponent\n cell={cell}\n view={view}\n transform={transform}\n readOnly={readOnly}\n layout={layout}\n layoutOptions={layoutOptions}\n activeTarget={activeTarget}\n cells={cells}\n onCellResizing={onCellResizing}\n onCellResized={onCellResized}\n onSwitchActiveTarget={onSwitchActiveTarget}\n onDecoratorTextEditing={onDecoratorTextEditing}\n onDecoratorTextChange={onDecoratorTextChange}\n />\n );\n}\n","import { BaseNodeCell } from \"../interfaces\";\n\nexport function computeContainerRect(cells: BaseNodeCell[]) {\n let minX = Infinity,\n minY = Infinity;\n let maxX = -Infinity,\n maxY = -Infinity;\n cells.forEach((cell) => {\n const { x, y, width, height } = cell.view;\n if (x < minX) minX = x;\n if (y < minY) minY = y;\n if (x + width > maxX) maxX = x + width;\n if (y + height > maxY) maxY = y + height;\n });\n if (![minX, maxX, minY, maxY].some((n) => isFinite(n))) return {};\n const padding = 20;\n const width = maxX - minX + padding * 2;\n const height = maxY - minY + padding * 2;\n return {\n x: minX - padding,\n y: minY - padding,\n width: width,\n height: height,\n };\n}\n","import React, { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport classNames from \"classnames\";\nimport type {\n ActiveTarget,\n Cell,\n CellContextMenuDetail,\n ComputedEdgeLineConf,\n DecoratorTextChangeDetail,\n DecoratorView,\n EdgeCell,\n LayoutOptions,\n LayoutType,\n NodeBrickConf,\n NodeCell,\n} from \"./interfaces\";\nimport {\n isContainerDecoratorCell,\n isDecoratorCell,\n isEdgeCell,\n isEdgeSide,\n isNoManualLayout,\n isNodeCell,\n} from \"./processors/asserts\";\nimport { EdgeComponent } from \"./EdgeComponent\";\nimport { NodeComponent } from \"./NodeComponent\";\nimport { handleMouseDown } from \"./processors/handleMouseDown\";\nimport type { MoveCellPayload, ResizeCellPayload } from \"./reducers/interfaces\";\nimport { DecoratorComponent } from \"./decorators\";\nimport { cellToTarget } from \"./processors/cellToTarget\";\nimport type { SizeTuple, TransformLiteral } from \"../diagram/interfaces\";\nimport { sameTarget } from \"./processors/sameTarget\";\nimport { targetIsActive } from \"./processors/targetIsActive\";\nimport { computeContainerRect } from \"./processors/computeContainerRect\";\nimport { get } from \"lodash\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nexport interface CellComponentProps {\n layout: LayoutType;\n layoutOptions?: LayoutOptions;\n cell: Cell;\n cells: Cell[];\n degraded: boolean;\n degradedNodeLabel?: string;\n defaultNodeBricks?: NodeBrickConf[];\n transform: TransformLiteral;\n lineConfMap: WeakMap<EdgeCell, ComputedEdgeLineConf>;\n activeTarget: ActiveTarget | null | undefined;\n readOnly?: boolean;\n unrelatedCells: Cell[];\n dragNodeToContainerActive?: boolean;\n allowEdgeToArea?: boolean;\n onCellsMoving?(info: MoveCellPayload[]): void;\n onCellsMoved?(info: MoveCellPayload[]): void;\n onCellResizing?(info: ResizeCellPayload): void;\n onCellResized?(info: ResizeCellPayload): void;\n onSwitchActiveTarget(target: ActiveTarget | null): void;\n onCellContextMenu(detail: CellContextMenuDetail): void;\n onCellClick?(detail: CellContextMenuDetail): void;\n onDecoratorTextEditing?(detail: { id: string; editing: boolean }): void;\n onDecoratorTextChange?(detail: DecoratorTextChangeDetail): void;\n onNodeBrickResize(id: string, size: SizeTuple | null): void;\n onCellMouseEnter?(cell: Cell): void;\n onCellMouseLeave?(cell: Cell): void;\n}\n\nexport function CellComponent({\n layout,\n layoutOptions,\n cell,\n cells,\n degraded,\n degradedNodeLabel,\n defaultNodeBricks,\n lineConfMap,\n activeTarget,\n dragNodeToContainerActive,\n readOnly,\n transform,\n unrelatedCells,\n allowEdgeToArea,\n onCellsMoving,\n onCellsMoved,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n onCellContextMenu,\n onCellClick,\n onDecoratorTextEditing,\n onDecoratorTextChange,\n onNodeBrickResize,\n onCellMouseEnter,\n onCellMouseLeave,\n}: CellComponentProps): JSX.Element | null {\n const {\n lineEditorState,\n smartConnectLineState,\n setSmartConnectLineState,\n onConnect,\n setLineEditorState,\n onChangeEdgeView,\n } = useHoverStateContext();\n const gRef = useRef<SVGGElement>(null);\n const unrelated = useMemo(\n () => unrelatedCells.some((item) => sameTarget(item, cell)),\n [cell, unrelatedCells]\n );\n // `containerRect` is undefined when it's an edge cell.\n const containerRect = useMemo((): DecoratorView | undefined => {\n if (isContainerDecoratorCell(cell) && isNoManualLayout(layout)) {\n const containCells = cells.filter(\n (c): c is NodeCell => isNodeCell(c) && c.containerId === cell.id\n );\n const view = {\n ...cell.view,\n ...computeContainerRect(containCells),\n };\n cell.view = view; //Update the rect container to make sure Lasso gets the correct size\n return view;\n }\n return isEdgeCell(cell)\n ? undefined\n : get(cell, \"view\", { x: 0, y: 0, width: 0, height: 0 });\n }, [layout, cell, cells]);\n\n useEffect(() => {\n const g = gRef.current;\n if (!g) {\n return;\n }\n const onMouseDown = (event: MouseEvent) => {\n if (\n readOnly ||\n (isContainerDecoratorCell(cell) && isNoManualLayout(layout))\n ) {\n event.stopPropagation();\n } else {\n handleMouseDown(event, {\n layout,\n layoutOptions,\n action: \"move\",\n cell,\n scale: transform.k,\n activeTarget,\n cells,\n onCellsMoving,\n onCellsMoved,\n onSwitchActiveTarget,\n });\n }\n };\n g.addEventListener(\"mousedown\", onMouseDown);\n return () => {\n g.removeEventListener(\"mousedown\", onMouseDown);\n };\n }, [\n layout,\n layoutOptions,\n cell,\n activeTarget,\n cells,\n onCellsMoved,\n onCellsMoving,\n onSwitchActiveTarget,\n readOnly,\n transform.k,\n ]);\n\n // istanbul ignore next: experimental\n useEffect(() => {\n const g = gRef.current;\n if (\n !g ||\n !isEdgeSide(cell, allowEdgeToArea) ||\n !(\n smartConnectLineState ||\n (lineEditorState && lineEditorState.type !== \"control\")\n )\n ) {\n return;\n }\n const onMouseUp = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n if (smartConnectLineState) {\n if (smartConnectLineState.source !== cell) {\n onConnect?.(\n smartConnectLineState.source,\n cell,\n smartConnectLineState.exitPosition,\n undefined\n );\n }\n setSmartConnectLineState(null);\n } else if (lineEditorState) {\n const {\n type,\n source,\n target,\n edge: { view },\n } = lineEditorState;\n\n const isEntry = type === \"entry\";\n if ((isEntry ? target : source) === cell) {\n if (isEntry) {\n onChangeEdgeView?.(source, target, {\n ...view,\n entryPosition: null,\n // ...(!view?.exitPosition ? { vertices: null } : {}),\n });\n } else {\n onChangeEdgeView?.(source, target, {\n ...view,\n exitPosition: null,\n // ...(!view?.entryPosition ? { vertices: null } : {}),\n });\n }\n }\n setLineEditorState(null);\n }\n };\n g.addEventListener(\"mouseup\", onMouseUp);\n return () => {\n g.removeEventListener(\"mouseup\", onMouseUp);\n };\n }, [\n allowEdgeToArea,\n cell,\n lineEditorState,\n onChangeEdgeView,\n onConnect,\n setLineEditorState,\n setSmartConnectLineState,\n smartConnectLineState,\n ]);\n\n const handleContextMenu = useCallback(\n (event: React.MouseEvent<SVGGElement>) => {\n if (readOnly && cell.type === \"decorator\") {\n return;\n }\n event.preventDefault();\n onSwitchActiveTarget(cellToTarget(cell));\n onCellContextMenu({\n cell,\n clientX: event.clientX,\n clientY: event.clientY,\n });\n },\n [cell, onCellContextMenu, onSwitchActiveTarget, readOnly]\n );\n\n const handleCellClick = useCallback(\n (event: React.MouseEvent<SVGGElement>) => {\n if (!onCellClick || cell.type === \"decorator\") {\n return;\n }\n onCellClick({\n cell,\n clientX: event.clientX,\n clientY: event.clientY,\n });\n },\n [cell, onCellClick]\n );\n\n const handleMouseEnter = useCallback(() => {\n onCellMouseEnter?.(cell);\n }, [cell, onCellMouseEnter]);\n\n const handleMouseLeave = useCallback(() => {\n onCellMouseLeave?.(cell);\n }, [cell, onCellMouseLeave]);\n\n const active = targetIsActive(cell, activeTarget);\n\n return (\n <g\n className={classNames(\"cell\", {\n active,\n faded: unrelated,\n \"read-only\": readOnly,\n \"container-active\": dragNodeToContainerActive,\n })}\n ref={gRef}\n transform={\n cell.type === \"edge\" || cell.view.x == null\n ? undefined\n : `translate(${containerRect!.x} ${containerRect!.y})`\n }\n onContextMenu={handleContextMenu}\n onClick={handleCellClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n {isNodeCell(cell) ? (\n <NodeComponent\n node={cell}\n degraded={degraded}\n degradedNodeLabel={degradedNodeLabel}\n defaultNodeBricks={defaultNodeBricks}\n onResize={onNodeBrickResize}\n />\n ) : isEdgeCell(cell) ? (\n <EdgeComponent\n edge={cell}\n cells={cells}\n lineConfMap={lineConfMap}\n active={active}\n />\n ) : isDecoratorCell(cell) ? (\n <DecoratorComponent\n cell={cell}\n view={containerRect!}\n transform={transform}\n readOnly={readOnly}\n layout={layout}\n layoutOptions={layoutOptions}\n activeTarget={activeTarget}\n cells={cells}\n onCellResizing={onCellResizing}\n onCellResized={onCellResized}\n onSwitchActiveTarget={onSwitchActiveTarget}\n onDecoratorTextEditing={onDecoratorTextEditing}\n onDecoratorTextChange={onDecoratorTextChange}\n />\n ) : null}\n </g>\n );\n}\n","import React, { useEffect, useState } from \"react\";\nimport classNames from \"classnames\";\nimport type { ConnectLineState } from \"./interfaces\";\nimport type { PositionTuple, TransformLiteral } from \"../diagram/interfaces\";\n\nexport interface ConnectLineComponentProps {\n connectLineState: ConnectLineState | null;\n transform: TransformLiteral;\n markerEnd: string;\n onConnect(state: ConnectLineState, to: PositionTuple): void;\n}\n\nexport function ConnectLineComponent({\n connectLineState,\n transform,\n markerEnd,\n onConnect,\n}: ConnectLineComponentProps): JSX.Element {\n const [connectLineTo, setConnectLineTo] = useState<PositionTuple | null>(\n null\n );\n\n useEffect(() => {\n if (connectLineState) {\n setConnectLineTo(connectLineState.from);\n }\n }, [connectLineState]);\n\n useEffect(() => {\n if (connectLineState) {\n const getConnectTo = (e: MouseEvent): PositionTuple => [\n (e.clientX - transform.x - connectLineState.offset[0]) / transform.k,\n (e.clientY - transform.y - connectLineState.offset[1]) / transform.k,\n ];\n const onMouseMove = (e: MouseEvent) => {\n // Set connect line to based on the mouse position and the transform\n setConnectLineTo(getConnectTo(e));\n };\n const onMouseDown = (e: MouseEvent) => {\n e.stopPropagation();\n };\n const onClick = (e: MouseEvent) => {\n e.stopPropagation();\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n reset();\n onConnect(connectLineState, getConnectTo(e));\n };\n const reset = () => {\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mousedown\", onMouseDown, {\n capture: true,\n });\n document.removeEventListener(\"click\", onClick, { capture: true });\n setConnectLineTo(null);\n };\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mousedown\", onMouseDown, { capture: true });\n document.addEventListener(\"click\", onClick, { capture: true });\n\n return reset;\n }\n }, [connectLineState, onConnect, transform]);\n\n return (\n <path\n className={classNames(\"connect-line\", {\n connecting:\n !!connectLineState &&\n connectLineTo &&\n // Do not show when the distance of mouse move is less than 5px\n (connectLineTo[0] - connectLineState.from[0]) ** 2 +\n (connectLineTo[1] - connectLineState.from[1]) ** 2 >\n 25,\n })}\n d={\n connectLineState && connectLineTo\n ? `M${connectLineState.from.join(\" \")}L${connectLineTo.join(\" \")}`\n : \"\"\n }\n fill=\"none\"\n stroke=\"gray\"\n strokeWidth={1}\n markerEnd={`url(#${markerEnd})`}\n />\n );\n}\n","import { pick } from \"lodash\";\nimport type { NodePosition, PositionTuple } from \"../../../diagram/interfaces\";\nimport type { HoverState } from \"../../../draw-canvas/HoverStateContext\";\nimport type {\n LineEditorState,\n LineEditorStateOfControl,\n} from \"../../../draw-canvas/interfaces\";\nimport { getSmartLinePoints, simplifyVertices } from \"./getSmartLinePoints\";\n\nexport function getEditingLinePoints(\n lineEditorState: LineEditorState | null,\n connectLineTo: PositionTuple | null,\n hoverState: HoverState | null\n): NodePosition[] | null {\n if (\n !lineEditorState ||\n !(\n connectLineTo ||\n (lineEditorState.type !== \"control\" &&\n hoverState?.activePointIndex !== undefined)\n )\n ) {\n return null;\n }\n\n const {\n type,\n source,\n target,\n edge: { view },\n } = lineEditorState;\n const { exitPosition, entryPosition, vertices } = view ?? {};\n\n const lineSettings = pick(view, [\"type\", \"curveType\"]);\n\n if (type === \"control\") {\n const newVertices = getNewLineVertices(lineEditorState, connectLineTo!);\n\n return getSmartLinePoints(source.view, target.view, {\n ...lineSettings,\n exitPosition,\n entryPosition,\n vertices: newVertices,\n });\n }\n\n if (hoverState?.activePointIndex !== undefined) {\n const position = hoverState.relativePoints[hoverState.activePointIndex];\n // Assert `hoverState.cell` is `target`\n return getSmartLinePoints(source.view, target.view, {\n ...lineSettings,\n ...(type === \"entry\"\n ? {\n exitPosition,\n entryPosition: position,\n }\n : {\n exitPosition: position,\n entryPosition,\n }),\n vertices,\n });\n }\n\n const [x1, y1] = connectLineTo!;\n\n if (type === \"entry\") {\n return getSmartLinePoints(\n source.view,\n { x: x1, y: y1, width: 0, height: 0 },\n { ...lineSettings, exitPosition, vertices }\n );\n }\n\n return getSmartLinePoints(\n { x: x1, y: y1, width: 0, height: 0 },\n target.view,\n { ...lineSettings, entryPosition, vertices }\n );\n}\n\nexport function getNewLineVertices(\n lineEditorState: LineEditorStateOfControl,\n connectLineTo: PositionTuple\n) {\n const { control, linePoints } = lineEditorState;\n const newVertices: NodePosition[] = [];\n const [x1, y1] = connectLineTo!;\n const exitPoint = linePoints[0];\n const entryPoint = linePoints[linePoints.length - 1];\n\n // If moving the first control, prepend a vertex to connect the control to the source\n if (control.index === 0) {\n newVertices.push(\n control.direction === \"ns\"\n ? { x: exitPoint.x, y: y1 }\n : { x: x1, y: exitPoint.y }\n );\n }\n\n // Adjust the related two controls, and leave other controls unchanged\n for (let i = 1; i < linePoints.length - 1; i++) {\n const vertex = linePoints[i];\n newVertices.push(\n i === control.index || i === control.index + 1\n ? control.direction === \"ns\"\n ? { x: vertex.x, y: y1 }\n : { x: x1, y: vertex.y }\n : vertex\n );\n }\n\n // If moving the last control, append a vertex to connect the control to the target\n if (control.index === linePoints.length - 2) {\n newVertices.push(\n control.direction === \"ns\"\n ? { x: entryPoint.x, y: y1 }\n : { x: x1, y: entryPoint.y }\n );\n }\n\n return simplifyVertices(exitPoint, newVertices, entryPoint);\n}\n","// istanbul ignore file: experimental\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport classNames from \"classnames\";\nimport type { ComputedLineConnecterConf } from \"./interfaces\";\nimport type {\n LineMarkerConf,\n NodePosition,\n PositionTuple,\n TransformLiteral,\n} from \"../diagram/interfaces\";\nimport { curveLine } from \"../diagram/lines/curveLine\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport {\n getEditingLinePoints,\n getNewLineVertices,\n} from \"../shared/canvas/processors/getEditingLinePoints\";\nimport { getMarkers } from \"../shared/canvas/useLineMarkers\";\n\nexport interface EditingLineComponentProps {\n transform: TransformLiteral;\n options: ComputedLineConnecterConf;\n}\n\nexport function EditingLineComponent({\n transform,\n options,\n}: EditingLineComponentProps): JSX.Element {\n const [connectLineTo, setConnectLineTo] = useState<PositionTuple | null>(\n null\n );\n const {\n activeEditableLine,\n hoverState,\n lineEditorState,\n setLineEditorState,\n onChangeEdgeView,\n } = useHoverStateContext();\n const movedRef = useRef(false);\n\n useEffect(() => {\n if (!lineEditorState) {\n setTimeout(() => {\n movedRef.current = false;\n }, 0);\n }\n }, [lineEditorState]);\n\n useEffect(() => {\n if (!lineEditorState) {\n return;\n }\n movedRef.current = false;\n const { type, offset, from } = lineEditorState;\n // Set connect line to based on the mouse position and the transform\n const getConnectTo = (e: MouseEvent): PositionTuple => {\n const position: NodePosition = {\n x: (e.clientX - transform.x - offset[0]) / transform.k,\n y: (e.clientY - transform.y - offset[1]) / transform.k,\n };\n let diff = Infinity;\n if (type === \"control\" && !e.altKey) {\n // Snap to other points\n const { linePoints, control } = lineEditorState;\n const axis = control.direction === \"ns\" ? \"y\" : \"x\";\n const original = control[axis];\n const otherPoints = linePoints.filter(\n (_, i) =>\n i === 0 ||\n i === linePoints.length - 1 ||\n (i !== control.index && i !== control.index + 1)\n );\n const snapDistance = 5;\n for (const point of otherPoints) {\n const newDiff = Math.abs(point[axis] - position[axis]);\n if (newDiff <= snapDistance && newDiff < diff) {\n position[axis] = point[axis];\n diff = newDiff;\n if (!movedRef.current && original !== position[axis]) {\n movedRef.current = true;\n }\n }\n }\n }\n if (diff === Infinity && !movedRef.current) {\n const movementX = (e.clientX - from[0]) / transform.k;\n const movementY = (e.clientY - from[1]) / transform.k;\n movedRef.current = movementX ** 2 + movementY ** 2 >= 9;\n }\n return [position.x, position.y];\n };\n const onMouseMove = (e: MouseEvent) => {\n const newConnectTo = getConnectTo(e);\n if (movedRef.current) {\n setConnectLineTo(newConnectTo);\n }\n };\n function onMouseUp(e: MouseEvent) {\n e.preventDefault();\n reset();\n if (lineEditorState?.type === \"control\") {\n const newConnectTo = getConnectTo(e);\n if (movedRef.current) {\n const {\n source,\n target,\n edge: { view },\n } = lineEditorState;\n onChangeEdgeView?.(source, target, {\n ...view,\n vertices: getNewLineVertices(lineEditorState, newConnectTo),\n });\n }\n }\n }\n function reset() {\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n setConnectLineTo(null);\n setLineEditorState(null);\n }\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n\n return reset;\n }, [lineEditorState, transform, setLineEditorState, onChangeEdgeView]);\n\n useEffect(() => {\n if (!activeEditableLine) {\n return;\n }\n const handleBodyClick = (e: MouseEvent) => {\n if (movedRef.current) {\n e.stopPropagation();\n e.preventDefault();\n }\n };\n document.body.addEventListener(\"click\", handleBodyClick);\n return () => {\n document.body.removeEventListener(\"click\", handleBodyClick);\n };\n }, [activeEditableLine]);\n\n const line = useMemo(() => {\n const points = getEditingLinePoints(\n lineEditorState,\n connectLineTo,\n hoverState\n );\n return curveLine(\n points,\n lineEditorState?.edge.view?.type === \"curve\"\n ? lineEditorState.edge.view.curveType\n : \"curveLinear\",\n 0,\n 1\n );\n }, [connectLineTo, hoverState, lineEditorState]);\n let markerStart: string | undefined;\n let markerEnd: string | undefined;\n const lineMarkers: LineMarkerConf[] = getMarkers(options);\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart = options.$editingStartMarkerUrl;\n } else {\n markerEnd = options.$editingEndMarkerUrl;\n }\n }\n\n return (\n <path\n className={classNames(\"editing-line\", {\n editing: !!(lineEditorState && connectLineTo),\n })}\n d={line}\n fill=\"none\"\n stroke={options.editingStrokeColor}\n markerStart={markerStart}\n markerEnd={markerEnd}\n />\n );\n}\n","// istanbul ignore file: nothing logical to test\nimport React from \"react\";\nimport type {\n DecoratorCell,\n EdgeView,\n EditableLineInfo,\n LineEditorState,\n NodeCell,\n SmartConnectLineState,\n} from \"./interfaces\";\nimport type { NodePosition } from \"../diagram/interfaces\";\n\nexport interface HoverState {\n // Currently only support node cell\n cell: NodeCell | DecoratorCell;\n relativePoints: ReadonlyArray<NodePosition>;\n points: ReadonlyArray<NodePosition>;\n activePointIndex?: number;\n}\n\nexport const HoverStateContext = React.createContext<{\n rootRef: React.RefObject<SVGSVGElement>;\n smartConnectLineState: SmartConnectLineState | null;\n unsetHoverStateTimeoutRef: React.MutableRefObject<number | null>;\n hoverState: HoverState | null;\n activeEditableLine: EditableLineInfo | null;\n lineEditorState: LineEditorState | null;\n setLineEditorState: React.Dispatch<\n React.SetStateAction<LineEditorState | null>\n >;\n setActiveEditableLine: React.Dispatch<\n React.SetStateAction<EditableLineInfo | null>\n >;\n setHoverState: React.Dispatch<React.SetStateAction<HoverState | null>>;\n setSmartConnectLineState: React.Dispatch<\n React.SetStateAction<SmartConnectLineState | null>\n >;\n onConnect?: (\n source: NodeCell | DecoratorCell,\n target: NodeCell | DecoratorCell,\n exitPosition: NodePosition,\n entryPosition: NodePosition | undefined\n ) => void;\n onChangeEdgeView?: (\n source: NodeCell | DecoratorCell,\n target: NodeCell | DecoratorCell,\n view: EdgeView\n ) => void;\n}>({\n rootRef: { current: null },\n smartConnectLineState: null,\n unsetHoverStateTimeoutRef: { current: null },\n hoverState: null,\n activeEditableLine: null,\n lineEditorState: null,\n setLineEditorState: () => {},\n setActiveEditableLine: () => {},\n setHoverState: () => {},\n setSmartConnectLineState: () => {},\n});\n\nexport function useHoverStateContext() {\n return React.useContext(HoverStateContext);\n}\n","// istanbul ignore file: experimental\nimport React, { useCallback, useEffect, useRef } from \"react\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport type { ActiveTarget, NodeCell } from \"./interfaces\";\nimport { targetIsActive } from \"./processors/targetIsActive\";\nimport type { NodePosition } from \"../diagram/interfaces\";\nimport { DEFAULT_NODE_PADDING_FOR_SMART_LINES } from \"./constants\";\n\nconst HELPER_IMAGE =\n \"data:image/svg+xml;base64,PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSI1cHgiIGhlaWdodD0iNXB4IiB2ZXJzaW9uPSIxLjEiPjxwYXRoIGQ9Im0gMCAwIEwgNSA1IE0gMCA1IEwgNSAwIiBzdHJva2Utd2lkdGg9IjIiIHN0eWxlPSJzdHJva2Utb3BhY2l0eTowLjQiIHN0cm9rZT0iI2ZmZmZmZiIvPjxwYXRoIGQ9Im0gMCAwIEwgNSA1IE0gMCA1IEwgNSAwIiBzdHJva2U9IiMyOWI2ZjIiLz48L3N2Zz4=\";\nconst HELPER_RADIUS = 5;\nconst HELPER_BG_RADIUS = 8;\nconst HALF_HELPER_RADIUS = HELPER_RADIUS / 2;\n\nexport interface LineConnectorComponentProps {\n activeTarget: ActiveTarget | null;\n scale: number;\n disabled?: boolean;\n}\n\nexport function LineConnectorComponent({\n activeTarget,\n scale,\n disabled,\n}: LineConnectorComponentProps): JSX.Element | null {\n const {\n unsetHoverStateTimeoutRef,\n hoverState,\n setHoverState,\n smartConnectLineState,\n lineEditorState,\n } = useHoverStateContext();\n\n const unsetTimeout = useCallback(() => {\n if (unsetHoverStateTimeoutRef.current !== null) {\n clearTimeout(unsetHoverStateTimeoutRef.current);\n unsetHoverStateTimeoutRef.current = null;\n }\n }, [unsetHoverStateTimeoutRef]);\n\n const unsetActivePointIndex = useCallback(() => {\n unsetTimeout();\n setHoverState((prev) =>\n prev?.activePointIndex === undefined\n ? prev\n : { ...hoverState!, activePointIndex: undefined }\n );\n }, [hoverState, setHoverState, unsetTimeout]);\n\n const unsetHoverState = useCallback(() => {\n unsetHoverStateTimeoutRef.current = setTimeout(() => {\n setHoverState(null);\n }) as unknown as number;\n }, [setHoverState, unsetHoverStateTimeoutRef]);\n\n const available =\n !disabled &&\n hoverState &&\n (!!smartConnectLineState ||\n (lineEditorState\n ? lineEditorState.type === \"entry\"\n ? hoverState.cell === lineEditorState.target\n : lineEditorState.type === \"exit\" &&\n hoverState.cell === lineEditorState.source\n : !targetIsActive(hoverState.cell, activeTarget) &&\n !hasActiveEdge(activeTarget)));\n\n const padding = DEFAULT_NODE_PADDING_FOR_SMART_LINES;\n const halfPadding = padding / 2;\n\n return (\n <g onMouseEnter={unsetActivePointIndex} onMouseLeave={unsetHoverState}>\n {available && (\n <>\n <rect\n x={hoverState.cell.view.x - halfPadding}\n y={hoverState.cell.view.y - halfPadding}\n width={hoverState.cell.view.width + padding}\n height={hoverState.cell.view.height + padding}\n fill=\"none\"\n stroke=\"transparent\"\n strokeWidth={(HELPER_BG_RADIUS * 2) / scale}\n pointerEvents=\"stroke\"\n />\n {hoverState.activePointIndex !== undefined && (\n <circle\n cx={hoverState.points[hoverState.activePointIndex].x}\n cy={hoverState.points[hoverState.activePointIndex].y}\n r={HELPER_BG_RADIUS / scale}\n fill=\"lightgreen\"\n fillOpacity={0.5}\n pointerEvents=\"none\"\n />\n )}\n {hoverState.points.map((point, index) => (\n <ConnectPointComponent\n key={index}\n index={index}\n point={point}\n scale={scale}\n unsetActivePointIndex={unsetActivePointIndex}\n unsetTimeout={unsetTimeout}\n />\n ))}\n </>\n )}\n </g>\n );\n}\n\ninterface ConnectPointComponentProps {\n index: number;\n point: NodePosition;\n scale: number;\n unsetTimeout: () => void;\n unsetActivePointIndex: () => void;\n}\n\nfunction ConnectPointComponent({\n index,\n point,\n scale,\n unsetTimeout,\n unsetActivePointIndex,\n}: ConnectPointComponentProps): JSX.Element {\n const {\n rootRef,\n smartConnectLineState,\n hoverState,\n setHoverState,\n setSmartConnectLineState,\n onConnect,\n lineEditorState,\n setLineEditorState,\n onChangeEdgeView,\n } = useHoverStateContext();\n const ref = useRef<SVGGElement>(null);\n\n useEffect(() => {\n const g = ref.current;\n const handleMouseEnter = (e: MouseEvent) => {\n // There is a chance that mouseenter will not be triggered when the element is shown aync.\n // So we also listen to the mousemove event, but only once.\n if (e.type === \"mousemove\") {\n g?.removeEventListener(e.type, handleMouseEnter);\n }\n unsetTimeout();\n setHoverState((prev) =>\n prev && prev.activePointIndex !== index\n ? { ...hoverState!, activePointIndex: index }\n : prev\n );\n };\n g?.addEventListener(\"mouseenter\", handleMouseEnter);\n g?.addEventListener(\"mousemove\", handleMouseEnter);\n return () => {\n g?.removeEventListener(\"mouseenter\", handleMouseEnter);\n g?.removeEventListener(\"mousemove\", handleMouseEnter);\n };\n }, [hoverState, index, setHoverState, unsetTimeout]);\n\n useEffect(() => {\n if (lineEditorState) {\n return;\n }\n const handleMouseDown = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n const rect = rootRef.current!.getBoundingClientRect();\n const originalPoint = hoverState!.points[index];\n setSmartConnectLineState({\n source: hoverState!.cell as NodeCell,\n from: [originalPoint.x, originalPoint.y],\n offset: [rect.left, rect.top],\n exitPosition: hoverState!.relativePoints[index],\n });\n };\n const g = ref.current;\n g?.addEventListener(\"mousedown\", handleMouseDown);\n return () => {\n g?.removeEventListener(\"mousedown\", handleMouseDown);\n };\n }, [hoverState, index, lineEditorState, rootRef, setSmartConnectLineState]);\n\n useEffect(() => {\n const handleMouseUp = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n if (smartConnectLineState) {\n if (smartConnectLineState.source !== hoverState?.cell) {\n onConnect?.(\n smartConnectLineState.source,\n hoverState!.cell,\n smartConnectLineState.exitPosition,\n hoverState!.relativePoints[hoverState!.activePointIndex!]\n );\n }\n setSmartConnectLineState(null);\n } else if (lineEditorState) {\n const position =\n hoverState!.relativePoints[hoverState!.activePointIndex!];\n const {\n type,\n source,\n target,\n edge: { view },\n } = lineEditorState;\n if (type === \"entry\") {\n onChangeEdgeView?.(source, target, {\n ...view,\n entryPosition: position,\n });\n } else {\n onChangeEdgeView?.(source, target, {\n ...view,\n exitPosition: position,\n });\n }\n setLineEditorState(null);\n }\n };\n const g = ref.current;\n g?.addEventListener(\"mouseup\", handleMouseUp);\n return () => {\n g?.removeEventListener(\"mouseup\", handleMouseUp);\n };\n }, [\n smartConnectLineState,\n hoverState,\n onConnect,\n setSmartConnectLineState,\n lineEditorState,\n onChangeEdgeView,\n setLineEditorState,\n ]);\n\n return (\n <g ref={ref} onMouseLeave={unsetActivePointIndex}>\n <circle\n cx={point.x}\n cy={point.y}\n r={HELPER_BG_RADIUS}\n fill=\"transparent\"\n />\n <image\n x={point.x - HALF_HELPER_RADIUS / scale}\n y={point.y - HALF_HELPER_RADIUS / scale}\n width={HELPER_RADIUS / scale}\n height={HELPER_RADIUS / scale}\n xlinkHref={HELPER_IMAGE}\n preserveAspectRatio=\"none\"\n />\n </g>\n );\n}\n\nfunction hasActiveEdge(activeTarget: ActiveTarget | null) {\n return (\n activeTarget &&\n (activeTarget.type === \"edge\" ||\n (activeTarget.type === \"multi\" &&\n activeTarget.targets.some((target) => target.type === \"edge\")))\n );\n}\n","// istanbul ignore file: experimental\nimport React, { useEffect, useMemo, useRef } from \"react\";\nimport type { NodePosition } from \"../diagram/interfaces\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport type { ControlPoint } from \"./interfaces\";\nimport { isStraightType } from \"./processors/asserts\";\n\nconst POINT_HELPER_IMAGE =\n \"data:image/svg+xml;base64,PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSIyMnB4IiBoZWlnaHQ9IjIycHgiIHZlcnNpb249IjEuMSI+PGNpcmNsZSBjeD0iMTEiIGN5PSIxMSIgcj0iNyIgc3Ryb2tlPSIjZmZmIiBmaWxsPSIjMjliNmYyIi8+PGNpcmNsZSBjeD0iMTEiIGN5PSIxMSIgcj0iMyIgc3Ryb2tlPSIjZmZmIiBmaWxsPSJ0cmFuc3BhcmVudCIvPjwvc3ZnPg==\";\nconst ANCHORED_POINT_HELPER_IMAGE =\n \"data:image/svg+xml;base64,PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSIyMnB4IiBoZWlnaHQ9IjIycHgiIHZlcnNpb249IjEuMSI+PGNpcmNsZSBjeD0iMTEiIGN5PSIxMSIgcj0iNyIgc3Ryb2tlPSIjZmZmIiBmaWxsPSIjMDFiZDIyIi8+PHBhdGggZD0ibSA4IDggTCAxNCAxNE0gOCAxNCBMIDE0IDgiIHN0cm9rZT0iI2ZmZiIvPjwvc3ZnPg==\";\nconst VERTEX_HELPER_IMAGE =\n \"data:image/svg+xml;base64,PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSIxOHB4IiBoZWlnaHQ9IjE4cHgiIHZlcnNpb249IjEuMSI+PGNpcmNsZSBjeD0iOSIgY3k9IjkiIHI9IjUiIHN0cm9rZT0iI2ZmZiIgZmlsbD0iIzI5YjZmMiIvPjwvc3ZnPg==\";\nconst POINT_HELPER_BG_SIZE = 22;\n\nexport interface LineEditorComponentProps {\n scale: number;\n}\n\nexport function LineEditorComponent({\n scale,\n}: LineEditorComponentProps): JSX.Element | null {\n const { rootRef, activeEditableLine, setLineEditorState } =\n useHoverStateContext();\n const exitRef = useRef<SVGImageElement>(null);\n const entryRef = useRef<SVGImageElement>(null);\n const controlPointsRef = useRef<(SVGImageElement | null)[]>([]);\n\n useEffect(() => {\n const exit = exitRef.current;\n const entry = entryRef.current;\n if (!exit || !entry || !activeEditableLine) {\n return;\n }\n const handleMouseDownFactory = (type: \"exit\" | \"entry\") => {\n return (e: MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n const rect = rootRef.current!.getBoundingClientRect();\n setLineEditorState({\n ...activeEditableLine,\n offset: [rect.left, rect.top],\n from: [e.clientX, e.clientY],\n type,\n });\n };\n };\n const handleStartMouseDown = handleMouseDownFactory(\"exit\");\n const handleEndMouseDown = handleMouseDownFactory(\"entry\");\n exit.addEventListener(\"mousedown\", handleStartMouseDown);\n entry.addEventListener(\"mousedown\", handleEndMouseDown);\n return () => {\n exit.removeEventListener(\"mousedown\", handleStartMouseDown);\n entry.removeEventListener(\"mousedown\", handleEndMouseDown);\n };\n }, [activeEditableLine, rootRef, setLineEditorState]);\n\n const controlPoints = useMemo(() => {\n return activeEditableLine &&\n !isStraightType(activeEditableLine.edge.view?.type)\n ? getControlPoints(activeEditableLine!.linePoints)\n : [];\n }, [activeEditableLine]);\n\n useEffect(() => {\n if (!activeEditableLine) {\n return;\n }\n const controlElements = controlPointsRef.current;\n const handleMouseDownFactory = (control: ControlPoint) => {\n return (e: MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n const rect = rootRef.current!.getBoundingClientRect();\n setLineEditorState({\n ...activeEditableLine!,\n offset: [rect.left, rect.top],\n from: [e.clientX, e.clientY],\n type: \"control\",\n control,\n });\n };\n };\n const handlers = controlPoints.map((control) =>\n handleMouseDownFactory(control)\n );\n controlElements.forEach((el, i) => {\n el?.addEventListener(\"mousedown\", handlers[i]);\n });\n return () => {\n controlElements.forEach((el, i) => {\n el?.removeEventListener(\"mousedown\", handlers[i]);\n });\n };\n }, [activeEditableLine, controlPoints, rootRef, setLineEditorState]);\n\n const gRef = useRef<SVGGElement>(null);\n useEffect(() => {\n const g = gRef.current;\n const onClick = (e: MouseEvent) => {\n e.stopPropagation();\n e.preventDefault();\n };\n g?.addEventListener(\"click\", onClick);\n return () => {\n g?.removeEventListener(\"click\", onClick);\n };\n }, []);\n\n if (!activeEditableLine) {\n return null;\n }\n const {\n linePoints,\n edge: { view },\n } = activeEditableLine;\n const { exitPosition, entryPosition } = view ?? {};\n\n const commonProps: React.SVGAttributes<SVGImageElement> = {\n width: POINT_HELPER_BG_SIZE / scale,\n height: POINT_HELPER_BG_SIZE / scale,\n preserveAspectRatio: \"none\",\n cursor: \"pointer\",\n pointerEvents: \"fill\",\n };\n const exitPoint = linePoints[0];\n const entryPoint = linePoints[linePoints.length - 1];\n const offset = POINT_HELPER_BG_SIZE / scale / 2;\n\n return (\n <g ref={gRef}>\n <image\n ref={exitRef}\n {...commonProps}\n x={exitPoint.x - offset}\n y={exitPoint.y - offset}\n xlinkHref={\n exitPosition ? ANCHORED_POINT_HELPER_IMAGE : POINT_HELPER_IMAGE\n }\n />\n {controlPoints.map((point, i) => (\n <image\n key={i}\n ref={(el) => {\n controlPointsRef.current[i] = el;\n }}\n {...commonProps}\n x={point.x - offset}\n y={point.y - offset}\n xlinkHref={VERTEX_HELPER_IMAGE}\n cursor={point.direction === \"ns\" ? \"row-resize\" : \"col-resize\"}\n />\n ))}\n <image\n ref={entryRef}\n {...commonProps}\n x={entryPoint.x - offset}\n y={entryPoint.y - offset}\n xlinkHref={\n entryPosition ? ANCHORED_POINT_HELPER_IMAGE : POINT_HELPER_IMAGE\n }\n />\n </g>\n );\n}\n\nfunction getControlPoints(linePoints: NodePosition[]): ControlPoint[] {\n const controlPoints: ControlPoint[] = [];\n let prev = linePoints[0];\n let cursor = 1;\n while (cursor < linePoints.length) {\n const next = linePoints[cursor];\n const ns = prev.y === next.y;\n const ew = prev.x === next.x;\n if (!(ns && ew)) {\n const direction = ns ? \"ns\" : \"ew\";\n controlPoints.push({\n direction,\n index: cursor - 1,\n x: (prev.x + next.x) / 2,\n y: (prev.y + next.y) / 2,\n });\n }\n prev = next;\n cursor++;\n }\n\n return controlPoints;\n}\n","// istanbul ignore file: experimental\nimport React, { useEffect, useMemo, useState } from \"react\";\nimport classNames from \"classnames\";\nimport type { ComputedLineConnecterConf, LineSettings } from \"./interfaces\";\nimport type {\n LineMarkerConf,\n PositionTuple,\n TransformLiteral,\n} from \"../diagram/interfaces\";\nimport { curveLine } from \"../diagram/lines/curveLine\";\nimport { useHoverStateContext } from \"./HoverStateContext\";\nimport { getConnectLinePoints } from \"../shared/canvas/processors/getConnectLinePoints\";\nimport { getMarkers } from \"../shared/canvas/useLineMarkers\";\n\nexport interface SmartConnectLineComponentProps {\n transform: TransformLiteral;\n lineSettings?: LineSettings;\n options: ComputedLineConnecterConf;\n}\n\nexport function SmartConnectLineComponent({\n transform,\n lineSettings,\n options,\n}: SmartConnectLineComponentProps): JSX.Element {\n const [connectLineTo, setConnectLineTo] = useState<PositionTuple | null>(\n null\n );\n const { hoverState, smartConnectLineState, setSmartConnectLineState } =\n useHoverStateContext();\n\n useEffect(() => {\n if (!smartConnectLineState) {\n return;\n }\n function onMouseMove(e: MouseEvent) {\n // Set connect line to based on the mouse position and the transform\n setConnectLineTo([\n (e.clientX - transform.x - smartConnectLineState!.offset[0]) /\n transform.k,\n (e.clientY - transform.y - smartConnectLineState!.offset[1]) /\n transform.k,\n ]);\n }\n function onMouseUp(e: MouseEvent) {\n e.preventDefault();\n reset();\n }\n function reset() {\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n setConnectLineTo(null);\n setSmartConnectLineState(null);\n }\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n\n return reset;\n }, [setSmartConnectLineState, smartConnectLineState, transform]);\n\n const line = useMemo(() => {\n const points = getConnectLinePoints(\n smartConnectLineState,\n connectLineTo,\n hoverState,\n lineSettings\n );\n return curveLine(\n points,\n options.type === \"curve\" ? options.curveType : \"curveLinear\",\n 0,\n 1\n );\n }, [connectLineTo, hoverState, smartConnectLineState, options, lineSettings]);\n\n let markerStart: string | undefined;\n let markerEnd: string | undefined;\n const lineMarkers: LineMarkerConf[] = getMarkers(options);\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart = options.$markerStartUrl;\n } else {\n markerEnd = options.$markerEndUrl;\n }\n }\n\n return (\n <path\n className={classNames(\"connect-line\", {\n connecting: !!(smartConnectLineState && connectLineTo),\n })}\n d={line}\n fill=\"none\"\n stroke={options.strokeColor}\n strokeWidth={options.strokeWidth}\n markerStart={markerStart}\n markerEnd={markerEnd}\n />\n );\n}\n","import type { NodePosition, PositionTuple } from \"../../../diagram/interfaces\";\nimport type { HoverState } from \"../../../draw-canvas/HoverStateContext\";\nimport type {\n LineSettings,\n SmartConnectLineState,\n} from \"../../../draw-canvas/interfaces\";\nimport { getSmartLinePoints } from \"./getSmartLinePoints\";\n\nexport function getConnectLinePoints(\n smartConnectLineState: SmartConnectLineState | null,\n connectLineTo: PositionTuple | null,\n hoverState: HoverState | null,\n lineSettings?: LineSettings\n): NodePosition[] | null {\n if (\n !smartConnectLineState ||\n !(connectLineTo || hoverState?.activePointIndex !== undefined)\n ) {\n return null;\n }\n\n const sourceView = smartConnectLineState.source.view;\n if (hoverState?.activePointIndex !== undefined) {\n return getSmartLinePoints(sourceView, hoverState.cell.view, {\n ...lineSettings,\n exitPosition: smartConnectLineState.exitPosition,\n entryPosition: hoverState.relativePoints[hoverState.activePointIndex],\n });\n }\n\n const [x1, y1] = connectLineTo!;\n\n return getSmartLinePoints(\n sourceView,\n { x: x1, y: y1, width: 0, height: 0 },\n {\n ...lineSettings,\n exitPosition: smartConnectLineState.exitPosition,\n }\n );\n}\n","export const SYMBOL_FOR_SIZE_INITIALIZED = Symbol.for(\"size-initialized\");\nexport const SYMBOL_FOR_LAYOUT_INITIALIZED = Symbol.for(\"layout-initialized\");\nexport const DEFAULT_NODE_SIZE = 20;\nexport const DEFAULT_NODE_GAP = 36;\nexport const DEFAULT_AREA_WIDTH = 180;\nexport const DEFAULT_AREA_HEIGHT = 120;\nexport const DEFAULT_SCALE_RANGE_MIN = 0.5;\nexport const DEFAULT_SCALE_RANGE_MAX = 2;\nexport const DEFAULT_LINE_STROKE_COLOR = \"gray\";\nexport const DEFAULT_LINE_STROKE_WIDTH = 1;\nexport const DEFAULT_LINE_INTERACT_STROKE_WIDTH = 15;\nexport const DEFAULT_LINE_INTERACT_SHOW_START_ARROW = false;\nexport const DEFAULT_LINE_INTERACT_SHOW_END_ARROW = true;\nexport const DEFAULT_LINE_INTERACT_ANIMATE_DURATION = 1;\nexport const DEFAULT_DEGRADED_THRESHOLD = 500;\nexport const DEFAULT_SNAP_GRID_SIZE = 10;\nexport const DEFAULT_SNAP_OBJECT_DISTANCE = 5;\n/** Padding left + padding right, as well as top + bottom */\nexport const DEFAULT_NODE_PADDING_FOR_LINES = 5;\n/** Padding left + padding right, as well as top + bottom */\nexport const DEFAULT_NODE_PADDING_FOR_SMART_LINES = 0;\n\nexport const POINT_HELPER_RADIUS = 5;\n","import type {\n Cell,\n DecoratorCell,\n EdgeCell,\n InitialCell,\n InitialNodeCell,\n LayoutType,\n LineType,\n NodeCell,\n} from \"../interfaces\";\nimport { MoveCellPayload } from \"../reducers/interfaces\";\n\nexport function isNodeCell(cell: Cell | MoveCellPayload): cell is NodeCell {\n return cell.type === \"node\";\n}\n\nexport function isDecoratorCell(cell: Cell): cell is DecoratorCell {\n return cell.type === \"decorator\";\n}\n\nexport function isInitialNodeCell(cell: InitialCell): cell is InitialNodeCell {\n return cell.type === \"node\";\n}\n\nexport function isEdgeCell(cell: Cell): cell is EdgeCell {\n return cell.type === \"edge\";\n}\n\nexport function isNodeOrEdgeCell(cell: Cell): cell is NodeCell | EdgeCell {\n return cell.type === \"node\" || cell.type === \"edge\";\n}\n\nexport function isNodeOrAreaDecoratorCell(\n cell: Cell\n): cell is NodeCell | DecoratorCell {\n return (\n cell.type === \"node\" ||\n (cell.type === \"decorator\" && cell.decorator === \"area\")\n );\n}\n\nexport function isEdgeSide(\n cell: Cell,\n allowEdgeToArea: boolean | undefined\n): cell is NodeCell | DecoratorCell {\n return (\n cell.type === \"node\" ||\n (!!allowEdgeToArea &&\n cell.type === \"decorator\" &&\n cell.decorator === \"area\")\n );\n}\n\nexport function isNodeOrTextDecoratorCell(\n cell: Cell | MoveCellPayload\n): cell is NodeCell | DecoratorCell {\n return (\n cell.type === \"node\" ||\n (cell.type === \"decorator\" && cell.decorator === \"text\")\n );\n}\n\nexport function isTextDecoratorCell(cell: Cell): cell is DecoratorCell {\n return cell.type === \"decorator\" && cell.decorator === \"text\";\n}\nexport function isContainerDecoratorCell(\n cell: Cell | MoveCellPayload\n): cell is DecoratorCell {\n return cell.type === \"decorator\" && cell.decorator === \"container\";\n}\n\nexport function isNoManualLayout(layout: LayoutType) {\n return ![\"manual\", undefined].includes(layout!);\n}\n\nexport function isStraightType(type: LineType | undefined) {\n return !(type === \"polyline\" || type === \"curve\");\n}\n","import { pick } from \"lodash\";\nimport type { ActiveTargetOfSingular, Cell } from \"../interfaces\";\n\nexport function cellToTarget(cell: Cell): ActiveTargetOfSingular {\n return cell.type === \"edge\"\n ? pick(cell, [\"type\", \"source\", \"target\", \"data\"])\n : pick(cell, [\"type\", \"id\", \"data\"]);\n}\n","import type { ActiveTarget, Cell, ConnectLineState } from \"../interfaces\";\nimport { targetIsActive } from \"./targetIsActive\";\n\nexport function getUnrelatedCells(\n cells: Cell[],\n connectLineState: ConnectLineState | null,\n activeTarget: ActiveTarget | null,\n allowEdgeToArea?: boolean\n): Cell[] {\n const unrelated: Cell[] = [];\n if (connectLineState) {\n const existedTargets = new Set<string>();\n for (const cell of cells) {\n if (cell.type === \"edge\" && cell.source === connectLineState.source.id) {\n existedTargets.add(cell.target);\n }\n }\n for (const cell of cells) {\n switch (cell.type) {\n case \"node\":\n if (existedTargets.has(cell.id)) {\n unrelated.push(cell);\n }\n break;\n case \"decorator\":\n if (\n !allowEdgeToArea ||\n cell.decorator == \"text\" ||\n existedTargets.has(cell.id)\n ) {\n unrelated.push(cell);\n }\n break;\n default:\n unrelated.push(cell);\n }\n }\n } else {\n switch (activeTarget?.type) {\n case \"multi\": {\n const nodesMap = new Map<string, Cell>();\n const activeNodeIds = new Set<string>();\n const relatedNodeIds = new Set<string>();\n for (const active of activeTarget.targets) {\n if (active.type === \"node\") {\n activeNodeIds.add(active.id);\n relatedNodeIds.add(active.id);\n }\n }\n for (const cell of cells) {\n if (cell.type === \"node\") {\n nodesMap.set(cell.id, cell);\n } else if (cell.type === \"edge\") {\n if (activeNodeIds.has(cell.source)) {\n relatedNodeIds.add(cell.target);\n } else if (activeNodeIds.has(cell.target)) {\n relatedNodeIds.add(cell.source);\n } else if (!targetIsActive(cell, activeTarget)) {\n unrelated.push(cell);\n }\n } else if (!targetIsActive(cell, activeTarget)) {\n unrelated.push(cell);\n }\n }\n for (const [id, cell] of nodesMap) {\n if (!relatedNodeIds.has(id)) {\n unrelated.push(cell);\n }\n }\n break;\n }\n\n case \"node\": {\n const nodesMap = new Map<string, Cell>();\n const relatedNodeIds = new Set<string>([activeTarget.id]);\n for (const cell of cells) {\n if (cell.type === \"node\") {\n nodesMap.set(cell.id, cell);\n } else if (cell.type === \"edge\") {\n if (cell.source === activeTarget.id) {\n relatedNodeIds.add(cell.target);\n } else if (cell.target === activeTarget.id) {\n relatedNodeIds.add(cell.source);\n } else {\n unrelated.push(cell);\n }\n } else {\n unrelated.push(cell);\n }\n }\n for (const [id, cell] of nodesMap) {\n if (!relatedNodeIds.has(id)) {\n unrelated.push(cell);\n }\n }\n break;\n }\n\n case \"edge\":\n for (const cell of cells) {\n if (\n !(cell.type === \"edge\"\n ? targetIsActive(cell, activeTarget)\n : cell.type === \"node\" &&\n (cell.id === activeTarget.source ||\n cell.id === activeTarget.target))\n ) {\n unrelated.push(cell);\n }\n }\n break;\n }\n }\n\n return unrelated;\n}\n","import type { ActiveTarget, Cell } from \"../interfaces\";\nimport { targetIsActive } from \"./targetIsActive\";\n\nexport type KeyboardAction = KeyboardActionDeleteCells;\n\nexport interface KeyboardActionDeleteCells {\n action: \"delete-cells\";\n cells: Cell[];\n}\n\nexport function handleKeyboard(\n event: KeyboardEvent,\n {\n cells,\n activeTarget,\n }: {\n cells: Cell[];\n activeTarget: ActiveTarget | null | undefined;\n }\n): KeyboardAction | undefined {\n const activeCells = cells.filter((cell) =>\n targetIsActive(cell, activeTarget)\n );\n\n if (activeCells.length === 0) {\n return;\n }\n\n const key =\n event.key ||\n /* istanbul ignore next: compatibility */ event.keyCode ||\n /* istanbul ignore next: compatibility */ event.which;\n\n switch (key) {\n case \"Backspace\":\n case 8:\n case \"Delete\":\n case 46: {\n event.preventDefault();\n event.stopPropagation();\n return {\n action: \"delete-cells\",\n cells: activeCells,\n };\n }\n }\n}\n","import type { PositionTuple, TransformLiteral } from \"../../diagram/interfaces\";\nimport type { NodeView } from \"../interfaces\";\n\nexport interface HandleLassoOptions {\n transform: TransformLiteral;\n offset: PositionTuple;\n onLassoing(rect: NodeView): void;\n onLassoed(rect: NodeView): void;\n}\n\nexport function handleLasso(\n event: MouseEvent,\n { transform, offset, onLassoing, onLassoed }: HandleLassoOptions\n) {\n if (event.ctrlKey || event.button) {\n return;\n }\n\n event.stopPropagation();\n\n const from: PositionTuple = [event.clientX, event.clientY];\n const x0 = (event.clientX - offset[0] - transform.x) / transform.k;\n const y0 = (event.clientY - offset[1] - transform.y) / transform.k;\n\n function getMovement(e: MouseEvent): PositionTuple {\n return [\n (e.clientX - from[0]) / transform.k,\n (e.clientY - from[1]) / transform.k,\n ];\n }\n\n let moved = false;\n\n const handleMove = (e: MouseEvent, finished?: boolean) => {\n // Respect the scale\n const movement = getMovement(e);\n if (!moved) {\n moved = movement[0] ** 2 + movement[1] ** 2 >= 9;\n }\n if (moved) {\n let [width, height] = movement;\n let x = x0;\n let y = y0;\n if (width < 0) {\n x = x0 + width;\n width = -width;\n }\n if (height < 0) {\n y = y0 + height;\n height = -height;\n }\n (finished ? onLassoed : onLassoing)({\n x,\n y,\n width,\n height,\n });\n }\n };\n\n const onMouseMove = (e: MouseEvent) => {\n handleMove(e);\n };\n const onMouseUp = (e: MouseEvent) => {\n handleMove(e, true);\n moved = false;\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n };\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n}\n","import { Cell, DecoratorCell, NodeCell } from \"../interfaces\";\nimport { MoveCellPayload } from \"../reducers/interfaces\";\nimport { isContainerDecoratorCell, isNodeCell } from \"./asserts\";\n\nexport function handleNodeContainedChange(\n payloads: MoveCellPayload[],\n cells: Cell[],\n onContainerContainerChange?: (detail: MoveCellPayload[]) => void\n) {\n const nodeCells = cells.filter((c): c is NodeCell => isNodeCell(c));\n const containerIds = payloads\n .filter((p) => isContainerDecoratorCell(p))\n .map((v) => v.id);\n const nodePayloads = payloads.filter((p) => {\n const nodeCell = nodeCells.find((v) => v.id === p.id)!;\n const includeNodeFlag =\n nodeCell?.containerId && containerIds.includes(nodeCell.containerId);\n return isNodeCell(p) && !includeNodeFlag;\n });\n nodePayloads.forEach((payload) => {\n const left = payload.x;\n const right = payload.x + payload.width!;\n const top = payload.y;\n const bottom = payload.y + payload!.height!;\n const containerDecoratorCells = cells.filter(\n (cell): cell is DecoratorCell => isContainerDecoratorCell(cell)\n );\n for (const containerCell of containerDecoratorCells) {\n const containerLeft = containerCell.view.x;\n const containerRight = containerCell.view.x + containerCell.view.width;\n const containerTop = containerCell.view.y;\n const containerBottom = containerCell.view.y + containerCell.view.height;\n if (\n left >= containerLeft &&\n right <= containerRight &&\n top >= containerTop &&\n bottom <= containerBottom\n ) {\n payload.containerCell = containerCell;\n break; //A node can be associated with only one container\n }\n }\n });\n let containedChanges = [];\n containedChanges = nodePayloads.filter((payload) => {\n const nodeCell = nodeCells.find((c) => c.id === payload.id);\n const containerId = nodeCell?.containerId;\n const containerCellId = payload.containerCell?.id;\n //过滤掉一直没有combo关系或者combo关系没有改变的\n return containerId !== containerCellId;\n });\n if (containedChanges.length > 0) {\n onContainerContainerChange?.(containedChanges);\n }\n return containedChanges;\n}\n","import type { SizeTuple } from \"../../diagram/interfaces\";\nimport type { Cell, InitialCell, NodeCell } from \"../interfaces\";\nimport { isInitialNodeCell } from \"./asserts\";\n\nexport function initializeCells(\n initialCells: InitialCell[] | undefined,\n {\n defaultNodeSize,\n }: {\n defaultNodeSize: SizeTuple;\n }\n): Cell[] {\n const originalCells = initialCells ?? [];\n const finalCells: Cell[] = originalCells.map<Cell>((cell) => {\n if (\n !isInitialNodeCell(cell) ||\n (cell.view?.width !== undefined && cell.view?.height !== undefined)\n ) {\n return cell as NodeCell;\n }\n return {\n ...cell,\n view: {\n width: defaultNodeSize[0],\n height: defaultNodeSize[1],\n ...cell.view,\n },\n } as NodeCell;\n });\n return finalCells;\n}\n","import type {\n ActiveTarget,\n ActiveTargetOfEdge,\n ActiveTargetOfMulti,\n ActiveTargetOfNode,\n} from \"../interfaces\";\n\nexport function sameTarget(\n a: ActiveTarget | null | undefined,\n b: ActiveTarget | null | undefined\n): boolean {\n return a\n ? !!b &&\n a.type === b.type &&\n (a.type === \"multi\"\n ? a.targets.length === (b as ActiveTargetOfMulti).targets.length &&\n a.targets.every((targetA) =>\n (b as ActiveTargetOfMulti).targets.some((targetB) =>\n sameTarget(targetA, targetB)\n )\n )\n : a.type === \"node\" || a.type === \"decorator\"\n ? a.id === (b as ActiveTargetOfNode).id\n : a.source === (b as ActiveTargetOfEdge).source &&\n a.target === (b as ActiveTargetOfEdge).target)\n : !b;\n}\n","import type { ActiveTarget, ActiveTargetOfSingular } from \"../interfaces\";\nimport { sameTarget } from \"./sameTarget\";\n\nexport function targetIsActive(\n target: ActiveTargetOfSingular,\n activeTarget: ActiveTarget | null | undefined\n): boolean {\n return (\n !!activeTarget &&\n (activeTarget.type === \"multi\"\n ? activeTarget.targets\n : [activeTarget]\n ).some((active) => sameTarget(active, target))\n );\n}\n","import type { TransformLiteral } from \"../../diagram/interfaces\";\nimport type { Cell } from \"../interfaces\";\nimport { isEdgeCell } from \"./asserts\";\n\nexport interface TransformToCenterOptions {\n canvasWidth: number;\n canvasHeight: number;\n scaleRange?: [min: number, max: number];\n}\n\nexport function transformToCenter(\n cells: Cell[],\n { canvasWidth, canvasHeight, scaleRange }: TransformToCenterOptions\n): TransformLiteral {\n let left = Infinity;\n let top = Infinity;\n let right = -Infinity;\n let bottom = -Infinity;\n let empty = true;\n for (const cell of cells) {\n if (!isEdgeCell(cell)) {\n empty = false;\n const { view } = cell;\n const r = view.x + view.width;\n const b = view.y + view.height;\n if (view.x < left) {\n left = view.x;\n }\n if (r > right) {\n right = r;\n }\n if (view.y < top) {\n top = view.y;\n }\n if (b > bottom) {\n bottom = b;\n }\n }\n }\n\n const width = right - left;\n const height = bottom - top;\n\n const scale =\n scaleRange && !empty && (width > canvasWidth || height > canvasHeight)\n ? Math.max(\n Math.min(canvasWidth / width, canvasHeight / height, scaleRange[1]),\n scaleRange[0]\n )\n : 1;\n\n const x = empty ? 0 : (canvasWidth - width * scale) / 2 - left * scale;\n const y = empty ? 0 : (canvasHeight - height * scale) / 2 - top * scale;\n\n return { x, y, k: scale };\n}\n","import { without } from \"lodash\";\nimport type {\n RangeTuple,\n SizeTuple,\n TransformLiteral,\n} from \"../../diagram/interfaces\";\nimport { DEFAULT_NODE_GAP, SYMBOL_FOR_SIZE_INITIALIZED } from \"../constants\";\nimport type {\n Cell,\n InitialCell,\n LayoutType,\n NodeCell,\n NodeId,\n NodeView,\n} from \"../interfaces\";\nimport { isDecoratorCell, isEdgeCell, isNodeCell } from \"./asserts\";\nimport { initializeCells } from \"./initializeCells\";\nimport { transformToCenter } from \"./transformToCenter\";\nimport { forceLayout } from \"../../shared/canvas/forceLayout\";\nimport { dagreLayout } from \"../../shared/canvas/dagreLayout\";\nimport { sameTarget } from \"./sameTarget\";\n\nexport function updateCells({\n cells,\n layout,\n previousCells,\n defaultNodeSize,\n canvasWidth,\n canvasHeight,\n scaleRange,\n transform,\n reason,\n parent,\n allowEdgeToArea,\n}: {\n cells: InitialCell[] | undefined;\n layout?: LayoutType;\n previousCells: Cell[];\n defaultNodeSize: SizeTuple;\n canvasWidth: number;\n canvasHeight: number;\n scaleRange: RangeTuple;\n transform: TransformLiteral;\n reason?: \"add-related-nodes\";\n parent?: NodeId;\n allowEdgeToArea?: boolean;\n}): {\n cells: Cell[];\n updated: Cell[];\n shouldReCenter: boolean;\n} {\n const isManualLayout = layout !== \"force\" && layout !== \"dagre\";\n const newCells = initializeCells(cells, { defaultNodeSize });\n const updateCandidates: NodeCell[] = [];\n let shouldReCenter = false;\n\n const previousSizeInitializedNodes = new Map<string, NodeCell>();\n let previousShouldCentered = false;\n for (const cell of previousCells) {\n if (isDecoratorCell(cell)) {\n previousShouldCentered = true;\n } else if (isNodeCell(cell)) {\n previousShouldCentered = true;\n if (cell[SYMBOL_FOR_SIZE_INITIALIZED]) {\n previousSizeInitializedNodes.set(cell.id, cell);\n }\n }\n }\n\n const nodesMap = new Map<string, NodeCell>();\n for (const cell of newCells) {\n if (isNodeCell(cell)) {\n nodesMap.set(cell.id, cell);\n const previousNode = previousSizeInitializedNodes.get(cell.id);\n if (previousNode) {\n cell.view.width = previousNode.view.width;\n cell.view.height = previousNode.view.height;\n cell[SYMBOL_FOR_SIZE_INITIALIZED] = true;\n }\n }\n }\n\n let handled = false;\n\n if (reason === \"add-related-nodes\" && parent) {\n // Place these unpositioned downstream nodes below the parent node, and\n // on the right side of the positioned siblings.\n const downstreamNodeIds = new Set<string>();\n for (const cell of newCells) {\n if (\n isEdgeCell(cell) &&\n cell.source === parent &&\n cell.target !== parent\n ) {\n downstreamNodeIds.add(cell.target);\n }\n }\n const parentNode = nodesMap.get(parent);\n if (parentNode?.view.x !== undefined && parentNode.view.y !== undefined) {\n handled = true;\n /**\n * 临时解决一次性添加多层的节点手工布局报错\n */\n if (isManualLayout) {\n for (const cell of newCells) {\n if (\n (isNodeCell(cell) && cell.view.x === undefined) ||\n (isNodeCell(cell) && cell.view.y === undefined)\n ) {\n downstreamNodeIds.add(cell.id);\n }\n }\n }\n const downstreamNodes = [...downstreamNodeIds]\n .map((id) => nodesMap.get(id))\n .filter(Boolean) as NodeCell[];\n let rightMostNode: NodeCell | undefined = undefined;\n for (const node of downstreamNodes) {\n if (node.view.x !== undefined && node.view.y !== undefined) {\n // Find the rightmost node that is below the parent node.\n if (\n (!rightMostNode || node.view.x > rightMostNode.view.x) &&\n node.view.y > parentNode.view.y\n ) {\n rightMostNode = node;\n }\n } else {\n // Unpositioned nodes\n updateCandidates.push(node);\n }\n }\n if (updateCandidates.length > 0 && isManualLayout) {\n let nextX: number;\n let nextY: number;\n if (rightMostNode) {\n // Place unpositioned nodes on the right side of the rightmost positioned siblings.\n nextX =\n rightMostNode.view.x + rightMostNode.view.width + DEFAULT_NODE_GAP;\n nextY = rightMostNode.view.y;\n } else {\n // If there are no positioned siblings, just place them below the parent.\n const totalWidth = updateCandidates.reduce(\n (acc, node) => acc + node.view.width + DEFAULT_NODE_GAP,\n -DEFAULT_NODE_GAP\n );\n nextX =\n parentNode.view.x - totalWidth / 2 + parentNode.view.width / 2;\n nextY = parentNode.view.y + parentNode.view.height + DEFAULT_NODE_GAP;\n }\n for (const node of updateCandidates) {\n node.view.x = nextX;\n node.view.y = nextY;\n nextX += node.view.width + DEFAULT_NODE_GAP;\n }\n }\n }\n }\n\n if (!handled) {\n // By default, place unpositioned nodes in a grid.\n let maxWidth = defaultNodeSize[0];\n let maxHeight = defaultNodeSize[1];\n const positionedNodes: NodeCell[] = [];\n let hasDecorators = false;\n for (const cell of newCells) {\n if (isNodeCell(cell)) {\n if (cell.view.width > maxWidth) {\n maxWidth = cell.view.width;\n }\n if (cell.view.height > maxHeight) {\n maxHeight = cell.view.height;\n }\n if (cell.view.x === undefined || cell.view.y === undefined) {\n updateCandidates.push(cell);\n } else {\n positionedNodes.push(cell);\n }\n } else if (isDecoratorCell(cell)) {\n hasDecorators = true;\n }\n }\n\n if (isManualLayout) {\n if (!previousShouldCentered) {\n // If the previous cells are not centered, use the centered transform instead.\n transform = transformToCenter(without(newCells, ...updateCandidates), {\n canvasWidth,\n canvasHeight,\n scaleRange,\n });\n }\n\n let getNodeView: (id: NodeId) => NodeView;\n\n // If there is no positioned nodes, or only one while without decorators,\n // then there is no relative positions, we can place the nodes with dagre layout.\n // Otherwise, use the force layout.\n if (\n positionedNodes.length === 0 ||\n (positionedNodes.length === 1 && !hasDecorators)\n ) {\n // The positioned node (if exists) will be updated.\n updateCandidates.push(...positionedNodes);\n ({ getNodeView } = dagreLayout({ cells: newCells, allowEdgeToArea }));\n // Only re-center when there is no cells previous,\n // or the cell ids are not changed (this happens when updateCells called by backend right after dropNode).\n shouldReCenter =\n previousCells.length === 0 ||\n (previousCells.length === newCells.length &&\n previousCells.every((cell, index) =>\n sameTarget(cell, newCells[index])\n ));\n } else {\n ({ getNodeView } = forceLayout({\n cells: newCells,\n fixedPosition: true,\n allowEdgeToArea,\n center: [\n (canvasWidth / 2 - transform.x) / transform.k,\n (canvasHeight / 2 - transform.y) / transform.k,\n ],\n }));\n }\n\n for (const cell of newCells) {\n if (isNodeCell(cell)) {\n const view = getNodeView(cell.id);\n cell.view.x = view.x;\n cell.view.y = view.y;\n }\n }\n }\n }\n\n return { cells: newCells, updated: updateCandidates, shouldReCenter };\n}\n","import type { Reducer } from \"react\";\nimport type { DrawCanvasAction } from \"./interfaces\";\nimport type { Cell, EdgeCell, NodeCell } from \"../interfaces\";\nimport { isNodeCell } from \"../processors/asserts\";\nimport { SYMBOL_FOR_SIZE_INITIALIZED } from \"../constants\";\n\nexport const cells: Reducer<Cell[], DrawCanvasAction> = (state, action) => {\n switch (action.type) {\n case \"drop-node\":\n return insertCellAfter(\n state,\n action.payload,\n (cell) => !(cell.type === \"decorator\" && cell.decorator === \"text\")\n );\n case \"drop-decorator\": {\n if (action.payload.decorator === \"text\") {\n return [...state, action.payload];\n }\n return insertCellAfter(\n state,\n action.payload,\n (cell) => cell.type === \"decorator\" && cell.decorator === \"area\"\n );\n }\n case \"add-nodes\": {\n const index =\n state.findLastIndex(\n (cell) => !(cell.type === \"decorator\" && cell.decorator === \"text\")\n ) + 1;\n return [\n ...state.slice(0, index),\n ...action.payload,\n ...state.slice(index),\n ];\n }\n case \"add-edge\": {\n const existedEdgeIndex = state.findIndex(\n (cell) =>\n cell.type === \"edge\" &&\n cell.source === action.payload.source &&\n cell.target === action.payload.target\n );\n if (existedEdgeIndex === -1) {\n // Add the edge to just next to the previous last edge or area decorator.\n // If not found, append to the start.\n return insertCellAfter(\n state,\n action.payload,\n (cell) =>\n cell.type === \"edge\" ||\n (cell.type === \"decorator\" && cell.decorator === \"area\")\n );\n }\n return [\n ...state.slice(0, existedEdgeIndex),\n action.payload,\n ...state.slice(existedEdgeIndex + 1),\n ];\n }\n case \"change-edge-view\": {\n const existedEdgeIndex = state.findIndex(\n (cell) =>\n cell.type === \"edge\" &&\n cell.source === action.payload.source &&\n cell.target === action.payload.target\n );\n return existedEdgeIndex === -1\n ? state\n : [\n ...state.slice(0, existedEdgeIndex),\n {\n ...(state[existedEdgeIndex] as EdgeCell),\n view: {\n ...(state[existedEdgeIndex] as EdgeCell).view,\n ...action.payload.view,\n },\n },\n ...state.slice(existedEdgeIndex + 1),\n ];\n }\n case \"move-cells\": {\n let matched = false;\n const newState = state.map((cell) => {\n const newCell = action.payload.find(\n (move) => cell.type === move.type && cell.id === move.id\n );\n if (newCell) {\n matched = true;\n return {\n ...(cell as NodeCell),\n view: { ...(cell as NodeCell).view, x: newCell.x, y: newCell.y },\n };\n }\n return cell;\n });\n return matched ? newState : state;\n }\n case \"resize-cell\": {\n const { type, id, width, height } = action.payload;\n const index = state.findIndex(\n (cell) => cell.type === type && cell.id === id\n );\n if (index !== -1) {\n const node = state[index] as NodeCell;\n return [\n ...state.slice(0, index),\n { ...node, view: { ...node.view, width, height } },\n ...state.slice(index + 1),\n ];\n }\n return state;\n }\n case \"update-cells\":\n return action.payload;\n case \"update-node-size\":\n return state.map((cell) =>\n isNodeCell(cell) && cell.id === action.payload.id\n ? {\n ...cell,\n [SYMBOL_FOR_SIZE_INITIALIZED]: true,\n view: action.payload.size\n ? {\n ...cell.view,\n width: action.payload.size[0],\n height: action.payload.size[1],\n }\n : cell.view,\n }\n : cell\n );\n }\n return state;\n};\n\nfunction insertCellAfter(\n cells: Cell[],\n newCell: Cell,\n after: (cell: Cell) => boolean\n) {\n const index = cells.findLastIndex(after) + 1;\n return [...cells.slice(0, index), newCell, ...cells.slice(index)];\n}\n","import { Reducer } from \"react\";\nimport type { DrawCanvasAction, DrawCanvasState } from \"./interfaces\";\nimport { cells } from \"./cells\";\nimport { layoutKey } from \"./layoutKey\";\n\ntype ReducersMapObject<S, A> = {\n [K in keyof S]: Reducer<S[K], A>;\n};\n\nfunction combineReducers<S, A>(\n reducers: ReducersMapObject<S, A>\n): Reducer<S, A> {\n return ((state, action) =>\n Object.fromEntries(\n Object.entries<Reducer<any, A>>(reducers).map(([key, value]) => [\n key,\n value(state[key as keyof S], action),\n ])\n )) as Reducer<S, A>;\n}\n\nexport const rootReducer = combineReducers<DrawCanvasState, DrawCanvasAction>({\n cells,\n layoutKey,\n});\n","import type { Reducer } from \"react\";\nimport type { DrawCanvasAction } from \"./interfaces\";\n\nexport const layoutKey: Reducer<number, DrawCanvasAction> = (state, action) => {\n switch (action.type) {\n case \"update-node-size\":\n return action.layoutKey;\n default:\n return state;\n }\n};\n","import * as React from \"react\";\nconst SvgCenter = props => <svg xmlns=\"http://www.w3.org/2000/svg\" width={24} height={24} viewBox=\"0 0 24 24\" {...props}><path d=\"M12 0a.5.5 0 0 1 .5.5v2.013a9.5 9.5 0 0 1 8.987 8.988L23.5 11.5a.5.5 0 0 1 0 1h-2.013a9.5 9.5 0 0 1-8.987 8.987V23.5a.5.5 0 0 1-1 0v-2.013A9.5 9.5 0 0 1 2.514 12.5H.5a.5.5 0 0 1 0-1h2.013A9.5 9.5 0 0 1 11.5 2.514V.5A.5.5 0 0 1 12 0M3.514 11.5H7.5a.5.5 0 0 1 0 1H3.514a8.5 8.5 0 0 0 7.987 7.986L11.5 16.5a.5.5 0 0 1 1 0v3.986a8.5 8.5 0 0 0 7.986-7.986H16.5a.5.5 0 0 1 0-1h3.986A8.5 8.5 0 0 0 12.5 3.515V7.5a.5.5 0 0 1-1 0V3.514a8.5 8.5 0 0 0-7.986 7.987zm8.486-1a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3\" /></svg>;\nexport default SvgCenter;","import * as React from \"react\";\nconst SvgZoomIn = props => <svg xmlns=\"http://www.w3.org/2000/svg\" width={128} height={128} className=\"icon\" viewBox=\"0 0 1024 1024\" {...props}><path d=\"M512 76.8A435.2 435.2 0 1 0 947.2 512 435.71 435.71 0 0 0 512 76.8m0 819.2a384 384 0 1 1 384-384 384 384 0 0 1-384 384\" /><path d=\"M744.448 486.4h-204.8V281.6a25.6 25.6 0 1 0-51.2 0v204.8h-204.8a25.6 25.6 0 0 0 0 51.2h204.8v204.8a25.6 25.6 0 0 0 51.2 0V537.6h204.8a25.6 25.6 0 0 0 0-51.2\" /></svg>;\nexport default SvgZoomIn;","import * as React from \"react\";\nconst SvgZoomOut = props => <svg xmlns=\"http://www.w3.org/2000/svg\" width={128} height={128} className=\"icon\" viewBox=\"0 0 1024 1024\" {...props}><path d=\"M512 76.8A435.2 435.2 0 1 0 947.2 512 435.71 435.71 0 0 0 512 76.8m0 819.2a384 384 0 1 1 384-384 384 384 0 0 1-384 384\" /><path d=\"M744.448 486.4H280.064a25.6 25.6 0 1 0 0 51.2h464.384a25.6 25.6 0 0 0 0-51.2\" /></svg>;\nexport default SvgZoomOut;","import React, { useCallback, useMemo, useRef } from \"react\";\nimport { ConfigProvider, Slider, theme } from \"antd\";\nimport { StyleProvider, createCache } from \"@ant-design/cssinjs\";\nimport { useCurrentTheme } from \"@next-core/react-runtime\";\nimport type { RangeTuple } from \"../../diagram/interfaces\";\nimport CenterSVG from \"./icons/center.svg\";\nimport ZoomInSVG from \"./icons/zoom-in.svg\";\nimport ZoomOutSVG from \"./icons/zoom-out.svg\";\n\nexport interface ZoomBarComponentProps {\n shadowRoot: ShadowRoot;\n scale: number;\n scaleRange: RangeTuple;\n onZoomChange(value: number): void;\n onReCenter(): void;\n}\n\nexport function ZoomBarComponent({\n shadowRoot,\n scale,\n scaleRange,\n onZoomChange,\n onReCenter,\n}: ZoomBarComponentProps): JSX.Element | null {\n const currentTheme = useCurrentTheme();\n const cache = useMemo(() => createCache(), []);\n const zoomBarRef = useRef<HTMLDivElement | null>(null);\n const min = scaleRange[0] * 100;\n const max = scaleRange[1] * 100;\n const value = scale * 100;\n const step = 5;\n\n const tooltip = useMemo(() => {\n return {\n formatter: (value: number | undefined) => `${value}%`,\n placement: \"left\" as const,\n getPopupContainer: () => zoomBarRef.current!,\n };\n }, []);\n\n const onZoomIn = useCallback(() => {\n onZoomChange(Math.min(value + step, max));\n }, [max, onZoomChange, value]);\n\n const onZoomOut = useCallback(() => {\n onZoomChange(Math.max(value - step, min));\n }, [min, onZoomChange, value]);\n\n return (\n <ConfigProvider\n theme={{\n algorithm:\n currentTheme === \"dark-v2\"\n ? theme.darkAlgorithm\n : theme.defaultAlgorithm,\n }}\n >\n <StyleProvider\n container={shadowRoot}\n // Auto clear injected styles after unmount\n autoClear\n cache={cache}\n // Set hashPriority to \"high\" to disable `:where()` usage for compatibility\n hashPriority=\"high\"\n >\n <div className=\"zoom-bar\" ref={zoomBarRef}>\n <div className=\"center-button\" onClick={onReCenter} role=\"button\">\n <CenterSVG />\n </div>\n <div className=\"zoom-slider\">\n <div className=\"zoom-button\" role=\"button\" onClick={onZoomIn}>\n <ZoomInSVG />\n </div>\n <Slider\n min={min}\n max={max}\n value={value}\n step={step}\n vertical\n included={false}\n tooltip={tooltip}\n onChange={onZoomChange}\n />\n <div className=\"zoom-button\" role=\"button\" onClick={onZoomOut}>\n <ZoomOutSVG />\n </div>\n </div>\n </div>\n </StyleProvider>\n </ConfigProvider>\n );\n}\n","import { pick } from \"lodash\";\nimport dagre from \"@dagrejs/dagre\";\nimport { extractPartialRectTuple } from \"../../diagram/processors/extractPartialRectTuple\";\nimport type {\n Cell,\n ForceNode,\n LayoutOptionsDagre,\n NodeId,\n NodeView,\n} from \"../../draw-canvas/interfaces\";\nimport {\n isEdgeCell,\n isNodeCell,\n isNodeOrAreaDecoratorCell,\n} from \"../../draw-canvas/processors/asserts\";\nimport type { FullRectTuple } from \"../../diagram/interfaces\";\n\nexport interface DagreLayoutOptions {\n cells: Cell[];\n layoutOptions?: LayoutOptionsDagre;\n allowEdgeToArea?: boolean;\n}\n\nexport function dagreLayout({\n cells,\n layoutOptions,\n allowEdgeToArea,\n}: DagreLayoutOptions): {\n getNodeView: (id: NodeId) => NodeView;\n nodePaddings: FullRectTuple;\n} {\n const { nodePadding, ...dagreGraphOptions } = {\n nodePadding: 0,\n rankdir: \"TB\",\n ranksep: 50,\n edgesep: 10,\n nodesep: 50,\n // align: undefined,\n ...pick(layoutOptions, [\n \"nodePadding\",\n \"rankdir\",\n \"ranksep\",\n \"edgesep\",\n \"nodesep\",\n \"align\",\n ]),\n };\n const nodePaddings = extractPartialRectTuple(nodePadding);\n\n if (!cells.some(isNodeCell)) {\n // Dagre cannot render empty nodes\n return {\n getNodeView: () => null!,\n nodePaddings,\n };\n }\n\n const graph = new dagre.graphlib.Graph<ForceNode>();\n graph.setGraph(dagreGraphOptions);\n // Default to assigning a new object as a label for each new edge.\n graph.setDefaultEdgeLabel(function () {\n return {};\n });\n for (const cell of cells) {\n if (\n (allowEdgeToArea && isNodeOrAreaDecoratorCell(cell)) ||\n isNodeCell(cell)\n ) {\n graph.setNode(cell.id, {\n id: cell.id,\n width: cell.view.width + nodePaddings[1] + nodePaddings[3],\n height: cell.view.height + nodePaddings[0] + nodePaddings[2],\n });\n } else if (isEdgeCell(cell)) {\n graph.setEdge(cell.source, cell.target);\n }\n }\n dagre.layout(graph);\n\n return {\n getNodeView: (id: NodeId) => graph.node(id),\n nodePaddings,\n };\n}\n","import { pick } from \"lodash\";\nimport {\n forceCollide,\n forceLink,\n forceManyBody,\n forceSimulation,\n forceX,\n forceY,\n type Simulation,\n} from \"d3-force\";\nimport type {\n Cell,\n ForceCollideOptions,\n ForceLink,\n ForceNode,\n LayoutOptionsForce,\n NodeId,\n NodeView,\n} from \"../../draw-canvas/interfaces\";\nimport {\n isEdgeCell,\n isNodeCell,\n isNodeOrAreaDecoratorCell,\n} from \"../../draw-canvas/processors/asserts\";\nimport { extractPartialRectTuple } from \"../../diagram/processors/extractPartialRectTuple\";\nimport type { FullRectTuple, PositionTuple } from \"../../diagram/interfaces\";\n\nexport interface ForceLayoutOptions {\n cells: Cell[];\n layoutOptions?: LayoutOptionsForce;\n center?: PositionTuple;\n fixedPosition?: boolean;\n allowEdgeToArea?: boolean;\n}\n\nexport function forceLayout({\n cells,\n layoutOptions,\n center,\n fixedPosition,\n allowEdgeToArea,\n}: ForceLayoutOptions): {\n getNodeView: (id: NodeId) => NodeView;\n nodePaddings: FullRectTuple;\n} {\n const { nodePadding, collide } = {\n nodePadding: 0,\n ...pick(layoutOptions, [\"nodePadding\"]),\n collide:\n layoutOptions?.collide !== false\n ? ({\n radiusDiff: 18,\n strength: 1,\n iterations: 1,\n ...(layoutOptions?.collide === true\n ? null\n : (layoutOptions?.collide as ForceCollideOptions)),\n } as Required<ForceCollideOptions>)\n : (false as const),\n };\n const nodePaddings = extractPartialRectTuple(nodePadding);\n const forceNodes: ForceNode[] = [];\n const forceLinks: ForceLink[] = [];\n const nodesMap = new Map<NodeId, ForceNode>();\n for (const cell of cells) {\n if (\n (allowEdgeToArea && isNodeOrAreaDecoratorCell(cell)) ||\n isNodeCell(cell)\n ) {\n const node: ForceNode = {\n id: cell.id,\n width: cell.view.width + nodePaddings[1] + nodePaddings[3],\n height: cell.view.height + nodePaddings[0] + nodePaddings[2],\n ...(fixedPosition ? { fx: cell.view.x, fy: cell.view.y } : null),\n };\n forceNodes.push(node);\n nodesMap.set(node.id, node);\n } else if (isEdgeCell(cell)) {\n forceLinks.push({ source: cell.source, target: cell.target });\n }\n }\n\n const linkSimulation = forceLink<ForceNode, ForceLink>(forceLinks).id(\n (d) => d.id\n );\n const simulation = forceSimulation<ForceNode, ForceLink>(forceNodes)\n .force(\"link\", linkSimulation)\n .force(\"x\", forceX(center?.[0]))\n .force(\"y\", forceY(center?.[1]))\n .force(\"charge\", forceManyBody());\n\n if (collide) {\n simulation.force(\n \"collide\",\n forceCollide<ForceNode>()\n .radius(\n (d) =>\n Math.sqrt(d.width ** 2 + d.height ** 2) / 2 + collide.radiusDiff\n )\n .strength(collide.strength)\n .iterations(collide.iterations)\n );\n }\n\n simulation.stop();\n manuallyTickToTheEnd(simulation);\n\n return {\n getNodeView: (id: NodeId) => nodesMap.get(id) as NodeView,\n nodePaddings,\n };\n}\n\nfunction manuallyTickToTheEnd(\n simulation: Simulation<ForceNode, ForceLink>\n): void {\n // Manually tick to the end.\n simulation.tick(\n Math.ceil(\n Math.log(simulation.alphaMin()) / Math.log(1 - simulation.alphaDecay())\n )\n );\n}\n","import type { NodeRect } from \"../../../diagram/interfaces\";\nimport type { NodeView } from \"../../../draw-canvas/interfaces\";\n\nexport function nodeViewToNodeRect(view: NodeView, padding: number): NodeRect {\n return {\n x: view.x + view.width / 2,\n y: view.y + view.height / 2,\n width: view.width + padding,\n height: view.height + padding,\n };\n}\n","import { pull } from \"lodash\";\nimport type { NodePosition } from \"../../../diagram/interfaces\";\nimport { getConnectPointsOfRectangleWithDirection } from \"../shapes/Rectangle\";\nimport type {\n BiDirection,\n EdgeView,\n NodeView,\n} from \"../../../draw-canvas/interfaces\";\nimport { getPolyLinePoints } from \"../../../diagram/lines/getPolyLinePoints\";\nimport { nodeViewToNodeRect } from \"./nodeViewToNodeRect\";\nimport {\n DEFAULT_NODE_PADDING_FOR_LINES,\n DEFAULT_NODE_PADDING_FOR_SMART_LINES,\n} from \"../../../draw-canvas/constants\";\nimport { getDirectLinePoints } from \"../../../diagram/lines/getDirectLinePoints\";\nimport { isStraightType } from \"../../../draw-canvas/processors/asserts\";\n\nconst DEFAULT_DIRECTIONS = [\"right\", \"top\", \"left\", \"bottom\"] as const;\n\nexport function getSmartLinePoints(\n sourceView: NodeView,\n targetView: NodeView,\n edgeView: EdgeView | undefined,\n parallelGap?: number\n): NodePosition[] | null {\n const {\n type,\n vertices,\n exitPosition: originalExit,\n entryPosition: originalEntry,\n } = edgeView ?? {};\n\n if (isStraightType(type)) {\n return getDirectLinePoints(\n nodeViewToNodeRect(\n sourceView,\n originalExit\n ? DEFAULT_NODE_PADDING_FOR_SMART_LINES\n : DEFAULT_NODE_PADDING_FOR_LINES\n ),\n nodeViewToNodeRect(\n targetView,\n originalEntry\n ? DEFAULT_NODE_PADDING_FOR_SMART_LINES\n : DEFAULT_NODE_PADDING_FOR_LINES\n ),\n parallelGap,\n edgeView\n );\n }\n\n if (vertices?.length) {\n const firstVertex = vertices[0];\n const lastVertex = vertices[vertices.length - 1];\n\n let exitPoint: NodePosition;\n let entryPoint: NodePosition;\n let exitDirection: BiDirection | undefined;\n let entryDirection: BiDirection | undefined;\n\n // Auto decide the exit and entry position.\n if (originalExit) {\n exitPoint = getAbsolutePosition(sourceView, originalExit);\n } else {\n let possibleFirstNextPoint: NodePosition | undefined;\n if (vertices.length > 1) {\n // Decide exit point by the first two vertices.\n possibleFirstNextPoint = vertices[1];\n } else if (originalEntry) {\n // Decide exit point by the entry position.\n possibleFirstNextPoint = getAbsolutePosition(targetView, originalEntry);\n }\n if (possibleFirstNextPoint) {\n exitPoint = getDefaultAbsolutePosition(\n firstVertex,\n sourceView,\n firstVertex.y === possibleFirstNextPoint.y\n );\n } else {\n // No other vertices nor the entry position, decide exit point by the\n // relative position between the last vertex and the target node.\n const prefer =\n lastVertex.y < targetView.y ||\n lastVertex.y > targetView.y + targetView.height\n ? \"ns\"\n : \"ew\";\n ({ point: exitPoint, direction: exitDirection } =\n fitEndpointAndDirection(sourceView, targetView, vertices, prefer));\n }\n }\n\n if (originalEntry) {\n entryPoint = getAbsolutePosition(targetView, originalEntry);\n } else {\n let possibleLastPreviousPoint: NodePosition | undefined;\n if (vertices.length > 1) {\n // Decide entry point by the last two vertices.\n possibleLastPreviousPoint = vertices[vertices.length - 2];\n } else if (originalExit) {\n // Decide entry point by the exit position.\n possibleLastPreviousPoint = getAbsolutePosition(\n sourceView,\n originalExit\n );\n }\n if (possibleLastPreviousPoint) {\n entryPoint = getDefaultAbsolutePosition(\n lastVertex,\n targetView,\n lastVertex.y === possibleLastPreviousPoint.y\n );\n } else {\n // No other vertices nor the exit position, decide entry point by the\n // relative position between the first vertex and the source node.\n const prefer =\n firstVertex.x < sourceView.x ||\n firstVertex.x > sourceView.x + sourceView.width\n ? \"ew\"\n : \"ns\";\n ({ point: entryPoint, direction: entryDirection } =\n fitEndpointAndDirection(\n targetView,\n sourceView,\n vertices.slice().reverse(),\n prefer\n ));\n }\n }\n\n const { x: sourceX, y: sourceY } = exitPoint;\n const { x: targetX, y: targetY } = entryPoint;\n\n const newLinePoints = [exitPoint, ...vertices, entryPoint];\n\n const newVertices = [...vertices];\n\n // If the first vertex is not on any axis of the source exit point,\n // add a vertex to connect them.\n if (firstVertex && firstVertex.x !== sourceX && firstVertex.y !== sourceY) {\n newVertices.unshift(\n exitDirection === \"ns\"\n ? { x: sourceX, y: firstVertex.y }\n : exitDirection === \"ew\"\n ? { x: firstVertex.x, y: sourceY }\n : firstVertex.x === newLinePoints[2].x\n ? { x: sourceX, y: firstVertex.y }\n : { x: firstVertex.x, y: sourceY }\n );\n }\n\n // If the last vertex is not on any axis of the target entry point,\n // add a vertex to connect them.\n if (lastVertex && lastVertex.x !== targetX && lastVertex.y !== targetY) {\n newVertices.push(\n entryDirection === \"ns\"\n ? { x: targetX, y: lastVertex.y }\n : entryDirection === \"ew\"\n ? { x: lastVertex.x, y: targetY }\n : lastVertex.x === newLinePoints[newLinePoints.length - 3].x\n ? { x: targetX, y: lastVertex.y }\n : { x: lastVertex.x, y: targetY }\n );\n }\n\n return [\n exitPoint,\n ...simplifyVertices(exitPoint, newVertices, entryPoint),\n entryPoint,\n ];\n }\n\n const exitPosition =\n originalExit ?? getDefaultPosition(targetView, sourceView);\n const entryPosition =\n originalEntry ?? getDefaultPosition(sourceView, targetView);\n\n const { x: sourceX, y: sourceY } = getAbsolutePosition(\n sourceView,\n exitPosition\n );\n const { x: targetX, y: targetY } = getAbsolutePosition(\n targetView,\n entryPosition\n );\n\n const connectPoints = getConnectPointsOfRectangleWithDirection();\n const originalSourceDirections =\n connectPoints.find((p) => p.x === exitPosition.x && p.y === exitPosition.y)\n ?.d ?? DEFAULT_DIRECTIONS;\n const originalTargetDirections =\n connectPoints.find(\n (p) => p.x === entryPosition.x && p.y === entryPosition.y\n )?.d ?? DEFAULT_DIRECTIONS;\n const sourceDirections = [...originalSourceDirections];\n const targetDirections = [...originalTargetDirections];\n\n if (sourceX < targetX) {\n pull(sourceDirections, \"left\");\n pull(targetDirections, \"right\");\n } else {\n pull(sourceDirections, \"right\");\n pull(targetDirections, \"left\");\n }\n\n if (sourceY < targetY) {\n pull(sourceDirections, \"top\");\n pull(targetDirections, \"bottom\");\n } else {\n pull(sourceDirections, \"bottom\");\n pull(targetDirections, \"top\");\n }\n\n const sourceDirection = sourceDirections[0] ?? originalSourceDirections[0];\n const targetDirection = targetDirections[0] ?? originalTargetDirections[0];\n\n const sourcePosition =\n sourceDirection === \"left\" || sourceDirection === \"right\"\n ? exitPosition.y\n : exitPosition.x;\n const targetPosition =\n targetDirection === \"left\" || targetDirection === \"right\"\n ? entryPosition.y\n : entryPosition.x;\n\n return getPolyLinePoints(\n nodeViewToNodeRect(sourceView, DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n nodeViewToNodeRect(targetView, DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n sourceDirection,\n targetDirection,\n sourcePosition,\n targetPosition\n );\n}\n\nexport function simplifyVertices(\n exitPoint: NodePosition,\n vertices: NodePosition[],\n entryPoint: NodePosition\n): NodePosition[] {\n // Simplify the vertices, ignore all vertices that its previous and next points are on the same axis\n // E.g, ignore two vertices of index 1 and index 3 for the following line.\n // 0---1---2\n // |\n // 3\n // |\n // 4\n const simplifiedVertices: NodePosition[] = [];\n let prev = exitPoint;\n let prevDirection: \"ns\" | \"ew\" | undefined;\n let index = 0;\n while (index < vertices.length) {\n const vertex = vertices[index];\n const isHorizontal = vertex.x !== prev.x;\n const isVertical = vertex.y !== prev.y;\n if (isHorizontal || isVertical) {\n const direction = isHorizontal ? \"ew\" : \"ns\";\n if (direction !== prevDirection) {\n const next =\n index === vertices.length - 1 ? entryPoint : vertices[index + 1];\n const isHorizontalNext = next.x !== vertex.x;\n const isVerticalNext = next.y !== vertex.y;\n if (isHorizontalNext || isVerticalNext) {\n const nextDirection = isHorizontalNext ? \"ew\" : \"ns\";\n if (direction !== nextDirection) {\n prevDirection = direction;\n simplifiedVertices.push(vertex);\n prev = vertex;\n }\n }\n }\n }\n index++;\n }\n\n return simplifiedVertices;\n}\n\nfunction getDefaultPosition(\n sourceView: NodeView,\n targetView: NodeView\n): NodePosition {\n if (targetView.y + targetView.height < sourceView.y) {\n return { x: 0.5, y: 1 };\n }\n if (targetView.y > sourceView.y + sourceView.height) {\n return { x: 0.5, y: 0 };\n }\n return targetView.x < sourceView.x ? { x: 1, y: 0.5 } : { x: 0, y: 0.5 };\n}\n\nfunction getAbsolutePosition(view: NodeView, position: NodePosition) {\n const halfPadding = DEFAULT_NODE_PADDING_FOR_SMART_LINES / 2;\n return {\n x:\n view.x -\n halfPadding +\n position.x * (view.width + DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n y:\n view.y -\n halfPadding +\n position.y * (view.height + DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n };\n}\n\nfunction getDefaultAbsolutePosition(\n sourceView: NodePosition,\n targetView: NodeView,\n flip?: boolean\n): NodePosition {\n let xAxis: \"x\" | \"y\";\n let yAxis: \"x\" | \"y\";\n let xSize: \"width\" | \"height\";\n let ySize: \"width\" | \"height\";\n if (flip) {\n xAxis = \"y\";\n yAxis = \"x\";\n xSize = \"height\";\n ySize = \"width\";\n } else {\n xAxis = \"x\";\n yAxis = \"y\";\n xSize = \"width\";\n ySize = \"height\";\n }\n let position: NodePosition | undefined;\n if (targetView[yAxis] + targetView[ySize] < sourceView[yAxis]) {\n position = { [xAxis]: 0.5, [yAxis]: 1 } as unknown as NodePosition;\n }\n if (targetView[yAxis] > sourceView[yAxis]) {\n position = { [xAxis]: 0.5, [yAxis]: 0 } as unknown as NodePosition;\n }\n if (position) {\n return getAbsolutePosition(targetView, position);\n }\n\n const xPosition = targetView[xAxis] < sourceView[xAxis] ? 1 : 0;\n\n return {\n [xAxis]:\n targetView[xAxis] -\n DEFAULT_NODE_PADDING_FOR_SMART_LINES / 2 +\n xPosition * (targetView[xSize] + DEFAULT_NODE_PADDING_FOR_SMART_LINES),\n [yAxis]: sourceView[yAxis],\n } as unknown as NodePosition;\n}\n\nfunction fitEndpointAndDirection(\n view: NodeView,\n oppositeView: NodeView,\n vertices: NodePosition[],\n prefer: BiDirection\n): { point: NodePosition; direction: BiDirection } {\n let point: NodePosition;\n let direction: BiDirection;\n\n let xAxis: \"x\" | \"y\";\n let yAxis: \"x\" | \"y\";\n let xSize: \"width\" | \"height\";\n let ySize: \"width\" | \"height\";\n let nsDirection: BiDirection;\n let ewDirection: BiDirection;\n if (prefer === \"ns\") {\n xAxis = \"x\";\n yAxis = \"y\";\n xSize = \"width\";\n ySize = \"height\";\n nsDirection = \"ns\";\n ewDirection = \"ew\";\n } else {\n xAxis = \"y\";\n yAxis = \"x\";\n xSize = \"height\";\n ySize = \"width\";\n nsDirection = \"ew\";\n ewDirection = \"ns\";\n }\n const vertex = vertices[0];\n\n if (\n vertex[xAxis] >= view[xAxis] &&\n vertex[xAxis] <= view[xAxis] + view[xSize]\n ) {\n if (vertex[yAxis] > view[yAxis] + view[ySize]) {\n point = {\n [xAxis]: vertex[xAxis],\n [yAxis]: view[yAxis] + view[ySize],\n } as unknown as NodePosition;\n direction = nsDirection;\n } else if (vertex[yAxis] < view[yAxis]) {\n point = {\n [xAxis]: vertex[xAxis],\n [yAxis]: view[yAxis],\n } as unknown as NodePosition;\n direction = nsDirection;\n } else {\n const nextVertex = vertices[1] ?? oppositeView;\n point = {\n [xAxis]: vertex[xAxis],\n [yAxis]:\n nextVertex[yAxis] < vertex[yAxis]\n ? vertex[yAxis]\n : view[yAxis] + view[ySize],\n } as unknown as NodePosition;\n direction = nsDirection;\n }\n } else {\n if (vertex[yAxis] < view[yAxis]) {\n point = {\n [xAxis]: view[xAxis] + view[xSize] / 2,\n [yAxis]: view[yAxis],\n } as unknown as NodePosition;\n direction = nsDirection;\n } else if (vertex[yAxis] > view[yAxis] + view[ySize]) {\n point = {\n [xAxis]: view[xAxis] + view[xSize] / 2,\n [yAxis]: view[yAxis] + view[ySize],\n } as unknown as NodePosition;\n direction = nsDirection;\n } else if (vertex[xAxis] < view[xAxis]) {\n point = {\n [xAxis]: view[xAxis],\n [yAxis]: vertex[yAxis],\n } as unknown as NodePosition;\n direction = ewDirection;\n } else {\n point = {\n [xAxis]: view[xAxis] + view[xSize],\n [yAxis]: vertex[yAxis],\n } as unknown as NodePosition;\n direction = ewDirection;\n }\n }\n return { point, direction: direction };\n}\n","import type { NodePosition } from \"../../../diagram/interfaces\";\nimport type { NodeConnectPoint } from \"../../../draw-canvas/interfaces\";\n\n// *--*--*--*--*\n// | |\n// * *\n// | |\n// * Rect *\n// | |\n// * *\n// | |\n// *--*--*--*--*\nconst RectangleRelativeConnectPointsWithDirection: ReadonlyArray<NodeConnectPoint> =\n [\n {\n x: 0,\n y: 0,\n d: [\"top\", \"left\"],\n },\n { x: 0.5, y: 0, d: [\"top\"] },\n {\n x: 1,\n y: 0,\n d: [\"top\", \"right\"],\n },\n { x: 0, y: 0.5, d: [\"left\"] },\n { x: 1, y: 0.5, d: [\"right\"] },\n {\n x: 0,\n y: 1,\n d: [\"bottom\", \"left\"],\n },\n { x: 0.5, y: 1, d: [\"bottom\"] },\n {\n x: 1,\n y: 1,\n d: [\"bottom\", \"right\"],\n },\n ];\n\nconst RectangleRelativeConnectPoints: ReadonlyArray<NodePosition> =\n RectangleRelativeConnectPointsWithDirection.map((p) => ({ x: p.x, y: p.y }));\n\nexport function getConnectPointsOfRectangleWithDirection() {\n return RectangleRelativeConnectPointsWithDirection;\n}\n\nexport function getConnectPointsOfRectangle() {\n return RectangleRelativeConnectPoints;\n}\n","import React, { useEffect, useRef, useState } from \"react\";\nimport type { ActiveTarget } from \"../../draw-canvas/interfaces\";\nimport { sameTarget } from \"../../draw-canvas/processors/sameTarget\";\n\nexport interface UseActiveTargetOptions {\n rootRef: React.RefObject<SVGGElement>;\n activeTarget?: ActiveTarget | null;\n onActiveTargetChange(target: ActiveTarget | null): void;\n}\n\nexport type UseActiveTargetResult = ActiveTarget | null;\n\nexport function useActiveTarget({\n rootRef,\n activeTarget: _activeTarget,\n onActiveTargetChange,\n}: UseActiveTargetOptions): UseActiveTargetResult {\n const newActiveTarget = _activeTarget ?? null;\n const [activeTarget, setActiveTarget] = useState<ActiveTarget | null>(\n newActiveTarget\n );\n\n useEffect(() => {\n setActiveTarget((previous) =>\n sameTarget(previous, newActiveTarget) ? previous : newActiveTarget\n );\n }, [newActiveTarget]);\n\n const activeTargetChangeInitialized = useRef(false);\n useEffect(() => {\n if (!activeTargetChangeInitialized.current) {\n activeTargetChangeInitialized.current = true;\n return;\n }\n onActiveTargetChange(activeTarget);\n }, [activeTarget, onActiveTargetChange]);\n\n useEffect(() => {\n if (!activeTarget) {\n return;\n }\n const resetActiveTarget = (e: MouseEvent) => {\n const path = e.composedPath();\n const rootIndex = path.indexOf(rootRef.current!);\n // Reset active target to null when clicking outside of the cells container,\n // Or inside the cells container but not on any cell.\n if (rootIndex <= 0) {\n setActiveTarget(null);\n }\n };\n document.addEventListener(\"click\", resetActiveTarget);\n return () => {\n document.removeEventListener(\"click\", resetActiveTarget);\n };\n }, [activeTarget, rootRef]);\n\n return activeTarget;\n}\n","import type { AlignOrigin, NormalizedAlignOrigin } from \"../interfaces\";\n\nconst KeywordMap = new Map([\n [\"center\", 0.5],\n [\"left\", 0],\n [\"right\", 1],\n [\"top\", 0],\n [\"bottom\", 1],\n]);\n\nexport function normalizeAlignOrigin(\n alignOrigin: AlignOrigin | undefined\n): NormalizedAlignOrigin {\n const origin = alignOrigin ?? [0.5, 0.5];\n return [\n normalizeAlignAxis(origin[0], \"x\"),\n normalizeAlignAxis(origin[1], \"y\"),\n ];\n}\n\nfunction normalizeAlignAxis(value: string | number, axis: \"x\" | \"y\"): number {\n if (typeof value === \"string\") {\n const newX = KeywordMap.get(value);\n if (newX !== undefined) {\n return newX;\n }\n const matches = value.match(/^(-?\\d+(?:\\.\\d+)?)%$/);\n if (matches) {\n return Number(matches[1]) / 100;\n }\n // eslint-disable-next-line no-console\n console.error(\"Unexpected align origin %s:\", axis, value);\n } else if (typeof value === \"number\") {\n return value;\n } else {\n // eslint-disable-next-line no-console\n console.error(\n \"Unexpected align origin %s, expected %s, received %s:\",\n axis,\n \"string | number\",\n typeof value,\n value\n );\n }\n\n return 0.5;\n}\n","import { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { ZoomBehavior } from \"d3-zoom\";\nimport type {\n Cell,\n LayoutOptions,\n LayoutOptionsForce,\n LayoutOptionsDagre,\n LayoutType,\n NodeId,\n NodeView,\n} from \"../../draw-canvas/interfaces\";\nimport type { FullRectTuple, RangeTuple } from \"../../diagram/interfaces\";\nimport { useAutoCenter } from \"./useAutoCenter\";\nimport {\n isNodeCell,\n isNodeOrAreaDecoratorCell,\n isNodeOrEdgeCell,\n} from \"../../draw-canvas/processors/asserts\";\nimport {\n SYMBOL_FOR_LAYOUT_INITIALIZED,\n SYMBOL_FOR_SIZE_INITIALIZED,\n} from \"../../draw-canvas/constants\";\nimport type { DrawCanvasAction } from \"../../draw-canvas/reducers/interfaces\";\nimport { forceLayout } from \"./forceLayout\";\nimport { dagreLayout } from \"./dagreLayout\";\nimport { normalizeAlignOrigin } from \"../../draw-canvas/processors/normalizeAlignOrigin\";\n\nexport interface UseLayoutOptions {\n layout: LayoutType;\n layoutOptions?: LayoutOptions;\n rootRef: React.RefObject<SVGSVGElement>;\n cells: Cell[];\n zoomable?: boolean;\n zoomer: ZoomBehavior<SVGSVGElement, unknown>;\n scaleRange: RangeTuple;\n layoutKey: number;\n allowEdgeToArea?: boolean;\n dispatch: (value: DrawCanvasAction) => void;\n}\n\nexport function useLayout({\n layout,\n layoutOptions,\n rootRef,\n cells,\n zoomable,\n zoomer,\n scaleRange,\n layoutKey,\n allowEdgeToArea,\n dispatch,\n}: UseLayoutOptions) {\n const [layoutInitialized, setLayoutInitialized] = useState(\n layout !== \"force\" && layout !== \"dagre\"\n );\n\n const layoutKeyRef = useRef(layoutKey);\n\n const getNextLayoutKey = useCallback(() => {\n return ++layoutKeyRef.current;\n }, []);\n\n const [centered, setCentered] = useAutoCenter({\n rootRef,\n layoutInitialized,\n cells,\n zoomable,\n zoomer,\n scaleRange,\n });\n\n const previousLayoutRef = useRef<Cell[] | null>(null);\n\n useEffect(() => {\n // Wait for all nodes to be size-initialized before layout.\n if (\n cells.some(\n (cell) => isNodeCell(cell) && !cell[SYMBOL_FOR_SIZE_INITIALIZED]\n ) ||\n // Skip layout if no cells.\n cells.length === 0\n ) {\n return;\n }\n\n if (layout !== \"force\" && layout !== \"dagre\") {\n setLayoutInitialized(true);\n return;\n }\n\n // DO NOT re-layout if layout key mismatched.\n // DO NOT re-layout if nodes and edges not changed.\n if (\n layoutKeyRef.current !== layoutKey ||\n isSameArray(previousLayoutRef.current, cells.filter(isNodeOrEdgeCell))\n ) {\n // Layout key mismatch happens when this effect is performed after\n // update-node-size dispatched but not yet applied.\n // If didn't ignore mismatched layout, it will cause the update-cells\n // action overwrites those update-node-size actions.\n return;\n }\n\n let getNodeView: (id: NodeId) => NodeView;\n let nodePaddings: FullRectTuple;\n\n if (layout === \"force\") {\n ({ getNodeView, nodePaddings } = forceLayout({\n cells,\n layoutOptions: layoutOptions as LayoutOptionsForce,\n allowEdgeToArea,\n }));\n } else {\n ({ getNodeView, nodePaddings } = dagreLayout({\n cells,\n layoutOptions: layoutOptions as LayoutOptionsDagre,\n allowEdgeToArea,\n }));\n }\n\n const alignOrigin = normalizeAlignOrigin(\n (layoutOptions as LayoutOptionsForce | LayoutOptionsDagre)?.alignOrigin\n );\n\n const newCells: Cell[] = cells.map((cell) => {\n if (\n (allowEdgeToArea && isNodeOrAreaDecoratorCell(cell)) ||\n isNodeCell(cell)\n ) {\n const nodeView = getNodeView(cell.id);\n return {\n ...cell,\n view: {\n ...cell.view,\n x: nodeView.x! - nodeView.width * alignOrigin[0] + nodePaddings[3],\n y: nodeView.y! - nodeView.height * alignOrigin[1] + nodePaddings[0],\n },\n [SYMBOL_FOR_LAYOUT_INITIALIZED]: true,\n };\n }\n return cell;\n });\n previousLayoutRef.current = newCells.filter(isNodeOrEdgeCell);\n\n dispatch({ type: \"update-cells\", payload: newCells });\n // setCentered(false);\n setLayoutInitialized(true);\n }, [cells, dispatch, layout, layoutKey, layoutOptions /* , setCentered */]);\n\n return { centered, setCentered, getNextLayoutKey };\n}\n\nfunction isSameArray<T = unknown>(a: T[] | null, b: T[]): boolean {\n return a?.length === b.length && a.every((v, i) => v === b[i]);\n}\n","import React, { useEffect, useState } from \"react\";\nimport { select } from \"d3-selection\";\nimport { ZoomTransform, type ZoomBehavior } from \"d3-zoom\";\nimport type { RangeTuple } from \"../../diagram/interfaces\";\nimport { SYMBOL_FOR_SIZE_INITIALIZED } from \"../../draw-canvas/constants\";\nimport type { Cell } from \"../../draw-canvas/interfaces\";\nimport {\n isDecoratorCell,\n isNodeCell,\n} from \"../../draw-canvas/processors/asserts\";\nimport { transformToCenter } from \"../../draw-canvas/processors/transformToCenter\";\n\nexport interface UseAutoCenterOptions {\n rootRef: React.RefObject<SVGSVGElement>;\n cells: Cell[];\n layoutInitialized: boolean;\n zoomable?: boolean;\n zoomer: ZoomBehavior<SVGSVGElement, unknown>;\n scaleRange: RangeTuple;\n}\n\nexport type UseAutoCenterResult = [\n centered: boolean,\n setCentered: React.Dispatch<React.SetStateAction<boolean>>,\n];\n\nexport function useAutoCenter({\n rootRef,\n cells,\n layoutInitialized,\n zoomable,\n zoomer,\n scaleRange,\n}: UseAutoCenterOptions): UseAutoCenterResult {\n const [centered, setCentered] = useState(false);\n\n useEffect(() => {\n const root = rootRef.current;\n if (\n !root ||\n !layoutInitialized ||\n centered ||\n !cells.some((cell) => isNodeCell(cell) || isDecoratorCell(cell)) ||\n cells.some(\n (cell) => isNodeCell(cell) && !cell[SYMBOL_FOR_SIZE_INITIALIZED]\n )\n ) {\n return;\n }\n const { k, x, y } = transformToCenter(cells, {\n canvasWidth: root.clientWidth,\n canvasHeight: root.clientHeight,\n scaleRange: zoomable ? scaleRange : undefined,\n });\n // istanbul ignore next\n if (process.env.NODE_ENV !== \"test\") {\n // jsdom doesn't support svg baseVal yet.\n // https://github.com/jsdom/jsdom/issues/2531\n zoomer.transform(select(root), new ZoomTransform(k, x, y));\n }\n setCentered(true);\n }, [\n cells,\n centered,\n layoutInitialized,\n rootRef,\n scaleRange,\n zoomable,\n zoomer,\n ]);\n\n useEffect(() => {\n // Reset auto centering when nodes and decorators are all removed.\n if (!cells.some((cell) => isNodeCell(cell) || isDecoratorCell(cell))) {\n setCentered(false);\n }\n }, [cells]);\n\n return [centered, setCentered];\n}\n","import { useMemo } from \"react\";\nimport {\n __secret_internals,\n checkIfByTransform,\n checkIfOfComputed,\n} from \"@next-core/runtime\";\nimport { findIndex, isUndefined, omitBy } from \"lodash\";\nimport type {\n Cell,\n ComputedEdgeLineConf,\n ComputedLineConnecterConf,\n EdgeCell,\n EdgeLineConf,\n LineConnecterConf,\n LineMarker,\n} from \"../../draw-canvas/interfaces\";\nimport { isEdgeCell } from \"../../draw-canvas/processors/asserts\";\nimport {\n DEFAULT_LINE_STROKE_COLOR,\n DEFAULT_LINE_STROKE_WIDTH,\n DEFAULT_LINE_INTERACT_STROKE_WIDTH,\n DEFAULT_LINE_INTERACT_SHOW_START_ARROW,\n DEFAULT_LINE_INTERACT_SHOW_END_ARROW,\n DEFAULT_LINE_INTERACT_ANIMATE_DURATION,\n} from \"../../draw-canvas/constants\";\nimport { LineMarkerConf } from \"../../diagram/interfaces\";\n\nexport interface UseLineMarkersOptions {\n cells: Cell[];\n defaultEdgeLines: EdgeLineConf[] | undefined;\n markerPrefix: string;\n lineConnector?: LineConnecterConf | boolean;\n}\n\nexport function useLineMarkers({\n cells,\n defaultEdgeLines,\n markerPrefix,\n lineConnector,\n}: UseLineMarkersOptions): {\n lineConfMap: WeakMap<EdgeCell, ComputedEdgeLineConf>;\n lineConnectorConf: ComputedLineConnecterConf | null;\n markers: LineMarker[];\n} {\n return useMemo(() => {\n // Always put the default stroke marker at the first position,\n // since the connecting line will use it.\n const markers: LineMarker[] = [\n {\n strokeColor: DEFAULT_LINE_STROKE_COLOR,\n markerType: \"arrow\",\n },\n ];\n\n let lineConnectorConf: ComputedLineConnecterConf | null = null;\n if (lineConnector) {\n lineConnectorConf = {\n ...getDefaultLineConf(),\n editingStrokeColor: \"var(--palette-blue-5)\",\n ...omitBy(lineConnector === true ? {} : lineConnector, isUndefined),\n } as ComputedLineConnecterConf;\n const lineMarkers: LineMarkerConf[] = getMarkers(lineConnectorConf);\n for (const marker of lineMarkers) {\n const { placement, type: _type } = marker;\n const type = _type ?? \"arrow\";\n const markerIndex = addMarker(\n {\n strokeColor: lineConnectorConf.strokeColor,\n markerType: type,\n },\n markers\n );\n const editingMarkerIndex = addMarker(\n {\n strokeColor: lineConnectorConf.editingStrokeColor,\n markerType: type,\n },\n markers\n );\n if (placement === \"start\") {\n lineConnectorConf.$markerStartUrl = `url(#${markerPrefix}${markerIndex})`;\n lineConnectorConf.$editingStartMarkerUrl = `url(#${markerPrefix}${editingMarkerIndex})`;\n } else {\n lineConnectorConf.$markerEndUrl = `url(#${markerPrefix}${markerIndex})`;\n lineConnectorConf.$editingEndMarkerUrl = `url(#${markerPrefix}${editingMarkerIndex})`;\n }\n }\n }\n\n const map = new WeakMap<EdgeCell, ComputedEdgeLineConf>();\n for (const cell of cells) {\n if (isEdgeCell(cell)) {\n const computedLineConf =\n (Array.isArray(defaultEdgeLines)\n ? __secret_internals.legacyDoTransform(\n { edge: cell },\n defaultEdgeLines.find((item) =>\n checkIfByTransform(item, { edge: cell })\n )\n )\n : (\n __secret_internals.legacyDoTransform(\n { edge: cell },\n defaultEdgeLines\n ) as EdgeLineConf[]\n )?.find((item) => checkIfOfComputed(item))) ?? {};\n const lineConf = {\n ...getDefaultLineConf(),\n ...omitBy(computedLineConf, isUndefined),\n ...omitBy(cell.view, isUndefined),\n } as ComputedEdgeLineConf;\n if (lineConf.parallelGap === undefined) {\n lineConf.parallelGap = lineConf.interactStrokeWidth;\n }\n\n const lineMarkers: LineMarkerConf[] = getMarkers(lineConf);\n\n for (const marker of lineMarkers) {\n const { placement, type: _type } = marker;\n const type = _type ?? \"arrow\";\n const markerIndex = addMarker(\n {\n strokeColor: lineConf.strokeColor,\n markerType: type,\n },\n markers\n );\n if (placement === \"start\") {\n lineConf.$markerStartUrl = `url(#${markerPrefix}${markerIndex})`;\n } else {\n lineConf.$markerEndUrl = `url(#${markerPrefix}${markerIndex})`;\n }\n }\n map.set(cell, lineConf);\n }\n }\n return { lineConfMap: map, lineConnectorConf, markers };\n }, [cells, defaultEdgeLines, lineConnector, markerPrefix]);\n}\nexport function getMarkers(lineConf: ComputedEdgeLineConf): LineMarkerConf[] {\n let lineMarkers: LineMarkerConf[] = [];\n if (lineConf.markers) {\n lineMarkers = lineConf.markers;\n } else {\n if (lineConf.showStartArrow) {\n lineMarkers.push({\n type: \"arrow\",\n placement: \"start\",\n });\n }\n if (lineConf.showEndArrow) {\n lineMarkers.push({\n type: \"arrow\",\n placement: \"end\",\n });\n }\n }\n return lineMarkers;\n}\nfunction addMarker(marker: LineMarker, markers: LineMarker[]): number {\n let markerIndex = findIndex(markers, marker);\n if (markerIndex === -1) {\n markerIndex = markers.push(marker) - 1;\n }\n return markerIndex;\n}\n\nfunction getDefaultLineConf(): EdgeLineConf {\n return {\n type: \"straight\",\n dashed: false,\n strokeColor: DEFAULT_LINE_STROKE_COLOR,\n strokeWidth: DEFAULT_LINE_STROKE_WIDTH,\n interactStrokeWidth: DEFAULT_LINE_INTERACT_STROKE_WIDTH,\n showStartArrow: DEFAULT_LINE_INTERACT_SHOW_START_ARROW,\n showEndArrow: DEFAULT_LINE_INTERACT_SHOW_END_ARROW,\n animate: {\n useAnimate: false,\n duration: DEFAULT_LINE_INTERACT_ANIMATE_DURATION,\n },\n };\n}\n","import { useMemo } from \"react\";\nimport type { Cell, LayoutType } from \"../../draw-canvas/interfaces\";\nimport { isNodeCell } from \"../../draw-canvas/processors/asserts\";\nimport {\n SYMBOL_FOR_LAYOUT_INITIALIZED,\n SYMBOL_FOR_SIZE_INITIALIZED,\n} from \"../../draw-canvas/constants\";\n\nexport interface UseReadyOptions {\n cells: Cell[];\n layout: LayoutType;\n centered: boolean;\n}\n\nexport function useReady({ cells, layout, centered }: UseReadyOptions) {\n const ready = useMemo(\n () =>\n centered &&\n cells.every(\n (cell) =>\n !isNodeCell(cell) ||\n (cell[SYMBOL_FOR_SIZE_INITIALIZED] &&\n ((layout !== \"force\" && layout !== \"dagre\") ||\n cell[SYMBOL_FOR_LAYOUT_INITIALIZED]))\n ),\n [cells, centered, layout]\n );\n return ready;\n}\n","import React, { useEffect, useMemo, useState } from \"react\";\nimport { select } from \"d3-selection\";\nimport { zoom, type ZoomBehavior } from \"d3-zoom\";\nimport type { RangeTuple, TransformLiteral } from \"../../diagram/interfaces\";\nimport {\n DEFAULT_SCALE_RANGE_MIN,\n DEFAULT_SCALE_RANGE_MAX,\n} from \"../../draw-canvas/constants\";\nimport type { ActiveTarget } from \"../../draw-canvas/interfaces\";\n\nexport interface UseZoomOptions {\n rootRef: React.RefObject<SVGSVGElement>;\n zoomable?: boolean;\n scrollable?: boolean;\n pannable?: boolean;\n draggable?: boolean;\n ctrlDraggable?: boolean;\n scaleRange?: RangeTuple;\n onSwitchActiveTarget?(target: ActiveTarget | null): void;\n}\n\nexport interface UseZoomResult {\n grabbing: boolean;\n transform: TransformLiteral;\n scaleRange: RangeTuple;\n zoomer: ZoomBehavior<SVGSVGElement, unknown>;\n}\n\nexport function useZoom({\n rootRef,\n zoomable,\n scrollable,\n pannable,\n draggable,\n ctrlDraggable,\n scaleRange: _scaleRange,\n onSwitchActiveTarget,\n}: UseZoomOptions): UseZoomResult {\n const [grabbing, setGrabbing] = useState(false);\n const [transform, setTransform] = useState<TransformLiteral>({\n k: 1,\n x: 0,\n y: 0,\n });\n\n const scaleRange = useMemo(\n () =>\n _scaleRange ??\n ([DEFAULT_SCALE_RANGE_MIN, DEFAULT_SCALE_RANGE_MAX] as RangeTuple),\n [_scaleRange]\n );\n\n const zoomer = useMemo(() => zoom<SVGSVGElement, unknown>(), []);\n\n // istanbul ignore next: d3-zoom currently hard to test\n useEffect(() => {\n let moved = false;\n zoomer\n .scaleExtent(zoomable ? scaleRange : [1, 1])\n .on(\"start\", () => {\n moved = false;\n setGrabbing(true);\n })\n .on(\"zoom\", (e: { transform: TransformLiteral }) => {\n moved = true;\n setTransform(e.transform);\n })\n .on(\"end\", () => {\n setGrabbing(false);\n if (!moved) {\n onSwitchActiveTarget?.(null);\n }\n })\n .filter(\n (event) =>\n (event.type === \"wheel\" ||\n (ctrlDraggable ? draggable || event.ctrlKey : !event.ctrlKey)) &&\n !event.button\n );\n }, [\n onSwitchActiveTarget,\n scaleRange,\n zoomable,\n zoomer,\n ctrlDraggable,\n draggable,\n ]);\n\n useEffect(() => {\n if (ctrlDraggable) {\n const onContextMenu = (e: MouseEvent) => {\n if (e.ctrlKey) {\n e.preventDefault();\n }\n };\n document.addEventListener(\"contextmenu\", onContextMenu, true);\n return () => {\n document.removeEventListener(\"contextmenu\", onContextMenu, true);\n };\n }\n }, [ctrlDraggable]);\n\n // istanbul ignore next: d3-zoom currently hard to test\n useEffect(() => {\n const root = rootRef.current;\n if (!root) {\n return;\n }\n\n const rootSelection = select(root);\n\n const unsetZoom = () => {\n rootSelection\n .on(\".zoom\", null)\n .on(\".zoom.custom\", null)\n .on(\"wheel\", null);\n };\n\n if (!(zoomable || scrollable || pannable)) {\n unsetZoom();\n return;\n }\n\n if (zoomable || scrollable) {\n // Do not override default d3 zoom handler.\n // Only handles *panning*\n rootSelection.on(\n \"wheel.zoom.custom\",\n (e: WheelEvent & { wheelDeltaX: number; wheelDeltaY: number }) => {\n // Mac OS trackpad pinch event is emitted as a wheel.zoom and d3.event.ctrlKey set to true\n if (!e.ctrlKey) {\n // Stop immediate propagation for default d3 zoom handler\n e.stopImmediatePropagation();\n if (scrollable) {\n e.preventDefault();\n zoomer.translateBy(\n rootSelection,\n e.wheelDeltaX / 5,\n e.wheelDeltaY / 5\n );\n }\n }\n // zoomer.scaleBy(rootSelection, Math.pow(2, defaultWheelDelta(e)))\n }\n );\n }\n\n rootSelection\n .call(zoomer)\n .on(\"wheel\", (e: WheelEvent) => {\n e.preventDefault();\n })\n .on(\"dblclick.zoom\", null);\n\n if ((!draggable && !ctrlDraggable) || !pannable) {\n rootSelection.on(\"mousedown.zoom\", null);\n }\n\n if (!pannable) {\n rootSelection\n .on(\"touchstart.zoom\", null)\n .on(\"touchmove.zoom\", null)\n .on(\"touchend.zoom\", null);\n }\n\n return unsetZoom;\n }, [\n ctrlDraggable,\n draggable,\n pannable,\n rootRef,\n scrollable,\n zoomable,\n zoomer,\n ]);\n\n return { grabbing, transform, zoomer, scaleRange };\n}\n","// Imports\nimport ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from \"../../../../../node_modules/css-loader/dist/runtime/noSourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../../../../../node_modules/css-loader/dist/runtime/api.js\";\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `.zoom-bar{position:absolute;bottom:20px;right:20px;width:40px;scale:0.8}.zoom-slider,\n.center-button{width:100%;display:flex;align-items:center;border:1px solid var(--antd-background-color-base);border-radius:var(--larger-border-radius);box-shadow:var(--connected-overlay-shadow);background-color:var(--color-fill-bg-container-4)}.zoom-slider{height:140px;padding:8px 0;flex-direction:column}[role=\"button\"]{cursor:pointer}.center-button{justify-content:center;margin-bottom:8px;height:40px}.center-button:hover{border-color:var(--antd-btn-default-hover-border-color)}.center-button path{fill:var(--antd-link-hover-color)}.center-button:hover path{fill:var(--palette-blue-7)}.zoom-button{font-size:16px;line-height:0}.zoom-button svg{width:1em;height:1em;fill:var(--antd-link-hover-color)}.zoom-slider .ant-slider-vertical{padding-inline:5px}.zoom-slider .ant-slider-vertical .ant-slider-rail{width:2px}.zoom-slider .ant-slider-vertical .ant-slider-handle{width:6px;height:6px;inset-inline-start:3px}.zoom-slider .ant-slider .ant-slider-handle:hover::before,\n.zoom-slider .ant-slider .ant-slider-handle:focus::before,\n.zoom-slider .ant-slider .ant-slider-handle::before{width:10px;height:10px;inset-inline-start:-2px}.zoom-slider .ant-slider .ant-slider-handle:hover::after,\n.zoom-slider .ant-slider .ant-slider-handle:focus::after,\n.zoom-slider .ant-slider .ant-slider-handle::after{width:6px;height:6px;inset-block-start:0;inset-inline-start:0}`, \"\"]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___.toString();\n","// Imports\nimport ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from \"../../../../../node_modules/css-loader/dist/runtime/noSourceMaps.js\";\nimport ___CSS_LOADER_API_IMPORT___ from \"../../../../../node_modules/css-loader/dist/runtime/api.js\";\nvar ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `*{box-sizing:border-box}:host{display:block;position:relative;overflow:hidden;--animation-dasharray:48;--stroke-dashedoffset:96;--stroke-dottedoffset:24;--dasharray:4;--dotted:1}:host,\n.root{width:100%;height:100%}:host([hidden]){display:none}.root{opacity:0}.root.ready{opacity:1}.root:focus{outline:none}@keyframes solidAnimation{to{stroke-dashoffset:0}}@keyframes dashedAnimation{0%{stroke-dashoffset:var(--stroke-dashedoffset)}to{stroke-dashoffset:0}}@keyframes dottedAnimation{0%{stroke-dashoffset:var(--stroke-dottedoffset)}to{stroke-dashoffset:0}}.solid-animation{stroke-dasharray:var(--solid-length);stroke-dashoffset:var(--solid-length);animation:solidAnimation var(--time) linear infinite}.dashed-animation{animation:dashedAnimation var(--time) linear infinite}.dotted-animation{animation:dottedAnimation var(--time) linear infinite}.decorator-area .area,\n.decorator-container .container{fill:rgba(119,141,195,0.1);stroke:none;stroke-width:0}.node,\n.decorator-text{overflow:visible}.cell.active .decorator-area .area,\n.cell.active .decorator-container .container,\n.cell:not(.read-only) .decorator-container .container:hover,\n.allowEdgeToArea .decorator-area .area:hover,\n.cell.active .line-active-bg{stroke:var(--palette-blue-5);stroke-dasharray:var(--dasharray);stroke-width:1}.container-active .decorator-container .container{stroke:var(--palette-blue-5);stroke-width:1}.cell:not(.read-only){-webkit-user-select:none;user-select:none}.resize-handle{cursor:nwse-resize;opacity:0}.resize-handle rect{fill:transparent;stroke:none}.resize-handle path{fill:none;stroke:var(--palette-gray-5);stroke-width:1.5}.cell.active .decorator-area .resize-handle,\n.decorator-area:hover .resize-handle,\n.decorator-container:hover .resize-handle{opacity:1}.connect-line{pointer-events:none}.connect-line:not(.connecting){display:none}.editing-line{pointer-events:none;stroke-dasharray:var(--dasharray);stroke-width:1}.editing-line:not(.editing){display:none}.line.dashed{stroke-dasharray:var(--dasharray)}.line.dotted{stroke-dasharray:var(--dotted)}.cell.active .decorator-text .text-container{outline:1px dashed var(--palette-blue-5)}.decorator-text .text-container{width:max-content;padding:0.5em}.decorator-text .text:focus{outline:none}.cell.faded{opacity:0.3}.cell.container-active{opacity:1}.cell .node{pointer-events:none}.cell .node > *{position:fixed;pointer-events:auto}.degraded{pointer-events:bounding-box}.degraded circle{fill:rgb(119,141,195)}.degraded text{text-anchor:middle;fill:var(--antd-text-color)}.cell.active .degraded circle,\n.cell.active .degraded text,\n.degraded:hover circle,\n.degraded:hover text{fill:var(--color-brand)}.decorator-container{--defaultSize:24px}.decorator-container .text-container{display:flex;align-items:center;justify-content:center;padding:0.5em;text-align:center;font-size:16px;background-color:rgba(119,141,195,0.6);overflow:hidden}.decorator-container .horizontal{height:max-content;width:100%}:is(.decorator-container .horizontal) .text{min-height:var(--defaultSize)}.decorator-container .vertical{width:max-content;height:100%;writing-mode:vertical-lr;text-orientation:upright;letter-spacing:4px}:is(.decorator-container .vertical) .text{min-width:var(--defaultSize)}`, \"\"]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___.toString();\n"],"names":["findNodeOrAreaDecorator","cells","id","find","cell","isNodeOrAreaDecoratorCell","EdgeComponent","_ref","_pathRef$current","_pathRef$current$getT","edge","lineConfMap","active","setActiveEditableLine","useHoverStateContext","pathRef","useRef","sourceNode","useMemo","source","targetNode","target","lineConf","get","parallelGap","_edge$view","isStraightType","view","type","some","_cell$view","isEdgeCell","linePoints","x","getSmartLinePoints","line","fixedLineType","curveLine","curveType","useEffect","prev","lineType","lineCurveType","markerStart","markerEnd","lineMarkers","getMarkers","marker","placement","$markerStartUrl","$markerEndUrl","React","d","fill","stroke","strokeWidth","interactStrokeWidth","ref","className","classNames","dashed","dotted","animate","useAnimate","style","duration","DEFAULT_LINE_INTERACT_ANIMATE_DURATION","current","getTotalLength","call","strokeColor","NodeComponent","node","degraded","degradedNodeLabel","defaultNodeBricks","onResize","memoizedData","value","memoizedValue","setMemoizedValue","useState","isEqual","useDeepMemo","data","specifiedUseBrick","useBrick","observerRef","_defaultNodeBricks$fi","item","checkIfByTransform","label","String","__secret_internals","legacyDoTransform","refCallback","useCallback","element","prevObserver","disconnect","setTimeout","observer","ResizeObserver","offsetWidth","offsetHeight","observe","degradedRefCallBack","g","size","getBBox","width","height","ReactUseBrick","cx","cy","r","y","handleMouseDown","event","action","scale","layout","layoutOptions","activeTarget","onCellsMoving","onCellsMoved","onCellResizing","onCellResized","onSwitchActiveTarget","stopPropagation","targetIsActive","cellToTarget","activeCells","actives","filter","c","forEach","a","push","isContainerDecoratorCell","isNodeCell","containerId","includes","isAutoLayout","movableActiveCells","isDecoratorCell","length","snap","intermediateSnap","grid","object","snapToGrid","snapToObject","DEFAULT_SNAP_GRID_SIZE","distance","DEFAULT_SNAP_OBJECT_DISTANCE","normalizeSnapOptions","from","clientX","clientY","originals","map","position","center","getCenterPosition","firstOriginalPosition","previousPositions","_ref2","snapToObjectTargets","objectCells","moved","handleMove","e","finished","movement","getMovement","newPositions","xAlign","yAlign","xAlignCell","yAlignCell","altKey","_ref3","diffX","Infinity","diffY","snapMovement","snapToObjectDistance","xAlignFrom","yAlignFrom","xAlignTarget","yAlignTarget","xAlignToY","yAlignToX","dX","Math","abs","dY","ySnapped","halfHeight","halfWidth","snapToGridSize","firstNewPosition","round","snapToGridMovement","snapToGridDiffX","snapToGridDiffY","undefined","_ref4","_ref6","payloads","_ref5","index","decorator","guideLines","_ref7","onMouseMove","onMouseUp","document","removeEventListener","addEventListener","DecoratorArea","transform","readOnly","resizeHandleRef","resizeHandle","onMouseDown","k","DecoratorText","onDecoratorTextEditing","onDecoratorTextChange","text","currentLabel","setCurrentLabel","editingLabel","setEditingLabel","editingLabelInitialized","shouldEmitLabelChange","setShouldEmitLabelChange","handleEnableEdit","preventDefault","textContent","_ref$current","parentElement","clientWidth","clientHeight","focus","selectAllText","editing","handleInput","handleBlur","onDoubleClick","contentEditable","onInput","onBlur","range","createRange","selectNodeContents","selection","window","getSelection","removeAllRanges","addRange","DecoratorContainer","direction","textRef","recomputation","setRecomputation","titleForeignRect","setTitleForeignRect","uuidV4","_textRef$current","textParentEle","rect","isNoManualLayout","DecoratorComponent","SpecifiedComponent","console","error","computeContainerRect","minX","minY","maxX","maxY","n","isFinite","padding","CellComponent","dragNodeToContainerActive","unrelatedCells","allowEdgeToArea","onCellContextMenu","onCellClick","onNodeBrickResize","onCellMouseEnter","onCellMouseLeave","lineEditorState","smartConnectLineState","setSmartConnectLineState","onConnect","setLineEditorState","onChangeEdgeView","gRef","unrelated","sameTarget","containerRect","containCells","isEdgeSide","exitPosition","isEntry","entryPosition","handleContextMenu","handleCellClick","handleMouseEnter","handleMouseLeave","faded","onContextMenu","onClick","onMouseEnter","onMouseLeave","ConnectLineComponent","connectLineState","connectLineTo","setConnectLineTo","getConnectTo","offset","reset","capture","connecting","join","getNewLineVertices","control","newVertices","x1","y1","exitPoint","entryPoint","i","vertex","simplifyVertices","EditingLineComponent","options","activeEditableLine","hoverState","movedRef","diff","axis","original","otherPoints","_","snapDistance","point","newDiff","movementX","movementY","newConnectTo","vertices","handleBodyClick","body","_lineEditorState$edge","points","activePointIndex","lineSettings","pick","relativePoints","getEditingLinePoints","$editingStartMarkerUrl","$editingEndMarkerUrl","editingStrokeColor","HoverStateContext","rootRef","unsetHoverStateTimeoutRef","setHoverState","HELPER_IMAGE","HELPER_RADIUS","HELPER_BG_RADIUS","HALF_HELPER_RADIUS","LineConnectorComponent","disabled","unsetTimeout","clearTimeout","unsetActivePointIndex","unsetHoverState","available","targets","hasActiveEdge","DEFAULT_NODE_PADDING_FOR_SMART_LINES","halfPadding","pointerEvents","fillOpacity","ConnectPointComponent","key","getBoundingClientRect","originalPoint","left","top","handleMouseUp","xlinkHref","preserveAspectRatio","POINT_HELPER_IMAGE","ANCHORED_POINT_HELPER_IMAGE","VERTEX_HELPER_IMAGE","POINT_HELPER_BG_SIZE","LineEditorComponent","exitRef","entryRef","controlPointsRef","exit","entry","handleMouseDownFactory","handleStartMouseDown","handleEndMouseDown","controlPoints","_activeEditableLine$e","cursor","next","ns","ew","getControlPoints","controlElements","handlers","el","commonProps","_extends","SmartConnectLineComponent","sourceView","getConnectLinePoints","SYMBOL_FOR_SIZE_INITIALIZED","Symbol","for","SYMBOL_FOR_LAYOUT_INITIALIZED","DEFAULT_NODE_SIZE","DEFAULT_NODE_GAP","DEFAULT_AREA_WIDTH","DEFAULT_AREA_HEIGHT","DEFAULT_SCALE_RANGE_MIN","DEFAULT_SCALE_RANGE_MAX","DEFAULT_LINE_STROKE_COLOR","DEFAULT_LINE_STROKE_WIDTH","DEFAULT_LINE_INTERACT_STROKE_WIDTH","DEFAULT_LINE_INTERACT_SHOW_START_ARROW","DEFAULT_LINE_INTERACT_SHOW_END_ARROW","DEFAULT_DEGRADED_THRESHOLD","DEFAULT_NODE_PADDING_FOR_LINES","isInitialNodeCell","isNodeOrEdgeCell","isTextDecoratorCell","getUnrelatedCells","existedTargets","Set","add","has","nodesMap","Map","activeNodeIds","relatedNodeIds","set","handleKeyboard","keyCode","which","handleLasso","onLassoing","onLassoed","ctrlKey","button","x0","y0","handleNodeContainedChange","onContainerContainerChange","nodeCells","containerIds","p","v","nodePayloads","nodeCell","includeNodeFlag","payload","right","bottom","containerDecoratorCells","containerCell","containerLeft","containerRight","containerTop","containerBottom","containedChanges","_payload$containerCel","initializeCells","initialCells","defaultNodeSize","_cell$view2","b","every","targetA","targetB","transformToCenter","canvasWidth","canvasHeight","scaleRange","empty","max","min","updateCells","previousCells","reason","parent","isManualLayout","newCells","updateCandidates","shouldReCenter","previousSizeInitializedNodes","previousShouldCentered","previousNode","handled","downstreamNodeIds","parentNode","downstreamNodes","Boolean","rightMostNode","nextX","nextY","totalWidth","reduce","acc","maxWidth","maxHeight","positionedNodes","hasDecorators","getNodeView","without","dagreLayout","forceLayout","fixedPosition","updated","insertCellAfter","newCell","after","findLastIndex","slice","rootReducer","reducers","state","existedEdgeIndex","findIndex","matched","newState","move","layoutKey","Object","fromEntries","entries","props","xmlns","viewBox","ZoomBarComponent","shadowRoot","onZoomChange","onReCenter","currentTheme","useCurrentTheme","cache","createCache","zoomBarRef","tooltip","formatter","getPopupContainer","onZoomIn","onZoomOut","ConfigProvider","theme","algorithm","darkAlgorithm","defaultAlgorithm","StyleProvider","container","autoClear","hashPriority","role","CenterSVG","ZoomInSVG","Slider","step","vertical","included","onChange","ZoomOutSVG","nodePadding","dagreGraphOptions","rankdir","ranksep","edgesep","nodesep","nodePaddings","extractPartialRectTuple","graph","dagre","Graph","setGraph","setDefaultEdgeLabel","setNode","setEdge","collide","radiusDiff","strength","iterations","forceNodes","forceLinks","fx","fy","linkSimulation","forceLink","simulation","forceSimulation","force","forceX","forceY","forceManyBody","forceCollide","radius","sqrt","stop","tick","ceil","log","alphaMin","alphaDecay","manuallyTickToTheEnd","nodeViewToNodeRect","DEFAULT_DIRECTIONS","targetView","edgeView","_connectPoints$find","_connectPoints$find2","originalExit","originalEntry","getDirectLinePoints","firstVertex","lastVertex","exitDirection","entryDirection","getAbsolutePosition","possibleFirstNextPoint","getDefaultAbsolutePosition","prefer","fitEndpointAndDirection","possibleLastPreviousPoint","reverse","sourceX","sourceY","targetX","targetY","newLinePoints","unshift","getDefaultPosition","connectPoints","getConnectPointsOfRectangleWithDirection","originalSourceDirections","originalTargetDirections","sourceDirections","targetDirections","pull","sourceDirection","targetDirection","sourcePosition","targetPosition","getPolyLinePoints","simplifiedVertices","prevDirection","isHorizontal","isVertical","isHorizontalNext","isVerticalNext","flip","xAxis","yAxis","xSize","ySize","xPosition","oppositeView","nsDirection","ewDirection","nextVertex","RectangleRelativeConnectPointsWithDirection","RectangleRelativeConnectPoints","getConnectPointsOfRectangle","useActiveTarget","_activeTarget","onActiveTargetChange","newActiveTarget","setActiveTarget","previous","activeTargetChangeInitialized","resetActiveTarget","composedPath","indexOf","KeywordMap","normalizeAlignAxis","newX","matches","match","Number","useLayout","zoomable","zoomer","dispatch","layoutInitialized","setLayoutInitialized","layoutKeyRef","getNextLayoutKey","centered","setCentered","root","select","ZoomTransform","useAutoCenter","previousLayoutRef","alignOrigin","origin","normalizeAlignOrigin","nodeView","useLineMarkers","defaultEdgeLines","markerPrefix","lineConnector","markers","markerType","lineConnectorConf","getDefaultLineConf","omitBy","isUndefined","_type","markerIndex","addMarker","editingMarkerIndex","WeakMap","_secret_internals$le","computedLineConf","Array","isArray","checkIfOfComputed","showStartArrow","showEndArrow","useReady","useZoom","scrollable","pannable","draggable","ctrlDraggable","_scaleRange","grabbing","setGrabbing","setTransform","zoom","scaleExtent","on","rootSelection","unsetZoom","stopImmediatePropagation","translateBy","wheelDeltaX","wheelDeltaY","___CSS_LOADER_EXPORT___","module","toString"],"sourceRoot":""}