@next-bricks/diagram 0.56.0 → 0.57.0

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 (31) hide show
  1. package/dist/bricks.json +3 -3
  2. package/dist/chunks/8436.38f6bb4d.js +2 -0
  3. package/dist/chunks/8436.38f6bb4d.js.map +1 -0
  4. package/dist/chunks/9024.9fb24b35.js +2 -0
  5. package/dist/chunks/9024.9fb24b35.js.map +1 -0
  6. package/dist/chunks/{9711.a67e7f03.js → 9711.6468901d.js} +2 -2
  7. package/dist/chunks/{9711.a67e7f03.js.map → 9711.6468901d.js.map} +1 -1
  8. package/dist/chunks/{eo-display-canvas.28d0385d.js → eo-display-canvas.d3d4fa57.js} +2 -2
  9. package/dist/chunks/{eo-display-canvas.28d0385d.js.map → eo-display-canvas.d3d4fa57.js.map} +1 -1
  10. package/dist/chunks/{eo-draw-canvas.4b11d12e.js → eo-draw-canvas.c41d08df.js} +2 -2
  11. package/dist/chunks/{eo-draw-canvas.4b11d12e.js.map → eo-draw-canvas.c41d08df.js.map} +1 -1
  12. package/dist/chunks/{main.3238fda4.js → main.cab55157.js} +2 -2
  13. package/dist/chunks/{main.3238fda4.js.map → main.cab55157.js.map} +1 -1
  14. package/dist/examples.json +6 -6
  15. package/dist/index.e995f9bc.js +2 -0
  16. package/dist/{index.9e7c2eca.js.map → index.e995f9bc.js.map} +1 -1
  17. package/dist/manifest.json +205 -205
  18. package/dist/types.json +4049 -4023
  19. package/dist-types/diagram/lines/curveLine.d.ts +2 -1
  20. package/dist-types/diagram/lines/intersect.d.ts +2 -0
  21. package/dist-types/diagram/lines/intersect.spec.d.ts +1 -0
  22. package/dist-types/draw-canvas/interfaces.d.ts +17 -4
  23. package/dist-types/shared/canvas/collectLineJumpsFactory.d.ts +3 -0
  24. package/dist-types/shared/canvas/collectLineJumpsFactory.spec.d.ts +1 -0
  25. package/docs/eo-draw-canvas.md +2 -0
  26. package/package.json +2 -2
  27. package/dist/chunks/5903.ee85cf0c.js +0 -2
  28. package/dist/chunks/5903.ee85cf0c.js.map +0 -1
  29. package/dist/chunks/8436.107dc714.js +0 -2
  30. package/dist/chunks/8436.107dc714.js.map +0 -1
  31. package/dist/index.9e7c2eca.js +0 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunks/9024.9fb24b35.js","mappings":"kRAqBO,SAASA,EAAkBC,GAQc,IARb,KACjCC,EAAI,SACJC,EAAQ,OACRC,EAAM,MACNC,EAAK,KACLC,EAAI,WACJC,EAAU,QACVC,GACwBP,EACxB,IAAKI,IAAUC,EACb,OAAO,KAET,MAAMG,KAAWN,IAAYC,GAC7B,OACEM,IAAAA,cAAA,iBACEC,UAAWC,IAAW,uBAAwB,CAAEH,UAChDI,EAAGJ,EAAQN,EAAS,GAAKC,EAAO,GAAK,EACrCU,EAAGL,EAAQN,EAAS,GAAKC,EAAO,GAAK,EACrCI,QAASA,GAERH,EACCK,IAAAA,cAAA,OAAKC,UAAU,oBACbD,IAAAA,cAACK,EAA0B,CACzBb,KAAMA,EACNG,MAAOA,EACPE,WAAYA,KAIhBG,IAAAA,cAACM,EAAsB,CAACV,KAAMA,EAAOC,WAAYA,IAIzD,CAOA,SAASS,EAAsBC,GAGc,IAHb,KAC9BX,EAAI,WACJC,GAC4BU,EAC5B,MAAMC,GAAcC,EAAAA,EAAAA,cACjBC,IACCb,SAAAA,EAAaa,EAAQ,GAEvB,CAACb,IAGH,OACEG,IAAAA,cAAA,OAAKC,UAAU,kBAAkBU,IAAKH,EAAaI,MAAOhB,EAAKgB,OAC5DhB,EAAKiB,QAGZ,CASA,SAASR,EAA0BS,GAIqB,IAJpB,KAClCtB,EAAI,MACJG,EAAK,WACLE,GACgCiB,EAChC,MAAMC,GAAWC,EAAAA,EAAAA,UACf,KAAOC,EAAAA,EAAAA,mBAAkBtB,GAASA,EAAMoB,SAAW,MACnD,CAACpB,IAGGuB,GAAeF,EAAAA,EAAAA,UAAQ,KAAM,CAAGxB,UAAS,CA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AQ7a,QACrB,IAAKyyB,EACH,OAGF,MAAM+D,GAAgB9D,EAAAA,EAAAA,GAAOD,GAEvBgE,EAAYA,KAChBD,EACGD,GAAG,QAAS,MACZA,GAAG,eAAgB,MACnBA,GAAG,QAAS,KAAK,EAGtB,GAAMxE,GAAY6D,GAAcC,EA+ChC,OA1CI9D,GAAY6D,IAGdY,EAAcD,GACZ,qBACC9zB,IAEMA,EAAEoe,UAELpe,EAAEi0B,2BACEd,IACFnzB,EAAEI,iBACFmvB,EAAO2E,YACLH,EACA/zB,EAAEm0B,YAAc,EAChBn0B,EAAEo0B,YAAc,IAGtB,IAMNL,EACG90B,KAAKswB,GACLuE,GAAG,SAAU9zB,IACZA,EAAEI,gBAAgB,IAEnB0zB,GAAG,gBAAiB,OAEjBT,GAAcC,IAAmBF,GACrCW,EAAcD,GAAG,iBAAkB,MAGhCV,GACHW,EACGD,GAAG,kBAAmB,MACtBA,GAAG,iBAAkB,MACrBA,GAAG,gBAAiB,MAGlBE,EA9CLA,GA8Cc,GACf,CACDV,EACAD,EACAD,EACAhb,EACA+a,EACA7D,EACAC,IAGK,CAAEiE,WAAUhkB,YAAW+f,SAAQnP,aACxC,C,kEC1MIiU,E,MAA0B,GAA4B,KAE1DA,EAAwB3qB,KAAK,CAAC4qB,EAAOlwB,GAAI,s4CAK+C,KAExF,QAAeiwB,EAAwBE,U,kECTnCF,E,MAA0B,GAA4B,KAE1DA,EAAwB3qB,KAAK,CAAC4qB,EAAOlwB,GAAI,4uHAY67B,KAEt+B,QAAeiwB,EAAwBE,U","sources":["webpack:///./src/draw-canvas/LineLabelComponent.tsx","webpack:///./src/draw-canvas/EdgeComponent.tsx","webpack:///./src/draw-canvas/processors/getLabelMaskAndOffset.ts","webpack:///./src/draw-canvas/NodeComponent.tsx","webpack:///./src/draw-canvas/processors/getSnapPositions.ts","webpack:///./src/draw-canvas/processors/handleMouseDown.ts","webpack:///./src/draw-canvas/processors/normalizeSnapOptions.ts","webpack:///./src/draw-canvas/decorators/DecoratorText.tsx","webpack:///./src/draw-canvas/decorators/index.tsx","webpack:///./src/draw-canvas/decorators/DecoratorContainer.tsx","webpack:///./src/draw-canvas/decorators/DecoratorArea.tsx","webpack:///./src/draw-canvas/decorators/DecoratorRect.tsx","webpack:///./src/draw-canvas/decorators/DecoratorLine.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/findNodeOrAreaDecorator.ts","webpack:///./src/shared/canvas/collectLineJumpsFactory.ts","webpack:///./src/shared/canvas/useEditableLineMap.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 React, { useCallback, useEffect, useMemo } from \"react\";\nimport { checkIfOfComputed } from \"@next-core/runtime\";\nimport { ReactUseBrick } from \"@next-core/react-runtime\";\nimport classNames from \"classnames\";\nimport type {\n LineLabelConf,\n PositionTuple,\n TextOptions,\n} from \"../diagram/interfaces\";\nimport type { EdgeCell, PositionAndAngle } from \"./interfaces\";\n\nexport interface LineLabelComponentProps {\n edge: EdgeCell;\n position?: PositionAndAngle | null;\n offset?: PositionTuple | null;\n label?: LineLabelConf;\n text?: TextOptions;\n onRendered?: (element: HTMLElement | null) => void;\n onClick?: () => void;\n}\n\nexport function LineLabelComponent({\n edge,\n position,\n offset,\n label,\n text,\n onRendered,\n onClick,\n}: LineLabelComponentProps): JSX.Element | null {\n if (!label && !text) {\n return null;\n }\n const ready = !!(position && offset);\n return (\n <foreignObject\n className={classNames(\"line-label-container\", { ready })}\n x={ready ? position[0] + offset[0] : 0}\n y={ready ? position[1] + offset[1] : 0}\n onClick={onClick}\n >\n {label ? (\n <div className=\"line-label label\">\n <LineLabelUseBrickComponent\n edge={edge}\n label={label}\n onRendered={onRendered}\n />\n </div>\n ) : (\n <LineLabelTextComponent text={text!} onRendered={onRendered} />\n )}\n </foreignObject>\n );\n}\n\ninterface LineLabelTextComponentProps {\n text: TextOptions;\n onRendered?: (element: HTMLElement | null) => void;\n}\n\nfunction LineLabelTextComponent({\n text,\n onRendered,\n}: LineLabelTextComponentProps): JSX.Element {\n const refCallback = useCallback(\n (element: HTMLDivElement) => {\n onRendered?.(element);\n },\n [onRendered]\n );\n\n return (\n <div className=\"line-label text\" ref={refCallback} style={text.style}>\n {text.content}\n </div>\n );\n}\n\ninterface LineLabelUseBrickComponentProps {\n edge: EdgeCell;\n label: LineLabelConf;\n onRendered?: (element: HTMLElement | null) => void;\n}\n\n// istanbul ignore next\nfunction LineLabelUseBrickComponent({\n edge,\n label,\n onRendered,\n}: LineLabelUseBrickComponentProps): JSX.Element | null {\n const useBrick = useMemo(\n () => (checkIfOfComputed(label) ? label.useBrick : null),\n [label]\n );\n\n const memoizedData = useMemo(() => ({ edge }), [edge]);\n\n useEffect(() => {\n if (!useBrick) {\n // Keep the same time delay for reporting rendered.\n setTimeout(() => {\n onRendered?.(null);\n });\n }\n }, [onRendered, useBrick]);\n\n useEffect(\n () => {\n return () => {\n onRendered?.(null);\n };\n },\n // Only unmount once\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n\n const refCallback = useCallback(\n (element: HTMLElement | null) => {\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 // await Promise.resolve();\n onRendered?.(element.parentElement);\n });\n }\n },\n [onRendered]\n );\n\n const ignoredCallback = useCallback(() => {\n setTimeout(() => {\n onRendered?.(null);\n });\n }, [onRendered]);\n\n if (!useBrick) {\n return null;\n }\n\n return (\n <ReactUseBrick\n refCallback={refCallback}\n ignoredCallback={ignoredCallback}\n useBrick={useBrick}\n data={memoizedData}\n />\n );\n}\n","import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport classNames from \"classnames\";\nimport { uniqueId } from \"lodash\";\nimport ResizeObserver from \"resize-observer-polyfill\";\nimport type {\n ActiveTarget,\n ComputedEdgeLineConf,\n Direction,\n EdgeCell,\n EdgeLineMotion,\n EditableLine,\n EditableLineCell,\n PositionAndAngle,\n} from \"./interfaces\";\nimport {\n DEFAULT_LINE_INTERACT_ANIMATE_DURATION,\n DEFAULT_MOTION_SPEED,\n} from \"./constants\";\nimport { curveLine } from \"../diagram/lines/curveLine\";\nimport { getMarkers } from \"../shared/canvas/useLineMarkers\";\nimport type {\n LineMarkerConf,\n NodePosition,\n SizeTuple,\n} from \"../diagram/interfaces\";\nimport { LineLabelComponent } from \"./LineLabelComponent\";\nimport { cellToTarget } from \"./processors/cellToTarget\";\nimport { getLabelMaskAndOffset } from \"./processors/getLabelMaskAndOffset\";\n\nexport interface EdgeComponentProps {\n edge: EdgeCell;\n lineConfMap: WeakMap<EditableLineCell, ComputedEdgeLineConf>;\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n readOnly?: boolean;\n active?: boolean;\n activeRelated?: boolean;\n onSwitchActiveTarget?(activeTarget: ActiveTarget | null): void;\n}\n\nexport function EdgeComponent({\n edge,\n lineConfMap,\n editableLineMap,\n readOnly,\n active,\n activeRelated,\n onSwitchActiveTarget,\n}: EdgeComponentProps): JSX.Element | null {\n const pathRef = useRef<SVGPathElement | null>(null);\n const lineConf = lineConfMap.get(edge)!;\n const { points: linePoints, jumpsMap } = editableLineMap.get(edge) ?? {};\n\n const line = useMemo(() => {\n return curveLine(\n linePoints,\n lineConf.type === \"curve\" ? lineConf.curveType : \"curveLinear\",\n 0,\n 1,\n jumpsMap\n );\n }, [lineConf, linePoints, jumpsMap]);\n\n const lineClipPathPrefix = useMemo(() => uniqueId(\"line-mask-\"), []);\n\n const [labelPosition, setLabelPosition] = useState<PositionAndAngle | null>(\n null\n );\n const [labelSize, setLabelSize] = useState<SizeTuple | null>(null);\n const [lineRect, setLineRect] = useState<Pick<\n SVGRect,\n \"x\" | \"y\" | \"width\" | \"height\"\n > | null>(null);\n\n const updateLabelPosition = useCallback(() => {\n const path = pathRef.current;\n const { label, text } = lineConf;\n // istanbul ignore next\n if (path && linePoints && (label || text)) {\n if (process.env.NODE_ENV === \"test\") {\n setLabelPosition([30, 40, \"center\", 0, 0]);\n setLineRect({ x: 10, y: 20, width: 300, height: 400 });\n return;\n }\n const placement = (label ? label.placement : text.placement) ?? \"center\";\n const pathLength = path.getTotalLength();\n const halfPathLength = pathLength / 2;\n const pathPoint = path.getPointAtLength(\n placement === \"start\"\n ? Math.min(0, halfPathLength)\n : placement === \"end\"\n ? Math.max(pathLength - 0, halfPathLength)\n : halfPathLength\n );\n\n let direction: Direction | \"center\" = \"center\";\n let angle = 0;\n if (placement === \"start\" || placement === \"end\") {\n let p0: NodePosition;\n let p1: NodePosition;\n if (placement === \"start\") {\n p0 = linePoints[0];\n p1 = linePoints[1];\n } else {\n p0 = linePoints[linePoints.length - 1];\n p1 = linePoints[linePoints.length - 2];\n }\n angle = Math.atan2(p1.y - p0.y, p1.x - p0.x);\n direction =\n Math.abs(p0.x - p1.x) > Math.abs(p0.y - p1.y)\n ? p0.x > p1.x\n ? \"left\"\n : \"right\"\n : p0.y > p1.y\n ? \"top\"\n : \"bottom\";\n }\n\n const offset = (label ? label.offset : text.offset) ?? 0;\n setLabelPosition([pathPoint.x, pathPoint.y, direction, angle, offset]);\n const rect = path.getBBox();\n setLineRect({\n x: rect.x - 1000,\n y: rect.y - 1000,\n width: rect.width + 2000,\n height: rect.height + 2000,\n });\n }\n }, [lineConf, linePoints]);\n\n const [pathLength, setPathLength] = useState<number | null>(null);\n\n const pathRefCallback = useCallback(\n (element: SVGPathElement | null) => {\n pathRef.current = element;\n if (element) {\n // Jest does not support `SVGPathElement::getTotalLength`\n setPathLength(element.getTotalLength?.() ?? 100);\n const rect = element.getBBox?.();\n edge.view = {\n ...edge.view,\n x: rect?.x,\n y: rect?.y,\n width: rect?.width,\n height: rect?.height,\n };\n }\n updateLabelPosition();\n },\n [updateLabelPosition, edge]\n );\n\n const [labelElement, setLabelElement] = useState<HTMLElement | null>(null);\n\n useEffect(() => {\n if (!labelElement) {\n setLabelSize(null);\n return;\n }\n const observerCallback = () => {\n const { offsetWidth, offsetHeight } = labelElement;\n // Do not mask out when the label takes no space.\n // istanbul ignore next\n if (\n process.env.NODE_ENV !== \"test\" &&\n (offsetWidth === 0 || offsetHeight === 0)\n ) {\n setLabelSize(null);\n return;\n }\n setLabelSize([offsetWidth, offsetHeight]);\n };\n const resizeObserver = new ResizeObserver(observerCallback);\n resizeObserver.observe(labelElement);\n\n // `ResizeObserver` will not call the callback in test environment.\n // istanbul ignore next\n if (process.env.NODE_ENV === \"test\") {\n observerCallback();\n }\n return () => {\n resizeObserver.disconnect();\n };\n }, [labelElement]);\n\n const handleLabelRendered = useCallback((element: HTMLElement | null) => {\n setLabelElement(element);\n }, []);\n\n useEffect(\n () => {\n updateLabelPosition();\n },\n // Update label position when line points changed\n [updateLabelPosition, linePoints]\n );\n\n const onLabelClick = useCallback(() => {\n onSwitchActiveTarget?.(cellToTarget(edge));\n }, [edge, onSwitchActiveTarget]);\n\n const onDoubleClick = useCallback(\n (e: React.MouseEvent) => {\n if (readOnly || !lineConf.callLabelOnDoubleClick) {\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n (\n labelElement?.firstElementChild as unknown as Record<string, () => void>\n )?.[lineConf.callLabelOnDoubleClick]?.();\n },\n [labelElement, lineConf, readOnly]\n );\n\n const [mask, labelOffset] = useMemo(\n () => getLabelMaskAndOffset(labelPosition, labelSize),\n [labelPosition, labelSize]\n );\n\n const clipPathPoints = useMemo(() => {\n if (!mask || !lineRect) {\n return null;\n }\n const right = lineRect.x + lineRect.width;\n const bottom = lineRect.y + lineRect.height;\n const maskRight = mask.left + mask.width;\n const maskBottom = mask.top + mask.height;\n return [\n [mask.left, maskBottom],\n [maskRight, maskBottom],\n [maskRight, mask.top],\n [mask.left, mask.top],\n [mask.left, lineRect.y],\n [right, lineRect.y],\n [right, bottom],\n [lineRect.x, bottom],\n [lineRect.x, lineRect.y],\n [mask.left, lineRect.y],\n ]\n .map((points) => points.join(\",\"))\n .join(\" \");\n }, [lineRect, mask]);\n\n if (!line) {\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 let strokeColor: string | undefined;\n let strokeWidth: number | undefined;\n let motion: EdgeLineMotion | undefined;\n const lineMarkers: LineMarkerConf[] = getMarkers(lineConf);\n if (active) {\n const overrides = lineConf.overrides?.active;\n strokeColor = overrides?.strokeColor ?? lineConf.strokeColor;\n strokeWidth = overrides?.strokeWidth ?? lineConf.strokeWidth;\n motion = overrides?.motion;\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart =\n lineConf.$activeMarkerStartUrl ?? lineConf.$markerStartUrl;\n } else {\n markerEnd = lineConf.$activeMarkerEndUrl ?? lineConf.$markerEndUrl;\n }\n }\n } else if (activeRelated) {\n const overrides = lineConf.overrides?.activeRelated;\n strokeColor = overrides?.strokeColor ?? lineConf.strokeColor;\n strokeWidth = overrides?.strokeWidth ?? lineConf.strokeWidth;\n motion = overrides?.motion;\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart =\n lineConf.$activeRelatedMarkerStartUrl ?? lineConf.$markerStartUrl;\n } else {\n markerEnd =\n lineConf.$activeRelatedMarkerEndUrl ?? lineConf.$markerEndUrl;\n }\n }\n } else {\n strokeColor = lineConf.strokeColor;\n strokeWidth = lineConf.strokeWidth;\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\n let motionPath: string | undefined;\n if (motion?.shape === \"dot\") {\n const radius = motion.size == null ? strokeWidth * 2 : motion.size / 2;\n motionPath = `M 0,${-radius} A ${radius},${radius} 0,1,1 0,${radius} A ${radius},${radius} 0,1,1 0,${-radius} z`;\n } else if (motion?.shape === \"triangle\") {\n const radius = motion.size == null ? strokeWidth * 2 : motion.size / 2;\n const offset = radius / Math.sqrt(3);\n motionPath = `M ${-offset},${radius} v ${-radius * 2} L ${offset * 2},0 z`;\n }\n let motionDuration: string | undefined;\n if (pathLength) {\n motionDuration = `${pathLength / (motion?.speed ?? DEFAULT_MOTION_SPEED)}s`;\n }\n\n const hasMotion = [\n lineConf.overrides?.active?.motion?.shape,\n lineConf.overrides?.activeRelated?.motion?.shape,\n ].some((item) => item === \"dot\" || item === \"triangle\");\n\n const clipPathUrl = clipPathPoints\n ? `url(#${lineClipPathPrefix})`\n : undefined;\n\n return (\n <>\n {clipPathPoints && (\n <defs>\n <clipPath id={lineClipPathPrefix}>\n <polygon points={clipPathPoints} />\n </clipPath>\n </defs>\n )}\n <g className=\"line-group\" onDoubleClick={onDoubleClick}>\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 clipPath={clipPathUrl}\n />\n <path\n ref={pathRefCallback}\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 clipPath={clipPathUrl}\n style={\n {\n \"--time\": `${lineConf.animate.duration ?? DEFAULT_LINE_INTERACT_ANIMATE_DURATION}s`,\n \"--solid-length\": pathLength,\n } as React.CSSProperties\n }\n d={line}\n fill=\"none\"\n stroke={strokeColor}\n strokeWidth={strokeWidth}\n markerStart={markerStart}\n markerEnd={markerEnd}\n />\n {!lineConf.overrides?.active && (\n <path\n className=\"line-active-bg\"\n d={line}\n fill=\"none\"\n clipPath={clipPathUrl}\n />\n )}\n {\n // No dur in old browsers will cause animation not working.\n // So always set a dur.\n hasMotion && motionDuration && (\n <path\n className={classNames(\"motion\", { visible: !!motionPath })}\n d={motionPath}\n fill={strokeColor}\n >\n <animateMotion\n dur={motionDuration}\n repeatCount={\"indefinite\"}\n rotate={\"auto\"}\n path={line}\n />\n </path>\n )\n }\n </g>\n <LineLabelComponent\n edge={edge}\n position={labelPosition}\n offset={labelOffset}\n label={lineConf.label}\n text={lineConf.text}\n onClick={onLabelClick}\n onRendered={handleLabelRendered}\n />\n </>\n );\n}\n","import type {\n PositionTuple,\n SimpleRect,\n SizeTuple,\n} from \"../../diagram/interfaces\";\nimport type { PositionAndAngle } from \"../interfaces\";\n\nexport function getLabelMaskAndOffset(\n labelPosition: PositionAndAngle | null,\n labelSize: SizeTuple | null\n): [labelMask: SimpleRect | null, labelOffset: PositionTuple | null] {\n if (!labelPosition || !labelSize) {\n return [null, null];\n }\n const padding = 3;\n const [x, y, direction, angle, gap] = labelPosition;\n const [width, height] = labelSize;\n\n const left = x - width / 2 - padding;\n const top = y - height / 2 - padding;\n let offsetX = 0;\n let offsetY = 0;\n const halfWidth = width / 2 + padding;\n const halfHeight = height / 2 + padding;\n switch (direction) {\n case \"top\":\n offsetX = gap * Math.cos(angle) - halfHeight / Math.tan(angle);\n offsetY = gap * Math.sin(angle) - halfHeight;\n break;\n case \"bottom\":\n offsetX = gap * Math.cos(angle) + halfHeight / Math.tan(angle);\n offsetY = gap * Math.sin(angle) + halfHeight;\n break;\n case \"left\":\n offsetX = gap * Math.cos(angle) - halfWidth;\n offsetY = gap * Math.sin(angle) - halfWidth * Math.tan(angle);\n break;\n case \"right\":\n offsetX = gap * Math.cos(angle) + halfWidth;\n offsetY = gap * Math.sin(angle) + halfWidth * Math.tan(angle);\n break;\n }\n\n return [\n {\n left: left + offsetX,\n top: top + offsetY,\n width: width + padding * 2,\n height: height + padding * 2,\n },\n [offsetX, offsetY],\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 { NodeView, SnapToObjectPosition } from \"../interfaces\";\n\nconst DEFAULT_ALL_POSITIONS = [\"center\", \"top\", \"bottom\", \"left\", \"right\"];\n\nexport type SnapPositions = Partial<\n Record<SnapToObjectPosition, PositionTuple>\n>;\n\nexport function getSnapPositions(\n view: NodeView,\n positions: string | undefined\n) {\n const snapPositions: SnapPositions = {};\n for (const position of positions\n ?.split(/\\s+/g)\n ?.flatMap((pos) => (pos === \"all\" ? DEFAULT_ALL_POSITIONS : pos)) ?? []) {\n let tuple: PositionTuple;\n const cx = view.x + view.width / 2;\n const cy = view.y + view.height / 2;\n switch (position) {\n case \"center\":\n tuple = [cx, cy];\n break;\n case \"top\":\n tuple = [cx, view.y];\n break;\n case \"right\":\n tuple = [view.x + view.width, cy];\n break;\n case \"bottom\":\n tuple = [cx, view.y + view.height];\n break;\n case \"left\":\n tuple = [view.x, cy];\n break;\n default:\n throw new Error(`Unknown snap position: \"${position}\"`);\n }\n snapPositions[position] = tuple;\n }\n return snapPositions;\n}\n","import type { PositionTuple } from \"../../diagram/interfaces\";\nimport type {\n ActiveTarget,\n Cell,\n LayoutOptions,\n DecoratorCell,\n LayoutType,\n NodeCell,\n SnapToObjectPosition,\n ActiveTargetOfSingular,\n EditableLineCell,\n} from \"../interfaces\";\nimport type {\n MoveCellPayload,\n ResizeCellPayload,\n} from \"../reducers/interfaces\";\nimport {\n isContainerDecoratorCell,\n isDecoratorCell,\n isEdgeCell,\n isLineDecoratorCell,\n isNodeCell,\n} from \"./asserts\";\nimport { cellToTarget } from \"./cellToTarget\";\nimport { getSnapPositions, type SnapPositions } from \"./getSnapPositions\";\nimport { normalizeSnapOptions } from \"./normalizeSnapOptions\";\nimport { sameTarget } from \"./sameTarget\";\nimport { targetIsActive } from \"./targetIsActive\";\n\nconst HORIZONTAL_POSITIONS = [\"left\", \"center\", \"right\"];\nconst VERTICAL_POSITIONS = [\"top\", \"center\", \"bottom\"];\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 updateCurActiveEditableLine,\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 updateCurActiveEditableLine?: (\n activeEditableLine: EditableLineCell | null\n ) => void;\n }\n) {\n event.stopPropagation();\n // Drag node\n const preActive = targetIsActive(cell, activeTarget);\n if (event.shiftKey) {\n const activeTargets = activeTarget\n ? activeTarget?.type === \"multi\"\n ? activeTarget.targets\n : [activeTarget]\n : [];\n let targets: ActiveTargetOfSingular[] = [];\n if (preActive) {\n targets = activeTargets.filter((target) => !sameTarget(target, cell));\n } else {\n targets = [...activeTargets, cell];\n if (isEdgeCell(cell) || isLineDecoratorCell(cell)) {\n updateCurActiveEditableLine?.(cell);\n }\n }\n onSwitchActiveTarget?.(\n targets.length > 0 ? { type: \"multi\", targets } : null\n );\n } else {\n if (action === \"resize\" || !preActive) {\n onSwitchActiveTarget?.(cellToTarget(cell));\n if (isEdgeCell(cell) || isLineDecoratorCell(cell)) {\n updateCurActiveEditableLine?.(cell);\n }\n }\n }\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 const snapToObjectPositions = snap.object?.positions;\n\n const from: PositionTuple = [event.clientX, event.clientY];\n const originals = movableActiveCells.map<{\n cell: NodeCell | DecoratorCell;\n position: PositionTuple;\n snapPositions: SnapPositions | null;\n }>((c) => ({\n cell: c,\n position:\n action === \"move\" ? [c.view.x, c.view.y] : [c.view.width, c.view.height],\n snapPositions:\n action === \"move\" && !isEdgeCell(c)\n ? getSnapPositions(c.view, snapToObjectPositions)\n : 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 snapPositions: SnapPositions;\n }[] = [];\n if (action === \"move\" && snap.object) {\n const objectCells = cells.filter(\n // Edge and line cells are not snap targets\n (c) =>\n !isEdgeCell(c) && !isLineDecoratorCell(c) && !activeCells.includes(c)\n ) as (NodeCell | DecoratorCell)[];\n snapToObjectTargets = objectCells.map((c) => ({\n cell: c,\n snapPositions: getSnapPositions(c.view, snapToObjectPositions),\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 const snapMovement: PositionTuple = [...movement];\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 if (!moved) {\n moved = movement[0] ** 2 + movement[1] ** 2 >= 9;\n }\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 } else {\n // Snap\n let diffX = Infinity;\n let diffY = Infinity;\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 snapPositions: targetPositions,\n // center: [x, y],\n } of snapToObjectTargets) {\n for (const {\n cell: c,\n snapPositions: originalPositions,\n } of originals) {\n for (const [position, originalPoint] of Object.entries(\n originalPositions!\n )) {\n const horizontal = HORIZONTAL_POSITIONS.includes(position);\n const vertical = VERTICAL_POSITIONS.includes(position);\n const [x, y] = targetPositions[position as SnapToObjectPosition]!;\n const [cx, cy] = originalPoint!;\n if (horizontal) {\n const dX = Math.abs(cx + movement[0] - x);\n const xSnapped = dX < snapToObjectDistance && dX < diffX;\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 }\n if (vertical) {\n const dY = Math.abs(cy + movement[1] - y);\n const ySnapped = dY < snapToObjectDistance && dY < diffY;\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 }\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 position[0] + snapMovement[0],\n position[1] + snapMovement[1],\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 ...(isLineDecoratorCell(c)\n ? {\n source: {\n x: c.view.source.x + snapMovement[0],\n y: c.view.source.y + snapMovement[1],\n },\n target: {\n x: c.view.target.x + snapMovement[0],\n y: c.view.target.y + snapMovement[1],\n },\n vertices: c.view.vertices?.map((v) => ({\n x: v.x + snapMovement[0],\n y: v.y + snapMovement[1],\n })),\n }\n : null),\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","import {\n DEFAULT_SNAP_GRID_SIZE,\n DEFAULT_SNAP_OBJECT_DISTANCE,\n DEFAULT_SNAP_OBJECT_POSITIONS,\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 ? {\n distance: snapToObject.distance ?? DEFAULT_SNAP_OBJECT_DISTANCE,\n positions: snapToObject.positions ?? DEFAULT_SNAP_OBJECT_POSITIONS,\n }\n : null,\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 from \"react\";\nimport type { BasicDecoratorProps, DecoratorType } from \"../interfaces\";\nimport { DecoratorArea } from \"./DecoratorArea\";\nimport { DecoratorText } from \"./DecoratorText\";\nimport { DecoratorContainer } from \"./DecoratorContainer\";\nimport { DecoratorRect } from \"./DecoratorRect\";\nimport { DecoratorLine } from \"./DecoratorLine\";\n\nconst decoratorComponents = new Map<\n DecoratorType,\n React.ComponentType<BasicDecoratorProps>\n>([\n [\"container\", DecoratorContainer],\n [\"area\", DecoratorArea],\n [\"text\", DecoratorText],\n [\"rect\", DecoratorRect],\n [\"line\", DecoratorLine],\n]);\n\nexport function DecoratorComponent({\n cell,\n view,\n transform,\n readOnly,\n layout,\n layoutOptions,\n active,\n activeTarget,\n cells,\n lineConfMap,\n editableLineMap,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n onDecoratorTextEditing,\n onDecoratorTextChange,\n}: BasicDecoratorProps): JSX.Element | null {\n const SpecifiedComponent = decoratorComponents.get(cell.decorator);\n\n if (!SpecifiedComponent) {\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 active={active}\n activeTarget={activeTarget}\n cells={cells}\n lineConfMap={lineConfMap}\n editableLineMap={editableLineMap}\n onCellResizing={onCellResizing}\n onCellResized={onCellResized}\n onSwitchActiveTarget={onSwitchActiveTarget}\n onDecoratorTextEditing={onDecoratorTextEditing}\n onDecoratorTextChange={onDecoratorTextChange}\n />\n );\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, { 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, { useEffect } from \"react\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport { handleMouseDown } from \"../processors/handleMouseDown\";\nimport { isNoManualLayout } from \"../processors/asserts\";\n\nexport type DecoratorRectProps = Omit<\n BasicDecoratorProps,\n \"lineConfMap\" | \"editableLineMap\"\n>;\n\nexport function DecoratorRect({\n cell,\n transform,\n readOnly,\n layout,\n view,\n activeTarget,\n cells,\n onCellResizing,\n onCellResized,\n onSwitchActiveTarget,\n}: DecoratorRectProps): 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 layout,\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 layout,\n ]);\n\n return (\n <g className=\"decorator-rect-container\">\n <rect\n width={view.width}\n height={view.height}\n className=\"rect-container\"\n />\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, { useCallback, useMemo, useRef } from \"react\";\nimport classNames from \"classnames\";\nimport type { BasicDecoratorProps } from \"../interfaces\";\nimport { getMarkers } from \"../../shared/canvas/useLineMarkers\";\nimport type { LineMarkerConf } from \"../../diagram/interfaces\";\nimport { curveLine } from \"../../diagram/lines/curveLine\";\n\nexport type DecoratorLineProps = Pick<\n BasicDecoratorProps,\n \"cell\" | \"active\" | \"lineConfMap\" | \"editableLineMap\"\n>;\n\nexport function DecoratorLine({\n cell,\n active,\n lineConfMap,\n editableLineMap,\n}: DecoratorLineProps): JSX.Element | null {\n const lineConf = lineConfMap.get(cell)!;\n const { points: linePoints, jumpsMap } = editableLineMap.get(cell) ?? {};\n\n const line = useMemo(() => {\n return curveLine(\n linePoints,\n lineConf.type === \"curve\" ? lineConf.curveType : \"curveLinear\",\n 0,\n 1,\n jumpsMap\n );\n }, [lineConf, linePoints, jumpsMap]);\n\n const pathRef = useRef<SVGPathElement | null>(null);\n const pathRefCallback = useCallback(\n (element: SVGPathElement | null) => {\n pathRef.current = element;\n // istanbul ignore next: Jest does not support `SVGPathElement::getBBox`\n if (element && process.env.NODE_ENV !== \"test\") {\n const rect = element.getBBox();\n cell.view = {\n ...cell.view,\n x: rect.x,\n y: rect.y,\n width: rect.width,\n height: rect.height,\n };\n }\n },\n [cell]\n );\n\n if (!line) {\n return null;\n }\n\n let markerStart: string | undefined;\n let markerEnd: string | undefined;\n let strokeColor: string | undefined;\n let strokeWidth: number | undefined;\n const lineMarkers: LineMarkerConf[] = getMarkers(lineConf);\n if (active) {\n const overrides = lineConf.overrides?.active;\n strokeColor = overrides?.strokeColor ?? lineConf.strokeColor;\n strokeWidth = overrides?.strokeWidth ?? lineConf.strokeWidth;\n // motion = overrides?.motion;\n for (const marker of lineMarkers) {\n if (marker.placement === \"start\") {\n markerStart =\n lineConf.$activeMarkerStartUrl ?? lineConf.$markerStartUrl;\n } else {\n markerEnd = lineConf.$activeMarkerEndUrl ?? lineConf.$markerEndUrl;\n }\n }\n } else {\n strokeColor = lineConf.strokeColor;\n strokeWidth = lineConf.strokeWidth;\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\n return (\n <g className=\"decorator-line\">\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 className={classNames(\"line\", {\n dashed: lineConf.dashed,\n dotted: lineConf.dotted,\n })}\n ref={pathRefCallback}\n d={line}\n fill=\"none\"\n stroke={strokeColor}\n strokeWidth={strokeWidth}\n markerStart={markerStart}\n markerEnd={markerEnd}\n />\n </g>\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 LayoutOptions,\n LayoutType,\n NodeBrickConf,\n NodeCell,\n EditableLine,\n EditableLineCell,\n EditableEdgeLine,\n} from \"./interfaces\";\nimport {\n isContainerDecoratorCell,\n isDecoratorCell,\n isEdgeCell,\n isEdgeSide,\n isLineDecoratorCell,\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<EditableLineCell, ComputedEdgeLineConf>;\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n activeTarget: ActiveTarget | null | undefined;\n readOnly?: boolean;\n hoverCell?: Cell | null | undefined;\n unrelatedCells: Cell[];\n dragNodeToContainerActive?: boolean;\n allowEdgeToArea?: boolean;\n curActiveEditableLine?: EditableLineCell | null;\n updateCurActiveEditableLine?: (\n activeEditableLine: EditableLineCell | null\n ) => void;\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 editableLineMap,\n activeTarget,\n dragNodeToContainerActive,\n readOnly,\n transform,\n hoverCell,\n unrelatedCells,\n allowEdgeToArea,\n curActiveEditableLine,\n updateCurActiveEditableLine,\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\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) || isLineDecoratorCell(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 updateCurActiveEditableLine,\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 updateCurActiveEditableLine,\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 if (\n curActiveEditableLine &&\n lineEditorState &&\n curActiveEditableLine.type === \"decorator\"\n ) {\n return;\n }\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 (curActiveEditableLine && lineEditorState) {\n const { type } = lineEditorState;\n const { source, target } = editableLineMap.get(\n curActiveEditableLine\n ) as EditableEdgeLine;\n const { view } = curActiveEditableLine;\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 curActiveEditableLine,\n editableLineMap,\n allowEdgeToArea,\n cell,\n lineEditorState,\n onChangeEdgeView,\n onConnect,\n setLineEditorState,\n setSmartConnectLineState,\n smartConnectLineState,\n updateCurActiveEditableLine,\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 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 isEdgeCell(cell) || isLineDecoratorCell(cell) || 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 active={readOnly ? hoverCell === cell : active}\n activeRelated={!!(readOnly ? hoverCell : activeTarget) && !unrelated}\n lineConfMap={lineConfMap}\n editableLineMap={editableLineMap}\n readOnly={readOnly}\n onSwitchActiveTarget={onSwitchActiveTarget}\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 active={active}\n activeTarget={activeTarget}\n cells={cells}\n lineConfMap={lineConfMap}\n editableLineMap={editableLineMap}\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 EditableLine,\n EditableLineCell,\n EditableLineView,\n DecoratorLineView,\n NodeView,\n} from \"../../../draw-canvas/interfaces\";\nimport { getSmartLinePoints, simplifyVertices } from \"./getSmartLinePoints\";\nimport { isEditableEdgeLine } from \"../../../draw-canvas/processors/asserts\";\n\nexport function getEditingLinePoints(\n activeEditableLine: EditableLineCell | null,\n lineEditorState: LineEditorState | null,\n editableLineMap: WeakMap<EditableLineCell, EditableLine>,\n connectLineTo: PositionTuple | null,\n hoverState: HoverState | null\n): NodePosition[] | null {\n if (\n !activeEditableLine ||\n !lineEditorState ||\n !(\n connectLineTo ||\n (lineEditorState.type !== \"control\" &&\n hoverState?.activePointIndex !== undefined)\n )\n ) {\n return null;\n }\n\n const { type } = lineEditorState;\n const editableLine = editableLineMap.get(activeEditableLine)!;\n let sourceView: NodeView;\n let targetView: NodeView;\n\n const cellType = activeEditableLine.type;\n if (isEditableEdgeLine(editableLine)) {\n sourceView = editableLine.source.view;\n targetView = editableLine.target.view;\n } else {\n const view = editableLine.decorator.view as DecoratorLineView;\n sourceView = { ...view.source, width: 0, height: 0 };\n targetView = { ...view.target, width: 0, height: 0 };\n }\n const view = activeEditableLine.view as EditableLineView;\n const { exitPosition, entryPosition, vertices } = view ?? {};\n const lineSettings = pick(view, [\"type\", \"curveType\"]);\n\n if (type === \"control\") {\n const newVertices = getNewLineVertices(\n activeEditableLine,\n lineEditorState,\n editableLineMap,\n connectLineTo!\n );\n\n return getSmartLinePoints(\n sourceView,\n targetView,\n {\n ...lineSettings,\n exitPosition,\n entryPosition,\n vertices: newVertices,\n },\n 0,\n cellType\n );\n }\n\n if (type === \"corner\") {\n const newVertices = [...vertices!];\n newVertices.splice(lineEditorState.control.index, 1, {\n x: connectLineTo![0],\n y: connectLineTo![1],\n });\n\n return getSmartLinePoints(\n sourceView,\n targetView,\n {\n ...lineSettings,\n exitPosition,\n entryPosition,\n vertices: newVertices,\n },\n 0,\n cellType\n );\n }\n\n if (type === \"break\") {\n const newVertices = [...(vertices ?? [])];\n newVertices.splice(lineEditorState.control.index, 0, {\n x: connectLineTo![0],\n y: connectLineTo![1],\n });\n\n return getSmartLinePoints(\n sourceView,\n targetView,\n {\n ...lineSettings,\n exitPosition,\n entryPosition,\n vertices: newVertices,\n },\n 0,\n cellType\n );\n }\n\n if (cellType === \"edge\" && hoverState?.activePointIndex !== undefined) {\n const position = hoverState.relativePoints[hoverState.activePointIndex];\n // Assert `hoverState.cell` is `target`\n return getSmartLinePoints(\n sourceView,\n targetView,\n {\n ...lineSettings,\n ...(type === \"entry\"\n ? {\n exitPosition,\n entryPosition: position,\n }\n : {\n exitPosition: position,\n entryPosition,\n }),\n vertices,\n },\n 0,\n cellType\n );\n }\n\n const [x1, y1] = connectLineTo!;\n\n if (type === \"entry\") {\n return getSmartLinePoints(\n sourceView,\n { x: x1, y: y1, width: 0, height: 0 },\n { ...lineSettings, exitPosition, vertices },\n 0,\n cellType\n );\n }\n\n return getSmartLinePoints(\n { x: x1, y: y1, width: 0, height: 0 },\n targetView,\n { ...lineSettings, entryPosition, vertices },\n 0,\n cellType\n );\n}\n\nexport function getNewLineVertices(\n activeEditableLine: EditableLineCell,\n lineEditorState: LineEditorStateOfControl,\n editableLineMap: WeakMap<EditableLineCell, EditableLine>,\n connectLineTo: PositionTuple\n) {\n const { control } = lineEditorState;\n const { points: linePoints } = editableLineMap.get(activeEditableLine)!;\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 {\n Cell,\n ComputedLineConnecterConf,\n EditableEdgeLine,\n EditableLine,\n EditableLineCell,\n EditableLineView,\n LineEditorState,\n LineEditorStateOfControl,\n} 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\";\nimport { isEdgeCell, isLineDecoratorCell } from \"./processors/asserts\";\n\nconst LOOSE_CONTROL_TYPES = [\n \"control\",\n \"corner\",\n \"break\",\n] as LineEditorState[\"type\"][];\n\nexport interface EditingLineComponentProps {\n cells: Cell[];\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n transform: TransformLiteral;\n options: ComputedLineConnecterConf;\n activeEditableLine: EditableLineCell | null;\n}\n\nexport function EditingLineComponent({\n cells,\n editableLineMap,\n transform,\n options,\n activeEditableLine,\n}: EditingLineComponentProps): JSX.Element {\n const [connectLineTo, setConnectLineTo] = useState<PositionTuple | null>(\n null\n );\n const {\n hoverState,\n lineEditorState,\n setLineEditorState,\n onChangeEdgeView,\n onChangeDecoratorView,\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 (!activeEditableLine || !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 const linePoints = editableLineMap.get(activeEditableLine)!.points;\n const snapDistance = 5;\n const diff: NodePosition = { x: Infinity, y: Infinity };\n let otherPoints: NodePosition[];\n let axises: (\"x\" | \"y\")[];\n\n const getFinalPosition = (): PositionTuple => {\n if (!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\n return [position.x, position.y];\n };\n\n if (LOOSE_CONTROL_TYPES.includes(type) && !e.altKey) {\n // Snap to other points\n const control = (lineEditorState as LineEditorStateOfControl).control;\n axises =\n type === \"control\"\n ? [control.direction === \"ns\" ? \"y\" : \"x\"]\n : [\"x\", \"y\"];\n otherPoints = linePoints.filter(\n (_, i) =>\n i === 0 ||\n i === linePoints.length - 1 ||\n (type === \"control\"\n ? i !== control.index && i !== control.index + 1\n : type !== \"corner\" || i !== control.index + 1)\n );\n } else if (\n isLineDecoratorCell(activeEditableLine) &&\n (type === \"exit\" || type === \"entry\") &&\n !e.altKey\n ) {\n const endpoint =\n type === \"exit\" ? linePoints[0] : linePoints[linePoints.length - 1];\n otherPoints = linePoints.filter((p) => p !== endpoint);\n axises = [\"x\", \"y\"];\n } else {\n return getFinalPosition();\n }\n\n // Snap to control points of other lines\n for (const cell of cells) {\n if (\n !(isEdgeCell(cell) || isLineDecoratorCell(cell)) ||\n cell === activeEditableLine\n ) {\n continue;\n }\n const editableLine = editableLineMap.get(cell);\n if (editableLine) {\n otherPoints.push(...editableLine.points.slice(1, -1));\n }\n }\n\n for (const point of otherPoints) {\n for (const axis of axises) {\n const newDiff = Math.abs(point[axis] - position[axis]);\n if (newDiff <= snapDistance && newDiff < diff[axis]) {\n position[axis] = point[axis];\n diff[axis] = newDiff;\n }\n }\n }\n\n return getFinalPosition();\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\n if (!movedRef.current) {\n return;\n }\n\n const newConnectTo = getConnectTo(e);\n const isEdge = isEdgeCell(activeEditableLine!);\n\n if (lineEditorState?.type === \"control\") {\n if (isEdge) {\n const editableLine = editableLineMap.get(\n activeEditableLine!\n ) as EditableEdgeLine;\n const { source, target } = editableLine;\n onChangeEdgeView?.(source, target, {\n ...activeEditableLine!.view,\n vertices: getNewLineVertices(\n activeEditableLine!,\n lineEditorState,\n editableLineMap,\n newConnectTo\n ),\n });\n } else {\n onChangeDecoratorView?.(activeEditableLine!, {\n ...activeEditableLine!.view,\n vertices: getNewLineVertices(\n activeEditableLine!,\n lineEditorState,\n editableLineMap,\n newConnectTo\n ),\n });\n }\n return;\n }\n\n if (isEdge) {\n return;\n }\n\n switch (lineEditorState?.type) {\n case \"entry\":\n case \"exit\":\n onChangeDecoratorView?.(activeEditableLine!, {\n ...activeEditableLine!.view,\n [lineEditorState.type === \"entry\" ? \"target\" : \"source\"]: {\n x: newConnectTo[0],\n y: newConnectTo[1],\n },\n });\n break;\n case \"corner\":\n onChangeDecoratorView?.(activeEditableLine!, {\n ...activeEditableLine!.view,\n vertices: activeEditableLine!.view.vertices!.map((point, i) =>\n i === lineEditorState.control.index\n ? { x: newConnectTo[0], y: newConnectTo[1] }\n : point\n ),\n });\n break;\n case \"break\": {\n const newVertices = [...(activeEditableLine!.view.vertices ?? [])];\n newVertices.splice(lineEditorState.control.index, 0, {\n x: newConnectTo[0],\n y: newConnectTo[1],\n });\n onChangeDecoratorView?.(activeEditableLine!, {\n ...activeEditableLine!.view,\n vertices: newVertices,\n });\n break;\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 }, [\n activeEditableLine,\n editableLineMap,\n lineEditorState,\n transform,\n setLineEditorState,\n onChangeEdgeView,\n cells,\n onChangeDecoratorView,\n ]);\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 activeEditableLine,\n lineEditorState,\n editableLineMap,\n connectLineTo,\n hoverState\n );\n const view = activeEditableLine?.view as EditableLineView | undefined;\n return curveLine(\n points,\n view?.type === \"curve\" ? view.curveType : \"curveLinear\",\n 0,\n 1\n );\n }, [\n connectLineTo,\n hoverState,\n activeEditableLine,\n lineEditorState,\n editableLineMap,\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.$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 DecoratorLineView,\n DecoratorView,\n EdgeView,\n EditableLineCell,\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 activeEditableLines: EditableLineCell[];\n lineEditorState: LineEditorState | null;\n movingCells?: boolean;\n setLineEditorState: React.Dispatch<\n React.SetStateAction<LineEditorState | 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 onChangeDecoratorView?: (\n cell: DecoratorCell,\n view: DecoratorView | DecoratorLineView\n ) => void;\n}>({\n rootRef: { current: null },\n smartConnectLineState: null,\n unsetHoverStateTimeoutRef: { current: null },\n hoverState: null,\n activeEditableLines: [],\n lineEditorState: null,\n setLineEditorState: () => {},\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 {\n ActiveTarget,\n Cell,\n EditableEdgeLine,\n EditableLine,\n EditableLineCell,\n NodeCell,\n} from \"./interfaces\";\nimport { targetIsActive } from \"./processors/targetIsActive\";\nimport type { NodePosition } from \"../diagram/interfaces\";\nimport { DEFAULT_NODE_PADDING_FOR_SMART_LINES } from \"./constants\";\nimport { isEditableEdgeLine } from \"./processors/asserts\";\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 editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n scale: number;\n activeEditableLine: EditableLineCell | null;\n disabled?: boolean;\n}\n\nexport function LineConnectorComponent({\n activeTarget,\n editableLineMap,\n scale,\n activeEditableLine,\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 let source: Cell | undefined;\n let target: Cell | undefined;\n let editableLine: EditableLine | undefined;\n\n const available =\n !disabled &&\n hoverState &&\n (!!smartConnectLineState ||\n (activeEditableLine && lineEditorState\n ? (editableLine = editableLineMap.get(activeEditableLine)) &&\n (isEditableEdgeLine(editableLine)\n ? (({ source, target } = editableLine),\n lineEditorState.type === \"entry\")\n ? hoverState.cell === target\n : lineEditorState.type === \"exit\" && hoverState.cell === source\n : // TODO(steve): decorator line\n false)\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 editableLineMap={editableLineMap}\n index={index}\n point={point}\n scale={scale}\n activeEditableLine={activeEditableLine}\n unsetActivePointIndex={unsetActivePointIndex}\n unsetTimeout={unsetTimeout}\n />\n ))}\n </>\n )}\n </g>\n );\n}\n\ninterface ConnectPointComponentProps {\n editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n index: number;\n point: NodePosition;\n scale: number;\n activeEditableLine: EditableLineCell | null;\n unsetTimeout: () => void;\n unsetActivePointIndex: () => void;\n}\n\nfunction ConnectPointComponent({\n editableLineMap,\n index,\n point,\n scale,\n activeEditableLine,\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 if (\n activeEditableLine &&\n lineEditorState &&\n activeEditableLine.type === \"decorator\"\n ) {\n return;\n }\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 (activeEditableLine && lineEditorState) {\n const position =\n hoverState!.relativePoints[hoverState!.activePointIndex!];\n const { type } = lineEditorState;\n const { source, target } = editableLineMap.get(\n activeEditableLine!\n ) as EditableEdgeLine;\n const { view } = activeEditableLine!;\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 activeEditableLine,\n lineEditorState,\n editableLineMap,\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 {\n ControlPoint,\n EditableLine,\n EditableLineCell,\n EditableLineView,\n} from \"./interfaces\";\nimport { isLineDecoratorCell, isStraightType } from \"./processors/asserts\";\n\nconst POINT_HELPER_IMAGE =\n \"data:image/svg+xml;base64,PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3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xpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSIyMnB4IiBoZWlnaHQ9IjIycHgiIHZlcnNpb249IjEuMSI+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 editableLineMap: WeakMap<EditableLineCell, EditableLine>;\n activeEditableLine: EditableLineCell;\n updateCurActiveEditableLine?: (\n activeEditableLine: EditableLineCell | null\n ) => void;\n}\n\nexport function LineEditorComponent({\n scale,\n editableLineMap,\n activeEditableLine,\n updateCurActiveEditableLine,\n}: LineEditorComponentProps): JSX.Element | null {\n const { rootRef, movingCells, lineEditorState, setLineEditorState } =\n useHoverStateContext();\n const exitRef = useRef<SVGImageElement>(null);\n const entryRef = useRef<SVGImageElement>(null);\n const controlPointsRef = useRef<(SVGImageElement | null)[]>([]);\n const isLineDecorator = isLineDecoratorCell(activeEditableLine);\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 offset: [rect.left, rect.top],\n from: [e.clientX, e.clientY],\n type,\n });\n updateCurActiveEditableLine?.(activeEditableLine);\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 }, [\n activeEditableLine,\n rootRef,\n setLineEditorState,\n updateCurActiveEditableLine,\n ]);\n\n const controlPoints = useMemo(() => {\n if (!activeEditableLine) {\n return [];\n }\n\n const points = editableLineMap.get(activeEditableLine)!.points!;\n\n if (isStraightType((activeEditableLine.view as EditableLineView)?.type)) {\n return isLineDecorator ? getStraightControlPoints(points) : [];\n }\n\n return getControlPoints(points);\n }, [activeEditableLine, editableLineMap, isLineDecorator]);\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 updateCurActiveEditableLine?.(activeEditableLine);\n const rect = rootRef.current!.getBoundingClientRect();\n setLineEditorState({\n offset: [rect.left, rect.top],\n from: [e.clientX, e.clientY],\n type: control.type,\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 }, [\n activeEditableLine,\n controlPoints,\n rootRef,\n setLineEditorState,\n updateCurActiveEditableLine,\n ]);\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 (movingCells) {\n return null;\n }\n\n const view = activeEditableLine.view as EditableLineView;\n const linePoints = editableLineMap.get(activeEditableLine)!.points!;\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 isLineDecorator\n ? VERTEX_HELPER_IMAGE\n : exitPosition\n ? ANCHORED_POINT_HELPER_IMAGE\n : 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 opacity={\n point.type === \"break\" &&\n !(\n lineEditorState?.type === \"break\" &&\n lineEditorState.control === point\n )\n ? 0.4\n : 1\n }\n xlinkHref={VERTEX_HELPER_IMAGE}\n cursor={\n isLineDecorator\n ? \"crosshair\"\n : point.direction === \"ns\"\n ? \"row-resize\"\n : \"col-resize\"\n }\n />\n ))}\n <image\n ref={entryRef}\n {...commonProps}\n x={entryPoint.x - offset}\n y={entryPoint.y - offset}\n xlinkHref={\n isLineDecorator\n ? END_POINT_HELPER_IMAGE\n : entryPosition\n ? ANCHORED_POINT_HELPER_IMAGE\n : 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 type: \"control\",\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\nfunction getStraightControlPoints(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 controlPoints.push({\n type: \"break\",\n index: cursor - 1,\n x: (prev.x + next.x) / 2,\n y: (prev.y + next.y) / 2,\n });\n if (cursor < linePoints.length - 1) {\n controlPoints.push({\n ...next,\n type: \"corner\",\n index: cursor - 1,\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 lineSettings?.type === \"curve\" ? lineSettings.curveType : \"curveLinear\",\n 0,\n 1\n );\n }, [connectLineTo, hoverState, smartConnectLineState, 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_H = 36;\nexport const DEFAULT_NODE_GAP_V = 50;\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_DECORATOR_LINE_STROKE_COLOR = \"rgba(73, 126, 255, 0.7)\";\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;\nexport const DEFAULT_SNAP_OBJECT_POSITIONS = \"all\";\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;\nexport const DEFAULT_MOTION_SPEED = 50;\n","import type {\n Cell,\n DecoratorCell,\n EdgeCell,\n EditableEdgeLine,\n EditableLine,\n InitialCell,\n InitialNodeCell,\n LayoutType,\n LineDecoratorCell,\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 isRectDecoratorCell(\n cell: Cell | MoveCellPayload\n): cell is DecoratorCell {\n return cell.type === \"decorator\" && cell.decorator === \"rect\";\n}\n\nexport function isLineDecoratorCell(\n cell: Cell | LineDecoratorCell | MoveCellPayload\n): cell is LineDecoratorCell {\n return cell.type === \"decorator\" && cell.decorator === \"line\";\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\nexport function isEditableEdgeLine(\n line: EditableLine\n): line is EditableEdgeLine {\n return !!(line as EditableEdgeLine).edge;\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 {\n DEFAULT_NODE_GAP_H,\n DEFAULT_NODE_GAP_V,\n SYMBOL_FOR_SIZE_INITIALIZED,\n} 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 +\n rightMostNode.view.width +\n DEFAULT_NODE_GAP_H;\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_H,\n -DEFAULT_NODE_GAP_H\n );\n nextX =\n parentNode.view.x - totalWidth / 2 + parentNode.view.width / 2;\n nextY =\n parentNode.view.y + parentNode.view.height + DEFAULT_NODE_GAP_V;\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_H;\n }\n }\n }\n }\n\n if (!handled) {\n // By default, place unpositioned nodes in a grid.\n const positionedNodes: NodeCell[] = [];\n let hasDecorators = false;\n for (const cell of newCells) {\n if (isNodeCell(cell)) {\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 and unpositioned nodes exist,\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 &&\n !hasDecorators &&\n updateCandidates.length > 0)\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 { pick } from \"lodash\";\nimport type { DrawCanvasAction } from \"./interfaces\";\nimport type {\n Cell,\n DecoratorCell,\n DecoratorType,\n EdgeCell,\n NodeCell,\n} from \"../interfaces\";\nimport { isNodeCell } from \"../processors/asserts\";\nimport { SYMBOL_FOR_SIZE_INITIALIZED } from \"../constants\";\n\ntype CellOrder = CellOrderOfDecorator | CellOrderOfOthers;\n\ninterface CellOrderOfDecorator {\n type: \"decorator\";\n decorators: DecoratorType[];\n}\n\ninterface CellOrderOfOthers {\n type: \"node\" | \"edge\";\n}\n\n// NOTE: keep the cells in the following order by default, when adding new cells:\n// 1. decorators other than text\n// 2. edges\n// 3. nodes\n// 4. decorators of text\nconst DEFAULT_CELL_ORDERS: CellOrder[] = [\n {\n type: \"decorator\",\n decorators: [\"line\", \"area\", \"container\", \"rect\"],\n },\n { type: \"edge\" },\n { type: \"node\" },\n { type: \"decorator\", decorators: [\"text\"] },\n];\n\nexport const cells: Reducer<Cell[], DrawCanvasAction> = (state, action) => {\n switch (action.type) {\n case \"drop-node\":\n case \"drop-decorator\":\n return insertCell(state, action.payload);\n case \"add-nodes\":\n return insertCells(state, action.payload);\n case \"add-edge\": {\n // If the new edge between the source and target already exists, override the old one.\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 insertCell(state, action.payload);\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: action.payload.view,\n },\n ...state.slice(existedEdgeIndex + 1),\n ];\n }\n case \"change-decorator-view\": {\n const existedDecoratorIndex = state.findIndex(\n (cell) => cell.type === \"decorator\" && cell.id === action.payload.id\n );\n return existedDecoratorIndex === -1\n ? state\n : [\n ...state.slice(0, existedDecoratorIndex),\n {\n ...(state[existedDecoratorIndex] as EdgeCell),\n view: action.payload.view,\n },\n ...state.slice(existedDecoratorIndex + 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: {\n ...(cell as NodeCell).view,\n x: newCell.x,\n y: newCell.y,\n ...pick(newCell, \"source\", \"target\", \"vertices\"),\n },\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 insertCell(cells: Cell[], newCell: Cell): Cell[] {\n return insertCells(cells, [newCell]);\n}\n\n/**\n * Insert new cells (with same types and some decorators) to the cells.\n */\nfunction insertCells(cells: Cell[], newCells: Cell[]): Cell[] {\n if (newCells.length === 0) {\n return cells;\n }\n const index = DEFAULT_CELL_ORDERS.findIndex((order) =>\n matchCellOrder(newCells[0], order)\n );\n\n // istanbul ignore next\n if (index === -1) {\n // eslint-disable-next-line no-console\n console.warn(\n \"Default order index unhandled for the cell: %o.\\n%s\",\n newCells[0],\n \"This is a bug of diagram-NB, please report it.\"\n );\n }\n\n const lastIndex = cells.findLastIndex(\n (cell) =>\n DEFAULT_CELL_ORDERS.findIndex((order) => matchCellOrder(cell, order)) <=\n index\n );\n const targetIndex = lastIndex + 1;\n return [\n ...cells.slice(0, targetIndex),\n ...newCells,\n ...cells.slice(targetIndex),\n ];\n}\n\nfunction matchCellOrder(cell: Cell, order: CellOrder) {\n return (\n cell.type === order.type &&\n (order.type !== \"decorator\" ||\n order.decorators.includes((cell as DecoratorCell).decorator))\n );\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 EditableLineView,\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 lineView: EditableLineView | undefined,\n parallelGap?: number,\n /** @default \"edge\" */\n cellType?: \"edge\" | \"decorator\"\n): NodePosition[] | null {\n const {\n type,\n vertices,\n exitPosition: originalExit,\n entryPosition: originalEntry,\n } = lineView ?? {};\n\n if (isStraightType(type)) {\n if (cellType === \"decorator\") {\n return [\n { x: sourceView.x, y: sourceView.y },\n ...(vertices ?? []),\n { x: targetView.x, y: targetView.y },\n ];\n }\n\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 lineView\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 doNotResetActiveTargetForSelector?: string;\n doNotResetActiveTargetOutsideCanvas?: boolean;\n onActiveTargetChange(target: ActiveTarget | null): void;\n}\n\nexport type UseActiveTargetResult = ActiveTarget | null;\n\nexport function useActiveTarget({\n rootRef,\n activeTarget: _activeTarget,\n doNotResetActiveTargetForSelector,\n doNotResetActiveTargetOutsideCanvas,\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 (\n doNotResetActiveTargetOutsideCanvas\n ? rootIndex === 0\n : rootIndex <= 0 &&\n !(\n doNotResetActiveTargetForSelector &&\n path.some(\n (el) =>\n el instanceof Element &&\n el.matches(doNotResetActiveTargetForSelector)\n )\n )\n ) {\n setActiveTarget(null);\n }\n };\n document.addEventListener(\"click\", resetActiveTarget);\n return () => {\n document.removeEventListener(\"click\", resetActiveTarget);\n };\n }, [\n activeTarget,\n doNotResetActiveTargetOutsideCanvas,\n doNotResetActiveTargetForSelector,\n rootRef,\n ]);\n\n return activeTarget;\n}\n","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 { sortBy } from \"lodash\";\nimport type {\n ComputedEdgeLineConf,\n LineSegmentJumps,\n} from \"../../draw-canvas/interfaces\";\nimport type { NodePosition } from \"../../diagram/interfaces\";\nimport { intersect } from \"../../diagram/lines/intersect\";\n\ninterface LineSegment {\n start: NodePosition;\n end: NodePosition;\n}\n\nconst LINE_JUMP_BASE_SIZE = 6;\n\nexport function collectLineJumpsFactory() {\n const allJumps: LineSegmentJumps[] = [];\n const allLineSegments: LineSegment[] = [];\n\n return function collectLineJumps(\n points: NodePosition[],\n lineConf: ComputedEdgeLineConf\n ): Map<number, LineSegmentJumps> | null {\n const lineJumps: LineSegmentJumps[] = [];\n const lineSegments: LineSegment[] = [];\n\n // Line jumps for curved lines are not supported.\n if (lineConf.type !== \"curve\" || lineConf.curveType === \"curveLinear\") {\n for (let i = 0; i < points.length - 1; i++) {\n const start = points[i];\n const end = points[i + 1];\n const jumpPoints: NodePosition[] = [];\n const radius = LINE_JUMP_BASE_SIZE / 2 + lineConf.strokeWidth - 1;\n if (lineConf.jumps) {\n jumpLoop: for (const item of allLineSegments) {\n const point = lineJumpIntersect(\n start,\n end,\n item.start,\n item.end,\n radius\n );\n if (point) {\n for (const jump of allJumps) {\n for (const p of jump.jumpPoints) {\n const distance = Math.sqrt(\n Math.pow(point.x - p.x, 2) + Math.pow(point.y - p.y, 2)\n );\n if (distance < radius + jump.radius) {\n // Ignore this jump point if it's too close to an existing one\n continue jumpLoop;\n }\n }\n }\n\n jumpPoints.push(point);\n }\n }\n }\n\n if (jumpPoints.length > 0) {\n // 将交叉点按其在连线上的顺序排列\n const sortedJumpPoints = sortBy(\n jumpPoints,\n (p) => (p.x - points[0].x) ** 2 + (p.y - points[0].y) ** 2\n );\n\n const segJumps: LineSegmentJumps = {\n jumpPoints: sortedJumpPoints,\n index: i,\n radius,\n };\n allJumps.push(segJumps);\n lineJumps.push(segJumps);\n }\n\n lineSegments.push({ start, end });\n }\n\n // 同一连线上的不同线段交叉时,不产生跨线\n allLineSegments.push(...lineSegments);\n }\n\n return lineJumps.length > 0\n ? new Map(lineJumps.map((j) => [j.index, j]))\n : null;\n };\n}\n\nfunction lineJumpIntersect(\n p1: NodePosition,\n p2: NodePosition,\n p3: NodePosition,\n p4: NodePosition,\n radius: number\n): NodePosition | null {\n const point = intersect(\n [p1.x, p1.y],\n [p2.x, p2.y],\n [p3.x, p3.y],\n [p4.x, p4.y]\n );\n if (point) {\n // Check if the intersection point is too close to the line ends\n const r2 = radius * radius;\n for (const p of [p1, p2, p3, p4]) {\n const dx = point[0] - p.x;\n const dy = point[1] - p.y;\n if (dx * dx + dy * dy < r2) {\n return null;\n }\n }\n return { x: point[0], y: point[1] };\n }\n return null;\n}\n","import { useMemo } from \"react\";\nimport type {\n Cell,\n ComputedEdgeLineConf,\n DecoratorCell,\n DecoratorLineView,\n EdgeCell,\n EditableLine,\n} from \"../../draw-canvas/interfaces\";\nimport {\n isEdgeCell,\n isLineDecoratorCell,\n isStraightType,\n} from \"../../draw-canvas/processors/asserts\";\nimport { findNodeOrAreaDecorator } from \"../../draw-canvas/processors/findNodeOrAreaDecorator\";\nimport { getSmartLinePoints } from \"./processors/getSmartLinePoints\";\nimport { collectLineJumpsFactory } from \"./collectLineJumpsFactory\";\n\nexport function useEditableLineMap({\n cells,\n lineConfMap,\n}: {\n cells: Cell[];\n lineConfMap: WeakMap<EdgeCell | DecoratorCell, ComputedEdgeLineConf>;\n}): WeakMap<EdgeCell | DecoratorCell, EditableLine> {\n return useMemo(() => {\n const map = new WeakMap<EdgeCell | DecoratorCell, EditableLine>();\n\n const collectLineJumps = collectLineJumpsFactory();\n\n for (const cell of cells) {\n if (isEdgeCell(cell)) {\n const lineConf = lineConfMap.get(cell)!;\n\n const sourceNode = findNodeOrAreaDecorator(cells, cell.source);\n const targetNode = findNodeOrAreaDecorator(cells, cell.target);\n\n const hasOppositeEdge =\n isStraightType(cell.view?.type) &&\n cells.some(\n (c) =>\n isEdgeCell(c) &&\n c.source === c.target &&\n c.target === c.source &&\n isStraightType(c.view?.type)\n );\n const parallelGap = hasOppositeEdge ? lineConf.parallelGap : 0;\n\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 cell.view,\n parallelGap,\n cell.type\n )\n : null;\n\n if (points) {\n const jumpsMap = collectLineJumps(points, lineConf);\n\n map.set(cell, {\n edge: cell,\n points,\n source: sourceNode!,\n target: targetNode!,\n parallelGap,\n jumpsMap,\n });\n }\n } else if (isLineDecoratorCell(cell)) {\n const { source, target } = cell.view as DecoratorLineView;\n\n const points =\n source && target\n ? getSmartLinePoints(\n { ...source, width: 0, height: 0 },\n { ...target, width: 0, height: 0 },\n cell.view,\n 0,\n cell.type\n )\n : null;\n\n if (points) {\n const lineConf = lineConfMap.get(cell)!;\n const jumpsMap = collectLineJumps(points, lineConf);\n\n map.set(cell, {\n decorator: cell,\n points,\n parallelGap: 0,\n jumpsMap,\n });\n }\n }\n }\n return map;\n }, [cells, lineConfMap]);\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 autoCenterWhenCellsChange?: 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 autoCenterWhenCellsChange,\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 autoCenterWhenCellsChange,\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 autoCenterWhenCellsChange?: boolean;\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 autoCenterWhenCellsChange,\n}: UseAutoCenterOptions): UseAutoCenterResult {\n const [centered, setCentered] = useState(false);\n\n useEffect(() => {\n // Reset auto centering when nodes and decorators are all removed,\n // or when cells change and autoCenterWhenCellsChange is enabled.\n if (\n !cells.some((cell) => isNodeCell(cell) || isDecoratorCell(cell)) ||\n autoCenterWhenCellsChange\n ) {\n setCentered(false);\n }\n }, [cells, autoCenterWhenCellsChange]);\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 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 EditableLineCell,\n LineConnecterConf,\n LineMarker,\n} from \"../../draw-canvas/interfaces\";\nimport {\n isEdgeCell,\n isLineDecoratorCell,\n} 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 DEFAULT_DECORATOR_LINE_STROKE_COLOR,\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<EditableLineCell, 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<EditableLineCell, ComputedEdgeLineConf>();\n for (const cell of cells) {\n const isEdge = isEdgeCell(cell);\n const isLineDecorator = isLineDecoratorCell(cell);\n\n let lineConf: ComputedEdgeLineConf;\n if (isEdge) {\n const computedLineConf =\n (Array.isArray(defaultEdgeLines)\n ? transformLineConf(\n defaultEdgeLines.find((item) =>\n checkIfByTransform(item, { edge: cell })\n ),\n cell\n )\n : (\n __secret_internals.legacyDoTransform(\n { edge: cell },\n defaultEdgeLines\n ) as EdgeLineConf[]\n )?.find((item) => checkIfOfComputed(item))) ?? {};\n 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 } else {\n lineConf = {\n ...getDefaultLineConf(),\n showEndArrow: false,\n strokeColor: DEFAULT_DECORATOR_LINE_STROKE_COLOR,\n ...omitBy(cell.view, isUndefined),\n } as ComputedEdgeLineConf;\n }\n\n if (isEdge || isLineDecorator) {\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 const activeStrokeColor = lineConf.overrides?.active?.strokeColor;\n if (activeStrokeColor && activeStrokeColor !== lineConf.strokeColor) {\n const activeMarkerIndex = addMarker(\n {\n strokeColor: activeStrokeColor,\n markerType: type,\n },\n markers\n );\n if (placement === \"start\") {\n lineConf.$activeMarkerStartUrl = `url(#${markerPrefix}${activeMarkerIndex})`;\n } else {\n lineConf.$activeMarkerEndUrl = `url(#${markerPrefix}${activeMarkerIndex})`;\n }\n }\n\n if (isEdge) {\n const activeRelatedStrokeColor =\n lineConf.overrides?.activeRelated?.strokeColor;\n if (\n activeRelatedStrokeColor &&\n activeRelatedStrokeColor !== lineConf.strokeColor\n ) {\n const activeRelatedMarkerIndex = addMarker(\n {\n strokeColor: activeRelatedStrokeColor,\n markerType: type,\n },\n markers\n );\n if (placement === \"start\") {\n lineConf.$activeRelatedMarkerStartUrl = `url(#${markerPrefix}${activeRelatedMarkerIndex})`;\n } else {\n lineConf.$activeRelatedMarkerEndUrl = `url(#${markerPrefix}${activeRelatedMarkerIndex})`;\n }\n }\n }\n }\n map.set(cell, lineConf);\n }\n }\n return { lineConfMap: map, lineConnectorConf, markers };\n }, [cells, defaultEdgeLines, lineConnector, markerPrefix]);\n}\n\nfunction transformLineConf(\n lineConf: EdgeLineConf | undefined,\n edge: EdgeCell\n): EdgeLineConf {\n // Do not transform useBrick\n if (lineConf?.label?.useBrick) {\n const {\n label: { useBrick, ...restLabel },\n ...restConf\n } = lineConf;\n const computedRestConf = __secret_internals.legacyDoTransform(\n { edge },\n {\n ...restConf,\n label: restLabel,\n }\n ) as EdgeLineConf;\n return {\n ...computedRestConf,\n label: {\n ...computedRestConf.label,\n useBrick,\n },\n } as EdgeLineConf;\n }\n return __secret_internals.legacyDoTransform(\n { edge },\n lineConf\n ) as EdgeLineConf;\n}\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 jumps: false,\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\n// istanbul ignore next\nconst isMac = /mac/i.test(\n (\n navigator as Navigator & {\n userAgentData?: {\n platform: string;\n };\n }\n ).userAgentData?.platform ??\n navigator.platform ??\n navigator.userAgent\n);\n\n// istanbul ignore next\nfunction wheelData(event: WheelEvent) {\n // On Windows with normal mouse, deltaY is too big when scroll with ctrlKey pressed,\n // which cause the zooming too fast.\n // While on mac OS, we need to keep default behavior of d3-zoom.\n return (\n -event.deltaY *\n (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002) *\n (event.ctrlKey && isMac ? 10 : 1)\n );\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(\n () => zoom<SVGSVGElement, unknown>().wheelDelta(wheelData),\n []\n );\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-left:5px;padding-right:5px}.zoom-slider .ant-slider-vertical .ant-slider-rail{width:2px}.zoom-slider .ant-slider-vertical .ant-slider-handle{width:6px;height:6px;left: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;left:-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;top:0;left: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(73,126,255,0.1);stroke:none;stroke-width:0}.decorator-rect-container .rect-container{fill:rgba(73,126,255,0);stroke:rgba(73,126,255,0.7)}.cell.active .decorator-rect-container .rect-container{fill:rgba(73,126,255,0);stroke:rgba(73,126,255,1);stroke-width:2}.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(73,126,255,0.6);overflow:hidden}.decorator-container .horizontal{height:max-content;width:100%}.decorator-container .horizontal .text{min-height:var(--defaultSize)}.decorator-container .vertical{width:max-content;height:100%;writing-mode:vertical-lr;-webkit-text-orientation:upright;text-orientation:upright;letter-spacing:4px}.decorator-container .vertical .text{min-width:var(--defaultSize)}.line-label-container{overflow:visible;opacity:0}.line-label-container.ready{opacity:1}.line-label{position:absolute;display:block;transform:translate(-50%,-50%);white-space:pre-line;width:max-content;text-align:center}.line-label.text{font-size:11px;color:var(--color-secondary-text);font-weight:400;line-height:1.63636364}.motion:not(.visible){opacity:0}`, \"\"]);\n// Exports\nexport default ___CSS_LOADER_EXPORT___.toString();\n"],"names":["LineLabelComponent","_ref","edge","position","offset","label","text","onRendered","onClick","ready","React","className","classNames","x","y","LineLabelUseBrickComponent","LineLabelTextComponent","_ref2","refCallback","useCallback","element","ref","style","content","_ref3","useBrick","useMemo","checkIfOfComputed","memoizedData","useEffect","setTimeout","parentElement","ignoredCallback","ReactUseBrick","data","EdgeComponent","_editableLineMap$get","_motion","_motion2","_lineConf$overrides3","_lineConf$overrides4","_lineConf$animate$dur","_lineConf$overrides5","lineConfMap","editableLineMap","readOnly","active","activeRelated","onSwitchActiveTarget","pathRef","useRef","lineConf","get","points","linePoints","jumpsMap","line","curveLine","type","curveType","lineClipPathPrefix","uniqueId","labelPosition","setLabelPosition","useState","labelSize","setLabelSize","lineRect","setLineRect","updateLabelPosition","path","current","placement","pathLength","getTotalLength","halfPathLength","pathPoint","getPointAtLength","Math","min","max","direction","angle","p0","p1","length","atan2","abs","rect","getBBox","width","height","setPathLength","pathRefCallback","_element$getTotalLeng","_element$getTotalLeng2","_element$getBBox","call","view","labelElement","setLabelElement","resizeObserver","ResizeObserver","observerCallback","offsetWidth","offsetHeight","observe","disconnect","handleLabelRendered","onLabelClick","cellToTarget","onDoubleClick","e","_labelElement$firstEl","_labelElement$firstEl2","callLabelOnDoubleClick","preventDefault","stopPropagation","firstElementChild","mask","labelOffset","gap","left","top","offsetX","offsetY","halfWidth","halfHeight","cos","tan","sin","padding","getLabelMaskAndOffset","clipPathPoints","right","bottom","maskRight","maskBottom","map","join","markerStart","markerEnd","strokeColor","strokeWidth","motion","lineMarkers","getMarkers","_lineConf$overrides","_overrides$strokeColo","_overrides$strokeWidt","overrides","marker","_lineConf$$activeMark","_lineConf$$activeMark2","$activeMarkerStartUrl","$markerStartUrl","$activeMarkerEndUrl","$markerEndUrl","_lineConf$overrides2","_overrides$strokeColo2","_overrides$strokeWidt2","_lineConf$$activeRela","_lineConf$$activeRela2","$activeRelatedMarkerStartUrl","$activeRelatedMarkerEndUrl","motionPath","motionDuration","shape","radius","size","sqrt","_motion$speed","_motion3","speed","DEFAULT_MOTION_SPEED","hasMotion","some","item","clipPathUrl","undefined","id","d","fill","stroke","interactStrokeWidth","clipPath","dashed","dotted","animate","useAnimate","duration","DEFAULT_LINE_INTERACT_ANIMATE_DURATION","visible","dur","repeatCount","rotate","NodeComponent","node","degraded","degradedNodeLabel","defaultNodeBricks","onResize","value","memoizedValue","setMemoizedValue","prev","isEqual","useDeepMemo","specifiedUseBrick","observerRef","_defaultNodeBricks$fi","find","checkIfByTransform","String","__secret_internals","legacyDoTransform","prevObserver","observer","degradedRefCallBack","g","cx","cy","r","DEFAULT_ALL_POSITIONS","getSnapPositions","positions","snapPositions","_positions$split$flat","_positions$split","split","flatMap","pos","tuple","Error","HORIZONTAL_POSITIONS","VERTICAL_POSITIONS","handleMouseDown","event","_snap$object","action","cell","scale","layout","layoutOptions","activeTarget","cells","onCellsMoving","onCellsMoved","onCellResizing","onCellResized","updateCurActiveEditableLine","preActive","targetIsActive","shiftKey","activeTargets","targets","filter","target","sameTarget","isEdgeCell","isLineDecoratorCell","activeCells","actives","c","forEach","a","push","isContainerDecoratorCell","isNodeCell","containerId","includes","isAutoLayout","movableActiveCells","isDecoratorCell","snap","_snapToGrid$size","_snapToObject$distanc","_snapToObject$positio","intermediateSnap","grid","object","snapToGrid","snapToObject","DEFAULT_SNAP_GRID_SIZE","distance","DEFAULT_SNAP_OBJECT_DISTANCE","DEFAULT_SNAP_OBJECT_POSITIONS","normalizeSnapOptions","snapToObjectPositions","from","clientX","clientY","originals","firstOriginalPosition","snapToObjectTargets","objectCells","moved","handleMove","finished","movement","getMovement","snapMovement","newPositions","xAlign","yAlign","xAlignCell","yAlignCell","altKey","diffX","Infinity","diffY","snapToObjectDistance","xAlignFrom","yAlignFrom","xAlignTarget","yAlignTarget","xAlignToY","yAlignToX","targetPositions","originalPositions","originalPoint","Object","entries","horizontal","vertical","dX","dY","snapToGridSize","firstNewPosition","round","snapToGridMovement","snapToGridDiffX","snapToGridDiffY","_ref5","payloads","_ref4","index","_c$view$vertices","decorator","guideLines","source","vertices","v","_ref6","onMouseMove","onMouseUp","document","removeEventListener","addEventListener","selectAllText","range","createRange","selectNodeContents","selection","window","getSelection","removeAllRanges","addRange","decoratorComponents","Map","transform","onDecoratorTextEditing","onDecoratorTextChange","textRef","resizeHandleRef","editingLabel","setEditingLabel","currentLabel","setCurrentLabel","shouldEmitLabelChange","setShouldEmitLabelChange","recomputation","setRecomputation","titleForeignRect","setTitleForeignRect","handleEnableEdit","handleInput","textContent","handleBlur","uuidV4","_textRef$current","textParentEle","clientWidth","clientHeight","focus","editing","resizeHandle","onMouseDown","k","contentEditable","onInput","onBlur","isNoManualLayout","_cell$view$text","editingLabelInitialized","_ref$current","DecoratorComponent","SpecifiedComponent","console","error","computeContainerRect","minX","minY","maxX","maxY","n","isFinite","CellComponent","dragNodeToContainerActive","hoverCell","unrelatedCells","allowEdgeToArea","curActiveEditableLine","onCellContextMenu","onCellClick","onNodeBrickResize","onCellMouseEnter","onCellMouseLeave","lineEditorState","smartConnectLineState","setSmartConnectLineState","onConnect","setLineEditorState","onChangeEdgeView","useHoverStateContext","gRef","unrelated","containerRect","containCells","isEdgeSide","exitPosition","isEntry","entryPosition","handleContextMenu","handleCellClick","handleMouseEnter","handleMouseLeave","faded","onContextMenu","onMouseEnter","onMouseLeave","ConnectLineComponent","connectLineState","connectLineTo","setConnectLineTo","getConnectTo","reset","capture","connecting","getNewLineVertices","activeEditableLine","control","newVertices","x1","y1","exitPoint","entryPoint","i","vertex","simplifyVertices","LOOSE_CONTROL_TYPES","EditingLineComponent","options","hoverState","onChangeDecoratorView","movedRef","diff","otherPoints","axises","getFinalPosition","movementX","movementY","_","endpoint","p","editableLine","slice","point","axis","newDiff","newConnectTo","isEdge","_view$vertices","splice","handleBodyClick","body","activePointIndex","sourceView","targetView","cellType","isEditableEdgeLine","lineSettings","pick","getSmartLinePoints","relativePoints","getEditingLinePoints","$editingStartMarkerUrl","$editingEndMarkerUrl","editingStrokeColor","HoverStateContext","rootRef","unsetHoverStateTimeoutRef","activeEditableLines","setHoverState","HELPER_IMAGE","HELPER_RADIUS","HELPER_BG_RADIUS","HALF_HELPER_RADIUS","LineConnectorComponent","disabled","unsetTimeout","clearTimeout","unsetActivePointIndex","unsetHoverState","available","hasActiveEdge","DEFAULT_NODE_PADDING_FOR_SMART_LINES","halfPadding","pointerEvents","fillOpacity","ConnectPointComponent","key","getBoundingClientRect","handleMouseUp","xlinkHref","preserveAspectRatio","POINT_HELPER_IMAGE","END_POINT_HELPER_IMAGE","ANCHORED_POINT_HELPER_IMAGE","VERTEX_HELPER_IMAGE","POINT_HELPER_BG_SIZE","LineEditorComponent","movingCells","exitRef","entryRef","controlPointsRef","isLineDecorator","exit","entry","handleMouseDownFactory","handleStartMouseDown","handleEndMouseDown","controlPoints","_activeEditableLine$v","isStraightType","cursor","next","getStraightControlPoints","ns","ew","getControlPoints","controlElements","handlers","el","commonProps","_extends","opacity","SmartConnectLineComponent","getConnectLinePoints","SYMBOL_FOR_SIZE_INITIALIZED","Symbol","for","SYMBOL_FOR_LAYOUT_INITIALIZED","DEFAULT_NODE_SIZE","DEFAULT_NODE_GAP_H","DEFAULT_NODE_GAP_V","DEFAULT_AREA_WIDTH","DEFAULT_AREA_HEIGHT","DEFAULT_SCALE_RANGE_MIN","DEFAULT_SCALE_RANGE_MAX","DEFAULT_LINE_STROKE_COLOR","DEFAULT_LINE_STROKE_WIDTH","DEFAULT_DECORATOR_LINE_STROKE_COLOR","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","isNodeOrAreaDecoratorCell","getUnrelatedCells","existedTargets","Set","add","has","nodesMap","activeNodeIds","relatedNodeIds","set","handleKeyboard","keyCode","which","handleLasso","onLassoing","onLassoed","ctrlKey","button","x0","y0","handleNodeContainedChange","onContainerContainerChange","nodeCells","containerIds","nodePayloads","nodeCell","includeNodeFlag","payload","containerDecoratorCells","containerCell","containerLeft","containerRight","containerTop","containerBottom","containedChanges","_payload$containerCel","initializeCells","initialCells","defaultNodeSize","_cell$view","_cell$view2","b","every","targetA","targetB","transformToCenter","canvasWidth","canvasHeight","scaleRange","empty","updateCells","previousCells","reason","parent","isManualLayout","newCells","updateCandidates","shouldReCenter","previousSizeInitializedNodes","previousShouldCentered","previousNode","handled","downstreamNodeIds","parentNode","downstreamNodes","Boolean","rightMostNode","nextX","nextY","totalWidth","reduce","acc","positionedNodes","hasDecorators","getNodeView","without","dagreLayout","forceLayout","fixedPosition","center","updated","DEFAULT_CELL_ORDERS","decorators","insertCell","newCell","insertCells","findIndex","order","matchCellOrder","warn","targetIndex","findLastIndex","rootReducer","reducers","state","existedEdgeIndex","existedDecoratorIndex","matched","newState","move","layoutKey","fromEntries","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","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","stop","tick","ceil","log","alphaMin","alphaDecay","manuallyTickToTheEnd","nodeViewToNodeRect","DEFAULT_DIRECTIONS","lineView","parallelGap","_connectPoints$find$d","_connectPoints$find","_connectPoints$find$d2","_connectPoints$find2","_sourceDirections$","_targetDirections$","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","_vertices$","nextVertex","RectangleRelativeConnectPointsWithDirection","RectangleRelativeConnectPoints","getConnectPointsOfRectangle","useActiveTarget","_activeTarget","doNotResetActiveTargetForSelector","doNotResetActiveTargetOutsideCanvas","onActiveTargetChange","newActiveTarget","setActiveTarget","previous","activeTargetChangeInitialized","resetActiveTarget","composedPath","rootIndex","indexOf","Element","matches","findNodeOrAreaDecorator","LINE_JUMP_BASE_SIZE","lineJumpIntersect","p2","p3","p4","intersect","r2","dx","dy","useEditableLineMap","WeakMap","collectLineJumps","allJumps","allLineSegments","lineJumps","lineSegments","start","end","jumpPoints","jumps","jumpLoop","jump","pow","segJumps","sortBy","j","collectLineJumpsFactory","sourceNode","targetNode","_c$view","KeywordMap","normalizeAlignAxis","newX","match","Number","useLayout","zoomable","zoomer","autoCenterWhenCellsChange","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","_secret_internals$le","computedLineConf","Array","isArray","transformLineConf","showEndArrow","activeStrokeColor","activeMarkerIndex","activeRelatedStrokeColor","activeRelatedMarkerIndex","_lineConf$label","restLabel","restConf","computedRestConf","showStartArrow","useReady","isMac","test","_userAgentData$platfo","_userAgentData","navigator","userAgentData","platform","userAgent","wheelData","deltaY","deltaMode","useZoom","scrollable","pannable","draggable","ctrlDraggable","_scaleRange","grabbing","setGrabbing","setTransform","zoom","wheelDelta","scaleExtent","on","rootSelection","unsetZoom","stopImmediatePropagation","translateBy","wheelDeltaX","wheelDeltaY","___CSS_LOADER_EXPORT___","module","toString"],"sourceRoot":""}